Project

General

Profile

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

    
6
import org.dataone.service.types.v1.SystemMetadata;
7

    
8
import edu.ucsb.nceas.metacat.IdentifierManager;
9
import edu.ucsb.nceas.metacat.McdbDocNotFoundException;
10

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