Package io.goobi.viewer.controller
Class DataFileTools
java.lang.Object
io.goobi.viewer.controller.DataFileTools
Utility class for retrieving data folders, data files and source files.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Path
getAltoFolder
(String pi) Constructs the alto folder path for the given pi, either directly in viewer-home or within a data repositorystatic Path
getDataFilePath
(String pi, String relativeFilePath) getDataFilePath.static Path
getDataFilePath
(String pi, String dataFolderName, String altDataFolderName, String fileName) Returns the path to the data file (if file name given) or data folder for the given record identifier.static Path
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.static Path
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.static String
Retrieves the path to viewer home or repositories root, depending on the record.static Dataset
getDataset
(String pi) creates a Dataset object, containing all relevant file pathsstatic Path
getMediaFolder
(String pi) Constructs the media folder path for the given pi, either directly in viewer-home or within a data repositorystatic Path
getPdfFolder
(String pi) Constructs the pdf folder path for the given pi, either directly in viewer-home or within a data repositorystatic String
getSourceFilePath
(String fileName, String format) Returns the absolute path to the source (METS/LIDO/etc.) file with the given file name.static String
getSourceFilePath
(String fileName, String dataRepository, String format) Returns the absolute path to the source (METS/LIDO/DENKXWEB/DUBLINCORE) file with the given file name.static Path
getTextFilePath
(String pi, String relativeFilePath) getTextFilePath.static String
getTextFilePath
(String pi, String fileName, String format) getTextFilePath.static StringPair
static String
loadFromApiURl
(String fulltextFilePath) static String
loadFulltext
(String altoFilePath, String fulltextFilePath, boolean mergeLineBreakWords) Loads plain full-text via the REST service.static String
loadTei.
-
Method Details
-
getDataRepositoryPathForRecord
public static 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
public static Path getMediaFolder(String pi) throws PresentationException, IndexUnreachableException 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.
-
getPdfFolder
Constructs the pdf 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 pdf folder for the given PI
- Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
getAltoFolder
Constructs the alto 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 alto folder for the given PI
- Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
getDataFolders
public static 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
- aString
object.- Returns:
- HashMap<dataFolderName,Path>
- Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
getDataFolder
public static 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. -
getDataFilePath
public static Path getDataFilePath(String pi, String dataFolderName, String altDataFolderName, String fileName) 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 choicefileName
- Optional name of the content file- Returns:
- Path to the requested file or folder
- Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
getDataFilePath
public static 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 static String getSourceFilePath(String fileName, String format) throws PresentationException, IndexUnreachableException Returns the absolute path to the source (METS/LIDO/etc.) file with the given file name.- Parameters:
fileName
- aString
object.format
- aString
object.- Returns:
- a
String
object. - 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. -
getTextFilePath
public static String getTextFilePath(String pi, String fileName, String format) throws PresentationException, IndexUnreachableException getTextFilePath.
- Parameters:
pi
- aString
object.fileName
- aString
object.format
- aString
object.- Returns:
- a
String
object. - Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
getTextFilePath
public static Path getTextFilePath(String pi, String relativeFilePath) throws PresentationException, IndexUnreachableException getTextFilePath.
- Parameters:
pi
- aString
object.relativeFilePath
- ALTO/text file path relative to the data folder- Returns:
- a
Path
object. - Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
loadFulltext
public static String loadFulltext(String altoFilePath, String fulltextFilePath, boolean mergeLineBreakWords) throws IOException, IndexUnreachableException 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
- a boolean.- Returns:
- a
String
object. - Throws:
AccessDeniedException
- if any.FileNotFoundException
- if any.IOException
- if any.IndexUnreachableException
- if any.DAOException
- if any.ViewerConfigurationException
- if any.
-
loadFromApiURl
- Throws:
FileNotFoundException
-
loadAlto
public static StringPair loadAlto(String altoFilePath) throws de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException, IndexUnreachableException, PresentationException, FileNotFoundException - Parameters:
altoFilePath
-- Returns:
- StringPair(ALTO,charset)
- Throws:
de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException
IndexUnreachableException
PresentationException
FileNotFoundException
-
loadTei
loadTei.
- Parameters:
pi
- aString
object.language
- aString
object.- Returns:
- a
String
object. - Throws:
AccessDeniedException
- if any.FileNotFoundException
- if any.IOException
- if any.ViewerConfigurationException
- if any.
-
getDataset
public static Dataset getDataset(String pi) throws PresentationException, IndexUnreachableException, RecordNotFoundException, IOException creates a Dataset object, containing all relevant file paths- Parameters:
pi
- aString
object.- Returns:
- a
Dataset
object. - Throws:
PresentationException
IndexUnreachableException
RecordNotFoundException
IOException
-