Package edu.ucsb.nceas.metacat
Class IdentifierManager
java.lang.Object
edu.ucsb.nceas.metacat.IdentifierManager
Manage the relationship between Metacat local identifiers (LocalIDs) that are
codified as the (docid, rev) pair with globally unique string identifiers
(GUIDs) that are opaque strings. This class provides methods to manage these
identifiers, and to search for and look up LocalIDs based on their GUID and
vice versa. IdentifierManager is a singleton.
- Author:
- Matthew Jones
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionList<org.dataone.service.types.v1.Permission>
convertPermission
(int permission) void
createMapping
(String guid, String localId) Create a mapping between the dataone identifier and local docid in the identifier tablevoid
createMapping
(String guid, String localId, DBConnection dbConn) Create a mapping between the dataone identifier and local docid in the identifier tableboolean
existsInIdentifierTable
(org.dataone.service.types.v1.Identifier pid) Determine if the given pid exists on the identifier table.boolean
existsInXmlLRevisionTable
(String docid, int rev) IF the given localId exists on the xml_revisions tablegenerateLocalId
(String guid, int rev) generateLocalId
(String guid, int rev, boolean isSystemMetadata) Given a global identifier (guid), create a suitable local identifier that follows Metacat's docid semantics and format (scope.id.rev), and create a mapping between these two identifiers.org.dataone.service.types.v1.AccessPolicy
getAccessPolicy
(String guid) Lookup access policy from Metacatreturn a listing of all local ids in the object storegetAllPidsInChain
(String sid) Get all pids in the series chainreturn a listing of all guids in the object storegiven a local identifer, look up the guid.Get the list of identifiers which system metadata matches the given format id and original member node id and guid or series id start with the scheme (doi for example).getGUIDsByTimeRange
(Date start, Date end) Get the list of guids whose modification dates are in the range of the given start and end times.org.dataone.service.types.v1.Identifier
getHeadPID
(org.dataone.service.types.v1.Identifier sid) Get the pid of the head (current) version of objects match the specified sid.static IdentifierManager
Return the single instance of the manager after initializing it if it wasn't previously initialized.returns a list of system metadata-only guids since the given dateint
getLatestRevForLocalId
(String localId) return the newest rev for a given localIdgetLocalId
(String guid) Lookup a localId given the GUID.getLocalIdsWithNoSystemMetadata
(boolean includeRevisions, int serverLocation) return all local ids in the object store that do not have associated system metadatagetObjectFilePath
(String localId, boolean isScienceMetadata) Get the the file path for the given object local idorg.dataone.service.types.v2.SystemMetadata
getSystemMetadata
(String guid) return a hash of all of the info that is in the systemmetadata tablegetUpdatedSystemMetadataIds
(Date since) returns a list of system metadata-only guids since the given dateboolean
identifierExists
(String guid) Determine if an identifier exists already, returning true if so.boolean
mappingExists
(String guid) Determine if an identifier mapping exists already, returning true if so.org.dataone.service.types.v1.ObjectList
querySystemMetadata
(Date startTime, Date endTime, org.dataone.service.types.v1.ObjectFormatIdentifier objectFormatId, org.dataone.service.types.v1.NodeReference nodeId, int start, int count, org.dataone.service.types.v1.Identifier identifier, boolean isSID) query the systemmetadata table based on the given parametersvoid
removeMapping
(String guid, String localId) remove a mapping in the identifier tableboolean
boolean
systemMetadataPIDExists
(org.dataone.service.types.v1.Identifier pid) Determine if the specified identifier object exists or not.boolean
Check if the specified sid exists on the serial id field on the system metadata tableboolean
systemMetadataSIDExists
(org.dataone.service.types.v1.Identifier sid) Check if the specified sid object exists on the serial id field on the system metadata tablevoid
updateMapping
(String guid, String localId) update a mapping
-
Field Details
-
TYPE_SYSTEM_METADATA
- See Also:
-
TYPE_IDENTIFIER
- See Also:
-
-
Method Details
-
getInstance
Return the single instance of the manager after initializing it if it wasn't previously initialized.- Returns:
- the single IdentifierManager instance
-
getSystemMetadata
public org.dataone.service.types.v2.SystemMetadata getSystemMetadata(String guid) throws McdbDocNotFoundException return a hash of all of the info that is in the systemmetadata table- Parameters:
guid
-- Returns:
- Throws:
McdbDocNotFoundException
-
getLatestRevForLocalId
return the newest rev for a given localId- Parameters:
localId
-- Returns:
- Throws:
McdbDocNotFoundException
-
getLocalIdsWithNoSystemMetadata
return all local ids in the object store that do not have associated system metadata -
getAllLocalIds
return a listing of all local ids in the object store- Returns:
- a list of all local ids in metacat
-
getAllSystemMetadataGUIDs
return a listing of all guids in the object store- Returns:
- a list of all GUIDs in metacat
-
getAllPidsInChain
Get all pids in the series chain- Parameters:
sid
- the id of the series chain- Returns:
- a list of pid in the chain
- Throws:
SQLException
-
getUpdatedSystemMetadataIds
returns a list of system metadata-only guids since the given date- Returns:
- a list of system ids in metacat that do not correspond to objects TODO: need to check which server they are on
- Throws:
Exception
-
getLastModifiedDate
returns a list of system metadata-only guids since the given date- Returns:
- a list of system ids in metacat that do not correspond to objects TODO: need to check which server they are on
- Throws:
Exception
-
identifierExists
Determine if an identifier exists already, returning true if so. NOTE: looks in the identifier and system metadata table for a match (in that order) Can return true for both PIDs and SIDs.- Parameters:
guid
- the global identifier to look up- Returns:
- boolean true if the identifier exists
- Throws:
SQLException
-
mappingExists
Determine if an identifier mapping exists already, returning true if so.- Parameters:
guid
- the global identifier to look up- Returns:
- boolean true if the identifier exists
- Throws:
SQLException
-
generateLocalId
- Parameters:
guid
-rev
-- Returns:
-
generateLocalId
Given a global identifier (guid), create a suitable local identifier that follows Metacat's docid semantics and format (scope.id.rev), and create a mapping between these two identifiers. This effectively reserves both the global and the local identifier, as they will now be present in the identifier mapping table. REMOVED feature: If the incoming guid has the syntax of a Metacat docid (scope.id.rev), then simply use it. WHY: because "test.1.001" becomes "test.1.1" which is not correct for DataONE identifier use (those revision numbers are just chartacters and should not be interpreted)- Parameters:
guid
- the global string identifierrev
- the revision number to be used in the localId- Returns:
- String containing the localId to be used for Metacat operations
-
getGUID
given a local identifer, look up the guid. Throw McdbDocNotFoundException if the docid, rev is not found in the identifiers or systemmetadata tables- Parameters:
docid
- the docid to look uprev
- the revision of the docid to look up- Returns:
- String containing the mapped guid
- Throws:
McdbDocNotFoundException
- if the docid, rev is not found
-
getGUIDs
Get the list of identifiers which system metadata matches the given format id and original member node id and guid or series id start with the scheme (doi for example).- Parameters:
formatId
- the format id of the identifier must match the given formatId.nodeId
- the original member node of the identifier must match the given nodeId.scheme
- the guid or series id must start with the given scheme (doi for exampe)- Returns:
- the list of identifier string. An empty list will be returned if nothing was found.
-
getHeadPID
public org.dataone.service.types.v1.Identifier getHeadPID(org.dataone.service.types.v1.Identifier sid) throws SQLException Get the pid of the head (current) version of objects match the specified sid. 1. locate all candidate chain-ends for S1: determined by: seriesId == S1 AND (obsoletedBy == null OR obsoletedBy.seriesId != S1) these are the type1 and type2 ends If obsoletedBy is missing, we generally consider it a type 2 end except: there is another object in the chain (has the same series id) that obsoletes the missing object. 2. if only 1 candidate chain-end, return it as the HEAD 3. otherwise return the one in the chain with the latest dateUploaded value. However, we find that dateUpload doesn't refect the obsoletes information (espically on the cn), so we will check osoletes information as well. https://redmine.dataone.org/issues/7624- Parameters:
sid
- specified sid which should match.- Returns:
- the pid of the head version. The null will be returned if there is no pid found.
- Throws:
SQLException
-
systemMetadataSIDExists
public boolean systemMetadataSIDExists(org.dataone.service.types.v1.Identifier sid) throws SQLException Check if the specified sid object exists on the serial id field on the system metadata table- Parameters:
sid
-- Returns:
- true if it exists; false otherwise.
- Throws:
SQLException
-
systemMetadataSIDExists
Check if the specified sid exists on the serial id field on the system metadata table- Parameters:
id
-- Returns:
- true if it exists; false otherwise.
- Throws:
SQLException
-
systemMetadataPIDExists
public boolean systemMetadataPIDExists(org.dataone.service.types.v1.Identifier pid) throws SQLException Determine if the specified identifier object exists or not.- Parameters:
pid
- - the specified identifier- Returns:
- true if it is exists.
- Throws:
SQLException
NullPointerException
-
systemMetadataPIDExists
- Throws:
SQLException
-
updateMapping
update a mapping- Parameters:
guid
-localId
-
-
getAccessPolicy
public org.dataone.service.types.v1.AccessPolicy getAccessPolicy(String guid) throws McdbDocNotFoundException, AccessException Lookup access policy from Metacat- Parameters:
guid
-- Returns:
- Throws:
McdbDocNotFoundException
AccessException
-
convertPermission
-
getLocalId
Lookup a localId given the GUID. If the identifier is not found, throw an exception.- Parameters:
guid
- the global identifier to look up- Returns:
- String containing the corresponding LocalId
- Throws:
McdbDocNotFoundException
- if the identifier is not foundSQLException
-
querySystemMetadata
public org.dataone.service.types.v1.ObjectList querySystemMetadata(Date startTime, Date endTime, org.dataone.service.types.v1.ObjectFormatIdentifier objectFormatId, org.dataone.service.types.v1.NodeReference nodeId, int start, int count, org.dataone.service.types.v1.Identifier identifier, boolean isSID) throws SQLException, edu.ucsb.nceas.utilities.PropertyNotFoundException, ServiceException query the systemmetadata table based on the given parameters- Parameters:
startTime
-endTime
-objectFormat
-nodeId
-start
-count
-- Returns:
- ObjectList
- Throws:
SQLException
ServiceException
edu.ucsb.nceas.utilities.PropertyNotFoundException
-
createMapping
Create a mapping between the dataone identifier and local docid in the identifier table- Parameters:
guid
- the dataone identifierlocalId
- the local docid- Throws:
SQLException
AccessionNumberException
NumberFormatException
-
createMapping
public void createMapping(String guid, String localId, DBConnection dbConn) throws NumberFormatException, AccessionNumberException, SQLException Create a mapping between the dataone identifier and local docid in the identifier table- Parameters:
guid
- the dataone identifierlocalId
- the local metacat docid- Throws:
SQLException
AccessionNumberException
NumberFormatException
-
removeMapping
remove a mapping in the identifier table- Parameters:
guid
-localId
-
-
getObjectFilePath
public String getObjectFilePath(String localId, boolean isScienceMetadata) throws edu.ucsb.nceas.utilities.PropertyNotFoundException Get the the file path for the given object local id- Parameters:
localId
-isScienceMetadata
-- Returns:
- Throws:
edu.ucsb.nceas.utilities.PropertyNotFoundException
-
existsInXmlLRevisionTable
IF the given localId exists on the xml_revisions table- Parameters:
localId
-- Returns:
- Throws:
SQLException
-
existsInIdentifierTable
public boolean existsInIdentifierTable(org.dataone.service.types.v1.Identifier pid) throws SQLException Determine if the given pid exists on the identifier table.- Parameters:
pid
- must be a PID- Returns:
- true if it exists; false otherwise.
- Throws:
SQLException
-
getGUIDsByTimeRange
Get the list of guids whose modification dates are in the range of the given start and end times.- Parameters:
start
- the start time of the rangeend
- the end time of the range- Returns:
- list of guids whose modification dates are in the range
-