Skip to content

Commit

Permalink
Handle missing metadata file exception
Browse files Browse the repository at this point in the history
  • Loading branch information
solth committed Nov 30, 2023
1 parent 1f63066 commit 9e9bb1b
Show file tree
Hide file tree
Showing 7 changed files with 247 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class CalendarForm implements Serializable {

private static final String BLOCK = "calendar.block.";
private static final String BLOCK_NEGATIVE = BLOCK + "negative";
private static final String UPLOAD_ERROR = "calendar.upload.error";
private static final String UPLOAD_ERROR = "errorLoadingFile";
private static final String REDIRECT_PARAMETER = "faces-redirect=true";
private static final String DEFAULT_REFERER = "processes?" + REDIRECT_PARAMETER;
private static final String TASK_MANAGER_REFERER = "system.jsf?tabIndex=0&" + REDIRECT_PARAMETER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ public class DataEditorForm implements MetadataTreeTableInterface, RulesetSetupI

private String renamingError = "";

private String metadataLoadingError = "";

/**
* Public constructor.
*/
Expand Down Expand Up @@ -294,8 +296,11 @@ public void open(String processID, String referringView, String taskId) {
} else {
PrimeFaces.current().executeScript("PF('metadataLockedDialog').show();");
}
} catch (IOException | DAOException | InvalidImagesException | NoSuchElementException e) {
} catch (DAOException | InvalidImagesException | NoSuchElementException e) {
Helper.setErrorMessage(e.getLocalizedMessage(), logger, e);
} catch (IOException e) {
metadataLoadingError = e.getMessage();
PrimeFaces.current().executeScript("PF('metadataLoadingFailedDialog').show();");
}
}

Expand Down Expand Up @@ -1154,4 +1159,13 @@ private void showPanels() {
paginationPanel.show();
structurePanel.show();
}

/**
* Return potential metadata loading error message.
* @return metadata loading error message
*/
public String getMetadataLoadingError() {
return metadataLoadingError;
}

}
2 changes: 1 addition & 1 deletion Kitodo/src/main/resources/messages/errors_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ authorityAssignedError=Berechtigung kann nicht gel\u00F6scht werden, da dieser n
batchPropertyEmpty=Die Eigenschaft {0} im Vorgang {1} ist ein Pflichtfeld, enth\u00E4lt aber keinen Wert.

# C
calendar.upload.error=Fehler beim Laden der Datei\:
calendar.upload.isEmpty=Es wurde keine Datei \u00FCbertragen.
calendar.upload.missingMandatoryElement=Ein erforderliches XML-Element konnte nicht gefunden werden.
calendar.upload.missingMandatoryValue=Ein erforderlicher Wert konnte nicht gefunden werden.
Expand Down Expand Up @@ -57,6 +56,7 @@ errorDirectoryRetrieve=Fehler beim Abrufen des ''{0}'' Verzeichnisses.
errorDownloading=Fehler beim Herunterladen von ''{0}''
errorDuplicate=Fehler: ''{0}'' konnte nicht dupliziert werden!
errorDuplicateFilegroup=Fehler: Dateigruppe wird bereits verwendet.
errorLoadingFile=Fehler beim Laden der Datei\:

# E
errorExport=Export abgebrochen, xml-LeseFehler bei Vorlage\: ''{0}''
Expand Down
2 changes: 1 addition & 1 deletion Kitodo/src/main/resources/messages/errors_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ authorityAssignedError=The authority could not be deleted because there are stil
batchPropertyEmpty=The property {0} in process {1} is a mandatory field but contains no value.

# C
calendar.upload.error=Error while loading the file\:
errorLoadingFile=Error while loading the file\:
calendar.upload.isEmpty=No file was transferred.
calendar.upload.missingMandatoryElement=A mandatory XML element could not be found.
calendar.upload.missingMandatoryValue=A mandatory value could not be found.
Expand Down
2 changes: 1 addition & 1 deletion Kitodo/src/main/resources/messages/errors_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ authorityAssignedError=El permiso no puede ser eliminado porque todavía tiene r
batchPropertyEmpty=La propiedad {0} en la operación {1} es un campo obligatorio pero no contiene un valor.

# C
calendar.upload.error=Error al cargar el archivo\:
errorLoadingFile=Error al cargar el archivo\:
calendar.upload.isEmpty=No se ha transferido ningún archivo.
calendar.upload.missingMandatoryElement=No se pudo encontrar un elemento XML requerido.
calendar.upload.missingMandatoryValue=No se ha podido encontrar un valor requerido.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!--
*
* (c) Kitodo. Key to digital objects e. V. <[email protected]>
*
* 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.
*
-->

<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<p:dialog id="metadataLoadingFailedDialog"
widgetVar="metadataLoadingFailedDialog"
width="500px"
showHeader="false"
appendTo="@(body)"
resizable="false"
closable="false"
modal="true">
<h:panelGroup id="metadataLoadingMessageWrapper">
<h3>#{err['errorLoadingFile']}</h3>
<h:panelGroup layout="block"
styleClass="select-note ui-messages-error">
<h:outputText value="#{DataEditorForm.metadataLoadingError}"/>
</h:panelGroup>
</h:panelGroup>
<h:panelGroup layout="block"
styleClass="dialogButtonWrapper">
<p:button outcome="/pages/desktop.jsf"
value="#{msgs['ok']}"
id="confirmButton"
styleClass="primary right"
icon="fa fa-close"
iconPos="right"/>
</h:panelGroup>
</p:dialog>
</ui:composition>
Loading

0 comments on commit 9e9bb1b

Please sign in to comment.