Package org.dspace.eperson

Examples of org.dspace.eperson.EPerson


            ex.printStackTrace();
        } // now try to login user
        loggedUser = "anonymous";

        try {
            EPerson eUser = EPerson.findByEmail(context, user);
            if ((eUser.canLogIn()) && (eUser.checkPassword(pass))) {
                context.setCurrentUser(eUser);
                loggedUser = eUser.getName();
            } else {
                throw new EntityException("Bad username or password", user, 403);
            }
        } catch (SQLException sql) {
//            System.out.println(sql.toString());
View Full Code Here


        try {
            context = new Context();
            refreshParams(context);

            int uid;
            EPerson ePerson;

            try {
                uid = Integer.parseInt(id);
                ePerson = EPerson.find(context, uid);
            } catch (NumberFormatException ex) {
View Full Code Here

            if (col != null && actionId != -1) {
                ResourcePolicy policy = ResourcePolicy.create(context);
                policy.setResource(col);
                policy.setAction(actionId);
                EPerson user;
                if (!"".equals(userId)) {
                    try {
                        user = EPerson.find(context, Integer.parseInt(userId));
                        policy.setEPerson(user);
                    } catch (NumberFormatException ex) {
View Full Code Here

    public List<Object> groups(EntityReference ref, UserRequestParams uparams, Context context) {

        try {
            Integer id = Integer.parseInt(ref.getId());
            EPerson ePerson = EPerson.find(context, id);

            Group[] gs = Group.allMemberGroups(context, ePerson);
            for (Group g : gs) {
                this.groups.add(new GroupEntityTrim(g));
            }
View Full Code Here

        boolean requireCertificate = "true".equals(inputVar.get("requireCertificate"));
        boolean selfRegistered = "true".equals(inputVar.get("selfRegistered"));

        try {
            if (EPerson.findByEmail(context, email) == null && EPerson.findByNetid(context, netId) == null) {
                EPerson ePerson = EPerson.create(context);
                if (ePerson != null) {
                    result = String.valueOf(ePerson.getID());
                    ePerson.setEmail(email);
                    ePerson.setFirstName(firstName);
                    ePerson.setLastName(lastName);
                    if (password != null && !"".equals(password)) ePerson.setPassword(password);
                    ePerson.setMetadata("phone", phone);
                    ePerson.setNetid(netId);
                    ePerson.setLanguage(language);
                    ePerson.setCanLogIn(canLogIn);
                    ePerson.setRequireCertificate(requireCertificate);
                    ePerson.setSelfRegistered(selfRegistered);
                    ePerson.update();
                } else {
                    throw new EntityException("Internal server error", "Could not create ePerson", 500);
                }
            } else {
                throw new EntityException("Internal server error", "Duplicated ePerson", 500);
View Full Code Here

    public void edit(EntityReference ref, Map<String, Object> inputVar, Context context) {

        try {
            int uid;
            EPerson ePerson;

            try {
                uid = Integer.parseInt(ref.getId());
                ePerson = EPerson.find(context, uid);
            } catch (NumberFormatException ex) {
                ePerson = EPerson.findByEmail(context, ref.getId());
            }

            String email = Utils.getMapValue(inputVar, "email");
            String password = Utils.getMapValue(inputVar, "password");
            String firstName = Utils.getMapValue(inputVar, "firstName");
            String lastName = Utils.getMapValue(inputVar, "lastName");
            String phone = Utils.getMapValue(inputVar, "phone");
            String netId = Utils.getMapValue(inputVar, "netId");
            String language = Utils.getMapValue(inputVar, "language");
            String canLogIn = Utils.getMapValue(inputVar, "canLogIn");
            String requireCertificate = Utils.getMapValue(inputVar, "requireCertificate");
            String selfRegistered = Utils.getMapValue(inputVar, "selfRegistered");

            if (ePerson != null) {
                EPerson ep = EPerson.findByEmail(context, email);
                if (ep == null || ePerson.getEmail().equalsIgnoreCase(ep.getEmail())) {
                    if (email != null) ePerson.setEmail(email);
                    if (firstName != null) ePerson.setFirstName(firstName);
                    if (lastName != null) ePerson.setLastName(lastName);
                    if (password != null && !"".equals(password)) ePerson.setPassword(password);
                    if (phone != null) ePerson.setMetadata("phone", phone);
View Full Code Here

        }
    }

    public void remove(EntityReference ref, Map<String, Object> inputVar, Context context) {
        try {
            EPerson ePerson = EPerson.find(context, Integer.parseInt(ref.getId()));
            if ((ePerson != null)) {
                ePerson.delete();
            }
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        } catch (AuthorizeException ae) {
            throw new EntityException("Forbidden", "Forbidden", 403);
View Full Code Here

            if (com != null && actionId != -1) {
                ResourcePolicy policy = ResourcePolicy.create(context);
                policy.setResource(com);
                policy.setAction(actionId);
                EPerson user;
                if (!"".equals(userId)) {
                    try {
                        user = EPerson.find(context, Integer.parseInt(userId));
                        policy.setEPerson(user);
                    } catch (NumberFormatException ex) {
View Full Code Here

    private static Item prepareItem(Context context, Collection col, Map metadataMap) throws AuthorizeException, SQLException, IOException {
        // Check the user has permission to ADD to the collection
        AuthorizeManager.authorizeAction(context, col, Constants.ADD);
        // Create an item
        Item item = Item.create(context);
        EPerson ePerson = context.getCurrentUser();
        item.setSubmitter(ePerson);
        item.setArchived(true);
        item.setOwningCollection(col);
        // read write add remove permission
        AuthorizeManager.addPolicy(context, item, Constants.READ, Group.find(context,0));
View Full Code Here

                    }

                    // process members, removing any that aren't in eperson_ids
                    for (int x = 0; x < members.length; x++)
                    {
                        EPerson e = members[x];

                        if (!epersonIDSet.contains(new Integer(e.getID())))
                        {
                            group.removeMember(e);
                        }
                    }
                }
View Full Code Here

TOP

Related Classes of org.dspace.eperson.EPerson

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.