Package org.fcrepo.kernel.impl.models
Class FedoraResourceImpl
- java.lang.Object
-
- org.fcrepo.kernel.impl.models.FedoraResourceImpl
-
- All Implemented Interfaces:
FedoraResource
- Direct Known Subclasses:
BinaryImpl
,ContainerImpl
,NonRdfSourceDescriptionImpl
,TimeMapImpl
,TombstoneImpl
public class FedoraResourceImpl extends Object implements FedoraResource
Implementation of a Fedora resource, containing functionality common to the more concrete resource implementations.- Author:
- bbpennel
-
-
Field Summary
Fields Modifier and Type Field Description protected FedoraId
fedoraId
protected ResourceFactory
resourceFactory
protected Transaction
transaction
-
Constructor Summary
Constructors Modifier Constructor Description protected
FedoraResourceImpl(FedoraId fedoraId, Transaction transaction, PersistentStorageSessionManager pSessionManager, ResourceFactory resourceFactory, UserTypesCache userTypesCache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FedoraResource
findMementoByDatetime(Instant mementoDatetime)
Retrieve the Memento with the closest datetime to the request.FedoraResource
getAcl()
Get the ACL of this resourceOptional<FedoraId>
getArchivalGroupId()
Get the FedoraId for the Archival Group of this resource, if it existsStream<FedoraResource>
getChildren(Boolean recursive)
Get the children of this resource, possibly recursivelyFedoraResource
getContainer()
Get the container of this resourceString
getCreatedBy()
Get the created by valueInstant
getCreatedDate()
Get the date this resource was createdFedoraResource
getDescribedResource()
Get the resource described by this resourceFedoraResource
getDescription()
Get the description for this resourceString
getEtagValue()
Construct an ETag value for the resource.FedoraId
getFedoraId()
Get the FedoraId for this resource.String
getId()
Get the fedora identifier for this resourceString
getInteractionModel()
Get the resource's interaction model.String
getLastModifiedBy()
Get the last modified by valueInstant
getLastModifiedDate()
Get the date this resource was last modifiedInstant
getMementoDatetime()
Retrieve the mementoDatetime property and return it as an InstantFedoraResource
getOriginalResource()
Get the Original Resource for which this resource is a memento or timemap for.FedoraResource
getParent()
Get the resource which contains this resource.FedoraId
getParentId()
Get the FedoraId of this resource's parentprotected PersistentStorageSession
getSession()
String
getStateToken()
Construct a State Token value for the resource.List<URI>
getSystemTypes(boolean forRdf)
Get only the system defined types from their RDF.TimeMap
getTimeMap()
Get the TimeMap/LDPCv of this resourceRdfStream
getTriples()
Return the RDF properties for this resource.List<URI>
getTypes()
Get the RDF:type values for this resource, this is usually the combination of getUserTypes and getSystemTypes(false) to get ALL the types.List<URI>
getUserTypes()
Get only the user provided types from their RDF.boolean
hasProperty(String relPath)
Does this resource have a propertyboolean
hasType(String type)
Check if this object uses a given RDF typeboolean
isAcl()
Returns true if this resource is an ACL.boolean
isMemento()
Returns true if this resource is a Memento.boolean
isOriginalResource()
Check if a resource is an original resource (ie versionable, as opposed to non-versionable resources like mementos, timemaps, and acls).protected List<URI>
resolveSystemTypes(boolean forRdf)
void
setArchivalGroupId(FedoraId archivalGroupId)
protected void
setCreatedBy(String createdBy)
protected void
setCreatedDate(Instant createdDate)
protected void
setEtag(String etag)
void
setInteractionModel(String interactionModel)
void
setIsArchivalGroup(boolean isArchivalGroup)
void
setIsMemento(boolean isMemento)
protected void
setLastModifiedBy(String lastModifiedBy)
protected void
setLastModifiedDate(Instant lastModifiedDate)
protected void
setMementoDatetime(Instant mementoDatetime)
protected void
setParentId(FedoraId parentId)
protected void
setStateToken(String stateToken)
protected void
setTypes(List<URI> types)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.fcrepo.kernel.api.models.FedoraResource
getChildren
-
-
-
-
Field Detail
-
resourceFactory
protected final ResourceFactory resourceFactory
-
transaction
protected final Transaction transaction
-
-
Constructor Detail
-
FedoraResourceImpl
protected FedoraResourceImpl(FedoraId fedoraId, Transaction transaction, PersistentStorageSessionManager pSessionManager, ResourceFactory resourceFactory, UserTypesCache userTypesCache)
-
-
Method Detail
-
getId
public String getId()
Description copied from interface:FedoraResource
Get the fedora identifier for this resource- Specified by:
getId
in interfaceFedoraResource
- Returns:
- the fedora identifier
-
getChildren
public Stream<FedoraResource> getChildren(Boolean recursive)
Description copied from interface:FedoraResource
Get the children of this resource, possibly recursively- Specified by:
getChildren
in interfaceFedoraResource
- Parameters:
recursive
- whether to recursively fetch child resources- Returns:
- a stream of Fedora resources
-
getContainer
public FedoraResource getContainer()
Description copied from interface:FedoraResource
Get the container of this resource- Specified by:
getContainer
in interfaceFedoraResource
- Returns:
- the container of this resource
-
getOriginalResource
public FedoraResource getOriginalResource()
Description copied from interface:FedoraResource
Get the Original Resource for which this resource is a memento or timemap for. If this resource is not a memento or timemap, then it is the original.- Specified by:
getOriginalResource
in interfaceFedoraResource
- Returns:
- the original resource for this
-
getTimeMap
public TimeMap getTimeMap()
Description copied from interface:FedoraResource
Get the TimeMap/LDPCv of this resource- Specified by:
getTimeMap
in interfaceFedoraResource
- Returns:
- the container for TimeMap/LDPCv of this resource
-
getMementoDatetime
public Instant getMementoDatetime()
Description copied from interface:FedoraResource
Retrieve the mementoDatetime property and return it as an Instant- Specified by:
getMementoDatetime
in interfaceFedoraResource
- Returns:
- the Instant for this resource
-
isMemento
public boolean isMemento()
Description copied from interface:FedoraResource
Returns true if this resource is a Memento.- Specified by:
isMemento
in interfaceFedoraResource
- Returns:
- true if the resource is a Memento.
-
isAcl
public boolean isAcl()
Description copied from interface:FedoraResource
Returns true if this resource is an ACL.- Specified by:
isAcl
in interfaceFedoraResource
- Returns:
- true if the resource is an ACL.
-
findMementoByDatetime
public FedoraResource findMementoByDatetime(Instant mementoDatetime)
Description copied from interface:FedoraResource
Retrieve the Memento with the closest datetime to the request.- Specified by:
findMementoByDatetime
in interfaceFedoraResource
- Parameters:
mementoDatetime
- The requested date time.- Returns:
- The closest Memento or null.
-
getAcl
public FedoraResource getAcl()
Description copied from interface:FedoraResource
Get the ACL of this resource- Specified by:
getAcl
in interfaceFedoraResource
- Returns:
- the container for ACL of this resource
-
hasProperty
public boolean hasProperty(String relPath)
Description copied from interface:FedoraResource
Does this resource have a property- Specified by:
hasProperty
in interfaceFedoraResource
- Parameters:
relPath
- the given path- Returns:
- the boolean value whether the resource has a property
-
getCreatedDate
public Instant getCreatedDate()
Description copied from interface:FedoraResource
Get the date this resource was created- Specified by:
getCreatedDate
in interfaceFedoraResource
- Returns:
- created date
-
getLastModifiedDate
public Instant getLastModifiedDate()
Description copied from interface:FedoraResource
Get the date this resource was last modified- Specified by:
getLastModifiedDate
in interfaceFedoraResource
- Returns:
- last modified date
-
hasType
public boolean hasType(String type)
Description copied from interface:FedoraResource
Check if this object uses a given RDF type- Specified by:
hasType
in interfaceFedoraResource
- Parameters:
type
- the given type- Returns:
- whether the object has the given type
-
getTypes
public List<URI> getTypes()
Description copied from interface:FedoraResource
Get the RDF:type values for this resource, this is usually the combination of getUserTypes and getSystemTypes(false) to get ALL the types.- Specified by:
getTypes
in interfaceFedoraResource
- Returns:
- a list of types for this resource
-
getSystemTypes
public List<URI> getSystemTypes(boolean forRdf)
Description copied from interface:FedoraResource
Get only the system defined types from their RDF.- Specified by:
getSystemTypes
in interfaceFedoraResource
- Parameters:
forRdf
- whether we only want types for displaying in a RDF body.- Returns:
- a list of types from the user provided RDF.
-
getUserTypes
public List<URI> getUserTypes()
Description copied from interface:FedoraResource
Get only the user provided types from their RDF.- Specified by:
getUserTypes
in interfaceFedoraResource
- Returns:
- a list of types from the user provided RDF.
-
getTriples
public RdfStream getTriples()
Description copied from interface:FedoraResource
Return the RDF properties for this resource.- Specified by:
getTriples
in interfaceFedoraResource
- Returns:
- the RDF properties of this object.
-
getEtagValue
public String getEtagValue()
Description copied from interface:FedoraResource
Construct an ETag value for the resource.- Specified by:
getEtagValue
in interfaceFedoraResource
- Returns:
- constructed etag value
-
getStateToken
public String getStateToken()
Description copied from interface:FedoraResource
Construct a State Token value for the resource.- Specified by:
getStateToken
in interfaceFedoraResource
- Returns:
- constructed state-token value
-
isOriginalResource
public boolean isOriginalResource()
Description copied from interface:FedoraResource
Check if a resource is an original resource (ie versionable, as opposed to non-versionable resources like mementos, timemaps, and acls).- Specified by:
isOriginalResource
in interfaceFedoraResource
- Returns:
- whether the resource is an original resource.
-
getDescription
public FedoraResource getDescription()
Description copied from interface:FedoraResource
Get the description for this resource- Specified by:
getDescription
in interfaceFedoraResource
- Returns:
- the description for this resource
-
getDescribedResource
public FedoraResource getDescribedResource()
Description copied from interface:FedoraResource
Get the resource described by this resource- Specified by:
getDescribedResource
in interfaceFedoraResource
- Returns:
- the resource being described
-
getSession
protected PersistentStorageSession getSession()
-
getParent
public FedoraResource getParent() throws PathNotFoundException
Description copied from interface:FedoraResource
Get the resource which contains this resource.- Specified by:
getParent
in interfaceFedoraResource
- Returns:
- the parent resource
- Throws:
PathNotFoundException
- thrown if the parent cannot be found
-
getParentId
public FedoraId getParentId()
Description copied from interface:FedoraResource
Get the FedoraId of this resource's parent- Specified by:
getParentId
in interfaceFedoraResource
- Returns:
- the parent resource's id
-
getCreatedBy
public String getCreatedBy()
Description copied from interface:FedoraResource
Get the created by value- Specified by:
getCreatedBy
in interfaceFedoraResource
- Returns:
- created by
-
getLastModifiedBy
public String getLastModifiedBy()
Description copied from interface:FedoraResource
Get the last modified by value- Specified by:
getLastModifiedBy
in interfaceFedoraResource
- Returns:
- last modified by
-
getFedoraId
public FedoraId getFedoraId()
Description copied from interface:FedoraResource
Get the FedoraId for this resource.- Specified by:
getFedoraId
in interfaceFedoraResource
- Returns:
- the FedoraId identifier.
-
getInteractionModel
public String getInteractionModel()
Description copied from interface:FedoraResource
Get the resource's interaction model.- Specified by:
getInteractionModel
in interfaceFedoraResource
- Returns:
- the interaction model.
-
setParentId
protected void setParentId(FedoraId parentId)
- Parameters:
parentId
- the parentId to set
-
setLastModifiedDate
protected void setLastModifiedDate(Instant lastModifiedDate)
- Parameters:
lastModifiedDate
- the lastModifiedDate to set
-
setLastModifiedBy
protected void setLastModifiedBy(String lastModifiedBy)
- Parameters:
lastModifiedBy
- the lastModifiedBy to set
-
setCreatedDate
protected void setCreatedDate(Instant createdDate)
- Parameters:
createdDate
- the createdDate to set
-
setCreatedBy
protected void setCreatedBy(String createdBy)
- Parameters:
createdBy
- the createdBy to set
-
setMementoDatetime
protected void setMementoDatetime(Instant mementoDatetime)
- Parameters:
mementoDatetime
- the mementoDatetime to set
-
setStateToken
protected void setStateToken(String stateToken)
- Parameters:
stateToken
- the stateToken to set
-
setIsMemento
public void setIsMemento(boolean isMemento)
- Parameters:
isMemento
- indicates if the resource is a memento
-
setIsArchivalGroup
public void setIsArchivalGroup(boolean isArchivalGroup)
- Parameters:
isArchivalGroup
- true if the resource is an AG
-
setInteractionModel
public void setInteractionModel(String interactionModel)
- Parameters:
interactionModel
- the resource's interaction model
-
resolveSystemTypes
protected List<URI> resolveSystemTypes(boolean forRdf)
-
setArchivalGroupId
public void setArchivalGroupId(FedoraId archivalGroupId)
- Parameters:
archivalGroupId
- the FedoraId of the Archival Group for this resource
-
getArchivalGroupId
public Optional<FedoraId> getArchivalGroupId()
Description copied from interface:FedoraResource
Get the FedoraId for the Archival Group of this resource, if it exists- Specified by:
getArchivalGroupId
in interfaceFedoraResource
- Returns:
- an Optional containing the FedoraId
-
-