Skip to content
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
50 changes: 23 additions & 27 deletions core/src/main/java/org/fao/geonet/kernel/EditLib.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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));

Expand Down
Original file line number Diff line number Diff line change
@@ -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)
//===
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
//===
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 4 additions & 7 deletions domain/src/main/java/org/fao/geonet/domain/MetadataLink.java
Original file line number Diff line number Diff line change
@@ -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)
*
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions domain/src/main/java/org/fao/geonet/domain/UserSearch.java
Original file line number Diff line number Diff line change
@@ -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)
*
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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)
*
Expand Down Expand Up @@ -256,7 +256,7 @@ public ResponseEntity deleteTag(
Optional<MetadataCategory> category = categoryRepository.findById(tagIdentifier);
if (category.isPresent()) {
long recordsCount = metadataRepository.count((Specification<Metadata>) 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
*
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
//===
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
*
Expand Down Expand Up @@ -173,7 +173,7 @@ public static UserFeedbackDTO convertToDto(UserFeedback input) {
Map<Integer, Integer> 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());
Expand Down Expand Up @@ -243,7 +243,7 @@ public RatingAverage getAverage(List<UserFeedback> list) {
? value
: (ratingAverages.get(criteriaId) + value) / 2);
}
if (criteriaId == AVERAGE_ID) {
if (criteriaId.equals(AVERAGE_ID)) {
ratingCount++;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
*
Expand Down Expand Up @@ -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);
Expand Down
Loading