Package org.mycore.frontend.cli
Class MCRCommandUtils
java.lang.Object
org.mycore.frontend.cli.MCRCommandUtils
Utilities intended to reduce redundant code when writing variants of CLI commands.
- Author:
- Christoph Neidahl (OPNA2608)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetIdsForBaseId
(String base) Get a stream of MCRObjectIDs found for a base.getIdsForProjectAndType
(String project, String type) Get a stream of MCRObjectIDs found for a project & type combination.getIdsForType
(String type) Get a stream of MCRObjectIDs found for a type.getIdsFromIdToId
(String startId, String endId) Get a stream of MCRObjectIDs found in range between two IDs, incrementing/decrementing by 1.static final Transformer
getTransformer
(String style, String defaultStyle, Map<String, Transformer> cache) This method search for the stylesheet style.xsl and builds a transformer.
-
Constructor Details
-
MCRCommandUtils
public MCRCommandUtils()
-
-
Method Details
-
getIdsForType
Get a stream of MCRObjectIDs found for a type.- Parameters:
type
- The type to look in the store for.- Returns:
- A (parallel) stream with found IDs. (may be empty if none were found)
- Throws:
MCRUsageException
- If no type was given or the type could not be found. Not thrown if type exists but has no values.
-
getIdsForProjectAndType
public static final Stream<String> getIdsForProjectAndType(String project, String type) throws MCRUsageException Get a stream of MCRObjectIDs found for a project & type combination.- Parameters:
project
- The project to look in the store for.type
- The type to look in the store for.- Returns:
- A (parallel) stream with found IDs. (may be empty if none were found)
- Throws:
MCRUsageException
- If no project was given, no type was given or the base (${project}_${base}) could not be found. Not thrown if the base exists but has no values.
-
getIdsForBaseId
Get a stream of MCRObjectIDs found for a base.- Parameters:
base
- The base to look in the store for.- Returns:
- A (parallel) stream with found IDs. (may be empty if none were found)
- Throws:
MCRUsageException
- If no base was given or the base could not be found. Not thrown if the base exists but has no values.
-
getIdsFromIdToId
public static final Stream<String> getIdsFromIdToId(String startId, String endId) throws MCRUsageException Get a stream of MCRObjectIDs found in range between two IDs, incrementing/decrementing by 1.- Parameters:
startId
- The first ID to start iterating from.endId
- The last ID to iterate towards.- Returns:
- A (parallel) stream with generated IDs that exist in the store. (may be empty if none exist)
- Throws:
MCRUsageException
- If the supplied IDs are missing, invalid or have different base IDs, or if an error occurred while getting the store responsible for their base. The latter *may* occur if there does not yet exist a store for this base. Not thrown if the base exists but has no values.
-
getTransformer
public static final Transformer getTransformer(String style, String defaultStyle, Map<String, Transformer> cache) This method search for the stylesheet style.xsl and builds a transformer. A fallback is used if no stylesheet is given or the stylesheet couldn't be resolved.- Parameters:
style
- the name of the style to be used when resolving the stylesheet.defaultStyle
- the name of the default style to be used when resolving the stylesheet. A corresponding file xsl/defaultStyle.xsl must exist.cache
- The transformer cache to be used.- Returns:
- the transformer
-