📄 eperson.java
字号:
/** * Get the e-person's email address * * @return their email address */ public String getEmail() { return myRow.getStringColumn("email"); } /** * Set the EPerson's email * * @param s * the new email */ public void setEmail(String s) { if (s != null) { s = s.toLowerCase(); } myRow.setColumn("email", s); } /** * Get the e-person's netid * * @return their netid */ public String getNetid() { return myRow.getStringColumn("netid"); } /** * Set the EPerson's netid * * @param s * the new netid */ public void setNetid(String s) { if (s != null) { s = s.toLowerCase(); } myRow.setColumn("netid", s); } /** * Get the e-person's full name, combining first and last name in a * displayable string. * * @return their full name */ public String getFullName() { String f = myRow.getStringColumn("firstname"); String l = myRow.getStringColumn("lastname"); if ((l == null) && (f == null)) { return getEmail(); } else if (f == null) { return l; } else { return (f + " " + l); } } /** * Get the eperson's first name. * * @return their first name */ public String getFirstName() { return myRow.getStringColumn("firstname"); } /** * Set the eperson's first name * * @param firstname * the person's first name */ public void setFirstName(String firstname) { myRow.setColumn("firstname", firstname); } /** * Get the eperson's last name. * * @return their last name */ public String getLastName() { return myRow.getStringColumn("lastname"); } /** * Set the eperson's last name * * @param lastname * the person's last name */ public void setLastName(String lastname) { myRow.setColumn("lastname", lastname); } /** * Indicate whether the user can log in * * @param login * boolean yes/no */ public void setCanLogIn(boolean login) { myRow.setColumn("can_log_in", login); } /** * Can the user log in? * * @return boolean, yes/no */ public boolean canLogIn() { return myRow.getBooleanColumn("can_log_in"); } /** * Set require cert yes/no * * @param isrequired * boolean yes/no */ public void setRequireCertificate(boolean isrequired) { myRow.setColumn("require_certificate", isrequired); } /** * Get require certificate or not * * @return boolean, yes/no */ public boolean getRequireCertificate() { return myRow.getBooleanColumn("require_certificate"); } /** * Indicate whether the user self-registered * * @param sr * boolean yes/no */ public void setSelfRegistered(boolean sr) { myRow.setColumn("self_registered", sr); } /** * Can the user log in? * * @return boolean, yes/no */ public boolean getSelfRegistered() { return myRow.getBooleanColumn("self_registered"); } /** * Get the value of a metadata field * * @param field * the name of the metadata field to get * * @return the value of the metadata field * * @exception IllegalArgumentException * if the requested metadata field doesn't exist */ public String getMetadata(String field) { return myRow.getStringColumn(field); } /** * Set a metadata value * * @param field * the name of the metadata field to get * @param value * value to set the field to * * @exception IllegalArgumentException * if the requested metadata field doesn't exist */ public void setMetadata(String field, String value) { myRow.setColumn(field, value); } /** * Set the EPerson's password * * @param s * the new email */ public void setPassword(String s) { // FIXME: encoding String encoded = Utils.getMD5(s); myRow.setColumn("password", encoded); } /** * Check EPerson's password * * @param attempt * the password attempt * @return boolean successful/unsuccessful */ public boolean checkPassword(String attempt) { String encoded = Utils.getMD5(attempt); return (encoded.equals(myRow.getStringColumn("password"))); } /** * Update the EPerson */ public void update() throws SQLException, AuthorizeException { // Check authorisation - if you're not the eperson // see if the authorization system says you can if (!myContext.ignoreAuthorization() && ((myContext.getCurrentUser() == null) || (getID() != myContext .getCurrentUser().getID()))) { AuthorizeManager.authorizeAction(myContext, this, Constants.WRITE); } DatabaseManager.update(myContext, myRow); log.info(LogManager.getHeader(myContext, "update_eperson", "eperson_id=" + getID())); HistoryManager.saveHistory(myContext, this, HistoryManager.MODIFY, myContext.getCurrentUser(), myContext.getExtraLogInfo()); } /** * Return <code>true</code> if <code>other</code> is the same EPerson as * this object, <code>false</code> otherwise * * @param other * object to compare to * * @return <code>true</code> if object passed in represents the same * eperson as this object */ public boolean obsolete_equals(Object other) { if (!(other instanceof EPerson)) { return false; } return (getID() == ((EPerson) other).getID()); } /** * return type found in Constants */ public int getType() { return Constants.EPERSON; } /** * Check for presence of EPerson in tables that have constraints on * EPersons. Called by delete() to determine whether the eperson can * actually be deleted. * * An EPerson cannot be deleted if it exists in the item, workflowitem, or * tasklistitem tables. * * @return Vector of tables that contain a reference to the eperson. */ public Vector getDeleteConstraints() throws SQLException { Vector tableList = new Vector(); // check for eperson in item table TableRowIterator tri = DatabaseManager.query(myContext, "SELECT * from item where submitter_id=" + getID()); if (tri.hasNext()) { tableList.add("item"); } // check for eperson in workflowitem table tri = DatabaseManager.query(myContext, "SELECT * from workflowitem where owner=" + getID()); if (tri.hasNext()) { tableList.add("workflowitem"); } // check for eperson in tasklistitem table tri = DatabaseManager.query(myContext, "SELECT * from tasklistitem where eperson_id=" + getID()); if (tri.hasNext()) { tableList.add("tasklistitem"); } // the list of tables can be used to construct an error message // explaining to the user why the eperson cannot be deleted. return tableList; } /** * return an array of all of the groups that this EPerson is a member of * * @return Group [] * @throws SQLException */ public Group[] getGroupMemberships() throws SQLException { // special groups Group[] specialGroups = myContext.getSpecialGroups(); List groupList = new ArrayList(); for (int i = 0; i < specialGroups.length; i++) { groupList.add(specialGroups[i]); } // primary group IDs - returned as a set of Integers Group[] myGroups = Group.allMemberGroups(myContext, this); for (int i = 0; i < myGroups.length; i++) { groupList.add(myGroups[i]); } return (Group[]) groupList.toArray(new Group[0]); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -