Package org.dspace.eperson

Examples of org.dspace.eperson.Group


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

        try {
            Group group = Group.find(context, Integer.parseInt(ref.getId()));
            if (group != null) {
                if (EPerson.findByEmail(context, email) == 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();

                        group.addMember(ePerson);
                        group.update();
                    } else {
                        throw new EntityException("Internal server error", "Could not create ePerson", 500);
                    }
                } else {
                    throw new EntityException("Data error", "Duplicated ePerson", 500);
View Full Code Here


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

        String id = (String) inputVar.get("id");

        try {
            Group group = Group.find(context, Integer.parseInt(ref.getId()));
            AuthorizeManager.authorizeAction(context, group, Constants.WRITE);
            if (group != null) {
                Group eGroup = Group.find(context, Integer.parseInt(id));
                if (eGroup != null) {
                    group.addMember(eGroup);
                    group.update();
                } else {
                    throw new IllegalArgumentException("Invalid id:" + ref.getId());
View Full Code Here

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

        String id = (String) inputVar.get("id");

        try {
            Group group = Group.find(context, Integer.parseInt(ref.getId()));
            AuthorizeManager.authorizeAction(context, group, Constants.WRITE);
            if (group != null) {
                EPerson ePerson = EPerson.find(context, Integer.parseInt(id));
                if (ePerson != null) {
                    group.addMember(ePerson);
                    group.update();
                } else {
                    throw new IllegalArgumentException("Invalid id:" + ref.getId());
                }
            } else {
                throw new IllegalArgumentException("Invalid id:" + ref.getId());
View Full Code Here

        }
    }

    public void removeGroup(EntityReference ref, Map<String, Object> inputVar, Context context) {
        try {
            Group group = Group.find(context, Integer.parseInt(ref.getId()));
            AuthorizeManager.authorizeAction(context, group, Constants.WRITE);
            if ((group != null)) {
                int eid = Integer.parseInt((String) inputVar.get("eid"));
                Group eGroup = Group.find(context, eid);
                if (eGroup != null) {
                    group.removeMember(eGroup);
                    group.update();
                }
            }
View Full Code Here

        }
    }

    public void removeUser(EntityReference ref, Map<String, Object> inputVar, Context context) {
        try {
            Group group = Group.find(context, Integer.parseInt(ref.getId()));
            AuthorizeManager.authorizeAction(context, group, Constants.WRITE);
            if ((group != null)) {
                int eid = Integer.parseInt((String) inputVar.get("eid"));
                EPerson ePerson = EPerson.find(context, eid);
                if (ePerson != null) {
                    group.removeMember(ePerson);
                    group.update();
                }
            }
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        } catch (AuthorizeException ae) {
View Full Code Here

            if (collection != null) {
                int act = Utils.getActionRole((String) inputVar.get("action"));
                switch (act) {
                    case 1: {
                        Group group = collection.createAdministrators();
                        collection.update();
                        return String.valueOf(group.getID());
                    }
                    case 2: {
                        Group group = collection.createSubmitters();
                        collection.update();
                        return String.valueOf(group.getID());
                    }
                    case 4:
                    case 5:
                    case 6: {
                        Group group = collection.createWorkflowGroup(act - 3);
                        collection.update();
                        return String.valueOf(group.getID());
                    }
                    default:
                        return null;
                }
            } else {
View Full Code Here

            if (collection != null) {
                int act = Utils.getActionRole((String) inputVar.get("eid"));
                switch (act) {
                    case 1: {
                        Group group = collection.getAdministrators();
                        if (group != null) {
                            collection.removeAdministrators();
                            collection.update();
                            group.delete();
                        }
                        break;
                    }
                    case 2: {
                        Group group = collection.getSubmitters();
                        if (group != null) {
                            collection.removeSubmitters();
                            collection.update();
                            group.delete();
                        }
                        break;
                    }
                    case 4:
                    case 5:
                    case 6: {
                        Group group = collection.getWorkflowGroup(act - 3);
                        if (group != null) {
                            AuthorizeUtil.authorizeManageWorkflowsGroup(context, collection);
                            collection.setWorkflowGroup(act - 3,null);
                            collection.update();
                            group.delete();
                        }
                        break;
                    }
                }
            } else {
View Full Code Here

    public Object getRoles(EntityReference ref, UserRequestParams uparams, Context context) {

        try {
            Collection res = Collection.find(context, Integer.parseInt(ref.getId()));
            AuthorizeManager.authorizeAction(context, res, Constants.READ);
            Group role;
            int act = Utils.getActionRole(uparams.getAction());
            switch (act) {
                case 1: {
                    role = res.getAdministrators();
                    break;
View Full Code Here

                        user = EPerson.find(context, Integer.parseInt(userId));
                        policy.setEPerson(user);
                    } catch (NumberFormatException ex) {
                    }
                }
                Group group;
                if (!"".equals(groupId)) {
                    try {
                        group = Group.find(context, Integer.parseInt(groupId));
                        policy.setGroup(group);
                    } catch (NumberFormatException ex) {
View Full Code Here

        try {
            Community com = Community.find(context, Integer.parseInt(ref.getId()));
            if (com != null) {
                com.createAdministrators();
                com.update();
                Group group = com.getAdministrators();
                return String.valueOf(group.getID());
            } else {
                throw new EntityException("Not found", "Entity not found", 404);
            }
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
View Full Code Here

TOP

Related Classes of org.dspace.eperson.Group

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.