Package edu.wisc.library.ocfl.core.model
Class InventoryBuilder
- java.lang.Object
-
- edu.wisc.library.ocfl.core.model.InventoryBuilder
-
public class InventoryBuilder extends Object
Used to construct Inventory objects.
-
-
Constructor Summary
Constructors Constructor Description InventoryBuilder()InventoryBuilder(Inventory original)Used to construct a newInventorythat's based on an existing inventory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InventoryBuilderaddFileToManifest(String id, String contentPath)Adds a file to the manifestInventoryBuilderaddFixityForFile(String contentPath, DigestAlgorithm algorithm, String value)Adds a file to the fixity blockInventoryBuilderaddHeadVersion(Version version)Add the version as the new HEAD version.Inventorybuild()InventoryBuilderclearFixity()Removes all of the entries from the fixity block.booleancontainsContentPath(String contentPath)Indicates if the manifest contains a contentPathbooleancontainsFileId(String fileId)Indicates if the manifest contains a fileIdInventoryBuildercontentDirectory(String contentDirectory)InventoryBuildercurrentDigest(String currentDigest)InventoryBuilderdigestAlgorithm(DigestAlgorithm digestAlgorithm)InventoryBuilderfixity(Map<DigestAlgorithm,Map<String,Set<String>>> fixity)InventoryBuilderfixityBiMap(Map<DigestAlgorithm,PathBiMap> fixity)Set<String>getContentPaths(String fileId)Retrieves the content paths associated to the fileId or an empty setStringgetFileFixity(String fileId, DigestAlgorithm algorithm)Returns the fixity digest for a file or nullStringgetFileId(String contentPath)Retrieves the fileId associated to the content pathbooleanhasMutableHead()InventoryBuilderhead(VersionNum head)InventoryBuilderid(String id)InventoryBuildermanifest(PathBiMap manifest)InventoryBuildermanifest(Map<String,Set<String>> manifest)InventoryBuildermutableHead(boolean mutableHead)InventoryBuilderobjectRootPath(String objectRootPath)InventoryBuilderpreviousDigest(String previousDigest)InventoryBuilderputVersion(VersionNum versionNum, Version version)Inserts a version at the specified version number.InventoryBuilderremoveContentPath(String contentPath)Removes a file from the manifest and fixity bock by content pathInventoryBuilderremoveContentPathFromFixity(String contentPath)Removes a file from the fixity block by content pathInventoryBuilderremoveFileId(String fileId)Removes a file from the manifest and fixity blockInventoryBuilderrevisionNum(RevisionNum revisionNum)InventoryBuildertype(InventoryType type)InventoryBuilderversions(Map<VersionNum,Version> versions)
-
-
-
Method Detail
-
addHeadVersion
public InventoryBuilder addHeadVersion(Version version)
Add the version as the new HEAD version. This assigns the version the next available version number, unless it's mutable.- Parameters:
version- the new version- Returns:
- builder
-
putVersion
public InventoryBuilder putVersion(VersionNum versionNum, Version version)
Inserts a version at the specified version number. This will OVERWRITE any version that is currently at that location.- Parameters:
versionNum- the id of the versionversion- the version- Returns:
- builder
-
addFileToManifest
public InventoryBuilder addFileToManifest(String id, String contentPath)
Adds a file to the manifest- Parameters:
id- the fileId of the filecontentPath- the content path of the file- Returns:
- builder
-
removeFileId
public InventoryBuilder removeFileId(String fileId)
Removes a file from the manifest and fixity block- Parameters:
fileId- the fileId of the file- Returns:
- builder
-
removeContentPath
public InventoryBuilder removeContentPath(String contentPath)
Removes a file from the manifest and fixity bock by content path- Parameters:
contentPath- the content path of the file to remove- Returns:
- builder
-
removeContentPathFromFixity
public InventoryBuilder removeContentPathFromFixity(String contentPath)
Removes a file from the fixity block by content path- Parameters:
contentPath- the content path of the file to remove- Returns:
- builder
-
addFixityForFile
public InventoryBuilder addFixityForFile(String contentPath, DigestAlgorithm algorithm, String value)
Adds a file to the fixity block- Parameters:
contentPath- the content path of the filealgorithm- digest algorithmvalue- digest value- Returns:
- builder
-
clearFixity
public InventoryBuilder clearFixity()
Removes all of the entries from the fixity block.- Returns:
- builder
-
id
public InventoryBuilder id(String id)
-
type
public InventoryBuilder type(InventoryType type)
-
digestAlgorithm
public InventoryBuilder digestAlgorithm(DigestAlgorithm digestAlgorithm)
-
head
public InventoryBuilder head(VersionNum head)
-
contentDirectory
public InventoryBuilder contentDirectory(String contentDirectory)
-
fixityBiMap
public InventoryBuilder fixityBiMap(Map<DigestAlgorithm,PathBiMap> fixity)
-
fixity
public InventoryBuilder fixity(Map<DigestAlgorithm,Map<String,Set<String>>> fixity)
-
manifest
public InventoryBuilder manifest(PathBiMap manifest)
-
manifest
public InventoryBuilder manifest(Map<String,Set<String>> manifest)
-
versions
public InventoryBuilder versions(Map<VersionNum,Version> versions)
-
mutableHead
public InventoryBuilder mutableHead(boolean mutableHead)
-
revisionNum
public InventoryBuilder revisionNum(RevisionNum revisionNum)
-
objectRootPath
public InventoryBuilder objectRootPath(String objectRootPath)
-
previousDigest
public InventoryBuilder previousDigest(String previousDigest)
-
currentDigest
public InventoryBuilder currentDigest(String currentDigest)
-
build
public Inventory build()
- Returns:
- a new Inventory
-
containsFileId
public boolean containsFileId(String fileId)
Indicates if the manifest contains a fileId- Parameters:
fileId- the fileId- Returns:
- true if the manifest contains the fileId
-
containsContentPath
public boolean containsContentPath(String contentPath)
Indicates if the manifest contains a contentPath- Parameters:
contentPath- the contentPath- Returns:
- true if the manifest contains the contentPath
-
getContentPaths
public Set<String> getContentPaths(String fileId)
Retrieves the content paths associated to the fileId or an empty set- Parameters:
fileId- the fileId- Returns:
- associated content paths or an empty set
-
getFileId
public String getFileId(String contentPath)
Retrieves the fileId associated to the content path- Parameters:
contentPath- the contentPath- Returns:
- associated fileId or null
-
hasMutableHead
public boolean hasMutableHead()
-
getFileFixity
public String getFileFixity(String fileId, DigestAlgorithm algorithm)
Returns the fixity digest for a file or null- Parameters:
fileId- the fileIdalgorithm- the digest algorithm- Returns:
- digest or null
-
-