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:
ModifiableResource,Resource,ACLAmetysObject,AmetysObject,CopiableAmetysObject,DublinCoreAwareAmetysObject,ModifiableDublinCoreAwareAmetysObject,JCRAmetysObject,LockableAmetysObject,LockAwareAmetysObject,MetadataAwareAmetysObject,ModifiableMetadataAwareAmetysObject,ModifiableACLAmetysObject,ModifiableAmetysObject,RemovableAmetysObject,TagAwareAmetysObject,TaggableAmetysObject,TrashableAmetysObject,DataAndVersionAwareAmetysObject,ModifiableDataAwareVersionableAmetysObject,VersionableAmetysObject,VersionAwareAmetysObject
- Direct Known Subclasses:
File
public class JCRResource<F extends JCRResourceFactory>
extends DefaultLockableAmetysObject<F>
implements ModifiableResource, CopiableAmetysObject, TrashableAmetysObject
Default implementation of an
Resource, backed by a JCR node.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of node holding the last contributorstatic final StringConstants for lastModified Metadatastatic final StringThe name of node holding the creatorFields inherited from class org.ametys.plugins.repository.jcr.DefaultAmetysObject
__VERSION_COMPARATOR, PROTECTED_PROPERTIES -
Constructor Summary
ConstructorsConstructorDescriptionJCRResource(javax.jcr.Node node, String parentPath, F factory) Creates anJCRResource. -
Method Summary
Modifier and TypeMethodDescriptioncopyTo(ModifiableTraversableAmetysObject parent, String name) Copy the currentAmetysObjectto the given object.copyTo(ModifiableTraversableAmetysObject parent, String name, List<String> restrictTo) Copy the currentAmetysObjectto the given object if it is not in the restriction list.getAuthorFromRevision(String revision) Get the author from old revisionRetrieves 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.longReturns 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.Move thisAmetysObjectto the trash.protected voidrestoreFromNode(javax.jcr.Node node) Restore from a nodeRestore thisAmetysObjectfrom the trash.voidsetCreationDate(Date creationDate) Set the creation date if this resource.voidsetCreator(UserIdentity author) Set the creator of the resourcevoidsetData(InputStream stream, String mimeType, Date lastModified, UserIdentity author) Set binary data.voidsetDCContributor(String contributor) Set the Dublin Core contributor.voidsetDCCoverage(String coverage) Set the Dublin Core coverage.voidsetDCCreator(String creator) Set the Dublin Core creator.voidSet the Dublin Core date.voidsetDCDescription(String description) Set the Dublin Core description.voidsetDCFormat(String format) Set the Dublin Core format.voidsetDCIdentifier(String identifier) Set the Dublin Core identifier.voidsetDCLanguage(String language) Set the Dublin Core language.voidsetDCPublisher(String publisher) Set the Dublin Core publisher.voidsetDCRelation(String relation) Set the Dublin Core relation.voidsetDCRights(String rights) Set the Dublin Core rights.voidsetDCSource(String source) Set the Dublin Core source.voidsetDCSubject(String[] subject) Set the Dublin Core subject.voidsetDCTitle(String title) Set the Dublin Core title.voidSet the Dublin Core type.voidsetKeywords(String keywords) Set this resource's keywords.voidsetKeywords(String[] keywords) Set this resource's keywords.voidsetLastContributor(UserIdentity lastContributor) Set the last contributor of the resourcevoidsetLastModified(Date lastModified) Set the last modified date if this resource.voidsetMimeType(String mimeType) Set this resource mime type.voidTags.voidUntags.Methods inherited from class org.ametys.plugins.repository.jcr.DefaultLockableAmetysObject
getLockOwner, isLocked, lock, setLockInfoOnCurrentContext, unlockMethods 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, switchToRevisionMethods inherited from class org.ametys.plugins.repository.jcr.SimpleAmetysObject
_getFactory, _invalidateName, _invalidateParentPath, getId, getMetadataHolder, getName, getParent, getParentPath, getPath, needsSave, remove, rename, revertChanges, saveChangesMethods inherited from class org.ametys.plugins.repository.AbstractAmetysObject
equals, hashCode, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.ametys.plugins.repository.AmetysObject
equals, getId, getName, getParent, getParentPath, getPath, hashCodeMethods inherited from interface org.ametys.plugins.repository.jcr.JCRAmetysObject
getNodeMethods inherited from interface org.ametys.plugins.repository.lock.LockableAmetysObject
lock, setLockInfoOnCurrentContext, unlockMethods inherited from interface org.ametys.plugins.repository.lock.LockAwareAmetysObject
getLockOwner, isLockedMethods inherited from interface org.ametys.plugins.repository.ModifiableAmetysObject
needsSave, rename, revertChanges, saveChangesMethods inherited from interface org.ametys.plugins.repository.metadata.ModifiableMetadataAwareAmetysObject
getMetadataHolderMethods 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 thisAmetysObjectparentPath- the parentPath in the Ametys hierarchyfactory- the DefaultAmetysObjectFactory which created the AmetysObject
-
-
Method Details
-
setData
Description copied from interface:ModifiableResourceSet binary data.- Specified by:
setDatain 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:ModifiableResourceSet the last modified date if this resource.- Specified by:
setLastModifiedin interfaceModifiableResource- Parameters:
lastModified- the last modified date.
-
setKeywords
Description copied from interface:ModifiableResourceSet this resource's keywords.- Specified by:
setKeywordsin interfaceModifiableResource- Parameters:
keywords- the comma-separated keywords.
-
setKeywords
Description copied from interface:ModifiableResourceSet this resource's keywords.- Specified by:
setKeywordsin interfaceModifiableResource- Parameters:
keywords- the keywords.
-
setMimeType
Description copied from interface:ModifiableResourceSet this resource mime type.- Specified by:
setMimeTypein interfaceModifiableResource- Parameters:
mimeType- the mime type.
-
setCreator
Description copied from interface:ModifiableResourceSet the creator of the resource- Specified by:
setCreatorin interfaceModifiableResource- Parameters:
author- The author
-
getInputStream
Description copied from interface:ResourceReturns the data stream.- Specified by:
getInputStreamin interfaceResource- Returns:
- the data stream.
- Throws:
AmetysRepositoryException- if an error occurs.
-
getMimeType
Description copied from interface:ResourceReturns the data mime-type.- Specified by:
getMimeTypein interfaceResource- Returns:
- the data mime-type.
- Throws:
AmetysRepositoryException- if an error occurs.
-
getLastModified
Description copied from interface:ResourceReturns the last modification date.- Specified by:
getLastModifiedin interfaceResource- Returns:
- the last modification date.
- Throws:
AmetysRepositoryException- if an error occurs.
-
getLength
Description copied from interface:ResourceReturns the length of the data stream.- Specified by:
getLengthin interfaceResource- Returns:
- the length of the data stream.
- Throws:
AmetysRepositoryException- if an error occurs.
-
getCreator
Description copied from interface:ResourceReturns the last contributor of this resource.- Specified by:
getCreatorin 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
nullif not found - Throws:
javax.jcr.RepositoryException- If an error occurred
-
getKeywords
Description copied from interface:ResourceReturns the keywords of this resource, as a String array.- Specified by:
getKeywordsin interfaceResource- Returns:
- the keywords of this resource.
- Throws:
AmetysRepositoryException- if an error occurs.
-
getKeywordsAsString
Description copied from interface:ResourceReturns the keywords of this resource, as a comme-separated String.- Specified by:
getKeywordsAsStringin interfaceResource- Returns:
- the keywords of this resource.
- Throws:
AmetysRepositoryException- if an error occurs.
-
restoreFromNode
Description copied from class:DefaultAmetysObjectRestore from a node- Overrides:
restoreFromNodein classDefaultAmetysObject<F extends JCRResourceFactory>- Parameters:
node- The node to restore- Throws:
javax.jcr.RepositoryException- If error occurs
-
getResourcePath
Description copied from interface:ResourceReturns the path of this resource in its hierarchy (which is a subset of the whole repository).- Specified by:
getResourcePathin interfaceResource- Returns:
- the path of this resource in its hierarchy.
- Throws:
AmetysRepositoryException- if an error occurs.
-
copyTo
public AmetysObject copyTo(ModifiableTraversableAmetysObject parent, String name) throws AmetysRepositoryException Description copied from interface:CopiableAmetysObjectCopy the currentAmetysObjectto the given object. Be careful, this method save changes.- Specified by:
copyToin 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:CopiableAmetysObjectCopy the currentAmetysObjectto the given object if it is not in the restriction list. Be careful, this method save changes.- Specified by:
copyToin 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 ofCopiableAmetysObjectauthorized to be copied- Returns:
- the created object
- Throws:
AmetysRepositoryException- if an error occurs.
-
getDCTitle
Description copied from interface:DublinCoreAwareAmetysObjectGet the Dublin Core title.- Specified by:
getDCTitlein interfaceDublinCoreAwareAmetysObject- Returns:
- the Dublin Core title. Can be null.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setDCTitle
Description copied from interface:ModifiableDublinCoreAwareAmetysObjectSet the Dublin Core title.- Specified by:
setDCTitlein interfaceModifiableDublinCoreAwareAmetysObject- Parameters:
title- the Dublin Core title to set. Can be null.- Throws:
AmetysRepositoryException- if an error occurs.
-
getDCCreator
Description copied from interface:DublinCoreAwareAmetysObjectGet the Dublin Core creator.- Specified by:
getDCCreatorin interfaceDublinCoreAwareAmetysObject- Returns:
- the Dublin Core creator. Can be null.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setDCCreator
Description copied from interface:ModifiableDublinCoreAwareAmetysObjectSet the Dublin Core creator.- Specified by:
setDCCreatorin interfaceModifiableDublinCoreAwareAmetysObject- Parameters:
creator- the Dublin Core creator to set. Can be null.- Throws:
AmetysRepositoryException- if an error occurs.
-
getDCSubject
Description copied from interface:DublinCoreAwareAmetysObjectGet the Dublin Core subject.- Specified by:
getDCSubjectin interfaceDublinCoreAwareAmetysObject- Returns:
- the Dublin Core subject. Can be null.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setDCSubject
Description copied from interface:ModifiableDublinCoreAwareAmetysObjectSet the Dublin Core subject.- Specified by:
setDCSubjectin interfaceModifiableDublinCoreAwareAmetysObject- Parameters:
subject- the Dublin Core subject to set. Can be null.- Throws:
AmetysRepositoryException- if an error occurs.
-
getDCDescription
Description copied from interface:DublinCoreAwareAmetysObjectGet the Dublin Core description.- Specified by:
getDCDescriptionin interfaceDublinCoreAwareAmetysObject- Returns:
- the Dublin Core description. Can be null.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setDCDescription
Description copied from interface:ModifiableDublinCoreAwareAmetysObjectSet the Dublin Core description.- Specified by:
setDCDescriptionin interfaceModifiableDublinCoreAwareAmetysObject- Parameters:
description- the Dublin Core description to set. Can be null.- Throws:
AmetysRepositoryException- if an error occurs.
-
getDCPublisher
Description copied from interface:DublinCoreAwareAmetysObjectGet the Dublin Core publisher.- Specified by:
getDCPublisherin interfaceDublinCoreAwareAmetysObject- Returns:
- the Dublin Core publisher. Can be null.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setDCPublisher
Description copied from interface:ModifiableDublinCoreAwareAmetysObjectSet the Dublin Core publisher.- Specified by:
setDCPublisherin interfaceModifiableDublinCoreAwareAmetysObject- Parameters:
publisher- the Dublin Core publisher to set. Can be null.- Throws:
AmetysRepositoryException- if an error occurs.
-
getDCContributor
Description copied from interface:DublinCoreAwareAmetysObjectGet the Dublin Core contributor.- Specified by:
getDCContributorin interfaceDublinCoreAwareAmetysObject- Returns:
- the Dublin Core contributor. Can be null.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setDCContributor
Description copied from interface:ModifiableDublinCoreAwareAmetysObjectSet the Dublin Core contributor.- Specified by:
setDCContributorin interfaceModifiableDublinCoreAwareAmetysObject- Parameters:
contributor- the Dublin Core contributor to set. Can be null.- Throws:
AmetysRepositoryException- if an error occurs.
-
getDCDate
Description copied from interface:DublinCoreAwareAmetysObjectGet the Dublin Core date.- Specified by:
getDCDatein interfaceDublinCoreAwareAmetysObject- Returns:
- the Dublin Core date. Can be null.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setDCDate
Description copied from interface:ModifiableDublinCoreAwareAmetysObjectSet the Dublin Core date.- Specified by:
setDCDatein interfaceModifiableDublinCoreAwareAmetysObject- Parameters:
date- the Dublin Core date to set. Can be null.- Throws:
AmetysRepositoryException- if an error occurs.
-
getDCType
Description copied from interface:DublinCoreAwareAmetysObjectGet the Dublin Core type.- Specified by:
getDCTypein interfaceDublinCoreAwareAmetysObject- Returns:
- the Dublin Core type. Can be null.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setDCType
Description copied from interface:ModifiableDublinCoreAwareAmetysObjectSet the Dublin Core type. You can use a constant from org.ametys.plugins.repository.dublincore.DCMITypes.- Specified by:
setDCTypein interfaceModifiableDublinCoreAwareAmetysObject- Parameters:
type- the Dublin Core type to set. Can be null.- Throws:
AmetysRepositoryException- if an error occurs.
-
getDCFormat
Description copied from interface:DublinCoreAwareAmetysObjectGet the Dublin Core format.- Specified by:
getDCFormatin interfaceDublinCoreAwareAmetysObject- Returns:
- the Dublin Core format. Can be null.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setDCFormat
Description copied from interface:ModifiableDublinCoreAwareAmetysObjectSet the Dublin Core format.- Specified by:
setDCFormatin interfaceModifiableDublinCoreAwareAmetysObject- Parameters:
format- the Dublin Core format to set. Can be null.- Throws:
AmetysRepositoryException- if an error occurs.
-
getDCIdentifier
Description copied from interface:DublinCoreAwareAmetysObjectGet the Dublin Core identifier.- Specified by:
getDCIdentifierin interfaceDublinCoreAwareAmetysObject- Returns:
- the Dublin Core identifier. Can be null.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setDCIdentifier
Description copied from interface:ModifiableDublinCoreAwareAmetysObjectSet the Dublin Core identifier.- Specified by:
setDCIdentifierin interfaceModifiableDublinCoreAwareAmetysObject- Parameters:
identifier- the Dublin Core identifier to set. Can be null.- Throws:
AmetysRepositoryException- if an error occurs.
-
getDCSource
Description copied from interface:DublinCoreAwareAmetysObjectGet the Dublin Core source.- Specified by:
getDCSourcein interfaceDublinCoreAwareAmetysObject- Returns:
- the Dublin Core source. Can be null.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setDCSource
Description copied from interface:ModifiableDublinCoreAwareAmetysObjectSet the Dublin Core source.- Specified by:
setDCSourcein interfaceModifiableDublinCoreAwareAmetysObject- Parameters:
source- the Dublin Core source to set. Can be null.- Throws:
AmetysRepositoryException- if an error occurs.
-
getDCLanguage
Description copied from interface:DublinCoreAwareAmetysObjectGet the Dublin Core language.- Specified by:
getDCLanguagein interfaceDublinCoreAwareAmetysObject- Returns:
- the Dublin Core language. Can be null.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setDCLanguage
Description copied from interface:ModifiableDublinCoreAwareAmetysObjectSet the Dublin Core language.- Specified by:
setDCLanguagein interfaceModifiableDublinCoreAwareAmetysObject- Parameters:
language- the Dublin Core language to set. Can be null.- Throws:
AmetysRepositoryException- if an error occurs.
-
getDCRelation
Description copied from interface:DublinCoreAwareAmetysObjectGet the Dublin Core relation.- Specified by:
getDCRelationin interfaceDublinCoreAwareAmetysObject- Returns:
- the Dublin Core relation. Can be null.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setDCRelation
Description copied from interface:ModifiableDublinCoreAwareAmetysObjectSet the Dublin Core relation.- Specified by:
setDCRelationin interfaceModifiableDublinCoreAwareAmetysObject- Parameters:
relation- the Dublin Core relation to set. Can be null.- Throws:
AmetysRepositoryException- if an error occurs.
-
getDCCoverage
Description copied from interface:DublinCoreAwareAmetysObjectGet the Dublin Core coverage.- Specified by:
getDCCoveragein interfaceDublinCoreAwareAmetysObject- Returns:
- the Dublin Core coverage. Can be null.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setDCCoverage
Description copied from interface:ModifiableDublinCoreAwareAmetysObjectSet the Dublin Core coverage.- Specified by:
setDCCoveragein interfaceModifiableDublinCoreAwareAmetysObject- Parameters:
coverage- the Dublin Core coverage to set. Can be null.- Throws:
AmetysRepositoryException- if an error occurs.
-
getDCRights
Description copied from interface:DublinCoreAwareAmetysObjectGet the Dublin Core rights.- Specified by:
getDCRightsin interfaceDublinCoreAwareAmetysObject- Returns:
- the Dublin Core rights. Can be null.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setDCRights
Description copied from interface:ModifiableDublinCoreAwareAmetysObjectSet the Dublin Core rights.- Specified by:
setDCRightsin interfaceModifiableDublinCoreAwareAmetysObject- Parameters:
rights- the Dublin Core rights to set. Can be null.- Throws:
AmetysRepositoryException- if an error occurs.
-
getCreationDate
Description copied from interface:ResourceRetrieves the creation date.- Specified by:
getCreationDatein interfaceResource- Returns:
- the creation date.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setCreationDate
Description copied from interface:ModifiableResourceSet the creation date if this resource.- Specified by:
setCreationDatein interfaceModifiableResource- Parameters:
creationDate- the creation date.
-
getLastContributor
Description copied from interface:ResourceRetrieves the login of the last contributor.- Specified by:
getLastContributorin interfaceResource- Returns:
- the login of the last contributor.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setLastContributor
Description copied from interface:ModifiableResourceSet the last contributor of the resource- Specified by:
setLastContributorin interfaceModifiableResource- Parameters:
lastContributor- The last contributor
-
tag
Description copied from interface:TaggableAmetysObjectTags.- Specified by:
tagin interfaceTaggableAmetysObject- Parameters:
tag- the tag to add.- Throws:
AmetysRepositoryException- if an error occurs.
-
untag
Description copied from interface:TaggableAmetysObjectUntags.- Specified by:
untagin interfaceTaggableAmetysObject- Parameters:
tag- the tag to remove.- Throws:
AmetysRepositoryException- if an error occurs.
-
getTags
Description copied from interface:TagAwareAmetysObjectRetrieves current tags.- Specified by:
getTagsin interfaceTagAwareAmetysObject- Returns:
- the current tags.
- Throws:
AmetysRepositoryException- if an error occurs.
-
moveToTrash
Description copied from interface:TrashableAmetysObjectMove thisAmetysObjectto the trash.- Specified by:
moveToTrashin interfaceTrashableAmetysObject- Returns:
- the created trash element that represents the object in the trash
-
restoreFromTrash
Description copied from interface:TrashableAmetysObjectRestore thisAmetysObjectfrom the trash.- Specified by:
restoreFromTrashin interfaceTrashableAmetysObject- Returns:
- the restored ametys object
- Throws:
UnknownParentException- if it's not possible to determine a location to restore the object
-