Package io.goobi.viewer.controller
Class ProcessDataResolver
java.lang.Object
io.goobi.viewer.controller.ProcessDataResolver
Utility class for retrieving data folders, data files and source files. Must be instantiated with
Configuration, SolrSearchIndex
and RestApiManager as data sources No-Args constructor creates required data sources from DataManager.getInstance()-
Constructor Summary
ConstructorsConstructorDescriptionProcessDataResolver(Configuration config, SolrSearchIndex searchIndex, RestApiManager restApiManager) -
Method Summary
Modifier and TypeMethodDescriptiongetDataFilePath(String pi, String relativeFilePath) getDataFilePath.getDataFilePath(String pi, String dataFolderName, String altDataFolderName, String inFileName) Returns the path to the data file (if file name given) or data folder for the given record identifier.getDataFolder(String pi, String dataFolderName) Constructs the folder path for data of the given pi, either directly in viewer-home or within a data repository.getDataFolder(String pi, String dataFolderName, String dataRepositoryFolder) Returns the data folder path for the given record identifier.getDataFolders(String pi, String... dataFolderNames) Returns a map of Paths for each data folder name passed as an argument.Retrieves the path to viewer home or repositories root, depending on the record.getDataset(String pi) Creates a Dataset object, containing all relevant file paths.getMediaFolder(String pi) Constructs the media folder path for the given pi, either directly in viewer-home or within a data repository.getSourceFilePath(String fileName, String format) Returns the absolute path to the source (METS/LIDO) file with the given file name.getSourceFilePath(String fileName, String dataRepository, String format) Returns the absolute path to the source (METS/LIDO/DENKXWEB/DUBLINCORE) file with the given file name.getTextFilePath(String pi, String relativeFilePath) getTextFilePath.getTextFilePath(String pi, String fileName, String format) getTextFilePath.loadFulltext(String altoFilePath, String fulltextFilePath, boolean mergeLineBreakWords, HttpServletRequest request) Loads plain full-text via the REST service.loadTei.
-
Constructor Details
-
ProcessDataResolver
public ProcessDataResolver(Configuration config, SolrSearchIndex searchIndex, RestApiManager restApiManager) -
ProcessDataResolver
public ProcessDataResolver()
-
-
Method Details
-
getDataRepositoryPathForRecord
public String getDataRepositoryPathForRecord(String pi) throws PresentationException, IndexUnreachableException Retrieves the path to viewer home or repositories root, depending on the record. Used to generate a specific task client query parameter.- Parameters:
pi- Record identifier- Returns:
- The root folder path of the data repositories; viewer home if none are used
- Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
getMediaFolder
Constructs the media folder path for the given pi, either directly in viewer-home or within a data repository.- Parameters:
pi- The work PI. This is both the actual name of the folder and the identifier used to look up data repository in solr- Returns:
- A Path to the media folder for the given PI
- Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
getDataFolders
public Map<String,Path> getDataFolders(String pi, String... dataFolderNames) throws PresentationException, IndexUnreachableException Returns a map of Paths for each data folder name passed as an argument.- Parameters:
pi- The record identifier. This is both the actual name of the folder and the identifier used to look up data repository in SolrdataFolderNames- names of the data folders to resolve- Returns:
- HashMap<dataFolderName,Path>
- Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
getDataFolder
public Path getDataFolder(String pi, String dataFolderName) throws PresentationException, IndexUnreachableException Constructs the folder path for data of the given pi, either directly in viewer-home or within a data repository.- Parameters:
pi- The record identifier. This is both the actual name of the folder and the identifier used to look up data repository in SolrdataFolderName- the data folder within the repository; e.g 'media' or 'alto'- Returns:
- A Path to the data folder for the given PI
- Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
getDataFolder
Returns the data folder path for the given record identifier. To be used in clients that already possess the data repository name.- Parameters:
pi- persistent identifier of the recorddataFolderName- name of the data subfolder (e.g. 'alto', 'media')dataRepositoryFolder- Absolute path to the data repository folder or just the folder name- Returns:
- the resolved path to the named data subfolder for the given record
-
getDataFilePath
public Path getDataFilePath(String pi, String dataFolderName, String altDataFolderName, String inFileName) throws PresentationException, IndexUnreachableException Returns the path to the data file (if file name given) or data folder for the given record identifier.- Parameters:
pi- Record identifierdataFolderName- Name of the data folder (e.g. 'alto') - first choicealtDataFolderName- Name of the data folder - second choiceinFileName- Optional name of the content file- Returns:
- Path to the requested file or folder
- Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
getDataFilePath
public Path getDataFilePath(String pi, String relativeFilePath) throws PresentationException, IndexUnreachableException getDataFilePath.- Parameters:
pi- Record identifierrelativeFilePath- File path relative to data repositories root- Returns:
- File represented by the relative file path
- Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
getSourceFilePath
public String getSourceFilePath(String fileName, String format) throws PresentationException, IndexUnreachableException Returns the absolute path to the source (METS/LIDO) file with the given file name.- Parameters:
fileName- source file name (basename is used as record identifier)format- source document format (e.g. METS, LIDO)- Returns:
- the absolute file system path to the source file
- Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
getSourceFilePath
Returns the absolute path to the source (METS/LIDO/DENKXWEB/DUBLINCORE) file with the given file name.- Parameters:
fileName- source file name including extensiondataRepository- path or name of the data repository folderformat- source document format (e.g. METS, LIDO)- Returns:
- the absolute file system path to the source file in the resolved data repository
-
getTextFilePath
public String getTextFilePath(String pi, String fileName, String format) throws PresentationException, IndexUnreachableException getTextFilePath.- Parameters:
pi- persistent identifier of the recordfileName- name of the text fileformat- text format constant (e.g. FILENAME_ALTO, FILENAME_FULLTEXT)- Returns:
- the absolute file system path to the text file in the resolved data repository
- Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
getTextFilePath
public Path getTextFilePath(String pi, String relativeFilePath) throws PresentationException, IndexUnreachableException getTextFilePath.- Parameters:
pi- persistent identifier of the recordrelativeFilePath- ALTO/text file path relative to the data folder- Returns:
- the absolute path to the text file within the resolved data repository
- Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
loadFulltext
public String loadFulltext(String altoFilePath, String fulltextFilePath, boolean mergeLineBreakWords, HttpServletRequest request) throws IOException, IndexUnreachableException, DAOException, ViewerConfigurationException Loads plain full-text via the REST service. ALTO is is a fallback (and converted to plain text, with a plain text fallback.- Parameters:
altoFilePath- ALTO file path relative to the repository root (e.g. "alto/PPN123/00000001.xml")fulltextFilePath- plain full-text file path relative to the repository root (e.g. "fulltext/PPN123/00000001.xml")mergeLineBreakWords- true to merge words split across line breaksrequest- HTTP request used for access permission checks- Returns:
- the plain text content of the page, or null if no fulltext could be loaded
- Throws:
AccessDeniedException- if any.IOException- if any.IndexUnreachableException- if any.DAOException- if any.ViewerConfigurationException- if any.
-
loadAlto
public StringPair loadAlto(String altoFilePath) throws de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException, IndexUnreachableException, PresentationException, FileNotFoundException - Parameters:
altoFilePath- path to the ALTO XML file- Returns:
- StringPair(ALTO,charset)
- Throws:
de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundExceptionIndexUnreachableExceptionPresentationExceptionFileNotFoundException
-
loadTei
loadTei.- Parameters:
pi- persistent identifier of the recordlanguage- ISO language code for the requested TEI document- Returns:
- the TEI document content as a string, or null if not available
- Throws:
AccessDeniedException- if any.IOException- if any.ViewerConfigurationException- if any.
-
getDataset
public Dataset getDataset(String pi) throws PresentationException, IndexUnreachableException, RecordNotFoundException, IOException Creates a Dataset object, containing all relevant file paths.- Parameters:
pi- persistent identifier of the record to build the dataset for- Returns:
- the Dataset containing all relevant file paths for the given record
- Throws:
PresentationExceptionIndexUnreachableExceptionRecordNotFoundExceptionIOException
-