Package org.dspace.content

Examples of org.dspace.content.Collection


        try {
            while (tri.hasNext()) {
                TableRow row = tri.next();

                // First check the cache
                Collection fromCache = (Collection) context.fromCache(Collection.class, row.getIntColumn("collection_id"));

                if (fromCache != null) {
                    collections.add(fromCache);
                } else {
                    collections.add(Collection.find(context, row.getIntColumn("collection_id")));
View Full Code Here


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

        try {
            if (communityId > 0) {
                Community community = Community.find(context, communityId);
                Collection collection = community.createCollection();
                if (collection != null) {
                    collection.setMetadata("name", name);
                    collection.setMetadata("short_description", shortDescription);
                    collection.setMetadata("introductory_text", introductoryText);
                    collection.setMetadata("copyright_text", copyrightText);
                    collection.setMetadata("side_bar_text", sidebarText);
                    collection.setMetadata("provenance_description", provenance);
                    collection.setLicense(licence);
                    collection.update();
                    return String.valueOf(collection.getID());
                } else {
                    throw new EntityException("Internal server error", "Could not create collection", 500);
                }
            } else {
                throw new EntityException("Internal server error", "Could not create collection", 500);
View Full Code Here

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

        try {
            Integer id = Integer.parseInt(ref.getId());
            Collection collection = Collection.find(context, id);

            String name = Utils.getMapValue(inputVar, "name");
            String shortDescription = Utils.getMapValue(inputVar, "shortDescription");
            String copyrightText = Utils.getMapValue(inputVar, "copyrightText");
            String sidebarText = Utils.getMapValue(inputVar, "sidebarText");
            String introductoryText = Utils.getMapValue(inputVar, "introductoryText");
            String licence = Utils.getMapValue(inputVar, "licence");
            String provenance = Utils.getMapValue(inputVar, "provenance");

            if (collection != null) {
                if (name != null) collection.setMetadata("name", name);
                if (shortDescription != null) collection.setMetadata("short_description", shortDescription);
                if (copyrightText != null) collection.setMetadata("copyright_text", copyrightText);
                if (sidebarText != null) collection.setMetadata("side_bar_text", sidebarText);
                if (introductoryText != null) collection.setMetadata("introductory_text", introductoryText);
                if (provenance != null) collection.setMetadata("provenance_description", provenance);
                if (licence != null) collection.setLicense(licence);
                collection.update();
            } else {
                throw new EntityException("Internal server error", "Could not update collection", 500);
            }
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
View Full Code Here

        }
    }

    public void removeCollection(EntityReference ref, Map<String, Object> inputVar, Context context) {
        try {
            Collection collection = Collection.find(context, Integer.parseInt(ref.getId()));
            if ((collection != null)) {
                Community[] communities = collection.getCommunities();
                for (Community community : communities) {
                    community.removeCollection(collection);
                }
            }
        } catch (SQLException ex) {
View Full Code Here

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

        try {
            Integer id = Integer.parseInt(ref.getId());
            Collection collection = Collection.find(context, id);

            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;
                }
View Full Code Here

    }

    public void removeRoles(EntityReference ref, Map<String, Object> inputVar, Context context) {
        try {
            Integer id = Integer.parseInt(ref.getId());
            Collection collection = Collection.find(context, id);

            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 {
                throw new EntityException("Not found", "Entity not found", 404);
            }
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        } catch (AuthorizeException ae) {
            throw new EntityException("Forbidden", "Forbidden", 403);
        } catch (NumberFormatException ex) {
            throw new EntityException("Bad request", "Could not parse input", 400);
        }

        try {
            Integer elid = Integer.parseInt((String) inputVar.get("id"));
            Collection col = Collection.find(context, elid);
            if ((col != null)) {
                col.removeAdministrators();
            }
        } 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

    }

    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;
                }
                case 2: {
                    role = res.getSubmitters();
                    break;
                }
                case 4:
                case 5:
                case 6: {
                    role = res.getWorkflowGroup(act - 3);
                    break;
                }
                default: {
                    List<GroupEntityTrim> groups = new ArrayList<GroupEntityTrim>();
                    role = res.getAdministrators();
                    if (role != null) {
                        groups.add(new GroupEntityTrim(role));
                    }
                    role = res.getSubmitters();
                    if (role != null) {
                        groups.add(new GroupEntityTrim(role));
                    }
                    role = res.getWorkflowGroup(1);
                    if (role != null) {
                        groups.add(new GroupEntityTrim(role));
                    }
                    role = res.getWorkflowGroup(2);
                    if (role != null) {
                        groups.add(new GroupEntityTrim(role));
                    }
                    role = res.getWorkflowGroup(3);
                    if (role != null) {
                        groups.add(new GroupEntityTrim(role));
                    }
                    return groups;
                }
View Full Code Here

    }

    public String createLogo(EntityReference ref, Object inputVar, Context context) {

        try {
            Collection col = Collection.find(context, Integer.parseInt(ref.getId()));
            if (col != null) {
                Bitstream bitstream = col.setLogo((InputStream) inputVar);
                col.update();
                return String.valueOf(bitstream.getID());
            } else {
                throw new EntityException("Not found", "Entity not found", 404);
            }
        } catch (SQLException ex) {
View Full Code Here

        }
    }

    public void removeLogo(EntityReference ref, Map<String, Object> inputVar, Context context) {
        try {
            Collection col = Collection.find(context, Integer.parseInt(ref.getId()));
            if ((col != null)) {
                col.setLogo(null);
                col.update();
            }
        } 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

        }
    }

    public Object getLogo(EntityReference ref, UserRequestParams uparams, Context context) {
        try {
            Collection res = Collection.find(context, Integer.parseInt(ref.getId()));
            AuthorizeManager.authorizeAction(context, res, Constants.READ);
            Bitstream logo = res.getLogo();

            if (logo != null) {
                return new BitstreamEntityId(logo);
            }
        } catch (SQLException ex) {
View Full Code Here

TOP

Related Classes of org.dspace.content.Collection

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.