Skip to content

Commit

Permalink
Adjust calls to prevent null pointer exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
henning-gerhardt committed Feb 26, 2024
1 parent ff03f6a commit 25fb5fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1183,14 +1183,14 @@ private List<String> getCanonicalFileNamePartsAndSanitizeAbsoluteURIs(Workpiece
physicalDivision.getMediaFiles().put(entry.getKey(), mediaFile);
}
String fileCanonical = subfolder.getCanonical(mediaFile);
if (unitCanonical.isEmpty()) {
if (StringUtils.isBlank(unitCanonical)) {
unitCanonical = fileCanonical;
} else if (!unitCanonical.equals(fileCanonical)) {
throw new InvalidImagesException("Ambiguous canonical file name part in the same physical division: \""
+ unitCanonical + "\" and \"" + fileCanonical + "\"!");
}
}
if (!physicalDivision.getMediaFiles().isEmpty() && unitCanonical.isEmpty()) {
if (!physicalDivision.getMediaFiles().isEmpty() && StringUtils.isBlank(unitCanonical)) {
throw new InvalidImagesException("Missing canonical file name part in physical division " + physicalDivision);
}
canonicals.add(unitCanonical);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import javax.json.JsonReader;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kitodo.config.ConfigCore;
Expand Down Expand Up @@ -426,7 +427,7 @@ public int getProgress(ObjectType currentType, PushContext pollingChannel) throw
public String createMapping() throws IOException, CustomResponseException {
for (String mappingType : KitodoRestClient.MAPPING_TYPES) {
String mapping = readMapping(mappingType);
if (mapping.isEmpty()) {
if (StringUtils.isBlank(mapping)) {
if (indexRestClient.createIndex(null, mappingType)) {
currentState = IndexStates.CREATING_MAPPING_SUCCESSFUL;
} else {
Expand Down

0 comments on commit 25fb5fe

Please sign in to comment.