Package edu.ucsb.nceas.metacat.dataone
Class SystemMetadataFactory
java.lang.Object
edu.ucsb.nceas.metacat.dataone.SystemMetadataFactory
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.dataone.service.types.v2.SystemMetadata
createSystemMetadata
(String localId) Creates a system metadata object for insertion into metacatprotected static org.dataone.service.types.v1.ReplicationPolicy
Create a default ReplicationPolicy by reading properties from metacat's configuration and using those defaults.getDocumentInfoMap
(String docid) Get the document information in the format of a map.static File
getFileFromLegacyStore
(String localId) Get a file object for the given localId from the legacyStore.protected static long
length
(InputStream inputStream) protected static InputStream
readInputStreamFromLegacyStore
(org.dataone.service.types.v1.Identifier pid) This method is used for the HashStoreUpgrader class to read the object from the Metacat legacy store since the Hashtore hasn't been successfully converted.static long
Find the size (in bytes) of a stream.
-
Field Details
-
RESOURCE_MAP_PREFIX
- See Also:
-
-
Constructor Details
-
SystemMetadataFactory
public SystemMetadataFactory()
-
-
Method Details
-
createSystemMetadata
public static org.dataone.service.types.v2.SystemMetadata createSystemMetadata(String localId) throws McdbException, McdbDocNotFoundException, SQLException, IOException, AccessionNumberException, ClassNotFoundException, InsufficientKarmaException, edu.ucsb.nceas.utilities.ParseLSIDException, edu.ucsb.nceas.utilities.PropertyNotFoundException, org.dataone.service.exceptions.BaseException, NoSuchAlgorithmException, org.dataone.exceptions.MarshallingException, AccessControlException, HandlerException, SAXException, AccessException Creates a system metadata object for insertion into metacat- Parameters:
indexDataFile
- Indicate if we need to index data file.localId
- The local document identifier- Returns:
- sysMeta The system metadata object created
- Throws:
McdbException
McdbDocNotFoundException
SQLException
IOException
AccessionNumberException
ClassNotFoundException
InsufficientKarmaException
edu.ucsb.nceas.utilities.ParseLSIDException
edu.ucsb.nceas.utilities.PropertyNotFoundException
org.dataone.service.exceptions.BaseException
NoSuchAlgorithmException
org.dataone.exceptions.MarshallingException
AccessControlException
HandlerException
SAXException
AccessException
-
sizeOfStream
Find the size (in bytes) of a stream. Note: This needs to refactored out of MetacatHandler and into a utility when stream i/o in Metacat is evaluated.- Parameters:
is
- The InputStream of bytes- Returns:
- size The size in bytes of the input stream as a long
- Throws:
IOException
-
getDefaultReplicationPolicy
protected static org.dataone.service.types.v1.ReplicationPolicy getDefaultReplicationPolicy()Create a default ReplicationPolicy by reading properties from metacat's configuration and using those defaults. If the numReplicas property is not found, malformed, or less than or equal to zero, no policy needs to be set, so return null.- Returns:
- ReplicationPolicy, or null if no replication policy is needed
-
getDocumentInfoMap
public static Hashtable<String,String> getDocumentInfoMap(String docid) throws HandlerException, AccessControlException, org.dataone.exceptions.MarshallingException, IOException, McdbException, SAXException Get the document information in the format of a map.- Parameters:
docid
- the id of the document- Returns:
- a map containing the document information
- Throws:
HandlerException
AccessControlException
org.dataone.exceptions.MarshallingException
IOException
McdbException
SAXException
-
length
- Throws:
IOException
-
readInputStreamFromLegacyStore
protected static InputStream readInputStreamFromLegacyStore(org.dataone.service.types.v1.Identifier pid) throws FileNotFoundException This method is used for the HashStoreUpgrader class to read the object from the Metacat legacy store since the Hashtore hasn't been successfully converted.- Parameters:
pid
- the identifier the object. Note: We assume the pid's value equals the docid- Returns:
- the InputStream presentation of the object
- Throws:
FileNotFoundException
-
getFileFromLegacyStore
Get a file object for the given localId from the legacyStore. It will try both the document and data directories.- Parameters:
localId
- the local id (doc id) will be look.- Returns:
- the file which have the content of the local id
- Throws:
FileNotFoundException
-