Package org.fcrepo.migration.handlers
Class BasicObjectVersionHandler
- java.lang.Object
-
- org.fcrepo.migration.handlers.BasicObjectVersionHandler
-
- All Implemented Interfaces:
FedoraObjectVersionHandler
public class BasicObjectVersionHandler extends Object implements FedoraObjectVersionHandler
- Author:
- mdurbin
-
-
Constructor Summary
Constructors Constructor Description BasicObjectVersionHandler(Fedora4Client client, MigrationIDMapper idMapper, String localFedoraServer, NamespacePrefixMapper namespacePrefixMapper)Basic object version handler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddDateEvent(com.hp.hpl.jena.sparql.modify.request.QuadDataAcc triplesToInsert, String eventTypeURI, String object)Utility function for adding a premis date event.protected StringgetCurrentTimeInXSDDateTime()Utility function to get the current time properly formatted for SPARQL or XML.protected booleanisDateProperty(String uri)Evaluates if an object/datastream property is a date.protected voidmapProperty(String origPred, String obj, com.hp.hpl.jena.sparql.modify.request.QuadAcc triplesToRemove, com.hp.hpl.jena.sparql.modify.request.QuadDataAcc triplesToInsert, Boolean isLiteral)WIP function to map properties from 3 to 4.protected voidmigrateDc(DatastreamVersion v, com.hp.hpl.jena.sparql.modify.request.QuadAcc triplesToRemove, com.hp.hpl.jena.sparql.modify.request.QuadDataAcc triplesToInsert)Migrates a DC datastream by shredding it into RDF properties and applying them directly to the object.protected voidmigrateRelsExt(DatastreamVersion v, com.hp.hpl.jena.sparql.modify.request.QuadAcc triplesToRemove, com.hp.hpl.jena.sparql.modify.request.QuadDataAcc triplesToInsert)Migrates a RELS-EXT datastream by splitting it apart into triples to update on the object it describes.protected voidmigrateRelsInt(DatastreamVersion v)Migrates a RELS-INT datastream by splitting it apart and updating the other datastreams it describes.voidprocessObjectVersions(Iterable<ObjectVersionReference> versions)Invoked to process a version of a Fedora 3 object.protected StringresolveInternalURI(String uri)Takes a URI (String) and if it appears to be an internal Fedora URI ("info:fedora/pid") the migrated URI for that resource is returned (and a placeholder is created in the repository if it doesn't already exist).voidsetCustomPropertyMapping(File propertiesFile)A property setter for the optional propertly that indicates a Properties file whose key value pairs represent custom mappings from fedora 3 properties to fedora 4 properties.voidsetImportExternal(boolean value)A property setter for a property that determines the handling of External (X) fedora 3 datastreams.voidsetImportRedirect(boolean value)A property setter for a property that determines the handling of Redirect (R) fedora 3 datastreams.voidsetSkipDisseminators(boolean skip)Sets a property that indicates whether fedora 2 disseminators will be skipped or not.protected voidupdateDatastreamProperties(ObjectReference obj, DatastreamVersion v, String dsPath)WIP utility function to update datastream properties.protected voidupdateDateTriple(com.hp.hpl.jena.sparql.modify.request.QuadAcc triplesToRemove, com.hp.hpl.jena.sparql.modify.request.QuadDataAcc triplesToInsert, String predicate, String object)Utility function for updating a date triple.protected voidupdateLiteralTriple(com.hp.hpl.jena.sparql.modify.request.QuadAcc triplesToRemove, com.hp.hpl.jena.sparql.modify.request.QuadDataAcc triplesToInsert, String predicate, String object)Utility function for updating a literal triple.protected voidupdateObjectProperties(ObjectVersionReference version, String objectPath, com.hp.hpl.jena.sparql.modify.request.QuadAcc triplesToRemove, com.hp.hpl.jena.sparql.modify.request.QuadDataAcc triplesToInsert)Updates object properties after mapping them from 3 to 4.protected voidupdateResourceProperties(String path, com.hp.hpl.jena.sparql.modify.request.QuadAcc triplesToRemove, com.hp.hpl.jena.sparql.modify.request.QuadDataAcc triplesToInsert, boolean isNonRDF)Utility function for updating a FedoraResource's properties.protected voidupdateUriTriple(com.hp.hpl.jena.sparql.modify.request.QuadAcc triplesToRemove, com.hp.hpl.jena.sparql.modify.request.QuadDataAcc triplesToInsert, String predicate, String object)Utility function for updating a uri triple.
-
-
-
Constructor Detail
-
BasicObjectVersionHandler
public BasicObjectVersionHandler(Fedora4Client client, MigrationIDMapper idMapper, String localFedoraServer, NamespacePrefixMapper namespacePrefixMapper)
Basic object version handler.- Parameters:
client- a fedora4 clientidMapper- the id mapperlocalFedoraServer- uri to fedora servernamespacePrefixMapper- a namespace prefix mapper.
-
-
Method Detail
-
setImportExternal
public void setImportExternal(boolean value)
A property setter for a property that determines the handling of External (X) fedora 3 datastreams. If true, the content of the URL to which those datastreams redirect is fetched and ingested as a fedora 4-managed non-RDF resource. If false (default), a non-RDF resource is created in fedora 4 that when fetched results in an HTTP redirect to the external url.- Parameters:
value- indicating if content is external
-
setImportRedirect
public void setImportRedirect(boolean value)
A property setter for a property that determines the handling of Redirect (R) fedora 3 datastreams. If true, the content of the URL to which those datastreams redirect is fetched and ingested as a fedora 4-managed non-RDF resource. If false (default), a non-RDF resource is created in fedora 4 that when fetched results in an HTTP redirect to the external url.- Parameters:
value- indicating if content is imported
-
setCustomPropertyMapping
public void setCustomPropertyMapping(File propertiesFile)
A property setter for the optional propertly that indicates a Properties file whose key value pairs represent custom mappings from fedora 3 properties to fedora 4 properties.- Parameters:
propertiesFile- a properties file containing mappings from foxml to fedoar 4 properties
-
setSkipDisseminators
public void setSkipDisseminators(boolean skip)
Sets a property that indicates whether fedora 2 disseminators will be skipped or not.- Parameters:
skip- indicates whether it is ok to skip fedora 2 disseminators.
-
processObjectVersions
public void processObjectVersions(Iterable<ObjectVersionReference> versions)
Description copied from interface:FedoraObjectVersionHandlerInvoked to process a version of a Fedora 3 object. All the metadata and content that changed from the previous version to the one represented by the current call is conventiently made available.- Specified by:
processObjectVersionsin interfaceFedoraObjectVersionHandler- Parameters:
versions- an iterable of Objects each encapsulating everything about a single version of a Fedora 3 object.
-
isDateProperty
protected boolean isDateProperty(String uri)
Evaluates if an object/datastream property is a date.- Parameters:
uri- The predicate in question.- Returns:
- True if the property is a date. False otherwise.
-
updateObjectProperties
protected void updateObjectProperties(ObjectVersionReference version, String objectPath, com.hp.hpl.jena.sparql.modify.request.QuadAcc triplesToRemove, com.hp.hpl.jena.sparql.modify.request.QuadDataAcc triplesToInsert)
Updates object properties after mapping them from 3 to 4.- Parameters:
version- Object version to referenceobjectPath- Destination path (in f4) for the object being migratedtriplesToRemove- List of triples to remove from resource.triplesToInsert- List of triples to add to resource.
-
mapProperty
protected void mapProperty(String origPred, String obj, com.hp.hpl.jena.sparql.modify.request.QuadAcc triplesToRemove, com.hp.hpl.jena.sparql.modify.request.QuadDataAcc triplesToInsert, Boolean isLiteral)
WIP function to map properties from 3 to 4. Feel free to override this to suit your needs.- Parameters:
origPred- Predicate of property to map from 3 to 4.obj- Object of property to map from 3 to 4.triplesToRemove- List of triples to remove from resource.triplesToInsert- List of triples to add to resource.isLiteral- TRUE if obj is a literal triple, FALSE if a URI
-
updateDatastreamProperties
protected void updateDatastreamProperties(ObjectReference obj, DatastreamVersion v, String dsPath)
WIP utility function to update datastream properties. Feel free to override this to suit your needs.- Parameters:
obj- Object to operate uponv- Version of the datasream to update.dsPath- resolved path (in f4) for the datastream
-
migrateRelsExt
protected void migrateRelsExt(DatastreamVersion v, com.hp.hpl.jena.sparql.modify.request.QuadAcc triplesToRemove, com.hp.hpl.jena.sparql.modify.request.QuadDataAcc triplesToInsert) throws IOException
Migrates a RELS-EXT datastream by splitting it apart into triples to update on the object it describes.- Parameters:
v- Version of the datasream to migrate.triplesToRemove- List of triples to remove from resource.triplesToInsert- List of triples to add to resource.- Throws:
IOException- on error
-
migrateRelsInt
protected void migrateRelsInt(DatastreamVersion v) throws IOException, RuntimeException
Migrates a RELS-INT datastream by splitting it apart and updating the other datastreams it describes.- Parameters:
v- Version of the datasream to migrate.- Throws:
IOException- on errorRuntimeException- on error
-
migrateDc
protected void migrateDc(DatastreamVersion v, com.hp.hpl.jena.sparql.modify.request.QuadAcc triplesToRemove, com.hp.hpl.jena.sparql.modify.request.QuadDataAcc triplesToInsert) throws IOException, RuntimeException
Migrates a DC datastream by shredding it into RDF properties and applying them directly to the object.- Parameters:
v- Version of the datasream to migrate.triplesToRemove- List of triples to remove from resource.triplesToInsert- List of triples to add to resource.- Throws:
IOException- on errorRuntimeException- on error
-
updateResourceProperties
protected void updateResourceProperties(String path, com.hp.hpl.jena.sparql.modify.request.QuadAcc triplesToRemove, com.hp.hpl.jena.sparql.modify.request.QuadDataAcc triplesToInsert, boolean isNonRDF) throws RuntimeException
Utility function for updating a FedoraResource's properties.- Parameters:
path- Path to the fedora resource to update.triplesToRemove- List of triples to remove from resource.triplesToInsert- List of triples to add to resource.isNonRDF- true if the resource is a non-RDF resource.- Throws:
RuntimeException- Possible FedoraExcpetions and IOExceptions
-
updateLiteralTriple
protected void updateLiteralTriple(com.hp.hpl.jena.sparql.modify.request.QuadAcc triplesToRemove, com.hp.hpl.jena.sparql.modify.request.QuadDataAcc triplesToInsert, String predicate, String object)
Utility function for updating a literal triple.- Parameters:
triplesToRemove- List of triples to remove from resource.triplesToInsert- List of triples to add to resource.predicate- Predicate of relationship (assumed to be URI).object- Object of relationship (assumed to be literal).
-
updateUriTriple
protected void updateUriTriple(com.hp.hpl.jena.sparql.modify.request.QuadAcc triplesToRemove, com.hp.hpl.jena.sparql.modify.request.QuadDataAcc triplesToInsert, String predicate, String object)
Utility function for updating a uri triple.- Parameters:
triplesToRemove- List of triples to remove from resource.triplesToInsert- List of triples to add to resource.predicate- Predicate of relationship (assumed to be URI).object- Object of relationship (assumed to URI).
-
resolveInternalURI
protected String resolveInternalURI(String uri)
Takes a URI (String) and if it appears to be an internal Fedora URI ("info:fedora/pid") the migrated URI for that resource is returned (and a placeholder is created in the repository if it doesn't already exist). Otherwise the value is returned unmodified.- Parameters:
uri- to be resolved- Returns:
- string which is either the migrated URI or the unmodified URI
-
updateDateTriple
protected void updateDateTriple(com.hp.hpl.jena.sparql.modify.request.QuadAcc triplesToRemove, com.hp.hpl.jena.sparql.modify.request.QuadDataAcc triplesToInsert, String predicate, String object)
Utility function for updating a date triple.- Parameters:
triplesToRemove- List of triples to remove from resource.triplesToInsert- List of triples to add to resource.predicate- Predicate of relationship (assumed to be URI).object- Object of relationship (assumed to be literal).
-
addDateEvent
protected void addDateEvent(com.hp.hpl.jena.sparql.modify.request.QuadDataAcc triplesToInsert, String eventTypeURI, String object)
Utility function for adding a premis date event. Current implementation utilizes a blank node.- Parameters:
triplesToInsert- List of triples to add to resource.eventTypeURI- Type of premis event.object- Object of relationship (e.g. the date. Assumed to be literal).
-
getCurrentTimeInXSDDateTime
protected String getCurrentTimeInXSDDateTime()
Utility function to get the current time properly formatted for SPARQL or XML.- Returns:
- String representing current time in XSDdateTime format (null if error).
-
-