Merge pull request #4028 from matthias-ronge/resolve-os
Suggestion for Windows and Linux file extensions
This commit is contained in:
commit
df8814b678
|
@ -11,6 +11,7 @@
|
|||
|
||||
package org.kitodo.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.NoSuchElementException;
|
||||
|
@ -84,10 +85,9 @@ public class KitodoConfig extends Config {
|
|||
* @throws NoSuchElementException
|
||||
* if parameter taken from config file is null or exception occurred
|
||||
*/
|
||||
//TODO: there is still image management where it is needed
|
||||
public static String getParameter(String key) {
|
||||
try {
|
||||
return getConfig().getString(key);
|
||||
return resolveOsSpecific(getConfig().getString(key));
|
||||
} catch (NoSuchElementException e) {
|
||||
throw new NoSuchElementException("No configuration found in " + CONFIG_FILE + " for key " + key + "!");
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ public class KitodoConfig extends Config {
|
|||
*/
|
||||
public static Optional<String> getOptionalString(ParameterInterface key) {
|
||||
try {
|
||||
return Optional.of(getConfig().getString(key.getName()));
|
||||
return Optional.of(resolveOsSpecific(getConfig().getString(key.getName())));
|
||||
} catch (NoSuchElementException e) {
|
||||
logger.catching(Level.TRACE, e);
|
||||
return Optional.empty();
|
||||
|
@ -268,4 +268,16 @@ public class KitodoConfig extends Config {
|
|||
public static URI getUriParameter(ParameterInterface key, String fullFilenameToAdd) {
|
||||
return Paths.get(FilenameUtils.concat(getParameter(key), fullFilenameToAdd)).toUri();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameter value like "foo(.bar|.baz)" will resolve to "foo.bar" on Unix
|
||||
* and to "foo.baz" on Windows.
|
||||
*
|
||||
* @param string
|
||||
* string to process
|
||||
* @return OS-specific string
|
||||
*/
|
||||
private static String resolveOsSpecific(String string) {
|
||||
return string.replaceFirst("\\((\\p{Graph}*)\\|(\\p{Graph}*)\\)$", File.separatorChar == '/' ? "$1" : "$2");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,6 @@ directory.metadata=src/test/resources/
|
|||
directory.modules=../Kitodo/modules/
|
||||
# Script to create a symbolic link in the user home directory and set
|
||||
# permissions for the user
|
||||
script_createSymLink=src/test/resources/scripts/script_createSymLink.sh
|
||||
script_createSymLink=src/test/resources/scripts/script_createSymLink(.sh|.bat)
|
||||
script_deleteSymLink=src/test/resources/scripts/script_deleteSymLink.sh
|
||||
script_createDirMeta=src/test/resources/scripts/script_createDirMeta.sh
|
||||
script_createDirMeta=src/test/resources/scripts/script_createDirMeta(.sh|.bat)
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
:: (c) Kitodo. Key to digital objects e. V. <contact@kitodo.org>
|
||||
::
|
||||
:: This file is part of the Kitodo project.
|
||||
::
|
||||
:: It is licensed under GNU General Public License version 3 or later.
|
||||
::
|
||||
:: For the full copyright and license information, please read the
|
||||
:: GPL3-License.txt file that was distributed with this source code.
|
||||
::
|
||||
|
||||
::
|
||||
:: Note: Ensure that Tomcat has permission to execute the given commands.
|
||||
::
|
||||
|
||||
md %1
|
|
@ -0,0 +1,16 @@
|
|||
::
|
||||
:: (c) Kitodo. Key to digital objects e. V. <contact@kitodo.org>
|
||||
::
|
||||
:: This file is part of the Kitodo project.
|
||||
::
|
||||
:: It is licensed under GNU General Public License version 3 or later.
|
||||
::
|
||||
:: For the full copyright and license information, please read the
|
||||
:: GPL3-License.txt file that was distributed with this source code.
|
||||
::
|
||||
|
||||
::
|
||||
:: Note: Ensure that Tomcat has permission to execute the given commands.
|
||||
::
|
||||
|
||||
mkdir %2
|
|
@ -99,31 +99,43 @@ useOrigFolder=true
|
|||
# Directory and symbolic link management
|
||||
# -----------------------------------
|
||||
|
||||
# For each process, a process directory will be created to store the associated
|
||||
# files in them. If a user accepts a task to work on which will require him
|
||||
# or her to have access permission to the data of a process, a symbolic link
|
||||
# to the process directory in question will be created in his or her home
|
||||
# directory that will be removed again after finishing the task. Since the
|
||||
# application is based on Java 6 which cannot handle file system permissions,
|
||||
# scripts are called to do these things. The scripts must have been configured
|
||||
# to have sufficient permissions to do whatever they should do.
|
||||
# For each user, Production creates a user home directory. For each process,
|
||||
# Production creates a process directory to store the process files in it. As a
|
||||
# user starts to work on a task which gives access to the process files, a
|
||||
# symbolic link will be created. It is created in the user's home directory, is
|
||||
# named like the process, and points to the folder 'images/' in the process
|
||||
# directory in question. The link will be removed when the user finishes or
|
||||
# resigns from the task.
|
||||
# The idea behind this is to use the users' home directories as the starting
|
||||
# point for network drives and to only give users access to the directories
|
||||
# that are currently relevant to them.
|
||||
# In the era of Java 5, these scripts were introduced to handle file system
|
||||
# permissions. Meanwhile they are used to implement various extensions and have
|
||||
# therefore been kept. The scripts are executed by the same user as the servlet
|
||||
# container and must be configured to have sufficient permissions to do
|
||||
# whatever they are intended to (i.e., sudo without password).
|
||||
# Refer to the installation guide how to set up all of this.
|
||||
#
|
||||
# For examples of these scripts, see the *.sh files in subdirectory `script`
|
||||
# of your Kitodo installation.
|
||||
# For examples of these scripts, see the *.sh and *.bat files in subdirectory
|
||||
# 'script' of your Kitodo installation.
|
||||
# You will have to set execute permission before using those script files.
|
||||
#
|
||||
# The syntax allows to define a second alternative script to run on Windows.
|
||||
# This is to provide an example which runs out of the box on either OS. You
|
||||
# don't need to use this syntax.
|
||||
|
||||
# Script to create the user's home directory when adding a new user
|
||||
script_createDirUserHome=/usr/local/kitodo/scripts/script_createDirUserHome.sh
|
||||
script_createDirUserHome=/usr/local/kitodo/scripts/script_createDirUserHome(.sh|.bat)
|
||||
|
||||
# Script to create the directory for a new process
|
||||
script_createDirMeta=/usr/local/kitodo/scripts/script_createDirMeta.sh
|
||||
script_createDirMeta=/usr/local/kitodo/scripts/script_createDirMeta(.sh|.bat)
|
||||
|
||||
# Script to create a symbolic link in the user home directory and set
|
||||
# permissions for the user
|
||||
script_createSymLink=/usr/local/kitodo/scripts/script_createSymLink.sh
|
||||
script_createSymLink=/usr/local/kitodo/scripts/script_createSymLink(.sh|.bat)
|
||||
|
||||
# Script to remove the symbolic link from the user home directory
|
||||
script_deleteSymLink=/usr/local/kitodo/scripts/script_deleteSymLink.sh
|
||||
script_deleteSymLink=/usr/local/kitodo/scripts/script_deleteSymLink(.sh|.bat)
|
||||
|
||||
# Process property to use in the name of the smLink.
|
||||
# If none is specified or if the property cannot be found the process title will be used by default.
|
||||
|
|
|
@ -26,12 +26,12 @@ xsltFilenameMetadataTransformation=MetsModsGoobi_to_MetsKitodo.xsl
|
|||
# Path to directory in which BPMN diagrams are stored
|
||||
directory.diagrams=src/test/resources/diagrams/
|
||||
# Script to create the directory for a new process
|
||||
script_createDirMeta=src/test/resources/scripts/script_createDirMeta.sh
|
||||
script_createDirUserHome=src/test/resources/scripts/script_createDirUserHome.sh
|
||||
script_createDirMeta=src/test/resources/scripts/script_createDirMeta(.sh|.bat)
|
||||
script_createDirUserHome=src/test/resources/scripts/script_createDirUserHome(.sh|.bat)
|
||||
# Script to create a symbolic link in the user home directory and set
|
||||
# permissions for the user
|
||||
script_createSymLink=src/test/resources/scripts/script_createSymLink.sh
|
||||
script_deleteSymLink=src/test/resources/scripts/script_deleteSymLink.sh
|
||||
script_createSymLink=src/test/resources/scripts/script_createSymLink(.sh|.bat)
|
||||
script_deleteSymLink=src/test/resources/scripts/script_deleteSymLink(.sh|.bat)
|
||||
# Prefix for image names as regex.
|
||||
image.prefix=.*
|
||||
|
||||
|
|
Loading…
Reference in New Issue