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

[pull] master from kitodo:master #274

Merged
merged 7 commits into from
Mar 1, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class FileNameBeginsAndEndsWithFilter implements FilenameFilter {
* Strings
*/
public FileNameBeginsAndEndsWithFilter(String begin, String end) {
if (begin == null || begin.equals("") || end == null || end.equals("")) {
if (begin == null || begin.isEmpty() || end == null || end.isEmpty()) {
throw new IllegalArgumentException("No filter or empty filter for file begin or end is given.");
}
this.begin = begin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class FileNameEndsAndDoesNotBeginWithFilter implements FilenameFilter {
* Strings
*/
public FileNameEndsAndDoesNotBeginWithFilter(String notBegin, String end) {
if (notBegin == null || notBegin.equals("") || end == null || end.equals("")) {
if (notBegin == null || notBegin.isEmpty() || end == null || end.isEmpty()) {
throw new IllegalArgumentException("No filter or empty filter for file begin or end is given.");
}
this.notBegin = notBegin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class FileNameEndsWithFilter implements FilenameFilter {
* it is thrown in case parameter is null or empty String
*/
public FileNameEndsWithFilter(String end) {
if (end == null || end.equals("")) {
if (end == null || end.isEmpty()) {
throw new IllegalArgumentException("No filter or empty filter for file end is given.");
}
this.end = end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class FileNameMatchesFilter implements FilenameFilter {
* it is thrown in case parameter is null or empty String
*/
public FileNameMatchesFilter(String name) {
if (name == null || name.equals("")) {
if (name == null || name.isEmpty()) {
throw new IllegalArgumentException("No filter or empty name is given.");
}
this.name = name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ private void loadModulesIntoClasspath() {

// create a single URL class loader with all jars
// such that plugins can load classes from each other
if (jarsToBeAdded.size() > 0) {
if (!jarsToBeAdded.isEmpty()) {

for (URL url : jarsToBeAdded) {
logger.info("Loading module jar file from path " + url.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public DivXmlElementAccess() {
private boolean fileXmlElementAccessIsLinkedToChildren(FileXmlElementAccess fileXmlElementAccess,
List<DivType> divs,
Map<String, List<FileXmlElementAccess>> physicalDivisionsMap) {
if (divs.size() == 0) {
if (divs.isEmpty()) {
return false;
}
boolean test = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Map<String, Object> getJsonObject(Process process) {
jsonObject.put(ProcessTypeField.BATCHES.getKey(), addObjectRelation(process.getBatches(), true));
jsonObject.put(ProcessTypeField.COMMENTS.getKey(), addObjectRelation(process.getComments()));
jsonObject.put(ProcessTypeField.COMMENTS_MESSAGE.getKey(), getProcessComments(process));
jsonObject.put(ProcessTypeField.HAS_CHILDREN.getKey(), process.getChildren().size() > 0);
jsonObject.put(ProcessTypeField.HAS_CHILDREN.getKey(), !process.getChildren().isEmpty());
jsonObject.put(ProcessTypeField.PARENT_ID.getKey(), processParentId);
jsonObject.put(ProcessTypeField.TASKS.getKey(), addObjectRelation(process.getTasks(), true));
jsonObject.put(ProcessTypeField.METADATA.getKey(), process.getMetadata());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CommandResult runCommand(String script) throws IOException {

CommandResult commandResult = command.runCommand(script);
List<String> commandResultMessages = commandResult.getMessages();
if (commandResultMessages.size() > 0 && commandResultMessages.get(0).contains("IOException")) {
if (!commandResultMessages.isEmpty() && commandResultMessages.get(0).contains("IOException")) {
throw new IOException(commandResultMessages.get(1));
}
return commandResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ public void removeBlock(Block block) {
if (index > 0) {
index--;
}
if (course.size() > 0) {
if (!course.isEmpty()) {
navigate(course.get(index));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public List<Process> getSelectedProcesses() {
logger.error(e.getMessage());
}
}
if (selectedProcessesOrProcessDTOs.size() > 0) {
if (!selectedProcessesOrProcessDTOs.isEmpty()) {
if (selectedProcessesOrProcessDTOs.get(0) instanceof ProcessDTO) {
// list contains ProcessDTO instances
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void handleFileUpload(FileUploadEvent event) {
}
}

if (createProcessForm.getProcesses().size() > 0 && additionalImport) {
if (!createProcessForm.getProcesses().isEmpty() && additionalImport) {
extendsMetadataTableOfMetadataTab(processes);
} else {
this.createProcessForm.setProcesses(processes);
Expand All @@ -116,7 +116,7 @@ private TempProcess extractParentRecordFromFile(UploadedFile uploadedFile, Docum
Collection<String> higherLevelIdentifier = this.createProcessForm.getRulesetManagement()
.getFunctionalKeys(FunctionalMetadata.HIGHERLEVEL_IDENTIFIER);

if (higherLevelIdentifier.size() > 0) {
if (!higherLevelIdentifier.isEmpty()) {
ImportService importService = ServiceManager.getImportService();
String parentID = importService.getParentID(internalDocument, higherLevelIdentifier.toArray()[0].toString(),
importConfiguration.getParentElementTrimMode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void createInsertionPositionSelectionTree() throws DAOException, DataExce
priorityList);
logicalStructure.setExpanded(true);

if (selectableInsertionPositions.size() > 0) {
if (!selectableInsertionPositions.isEmpty()) {
selectedInsertionPosition = (String) ((LinkedList<SelectItem>) selectableInsertionPositions).getLast()
.getValue();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void addDocStruc(boolean preview) {
}
if (preview && (!(StringUtils.isEmpty(selectFirstPageOnAddNode)
|| StringUtils.isEmpty(this.selectLastPageOnAddNode))
|| Objects.nonNull(this.preselectedViews) && this.preselectedViews.size() > 0)) {
|| Objects.nonNull(this.preselectedViews) && !this.preselectedViews.isEmpty())) {
dataEditor.getGalleryPanel().setGalleryViewMode(PREVIEW_MODE);
} else {
dataEditor.getGalleryPanel().setGalleryViewMode(LIST_MODE);
Expand All @@ -149,7 +149,7 @@ public void addDocStruc(boolean preview) {
private void addMultiDocStruc() {
Optional<LogicalDivision> selectedStructure = dataEditor.getSelectedStructure();
if (selectedStructure.isPresent()) {
if (selectedMetadata != "") {
if (!selectedMetadata.isEmpty()) {
MetadataViewInterface metadataView = getMetadataViewFromKey(
docStructAddTypeSelectionSelectedItem, selectedMetadata);
MetadataEditor.addMultipleStructuresWithMetadata(elementsToAddSpinnerValue,
Expand Down Expand Up @@ -393,7 +393,7 @@ public List<SelectItem> getSelectPageOnAddNodeItems() {
}

private List<View> getViewsToAdd() {
if (Objects.nonNull(preselectedViews) && preselectedViews.size() > 0) {
if (Objects.nonNull(preselectedViews) && !preselectedViews.isEmpty()) {
return preselectedViews;
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private void preparePossiblePositions() {
Helper.getTranslation("dataEditor.position.asLastChildOfCurrentElement")));
List<PhysicalDivision> parents = MetadataEditor.getAncestorsOfPhysicalDivision(selectedPhysicalDivision.get(),
dataEditor.getWorkpiece().getPhysicalStructure());
if (parents.size() > 0) {
if (!parents.isEmpty()) {
possiblePositions.add(new SelectItem(InsertionPosition.BEFORE_CURRENT_ELEMENT,
Helper.getTranslation("dataEditor.position.beforeCurrentElement")));
possiblePositions.add(new SelectItem(InsertionPosition.AFTER_CURRENT_ELEMENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ public class GalleryPanel {
private GalleryViewMode galleryViewMode = GalleryViewMode.LIST;
private List<GalleryMediaContent> medias = Collections.emptyList();

private Map<String, GalleryMediaContent> previewImageResolver = new HashMap<>();

private Map<MediaContentType, Map<GalleryViewMode, MediaVariant>> mediaContentTypeVariants = new HashMap<>();

private Map<MediaContentType, Subfolder> mediaContentTypePreviewFolder = new HashMap<>();
Expand Down Expand Up @@ -130,7 +128,7 @@ public String getGalleryViewMode() {
* @return value of lastSelection
*/
public Pair<PhysicalDivision, LogicalDivision> getLastSelection() {
if (dataEditor.getSelectedMedia().size() > 0) {
if (!dataEditor.getSelectedMedia().isEmpty()) {
return dataEditor.getSelectedMedia().get(dataEditor.getSelectedMedia().size() - 1);
} else if (dataEditor.getSelectedStructure().isPresent()
&& !dataEditor.getSelectedStructure().get().getViews().isEmpty()) {
Expand All @@ -148,7 +146,7 @@ public Pair<PhysicalDivision, LogicalDivision> getLastSelection() {
* @return boolean
*/
public boolean isLastSelection(GalleryMediaContent galleryMediaContent, GalleryStripe galleryStripe) {
if (isSelected(galleryMediaContent, galleryStripe) && dataEditor.getSelectedMedia().size() > 0
if (isSelected(galleryMediaContent, galleryStripe) && !dataEditor.getSelectedMedia().isEmpty()
&& Objects.nonNull(galleryMediaContent)) {
return Objects.equals(galleryMediaContent.getView().getPhysicalDivision(),
dataEditor.getSelectedMedia().get(dataEditor.getSelectedMedia().size() - 1).getKey());
Expand Down Expand Up @@ -337,7 +335,7 @@ private void updateStructure(GalleryMediaContent galleryMediaContent, LogicalDiv
}

void updateSelection(PhysicalDivision physicalDivision, LogicalDivision structuralElement) {
if (physicalDivision.getMediaFiles().size() > 0) {
if (!physicalDivision.getMediaFiles().isEmpty()) {

// Update structured view
if (this.galleryViewMode.equals(GalleryViewMode.LIST)) {
Expand Down Expand Up @@ -708,7 +706,7 @@ private List<Pair<PhysicalDivision, LogicalDivision>> getMediaWithinRangeFromSel
countDown = true;
}

if (galleryStripes.size() == 0) {
if (galleryStripes.isEmpty()) {
return new LinkedList<>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ void reorderPhysicalDivisions(LogicalDivision toElement,
insertionIndex = -1;
}

if (insertionIndex < 0 || toElement.getViews().size() == 0) {
if (insertionIndex < 0 || toElement.getViews().isEmpty()) {
// no insertion position was specified or the element does not contain any pages yet
physicalInsertionIndex = toElement.getOrder() - 1;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public static String getDateAsFormattedString(Date date) {
* @return the date or null if it can not be parsed
*/
public static Date parseDateFromFormattedString(String date) {
if (Objects.isNull(date) || date.equals("")) {
if (Objects.isNull(date) || date.isEmpty()) {
return null;
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ private static String getTitleFromWorkpiece(Process process) {
private static String getTitleFromParents(List<TempProcess> parentTempProcesses,
RulesetManagementInterface rulesetManagement, String acquisitionStage,
List<Locale.LanguageRange> priorityList) {
if (parentTempProcesses.size() == 0) {
if (parentTempProcesses.isEmpty()) {
return StringUtils.EMPTY;
}

Expand Down
5 changes: 3 additions & 2 deletions Kitodo/src/main/java/org/kitodo/production/ldap/LdapUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import javax.naming.directory.SearchResult;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bouncycastle.crypto.digests.MD4Digest;
Expand Down Expand Up @@ -278,7 +279,7 @@ public static String toHexString(byte[] bytes) {

@Override
public Attributes getAttributes(String name) throws NamingException {
if (!name.equals("")) {
if (StringUtils.isBlank(name)) {
throw new NameNotFoundException();
}
return (Attributes) this.attributes.clone();
Expand All @@ -291,7 +292,7 @@ public Attributes getAttributes(Name name) throws NamingException {

@Override
public Attributes getAttributes(String name, String[] ids) throws NamingException {
if (!name.isEmpty()) {
if (StringUtils.isBlank(name)) {
throw new NameNotFoundException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,16 @@ public boolean isAutogenerated() {
*/
public boolean showDependingOnDoctype() {
// if nothing was specified, then show
if (this.isDocType.equals("") && this.isNotDoctype.equals("")) {
if (this.isDocType.isEmpty() && this.isNotDoctype.isEmpty()) {
return true;
}

// if obligatory was specified
if (!this.isDocType.equals("") && !StringUtils.containsIgnoreCase(this.isDocType, this.docType)) {
if (!this.isDocType.isEmpty() && !StringUtils.containsIgnoreCase(this.isDocType, this.docType)) {
return false;
}

// if only "may not" was specified
return !(!this.isNotDoctype.equals("") && StringUtils.containsIgnoreCase(this.isNotDoctype, this.docType));
return !(!this.isNotDoctype.isEmpty() && StringUtils.containsIgnoreCase(this.isNotDoctype, this.docType));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ public boolean searchForMedia(Process process, Workpiece workpiece)
List<String> canonicals = getCanonicalFileNamePartsAndSanitizeAbsoluteURIs(workpiece, subfolders,
process.getProcessBaseUri());

if (currentMedia.size() == 0 && canonicals.size() > 0) {
if (currentMedia.isEmpty() && !canonicals.isEmpty()) {
throw new MediaNotFoundException();
}

Expand Down Expand Up @@ -1183,14 +1183,14 @@ private List<String> getCanonicalFileNamePartsAndSanitizeAbsoluteURIs(Workpiece
physicalDivision.getMediaFiles().put(entry.getKey(), mediaFile);
}
String fileCanonical = subfolder.getCanonical(mediaFile);
if ("".equals(unitCanonical)) {
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().size() > 0 && "".equals(unitCanonical)) {
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 ("".equals(mapping)) {
if (StringUtils.isBlank(mapping)) {
if (indexRestClient.createIndex(null, mappingType)) {
currentState = IndexStates.CREATING_MAPPING_SUCCESSFUL;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private String getWebElementText(WebElement webElement) {
};

Predicate<WebElement> isInputValueNotEmpty = (webElement) -> {
return !webElement.getAttribute("value").equals("");
return !webElement.getAttribute("value").isEmpty();
};

Predicate<File> isFileDownloaded = (file) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void filterByProject() {
*/
public String getFirstSearchResultProcessTitle() {
List<String> tableDataByColumn = getTableDataByColumn(searchResultTable, 3);
if (tableDataByColumn.size() == 0 || tableDataByColumn.contains("No records found.")) {
if (tableDataByColumn.isEmpty() || tableDataByColumn.contains("No records found.")) {
return null;
}
return tableDataByColumn.get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void clickTaskTableColumnHeaderForSorting(int column) {
*/
public String getFirstRowTaskTitle() {
List<String> taskTitles = getTableDataByColumn(taskTable, 1);
if (taskTitles.size() > 0) {
if (!taskTitles.isEmpty()) {
return taskTitles.get(0);
}
return "";
Expand Down