First batch of errorprone fixes. #3061

This commit is contained in:
Mark H. Wood
2020-11-24 10:55:08 -05:00
parent 96742fe558
commit 65f04fcec9
29 changed files with 134 additions and 161 deletions

View File

@@ -169,6 +169,7 @@ public class ResourcePolicy implements ReloadableEntity<Integer> {
* *
* @return the internal identifier * @return the internal identifier
*/ */
@Override
public Integer getID() { public Integer getID() {
return id; return id;
} }

View File

@@ -21,7 +21,6 @@ import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
import org.apache.log4j.Logger;
import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.BitstreamService; import org.dspace.content.service.BitstreamService;
import org.dspace.core.Constants; 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. * the contents of a bitstream; you need to create a new bitstream.
* *
* @author Robert Tansley * @author Robert Tansley
* @version $Revision$
*/ */
@Entity @Entity
@Table(name = "bitstream") @Table(name = "bitstream")
public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport { 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) @Column(name = "bitstream_id", insertable = false, updatable = false)
private Integer legacyId; private Integer legacyId;
@@ -411,7 +403,7 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
*/ */
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other == null) { if (!(other instanceof Bitstream)) {
return false; return false;
} }
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(other); Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(other);
@@ -419,11 +411,7 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
return false; return false;
} }
final Bitstream otherBitstream = (Bitstream) other; final Bitstream otherBitstream = (Bitstream) other;
if (!this.getID().equals(otherBitstream.getID())) { return this.getID().equals(otherBitstream.getID());
return false;
}
return true;
} }
@Override @Override

View File

@@ -40,7 +40,6 @@ import org.hibernate.proxy.HibernateProxyHelper;
* when <code>update</code> is called. * when <code>update</code> is called.
* *
* @author Robert Tansley * @author Robert Tansley
* @version $Revision$
*/ */
@Entity @Entity
@Table(name = "bitstreamformatregistry") @Table(name = "bitstreamformatregistry")
@@ -120,6 +119,7 @@ public class BitstreamFormat implements Serializable, ReloadableEntity<Integer>
* *
* @return the internal identifier * @return the internal identifier
*/ */
@Override
public final Integer getID() { public final Integer getID() {
return id; return id;
} }
@@ -267,7 +267,7 @@ public class BitstreamFormat implements Serializable, ReloadableEntity<Integer>
*/ */
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other == null) { if (!(other instanceof BitstreamFormat)) {
return false; return false;
} }
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(other); Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(other);
@@ -275,11 +275,7 @@ public class BitstreamFormat implements Serializable, ReloadableEntity<Integer>
return false; return false;
} }
final BitstreamFormat otherBitstreamFormat = (BitstreamFormat) other; final BitstreamFormat otherBitstreamFormat = (BitstreamFormat) other;
if (!this.getID().equals(otherBitstreamFormat.getID())) { return this.getID().equals(otherBitstreamFormat.getID());
return false;
}
return true;
} }
@Override @Override

View File

@@ -310,7 +310,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
* whitespace. * whitespace.
*/ */
if (value == null) { 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(); collection.setMetadataModified();
} else { } else {
super.setMetadataSingleValue(context, collection, field, null, value); super.setMetadataSingleValue(context, collection, field, null, value);

View File

@@ -24,7 +24,6 @@ import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.logging.log4j.Logger;
import org.dspace.content.comparator.NameAscendingComparator; import org.dspace.content.comparator.NameAscendingComparator;
import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.CommunityService; import org.dspace.content.service.CommunityService;
@@ -42,18 +41,12 @@ import org.hibernate.proxy.HibernateProxyHelper;
* <code>update</code> is called. * <code>update</code> is called.
* *
* @author Robert Tansley * @author Robert Tansley
* @version $Revision$
*/ */
@Entity @Entity
@Table(name = "community") @Table(name = "community")
@Cacheable @Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy") @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy")
public class Community extends DSpaceObject implements DSpaceObjectLegacySupport { 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) @Column(name = "community_id", insertable = false, updatable = false)
private Integer legacyId; private Integer legacyId;
@@ -215,7 +208,7 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
*/ */
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other == null) { if (!(other instanceof Community)) {
return false; return false;
} }
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(other); Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(other);
@@ -223,11 +216,7 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
return false; return false;
} }
final Community otherCommunity = (Community) other; final Community otherCommunity = (Community) other;
if (!this.getID().equals(otherCommunity.getID())) { return this.getID().equals(otherCommunity.getID());
return false;
}
return true;
} }
@Override @Override

View File

@@ -192,7 +192,7 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
* whitespace. * whitespace.
*/ */
if (value == null) { 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(); community.setMetadataModified();
} else { } else {
super.setMetadataSingleValue(context, community, field, null, value); super.setMetadataSingleValue(context, community, field, null, value);

View File

@@ -39,7 +39,6 @@ import org.apache.logging.log4j.Logger;
* *
* @author Robert Tansley * @author Robert Tansley
* @author Larry Stone * @author Larry Stone
* @version $Revision$
*/ */
public class DCDate { public class DCDate {
/** /**
@@ -370,6 +369,7 @@ public class DCDate {
* *
* @return The date as a string. * @return The date as a string.
*/ */
@Override
public String toString() { public String toString() {
if (calendar == null) { if (calendar == null) {
return "null"; return "null";

View File

@@ -61,7 +61,7 @@ public abstract class DSpaceObject implements Serializable, ReloadableEntity<jav
private List<Handle> handles = new ArrayList<>(); private List<Handle> handles = new ArrayList<>();
@OneToMany(fetch = FetchType.LAZY, mappedBy = "dSpaceObject", cascade = CascadeType.ALL) @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() * 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 * @return internal ID of object
*/ */
@Override
public UUID getID() { public UUID getID() {
return id; return id;
} }

View File

@@ -420,7 +420,7 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
@Override @Override
public String getMetadataFirstValue(T dso, MetadataFieldName field, String language) { public String getMetadataFirstValue(T dso, MetadataFieldName field, String language) {
List<MetadataValue> metadataValues 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)) { if (CollectionUtils.isNotEmpty(metadataValues)) {
return metadataValues.get(0).getValue(); return metadataValues.get(0).getValue();
} }
@@ -447,11 +447,11 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
String language, String value) String language, String value)
throws SQLException { throws SQLException {
if (value != null) { if (value != null) {
clearMetadata(context, dso, field.SCHEMA, field.ELEMENT, field.QUALIFIER, clearMetadata(context, dso, field.schema, field.element, field.qualifier,
language); language);
String newValueLanguage = (Item.ANY.equals(language)) ? null : 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); newValueLanguage, value);
dso.setMetadataModified(); dso.setMetadataModified();
} }

View File

@@ -17,7 +17,6 @@ import org.dspace.eperson.EPerson;
* which stage of submission they are (in workspace or workflow system) * which stage of submission they are (in workspace or workflow system)
* *
* @author Robert Tansley * @author Robert Tansley
* @version $Revision$
*/ */
public interface InProgressSubmission extends ReloadableEntity<Integer> { public interface InProgressSubmission extends ReloadableEntity<Integer> {
/** /**
@@ -25,6 +24,7 @@ public interface InProgressSubmission extends ReloadableEntity<Integer> {
* *
* @return the internal identifier * @return the internal identifier
*/ */
@Override
Integer getID(); Integer getID();
/** /**

View File

@@ -27,7 +27,6 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import javax.persistence.Transient; import javax.persistence.Transient;
import org.apache.log4j.Logger;
import org.dspace.content.comparator.NameAscendingComparator; import org.dspace.content.comparator.NameAscendingComparator;
import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.ItemService; import org.dspace.content.service.ItemService;
@@ -48,17 +47,10 @@ import org.hibernate.proxy.HibernateProxyHelper;
* *
* @author Robert Tansley * @author Robert Tansley
* @author Martin Hald * @author Martin Hald
* @version $Revision$
*/ */
@Entity @Entity
@Table(name = "item") @Table(name = "item")
public class Item extends DSpaceObject implements DSpaceObjectLegacySupport { 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 * 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 * @return the bundles in an unordered array
*/ */
public List<Bundle> getBundles(String name) { public List<Bundle> getBundles(String name) {
List<Bundle> matchingBundles = new ArrayList<Bundle>(); List<Bundle> matchingBundles = new ArrayList<>();
// now only keep bundles with matching names // now only keep bundles with matching names
List<Bundle> bunds = getBundles(); List<Bundle> bunds = getBundles();
for (Bundle bundle : bunds) { 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 * 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 * @param obj object to compare to
* @return <code>true</code> if object passed in represents the same item * @return <code>true</code> if object passed in represents the same item
@@ -325,7 +317,7 @@ public class Item extends DSpaceObject implements DSpaceObjectLegacySupport {
*/ */
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) { if (!(obj instanceof Item)) {
return false; return false;
} }
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj); Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj);
@@ -333,10 +325,7 @@ public class Item extends DSpaceObject implements DSpaceObjectLegacySupport {
return false; return false;
} }
final Item otherItem = (Item) obj; final Item otherItem = (Item) obj;
if (!this.getID().equals(otherItem.getID())) { return this.getID().equals(otherItem.getID());
return false;
}
return true;
} }
@Override @Override

View File

@@ -32,7 +32,6 @@ import org.hibernate.proxy.HibernateProxyHelper;
* metadata element belongs in a field. * metadata element belongs in a field.
* *
* @author Martin Hald * @author Martin Hald
* @version $Revision$
* @see org.dspace.content.MetadataValue * @see org.dspace.content.MetadataValue
* @see org.dspace.content.MetadataSchema * @see org.dspace.content.MetadataSchema
*/ */
@@ -77,6 +76,7 @@ public class MetadataField implements ReloadableEntity<Integer> {
* *
* @return metadata field id * @return metadata field id
*/ */
@Override
public Integer getID() { public Integer getID() {
return id; return id;
} }
@@ -164,7 +164,7 @@ public class MetadataField implements ReloadableEntity<Integer> {
*/ */
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) { if (!(obj instanceof MetadataField)) {
return false; return false;
} }
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj); Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj);
@@ -175,10 +175,7 @@ public class MetadataField implements ReloadableEntity<Integer> {
if (!this.getID().equals(other.getID())) { if (!this.getID().equals(other.getID())) {
return false; return false;
} }
if (!getMetadataSchema().equals(other.getMetadataSchema())) { return getMetadataSchema().equals(other.getMetadataSchema());
return false;
}
return true;
} }
@Override @Override

View File

@@ -17,13 +17,13 @@ import javax.annotation.Nonnull;
*/ */
public class MetadataFieldName { public class MetadataFieldName {
/** Name of the metadata schema which defines this field. Never null. */ /** 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. */ /** Element name of this field. Never null. */
public final String ELEMENT; public final String element;
/** Qualifier name of this field. May be {@code null}. */ /** 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. * 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."); throw new NullPointerException("Element must not be null.");
} }
SCHEMA = schema; this.schema = schema;
ELEMENT = element; this.element = element;
QUALIFIER = qualifier; this.qualifier = qualifier;
} }
/** /**
@@ -59,9 +59,9 @@ public class MetadataFieldName {
throw new NullPointerException("Element must not be null."); throw new NullPointerException("Element must not be null.");
} }
SCHEMA = schema; this.schema = schema;
ELEMENT = element; this.element = element;
QUALIFIER = null; qualifier = null;
} }
/** /**
@@ -79,9 +79,9 @@ public class MetadataFieldName {
throw new IllegalArgumentException("Element must not be null."); throw new IllegalArgumentException("Element must not be null.");
} }
SCHEMA = schema.getName(); this.schema = schema.getName();
ELEMENT = element; this.element = element;
QUALIFIER = qualifier; this.qualifier = qualifier;
} }
/** /**
@@ -98,9 +98,9 @@ public class MetadataFieldName {
throw new IllegalArgumentException("Element must not be null."); throw new IllegalArgumentException("Element must not be null.");
} }
SCHEMA = schema.getName(); this.schema = schema.getName();
ELEMENT = element; this.element = element;
QUALIFIER = null; qualifier = null;
} }
/** /**
@@ -110,9 +110,9 @@ public class MetadataFieldName {
*/ */
public MetadataFieldName(@Nonnull String name) { public MetadataFieldName(@Nonnull String name) {
String[] elements = parse(name); String[] elements = parse(name);
SCHEMA = elements[0]; schema = elements[0];
ELEMENT = elements[1]; element = elements[1];
QUALIFIER = elements[2]; qualifier = elements[2];
} }
/** /**
@@ -138,17 +138,17 @@ public class MetadataFieldName {
/** /**
* Format a dotted-atoms representation of this field name. * Format a dotted-atoms representation of this field name.
* @return SCHEMA.ELEMENT.QUALIFIER * @return schema.element.qualifier
*/ */
@Override @Override
public String toString() { public String toString() {
StringBuilder buffer = new StringBuilder(32); StringBuilder buffer = new StringBuilder(32);
buffer.append(SCHEMA) buffer.append(schema)
.append('.') .append('.')
.append(ELEMENT); .append(element);
if (null != QUALIFIER) { if (null != qualifier) {
buffer.append('.') buffer.append('.')
.append(QUALIFIER); .append(qualifier);
} }
return buffer.toString(); return buffer.toString();
} }

View File

@@ -30,7 +30,6 @@ import org.hibernate.proxy.HibernateProxyHelper;
* </p> * </p>
* *
* @author Martin Hald * @author Martin Hald
* @version $Revision$
* @see org.dspace.content.MetadataValue * @see org.dspace.content.MetadataValue
* @see org.dspace.content.MetadataField * @see org.dspace.content.MetadataField
*/ */
@@ -129,6 +128,7 @@ public class MetadataSchema implements ReloadableEntity<Integer> {
* *
* @return schema record key * @return schema record key
*/ */
@Override
public Integer getID() { public Integer getID() {
return id; return id;
} }

View File

@@ -46,7 +46,7 @@ public class MetadataValue implements ReloadableEntity<Integer> {
@Column(name = "metadata_value_id") @Column(name = "metadata_value_id")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "metadatavalue_seq") @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "metadatavalue_seq")
@SequenceGenerator(name = "metadatavalue_seq", sequenceName = "metadatavalue_seq", allocationSize = 1) @SequenceGenerator(name = "metadatavalue_seq", sequenceName = "metadatavalue_seq", allocationSize = 1)
private Integer id; private final Integer id;
/** /**
* The primary key for the metadata value * The primary key for the metadata value
@@ -104,6 +104,7 @@ public class MetadataValue implements ReloadableEntity<Integer> {
* *
* @return metadata value ID * @return metadata value ID
*/ */
@Override
public Integer getID() { public Integer getID() {
return id; return id;
} }
@@ -249,10 +250,7 @@ public class MetadataValue implements ReloadableEntity<Integer> {
if (!this.getID().equals(other.getID())) { if (!this.getID().equals(other.getID())) {
return false; return false;
} }
if (!this.getDSpaceObject().getID().equals(other.getDSpaceObject().getID())) { return this.getDSpaceObject().getID().equals(other.getDSpaceObject().getID());
return false;
}
return true;
} }
@Override @Override

View File

@@ -33,6 +33,7 @@ import org.dspace.core.Context;
*/ */
public interface BitstreamService extends DSpaceObjectService<Bitstream>, DSpaceObjectLegacySupportService<Bitstream> { public interface BitstreamService extends DSpaceObjectService<Bitstream>, DSpaceObjectLegacySupportService<Bitstream> {
@Override
public Bitstream find(Context context, UUID id) throws SQLException; public Bitstream find(Context context, UUID id) throws SQLException;
public List<Bitstream> findAll(Context context) throws SQLException; public List<Bitstream> findAll(Context context) throws SQLException;

View File

@@ -46,8 +46,6 @@ import org.springframework.util.CollectionUtils;
* changes and free up the resources. * changes and free up the resources.
* <P> * <P>
* The context object is also used as a cache for CM API objects. * The context object is also used as a cache for CM API objects.
*
* @version $Revision$
*/ */
public class Context implements AutoCloseable { public class Context implements AutoCloseable {
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(Context.class); private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(Context.class);

View File

@@ -217,12 +217,11 @@ public class I18nUtil {
*/ */
public static String getInputFormsFileName(Locale locale) { public static String getInputFormsFileName(Locale locale) {
/** Name of the form definition XML file */ /** Name of the form definition XML file */
String fileName = "";
final String FORM_DEF_FILE = "submission-forms"; final String FORM_DEF_FILE = "submission-forms";
final String FILE_TYPE = ".xml"; final String FILE_TYPE = ".xml";
String defsFilename = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir") String defsFilename = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir")
+ File.separator + "config" + File.separator + FORM_DEF_FILE; + File.separator + "config" + File.separator + FORM_DEF_FILE;
fileName = getFilename(locale, defsFilename, FILE_TYPE); String fileName = getFilename(locale, defsFilename, FILE_TYPE);
return fileName; return fileName;
} }
@@ -286,14 +285,13 @@ public class I18nUtil {
*/ */
public static String getDefaultLicense(Context context) { public static String getDefaultLicense(Context context) {
Locale locale = context.getCurrentLocale(); Locale locale = context.getCurrentLocale();
String fileName = "";
/** Name of the default license */ /** Name of the default license */
final String DEF_LIC_FILE = "default"; final String DEF_LIC_FILE = "default";
final String FILE_TYPE = ".license"; final String FILE_TYPE = ".license";
String defsFilename = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir") String defsFilename = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir")
+ File.separator + "config" + File.separator + DEF_LIC_FILE; + File.separator + "config" + File.separator + DEF_LIC_FILE;
fileName = getFilename(locale, defsFilename, FILE_TYPE); String fileName = getFilename(locale, defsFilename, FILE_TYPE);
return fileName; return fileName;
} }
@@ -316,8 +314,7 @@ public class I18nUtil {
// with Language, Country // with Language, Country
String fileNameLC = null; String fileNameLC = null;
// with Language // with Language
String fileNameL = null; String fileNameL = fileName + "_" + locale.getLanguage();
fileNameL = fileName + "_" + locale.getLanguage();
if (fileType == null) { if (fileType == null) {
fileType = ""; fileType = "";
@@ -372,12 +369,11 @@ public class I18nUtil {
* String - localized filename of an email template * String - localized filename of an email template
*/ */
public static String getEmailFilename(Locale locale, String name) { public static String getEmailFilename(Locale locale, String name) {
String templateName = "";
String templateFile = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir") String templateFile = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir")
+ File.separator + "config" + File.separator + "emails" + File.separator + "config" + File.separator + "emails"
+ File.separator + name; + File.separator + name;
templateName = getFilename(locale, templateFile, ""); String templateName = getFilename(locale, templateFile, "");
return templateName; return templateName;
} }
@@ -389,7 +385,7 @@ public class I18nUtil {
* @return array of locale results, possibly empty * @return array of locale results, possibly empty
*/ */
public static Locale[] parseLocales(String[] locales) { public static Locale[] parseLocales(String[] locales) {
List<Locale> resultList = new ArrayList<Locale>(); List<Locale> resultList = new ArrayList<>();
for (String ls : locales) { for (String ls : locales) {
Locale lc = makeLocale(ls); Locale lc = makeLocale(ls);
if (lc != null) { if (lc != null) {

View File

@@ -33,8 +33,10 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import com.coverity.security.Escape; import com.coverity.security.Escape;
import java.nio.charset.StandardCharsets;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringSubstitutor; import org.apache.commons.text.StringSubstitutor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.dspace.services.ConfigurationService; import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory; import org.dspace.services.factory.DSpaceServicesFactory;
@@ -43,13 +45,12 @@ import org.dspace.services.factory.DSpaceServicesFactory;
* Utility functions for DSpace. * Utility functions for DSpace.
* *
* @author Peter Breton * @author Peter Breton
* @version $Revision$
*/ */
public final class Utils { public final class Utils {
/** /**
* log4j logger * 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 private static final Pattern DURATION_PATTERN = Pattern
.compile("(\\d+)([smhdwy])"); .compile("(\\d+)([smhdwy])");
@@ -68,12 +69,12 @@ public final class Utils {
private static int counter = 0; 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 // for parseISO8601Date
private static SimpleDateFormat parseFmt[] = { private static final SimpleDateFormat parseFmt[] = {
// first try at parsing, has milliseconds (note General time zone) // first try at parsing, has milliseconds (note General time zone)
new SimpleDateFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ss.SSSz"), new SimpleDateFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ss.SSSz"),
@@ -88,12 +89,14 @@ public final class Utils {
// for formatISO8601Date // for formatISO8601Date
// output canonical format (note RFC22 time zone, easier to hack) // 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 // 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 * Private constructor
@@ -107,7 +110,7 @@ public final class Utils {
* @return MD5 checksum for the data in hex format. * @return MD5 checksum for the data in hex format.
*/ */
public static String getMD5(String data) { 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; return null;
} }
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
// This is far from the most efficient way to do things... // This is far from the most efficient way to do things...
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
@@ -194,10 +197,14 @@ public final class Utils {
random.nextBytes(junk); random.nextBytes(junk);
String input = new StringBuffer().append(vmid).append( String input = new StringBuilder()
new java.util.Date()).append(Arrays.toString(junk)).append(counter++).toString(); .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. // The following two methods are taken from the Jakarta IOUtil class.

View File

@@ -13,7 +13,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.Logger;
import org.dspace.content.Collection; import org.dspace.content.Collection;
import org.dspace.content.Community; import org.dspace.content.Community;
import org.dspace.content.DSpaceObject; import org.dspace.content.DSpaceObject;
@@ -39,8 +38,6 @@ public abstract class AbstractCurationTask implements CurationTask {
protected Curator curator = null; protected Curator curator = null;
// curator-assigned taskId // curator-assigned taskId
protected String taskId = null; protected String taskId = null;
// logger
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(AbstractCurationTask.class);
protected CommunityService communityService; protected CommunityService communityService;
protected ItemService itemService; protected ItemService itemService;
protected HandleService handleService; protected HandleService handleService;

View File

@@ -19,7 +19,6 @@ import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.dspace.authorize.AuthorizeException; import org.dspace.authorize.AuthorizeException;
import org.dspace.content.Bitstream; import org.dspace.content.Bitstream;
import org.dspace.content.BitstreamFormat;
import org.dspace.content.Bundle; import org.dspace.content.Bundle;
import org.dspace.content.DSpaceObject; import org.dspace.content.DSpaceObject;
import org.dspace.content.Item; import org.dspace.content.Item;
@@ -46,7 +45,7 @@ public class CitationPage extends AbstractCurationTask {
/** /**
* Class Logger * 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 int status = Curator.CURATE_UNSET;
protected String result = null; protected String result = null;
@@ -97,7 +96,7 @@ public class CitationPage extends AbstractCurationTask {
//Determine if the DISPLAY bundle exits. If not, create it. //Determine if the DISPLAY bundle exits. If not, create it.
List<Bundle> dBundles = itemService.getBundles(item, CitationPage.DISPLAY_BUNDLE_NAME); List<Bundle> dBundles = itemService.getBundles(item, CitationPage.DISPLAY_BUNDLE_NAME);
Bundle dBundle = null; Bundle dBundle = null;
if (dBundles == null || dBundles.size() == 0) { if (dBundles == null || dBundles.isEmpty()) {
try { try {
dBundle = bundleService.create(Curator.curationContext(), item, CitationPage.DISPLAY_BUNDLE_NAME); dBundle = bundleService.create(Curator.curationContext(), item, CitationPage.DISPLAY_BUNDLE_NAME);
} catch (AuthorizeException e) { } 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 //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. //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()) { for (Bitstream bs : dBundle.getBitstreams()) {
displayMap.put(bs.getName(), bs); 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 // Loop through each file and generate a cover page for documents
// that are PDFs. // that are PDFs.
for (Bitstream bitstream : bitstreams) { for (Bitstream bitstream : bitstreams) {
BitstreamFormat format = bitstream.getFormat(Curator.curationContext());
//If bitstream is a PDF document then it is citable. //If bitstream is a PDF document then it is citable.
CitationDocumentService citationDocument = DisseminateServiceFactory.getInstance() CitationDocumentService citationDocument = DisseminateServiceFactory.getInstance()
.getCitationDocumentService(); .getCitationDocumentService();
if (citationDocument.canGenerateCitationVersion(Curator.curationContext(), bitstream)) { if (citationDocument.canGenerateCitationVersion(Curator.curationContext(), bitstream)) {
this.resBuilder.append(item.getHandle() + " - " this.resBuilder.append(item.getHandle())
+ bitstream.getName() + " is citable."); .append(" - ")
.append(bitstream.getName())
.append(" is citable.");
try { try {
//Create the cited document //Create the cited document
Pair<InputStream, Long> citedDocument = Pair<InputStream, Long> citedDocument =
@@ -168,7 +168,9 @@ public class CitationPage extends AbstractCurationTask {
StringBuilder stack = new StringBuilder(); StringBuilder stack = new StringBuilder();
int numLines = Math.min(stackTrace.length, 12); int numLines = Math.min(stackTrace.length, 12);
for (int j = 0; j < numLines; j++) { 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) { if (stackTrace.length > numLines) {
stack.append("\t. . .\n"); stack.append("\t. . .\n");
@@ -180,8 +182,10 @@ public class CitationPage extends AbstractCurationTask {
} }
} else { } else {
//bitstream is not a document //bitstream is not a document
this.resBuilder.append(item.getHandle() + " - " this.resBuilder.append(item.getHandle())
+ bitstream.getName() + " is not citable.\n"); .append(" - ")
.append(bitstream.getName())
.append(" is not citable.\n");
this.status = Curator.CURATE_SUCCESS; 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 //If we are modifying a file that is not in the
//preservation bundle then we have to move it there. //preservation bundle then we have to move it there.
Context context = Curator.curationContext(); Context context = Curator.curationContext();
if (bundle.getID() != pBundle.getID()) { if (!bundle.getID().equals(pBundle.getID())) {
bundleService.addBitstream(context, pBundle, bitstream); bundleService.addBitstream(context, pBundle, bitstream);
bundleService.removeBitstream(context, bundle, bitstream); bundleService.removeBitstream(context, bundle, bitstream);
List<Bitstream> bitstreams = bundle.getBitstreams(); List<Bitstream> bitstreams = bundle.getBitstreams();
if (bitstreams == null || bitstreams.size() == 0) { if (bitstreams == null || bitstreams.isEmpty()) {
itemService.removeBundle(context, item, bundle); itemService.removeBundle(context, item, bundle);
} }
} }
@@ -235,9 +239,11 @@ public class CitationPage extends AbstractCurationTask {
bitstreamService.setFormat(context, citedBitstream, bitstream.getFormat(Curator.curationContext())); bitstreamService.setFormat(context, citedBitstream, bitstream.getFormat(Curator.curationContext()));
citedBitstream.setDescription(context, bitstream.getDescription()); citedBitstream.setDescription(context, bitstream.getDescription());
this.resBuilder.append(" Added " this.resBuilder.append(" Added ")
+ citedBitstream.getName() .append(citedBitstream.getName())
+ " to the " + CitationPage.DISPLAY_BUNDLE_NAME + " bundle.\n"); .append(" to the ")
.append(CitationPage.DISPLAY_BUNDLE_NAME)
.append(" bundle.\n");
//Run update to propagate changes to the //Run update to propagate changes to the
//database. //database.

View File

@@ -15,11 +15,13 @@ import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
import java.io.Writer; import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.Properties; import java.util.Properties;
import javax.script.ScriptEngine; import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager; import javax.script.ScriptEngineManager;
import javax.script.ScriptException; import javax.script.ScriptException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.dspace.core.factory.CoreServiceFactory; import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.services.factory.DSpaceServicesFactory; import org.dspace.services.factory.DSpaceServicesFactory;
@@ -64,7 +66,7 @@ import org.dspace.services.factory.DSpaceServicesFactory;
public class TaskResolver { public class TaskResolver {
// logging service // 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 // base directory of task scripts & catalog name
protected static final String CATALOG = "task.catalog"; protected static final String CATALOG = "task.catalog";
@@ -94,7 +96,7 @@ public class TaskResolver {
if (script.exists()) { if (script.exists()) {
BufferedReader reader = null; BufferedReader reader = null;
try { try {
reader = new BufferedReader(new FileReader(script)); reader = new BufferedReader(new FileReader(script, StandardCharsets.UTF_8));
String line = null; String line = null;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
if (line.startsWith("#") && line.indexOf("$td=") > 0) { if (line.startsWith("#") && line.indexOf("$td=") > 0) {
@@ -136,7 +138,7 @@ public class TaskResolver {
catalog.put(taskName, descriptor); catalog.put(taskName, descriptor);
Writer writer = null; Writer writer = null;
try { try {
writer = new FileWriter(new File(scriptDir, CATALOG)); writer = new FileWriter(new File(scriptDir, CATALOG), StandardCharsets.UTF_8);
catalog.store(writer, "do not edit"); catalog.store(writer, "do not edit");
} catch (IOException ioE) { } catch (IOException ioE) {
log.error("Error saving scripted task catalog: " + CATALOG); log.error("Error saving scripted task catalog: " + CATALOG);
@@ -179,7 +181,7 @@ public class TaskResolver {
File script = new File(scriptDir, tokens[1]); File script = new File(scriptDir, tokens[1]);
if (script.exists()) { if (script.exists()) {
try { try {
Reader reader = new FileReader(script); Reader reader = new FileReader(script, StandardCharsets.UTF_8);
engine.eval(reader); engine.eval(reader);
reader.close(); reader.close();
// third token is the constructor expression for the class // third token is the constructor expression for the class
@@ -212,7 +214,7 @@ public class TaskResolver {
File catalogFile = new File(scriptDir, CATALOG); File catalogFile = new File(scriptDir, CATALOG);
if (catalogFile.exists()) { if (catalogFile.exists()) {
try { try {
Reader reader = new FileReader(catalogFile); Reader reader = new FileReader(catalogFile, StandardCharsets.UTF_8);
catalog.load(reader); catalog.load(reader);
reader.close(); reader.close();
} catch (IOException ioE) { } catch (IOException ioE) {

View File

@@ -16,9 +16,9 @@ import java.io.Reader;
import java.io.SequenceInputStream; import java.io.SequenceInputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -55,7 +55,7 @@ public class FullTextContentStreams extends ContentStreamBase {
} }
protected void init(Item parentItem) { protected void init(Item parentItem) {
fullTextStreams = new LinkedList<>(); fullTextStreams = new ArrayList<>();
if (parentItem != null) { if (parentItem != null) {
sourceInfo = parentItem.getHandle(); sourceInfo = parentItem.getHandle();
@@ -149,8 +149,8 @@ public class FullTextContentStreams extends ContentStreamBase {
} }
private class FullTextBitstream { private class FullTextBitstream {
private String itemHandle; private final String itemHandle;
private Bitstream bitstream; private final Bitstream bitstream;
public FullTextBitstream(final String parentHandle, final Bitstream file) { public FullTextBitstream(final String parentHandle, final Bitstream file) {
this.itemHandle = parentHandle; 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; private final Iterator<FullTextBitstream> fulltextIterator;
public FullTextEnumeration(final Iterator<FullTextBitstream> fulltextStreams) { public FullTextEnumeration(final Iterator<FullTextBitstream> fulltextIterator) {
this.fulltextIterator = fulltextStreams; this.fulltextIterator = fulltextIterator;
} }
@Override
public boolean hasMoreElements() { public boolean hasMoreElements() {
return fulltextIterator.hasNext(); return fulltextIterator.hasNext();
} }
@Override
public InputStream nextElement() { public InputStream nextElement() {
InputStream inputStream = null; InputStream inputStream = null;
FullTextBitstream bitstream = null; FullTextBitstream bitstream = null;

View File

@@ -104,7 +104,9 @@ public class ConsumerProfile {
"No filters configured for consumer named: " + name); "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> : ... // Each "filter" is <objectTypes> + <eventTypes> : ...
filters = new ArrayList<>(); filters = new ArrayList<>();

View File

@@ -48,8 +48,6 @@ import org.dspace.event.factory.EventServiceFactory;
* significance varies by the combination of action and subject type.</li> * significance varies by the combination of action and subject type.</li>
* <li> - timestamp -- exact millisecond timestamp at which event was logged.</li> * <li> - timestamp -- exact millisecond timestamp at which event was logged.</li>
* </ul> * </ul>
*
* @version $Revision$
*/ */
public class Event implements Serializable { public class Event implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -308,6 +306,7 @@ public class Event implements Serializable {
* @param other the event to compare this one to * @param other the event to compare this one to
* @return true if events are "equal", false otherwise. * @return true if events are "equal", false otherwise.
*/ */
@Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other instanceof Event) { if (other instanceof Event) {
Event otherEvent = (Event) other; Event otherEvent = (Event) other;
@@ -315,14 +314,15 @@ public class Event implements Serializable {
.equals(otherEvent.detail)) .equals(otherEvent.detail))
&& this.eventType == otherEvent.eventType && this.eventType == otherEvent.eventType
&& this.subjectType == otherEvent.subjectType && this.subjectType == otherEvent.subjectType
&& this.subjectID == otherEvent.subjectID && this.subjectID.equals(otherEvent.subjectID)
&& this.objectType == otherEvent.objectType && this.objectType == otherEvent.objectType
&& this.objectID == otherEvent.objectID; && this.objectID.equals(otherEvent.objectID);
} }
return false; return false;
} }
@Override
public int hashCode() { public int hashCode() {
return new HashCodeBuilder().append(this.detail) return new HashCodeBuilder().append(this.detail)
.append(eventType) .append(eventType)
@@ -634,6 +634,7 @@ public class Event implements Serializable {
* @return Detailed string representation of contents of this event, to * @return Detailed string representation of contents of this event, to
* help in logging and debugging. * help in logging and debugging.
*/ */
@Override
public String toString() { public String toString() {
return "org.dspace.event.Event(eventType=" return "org.dspace.event.Event(eventType="
+ this.getEventTypeAsString() + this.getEventTypeAsString()

View File

@@ -105,7 +105,7 @@ public class Handle implements ReloadableEntity<Integer> {
return true; return true;
} }
if (o == null || getClass() != o.getClass()) { if (!(o instanceof Handle)) {
return false; return false;
} }

View File

@@ -110,7 +110,7 @@ public abstract class InitialArticleWord implements TextFilter {
return str.substring(cutPos); return str.substring(cutPos);
} else { } else {
// No - move the initial article word to the end // No - move the initial article word to the end
return new StringBuffer(str.substring(cutPos)) return new StringBuilder(str.substring(cutPos))
.append(wordSeparator) .append(wordSeparator)
.append(str.substring(initialStart, initialEnd)) .append(str.substring(initialStart, initialEnd))
.toString(); .toString();
@@ -124,10 +124,12 @@ public abstract class InitialArticleWord implements TextFilter {
} }
protected InitialArticleWord(boolean stripWord) { protected InitialArticleWord(boolean stripWord) {
this.wordSeparator = ", ";
stripInitialArticle = stripWord; stripInitialArticle = stripWord;
} }
protected InitialArticleWord() { protected InitialArticleWord() {
this.wordSeparator = ", ";
stripInitialArticle = false; stripInitialArticle = false;
} }
@@ -138,9 +140,8 @@ public abstract class InitialArticleWord implements TextFilter {
* @return An array of definite/indefinite article words * @return An array of definite/indefinite article words
*/ */
protected abstract String[] getArticleWords(String lang); protected abstract String[] getArticleWords(String lang);
// Separator to use when appending article to end // Separator to use when appending article to end
private String wordSeparator = ", "; private final String wordSeparator;
// Flag to signify initial article word should be removed // Flag to signify initial article word should be removed
// If false, then the initial article word is appended to the end // If false, then the initial article word is appended to the end

View File

@@ -59,6 +59,7 @@ public class InProgressUser implements ReloadableEntity<Integer> {
} }
@Override
public Integer getID() { public Integer getID() {
return id; return id;
} }

View File

@@ -26,17 +26,17 @@ public class MetadataFieldNameTest {
@Test @Test
public void testConstruct3() { public void testConstruct3() {
MetadataFieldName instance = new MetadataFieldName("one", "two", "three"); MetadataFieldName instance = new MetadataFieldName("one", "two", "three");
assertEquals("Incorrect schema", "one", instance.SCHEMA); assertEquals("Incorrect schema", "one", instance.schema);
assertEquals("Incorrect element", "two", instance.ELEMENT); assertEquals("Incorrect element", "two", instance.element);
assertEquals("Incorrect qualifier", "three", instance.QUALIFIER); assertEquals("Incorrect qualifier", "three", instance.qualifier);
} }
@Test @Test
public void testConstruct2() { public void testConstruct2() {
MetadataFieldName instance = new MetadataFieldName("one", "two"); MetadataFieldName instance = new MetadataFieldName("one", "two");
assertEquals("Incorrect schema", "one", instance.SCHEMA); assertEquals("Incorrect schema", "one", instance.schema);
assertEquals("Incorrect element", "two", instance.ELEMENT); assertEquals("Incorrect element", "two", instance.element);
assertNull("Incorrect qualifier", instance.QUALIFIER); assertNull("Incorrect qualifier", instance.qualifier);
} }
@Test(expected = NullPointerException.class) @Test(expected = NullPointerException.class)