diff --git a/core/src/main/java/org/fao/geonet/kernel/EditLib.java b/core/src/main/java/org/fao/geonet/kernel/EditLib.java index ebbc7d5b84f1..cde7f98c32bd 100644 --- a/core/src/main/java/org/fao/geonet/kernel/EditLib.java +++ b/core/src/main/java/org/fao/geonet/kernel/EditLib.java @@ -1,29 +1,25 @@ -//============================================================================== -//=== -//=== EditLib -//=== -//============================================================================= -//=== Copyright (C) 2001-2024 Food and Agriculture Organization of the -//=== United Nations (FAO-UN), United Nations World Food Programme (WFP) -//=== and United Nations Environment Programme (UNEP) -//=== -//=== This program is free software; you can redistribute it and/or modify -//=== it under the terms of the GNU General Public License as published by -//=== the Free Software Foundation; either version 2 of the License, or (at -//=== your option) any later version. -//=== -//=== This program is distributed in the hope that it will be useful, but -//=== WITHOUT ANY WARRANTY; without even the implied warranty of -//=== MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -//=== General Public License for more details. -//=== -//=== You should have received a copy of the GNU General Public License -//=== along with this program; if not, write to the Free Software -//=== Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA -//=== -//=== Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2, -//=== Rome - Italy. email: geonetwork@osgeo.org -//============================================================================== +/* + * Copyright (C) 2001-2026 Food and Agriculture Organization of the + * United Nations (FAO-UN), United Nations World Food Programme (WFP) + * and United Nations Environment Programme (UNEP) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * + * Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2, + * Rome - Italy. email: geonetwork@osgeo.org + */ package org.fao.geonet.kernel; @@ -1089,7 +1085,7 @@ private void fillElement(MetadataSchema schema, SchemaSuggestions sugg, String p //--- handle attributes if mandatory or suggested // for (MetadataAttribute attr: type.getAlAttribs()) { - LOGGER_FILL_ELEMENT.debug("#### - {} attribute = {}", attr.name); + LOGGER_FILL_ELEMENT.debug("#### - attribute = {}", attr.name); LOGGER_FILL_ELEMENT.debug("#### - required = {}", attr.required); LOGGER_FILL_ELEMENT.debug("#### - suggested = {}", sugg.isSuggested(elemName, attr.name)); diff --git a/core/src/main/java/org/fao/geonet/kernel/datamanager/base/BaseMetadataIndexer.java b/core/src/main/java/org/fao/geonet/kernel/datamanager/base/BaseMetadataIndexer.java index 50fff6228fce..01e2d9fce0e6 100644 --- a/core/src/main/java/org/fao/geonet/kernel/datamanager/base/BaseMetadataIndexer.java +++ b/core/src/main/java/org/fao/geonet/kernel/datamanager/base/BaseMetadataIndexer.java @@ -1,5 +1,5 @@ //============================================================================= -//=== Copyright (C) 2001-2025 Food and Agriculture Organization of the +//=== Copyright (C) 2001-2026 Food and Agriculture Organization of the //=== United Nations (FAO-UN), United Nations World Food Programme (WFP) //=== and United Nations Environment Programme (UNEP) //=== @@ -539,7 +539,7 @@ public void indexMetadata(final String metadataId, if (status == MetadataValidationStatus.NEVER_CALCULATED && vi.isRequired()) { isValid = "-1"; } - if (status == MetadataValidationStatus.INVALID && vi.isRequired() && isValid != "-1") { + if (status == MetadataValidationStatus.INVALID && vi.isRequired() && !"-1".equals(isValid)) { isValid = "0"; } } else { diff --git a/core/src/main/java/org/fao/geonet/kernel/datamanager/base/BaseMetadataValidator.java b/core/src/main/java/org/fao/geonet/kernel/datamanager/base/BaseMetadataValidator.java index 9906138357e0..08f3f738d40a 100644 --- a/core/src/main/java/org/fao/geonet/kernel/datamanager/base/BaseMetadataValidator.java +++ b/core/src/main/java/org/fao/geonet/kernel/datamanager/base/BaseMetadataValidator.java @@ -1,5 +1,5 @@ //============================================================================= -//=== Copyright (C) 2001-2025 Food and Agriculture Organization of the +//=== Copyright (C) 2001-2026 Food and Agriculture Organization of the //=== United Nations (FAO-UN), United Nations World Food Programme (WFP) //=== and United Nations Environment Programme (UNEP) //=== @@ -251,7 +251,7 @@ private Element validateInfo(String schema, Element md, XmlErrorHandler eh) thro String schemaLoc = md.getAttributeValue("schemaLocation", Namespaces.XSI); LOGGER.debug("Extracted schemaLocation of {}", schemaLoc); boolean noChoiceButToUseSchemaLocation = schema == null; - boolean isSchemaLocationDefinedInMd = schemaLoc != null && schemaLoc != ""; + boolean isSchemaLocationDefinedInMd = schemaLoc != null && !"".equals(schemaLoc); if (noChoiceButToUseSchemaLocation || isSchemaLocationDefinedInMd) { return Xml.validateInfo(md, eh, schema); diff --git a/domain/src/main/java/org/fao/geonet/domain/MetadataLink.java b/domain/src/main/java/org/fao/geonet/domain/MetadataLink.java index bbc688c1f06d..6a9220f5da01 100644 --- a/domain/src/main/java/org/fao/geonet/domain/MetadataLink.java +++ b/domain/src/main/java/org/fao/geonet/domain/MetadataLink.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001-2016 Food and Agriculture Organization of the + * Copyright (C) 2001-2026 Food and Agriculture Organization of the * United Nations (FAO-UN), United Nations World Food Programme (WFP) * and United Nations Environment Programme (UNEP) * @@ -37,6 +37,7 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; +import java.util.Objects; /** * An entity that represents the relationship between a metadata and a metadata link. @@ -92,11 +93,7 @@ public void setMetadataUuid(String metadataUuid) { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + link.getId(); - result = prime * result + metadataId; - return result; + return Objects.hash(link.getId(), metadataId); } @Override @@ -110,7 +107,7 @@ public boolean equals(Object obj) { MetadataLink other = (MetadataLink) obj; if (link.getId() != other.link.getId()) return false; - if (metadataId.intValue() != metadataId.intValue()) + if (!Objects.equals(metadataId, other.metadataId)) return false; return true; } diff --git a/domain/src/main/java/org/fao/geonet/domain/UserSearch.java b/domain/src/main/java/org/fao/geonet/domain/UserSearch.java index 1843ea1399e4..e421b8082a73 100644 --- a/domain/src/main/java/org/fao/geonet/domain/UserSearch.java +++ b/domain/src/main/java/org/fao/geonet/domain/UserSearch.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001-2016 Food and Agriculture Organization of the + * Copyright (C) 2001-2026 Food and Agriculture Organization of the * United Nations (FAO-UN), United Nations World Food Programme (WFP) * and United Nations Environment Programme (UNEP) * @@ -42,7 +42,7 @@ public class UserSearch extends Localized implements Serializable { static final String ID_SEQ_NAME = "user_search_id_seq"; - public static final long serialVersionUID = 8189762204841260782L; + private static final long serialVersionUID = 8189762204841260782L; private int id; private String url; diff --git a/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/AbstractHarvestError.java b/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/AbstractHarvestError.java index b340a754c3cf..b685170483ab 100644 --- a/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/AbstractHarvestError.java +++ b/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/AbstractHarvestError.java @@ -1,3 +1,26 @@ +/* + * Copyright (C) 2001-2026 Food and Agriculture Organization of the + * United Nations (FAO-UN), United Nations World Food Programme (WFP) + * and United Nations Environment Programme (UNEP) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * + * Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2, + * Rome - Italy. email: geonetwork@osgeo.org + */ + package org.fao.geonet.kernel.harvest.harvester; import org.fao.geonet.monitor.harvest.AbstractHarvesterErrorCounter; @@ -8,17 +31,14 @@ import jeeves.server.context.ServiceContext; public class AbstractHarvestError { - + public AbstractHarvestError(ServiceContext context) { super(); // we don't catch anything because this is not critical // if the following code is not executed, we just want to // avoid to raise an exception. - try { - MonitorManager mm = context.getBean(MonitorManager.class); - Counter harvestError = mm.getCounter(AbstractHarvesterErrorCounter.class); - harvestError.inc(); - } finally {} - + MonitorManager mm = context.getBean(MonitorManager.class); + Counter harvestError = mm.getCounter(AbstractHarvesterErrorCounter.class); + harvestError.inc(); } } diff --git a/services/src/main/java/org/fao/geonet/api/categories/TagsApi.java b/services/src/main/java/org/fao/geonet/api/categories/TagsApi.java index 3447a171fac1..e43cf2b86ec4 100644 --- a/services/src/main/java/org/fao/geonet/api/categories/TagsApi.java +++ b/services/src/main/java/org/fao/geonet/api/categories/TagsApi.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001-2023 Food and Agriculture Organization of the + * Copyright (C) 2001-2026 Food and Agriculture Organization of the * United Nations (FAO-UN), United Nations World Food Programme (WFP) * and United Nations Environment Programme (UNEP) * @@ -256,7 +256,7 @@ public ResponseEntity deleteTag( Optional category = categoryRepository.findById(tagIdentifier); if (category.isPresent()) { long recordsCount = metadataRepository.count((Specification) MetadataSpecs.hasCategory(category.get())); - if (recordsCount > 0l) { + if (recordsCount > 0L) { throw new IllegalArgumentException(String.format( "Tag '%s' is assigned to %d records. Update records first in order to remove that tag.", category.get().getName(), // TODO: Return in user language diff --git a/services/src/main/java/org/fao/geonet/api/links/model/LinkDto.java b/services/src/main/java/org/fao/geonet/api/links/model/LinkDto.java index 2d358fb39473..5300c2d29961 100644 --- a/services/src/main/java/org/fao/geonet/api/links/model/LinkDto.java +++ b/services/src/main/java/org/fao/geonet/api/links/model/LinkDto.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001-2016 Food and Agriculture Organization of the + * Copyright (C) 2001-2026 Food and Agriculture Organization of the * United Nations (FAO-UN), United Nations World Food Programme (WFP) * and United Nations Environment Programme (UNEP) * @@ -178,11 +178,11 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; LinkDto that = (LinkDto) o; return id == that.id && - featuredType == that.featuredType && + Objects.equals(featuredType, that.featuredType) && creatorId == that.creatorId && - url.equals(that.url) && - creationDate.equals(that.creationDate) && - creator.equals(that.creator) && + Objects.equals(url, that.url) && + Objects.equals(creationDate, that.creationDate) && + Objects.equals(creator, that.creator) && Objects.equals(logo, that.logo) && names.equals(that.names); } diff --git a/services/src/main/java/org/fao/geonet/api/records/editing/EditUtils.java b/services/src/main/java/org/fao/geonet/api/records/editing/EditUtils.java index be22517492cd..b7d6a9408509 100644 --- a/services/src/main/java/org/fao/geonet/api/records/editing/EditUtils.java +++ b/services/src/main/java/org/fao/geonet/api/records/editing/EditUtils.java @@ -1,5 +1,5 @@ //============================================================================= -//=== Copyright (C) 2001-2007 Food and Agriculture Organization of the +//=== Copyright (C) 2001-2026 Food and Agriculture Organization of the //=== United Nations (FAO-UN), United Nations World Food Programme (WFP) //=== and United Nations Environment Programme (UNEP) //=== @@ -91,7 +91,7 @@ protected static void addMissingGeoNetRef(Element element) { for (Object descendant : list) { if (descendant instanceof Element) { Element e = (Element) descendant; - if (e.getName() != Edit.RootChild.ELEMENT + if (!Edit.RootChild.ELEMENT.equals(e.getName()) && e.getNamespace() != Edit.NAMESPACE) { Element geonetRef = e.getChild(Edit.RootChild.ELEMENT, Edit.NAMESPACE); if (geonetRef == null) { diff --git a/services/src/main/java/org/fao/geonet/api/userfeedback/UserFeedbackUtils.java b/services/src/main/java/org/fao/geonet/api/userfeedback/UserFeedbackUtils.java index 20ab569c6912..ec5593791ee4 100644 --- a/services/src/main/java/org/fao/geonet/api/userfeedback/UserFeedbackUtils.java +++ b/services/src/main/java/org/fao/geonet/api/userfeedback/UserFeedbackUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001-2016 Food and Agriculture Organization of the + * Copyright (C) 2001-2026 Food and Agriculture Organization of the * United Nations (FAO-UN), United Nations World Food Programme (WFP) * and United Nations Environment Programme (UNEP) * @@ -173,7 +173,7 @@ public static UserFeedbackDTO convertToDto(UserFeedback input) { Map ratings = new HashMap<>(); for (final Rating rating : ratingList) { Integer id = rating.getCategory().getId(); - if (id == RatingCriteria.AVERAGE_ID) { + if (id.equals(AVERAGE_ID)) { userfeedbackDto.setRatingAVG(rating.getRating()); } else { ratings.put(id, rating.getRating()); @@ -243,7 +243,7 @@ public RatingAverage getAverage(List list) { ? value : (ratingAverages.get(criteriaId) + value) / 2); } - if (criteriaId == AVERAGE_ID) { + if (criteriaId.equals(AVERAGE_ID)) { ratingCount++; } } diff --git a/services/src/main/java/org/fao/geonet/api/usersearches/model/UserSearchDto.java b/services/src/main/java/org/fao/geonet/api/usersearches/model/UserSearchDto.java index 80edc2b5202e..22e8984c36f1 100644 --- a/services/src/main/java/org/fao/geonet/api/usersearches/model/UserSearchDto.java +++ b/services/src/main/java/org/fao/geonet/api/usersearches/model/UserSearchDto.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001-2016 Food and Agriculture Organization of the + * Copyright (C) 2001-2026 Food and Agriculture Organization of the * United Nations (FAO-UN), United Nations World Food Programme (WFP) * and United Nations Environment Programme (UNEP) * @@ -205,11 +205,11 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; UserSearchDto that = (UserSearchDto) o; return id == that.id && - featuredType == that.featuredType && + Objects.equals(featuredType, that.featuredType) && creatorId == that.creatorId && - url.equals(that.url) && - creationDate.equals(that.creationDate) && - creator.equals(that.creator) && + Objects.equals(url, that.url) && + Objects.equals(creationDate, that.creationDate) && + Objects.equals(creator, that.creator) && Objects.equals(logo, that.logo) && names.equals(that.names) && Objects.equals(groups, that.groups);