Class JCRResource<F extends JCRResourceFactory>
java.lang.Object
org.ametys.plugins.repository.AbstractAmetysObject
org.ametys.plugins.repository.jcr.SimpleAmetysObject<F>
org.ametys.plugins.repository.jcr.DefaultAmetysObject<F>
org.ametys.plugins.repository.jcr.DefaultLockableAmetysObject<F>
org.ametys.plugins.explorer.resources.jcr.JCRResource<F>
- Type Parameters:
F
- the actual type of factory.
- All Implemented Interfaces:
CommentableResource
,ModifiableResource
,Resource
,ACLAmetysObject
,AmetysObject
,CopiableAmetysObject
,DublinCoreAwareAmetysObject
,ModifiableDublinCoreAwareAmetysObject
,JCRAmetysObject
,LockableAmetysObject
,LockAwareAmetysObject
,MetadataAwareAmetysObject
,ModifiableMetadataAwareAmetysObject
,ModifiableACLAmetysObject
,ModifiableAmetysObject
,RemovableAmetysObject
,TagAwareAmetysObject
,TaggableAmetysObject
,DataAndVersionAwareAmetysObject
,ModifiableDataAwareVersionableAmetysObject
,VersionableAmetysObject
,VersionAwareAmetysObject
public class JCRResource<F extends JCRResourceFactory>
extends DefaultLockableAmetysObject<F>
implements ModifiableResource, CopiableAmetysObject
Default implementation of an
Resource
, backed by a JCR node.-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The name of node holding the last contributorstatic final String
Constants for lastModified Metadatastatic final String
The name of node holding the creatorFields inherited from class org.ametys.plugins.repository.jcr.DefaultAmetysObject
PROTECTED_PROPERTIES
-
Constructor Summary
ConstructorDescriptionJCRResource
(javax.jcr.Node node, String parentPath, F factory) Creates anJCRResource
. -
Method Summary
Modifier and TypeMethodDescriptioncopyTo
(ModifiableTraversableAmetysObject parent, String name) Copy the currentAmetysObject
to the given object.copyTo
(ModifiableTraversableAmetysObject parent, String name, List<String> restrictTo) Copy the currentAmetysObject
to the given object if it is not in the restriction list.getAuthorFromRevision
(String revision) Get the author from old revisiongetComments
(boolean createThread) Get the thread holding the commentsRetrieves the creation date.Returns the last contributor of this resource.Get the Dublin Core contributor.Get the Dublin Core coverage.Get the Dublin Core creator.Get the Dublin Core date.Get the Dublin Core description.Get the Dublin Core format.Get the Dublin Core identifier.Get the Dublin Core language.Get the Dublin Core publisher.Get the Dublin Core relation.Get the Dublin Core rights.Get the Dublin Core source.String[]
Get the Dublin Core subject.Get the Dublin Core title.Get the Dublin Core type.Returns the data stream.String[]
Returns the keywords of this resource, as a String array.Returns the keywords of this resource, as a comme-separated String.Retrieves the login of the last contributor.Returns the last modification date.long
Returns the length of the data stream.Returns the data mime-type.Returns the path of this resource in its hierarchy (which is a subset of the whole repository).getTags()
Retrieves current tags.protected void
restoreFromNode
(javax.jcr.Node node) Restore from a nodevoid
setCreationDate
(Date creationDate) Set the creation date if this resource.void
setCreator
(UserIdentity author) Set the creator of the resourcevoid
setData
(InputStream stream, String mimeType, Date lastModified, UserIdentity author) Set binary data.void
setDCContributor
(String contributor) Set the Dublin Core contributor.void
setDCCoverage
(String coverage) Set the Dublin Core coverage.void
setDCCreator
(String creator) Set the Dublin Core creator.void
Set the Dublin Core date.void
setDCDescription
(String description) Set the Dublin Core description.void
setDCFormat
(String format) Set the Dublin Core format.void
setDCIdentifier
(String identifier) Set the Dublin Core identifier.void
setDCLanguage
(String language) Set the Dublin Core language.void
setDCPublisher
(String publisher) Set the Dublin Core publisher.void
setDCRelation
(String relation) Set the Dublin Core relation.void
setDCRights
(String rights) Set the Dublin Core rights.void
setDCSource
(String source) Set the Dublin Core source.void
setDCSubject
(String[] subject) Set the Dublin Core subject.void
setDCTitle
(String title) Set the Dublin Core title.void
Set the Dublin Core type.void
setKeywords
(String keywords) Set this resource's keywords.void
setKeywords
(String[] keywords) Set this resource's keywords.void
setLastContributor
(UserIdentity lastContributor) Set the last contributor of the resourcevoid
setLastModified
(Date lastModified) Set the last modified date if this resource.void
setMimeType
(String mimeType) Set this resource mime type.void
Tags.void
Untags.Methods inherited from class org.ametys.plugins.repository.jcr.DefaultLockableAmetysObject
getLockOwner, isLocked, lock, setLockInfoOnCurrentContext, unlock
Methods inherited from class org.ametys.plugins.repository.jcr.DefaultAmetysObject
addAllowedGroups, addAllowedProfilesForAnonymous, addAllowedProfilesForAnyConnectedUser, addAllowedUsers, addDeniedGroups, addDeniedProfilesForAnonymous, addDeniedProfilesForAnyConnectedUser, addDeniedUsers, addLabel, checkpoint, copyNode, disallowInheritance, getAllLabels, getAllRevisions, getBaseNode, getBaseVersion, getLabels, getLabels, getNode, getProfilesForAnonymousAndAnyConnectedUser, getProfilesForGroups, getProfilesForUsers, getRevision, getRevisionTimestamp, getRevisionTimestamp, getUnversionedDataHolder, getVersionHistory, isInheritanceDisallowed, removeAllowedGroups, removeAllowedGroups, removeAllowedProfilesForAnonymous, removeAllowedProfilesForAnyConnectedUser, removeAllowedUsers, removeAllowedUsers, removeDeniedGroups, removeDeniedGroups, removeDeniedProfilesForAnonymous, removeDeniedProfilesForAnyConnectedUser, removeDeniedUsers, removeDeniedUsers, removeLabel, restoreFromLabel, restoreFromRevision, switchToLabel, switchToRevision
Methods inherited from class org.ametys.plugins.repository.jcr.SimpleAmetysObject
_getFactory, _invalidateName, _invalidateParentPath, getId, getMetadataHolder, getName, getParent, getParentPath, getPath, needsSave, remove, rename, revertChanges, saveChanges
Methods inherited from class org.ametys.plugins.repository.AbstractAmetysObject
equals, hashCode, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.ametys.plugins.repository.AmetysObject
equals, getId, getName, getParent, getParentPath, getPath, hashCode
Methods inherited from interface org.ametys.plugins.repository.lock.LockableAmetysObject
lock, setLockInfoOnCurrentContext, unlock
Methods inherited from interface org.ametys.plugins.repository.lock.LockAwareAmetysObject
getLockOwner, isLocked
Methods inherited from interface org.ametys.plugins.repository.ModifiableAmetysObject
needsSave, rename, revertChanges, saveChanges
Methods inherited from interface org.ametys.plugins.repository.RemovableAmetysObject
remove
-
Field Details
-
CREATOR_NODE_NAME
The name of node holding the creator- See Also:
-
CREATION_DATE
Constants for lastModified Metadata- See Also:
-
CONTRIBUTOR_NODE_NAME
The name of node holding the last contributor- See Also:
-
-
Constructor Details
-
JCRResource
Creates anJCRResource
.- Parameters:
node
- the node backing thisAmetysObject
parentPath
- the parentPath in the Ametys hierarchyfactory
- the DefaultAmetysObjectFactory which created the AmetysObject
-
-
Method Details
-
setData
Description copied from interface:ModifiableResource
Set binary data.- Specified by:
setData
in interfaceModifiableResource
- Parameters:
stream
- TheInputStream
.mimeType
- The file mimetype.lastModified
- The date of last modification.author
- The author of last modification.
-
setLastModified
Description copied from interface:ModifiableResource
Set the last modified date if this resource.- Specified by:
setLastModified
in interfaceModifiableResource
- Parameters:
lastModified
- the last modified date.
-
setKeywords
Description copied from interface:ModifiableResource
Set this resource's keywords.- Specified by:
setKeywords
in interfaceModifiableResource
- Parameters:
keywords
- the comma-separated keywords.
-
setKeywords
Description copied from interface:ModifiableResource
Set this resource's keywords.- Specified by:
setKeywords
in interfaceModifiableResource
- Parameters:
keywords
- the keywords.
-
setMimeType
Description copied from interface:ModifiableResource
Set this resource mime type.- Specified by:
setMimeType
in interfaceModifiableResource
- Parameters:
mimeType
- the mime type.
-
setCreator
Description copied from interface:ModifiableResource
Set the creator of the resource- Specified by:
setCreator
in interfaceModifiableResource
- Parameters:
author
- The author
-
getInputStream
Description copied from interface:Resource
Returns the data stream.- Specified by:
getInputStream
in interfaceResource
- Returns:
- the data stream.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getMimeType
Description copied from interface:Resource
Returns the data mime-type.- Specified by:
getMimeType
in interfaceResource
- Returns:
- the data mime-type.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getLastModified
Description copied from interface:Resource
Returns the last modification date.- Specified by:
getLastModified
in interfaceResource
- Returns:
- the last modification date.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getLength
Description copied from interface:Resource
Returns the length of the data stream.- Specified by:
getLength
in interfaceResource
- Returns:
- the length of the data stream.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getCreator
Description copied from interface:Resource
Returns the last contributor of this resource.- Specified by:
getCreator
in interfaceResource
- Returns:
- the last contributor of this resource.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getAuthorFromRevision
Get the author from old revision- Parameters:
revision
- The revision- Returns:
- The user identity of the author or
null
if not found - Throws:
javax.jcr.RepositoryException
- If an error occurred
-
getKeywords
Description copied from interface:Resource
Returns the keywords of this resource, as a String array.- Specified by:
getKeywords
in interfaceResource
- Returns:
- the keywords of this resource.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getKeywordsAsString
Description copied from interface:Resource
Returns the keywords of this resource, as a comme-separated String.- Specified by:
getKeywordsAsString
in interfaceResource
- Returns:
- the keywords of this resource.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
restoreFromNode
Description copied from class:DefaultAmetysObject
Restore from a node- Overrides:
restoreFromNode
in classDefaultAmetysObject<F extends JCRResourceFactory>
- Parameters:
node
- The node to restore- Throws:
javax.jcr.RepositoryException
- If error occurs
-
getResourcePath
Description copied from interface:Resource
Returns the path of this resource in its hierarchy (which is a subset of the whole repository).- Specified by:
getResourcePath
in interfaceResource
- Returns:
- the path of this resource in its hierarchy.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getComments
Description copied from interface:CommentableResource
Get the thread holding the comments- Specified by:
getComments
in interfaceCommentableResource
- Parameters:
createThread
- True to force the creation of the thread if it does not exists.- Returns:
- the thread holding the comments or null if the tread does not exist
-
copyTo
public AmetysObject copyTo(ModifiableTraversableAmetysObject parent, String name) throws AmetysRepositoryException Description copied from interface:CopiableAmetysObject
Copy the currentAmetysObject
to the given object. Be careful, this method save changes.- Specified by:
copyTo
in interfaceCopiableAmetysObject
- Parameters:
parent
- The parent of the new object. Can not be null.name
- Name of the new object. Can be null. If null, the new name will be get from the copied object- Returns:
- the created object
- Throws:
AmetysRepositoryException
- if an error occurs.
-
copyTo
public AmetysObject copyTo(ModifiableTraversableAmetysObject parent, String name, List<String> restrictTo) throws AmetysRepositoryException Description copied from interface:CopiableAmetysObject
Copy the currentAmetysObject
to the given object if it is not in the restriction list. Be careful, this method save changes.- Specified by:
copyTo
in interfaceCopiableAmetysObject
- Parameters:
parent
- The parent of the new object. Can not be null.name
- Name of the new object. Can be null. If null, the new name will be get from the copied objectrestrictTo
- A restrict list ofCopiableAmetysObject
authorized to be copied- Returns:
- the created object
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getDCTitle
Description copied from interface:DublinCoreAwareAmetysObject
Get the Dublin Core title.- Specified by:
getDCTitle
in interfaceDublinCoreAwareAmetysObject
- Returns:
- the Dublin Core title. Can be null.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setDCTitle
Description copied from interface:ModifiableDublinCoreAwareAmetysObject
Set the Dublin Core title.- Specified by:
setDCTitle
in interfaceModifiableDublinCoreAwareAmetysObject
- Parameters:
title
- the Dublin Core title to set. Can be null.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getDCCreator
Description copied from interface:DublinCoreAwareAmetysObject
Get the Dublin Core creator.- Specified by:
getDCCreator
in interfaceDublinCoreAwareAmetysObject
- Returns:
- the Dublin Core creator. Can be null.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setDCCreator
Description copied from interface:ModifiableDublinCoreAwareAmetysObject
Set the Dublin Core creator.- Specified by:
setDCCreator
in interfaceModifiableDublinCoreAwareAmetysObject
- Parameters:
creator
- the Dublin Core creator to set. Can be null.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getDCSubject
Description copied from interface:DublinCoreAwareAmetysObject
Get the Dublin Core subject.- Specified by:
getDCSubject
in interfaceDublinCoreAwareAmetysObject
- Returns:
- the Dublin Core subject. Can be null.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setDCSubject
Description copied from interface:ModifiableDublinCoreAwareAmetysObject
Set the Dublin Core subject.- Specified by:
setDCSubject
in interfaceModifiableDublinCoreAwareAmetysObject
- Parameters:
subject
- the Dublin Core subject to set. Can be null.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getDCDescription
Description copied from interface:DublinCoreAwareAmetysObject
Get the Dublin Core description.- Specified by:
getDCDescription
in interfaceDublinCoreAwareAmetysObject
- Returns:
- the Dublin Core description. Can be null.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setDCDescription
Description copied from interface:ModifiableDublinCoreAwareAmetysObject
Set the Dublin Core description.- Specified by:
setDCDescription
in interfaceModifiableDublinCoreAwareAmetysObject
- Parameters:
description
- the Dublin Core description to set. Can be null.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getDCPublisher
Description copied from interface:DublinCoreAwareAmetysObject
Get the Dublin Core publisher.- Specified by:
getDCPublisher
in interfaceDublinCoreAwareAmetysObject
- Returns:
- the Dublin Core publisher. Can be null.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setDCPublisher
Description copied from interface:ModifiableDublinCoreAwareAmetysObject
Set the Dublin Core publisher.- Specified by:
setDCPublisher
in interfaceModifiableDublinCoreAwareAmetysObject
- Parameters:
publisher
- the Dublin Core publisher to set. Can be null.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getDCContributor
Description copied from interface:DublinCoreAwareAmetysObject
Get the Dublin Core contributor.- Specified by:
getDCContributor
in interfaceDublinCoreAwareAmetysObject
- Returns:
- the Dublin Core contributor. Can be null.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setDCContributor
Description copied from interface:ModifiableDublinCoreAwareAmetysObject
Set the Dublin Core contributor.- Specified by:
setDCContributor
in interfaceModifiableDublinCoreAwareAmetysObject
- Parameters:
contributor
- the Dublin Core contributor to set. Can be null.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getDCDate
Description copied from interface:DublinCoreAwareAmetysObject
Get the Dublin Core date.- Specified by:
getDCDate
in interfaceDublinCoreAwareAmetysObject
- Returns:
- the Dublin Core date. Can be null.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setDCDate
Description copied from interface:ModifiableDublinCoreAwareAmetysObject
Set the Dublin Core date.- Specified by:
setDCDate
in interfaceModifiableDublinCoreAwareAmetysObject
- Parameters:
date
- the Dublin Core date to set. Can be null.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getDCType
Description copied from interface:DublinCoreAwareAmetysObject
Get the Dublin Core type.- Specified by:
getDCType
in interfaceDublinCoreAwareAmetysObject
- Returns:
- the Dublin Core type. Can be null.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setDCType
Description copied from interface:ModifiableDublinCoreAwareAmetysObject
Set the Dublin Core type. You can use a constant from org.ametys.plugins.repository.dublincore.DCMITypes.- Specified by:
setDCType
in interfaceModifiableDublinCoreAwareAmetysObject
- Parameters:
type
- the Dublin Core type to set. Can be null.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getDCFormat
Description copied from interface:DublinCoreAwareAmetysObject
Get the Dublin Core format.- Specified by:
getDCFormat
in interfaceDublinCoreAwareAmetysObject
- Returns:
- the Dublin Core format. Can be null.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setDCFormat
Description copied from interface:ModifiableDublinCoreAwareAmetysObject
Set the Dublin Core format.- Specified by:
setDCFormat
in interfaceModifiableDublinCoreAwareAmetysObject
- Parameters:
format
- the Dublin Core format to set. Can be null.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getDCIdentifier
Description copied from interface:DublinCoreAwareAmetysObject
Get the Dublin Core identifier.- Specified by:
getDCIdentifier
in interfaceDublinCoreAwareAmetysObject
- Returns:
- the Dublin Core identifier. Can be null.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setDCIdentifier
Description copied from interface:ModifiableDublinCoreAwareAmetysObject
Set the Dublin Core identifier.- Specified by:
setDCIdentifier
in interfaceModifiableDublinCoreAwareAmetysObject
- Parameters:
identifier
- the Dublin Core identifier to set. Can be null.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getDCSource
Description copied from interface:DublinCoreAwareAmetysObject
Get the Dublin Core source.- Specified by:
getDCSource
in interfaceDublinCoreAwareAmetysObject
- Returns:
- the Dublin Core source. Can be null.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setDCSource
Description copied from interface:ModifiableDublinCoreAwareAmetysObject
Set the Dublin Core source.- Specified by:
setDCSource
in interfaceModifiableDublinCoreAwareAmetysObject
- Parameters:
source
- the Dublin Core source to set. Can be null.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getDCLanguage
Description copied from interface:DublinCoreAwareAmetysObject
Get the Dublin Core language.- Specified by:
getDCLanguage
in interfaceDublinCoreAwareAmetysObject
- Returns:
- the Dublin Core language. Can be null.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setDCLanguage
Description copied from interface:ModifiableDublinCoreAwareAmetysObject
Set the Dublin Core language.- Specified by:
setDCLanguage
in interfaceModifiableDublinCoreAwareAmetysObject
- Parameters:
language
- the Dublin Core language to set. Can be null.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getDCRelation
Description copied from interface:DublinCoreAwareAmetysObject
Get the Dublin Core relation.- Specified by:
getDCRelation
in interfaceDublinCoreAwareAmetysObject
- Returns:
- the Dublin Core relation. Can be null.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setDCRelation
Description copied from interface:ModifiableDublinCoreAwareAmetysObject
Set the Dublin Core relation.- Specified by:
setDCRelation
in interfaceModifiableDublinCoreAwareAmetysObject
- Parameters:
relation
- the Dublin Core relation to set. Can be null.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getDCCoverage
Description copied from interface:DublinCoreAwareAmetysObject
Get the Dublin Core coverage.- Specified by:
getDCCoverage
in interfaceDublinCoreAwareAmetysObject
- Returns:
- the Dublin Core coverage. Can be null.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setDCCoverage
Description copied from interface:ModifiableDublinCoreAwareAmetysObject
Set the Dublin Core coverage.- Specified by:
setDCCoverage
in interfaceModifiableDublinCoreAwareAmetysObject
- Parameters:
coverage
- the Dublin Core coverage to set. Can be null.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getDCRights
Description copied from interface:DublinCoreAwareAmetysObject
Get the Dublin Core rights.- Specified by:
getDCRights
in interfaceDublinCoreAwareAmetysObject
- Returns:
- the Dublin Core rights. Can be null.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setDCRights
Description copied from interface:ModifiableDublinCoreAwareAmetysObject
Set the Dublin Core rights.- Specified by:
setDCRights
in interfaceModifiableDublinCoreAwareAmetysObject
- Parameters:
rights
- the Dublin Core rights to set. Can be null.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getCreationDate
Description copied from interface:Resource
Retrieves the creation date.- Specified by:
getCreationDate
in interfaceResource
- Returns:
- the creation date.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setCreationDate
Description copied from interface:ModifiableResource
Set the creation date if this resource.- Specified by:
setCreationDate
in interfaceModifiableResource
- Parameters:
creationDate
- the creation date.
-
getLastContributor
Description copied from interface:Resource
Retrieves the login of the last contributor.- Specified by:
getLastContributor
in interfaceResource
- Returns:
- the login of the last contributor.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setLastContributor
Description copied from interface:ModifiableResource
Set the last contributor of the resource- Specified by:
setLastContributor
in interfaceModifiableResource
- Parameters:
lastContributor
- The last contributor
-
tag
Description copied from interface:TaggableAmetysObject
Tags.- Specified by:
tag
in interfaceTaggableAmetysObject
- Parameters:
tag
- the tag to add.- Throws:
AmetysRepositoryException
- if an error occurs.
-
untag
Description copied from interface:TaggableAmetysObject
Untags.- Specified by:
untag
in interfaceTaggableAmetysObject
- Parameters:
tag
- the tag to remove.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getTags
Description copied from interface:TagAwareAmetysObject
Retrieves current tags.- Specified by:
getTags
in interfaceTagAwareAmetysObject
- Returns:
- the current tags.
- Throws:
AmetysRepositoryException
- if an error occurs.
-