Skip to content

Commit

Permalink
Merge branch 'kitodo:master' into fix-inconsistent-image-number-in-ad…
Browse files Browse the repository at this point in the history
…d-doc-struct-type-dialog
  • Loading branch information
thomaslow authored Sep 4, 2023
2 parents e2d8631 + 37c5e86 commit 8e10dae
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ void attachToExistingParentAndGenerateAtstslIfNotExist(TempProcess tempProcess)
}
}

if (StringUtils.isBlank(tempProcess.getAtstsl()) && Objects.nonNull(parentTempProcess)) {
ProcessHelper.generateAtstslFields(tempProcess, Collections.singletonList(parentTempProcess),
ImportService.ACQUISITION_STAGE_CREATE, true);
if (StringUtils.isBlank(tempProcess.getAtstsl())) {
if (Objects.nonNull(parentTempProcess)) {
ProcessHelper.generateAtstslFields(tempProcess, Collections.singletonList(parentTempProcess),
ImportService.ACQUISITION_STAGE_CREATE, true);
} else {
ProcessHelper.generateAtstslFields(tempProcess, null,
ImportService.ACQUISITION_STAGE_CREATE, true);
}
}
}

Expand Down Expand Up @@ -126,7 +131,7 @@ void extendsMetadataTableOfMetadataTab(LinkedList<TempProcess> processes)
throws InvalidMetadataValueException, NoSuchMetadataFieldException {

int countOfAddedMetadata = 0;
if (processes.size() > 0) {
if (!processes.isEmpty()) {
TempProcess process = processes.getFirst();
if (process.getMetadataNodes().getLength() > 0) {
if (createProcessForm.getProcessDataTab().getDocType()
Expand Down
1 change: 1 addition & 0 deletions Kitodo/src/main/resources/messages/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ docstructAnAndereStelleSchieben=Strukturelement an andere Stelle schieben
docstructNachObenSchieben=Strukturelement nach oben schieben
docstructNachUntenSchieben=Strukturelement nach unten schieben
docstructs=Strukturelemente
documentType=Dokumenttyp
down=unter
download=Images herunterladen
doYouWantToProceed=Wollen Sie fortfahren?
Expand Down
1 change: 1 addition & 0 deletions Kitodo/src/main/resources/messages/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ docstructAnAndereStelleSchieben=Move docstruct to other location
docstructNachObenSchieben=Move docstruct up
docstructNachUntenSchieben=Move docstruct down
docstructs=Docstructs
documentType=Document type
down=down
download=Download images
doYouWantToProceed=Do you want to proceed?
Expand Down
6 changes: 6 additions & 0 deletions Kitodo/src/main/resources/messages/messages_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ dataEditor.removeElement.noConsecutivePagesSelected=Los elementos estructurales
dataEditor.selectMetadataTask=Seleccionar la tarea
dataEditor.layoutSavedSuccessfullyTitle=La plantilla actual se guardó correctamente
dataEditor.layoutSavedSuccessfullyText=Su configuración actual del editor ha sido guardada con éxito y será aplicadad a todas las tareas futuras del mismo tipo.
dataEditor.renameMedia=Cambiar el nombre de los archivos de medios
dataEditor.renamingMediaComplete=El cambio de nombre de los medios ha finalizado
dataEditor.renamingMediaError=Se produjo un error al cambiar el nombre de los archivos multimedia
dataEditor.renamingMediaText=Se ha cambiado el nombre de {0} archivos de medios en {1} carpeta. Por favor, haga clic en el botón 'Guardar' para mantener los cambios en los nombres de archivo. De lo contrario, el cambio de nombre se revertirá al cerrar el editor.
dataEditor.structure.customizeDisplay=Personalizar la pantalla
dataEditor.structureTree.collapseAll=Ocultar todo
dataEditor.structureTree.expandAll=Expandir todo
Expand Down Expand Up @@ -451,6 +455,7 @@ fileGroupDelete=Borrar grupo de archivos
fileMassImport=Importación masiva de archivos
filename=Nombre del archivo
files=Archivos
filenameLengthForRenaming=Longitud del nombre de archivo para cambiar nombres de archivos multimedia
filter=Filtro
filterAdjust=Adaptar el filtro
filterApply=Aplicar filtro
Expand Down Expand Up @@ -1275,6 +1280,7 @@ assignTask=Asignar tarea
overrideTask=Asumir la tarea
superviseTask=Observar la tarea
resetWorkflow=Restablecer el flujo de trabajo
renameMedia=Cambiar el nombre de los archivos multimedia
runKitodoScript=Ejecutar KitodoScript

viewAllAuthorities=Mostrar todos los permisos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

<div>
<!-- DocType -->
<p:outputLabel value="DocType"/>
<p:outputLabel value="#{msgs.documentType}"/>
<p:selectOneMenu id="docType" value="#{CreateProcessForm.processDataTab.docType}">
<f:selectItems value="#{CreateProcessForm.processDataTab.allDoctypes}"
var="step"
Expand Down
12 changes: 10 additions & 2 deletions Kitodo/src/test/java/org/kitodo/selenium/MigrationST.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
import org.kitodo.selenium.testframework.pages.WorkflowEditPage;

public class MigrationST extends BaseTestSelenium {

private String randomWorkflowName;

@Before
public void login() throws Exception {
Pages.getLoginPage().goTo().performLoginAsAdmin();
Expand All @@ -44,10 +47,14 @@ public void login() throws Exception {
public void logout() throws Exception {
FileService fileService = ServiceManager.getFileService();
String diagramDirectory = ConfigCore.getKitodoDiagramDirectory();
URI svgDiagramURI = new File(diagramDirectory + "FinishedClosedProgressOpenLocked.svg").toURI();
URI xmlDiagramURI = new File(diagramDirectory + "FinishedClosedProgressOpenLocked.bpmn20.xml").toURI();
// remove XML and SVG files of migration workflow
URI svgDiagramURI = new File(diagramDirectory + "migrationWorkflow.svg").toURI();
URI xmlDiagramURI = new File(diagramDirectory + "migrationWorkflow.bpmn20.xml").toURI();
fileService.delete(svgDiagramURI);
fileService.delete(xmlDiagramURI);
// remove XML file of workflow with randomly generated name
xmlDiagramURI = new File(diagramDirectory + randomWorkflowName + ".bpmn20.xml").toURI();
fileService.delete(xmlDiagramURI);
Pages.getTopNavigation().logout();
}

Expand All @@ -63,6 +70,7 @@ public void testMigration() throws Exception {
systemPage.selectProjects();
assertEquals("Finished, Closed, Progress, Open, Locked", systemPage.getAggregatedTasks(2));
WorkflowEditPage workflowEditPage = systemPage.createNewWorkflow();
randomWorkflowName = workflowEditPage.getWorkflowTitle();
workflowEditPage.changeWorkflowStatusToActive();
assertTrue(workflowEditPage.getWorkflowTitle().contains("ChangeME"));
workflowEditPage.changeWorkflowTitle("migrationWorkflow");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,7 @@ public static void Initialize() throws IOException {
}

private static void provideChromeDriver() throws IOException {
String driverFileName = "chromedriver";
if (SystemUtils.IS_OS_WINDOWS) {
driverFileName = driverFileName.concat(".exe");
}
File driverFile = new File(DRIVER_DIR + driverFileName);
File driverFile = getDriverFile();

if (!driverFile.exists()) {
logger.debug("{} does not exist, providing chrome driver now", driverFile.getAbsolutePath());
Expand All @@ -106,6 +102,18 @@ private static void provideChromeDriver() throws IOException {
webDriver = new ChromeDriver(service, options);
}

private static File getDriverFile() {
String driver = WebDriverProvider.CHROME_DRIVER;
if (SystemUtils.IS_OS_WINDOWS) {
driver = WebDriverProvider.CHROME_DRIVER_WIN_SUBDIR + "/" + driver.concat(WebDriverProvider.EXE);
} else if (SystemUtils.IS_OS_MAC_OSX) {
driver = WebDriverProvider.CHROME_DRIVER_MAC_SUBDIR + "/" + driver;
} else {
driver = WebDriverProvider.CHROME_DRIVER_LINUX_SUBDIR + "/" + driver;
}
return new File(DRIVER_DIR + driver);
}

private static void provideGeckoDriver() throws IOException {
String driverFileName = "geckodriver";
if (SystemUtils.IS_OS_WINDOWS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonReader;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -32,11 +37,22 @@ public class WebDriverProvider {

private static final Logger logger = LogManager.getLogger(WebDriverProvider.class);

// https://sites.google.com/a/chromium.org/chromedriver/downloads/version-selection
private static final String CHROME_DRIVER_LATEST_RELEASE_URL = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE";

private static UnArchiver zipUnArchiver = new ZipUnArchiver();
private static UnArchiver tarGZipUnArchiver = new TarGZipUnArchiver();
// https://chromedriver.chromium.org/downloads
private static final String CHROME_DRIVER_LAST_GOOD_VERSIONS_URL
= "https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json";
private static final String CHROME_FOR_TESTING_URL = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/";
public static final String CHROME_DRIVER = "chromedriver";
private static final String CHROME_DRIVER_MAC_PREFIX = "mac-x64";
private static final String CHROME_DRIVER_WIN_PREFIX = "win32";
private static final String CHROME_DRIVER_LINUX_PREFIX = "linux64";
public static final String CHROME_DRIVER_MAC_SUBDIR = CHROME_DRIVER + "-" + CHROME_DRIVER_MAC_PREFIX;
public static final String CHROME_DRIVER_WIN_SUBDIR = CHROME_DRIVER + "-" + CHROME_DRIVER_WIN_PREFIX;
public static final String CHROME_DRIVER_LINUX_SUBDIR = CHROME_DRIVER + "-" + CHROME_DRIVER_LINUX_PREFIX;
private static final String ZIP = ".zip";
public static final String EXE = ".exe";
private static final String ZIP_FILE = CHROME_DRIVER + ZIP;
private static final UnArchiver zipUnArchiver = new ZipUnArchiver();
private static final UnArchiver tarGZipUnArchiver = new TarGZipUnArchiver();

/**
* Downloads Geckodriver, extracts archive file and set system property
Expand Down Expand Up @@ -66,8 +82,8 @@ public static void provideGeckoDriver(String geckoDriverVersion, String download
FileUtils.copyURLToFile(new URL(geckoDriverUrl + "geckodriver-v" + geckoDriverVersion + "-macos.tar.gz"),
geckoDriverTarFile);
File theDir = new File(extractFolder);
if (!theDir.exists()) {
theDir.mkdir();
if (!theDir.mkdir()) {
logger.error("Unable to create directory '" + theDir.getPath() + "'!");
}
extractTarFileToFolder(geckoDriverTarFile, theDir);
} else {
Expand Down Expand Up @@ -105,35 +121,36 @@ public static void provideGeckoDriver(String geckoDriverVersion, String download
*/
public static void provideChromeDriver(String downloadFolder, String extractFolder)
throws IOException {

String chromeDriverVersion = fetchLatestStableChromeDriverVersion();

String chromeDriverUrl = "https://chromedriver.storage.googleapis.com/" + chromeDriverVersion + "/";
String chromeDriverFileName;
String chromeDriverUrl = CHROME_FOR_TESTING_URL + chromeDriverVersion + File.separator;
String driverFilename = CHROME_DRIVER;
File chromeDriverFile;
if (SystemUtils.IS_OS_WINDOWS) {
chromeDriverFileName = "chromedriver.exe";
File chromeDriverZipFile = new File(downloadFolder + "chromedriver.zip");
FileUtils.copyURLToFile(new URL(chromeDriverUrl + "chromedriver_win32.zip"), chromeDriverZipFile);
extractZipFileToFolder(chromeDriverZipFile, new File(extractFolder));

driverFilename = driverFilename + EXE;
File chromeDriverZipFile = new File(downloadFolder + CHROME_DRIVER_WIN_SUBDIR + File.separator + ZIP_FILE);
FileUtils.copyURLToFile(new URL(chromeDriverUrl + CHROME_DRIVER_WIN_PREFIX + File.separator
+ CHROME_DRIVER_WIN_SUBDIR + ZIP), chromeDriverZipFile);
chromeDriverFile = extractZipFileToFolder(chromeDriverZipFile, new File(extractFolder), driverFilename,
CHROME_DRIVER_WIN_SUBDIR);
} else if (SystemUtils.IS_OS_MAC_OSX) {
chromeDriverFileName = "chromedriver";
File chromeDriverZipFile = new File(downloadFolder + "chromedriver.zip");
FileUtils.copyURLToFile(new URL(chromeDriverUrl + "chromedriver_mac64.zip"), chromeDriverZipFile);
File chromeDriverZipFile = new File(downloadFolder + CHROME_DRIVER_MAC_SUBDIR + File.separator + ZIP_FILE);
FileUtils.copyURLToFile(new URL(chromeDriverUrl + CHROME_DRIVER_MAC_PREFIX + File.separator
+ CHROME_DRIVER_MAC_SUBDIR + ZIP), chromeDriverZipFile);
File theDir = new File(extractFolder);
if (!theDir.exists()) {
theDir.mkdir();
if (!theDir.mkdir()) {
logger.error("Unable to create directory '" + theDir.getPath() + "'!");
}
}
extractZipFileToFolder(chromeDriverZipFile, new File(extractFolder));

chromeDriverFile = extractZipFileToFolder(chromeDriverZipFile, new File(extractFolder), driverFilename,
CHROME_DRIVER_MAC_SUBDIR);
} else {
chromeDriverFileName = "chromedriver";
File chromeDriverZipFile = new File(downloadFolder + "chromedriver.zip");
FileUtils.copyURLToFile(new URL(chromeDriverUrl + "chromedriver_linux64.zip"), chromeDriverZipFile);
extractZipFileToFolder(chromeDriverZipFile, new File(extractFolder));
File chromeDriverZipFile = new File(downloadFolder + CHROME_DRIVER_LINUX_SUBDIR + File.separator + ZIP_FILE);
FileUtils.copyURLToFile(new URL(chromeDriverUrl + CHROME_DRIVER_LINUX_PREFIX + File.separator
+ CHROME_DRIVER_LINUX_SUBDIR + ZIP), chromeDriverZipFile);
chromeDriverFile = extractZipFileToFolder(chromeDriverZipFile, new File(extractFolder), driverFilename,
CHROME_DRIVER_LINUX_SUBDIR);
}
File chromeDriverFile = new File(extractFolder, chromeDriverFileName);

if (chromeDriverFile.exists()) {
if (!SystemUtils.IS_OS_WINDOWS) {
ExecutionPermission.setExecutePermission(chromeDriverFile);
Expand All @@ -149,6 +166,13 @@ public static void provideChromeDriver(String downloadFolder, String extractFold
}
}

private static File extractZipFileToFolder(File zipFile, File destinationFolder, String chromeDriverFilename,
String chromeDriverVersion) {
extractZipFileToFolder(zipFile, destinationFolder);
return new File(destinationFolder.toURI().resolve(chromeDriverVersion + '/')
.resolve(chromeDriverFilename));
}

private static void extractZipFileToFolder(File zipFile, File destinationFolder) {
zipUnArchiver.setSourceFile(zipFile);
zipUnArchiver.extract("", destinationFolder);
Expand All @@ -168,24 +192,19 @@ private static void extractTarFileToFolder(File file, File destinationFolder) {
}

private static String fetchLatestStableChromeDriverVersion() {

String version = "";
try {

URL url = new URL(CHROME_DRIVER_LATEST_RELEASE_URL);
URLConnection urlConnection = url.openConnection();

BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));

StringBuilder content = new StringBuilder();
content.append(bufferedReader.readLine());

bufferedReader.close();

version = content.toString();

logger.info("Latest Chrome Driver Release found: {}", version);

URL url = new URL(CHROME_DRIVER_LAST_GOOD_VERSIONS_URL);
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(url.openStream()))) {
String content = bufferedReader.readLine();
JsonReader jsonReader = Json.createReader(new StringReader(content));
JsonObject jsonObject = jsonReader.readObject();
version = jsonObject.get("channels").asJsonObject().get("Stable").asJsonObject().get("version")
.toString();
version = StringUtils.strip(version, "\"");
jsonReader.close();
logger.info("Latest Chrome Driver Release found: {}", version);
}
} catch (MalformedURLException exception) {
logger.error("URL for fetching Chrome Release is malformed.");
} catch (IOException exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public String getWorkflowTitle() {
}

public void changeWorkflowTitle(String workflowTitle) {
fileInput.clear();
fileInput.sendKeys(workflowTitle);
}
}

0 comments on commit 8e10dae

Please sign in to comment.