Skip to content

Commit

Permalink
Merge pull request kitodo#4624 from matthias-ronge/issue-4621
Browse files Browse the repository at this point in the history
Issue 4621
  • Loading branch information
Kathrin-Huber authored Nov 15, 2021
2 parents b6937e7 + 71c2985 commit 0675697
Show file tree
Hide file tree
Showing 25 changed files with 87 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

package org.kitodo.exceptions;

import java.util.Arrays;

import javax.management.InvalidAttributeValueException;

import org.kitodo.production.helper.Helper;
Expand Down Expand Up @@ -59,7 +57,7 @@ public void addParent(String parentLabel) {

@Override
public String getLocalizedMessage() {
return Helper.getTranslation("dataEditor.invalidMetadataValue", Arrays.asList(key, value));
return Helper.getTranslation("dataEditor.invalidMetadataValue", key, value);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

package org.kitodo.exceptions;

import java.util.Arrays;

import org.kitodo.production.helper.Helper;

public class NoSuchMetadataFieldException extends NoSuchFieldException {
Expand Down Expand Up @@ -42,7 +40,7 @@ public NoSuchMetadataFieldException(String key, String label) {

@Override
public String getLocalizedMessage() {
return Helper.getTranslation("dataEditor.invalidStructureField", Arrays.asList(label, key));
return Helper.getTranslation("dataEditor.invalidStructureField", label, key);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
package org.kitodo.exceptions;

import java.io.FileNotFoundException;
import java.util.Collections;

import org.kitodo.production.helper.Helper;

Expand All @@ -24,6 +23,6 @@ public class RulesetNotFoundException extends FileNotFoundException {
* name of missing ruleset file
*/
public RulesetNotFoundException(String missingFile) {
super(Helper.getTranslation("rulesetNotFound", Collections.singletonList(missingFile)));
super(Helper.getTranslation("rulesetNotFound", missingFile));
}
}
10 changes: 4 additions & 6 deletions Kitodo/src/main/java/org/kitodo/export/ExportDms.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collection;
import java.util.Collections;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -145,7 +144,7 @@ public boolean startExport(Process process, ExportDmsTask exportDmsTask) {
} catch (IOException | DAOException e) {
if (Objects.nonNull(exportDmsTask)) {
exportDmsTask.setException(e);
logger.error(Helper.getTranslation(ERROR_EXPORT, Collections.singletonList(process.getTitle())), e);
logger.error(Helper.getTranslation(ERROR_EXPORT, process.getTitle()), e);
} else {
Helper.setErrorMessage(ERROR_EXPORT, new Object[] {process.getTitle() }, logger, e);
}
Expand Down Expand Up @@ -200,9 +199,8 @@ private boolean prepareExportLocation(Process process,

// delete old export folder
if (!fileService.delete(exportFolder)) {
String message = Helper.getTranslation(ERROR_EXPORT, Collections.singletonList(processTitle));
String description = Helper.getTranslation(EXPORT_DIR_DELETE,
Collections.singletonList(exportFolder.getPath()));
String message = Helper.getTranslation(ERROR_EXPORT, processTitle);
String description = Helper.getTranslation(EXPORT_DIR_DELETE, exportFolder.getPath());
Helper.setErrorMessage(message, description);
if (Objects.nonNull(exportDmsTask)) {
exportDmsTask.setException(new ExportException(message + ": " + description));
Expand Down Expand Up @@ -277,7 +275,7 @@ private LegacyMetsModsDigitalDocumentHelper readDocument(Process process, Legacy
} catch (RuntimeException e) {
if (Objects.nonNull(exportDmsTask)) {
exportDmsTask.setException(e);
logger.error(Helper.getTranslation(ERROR_EXPORT, Collections.singletonList(process.getTitle())), e);
logger.error(Helper.getTranslation(ERROR_EXPORT, process.getTitle()), e);
} else {
Helper.setErrorMessage(ERROR_EXPORT, new Object[] {process.getTitle() }, logger, e);
}
Expand Down
3 changes: 1 addition & 2 deletions Kitodo/src/main/java/org/kitodo/export/ExportMets.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.Objects;

import javax.xml.transform.TransformerException;
Expand Down Expand Up @@ -155,7 +154,7 @@ protected boolean writeMetsFile(Process process, URI metaFile, LegacyMetsModsDig
try (BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(new File(metaFile)))) {
URI xslFile = XsltHelper.getXsltFileFromConfig(process);
if (!Files.exists(Paths.get(xslFile))) {
String message = Helper.getTranslation("xsltFileNotFound", Collections.singletonList(xslFile.toString()));
String message = Helper.getTranslation("xsltFileNotFound", xslFile.toString());
throw new FileNotFoundException(message);
}
bufferedOutputStream.write(XsltHelper.transformXmlByXslt(source, xslFile).toByteArray());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

package org.kitodo.production.converter;

import java.util.Arrays;
import java.util.Objects;

import javax.faces.convert.ConverterException;
Expand All @@ -30,7 +29,7 @@ public abstract class BeanConverter {

/**
* Get as object for bean convert.
*
*
* @param searchDatabaseService
* service used for query the object
* @param value
Expand All @@ -54,7 +53,7 @@ protected Object getAsObject(SearchDatabaseService searchDatabaseService, String

/**
* Get as string for bean convert.
*
*
* @param value
* bean to be converted
* @param translationKey
Expand All @@ -75,7 +74,7 @@ protected String getAsString(Object value, String translationKey) {
return (String) value;
} else {
throw new ConverterException(Helper.getTranslation("errorConvert",
Arrays.asList(value.getClass().getCanonicalName(), translationKey)));
value.getClass().getCanonicalName(), translationKey));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
package org.kitodo.production.enums;

import java.net.URI;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;

Expand Down Expand Up @@ -57,7 +56,7 @@ public void accept(ImageGenerator imageGenerator) {
String canonical = source.getKey();
if (!imageGenerator.getMode().equals(GenerationMode.ALL)) {
imageGenerator.letTheSupervisorDo(emptyTask -> emptyTask.setWorkDetail(
Helper.getTranslation("determineWhichImagesNeedToBeGenerated", Collections.singletonList(canonical))));
Helper.getTranslation("determineWhichImagesNeedToBeGenerated", canonical)));
}

List<Subfolder> subfoldersWhoseContentsAreToBeGenerated = imageGenerator
Expand All @@ -81,7 +80,7 @@ public void accept(ImageGenerator imageGenerator) {
public void accept(ImageGenerator imageGenerator) {
ContentToBeGenerated instructuon = imageGenerator.getFromContentToBeGeneratedByPosition();
imageGenerator.letTheSupervisorDo(emptyTask -> emptyTask.setWorkDetail(
Helper.getTranslation("generateImages", Collections.singletonList(instructuon.getCanonical()))));
Helper.getTranslation("generateImages", instructuon.getCanonical())));
LogManager.getLogger(ImageGeneratorStep.class).info("Generating ".concat(instructuon.toString()));
imageGenerator.createDerivatives(instructuon);
if (imageGenerator.getPosition() == imageGenerator.getContentToBeGenerated().size() - 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.text.DateFormat;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -415,6 +414,6 @@ public void resetPaginator(String keepPagination) {
* @return translated String
*/
public String formatString(String messageKey, String... replacements) {
return Helper.getTranslation(messageKey, Arrays.asList(replacements));
return Helper.getTranslation(messageKey, replacements);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ private LocalDate parseDate(String value, String input) {
numbers[2] -= 100;
}
Helper.setMessage(Helper.getTranslation(BLOCK + input + ".yearCompleted",
Arrays.asList(dateParser.group(3), Integer.toString(numbers[2]))));
dateParser.group(3), Integer.toString(numbers[2])));
}
try {
return LocalDate.of(numbers[2], numbers[1], numbers[0]);
Expand Down Expand Up @@ -669,7 +669,7 @@ public String createProcesses() throws DAOException {
}

public String formatString(String messageKey, String... replacements) {
return Helper.getTranslation(messageKey, Arrays.asList(replacements));
return Helper.getTranslation(messageKey, replacements);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.io.IOException;
import java.io.Serializable;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -170,13 +169,13 @@ public void getRecordHierarchy() {

String summary = Helper.getTranslation("newProcess.catalogueSearch.importSuccessfulSummary");
String detail = Helper.getTranslation("newProcess.catalogueSearch.importSuccessfulDetail",
Arrays.asList(String.valueOf(processes.size()), opac));
String.valueOf(processes.size()), opac);
showGrowlMessage(summary, detail);

if (this.importChildren) {
summary = Helper.getTranslation("newProcess.catalogueSearch.loadingChilrenSuccessfulSummary");
detail = Helper.getTranslation("newProcess.catalogueSearch.loadingChilrenSuccessfulDetail",
Collections.singletonList(String.valueOf(this.createProcessForm.getChildProcesses().size())));
String.valueOf(this.createProcessForm.getChildProcesses().size()));
showGrowlMessage(summary, detail);
}

Expand Down Expand Up @@ -254,7 +253,7 @@ public void setSelectedExemplarRecord(ExemplarRecord selectedExemplarRecord) {
this.createProcessForm.getProcessMetadataTab().getProcessDetailsElements());
String summary = Helper.getTranslation("newProcess.catalogueSearch.exemplarRecordSelectedSummary");
String detail = Helper.getTranslation("newProcess.catalogueSearch.exemplarRecordSelectedDetail",
Arrays.asList(selectedExemplarRecord.getOwner(), selectedExemplarRecord.getSignature()));
selectedExemplarRecord.getOwner(), selectedExemplarRecord.getSignature());
showGrowlMessage(summary, detail);
Ajax.update(FORM_CLIENTID);
} catch (ParameterNotFoundException e) {
Expand Down Expand Up @@ -292,6 +291,6 @@ public String getOpacErrorMessage() {
*/
public String getNumberOfChildProcessesWarning() {
return Helper.getTranslation("newProcess.catalogueSearch.manyChildrenWarning",
Collections.singletonList(String.valueOf(this.numberOfChildren)));
String.valueOf(this.numberOfChildren));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ private void createProcessHierarchy()
processes.get(0).getProcess());
String summary = Helper.getTranslation("newProcess.catalogueSearch.linkedToExistingProcessSummary");
String detail = Helper.getTranslation("newProcess.catalogueSearch.linkedToExistingProcessDetail",
Collections.singletonList(titleRecordLinkTab.getTitleRecordProcess().getTitle()));
titleRecordLinkTab.getTitleRecordProcess().getTitle());
catalogImportDialog.showGrowlMessage(summary, detail);
} else {
// add links between consecutive processes in list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.io.Serializable;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
Expand Down Expand Up @@ -1015,8 +1014,8 @@ public void onDragDrop(TreeDragDropEvent event) {
&& dropNode.getDataObject() instanceof LogicalDivision) {
movePageNode(event, dropNode, dragNode);
} else {
Helper.setErrorMessage(Helper.getTranslation("dataEditor.dragnDropError", Arrays.asList(
dragNode.getLabel(), dropNode.getLabel())));
Helper.setErrorMessage(
Helper.getTranslation("dataEditor.dragnDropError", dragNode.getLabel(), dropNode.getLabel()));
show();
}
} catch (Exception exception) {
Expand Down Expand Up @@ -1071,12 +1070,12 @@ private void movePageNode(TreeDragDropEvent event, StructureTreeNode dropNode, S
dataEditor.getGalleryPanel().updateMedia();
return;
} else {
Helper.setErrorMessage(Helper.getTranslation("dataEditor.dragnDropError", Arrays.asList(
dragNode.getLabel(), dropNode.getLabel())));
Helper.setErrorMessage(
Helper.getTranslation("dataEditor.dragnDropError", dragNode.getLabel(), dropNode.getLabel()));
}
} else {
Helper.setErrorMessage(Helper.getTranslation("dataEditor.dragnDropError", Arrays.asList(
dragNode.getLabel(), dropNode.getLabel())));
Helper.setErrorMessage(
Helper.getTranslation("dataEditor.dragnDropError", dragNode.getLabel(), dropNode.getLabel()));
}
show();
}
Expand Down Expand Up @@ -1273,15 +1272,15 @@ private void checkLogicalDragDrop(StructureTreeNode dragNode, StructureTreeNode
this.dataEditor.getGalleryPanel().updateStripes();
} else {
Helper.setErrorMessage(Helper.getTranslation("dataEditor.childNotContainedError",
Collections.singletonList(dragNode.getLabel())));
dragNode.getLabel()));
}
} else {
Helper.setErrorMessage(Helper.getTranslation("dataEditor.noParentsError",
Collections.singletonList(dragNode.getLabel())));
dragNode.getLabel()));
}
} else {
Helper.setErrorMessage(Helper.getTranslation("dataEditor.forbiddenChildElement",
Arrays.asList(dragNode.getLabel(), dropNode.getLabel())));
dragNode.getLabel(), dropNode.getLabel()));
}
show();
}
Expand All @@ -1299,19 +1298,19 @@ private void checkPhysicalDragDrop(StructureTreeNode dragNode, StructureTreeNode
dragParents = MetadataEditor.getAncestorsOfPhysicalDivision(dragUnit, dataEditor.getWorkpiece().getPhysicalStructure());
if (dragParents.isEmpty()) {
Helper.setErrorMessage(Helper.getTranslation("dataEditor.noParentsError",
Collections.singletonList(dragNode.getLabel())));
dragNode.getLabel()));
} else {
PhysicalDivision parentUnit = dragParents.get(dragParents.size() - 1);
if (parentUnit.getChildren().contains(dragUnit)) {
preservePhysical();
} else {
Helper.setErrorMessage(Helper.getTranslation("dataEditor.childNotContainedError",
Collections.singletonList(dragUnit.getType())));
dragUnit.getType()));
}
}
} else {
Helper.setErrorMessage(Helper.getTranslation("dataEditor.forbiddenChildElement",
Arrays.asList(dragNode.getLabel(), dropNode.getLabel())));
dragNode.getLabel(), dropNode.getLabel()));
}
show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public void uploadMedia(FileUploadEvent event) {
dataEditor.getUnsavedUploadedMedia().add(physicalDivision);
selectedMedia.add(new ImmutablePair<>(physicalDivision, parent));
PrimeFaces.current().executeScript("PF('notifications').renderMessage({'summary':'"
+ Helper.getTranslation("mediaUploaded", Collections.singletonList(event.getFile().getFileName()))
+ Helper.getTranslation("mediaUploaded", event.getFile().getFileName())
+ "','severity':'info'});");
}
}
Expand Down
Loading

0 comments on commit 0675697

Please sign in to comment.