Skip to content

Commit

Permalink
Refactored StringUtils from core and persistence packages under utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Camelia-Orcid committed Aug 22, 2024
1 parent 08a52a1 commit caa9ca2
Show file tree
Hide file tree
Showing 59 changed files with 102 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import org.orcid.core.exception.OrcidBadRequestException;
import org.orcid.core.locale.LocaleManager;
import org.orcid.core.manager.impl.OrcidUrlManager;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.pojo.ajaxForm.PojoUtil;
import org.orcid.utils.OrcidStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMethod;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import org.orcid.core.manager.impl.OrcidUrlManager;
import org.orcid.core.togglz.Features;
import org.orcid.core.utils.JsonUtils;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.jaxb.model.v3.release.error.OrcidError;
import org.orcid.pojo.ajaxForm.PojoUtil;
import org.orcid.utils.OrcidStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.filter.OncePerRequestFilter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.orcid.core.exception.OrcidUnauthorizedException;
import org.orcid.core.oauth.OrcidOauth2TokenDetailService;
import org.orcid.persistence.jpa.entities.ProfileEntity;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.utils.OrcidStringUtils;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.orcid.core.oauth.OAuthError;
import org.orcid.core.oauth.OAuthErrorUtils;
import org.orcid.utils.DateUtils;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.utils.OrcidStringUtils;
import org.orcid.core.version.ApiSection;
import org.orcid.jaxb.model.message.DeprecatedDate;
import org.orcid.jaxb.model.message.ErrorDesc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import javax.servlet.http.HttpServletResponse;

import org.orcid.core.locale.LocaleManager;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.utils.OrcidStringUtils;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
Expand Down
7 changes: 1 addition & 6 deletions orcid-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,7 @@
<version>2.0.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.15.4</version>
</dependency>

<!-- https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api -->
<dependency>
<groupId>javax.ws.rs</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
import org.orcid.persistence.jpa.entities.StartDateEntity;
import org.orcid.persistence.jpa.entities.WorkEntity;
import org.orcid.pojo.ajaxForm.PojoUtil;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.utils.OrcidStringUtils;
import org.springframework.beans.factory.FactoryBean;

import ma.glasnost.orika.CustomMapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.orcid.persistence.dao.ProfileLastModifiedDao;
import org.orcid.persistence.jpa.entities.IndexingStatus;
import org.orcid.persistence.jpa.entities.OrcidAware;
import org.orcid.persistence.util.OrcidStringUtils;
import org.orcid.utils.OrcidStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.orcid.persistence.jpa.entities.ClientDetailsEntity;
import org.orcid.persistence.jpa.entities.ClientSecretEntity;
import org.orcid.utils.DateUtils;
import org.orcid.core.utils.NullUtils;
import org.orcid.utils.NullUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.transaction.TransactionStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.kohsuke.args4j.Option;
import org.orcid.persistence.dao.GenericDao;
import org.orcid.persistence.jpa.entities.WorkEntity;
import org.orcid.core.utils.NullUtils;
import org.orcid.utils.NullUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.orcid.jaxb.model.v3.release.record.summary.WorkGroup;
import org.orcid.jaxb.model.v3.release.record.summary.WorkSummary;
import org.orcid.jaxb.model.v3.release.record.summary.Works;
import org.orcid.core.utils.NullUtils;
import org.orcid.utils.NullUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.kohsuke.args4j.Option;
import org.orcid.persistence.dao.ProfileDao;
import org.orcid.persistence.jpa.entities.IndexingStatus;
import org.orcid.core.utils.NullUtils;
import org.orcid.utils.NullUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import org.orcid.jaxb.model.v3.release.record.WorkContributors;
import org.orcid.pojo.ajaxForm.ActivityExternalIdentifier;
import org.orcid.pojo.ajaxForm.PojoUtil;
import org.orcid.utils.OrcidStringUtils;
import org.orcid.core.contributors.roles.works.WorkContributorRoleConverter;
import org.orcid.core.utils.OrcidStringUtils;

public class AnonymizeText {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import org.orcid.core.manager.CountryManager;
import org.orcid.jaxb.model.message.OrcidProfile;
import org.orcid.persistence.jpa.entities.CountryIsoEntity;
import org.orcid.utils.OrcidStringUtils;
import org.orcid.core.utils.FunctionsOverCollections;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.core.utils.UTF8Control;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.orcid.core.crypto.DesEncrypter;
import org.orcid.core.manager.EncryptionManager;
import org.orcid.pojo.ajaxForm.PojoUtil;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.utils.OrcidStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.orcid.core.manager.OrgManager;
import org.orcid.core.manager.SourceManager;
import org.orcid.core.manager.read_only.ClientDetailsManagerReadOnly;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.jaxb.model.common_v2.OrganizationHolder;
import org.orcid.jaxb.model.message.Iso3166Country;
import org.orcid.jaxb.model.message.Organization;
Expand All @@ -21,6 +20,7 @@
import org.orcid.persistence.jpa.entities.OrgEntity;
import org.orcid.persistence.jpa.entities.ProfileEntity;
import org.orcid.persistence.jpa.entities.SourceEntity;
import org.orcid.utils.OrcidStringUtils;

import au.com.bytecode.opencsv.CSVWriter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.orcid.core.manager.v3.SourceManager;
import org.orcid.core.manager.v3.read_only.ClientManagerReadOnly;
import org.orcid.core.security.OrcidWebRole;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.jaxb.model.clientgroup.ClientType;
import org.orcid.jaxb.model.clientgroup.MemberType;
import org.orcid.jaxb.model.message.CreationMethod;
Expand All @@ -47,6 +46,7 @@
import org.orcid.pojo.ajaxForm.Member;
import org.orcid.pojo.ajaxForm.PojoUtil;
import org.orcid.pojo.ajaxForm.Text;
import org.orcid.utils.OrcidStringUtils;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.orcid.persistence.jpa.entities.EmailEntity;
import org.orcid.pojo.EmailFrequencyOptions;
import org.orcid.pojo.ajaxForm.PojoUtil;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.utils.OrcidStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
import org.orcid.jaxb.model.v3.release.record.WorkTitle;
import org.orcid.persistence.jpa.entities.SourceEntity;
import org.orcid.pojo.ajaxForm.PojoUtil;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.utils.OrcidStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
import org.orcid.jaxb.model.record_v2.WorkType;
import org.orcid.persistence.jpa.entities.SourceEntity;
import org.orcid.pojo.ajaxForm.PojoUtil;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.utils.OrcidStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import org.orcid.pojo.OrgDisambiguated;
import org.orcid.pojo.OrgDisambiguatedExternalIdentifiers;
import org.orcid.pojo.grouping.OrgGroup;
import org.orcid.utils.OrcidStringUtils;
import org.orcid.core.utils.FunderIdentifierType;
import org.orcid.core.utils.OrcidStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.orcid.persistence.dao.ProfileDao;
import org.orcid.persistence.jpa.entities.ProfileEntity;
import org.orcid.pojo.ajaxForm.PojoUtil;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.utils.OrcidStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.apache.commons.lang3.tuple.Pair;

import org.orcid.utils.DateUtils;
import org.orcid.utils.NullUtils;

public class PasswordResetToken {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.orcid.core.utils.NullUtils;
import org.orcid.utils.NullUtils;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.orcid.core.exception.UnexpectedResponseCodeException;
import org.orcid.core.locale.LocaleManager;
import org.orcid.core.manager.IdentifierTypeManager;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.core.utils.v3.identifiers.PIDNormalizationService;
import org.orcid.core.utils.v3.identifiers.PIDResolverCache;
import org.orcid.core.utils.v3.identifiers.normalizers.DOINormalizer;
Expand All @@ -47,6 +46,7 @@
import org.orcid.pojo.PIDResolutionResult;
import org.orcid.pojo.WorkExtended;
import org.orcid.pojo.ajaxForm.PojoUtil;
import org.orcid.utils.OrcidStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.orcid.jaxb.model.v3.release.record.summary.QualificationSummary;
import org.orcid.jaxb.model.v3.release.record.summary.ServiceSummary;
import org.orcid.pojo.OrgDisambiguatedExternalIdentifiers;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.utils.OrcidStringUtils;

public class AffiliationForm extends VisibilityForm implements ErrorsInterface, Serializable {

Expand Down
2 changes: 1 addition & 1 deletion orcid-core/src/main/java/org/orcid/pojo/ajaxForm/Text.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.ArrayList;
import java.util.List;

import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.utils.OrcidStringUtils;

public class Text implements ErrorsInterface, Required, Serializable, Comparable<Text> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import org.apache.commons.lang.StringUtils;
import org.orcid.utils.DateUtils;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.utils.OrcidStringUtils;
import org.orcid.jaxb.model.common.CitationType;
import org.orcid.jaxb.model.common.Relationship;
import org.orcid.jaxb.model.common.WorkType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import org.orcid.test.DBUnitTest;
import org.orcid.test.OrcidJUnit4ClassRunner;
import org.orcid.test.TargetProxyHelper;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.utils.OrcidStringUtils;
import org.springframework.security.oauth2.common.exceptions.InvalidRequestException;
import org.springframework.test.context.ContextConfiguration;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.mockito.MockitoAnnotations;
import org.orcid.core.BaseTest;
import org.orcid.core.manager.EncryptionManager;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.jaxb.model.v3.release.common.Visibility;
import org.orcid.jaxb.model.v3.release.record.Email;
import org.orcid.jaxb.model.v3.release.record.Emails;
Expand All @@ -45,6 +44,7 @@
import org.orcid.persistence.jpa.entities.ProfileEntity;
import org.orcid.persistence.jpa.entities.SourceEntity;
import org.orcid.test.TargetProxyHelper;
import org.orcid.utils.OrcidStringUtils;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.test.util.ReflectionTestUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.orcid.test.DBUnitTest;
import org.orcid.test.OrcidJUnit4ClassRunner;
import org.orcid.test.TargetProxyHelper;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.utils.OrcidStringUtils;
import org.springframework.test.context.ContextConfiguration;

@RunWith(OrcidJUnit4ClassRunner.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.orcid.core.utils;

import org.junit.Test;
import org.orcid.core.utils.OrcidStringUtils;
import org.orcid.utils.OrcidStringUtils;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand Down
7 changes: 6 additions & 1 deletion orcid-persistence/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@
</build>

<dependencies>
<!-- Internal dependencies -->
<!-- Internal dependencies -->
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>orcid-utils</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.orcid</groupId>
<artifactId>orcid-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;

import org.orcid.persistence.util.OrcidStringUtils;
import org.orcid.utils.NullUtils;

/**
* @author Declan Newman (declan) Date: 08/08/2012
Expand Down Expand Up @@ -72,19 +72,19 @@ public int compareTo(BaseContributorEntity other) {
if (other == null) {
return -1;
}
int compareSequenceTypes = OrcidStringUtils.compareObjectsNullSafe(sequence, other.getSequence());
int compareSequenceTypes = NullUtils.compareObjectsNullSafe(sequence, other.getSequence());
if (compareSequenceTypes != 0) {
return compareSequenceTypes;
}
int compareRoles = OrcidStringUtils.compareObjectsNullSafe(contributorRole, other.getContributorRole());
int compareRoles = NullUtils.compareObjectsNullSafe(contributorRole, other.getContributorRole());
if (compareRoles != 0) {
return compareRoles;
}
int compareCreditNames = OrcidStringUtils.compareObjectsNullSafe(creditName, other.getCreditName());
int compareCreditNames = NullUtils.compareObjectsNullSafe(creditName, other.getCreditName());
if (compareCreditNames != 0) {
return compareCreditNames;
}
int compareEmails = OrcidStringUtils.compareObjectsNullSafe(contributorEmail, other.getContributorEmail());
int compareEmails = NullUtils.compareObjectsNullSafe(contributorEmail, other.getContributorEmail());
if (compareEmails != 0) {
return compareEmails;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import javax.persistence.Transient;

import org.orcid.persistence.jpa.entities.keys.ClientSecretPk;
import org.orcid.persistence.util.OrcidStringUtils;
import org.orcid.utils.NullUtils;

/**
*
Expand Down Expand Up @@ -101,7 +101,7 @@ public void setDecryptedClientSecret(String decryptedClientSecret) {
public int compareTo(ClientSecretEntity other) {
Date otherLastModified = other.getLastModified();
Date thisLastModified = getLastModified();
int dateComparison = OrcidStringUtils.compareObjectsNullSafe(thisLastModified, otherLastModified);
int dateComparison = NullUtils.compareObjectsNullSafe(thisLastModified, otherLastModified);
if (dateComparison != 0) {
return -dateComparison;
}
Expand Down
Loading

0 comments on commit caa9ca2

Please sign in to comment.