Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move exception handling to Form class #4959

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import org.kitodo.data.database.beans.Process;
import org.kitodo.data.database.exceptions.DAOException;
import org.kitodo.data.exceptions.DataException;
import org.kitodo.exceptions.InvalidMetadataValueException;
import org.kitodo.exceptions.NoSuchMetadataFieldException;
import org.kitodo.exceptions.UnknownTreeNodeDataException;
import org.kitodo.production.dto.ProcessDTO;
import org.kitodo.production.helper.Helper;
Expand Down Expand Up @@ -115,7 +117,11 @@ public void setLinkSubDialogVisible(boolean visible) {
* Add structure element.
*/
public void addDocStruc(boolean preview) {
dataEditor.getMetadataPanel().preserve();
try {
dataEditor.getMetadataPanel().preserve();
} catch (InvalidMetadataValueException | NoSuchMetadataFieldException e) {
logger.info(e.getMessage());
}
if (this.elementsToAddSpinnerValue > 1) {
this.addMultiDocStruc();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ public void save() {
}

private String save(boolean close) {
metadataPanel.preserve();
try {
metadataPanel.preserve();
structurePanel.preserve();
ServiceManager.getFileService().createBackupFile(process);
try (OutputStream out = ServiceManager.getFileService().write(mainFileUri)) {
Expand Down Expand Up @@ -948,4 +948,15 @@ public UploadFileDialog getUploadFileDialog() {
public boolean isFolderConfigurationComplete() {
return folderConfigurationComplete;
}

/**
* Preserve changes in the metadata panel.
*/
public void preserveMetadataPanel() {
try {
metadataPanel.preserve();
} catch (InvalidMetadataValueException | NoSuchMetadataFieldException e) {
logger.info(e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,9 @@ void showPhysical(Optional<PhysicalDivision> optionalPhysicalDivision) {
/**
* Preserve metadata.
*/
public void preserve() {
try {
this.preserveLogical();
this.preservePhysical();
} catch (InvalidMetadataValueException | NoSuchMetadataFieldException e) {
logger.info(e.getMessage());
}
public void preserve() throws InvalidMetadataValueException, NoSuchMetadataFieldException {
this.preserveLogical();
this.preservePhysical();
}

void preserveLogical() throws InvalidMetadataValueException, NoSuchMetadataFieldException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@

import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kitodo.api.dataformat.LogicalDivision;
import org.kitodo.api.dataformat.PhysicalDivision;
import org.kitodo.api.dataformat.View;
import org.kitodo.config.ConfigCore;
import org.kitodo.config.enums.ParameterCore;
import org.kitodo.exceptions.InvalidImagesException;
import org.kitodo.exceptions.InvalidMetadataValueException;
import org.kitodo.exceptions.NoSuchMetadataFieldException;
import org.kitodo.production.helper.Helper;
import org.kitodo.production.helper.metadata.pagination.Paginator;
import org.kitodo.production.helper.metadata.pagination.PaginatorMode;
Expand All @@ -39,6 +43,7 @@
* Backing bean for the pagination panel.
*/
public class PaginationPanel {
private static final Logger logger = LogManager.getLogger(PaginationPanel.class);

private final DataEditorForm dataEditor;
private boolean fictitiousCheckboxChecked = false;
Expand Down Expand Up @@ -332,7 +337,11 @@ public void startPaginationClick() {
Helper.setErrorMessage("fehlerBeimEinlesen", "No pages selected for pagination.");
return;
}
dataEditor.getMetadataPanel().preserve();
try {
dataEditor.getMetadataPanel().preserve();
} catch (InvalidMetadataValueException | NoSuchMetadataFieldException e) {
logger.info(e.getMessage());
}
List<Separator> pageSeparators = Separator.factory(ConfigCore.getParameter(ParameterCore.PAGE_SEPARATORS));
String initializer = paginationTypeSelectSelectedItem.format(selectPaginationModeSelectedItem.getValue(),
paginationStartValue, fictitiousCheckboxChecked, pageSeparators.get(0).getSeparatorString());
Expand Down
2 changes: 1 addition & 1 deletion Kitodo/src/main/webapp/pages/metadataEditor.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<ui:define name="content">

<p:remoteCommand name="preserveMetadata"
actionListener="#{DataEditorForm.metadataPanel.preserve}"/>
actionListener="#{DataEditorForm.preserveMetadataPanel()}"/>

<!--@elvariable id="viewStructure" type="boolean"-->
<ui:param name="viewStructure" value="#{SecurityAccessController.hasAuthorityToViewProcessStructureData()}"/>
Expand Down