mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 22:43:12 +00:00
Fix dspace-api module per new code style
This commit is contained in:
@@ -7,6 +7,20 @@
|
||||
*/
|
||||
package org.dspace.eperson;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
@@ -19,15 +33,9 @@ import org.dspace.eperson.service.EPersonService;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.hibernate.proxy.HibernateProxyHelper;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Class representing an e-person.
|
||||
*
|
||||
*
|
||||
* @author David Stuve
|
||||
* @version $Revision$
|
||||
*/
|
||||
@@ -35,58 +43,67 @@ import java.util.List;
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy")
|
||||
@Table(name = "eperson")
|
||||
public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
{
|
||||
@Column(name="eperson_id", insertable = false, updatable = false)
|
||||
public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||
@Column(name = "eperson_id", insertable = false, updatable = false)
|
||||
private Integer legacyId;
|
||||
|
||||
@Column(name="netid", length = 64)
|
||||
@Column(name = "netid", length = 64)
|
||||
private String netid;
|
||||
|
||||
@Column(name="last_active")
|
||||
@Column(name = "last_active")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastActive;
|
||||
|
||||
@Column(name="can_log_in", nullable = true)
|
||||
@Column(name = "can_log_in", nullable = true)
|
||||
private Boolean canLogIn;
|
||||
|
||||
@Column(name="email", unique=true, length = 64)
|
||||
@Column(name = "email", unique = true, length = 64)
|
||||
private String email;
|
||||
|
||||
@Column(name="require_certificate")
|
||||
@Column(name = "require_certificate")
|
||||
private boolean requireCertificate = false;
|
||||
|
||||
@Column(name="self_registered")
|
||||
@Column(name = "self_registered")
|
||||
private boolean selfRegistered = false;
|
||||
|
||||
@Column(name="password", length = 128)
|
||||
@Column(name = "password", length = 128)
|
||||
private String password;
|
||||
|
||||
@Column(name="salt", length = 32)
|
||||
@Column(name = "salt", length = 32)
|
||||
private String salt;
|
||||
|
||||
@Column(name="session_salt", length = 32)
|
||||
@Column(name = "session_salt", length = 32)
|
||||
private String sessionSalt;
|
||||
|
||||
@Column(name="digest_algorithm", length = 16)
|
||||
@Column(name = "digest_algorithm", length = 16)
|
||||
private String digestAlgorithm;
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "epeople")
|
||||
private final List<Group> groups = new ArrayList<>();
|
||||
|
||||
/** The e-mail field (for sorting) */
|
||||
/**
|
||||
* The e-mail field (for sorting)
|
||||
*/
|
||||
public static final int EMAIL = 1;
|
||||
|
||||
/** The last name (for sorting) */
|
||||
/**
|
||||
* The last name (for sorting)
|
||||
*/
|
||||
public static final int LASTNAME = 2;
|
||||
|
||||
/** The e-mail field (for sorting) */
|
||||
/**
|
||||
* The e-mail field (for sorting)
|
||||
*/
|
||||
public static final int ID = 3;
|
||||
|
||||
/** The netid field (for sorting) */
|
||||
/**
|
||||
* The netid field (for sorting)
|
||||
*/
|
||||
public static final int NETID = 4;
|
||||
|
||||
/** The e-mail field (for sorting) */
|
||||
/**
|
||||
* The e-mail field (for sorting)
|
||||
*/
|
||||
public static final int LANGUAGE = 5;
|
||||
|
||||
@Transient
|
||||
@@ -98,10 +115,8 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
/**
|
||||
* Protected constructor, create object using:
|
||||
* {@link org.dspace.eperson.service.EPersonService#create(Context)}
|
||||
*
|
||||
*/
|
||||
protected EPerson()
|
||||
{
|
||||
protected EPerson() {
|
||||
|
||||
}
|
||||
|
||||
@@ -112,33 +127,27 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
|
||||
/**
|
||||
* Return true if this object equals obj, false otherwise.
|
||||
*
|
||||
*
|
||||
* @param obj another EPerson.
|
||||
* @return true if EPerson objects are equal in ID, email, and full name
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj);
|
||||
if (getClass() != objClass)
|
||||
{
|
||||
if (getClass() != objClass) {
|
||||
return false;
|
||||
}
|
||||
final EPerson other = (EPerson) obj;
|
||||
if (this.getID() != other.getID())
|
||||
{
|
||||
if (this.getID() != other.getID()) {
|
||||
return false;
|
||||
}
|
||||
if (!StringUtils.equals(this.getEmail(), other.getEmail()))
|
||||
{
|
||||
if (!StringUtils.equals(this.getEmail(), other.getEmail())) {
|
||||
return false;
|
||||
}
|
||||
if (!StringUtils.equals(this.getFullName(), other.getFullName()))
|
||||
{
|
||||
if (!StringUtils.equals(this.getFullName(), other.getFullName())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -150,78 +159,68 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
* @return int hash of object
|
||||
*/
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 89 * hash + this.getID().hashCode();
|
||||
hash = 89 * hash + (this.getEmail() != null? this.getEmail().hashCode():0);
|
||||
hash = 89 * hash + (this.getFullName() != null? this.getFullName().hashCode():0);
|
||||
hash = 89 * hash + (this.getEmail() != null ? this.getEmail().hashCode() : 0);
|
||||
hash = 89 * hash + (this.getFullName() != null ? this.getFullName().hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the e-person's language
|
||||
*
|
||||
*
|
||||
* @return language code (or null if the column is an SQL NULL)
|
||||
*/
|
||||
public String getLanguage()
|
||||
{
|
||||
return getePersonService().getMetadataFirstValue(this, "eperson", "language", null, Item.ANY);
|
||||
}
|
||||
|
||||
/**
|
||||
public String getLanguage() {
|
||||
return getePersonService().getMetadataFirstValue(this, "eperson", "language", null, Item.ANY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the EPerson's language. Value is expected to be a Unix/POSIX
|
||||
* Locale specification of the form {language} or {language}_{territory},
|
||||
* e.g. "en", "en_US", "pt_BR" (the latter is Brazilian Portugese).
|
||||
*
|
||||
* @param context
|
||||
* The relevant DSpace Context.
|
||||
* @param language
|
||||
* language code
|
||||
* @throws SQLException
|
||||
* An exception that provides information on a database access error or other errors.
|
||||
*
|
||||
* @param context The relevant DSpace Context.
|
||||
* @param language language code
|
||||
* @throws SQLException An exception that provides information on a database access error or other errors.
|
||||
*/
|
||||
public void setLanguage(Context context, String language) throws SQLException {
|
||||
getePersonService().setMetadataSingleValue(context, this, "eperson", "language", null, null, language);
|
||||
}
|
||||
public void setLanguage(Context context, String language) throws SQLException {
|
||||
getePersonService().setMetadataSingleValue(context, this, "eperson", "language", null, null, language);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the e-person's email address
|
||||
*
|
||||
*
|
||||
* @return their email address (or null if the column is an SQL NULL)
|
||||
*/
|
||||
public String getEmail()
|
||||
{
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the EPerson's email
|
||||
*
|
||||
* @param s
|
||||
* the new email
|
||||
*
|
||||
* @param s the new email
|
||||
*/
|
||||
public void setEmail(String s)
|
||||
{
|
||||
public void setEmail(String s) {
|
||||
this.email = StringUtils.lowerCase(s);
|
||||
setModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the e-person's netid
|
||||
*
|
||||
*
|
||||
* @return their netid (DB constraints ensure it's never NULL)
|
||||
*/
|
||||
public String getNetid()
|
||||
{
|
||||
public String getNetid() {
|
||||
return netid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the EPerson's netid
|
||||
*
|
||||
* @param netid
|
||||
* the new netid
|
||||
*
|
||||
* @param netid the new netid
|
||||
*/
|
||||
public void setNetid(String netid) {
|
||||
this.netid = netid;
|
||||
@@ -231,47 +230,37 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
/**
|
||||
* Get the e-person's full name, combining first and last name in a
|
||||
* displayable string.
|
||||
*
|
||||
*
|
||||
* @return their full name (first + last name; if both are NULL, returns email)
|
||||
*/
|
||||
public String getFullName()
|
||||
{
|
||||
public String getFullName() {
|
||||
String f = getFirstName();
|
||||
String l= getLastName();
|
||||
String l = getLastName();
|
||||
|
||||
if ((l == null) && (f == null))
|
||||
{
|
||||
if ((l == null) && (f == null)) {
|
||||
return getEmail();
|
||||
}
|
||||
else if (f == null)
|
||||
{
|
||||
} else if (f == null) {
|
||||
return l;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return (f + " " + l);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the eperson's first name.
|
||||
*
|
||||
*
|
||||
* @return their first name (or null if the column is an SQL NULL)
|
||||
*/
|
||||
public String getFirstName()
|
||||
{
|
||||
public String getFirstName() {
|
||||
return getePersonService().getMetadataFirstValue(this, "eperson", "firstname", null, Item.ANY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the eperson's first name
|
||||
*
|
||||
* @param context
|
||||
* The relevant DSpace Context.
|
||||
* @param firstname
|
||||
* the person's first name
|
||||
* @throws SQLException
|
||||
* An exception that provides information on a database access error or other errors.
|
||||
*
|
||||
* @param context The relevant DSpace Context.
|
||||
* @param firstname the person's first name
|
||||
* @throws SQLException An exception that provides information on a database access error or other errors.
|
||||
*/
|
||||
public void setFirstName(Context context, String firstname) throws SQLException {
|
||||
getePersonService().setMetadataSingleValue(context, this, "eperson", "firstname", null, null, firstname);
|
||||
@@ -280,23 +269,19 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
|
||||
/**
|
||||
* Get the eperson's last name.
|
||||
*
|
||||
*
|
||||
* @return their last name (or null if the column is an SQL NULL)
|
||||
*/
|
||||
public String getLastName()
|
||||
{
|
||||
public String getLastName() {
|
||||
return getePersonService().getMetadataFirstValue(this, "eperson", "lastname", null, Item.ANY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the eperson's last name
|
||||
*
|
||||
* @param context
|
||||
* The relevant DSpace Context.
|
||||
* @param lastname
|
||||
* the person's last name
|
||||
* @throws SQLException
|
||||
* An exception that provides information on a database access error or other errors.
|
||||
*
|
||||
* @param context The relevant DSpace Context.
|
||||
* @param lastname the person's last name
|
||||
* @throws SQLException An exception that provides information on a database access error or other errors.
|
||||
*/
|
||||
public void setLastName(Context context, String lastname) throws SQLException {
|
||||
getePersonService().setMetadataSingleValue(context, this, "eperson", "lastname", null, null, lastname);
|
||||
@@ -305,88 +290,77 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
|
||||
/**
|
||||
* Indicate whether the user can log in
|
||||
*
|
||||
* @param login
|
||||
* boolean yes/no
|
||||
*
|
||||
* @param login boolean yes/no
|
||||
*/
|
||||
public void setCanLogIn(boolean login)
|
||||
{
|
||||
public void setCanLogIn(boolean login) {
|
||||
this.canLogIn = login;
|
||||
setModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the user log in?
|
||||
*
|
||||
*
|
||||
* @return boolean, yes/no
|
||||
*/
|
||||
public boolean canLogIn()
|
||||
{
|
||||
public boolean canLogIn() {
|
||||
return BooleanUtils.isTrue(canLogIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set require cert yes/no
|
||||
*
|
||||
* @param isrequired
|
||||
* boolean yes/no
|
||||
*
|
||||
* @param isrequired boolean yes/no
|
||||
*/
|
||||
public void setRequireCertificate(boolean isrequired)
|
||||
{
|
||||
public void setRequireCertificate(boolean isrequired) {
|
||||
this.requireCertificate = isrequired;
|
||||
setModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get require certificate or not
|
||||
*
|
||||
*
|
||||
* @return boolean, yes/no (or false if the column is an SQL NULL)
|
||||
*/
|
||||
public boolean getRequireCertificate()
|
||||
{
|
||||
public boolean getRequireCertificate() {
|
||||
return requireCertificate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate whether the user self-registered
|
||||
*
|
||||
* @param sr
|
||||
* boolean yes/no
|
||||
*
|
||||
* @param sr boolean yes/no
|
||||
*/
|
||||
public void setSelfRegistered(boolean sr)
|
||||
{
|
||||
public void setSelfRegistered(boolean sr) {
|
||||
this.selfRegistered = sr;
|
||||
setModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the user self-registered?
|
||||
*
|
||||
*
|
||||
* @return boolean, yes/no (or false if the column is an SQL NULL)
|
||||
*/
|
||||
public boolean getSelfRegistered()
|
||||
{
|
||||
public boolean getSelfRegistered() {
|
||||
return selfRegistered;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stamp the EPerson's last-active date.
|
||||
*
|
||||
*
|
||||
* @param when latest activity timestamp, or null to clear.
|
||||
*/
|
||||
public void setLastActive(Date when)
|
||||
{
|
||||
public void setLastActive(Date when) {
|
||||
this.previousActive = lastActive;
|
||||
this.lastActive = when;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the EPerson's last-active stamp.
|
||||
*
|
||||
*
|
||||
* @return date when last logged on, or null.
|
||||
*/
|
||||
public Date getLastActive()
|
||||
{
|
||||
public Date getLastActive() {
|
||||
return lastActive;
|
||||
}
|
||||
|
||||
@@ -394,14 +368,12 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
* @return type found in Constants, see {@link org.dspace.core.Constants#Constants Constants}
|
||||
*/
|
||||
@Override
|
||||
public int getType()
|
||||
{
|
||||
public int getType() {
|
||||
return Constants.EPERSON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
public String getName() {
|
||||
return getEmail();
|
||||
}
|
||||
|
||||
@@ -434,8 +406,7 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
}
|
||||
|
||||
private EPersonService getePersonService() {
|
||||
if(ePersonService == null)
|
||||
{
|
||||
if (ePersonService == null) {
|
||||
ePersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
||||
}
|
||||
return ePersonService;
|
||||
|
Reference in New Issue
Block a user