mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-11 12:03:09 +00:00
First batch of errorprone fixes. #3061
This commit is contained in:
@@ -169,6 +169,7 @@ public class ResourcePolicy implements ReloadableEntity<Integer> {
|
||||
*
|
||||
* @return the internal identifier
|
||||
*/
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@ import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.core.Constants;
|
||||
@@ -36,17 +35,10 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
||||
* the contents of a bitstream; you need to create a new bitstream.
|
||||
*
|
||||
* @author Robert Tansley
|
||||
* @version $Revision$
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "bitstream")
|
||||
public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||
|
||||
/**
|
||||
* log4j logger
|
||||
*/
|
||||
private static Logger log = Logger.getLogger(Bitstream.class);
|
||||
|
||||
@Column(name = "bitstream_id", insertable = false, updatable = false)
|
||||
private Integer legacyId;
|
||||
|
||||
@@ -411,7 +403,7 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == null) {
|
||||
if (!(other instanceof Bitstream)) {
|
||||
return false;
|
||||
}
|
||||
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(other);
|
||||
@@ -419,11 +411,7 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
return false;
|
||||
}
|
||||
final Bitstream otherBitstream = (Bitstream) other;
|
||||
if (!this.getID().equals(otherBitstream.getID())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return this.getID().equals(otherBitstream.getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -40,7 +40,6 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
||||
* when <code>update</code> is called.
|
||||
*
|
||||
* @author Robert Tansley
|
||||
* @version $Revision$
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "bitstreamformatregistry")
|
||||
@@ -120,6 +119,7 @@ public class BitstreamFormat implements Serializable, ReloadableEntity<Integer>
|
||||
*
|
||||
* @return the internal identifier
|
||||
*/
|
||||
@Override
|
||||
public final Integer getID() {
|
||||
return id;
|
||||
}
|
||||
@@ -267,7 +267,7 @@ public class BitstreamFormat implements Serializable, ReloadableEntity<Integer>
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == null) {
|
||||
if (!(other instanceof BitstreamFormat)) {
|
||||
return false;
|
||||
}
|
||||
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(other);
|
||||
@@ -275,11 +275,7 @@ public class BitstreamFormat implements Serializable, ReloadableEntity<Integer>
|
||||
return false;
|
||||
}
|
||||
final BitstreamFormat otherBitstreamFormat = (BitstreamFormat) other;
|
||||
if (!this.getID().equals(otherBitstreamFormat.getID())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return this.getID().equals(otherBitstreamFormat.getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -310,7 +310,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
* whitespace.
|
||||
*/
|
||||
if (value == null) {
|
||||
clearMetadata(context, collection, field.SCHEMA, field.ELEMENT, field.QUALIFIER, Item.ANY);
|
||||
clearMetadata(context, collection, field.schema, field.element, field.qualifier, Item.ANY);
|
||||
collection.setMetadataModified();
|
||||
} else {
|
||||
super.setMetadataSingleValue(context, collection, field, null, value);
|
||||
|
@@ -24,7 +24,6 @@ import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.comparator.NameAscendingComparator;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
@@ -42,18 +41,12 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
||||
* <code>update</code> is called.
|
||||
*
|
||||
* @author Robert Tansley
|
||||
* @version $Revision$
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "community")
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy")
|
||||
public class Community extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(Community.class);
|
||||
|
||||
@Column(name = "community_id", insertable = false, updatable = false)
|
||||
private Integer legacyId;
|
||||
|
||||
@@ -215,7 +208,7 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == null) {
|
||||
if (!(other instanceof Community)) {
|
||||
return false;
|
||||
}
|
||||
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(other);
|
||||
@@ -223,11 +216,7 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
return false;
|
||||
}
|
||||
final Community otherCommunity = (Community) other;
|
||||
if (!this.getID().equals(otherCommunity.getID())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return this.getID().equals(otherCommunity.getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -192,7 +192,7 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
||||
* whitespace.
|
||||
*/
|
||||
if (value == null) {
|
||||
clearMetadata(context, community, field.SCHEMA, field.ELEMENT, field.QUALIFIER, Item.ANY);
|
||||
clearMetadata(context, community, field.schema, field.element, field.qualifier, Item.ANY);
|
||||
community.setMetadataModified();
|
||||
} else {
|
||||
super.setMetadataSingleValue(context, community, field, null, value);
|
||||
|
@@ -39,7 +39,6 @@ import org.apache.logging.log4j.Logger;
|
||||
*
|
||||
* @author Robert Tansley
|
||||
* @author Larry Stone
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class DCDate {
|
||||
/**
|
||||
@@ -370,6 +369,7 @@ public class DCDate {
|
||||
*
|
||||
* @return The date as a string.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
if (calendar == null) {
|
||||
return "null";
|
||||
|
@@ -61,7 +61,7 @@ public abstract class DSpaceObject implements Serializable, ReloadableEntity<jav
|
||||
private List<Handle> handles = new ArrayList<>();
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "dSpaceObject", cascade = CascadeType.ALL)
|
||||
private List<ResourcePolicy> resourcePolicies = new ArrayList<>();
|
||||
private final List<ResourcePolicy> resourcePolicies = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* True if anything else was changed since last update()
|
||||
@@ -122,6 +122,7 @@ public abstract class DSpaceObject implements Serializable, ReloadableEntity<jav
|
||||
*
|
||||
* @return internal ID of object
|
||||
*/
|
||||
@Override
|
||||
public UUID getID() {
|
||||
return id;
|
||||
}
|
||||
|
@@ -420,7 +420,7 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
||||
@Override
|
||||
public String getMetadataFirstValue(T dso, MetadataFieldName field, String language) {
|
||||
List<MetadataValue> metadataValues
|
||||
= getMetadata(dso, field.SCHEMA, field.ELEMENT, field.QUALIFIER, language);
|
||||
= getMetadata(dso, field.schema, field.element, field.qualifier, language);
|
||||
if (CollectionUtils.isNotEmpty(metadataValues)) {
|
||||
return metadataValues.get(0).getValue();
|
||||
}
|
||||
@@ -447,11 +447,11 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
||||
String language, String value)
|
||||
throws SQLException {
|
||||
if (value != null) {
|
||||
clearMetadata(context, dso, field.SCHEMA, field.ELEMENT, field.QUALIFIER,
|
||||
clearMetadata(context, dso, field.schema, field.element, field.qualifier,
|
||||
language);
|
||||
|
||||
String newValueLanguage = (Item.ANY.equals(language)) ? null : language;
|
||||
addMetadata(context, dso, field.SCHEMA, field.ELEMENT, field.QUALIFIER,
|
||||
addMetadata(context, dso, field.schema, field.element, field.qualifier,
|
||||
newValueLanguage, value);
|
||||
dso.setMetadataModified();
|
||||
}
|
||||
|
@@ -17,7 +17,6 @@ import org.dspace.eperson.EPerson;
|
||||
* which stage of submission they are (in workspace or workflow system)
|
||||
*
|
||||
* @author Robert Tansley
|
||||
* @version $Revision$
|
||||
*/
|
||||
public interface InProgressSubmission extends ReloadableEntity<Integer> {
|
||||
/**
|
||||
@@ -25,6 +24,7 @@ public interface InProgressSubmission extends ReloadableEntity<Integer> {
|
||||
*
|
||||
* @return the internal identifier
|
||||
*/
|
||||
@Override
|
||||
Integer getID();
|
||||
|
||||
/**
|
||||
|
@@ -27,7 +27,6 @@ import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.comparator.NameAscendingComparator;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.ItemService;
|
||||
@@ -48,17 +47,10 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
||||
*
|
||||
* @author Robert Tansley
|
||||
* @author Martin Hald
|
||||
* @version $Revision$
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "item")
|
||||
public class Item extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||
|
||||
/**
|
||||
* log4j logger
|
||||
*/
|
||||
private static Logger log = Logger.getLogger(Item.class);
|
||||
|
||||
/**
|
||||
* Wild card for Dublin Core metadata qualifiers/languages
|
||||
*/
|
||||
@@ -286,7 +278,7 @@ public class Item extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||
* @return the bundles in an unordered array
|
||||
*/
|
||||
public List<Bundle> getBundles(String name) {
|
||||
List<Bundle> matchingBundles = new ArrayList<Bundle>();
|
||||
List<Bundle> matchingBundles = new ArrayList<>();
|
||||
// now only keep bundles with matching names
|
||||
List<Bundle> bunds = getBundles();
|
||||
for (Bundle bundle : bunds) {
|
||||
@@ -317,7 +309,7 @@ public class Item extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||
|
||||
/**
|
||||
* Return <code>true</code> if <code>other</code> is the same Item as
|
||||
* this object, <code>false</code> otherwise
|
||||
* this object, <code>false</code> otherwise.
|
||||
*
|
||||
* @param obj object to compare to
|
||||
* @return <code>true</code> if object passed in represents the same item
|
||||
@@ -325,7 +317,7 @@ public class Item extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
if (!(obj instanceof Item)) {
|
||||
return false;
|
||||
}
|
||||
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj);
|
||||
@@ -333,10 +325,7 @@ public class Item extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||
return false;
|
||||
}
|
||||
final Item otherItem = (Item) obj;
|
||||
if (!this.getID().equals(otherItem.getID())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return this.getID().equals(otherItem.getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -32,7 +32,6 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
||||
* metadata element belongs in a field.
|
||||
*
|
||||
* @author Martin Hald
|
||||
* @version $Revision$
|
||||
* @see org.dspace.content.MetadataValue
|
||||
* @see org.dspace.content.MetadataSchema
|
||||
*/
|
||||
@@ -77,6 +76,7 @@ public class MetadataField implements ReloadableEntity<Integer> {
|
||||
*
|
||||
* @return metadata field id
|
||||
*/
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public class MetadataField implements ReloadableEntity<Integer> {
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
if (!(obj instanceof MetadataField)) {
|
||||
return false;
|
||||
}
|
||||
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj);
|
||||
@@ -175,10 +175,7 @@ public class MetadataField implements ReloadableEntity<Integer> {
|
||||
if (!this.getID().equals(other.getID())) {
|
||||
return false;
|
||||
}
|
||||
if (!getMetadataSchema().equals(other.getMetadataSchema())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return getMetadataSchema().equals(other.getMetadataSchema());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -17,13 +17,13 @@ import javax.annotation.Nonnull;
|
||||
*/
|
||||
public class MetadataFieldName {
|
||||
/** Name of the metadata schema which defines this field. Never null. */
|
||||
public final String SCHEMA;
|
||||
public final String schema;
|
||||
|
||||
/** Element name of this field. Never null. */
|
||||
public final String ELEMENT;
|
||||
public final String element;
|
||||
|
||||
/** Qualifier name of this field. May be {@code null}. */
|
||||
public final String QUALIFIER;
|
||||
public final String qualifier;
|
||||
|
||||
/**
|
||||
* Initialize a tuple of (schema, element, qualifier) to name a metadata field.
|
||||
@@ -40,9 +40,9 @@ public class MetadataFieldName {
|
||||
throw new NullPointerException("Element must not be null.");
|
||||
}
|
||||
|
||||
SCHEMA = schema;
|
||||
ELEMENT = element;
|
||||
QUALIFIER = qualifier;
|
||||
this.schema = schema;
|
||||
this.element = element;
|
||||
this.qualifier = qualifier;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,9 +59,9 @@ public class MetadataFieldName {
|
||||
throw new NullPointerException("Element must not be null.");
|
||||
}
|
||||
|
||||
SCHEMA = schema;
|
||||
ELEMENT = element;
|
||||
QUALIFIER = null;
|
||||
this.schema = schema;
|
||||
this.element = element;
|
||||
qualifier = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,9 +79,9 @@ public class MetadataFieldName {
|
||||
throw new IllegalArgumentException("Element must not be null.");
|
||||
}
|
||||
|
||||
SCHEMA = schema.getName();
|
||||
ELEMENT = element;
|
||||
QUALIFIER = qualifier;
|
||||
this.schema = schema.getName();
|
||||
this.element = element;
|
||||
this.qualifier = qualifier;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,9 +98,9 @@ public class MetadataFieldName {
|
||||
throw new IllegalArgumentException("Element must not be null.");
|
||||
}
|
||||
|
||||
SCHEMA = schema.getName();
|
||||
ELEMENT = element;
|
||||
QUALIFIER = null;
|
||||
this.schema = schema.getName();
|
||||
this.element = element;
|
||||
qualifier = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,9 +110,9 @@ public class MetadataFieldName {
|
||||
*/
|
||||
public MetadataFieldName(@Nonnull String name) {
|
||||
String[] elements = parse(name);
|
||||
SCHEMA = elements[0];
|
||||
ELEMENT = elements[1];
|
||||
QUALIFIER = elements[2];
|
||||
schema = elements[0];
|
||||
element = elements[1];
|
||||
qualifier = elements[2];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,17 +138,17 @@ public class MetadataFieldName {
|
||||
|
||||
/**
|
||||
* Format a dotted-atoms representation of this field name.
|
||||
* @return SCHEMA.ELEMENT.QUALIFIER
|
||||
* @return schema.element.qualifier
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buffer = new StringBuilder(32);
|
||||
buffer.append(SCHEMA)
|
||||
buffer.append(schema)
|
||||
.append('.')
|
||||
.append(ELEMENT);
|
||||
if (null != QUALIFIER) {
|
||||
.append(element);
|
||||
if (null != qualifier) {
|
||||
buffer.append('.')
|
||||
.append(QUALIFIER);
|
||||
.append(qualifier);
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
@@ -30,7 +30,6 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
||||
* </p>
|
||||
*
|
||||
* @author Martin Hald
|
||||
* @version $Revision$
|
||||
* @see org.dspace.content.MetadataValue
|
||||
* @see org.dspace.content.MetadataField
|
||||
*/
|
||||
@@ -129,6 +128,7 @@ public class MetadataSchema implements ReloadableEntity<Integer> {
|
||||
*
|
||||
* @return schema record key
|
||||
*/
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@ public class MetadataValue implements ReloadableEntity<Integer> {
|
||||
@Column(name = "metadata_value_id")
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "metadatavalue_seq")
|
||||
@SequenceGenerator(name = "metadatavalue_seq", sequenceName = "metadatavalue_seq", allocationSize = 1)
|
||||
private Integer id;
|
||||
private final Integer id;
|
||||
|
||||
/**
|
||||
* The primary key for the metadata value
|
||||
@@ -104,6 +104,7 @@ public class MetadataValue implements ReloadableEntity<Integer> {
|
||||
*
|
||||
* @return metadata value ID
|
||||
*/
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
@@ -249,10 +250,7 @@ public class MetadataValue implements ReloadableEntity<Integer> {
|
||||
if (!this.getID().equals(other.getID())) {
|
||||
return false;
|
||||
}
|
||||
if (!this.getDSpaceObject().getID().equals(other.getDSpaceObject().getID())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return this.getDSpaceObject().getID().equals(other.getDSpaceObject().getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -33,6 +33,7 @@ import org.dspace.core.Context;
|
||||
*/
|
||||
public interface BitstreamService extends DSpaceObjectService<Bitstream>, DSpaceObjectLegacySupportService<Bitstream> {
|
||||
|
||||
@Override
|
||||
public Bitstream find(Context context, UUID id) throws SQLException;
|
||||
|
||||
public List<Bitstream> findAll(Context context) throws SQLException;
|
||||
|
@@ -46,8 +46,6 @@ import org.springframework.util.CollectionUtils;
|
||||
* changes and free up the resources.
|
||||
* <P>
|
||||
* The context object is also used as a cache for CM API objects.
|
||||
*
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class Context implements AutoCloseable {
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(Context.class);
|
||||
|
@@ -217,12 +217,11 @@ public class I18nUtil {
|
||||
*/
|
||||
public static String getInputFormsFileName(Locale locale) {
|
||||
/** Name of the form definition XML file */
|
||||
String fileName = "";
|
||||
final String FORM_DEF_FILE = "submission-forms";
|
||||
final String FILE_TYPE = ".xml";
|
||||
String defsFilename = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir")
|
||||
+ File.separator + "config" + File.separator + FORM_DEF_FILE;
|
||||
fileName = getFilename(locale, defsFilename, FILE_TYPE);
|
||||
String fileName = getFilename(locale, defsFilename, FILE_TYPE);
|
||||
return fileName;
|
||||
}
|
||||
|
||||
@@ -286,14 +285,13 @@ public class I18nUtil {
|
||||
*/
|
||||
public static String getDefaultLicense(Context context) {
|
||||
Locale locale = context.getCurrentLocale();
|
||||
String fileName = "";
|
||||
/** Name of the default license */
|
||||
final String DEF_LIC_FILE = "default";
|
||||
final String FILE_TYPE = ".license";
|
||||
String defsFilename = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir")
|
||||
+ File.separator + "config" + File.separator + DEF_LIC_FILE;
|
||||
|
||||
fileName = getFilename(locale, defsFilename, FILE_TYPE);
|
||||
String fileName = getFilename(locale, defsFilename, FILE_TYPE);
|
||||
|
||||
return fileName;
|
||||
}
|
||||
@@ -316,8 +314,7 @@ public class I18nUtil {
|
||||
// with Language, Country
|
||||
String fileNameLC = null;
|
||||
// with Language
|
||||
String fileNameL = null;
|
||||
fileNameL = fileName + "_" + locale.getLanguage();
|
||||
String fileNameL = fileName + "_" + locale.getLanguage();
|
||||
|
||||
if (fileType == null) {
|
||||
fileType = "";
|
||||
@@ -372,12 +369,11 @@ public class I18nUtil {
|
||||
* String - localized filename of an email template
|
||||
*/
|
||||
public static String getEmailFilename(Locale locale, String name) {
|
||||
String templateName = "";
|
||||
String templateFile = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir")
|
||||
+ File.separator + "config" + File.separator + "emails"
|
||||
+ File.separator + name;
|
||||
|
||||
templateName = getFilename(locale, templateFile, "");
|
||||
String templateName = getFilename(locale, templateFile, "");
|
||||
return templateName;
|
||||
}
|
||||
|
||||
@@ -389,7 +385,7 @@ public class I18nUtil {
|
||||
* @return array of locale results, possibly empty
|
||||
*/
|
||||
public static Locale[] parseLocales(String[] locales) {
|
||||
List<Locale> resultList = new ArrayList<Locale>();
|
||||
List<Locale> resultList = new ArrayList<>();
|
||||
for (String ls : locales) {
|
||||
Locale lc = makeLocale(ls);
|
||||
if (lc != null) {
|
||||
|
@@ -33,8 +33,10 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.coverity.security.Escape;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.text.StringSubstitutor;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
@@ -43,13 +45,12 @@ import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
* Utility functions for DSpace.
|
||||
*
|
||||
* @author Peter Breton
|
||||
* @version $Revision$
|
||||
*/
|
||||
public final class Utils {
|
||||
/**
|
||||
* log4j logger
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(Utils.class);
|
||||
private static final Logger log = LogManager.getLogger(Utils.class);
|
||||
|
||||
private static final Pattern DURATION_PATTERN = Pattern
|
||||
.compile("(\\d+)([smhdwy])");
|
||||
@@ -68,12 +69,12 @@ public final class Utils {
|
||||
|
||||
private static int counter = 0;
|
||||
|
||||
private static Random random = new Random();
|
||||
private static final Random random = new Random();
|
||||
|
||||
private static VMID vmid = new VMID();
|
||||
private static final VMID vmid = new VMID();
|
||||
|
||||
// for parseISO8601Date
|
||||
private static SimpleDateFormat parseFmt[] = {
|
||||
private static final SimpleDateFormat parseFmt[] = {
|
||||
// first try at parsing, has milliseconds (note General time zone)
|
||||
new SimpleDateFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ss.SSSz"),
|
||||
|
||||
@@ -88,12 +89,14 @@ public final class Utils {
|
||||
|
||||
// for formatISO8601Date
|
||||
// output canonical format (note RFC22 time zone, easier to hack)
|
||||
private static SimpleDateFormat outFmtSecond = new SimpleDateFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ssZ");
|
||||
private static final SimpleDateFormat outFmtSecond
|
||||
= new SimpleDateFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ssZ");
|
||||
|
||||
// output format with millsecond precision
|
||||
private static SimpleDateFormat outFmtMillisec = new SimpleDateFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ss.SSSZ");
|
||||
private static final SimpleDateFormat outFmtMillisec
|
||||
= new SimpleDateFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ss.SSSZ");
|
||||
|
||||
private static Calendar outCal = GregorianCalendar.getInstance();
|
||||
private static final Calendar outCal = GregorianCalendar.getInstance();
|
||||
|
||||
/**
|
||||
* Private constructor
|
||||
@@ -107,7 +110,7 @@ public final class Utils {
|
||||
* @return MD5 checksum for the data in hex format.
|
||||
*/
|
||||
public static String getMD5(String data) {
|
||||
return getMD5(data.getBytes());
|
||||
return getMD5(data.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,7 +153,7 @@ public final class Utils {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
// This is far from the most efficient way to do things...
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
@@ -194,10 +197,14 @@ public final class Utils {
|
||||
|
||||
random.nextBytes(junk);
|
||||
|
||||
String input = new StringBuffer().append(vmid).append(
|
||||
new java.util.Date()).append(Arrays.toString(junk)).append(counter++).toString();
|
||||
String input = new StringBuilder()
|
||||
.append(vmid)
|
||||
.append(new java.util.Date())
|
||||
.append(Arrays.toString(junk))
|
||||
.append(counter++)
|
||||
.toString();
|
||||
|
||||
return getMD5Bytes(input.getBytes());
|
||||
return getMD5Bytes(input.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
// The following two methods are taken from the Jakarta IOUtil class.
|
||||
|
@@ -13,7 +13,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
@@ -39,8 +38,6 @@ public abstract class AbstractCurationTask implements CurationTask {
|
||||
protected Curator curator = null;
|
||||
// curator-assigned taskId
|
||||
protected String taskId = null;
|
||||
// logger
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(AbstractCurationTask.class);
|
||||
protected CommunityService communityService;
|
||||
protected ItemService itemService;
|
||||
protected HandleService handleService;
|
||||
|
@@ -19,7 +19,6 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.BitstreamFormat;
|
||||
import org.dspace.content.Bundle;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
@@ -46,7 +45,7 @@ public class CitationPage extends AbstractCurationTask {
|
||||
/**
|
||||
* Class Logger
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(CitationPage.class);
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(CitationPage.class);
|
||||
|
||||
protected int status = Curator.CURATE_UNSET;
|
||||
protected String result = null;
|
||||
@@ -97,7 +96,7 @@ public class CitationPage extends AbstractCurationTask {
|
||||
//Determine if the DISPLAY bundle exits. If not, create it.
|
||||
List<Bundle> dBundles = itemService.getBundles(item, CitationPage.DISPLAY_BUNDLE_NAME);
|
||||
Bundle dBundle = null;
|
||||
if (dBundles == null || dBundles.size() == 0) {
|
||||
if (dBundles == null || dBundles.isEmpty()) {
|
||||
try {
|
||||
dBundle = bundleService.create(Curator.curationContext(), item, CitationPage.DISPLAY_BUNDLE_NAME);
|
||||
} catch (AuthorizeException e) {
|
||||
@@ -110,7 +109,7 @@ public class CitationPage extends AbstractCurationTask {
|
||||
|
||||
//Create a map of the bitstreams in the displayBundle. This is used to
|
||||
//check if the bundle being cited is already in the display bundle.
|
||||
Map<String, Bitstream> displayMap = new HashMap<String, Bitstream>();
|
||||
Map<String, Bitstream> displayMap = new HashMap<>();
|
||||
for (Bitstream bs : dBundle.getBitstreams()) {
|
||||
displayMap.put(bs.getName(), bs);
|
||||
}
|
||||
@@ -143,15 +142,16 @@ public class CitationPage extends AbstractCurationTask {
|
||||
// Loop through each file and generate a cover page for documents
|
||||
// that are PDFs.
|
||||
for (Bitstream bitstream : bitstreams) {
|
||||
BitstreamFormat format = bitstream.getFormat(Curator.curationContext());
|
||||
|
||||
//If bitstream is a PDF document then it is citable.
|
||||
CitationDocumentService citationDocument = DisseminateServiceFactory.getInstance()
|
||||
.getCitationDocumentService();
|
||||
|
||||
if (citationDocument.canGenerateCitationVersion(Curator.curationContext(), bitstream)) {
|
||||
this.resBuilder.append(item.getHandle() + " - "
|
||||
+ bitstream.getName() + " is citable.");
|
||||
this.resBuilder.append(item.getHandle())
|
||||
.append(" - ")
|
||||
.append(bitstream.getName())
|
||||
.append(" is citable.");
|
||||
try {
|
||||
//Create the cited document
|
||||
Pair<InputStream, Long> citedDocument =
|
||||
@@ -168,7 +168,9 @@ public class CitationPage extends AbstractCurationTask {
|
||||
StringBuilder stack = new StringBuilder();
|
||||
int numLines = Math.min(stackTrace.length, 12);
|
||||
for (int j = 0; j < numLines; j++) {
|
||||
stack.append("\t" + stackTrace[j].toString() + "\n");
|
||||
stack.append("\t")
|
||||
.append(stackTrace[j].toString())
|
||||
.append("\n");
|
||||
}
|
||||
if (stackTrace.length > numLines) {
|
||||
stack.append("\t. . .\n");
|
||||
@@ -180,8 +182,10 @@ public class CitationPage extends AbstractCurationTask {
|
||||
}
|
||||
} else {
|
||||
//bitstream is not a document
|
||||
this.resBuilder.append(item.getHandle() + " - "
|
||||
+ bitstream.getName() + " is not citable.\n");
|
||||
this.resBuilder.append(item.getHandle())
|
||||
.append(" - ")
|
||||
.append(bitstream.getName())
|
||||
.append(" is not citable.\n");
|
||||
this.status = Curator.CURATE_SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -211,11 +215,11 @@ public class CitationPage extends AbstractCurationTask {
|
||||
//If we are modifying a file that is not in the
|
||||
//preservation bundle then we have to move it there.
|
||||
Context context = Curator.curationContext();
|
||||
if (bundle.getID() != pBundle.getID()) {
|
||||
if (!bundle.getID().equals(pBundle.getID())) {
|
||||
bundleService.addBitstream(context, pBundle, bitstream);
|
||||
bundleService.removeBitstream(context, bundle, bitstream);
|
||||
List<Bitstream> bitstreams = bundle.getBitstreams();
|
||||
if (bitstreams == null || bitstreams.size() == 0) {
|
||||
if (bitstreams == null || bitstreams.isEmpty()) {
|
||||
itemService.removeBundle(context, item, bundle);
|
||||
}
|
||||
}
|
||||
@@ -235,9 +239,11 @@ public class CitationPage extends AbstractCurationTask {
|
||||
bitstreamService.setFormat(context, citedBitstream, bitstream.getFormat(Curator.curationContext()));
|
||||
citedBitstream.setDescription(context, bitstream.getDescription());
|
||||
|
||||
this.resBuilder.append(" Added "
|
||||
+ citedBitstream.getName()
|
||||
+ " to the " + CitationPage.DISPLAY_BUNDLE_NAME + " bundle.\n");
|
||||
this.resBuilder.append(" Added ")
|
||||
.append(citedBitstream.getName())
|
||||
.append(" to the ")
|
||||
.append(CitationPage.DISPLAY_BUNDLE_NAME)
|
||||
.append(" bundle.\n");
|
||||
|
||||
//Run update to propagate changes to the
|
||||
//database.
|
||||
|
@@ -15,11 +15,13 @@ import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Properties;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
@@ -64,7 +66,7 @@ import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
public class TaskResolver {
|
||||
// logging service
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(TaskResolver.class);
|
||||
private static final Logger log = LogManager.getLogger(TaskResolver.class);
|
||||
|
||||
// base directory of task scripts & catalog name
|
||||
protected static final String CATALOG = "task.catalog";
|
||||
@@ -94,7 +96,7 @@ public class TaskResolver {
|
||||
if (script.exists()) {
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(script));
|
||||
reader = new BufferedReader(new FileReader(script, StandardCharsets.UTF_8));
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (line.startsWith("#") && line.indexOf("$td=") > 0) {
|
||||
@@ -136,7 +138,7 @@ public class TaskResolver {
|
||||
catalog.put(taskName, descriptor);
|
||||
Writer writer = null;
|
||||
try {
|
||||
writer = new FileWriter(new File(scriptDir, CATALOG));
|
||||
writer = new FileWriter(new File(scriptDir, CATALOG), StandardCharsets.UTF_8);
|
||||
catalog.store(writer, "do not edit");
|
||||
} catch (IOException ioE) {
|
||||
log.error("Error saving scripted task catalog: " + CATALOG);
|
||||
@@ -179,7 +181,7 @@ public class TaskResolver {
|
||||
File script = new File(scriptDir, tokens[1]);
|
||||
if (script.exists()) {
|
||||
try {
|
||||
Reader reader = new FileReader(script);
|
||||
Reader reader = new FileReader(script, StandardCharsets.UTF_8);
|
||||
engine.eval(reader);
|
||||
reader.close();
|
||||
// third token is the constructor expression for the class
|
||||
@@ -212,7 +214,7 @@ public class TaskResolver {
|
||||
File catalogFile = new File(scriptDir, CATALOG);
|
||||
if (catalogFile.exists()) {
|
||||
try {
|
||||
Reader reader = new FileReader(catalogFile);
|
||||
Reader reader = new FileReader(catalogFile, StandardCharsets.UTF_8);
|
||||
catalog.load(reader);
|
||||
reader.close();
|
||||
} catch (IOException ioE) {
|
||||
|
@@ -16,9 +16,9 @@ import java.io.Reader;
|
||||
import java.io.SequenceInputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class FullTextContentStreams extends ContentStreamBase {
|
||||
}
|
||||
|
||||
protected void init(Item parentItem) {
|
||||
fullTextStreams = new LinkedList<>();
|
||||
fullTextStreams = new ArrayList<>();
|
||||
|
||||
if (parentItem != null) {
|
||||
sourceInfo = parentItem.getHandle();
|
||||
@@ -149,8 +149,8 @@ public class FullTextContentStreams extends ContentStreamBase {
|
||||
}
|
||||
|
||||
private class FullTextBitstream {
|
||||
private String itemHandle;
|
||||
private Bitstream bitstream;
|
||||
private final String itemHandle;
|
||||
private final Bitstream bitstream;
|
||||
|
||||
public FullTextBitstream(final String parentHandle, final Bitstream file) {
|
||||
this.itemHandle = parentHandle;
|
||||
@@ -179,18 +179,20 @@ public class FullTextContentStreams extends ContentStreamBase {
|
||||
}
|
||||
}
|
||||
|
||||
private class FullTextEnumeration implements Enumeration<InputStream> {
|
||||
private static class FullTextEnumeration implements Enumeration<InputStream> {
|
||||
|
||||
private final Iterator<FullTextBitstream> fulltextIterator;
|
||||
|
||||
public FullTextEnumeration(final Iterator<FullTextBitstream> fulltextStreams) {
|
||||
this.fulltextIterator = fulltextStreams;
|
||||
public FullTextEnumeration(final Iterator<FullTextBitstream> fulltextIterator) {
|
||||
this.fulltextIterator = fulltextIterator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMoreElements() {
|
||||
return fulltextIterator.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream nextElement() {
|
||||
InputStream inputStream = null;
|
||||
FullTextBitstream bitstream = null;
|
||||
|
@@ -104,7 +104,9 @@ public class ConsumerProfile {
|
||||
"No filters configured for consumer named: " + name);
|
||||
}
|
||||
|
||||
consumer = (Consumer) Class.forName(className.trim()).getDeclaredConstructor().newInstance();
|
||||
consumer = Class.forName(className.trim())
|
||||
.asSubclass(Consumer.class)
|
||||
.getDeclaredConstructor().newInstance();
|
||||
|
||||
// Each "filter" is <objectTypes> + <eventTypes> : ...
|
||||
filters = new ArrayList<>();
|
||||
|
@@ -48,8 +48,6 @@ import org.dspace.event.factory.EventServiceFactory;
|
||||
* significance varies by the combination of action and subject type.</li>
|
||||
* <li> - timestamp -- exact millisecond timestamp at which event was logged.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class Event implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -308,6 +306,7 @@ public class Event implements Serializable {
|
||||
* @param other the event to compare this one to
|
||||
* @return true if events are "equal", false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other instanceof Event) {
|
||||
Event otherEvent = (Event) other;
|
||||
@@ -315,14 +314,15 @@ public class Event implements Serializable {
|
||||
.equals(otherEvent.detail))
|
||||
&& this.eventType == otherEvent.eventType
|
||||
&& this.subjectType == otherEvent.subjectType
|
||||
&& this.subjectID == otherEvent.subjectID
|
||||
&& this.subjectID.equals(otherEvent.subjectID)
|
||||
&& this.objectType == otherEvent.objectType
|
||||
&& this.objectID == otherEvent.objectID;
|
||||
&& this.objectID.equals(otherEvent.objectID);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder().append(this.detail)
|
||||
.append(eventType)
|
||||
@@ -634,6 +634,7 @@ public class Event implements Serializable {
|
||||
* @return Detailed string representation of contents of this event, to
|
||||
* help in logging and debugging.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "org.dspace.event.Event(eventType="
|
||||
+ this.getEventTypeAsString()
|
||||
|
@@ -105,7 +105,7 @@ public class Handle implements ReloadableEntity<Integer> {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
if (!(o instanceof Handle)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -110,7 +110,7 @@ public abstract class InitialArticleWord implements TextFilter {
|
||||
return str.substring(cutPos);
|
||||
} else {
|
||||
// No - move the initial article word to the end
|
||||
return new StringBuffer(str.substring(cutPos))
|
||||
return new StringBuilder(str.substring(cutPos))
|
||||
.append(wordSeparator)
|
||||
.append(str.substring(initialStart, initialEnd))
|
||||
.toString();
|
||||
@@ -124,10 +124,12 @@ public abstract class InitialArticleWord implements TextFilter {
|
||||
}
|
||||
|
||||
protected InitialArticleWord(boolean stripWord) {
|
||||
this.wordSeparator = ", ";
|
||||
stripInitialArticle = stripWord;
|
||||
}
|
||||
|
||||
protected InitialArticleWord() {
|
||||
this.wordSeparator = ", ";
|
||||
stripInitialArticle = false;
|
||||
}
|
||||
|
||||
@@ -138,9 +140,8 @@ public abstract class InitialArticleWord implements TextFilter {
|
||||
* @return An array of definite/indefinite article words
|
||||
*/
|
||||
protected abstract String[] getArticleWords(String lang);
|
||||
|
||||
// Separator to use when appending article to end
|
||||
private String wordSeparator = ", ";
|
||||
private final String wordSeparator;
|
||||
|
||||
// Flag to signify initial article word should be removed
|
||||
// If false, then the initial article word is appended to the end
|
||||
|
@@ -59,6 +59,7 @@ public class InProgressUser implements ReloadableEntity<Integer> {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
|
@@ -26,17 +26,17 @@ public class MetadataFieldNameTest {
|
||||
@Test
|
||||
public void testConstruct3() {
|
||||
MetadataFieldName instance = new MetadataFieldName("one", "two", "three");
|
||||
assertEquals("Incorrect schema", "one", instance.SCHEMA);
|
||||
assertEquals("Incorrect element", "two", instance.ELEMENT);
|
||||
assertEquals("Incorrect qualifier", "three", instance.QUALIFIER);
|
||||
assertEquals("Incorrect schema", "one", instance.schema);
|
||||
assertEquals("Incorrect element", "two", instance.element);
|
||||
assertEquals("Incorrect qualifier", "three", instance.qualifier);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstruct2() {
|
||||
MetadataFieldName instance = new MetadataFieldName("one", "two");
|
||||
assertEquals("Incorrect schema", "one", instance.SCHEMA);
|
||||
assertEquals("Incorrect element", "two", instance.ELEMENT);
|
||||
assertNull("Incorrect qualifier", instance.QUALIFIER);
|
||||
assertEquals("Incorrect schema", "one", instance.schema);
|
||||
assertEquals("Incorrect element", "two", instance.element);
|
||||
assertNull("Incorrect qualifier", instance.qualifier);
|
||||
}
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
|
Reference in New Issue
Block a user