/** * Delete token. * * @param context DSpace context * @param token The token to delete * @throws SQLException If a database error occurs */ @Override public void deleteToken(Context context, String token) throws SQLException { registrationDataService.deleteByToken(context, token); }
/** * Attempt to find an EPerson based on string ID * * @param context DSpace context * @param strID string identifier * @return EPerson object (if found) * @throws SQLException if database error */ protected EPerson getEPersonFromString(Context context, String strID) throws SQLException { EPerson eperson; try { UUID ePersonId = UUID.fromString(strID); eperson = ePersonService.find(context, ePersonId); } catch (Exception e) { eperson = ePersonService.findByLegacyId(context, Integer.parseInt(strID)); } return eperson; }
/** * 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); }
/** * <p> * Return the EPerson corresponding to token, where token was emailed to the * person by either the sendRegistrationInfo or sendForgotPasswordInfo * methods. * </p> * * <p> * If the token is not found return null. * </p> * * @param context DSpace context * @param token Account token * @return The EPerson corresponding to token, or null. * @throws SQLException If the token or eperson cannot be retrieved from the * database. */ @Override public EPerson getEPerson(Context context, String token) throws SQLException, AuthorizeException { String email = getEmail(context, token); if (email == null) { return null; } return ePersonService.findByEmail(context, email); }
private UUID mapOwner(String owntype, int val) throws SQLException { if (owntype.equals("e")) { EPerson per = epersonService.findByLegacyId(context, val); return per == null ? null : per.getID(); } else if (owntype.equals("g")) { Group perg = groupService.findByLegacyId(context, val); return perg == null ? null : perg.getID(); } return null; }
public static Group getRoleGroup(Context context, Collection collection, Role role) throws SQLException { if (role.getScope() == Role.Scope.REPOSITORY) { return groupService.findByName(context, role.getName()); } else if (role.getScope() == Role.Scope.COLLECTION) { CollectionRole collectionRole = collectionRoleService.find(context, collection, role.getId()); if (collectionRole == null) { return null; } return collectionRole.getGroup(); } else if (role.getScope() == Role.Scope.ITEM) { } return null; }
/** * 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. */ public void setLanguage(Context context, String language) throws SQLException { getePersonService().setMetadataSingleValue(context, this, "eperson", "language", null, null, language); }
@Override public List<PoolTask> findByEperson(Context context, EPerson ePerson) throws SQLException, AuthorizeException, IOException { List<PoolTask> result = poolTaskDAO.findByEPerson(context, ePerson); //Get all PoolTasks for groups of which this eperson is a member List<Group> groups = groupService.allMemberGroups(context, ePerson); result.addAll(findByGroups(context, ePerson, groups)); return result; }
@Override public boolean isAdmin(Context c, EPerson e) throws SQLException { // if we're ignoring authorization, user is member of admin if (c.ignoreAuthorization()) { return true; } if (e == null) { return false; // anonymous users can't be admins.... } else { return groupService.isMember(c, e, Group.ADMIN); } }
/** * Find all EPeople associated with this DSpace Object. * <P> * If object is SITE, all people are returned. * <P> * For all other objects, null is returned. * * @param context The DSpace context * @param object the DSpace object * @return array of all associated EPerson objects * @throws SQLException if database error */ protected List<EPerson> findAssociatedPeople(Context context, DSpaceObject object) throws SQLException { if (object.getType() == Constants.SITE) { return ePersonService.findAll(context, EPerson.EMAIL); } //by default, return nothing return null; }
/** * Return the e-mail address referred to by a token, or null if email * address can't be found ignores expiration of token * * @param context DSpace context * @param token Account token * @return The email address corresponding to token, or null. */ @Override public String getEmail(Context context, String token) throws SQLException { RegistrationData registrationData = registrationDataService.findByToken(context, token); if (registrationData == null) { return null; } /* * ignore the expiration date on tokens Date expires = * rd.getDateColumn("expires"); if (expires != null) { if ((new * java.util.Date()).after(expires)) return null; } */ return registrationData.getEmail(); }
public ArrayList<EPerson> getAllUniqueMembers(Context context) throws SQLException { HashMap<UUID, EPerson> epersonsMap = new HashMap(); for (EPerson eperson : epersons) { epersonsMap.put(eperson.getID(), eperson); } for (Group group : groups) { for (EPerson eperson : groupService.allMembers(context, group)) { epersonsMap.put(eperson.getID(), eperson); } } return new ArrayList<>(epersonsMap.values()); } }
/** * Get an array of all of the special groups that current user is a member * of. * * @return list of groups * @throws SQLException if database error */ public List<Group> getSpecialGroups() throws SQLException { List<Group> myGroups = new ArrayList<Group>(); for (UUID groupId : specialGroups) { myGroups.add(EPersonServiceFactory.getInstance().getGroupService().find(this, groupId)); } return myGroups; }
/** * Get the eperson's last name. * * @return their last name (or null if the column is an SQL NULL) */ 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. */ public void setLastName(Context context, String lastname) throws SQLException { getePersonService().setMetadataSingleValue(context, this, "eperson", "lastname", null, null, lastname); setModified(); }
public boolean isCommunityAdmin(Context c) throws SQLException { EPerson e = c.getCurrentUser(); if (e != null) { List<ResourcePolicy> policies = resourcePolicyService.find(c, e, groupService.allMemberGroups(c, e), Constants.ADMIN, Constants.COMMUNITY); if (CollectionUtils.isNotEmpty(policies)) { return true; } } return false; }
@Override public boolean isAdmin(Context c) throws SQLException { // if we're ignoring authorization, user is member of admin if (c.ignoreAuthorization()) { return true; } EPerson e = c.getCurrentUser(); if (e == null) { return false; // anonymous users can't be admins.... } else { return groupService.isMember(c, Group.ADMIN); } }
/** * Get the eperson's first name. * * @return their first name (or null if the column is an SQL NULL) */ 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. */ public void setFirstName(Context context, String firstname) throws SQLException { getePersonService().setMetadataSingleValue(context, this, "eperson", "firstname", null, null, firstname); setModified(); }
public boolean isCollectionAdmin(Context c) throws SQLException { EPerson e = c.getCurrentUser(); if (e != null) { List<ResourcePolicy> policies = resourcePolicyService.find(c, e, groupService.allMemberGroups(c, e), Constants.ADMIN, Constants.COLLECTION); if (CollectionUtils.isNotEmpty(policies)) { return true; } } return false; }