Class StoreArchiver
- java.lang.Object
-
- org.oa4mp.server.admin.oauth2.base.StoreArchiver
-
public class StoreArchiver extends Object
Class to encapsulate archive CRUD operations for a store. Having it here lets us use it in other places, e.g. QDL.Created by Jeff Gaynor
on 10/19/21 at 6:14 AM
-
-
Field Summary
Fields Modifier and Type Field Description static StringARCHIVE_VERSION_SEPARATOR_TAGSeparator between the version tag and the version number.static StringARCHIVE_VERSION_TAGKey in the fragment for the version
-
Constructor Summary
Constructors Constructor Description StoreArchiver(edu.uiuc.ncsa.security.core.Store store)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Longcreate(edu.uiuc.ncsa.security.core.Identifier identifier)Create a new version.edu.uiuc.ncsa.security.core.IdentifiercreateVersionedID(edu.uiuc.ncsa.security.core.Identifier id, long version)Given a base id and the new version number, create the identifieredu.uiuc.ncsa.security.core.IdentifiergetBaseID(edu.uiuc.ncsa.security.core.Identifier overloadedID)Removes the fragment (with the version number).protected LonggetLatestVersionNumber(edu.uiuc.ncsa.security.core.util.DoubleHashMap<URI,Long> versionNumbers)Get the latest version number or return a -1 if no versions present.edu.uiuc.ncsa.security.storage.data.MapConvertergetMapConverter()edu.uiuc.ncsa.security.core.StoregetStore()edu.uiuc.ncsa.security.core.IdentifiablegetVersion(edu.uiuc.ncsa.security.core.Identifier targetID, long version)Given the raw id and a version number (which may be -1 to indicate using the latest) get the stored version.longgetVersionNumber(edu.uiuc.ncsa.security.core.Identifier id)Given a version id (of form URI#version=number), return the number.List<Long>getVersionNumbers(edu.uiuc.ncsa.security.core.Identifier id)protected edu.uiuc.ncsa.security.core.util.DoubleHashMap<URI,Long>getVersions(edu.uiuc.ncsa.security.core.Identifier identifier)For a given object in the store, return all the versions associated with it in aDoubleHashMap.TreeMap<Long,edu.uiuc.ncsa.security.core.Identifiable>getVersionsMap(edu.uiuc.ncsa.security.core.Identifiable identifiable)For a given object, get all the versions (not just their identifiers) and return in a map keyed by version number.static voidmain(String[] args)voidremove(edu.uiuc.ncsa.security.core.Identifier identifier, long version)Removed the version of the object from the store.booleanrestore(edu.uiuc.ncsa.security.core.Identifier id, Long version)For a
-
-
-
Method Detail
-
getStore
public edu.uiuc.ncsa.security.core.Store getStore()
-
getMapConverter
public edu.uiuc.ncsa.security.storage.data.MapConverter getMapConverter()
-
getVersionNumber
public long getVersionNumber(edu.uiuc.ncsa.security.core.Identifier id)
Given a version id (of form URI#version=number), return the number.- Parameters:
id-- Returns:
-
createVersionedID
public edu.uiuc.ncsa.security.core.Identifier createVersionedID(edu.uiuc.ncsa.security.core.Identifier id, long version)Given a base id and the new version number, create the identifierURI#version=numberThis is to make sure everythign is created identically.- Parameters:
id-version-- Returns:
-
main
public static void main(String[] args)
-
getVersions
protected edu.uiuc.ncsa.security.core.util.DoubleHashMap<URI,Long> getVersions(edu.uiuc.ncsa.security.core.Identifier identifier)
For a given object in the store, return all the versions associated with it in aDoubleHashMap. Note that the keys are of the formURI#version=numberand the value is the number. As a double hash map then you can do a reverse lookup by version number and get the unique identifier.- Parameters:
identifier-- Returns:
-
getVersionsMap
public TreeMap<Long,edu.uiuc.ncsa.security.core.Identifiable> getVersionsMap(edu.uiuc.ncsa.security.core.Identifiable identifiable)
For a given object, get all the versions (not just their identifiers) and return in a map keyed by version number. This sorts the entries. Rather similar togetVersions(Identifier), this has key = number and value =URI#version=number. Use this where you need all the versions sorted by number for, e.g., display purposes.- Parameters:
identifiable-- Returns:
-
getLatestVersionNumber
protected Long getLatestVersionNumber(edu.uiuc.ncsa.security.core.util.DoubleHashMap<URI,Long> versionNumbers)
Get the latest version number or return a -1 if no versions present. Remember that versions increase, so version 0 is the first made, 1 is the next,... and the highest number is the most recent version.- Parameters:
versionNumbers-- Returns:
-
getVersion
public edu.uiuc.ncsa.security.core.Identifiable getVersion(edu.uiuc.ncsa.security.core.Identifier targetID, long version) throws IOExceptionGiven the raw id and a version number (which may be -1 to indicate using the latest) get the stored version. Might return null of there is no such version.- Parameters:
targetID-version-- Returns:
- Throws:
IOException
-
remove
public void remove(edu.uiuc.ncsa.security.core.Identifier identifier, long version)Removed the version of the object from the store. This either returns or throws a runtime exception from the store.Note
There is not a version with signature remove(Identifier) because of the risk of removing the base object if the wrong .- Parameters:
identifier-version-
-
create
public Long create(edu.uiuc.ncsa.security.core.Identifier identifier)
Create a new version. This returns the overloaded identifier of the versioned object.- Parameters:
identifier-- Returns:
-
getBaseID
public edu.uiuc.ncsa.security.core.Identifier getBaseID(edu.uiuc.ncsa.security.core.Identifier overloadedID)
Removes the fragment (with the version number).- Parameters:
overloadedID-- Returns:
-
restore
public boolean restore(edu.uiuc.ncsa.security.core.Identifier id, Long version)For a- Parameters:
id-version-- Returns:
-
-