Class ArchiveManager

java.lang.Object
io.goobi.viewer.model.archives.ArchiveManager
All Implemented Interfaces:
Serializable

public class ArchiveManager extends Object implements Serializable
Loads and holds archive tree models. This class should have an application wide scope
Author:
Florian Alpers
See Also:
  • Constructor Details

    • ArchiveManager

      public ArchiveManager()
  • Method Details

    • getArchiveTree

      Parameters:
      resourceId - identifier of the archive resource to load
      Returns:
      ArchiveTree
      Throws:
      IllegalStateException
      PresentationException
      IndexUnreachableException
    • getArchiveResource

      public ArchiveResource getArchiveResource(String archiveName)
      Parameters:
      archiveName - name of the archive resource to look up
      Returns:
      ArchiveResource
    • getNodeType

      public NodeType getNodeType(String name)
      Returns the node type configured for the given name. If no node type is configured for the name, then the default node type - indicated by the default="true" attribute - is used
      Parameters:
      name - node type name to look up in the configuration
      Returns:
      NodeType
    • getOnlyDatabaseResource

      public Optional<ArchiveResource> getOnlyDatabaseResource()
      If only one archive database exists and database status is ArchiveManager.DatabaseState.ARCHIVES_LOADED, redirect to the matching url.
      Returns:
      Optional
    • loadArchiveForEntry

      Parameters:
      identifier - EAD node ID used to locate the containing archive
      Returns:
      ArchiveResource
      Throws:
      IllegalStateException
      PresentationException
      IndexUnreachableException
    • getArchiveUrl

      public String getArchiveUrl(ArchiveResource resource, String entryIdentifier)
      Parameters:
      resource - archive resource the entry belongs to
      entryIdentifier - identifier of the selected archive entry
      Returns:
      Constructed URL
    • getDatabaseState

      public ArchiveManager.DatabaseState getDatabaseState()
    • getDatabases

      public List<ArchiveResource> getDatabases()
      Returns:
      List
    • findIndexedNeighbours

      public static org.apache.commons.lang3.tuple.Pair<Optional<String>,Optional<String>> findIndexedNeighbours(String entryId) throws PresentationException, IndexUnreachableException
      In the list of archive document search hits, find the id of the entry just before the given one.
      Parameters:
      entryId - EAD node ID for which neighbours are to be found
      Returns:
      the neighboring entry id if it exists
      Throws:
      PresentationException
      IndexUnreachableException
    • getArchiveHierarchyForIdentifier

      public List<ArchiveEntry> getArchiveHierarchyForIdentifier(ArchiveResource resource, String identifier)
      Returns the entry hierarchy from the root down to the entry with the given identifier.
      Parameters:
      resource - archive resource whose tree is searched
      identifier - Entry identifier
      Returns:
      List of entries An empty list if the identified node has no ancestors or doesn't exist
    • getArchive

      public ArchiveResource getArchive(String resourceId)
      Returns the loaded archive with the given resource ID.
      Parameters:
      resourceId - the resource identifier of the archive to look up
      Returns:
      the matching ArchiveResource, or null if not found or resourceId is blank
    • getUpdatedNodeTypes

      public Map<String,NodeType> getUpdatedNodeTypes()
      Reloads nodeTyps from the config.
      Returns:
      this.nodeTypes
    • updateArchiveList

      public void updateArchiveList()
      Checks the list of ead archives for updates. An update occurs if either the "lastModifiedDate" of an archive has changed since the last request, or if an archive was added or removed. In these cases, the list of records associated with an archive entry is updated as well
    • unloadArchives

      public int unloadArchives(Set<String> resourceIds)
      Removes archives from the loaded archives map if their resourceId matches any in the given list.
      Parameters:
      resourceIds - List of archive resource IDs to remove
      Returns:
      Number of removed archives
    • isInErrorState

      public boolean isInErrorState()
    • getEadParser

      public ArchiveParser getEadParser()