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
PrimaryDataDirectory
andPrimaryDataFile
.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
PrimaryDataEntity()
Constructor for PrimaryDataEntity.protected
PrimaryDataEntity(PrimaryDataDirectory path, java.lang.String name)
Construct aPrimaryDataEntity
object.
-
Method Summary
Modifier and Type Method Description void
addPublicReference(PersistentIdentifier identifierType)
Add a public identifier to the currentVersion of thisPrimaryDataEntity
.protected void
commitVersion(PrimaryDataEntityVersion version)
Internal function to commit aPrimaryDataEntityVersion
to the storage back-end.int
compareTo(PrimaryDataEntity other)
void
delete()
Delete thePrimaryDataEntity
object by generation of newPrimaryDataEntityVersion
and set the isDeleted flag totrue
.boolean
equals(java.lang.Object obj)
PrimaryDataEntityVersion
getCurrentVersion()
Getter for the currentPrimaryDataEntityVersion
.java.lang.String
getID()
Getter for the ID of thisPrimaryDataEntity
.protected ImplementationProvider
getImplementationProvider()
Getter for the currentImplementationProvider
.MetaData
getMetaData()
java.lang.String
getName()
Getter for the name of thisPrimaryDataEntity
.PrimaryDataDirectory
getParentDirectory()
Getter for the parentPrimaryDataDirectory
of thisPrimaryDataEntity
.java.lang.String
getPath()
Getter for the path of thisPrimaryDataEntity
asString
.java.util.Map<java.security.Principal,java.util.List<EdalPermission>>
getPermissions()
Getter for aList
containing allEdalPermission
objects.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 aList
of all storedPublicReference
s of the currentPrimaryDataEntityVersion
of thisPrimaryDataEntity
.protected javax.security.auth.Subject
getSubject()
Getter for the currentSubject
.PrimaryDataEntityVersion
getVersionByDate(java.util.Calendar date)
Convenience function to get aPrimaryDataEntityVersion
of thisPrimaryDataEntity
by the revision date.PrimaryDataEntityVersion
getVersionByRevisionNumber(long revisionNumber)
Convenience function to get aPrimaryDataEntityVersion
of thisPrimaryDataEntity
by the revision number.java.util.SortedSet<PrimaryDataEntityVersion>
getVersions()
protected abstract java.util.SortedSet<PrimaryDataEntityVersion>
getVersionsImpl()
Abstract function for implementation ofgetVersions()
.void
grantPermission(java.security.Principal principal, GrantableMethods.Methods method)
Grant aEdalPermission
to aPrincipal
and check before grant if the method exists.int
hashCode()
boolean
isDirectory()
Check if thePrimaryDataEntity
is aPrimaryDataDirectory
or not.void
move(PrimaryDataDirectory destinationDirectory)
Move thisPrimaryDataEntity
to anotherPrimaryDataDirectory
.protected abstract void
moveImpl(PrimaryDataDirectory destinationDirectory)
Abstract function for implementation ofmove(PrimaryDataDirectory)
.protected UntypedData
reloadOldDataType(EnumDublinCoreElements element)
Internal function to reload a data type of the oldMetaData
for the current version, after the user set a wrong value.void
rename(java.lang.String name)
Rename the currentPrimaryDataEntity
.void
revokePermission(java.security.Principal principal, GrantableMethods.Methods method)
Revoke aEdalPermission
to aPrincipal
and check before revoke if the method exists.protected void
setCurrentVersion(PrimaryDataEntityVersion version)
Setter for the currentPrimaryDataEntityVersion
.protected void
setDefaultPermissions()
Set initial and defaultEdalPermission
for thisPrimaryDataEntity
.protected void
setID(java.lang.String id)
Setter for the ID of the currentPrimaryDataEntity
void
setMetaData(MetaData newMetadata)
Setter for theMetaData
object of thisPrimaryDataEntity
object.protected void
setParentDirectory(PrimaryDataDirectory parentDirectory)
Setter for the parentPrimaryDataDirectory
of thisPrimaryDataEntity
.protected abstract void
storeVersion(PrimaryDataEntityVersion newVersion)
Abstract function for storing a newPrimaryDataEntityVersion
for anPrimaryDataEntity
object.void
switchCurrentVersion(PrimaryDataEntityVersion version)
Switch the currentPrimaryDataEntityVersion
with thisPrimaryDataEntityVersion
.java.lang.String
toString()
-
-
-
Constructor Detail
-
PrimaryDataEntity
protected PrimaryDataEntity()
Constructor for PrimaryDataEntity.
-
PrimaryDataEntity
protected PrimaryDataEntity(PrimaryDataDirectory path, java.lang.String name) throws PrimaryDataEntityVersionException, PrimaryDataDirectoryException, MetaDataException
Construct aPrimaryDataEntity
object. Set thePrimaryDataEntityVersion
to the latest one.If it is an initial
PrimaryDataEntityVersion
, a new defaultMetaData
object is instantiated- Parameters:
name
- the name for this objectpath
- the parentPrimaryDataDirectory
of thisPrimaryDataEntity
.- Throws:
PrimaryDataEntityVersionException
- if unable to set currentPrimaryDataEntityVersion
.PrimaryDataDirectoryException
- if no parentPrimaryDataDirectory
is found.MetaDataException
- if theMetaData
object of the parentPrimaryDataDirectory
is 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 thePublicReference
to thisPrimaryDataEntity
.
-
commitVersion
protected void commitVersion(PrimaryDataEntityVersion version) throws PrimaryDataEntityVersionException
Internal function to commit aPrimaryDataEntityVersion
to the storage back-end. Use the CREATEDEdalDate
of the currentPrimaryDataEntityVersion
and remove the UPDATEDEdalDate
to add a new one.- Parameters:
version
- thePrimaryDataEntityVersion
to store.- Throws:
PrimaryDataEntityVersionException
- if unable to store thePrimaryDataEntityVersion
.
-
compareTo
public int compareTo(PrimaryDataEntity other)
Compares PrimaryDataEntity based on toLowerCase(getName());
- Specified by:
compareTo
in interfacejava.lang.Comparable<PrimaryDataEntity>
-
delete
public final void delete() throws PrimaryDataEntityVersionException, PrimaryDataDirectoryException
Delete thePrimaryDataEntity
object by generation of newPrimaryDataEntityVersion
and 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 rootPrimaryDataDirectory
PrimaryDataDirectoryException
- if trying to delete a non-currentPrimaryDataEntityVersion
.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in 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
ImplementationProvider
from current thread
-
getMetaData
public MetaData getMetaData()
- Returns:
MetaData
object of the currentPrimaryDataEntityVersion
of 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 parentPrimaryDataDirectory
of thisPrimaryDataEntity
.NOTE: It is not allowed to access the parent
PrimaryDataDirectory
of the rootPrimaryDataDirectory
!- Returns:
- the parent
PrimaryDataDirectory
of thisPrimaryDataEntity
. - Throws:
PrimaryDataDirectoryException
- if trying to access the parentPrimaryDataDirectory
of the rootPrimaryDataDirectory
.
-
getPath
public java.lang.String getPath()
Getter for the path of thisPrimaryDataEntity
asString
.- Returns:
- the complete path of the
PrimaryDataEntity
object asString
-
getPermissions
public java.util.Map<java.security.Principal,java.util.List<EdalPermission>> getPermissions() throws PrimaryDataEntityException
Getter for aList
containing allEdalPermission
objects.- Returns:
- an unmodifiable
List
containing 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
List
containing allEdalPermission
- Throws:
PrimaryDataEntityException
- if unable to load all permissions.
-
getPublicReferences
public java.util.List<PublicReference> getPublicReferences()
Getter for aList
of all storedPublicReference
s of the currentPrimaryDataEntityVersion
of thisPrimaryDataEntity
.- Returns:
- a
List
with all storedPublicReference
s of the currentPrimaryDataEntityVersion
of thisPrimaryDataEntity
.
-
getSubject
protected javax.security.auth.Subject getSubject()
Getter for the currentSubject
.- Returns:
- the
Subject
from current thread.
-
getVersionByDate
public PrimaryDataEntityVersion getVersionByDate(java.util.Calendar date) throws PrimaryDataEntityVersionException
Convenience function to get aPrimaryDataEntityVersion
of thisPrimaryDataEntity
by the revision date.- Parameters:
date
- the date of thePrimaryDataEntityVersion
- Returns:
- the specified
PrimaryDataEntityVersion
- Throws:
PrimaryDataEntityVersionException
- if there are only olderPrimaryDataEntityVersion
stored for thisPrimaryDataEntity
-
getVersionByRevisionNumber
public PrimaryDataEntityVersion getVersionByRevisionNumber(long revisionNumber) throws PrimaryDataEntityVersionException
Convenience function to get aPrimaryDataEntityVersion
of thisPrimaryDataEntity
by the revision number.- Parameters:
revisionNumber
- the number of thePrimaryDataEntityVersion
- Returns:
- the specified
PrimaryDataEntityVersion
- Throws:
PrimaryDataEntityVersionException
- if there is noPrimaryDataEntityVersion
with this version stored.
-
getVersions
public java.util.SortedSet<PrimaryDataEntityVersion> getVersions()
- Returns:
- an unmodifiable
SortedSet
containing allPrimaryDataEntity
-
getVersionsImpl
protected abstract java.util.SortedSet<PrimaryDataEntityVersion> getVersionsImpl()
Abstract function for implementation ofgetVersions()
.- Returns:
- an unmodifiable
SortedSet
containing allPrimaryDataEntity
.
-
grantPermission
public void grantPermission(java.security.Principal principal, GrantableMethods.Methods method) throws PrimaryDataEntityException
Grant aEdalPermission
to aPrincipal
and check before grant if the method exists.- Parameters:
principal
- to grant this methodmethod
-Enum
for a the method- Throws:
PrimaryDataEntityException
- if can not found method to grant.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
isDirectory
public boolean isDirectory()
Check if thePrimaryDataEntity
is aPrimaryDataDirectory
or not.- Returns:
true
when it is aPrimaryDataDirectory
;
false
otherwise.
-
move
public void move(PrimaryDataDirectory destinationDirectory) throws PrimaryDataDirectoryException
Move thisPrimaryDataEntity
to anotherPrimaryDataDirectory
.NOTE: It is not allowed to move the root
PrimaryDataDirectory
!- Parameters:
destinationDirectory
- the new parentPrimaryDataDirectory
for 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 newPrimaryDataDirectory
for thisPrimaryDataEntity
.
-
rename
public final void rename(java.lang.String name) throws PrimaryDataEntityVersionException, PrimaryDataDirectoryException
Rename the currentPrimaryDataEntity
.NOTE: Can not rename if another
PrimaryDataEntity
with this name already exists!- Parameters:
name
- the new name for thisPrimaryDataEntity
.- Throws:
PrimaryDataEntityVersionException
- if unable to set the newPrimaryDataEntityVersion
.PrimaryDataDirectoryException
- if anPrimaryDataEntity
with this name already exists.
-
revokePermission
public void revokePermission(java.security.Principal principal, GrantableMethods.Methods method) throws PrimaryDataEntityException
Revoke aEdalPermission
to aPrincipal
and 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
-Enum
for a the method.- Throws:
PrimaryDataEntityException
- if trying to revoke theEdalPermission
forgrantPermission(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 currentPrimaryDataEntityVersion
object.
-
setDefaultPermissions
protected final void setDefaultPermissions() throws PrimaryDataEntityException
Set initial and defaultEdalPermission
for 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 oldMetaData
for 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 theMetaData
object of thisPrimaryDataEntity
object. Create a newPrimaryDataEntityVersion
with a newMetaData
set.- Parameters:
newMetadata
- the newMetaData
object to set.- Throws:
PrimaryDataEntityVersionException
- if unable to storePrimaryDataEntityVersion
.MetaDataException
- if there are non valid value for element in theMetaData
object.
-
setParentDirectory
protected void setParentDirectory(PrimaryDataDirectory parentDirectory)
Setter for the parentPrimaryDataDirectory
of thisPrimaryDataEntity
.- Parameters:
parentDirectory
- the parentPrimaryDataDirectory
to set
-
storeVersion
protected abstract void storeVersion(PrimaryDataEntityVersion newVersion) throws PrimaryDataEntityVersionException
Abstract function for storing a newPrimaryDataEntityVersion
for anPrimaryDataEntity
object.- Parameters:
newVersion
- the newPrimaryDataEntityVersion
to store.- Throws:
PrimaryDataEntityVersionException
- if unable to storePrimaryDataEntityVersion
.
-
switchCurrentVersion
public void switchCurrentVersion(PrimaryDataEntityVersion version) throws PrimaryDataEntityVersionException
Switch the currentPrimaryDataEntityVersion
with thisPrimaryDataEntityVersion
.NOTE: Can not switch when the current
PrimaryDataEntityVersion
is marked as deleted !NOTE: Can not switch when the
PrimaryDataEntityVersion
not in theSortedSet
of thisPrimaryDataEntity
!- Parameters:
version
- the newPrimaryDataEntityVersion
to set as currentPrimaryDataEntityVersion
.- Throws:
PrimaryDataEntityVersionException
- if requestedPrimaryDataEntityVersion
is not available or marked as deleted.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-