Class PrimaryDataEntity
- java.lang.Object
-
- de.ipk_gatersleben.bit.bi.edal.primary_data.file.PrimaryDataEntity
-
- All Implemented Interfaces:
java.lang.Comparable<PrimaryDataEntity>
- Direct Known Subclasses:
PrimaryDataDirectory,PrimaryDataFile
public abstract class PrimaryDataEntity extends java.lang.Object implements java.lang.Comparable<PrimaryDataEntity>
Abstract PrimaryDataEntity class.Super class for
PrimaryDataDirectoryandPrimaryDataFile.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPrimaryDataEntity()Constructor for PrimaryDataEntity.protectedPrimaryDataEntity(PrimaryDataDirectory path, java.lang.String name)Construct aPrimaryDataEntityobject.
-
Method Summary
Modifier and Type Method Description voidaddPublicReference(PersistentIdentifier identifierType)Add a public identifier to the currentVersion of thisPrimaryDataEntity.protected voidcommitVersion(PrimaryDataEntityVersion version)Internal function to commit aPrimaryDataEntityVersionto the storage back-end.intcompareTo(PrimaryDataEntity other)voiddelete()Delete thePrimaryDataEntityobject by generation of newPrimaryDataEntityVersionand set the isDeleted flag totrue.booleanequals(java.lang.Object obj)PrimaryDataEntityVersiongetCurrentVersion()Getter for the currentPrimaryDataEntityVersion.java.lang.StringgetID()Getter for the ID of thisPrimaryDataEntity.protected ImplementationProvidergetImplementationProvider()Getter for the currentImplementationProvider.MetaDatagetMetaData()java.lang.StringgetName()Getter for the name of thisPrimaryDataEntity.PrimaryDataDirectorygetParentDirectory()Getter for the parentPrimaryDataDirectoryof thisPrimaryDataEntity.java.lang.StringgetPath()Getter for the path of thisPrimaryDataEntityasString.java.util.Map<java.security.Principal,java.util.List<EdalPermission>>getPermissions()Getter for aListcontaining allEdalPermissionobjects.protected abstract java.util.Map<java.security.Principal,java.util.List<EdalPermission>>getPermissionsImpl()Abstract function for implementation ofgetPermissions().java.util.List<PublicReference>getPublicReferences()Getter for aListof all storedPublicReferences of the currentPrimaryDataEntityVersionof thisPrimaryDataEntity.protected javax.security.auth.SubjectgetSubject()Getter for the currentSubject.PrimaryDataEntityVersiongetVersionByDate(java.util.Calendar date)Convenience function to get aPrimaryDataEntityVersionof thisPrimaryDataEntityby the revision date.PrimaryDataEntityVersiongetVersionByRevisionNumber(long revisionNumber)Convenience function to get aPrimaryDataEntityVersionof thisPrimaryDataEntityby the revision number.java.util.SortedSet<PrimaryDataEntityVersion>getVersions()protected abstract java.util.SortedSet<PrimaryDataEntityVersion>getVersionsImpl()Abstract function for implementation ofgetVersions().voidgrantPermission(java.security.Principal principal, GrantableMethods.Methods method)Grant aEdalPermissionto aPrincipaland check before grant if the method exists.inthashCode()booleanisDirectory()Check if thePrimaryDataEntityis aPrimaryDataDirectoryor not.voidmove(PrimaryDataDirectory destinationDirectory)Move thisPrimaryDataEntityto anotherPrimaryDataDirectory.protected abstract voidmoveImpl(PrimaryDataDirectory destinationDirectory)Abstract function for implementation ofmove(PrimaryDataDirectory).protected UntypedDatareloadOldDataType(EnumDublinCoreElements element)Internal function to reload a data type of the oldMetaDatafor the current version, after the user set a wrong value.voidrename(java.lang.String name)Rename the currentPrimaryDataEntity.voidrevokePermission(java.security.Principal principal, GrantableMethods.Methods method)Revoke aEdalPermissionto aPrincipaland check before revoke if the method exists.protected voidsetCurrentVersion(PrimaryDataEntityVersion version)Setter for the currentPrimaryDataEntityVersion.protected voidsetDefaultPermissions()Set initial and defaultEdalPermissionfor thisPrimaryDataEntity.protected voidsetID(java.lang.String id)Setter for the ID of the currentPrimaryDataEntityvoidsetMetaData(MetaData newMetadata)Setter for theMetaDataobject of thisPrimaryDataEntityobject.protected voidsetParentDirectory(PrimaryDataDirectory parentDirectory)Setter for the parentPrimaryDataDirectoryof thisPrimaryDataEntity.protected abstract voidstoreVersion(PrimaryDataEntityVersion newVersion)Abstract function for storing a newPrimaryDataEntityVersionfor anPrimaryDataEntityobject.voidswitchCurrentVersion(PrimaryDataEntityVersion version)Switch the currentPrimaryDataEntityVersionwith thisPrimaryDataEntityVersion.java.lang.StringtoString()
-
-
-
Constructor Detail
-
PrimaryDataEntity
protected PrimaryDataEntity()
Constructor for PrimaryDataEntity.
-
PrimaryDataEntity
protected PrimaryDataEntity(PrimaryDataDirectory path, java.lang.String name) throws PrimaryDataEntityVersionException, PrimaryDataDirectoryException, MetaDataException
Construct aPrimaryDataEntityobject. Set thePrimaryDataEntityVersionto the latest one.If it is an initial
PrimaryDataEntityVersion, a new defaultMetaDataobject is instantiated- Parameters:
name- the name for this objectpath- the parentPrimaryDataDirectoryof thisPrimaryDataEntity.- Throws:
PrimaryDataEntityVersionException- if unable to set currentPrimaryDataEntityVersion.PrimaryDataDirectoryException- if no parentPrimaryDataDirectoryis found.MetaDataException- if theMetaDataobject of the parentPrimaryDataDirectoryis not clone-able.
-
-
Method Detail
-
addPublicReference
public void addPublicReference(PersistentIdentifier identifierType) throws PrimaryDataEntityException
Add a public identifier to the currentVersion of thisPrimaryDataEntity.- Parameters:
identifierType- the type of the new Identifier.- Throws:
PrimaryDataEntityException- if unable to add thePublicReferenceto thisPrimaryDataEntity.
-
commitVersion
protected void commitVersion(PrimaryDataEntityVersion version) throws PrimaryDataEntityVersionException
Internal function to commit aPrimaryDataEntityVersionto the storage back-end. Use the CREATEDEdalDateof the currentPrimaryDataEntityVersionand remove the UPDATEDEdalDateto add a new one.- Parameters:
version- thePrimaryDataEntityVersionto store.- Throws:
PrimaryDataEntityVersionException- if unable to store thePrimaryDataEntityVersion.
-
compareTo
public int compareTo(PrimaryDataEntity other)
Compares PrimaryDataEntity based on toLowerCase(getName());
- Specified by:
compareToin interfacejava.lang.Comparable<PrimaryDataEntity>
-
delete
public final void delete() throws PrimaryDataEntityVersionException, PrimaryDataDirectoryExceptionDelete thePrimaryDataEntityobject by generation of newPrimaryDataEntityVersionand set the isDeleted flag totrue.NOTE: It is not allowed delete the root
PrimaryDataDirectory!NOTE: It is not allowed delete a non-current
PrimaryDataEntityVersion!- Throws:
PrimaryDataEntityVersionException- if trying to delete the rootPrimaryDataDirectoryPrimaryDataDirectoryException- if trying to delete a non-currentPrimaryDataEntityVersion.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
getCurrentVersion
public PrimaryDataEntityVersion getCurrentVersion()
Getter for the currentPrimaryDataEntityVersion.- Returns:
- the currently set
PrimaryDataEntityVersion
-
getID
public java.lang.String getID()
Getter for the ID of thisPrimaryDataEntity.- Returns:
- the ID of this
PrimaryDataEntity - See Also:
UUID
-
getImplementationProvider
protected ImplementationProvider getImplementationProvider()
Getter for the currentImplementationProvider.- Returns:
- the
ImplementationProviderfrom current thread
-
getMetaData
public MetaData getMetaData()
- Returns:
MetaDataobject of the currentPrimaryDataEntityVersionof thisPrimaryDataEntity.
-
getName
public final java.lang.String getName()
Getter for the name of thisPrimaryDataEntity.- Returns:
- the file name as delegator to
this.getMetaData().getElementValue(EnumDublinCoreElements.TITLE)
-
getParentDirectory
public PrimaryDataDirectory getParentDirectory() throws PrimaryDataDirectoryException
Getter for the parentPrimaryDataDirectoryof thisPrimaryDataEntity.NOTE: It is not allowed to access the parent
PrimaryDataDirectoryof the rootPrimaryDataDirectory!- Returns:
- the parent
PrimaryDataDirectoryof thisPrimaryDataEntity. - Throws:
PrimaryDataDirectoryException- if trying to access the parentPrimaryDataDirectoryof the rootPrimaryDataDirectory.
-
getPath
public java.lang.String getPath()
Getter for the path of thisPrimaryDataEntityasString.- Returns:
- the complete path of the
PrimaryDataEntityobject asString
-
getPermissions
public java.util.Map<java.security.Principal,java.util.List<EdalPermission>> getPermissions() throws PrimaryDataEntityException
Getter for aListcontaining allEdalPermissionobjects.- Returns:
- an unmodifiable
Listcontaining allEdalPermission - Throws:
PrimaryDataEntityException- if unable to load all permissions.
-
getPermissionsImpl
protected abstract java.util.Map<java.security.Principal,java.util.List<EdalPermission>> getPermissionsImpl() throws PrimaryDataEntityException
Abstract function for implementation ofgetPermissions().- Returns:
- an unmodifiable
Listcontaining allEdalPermission - Throws:
PrimaryDataEntityException- if unable to load all permissions.
-
getPublicReferences
public java.util.List<PublicReference> getPublicReferences()
Getter for aListof all storedPublicReferences of the currentPrimaryDataEntityVersionof thisPrimaryDataEntity.- Returns:
- a
Listwith all storedPublicReferences of the currentPrimaryDataEntityVersionof thisPrimaryDataEntity.
-
getSubject
protected javax.security.auth.Subject getSubject()
Getter for the currentSubject.- Returns:
- the
Subjectfrom current thread.
-
getVersionByDate
public PrimaryDataEntityVersion getVersionByDate(java.util.Calendar date) throws PrimaryDataEntityVersionException
Convenience function to get aPrimaryDataEntityVersionof thisPrimaryDataEntityby the revision date.- Parameters:
date- the date of thePrimaryDataEntityVersion- Returns:
- the specified
PrimaryDataEntityVersion - Throws:
PrimaryDataEntityVersionException- if there are only olderPrimaryDataEntityVersionstored for thisPrimaryDataEntity
-
getVersionByRevisionNumber
public PrimaryDataEntityVersion getVersionByRevisionNumber(long revisionNumber) throws PrimaryDataEntityVersionException
Convenience function to get aPrimaryDataEntityVersionof thisPrimaryDataEntityby the revision number.- Parameters:
revisionNumber- the number of thePrimaryDataEntityVersion- Returns:
- the specified
PrimaryDataEntityVersion - Throws:
PrimaryDataEntityVersionException- if there is noPrimaryDataEntityVersionwith this version stored.
-
getVersions
public java.util.SortedSet<PrimaryDataEntityVersion> getVersions()
- Returns:
- an unmodifiable
SortedSetcontaining allPrimaryDataEntity
-
getVersionsImpl
protected abstract java.util.SortedSet<PrimaryDataEntityVersion> getVersionsImpl()
Abstract function for implementation ofgetVersions().- Returns:
- an unmodifiable
SortedSetcontaining allPrimaryDataEntity.
-
grantPermission
public void grantPermission(java.security.Principal principal, GrantableMethods.Methods method) throws PrimaryDataEntityExceptionGrant aEdalPermissionto aPrincipaland check before grant if the method exists.- Parameters:
principal- to grant this methodmethod-Enumfor a the method- Throws:
PrimaryDataEntityException- if can not found method to grant.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
isDirectory
public boolean isDirectory()
Check if thePrimaryDataEntityis aPrimaryDataDirectoryor not.- Returns:
truewhen it is aPrimaryDataDirectory;
falseotherwise.
-
move
public void move(PrimaryDataDirectory destinationDirectory) throws PrimaryDataDirectoryException
Move thisPrimaryDataEntityto anotherPrimaryDataDirectory.NOTE: It is not allowed to move the root
PrimaryDataDirectory!- Parameters:
destinationDirectory- the new parentPrimaryDataDirectoryfor thisPrimaryDataEntity.- Throws:
PrimaryDataDirectoryException- if trying to move the rootPrimaryDataDirectory.
-
moveImpl
protected abstract void moveImpl(PrimaryDataDirectory destinationDirectory)
Abstract function for implementation ofmove(PrimaryDataDirectory).- Parameters:
destinationDirectory- the newPrimaryDataDirectoryfor thisPrimaryDataEntity.
-
rename
public final void rename(java.lang.String name) throws PrimaryDataEntityVersionException, PrimaryDataDirectoryExceptionRename the currentPrimaryDataEntity.NOTE: Can not rename if another
PrimaryDataEntitywith this name already exists!- Parameters:
name- the new name for thisPrimaryDataEntity.- Throws:
PrimaryDataEntityVersionException- if unable to set the newPrimaryDataEntityVersion.PrimaryDataDirectoryException- if anPrimaryDataEntitywith this name already exists.
-
revokePermission
public void revokePermission(java.security.Principal principal, GrantableMethods.Methods method) throws PrimaryDataEntityExceptionRevoke aEdalPermissionto aPrincipaland check before revoke if the method exists.NOTE: Can not revoke
grantPermission(Principal, de.ipk_gatersleben.bit.bi.edal.aspectj.security.GrantableMethods.Methods)method for your ownPrimaryDataEntity!- Parameters:
principal- to revoke this method.method-Enumfor a the method.- Throws:
PrimaryDataEntityException- if trying to revoke theEdalPermissionforgrantPermission(Principal, de.ipk_gatersleben.bit.bi.edal.aspectj.security.GrantableMethods.Methods)of your ownPrimaryDataEntity.
-
setCurrentVersion
protected void setCurrentVersion(PrimaryDataEntityVersion version)
Setter for the currentPrimaryDataEntityVersion.- Parameters:
version- the new currentPrimaryDataEntityVersionobject.
-
setDefaultPermissions
protected final void setDefaultPermissions() throws PrimaryDataEntityExceptionSet initial and defaultEdalPermissionfor thisPrimaryDataEntity.- Throws:
PrimaryDataEntityException- if unable to set the permissions.
-
setID
protected void setID(java.lang.String id)
Setter for the ID of the currentPrimaryDataEntity- Parameters:
id- the ID to set
-
reloadOldDataType
protected UntypedData reloadOldDataType(EnumDublinCoreElements element) throws MetaDataException
Internal function to reload a data type of the oldMetaDatafor the current version, after the user set a wrong value.- Parameters:
element- the Element to reload from the oldMetaData- Returns:
- the original value of the given element.
- Throws:
MetaDataException- if unable to reload the oldMetaData.
-
setMetaData
public void setMetaData(MetaData newMetadata) throws PrimaryDataEntityVersionException, MetaDataException
Setter for theMetaDataobject of thisPrimaryDataEntityobject. Create a newPrimaryDataEntityVersionwith a newMetaDataset.- Parameters:
newMetadata- the newMetaDataobject to set.- Throws:
PrimaryDataEntityVersionException- if unable to storePrimaryDataEntityVersion.MetaDataException- if there are non valid value for element in theMetaDataobject.
-
setParentDirectory
protected void setParentDirectory(PrimaryDataDirectory parentDirectory)
Setter for the parentPrimaryDataDirectoryof thisPrimaryDataEntity.- Parameters:
parentDirectory- the parentPrimaryDataDirectoryto set
-
storeVersion
protected abstract void storeVersion(PrimaryDataEntityVersion newVersion) throws PrimaryDataEntityVersionException
Abstract function for storing a newPrimaryDataEntityVersionfor anPrimaryDataEntityobject.- Parameters:
newVersion- the newPrimaryDataEntityVersionto store.- Throws:
PrimaryDataEntityVersionException- if unable to storePrimaryDataEntityVersion.
-
switchCurrentVersion
public void switchCurrentVersion(PrimaryDataEntityVersion version) throws PrimaryDataEntityVersionException
Switch the currentPrimaryDataEntityVersionwith thisPrimaryDataEntityVersion.NOTE: Can not switch when the current
PrimaryDataEntityVersionis marked as deleted !NOTE: Can not switch when the
PrimaryDataEntityVersionnot in theSortedSetof thisPrimaryDataEntity!- Parameters:
version- the newPrimaryDataEntityVersionto set as currentPrimaryDataEntityVersion.- Throws:
PrimaryDataEntityVersionException- if requestedPrimaryDataEntityVersionis not available or marked as deleted.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-