Project

General

Profile

1
/**
2
 * 
3
 */
4
package edu.ucsb.nceas.metacat.dataone;
5

    
6
import edu.ucsb.nceas.metacat.IdentifierManager;
7
import edu.ucsb.nceas.metacat.McdbDocNotFoundException;
8

    
9
/**
10
 * @author berkley
11
 *
12
 * Class to handle SystemMetadata object in the metacat system
13
 */
14
public class SystemMetadataManager
15
{
16
    //singleton instance
17
    private static SystemMetadataManager manager = null;
18
    private IdentifierManager idManager = null;
19
    
20
    /**
21
     * private constructor.  Use the singleton getInstance() method to use
22
     * this class
23
     */
24
    private SystemMetadataManager()
25
    {
26
        idManager = IdentifierManager.getInstance();
27
    }
28
    
29
    /**
30
     * get a singleton instance of this class
31
     */
32
    public static SystemMetadataManager getInstance()
33
    {
34
        if(manager == null)
35
        {
36
            manager = new SystemMetadataManager();
37
        }
38
        return manager;
39
    }
40
    
41
    /**
42
     * return true if the document represented by guid has a system metadata
43
     * document registered in the systemmetadata table
44
     * @param guid
45
     * @return
46
     */
47
    public boolean documentHasSystemMetadata(String guid)
48
    {
49
        boolean hassm = false;
50
        try
51
        {
52
            String smid = idManager.getSystemMetadataLocalId(guid);
53
            if(smid != null && !smid.trim().equals(""))
54
            {
55
                hassm = true;
56
            }
57
        }
58
        catch(McdbDocNotFoundException me)
59
        {
60
            //if this exception is thrown, the doc with guid does not have
61
            //sys metadata
62
        }
63
        
64
        return hassm;
65
    }
66
}
(4-4/4)