Package org.dspace.content

Examples of org.dspace.content.Community


                        response);
            }
        }
        else if (dso.getType() == Constants.COMMUNITY)
        {
            Community c = (Community) dso;

            new DSpace().getEventService().fireEvent(
                new UsageEvent(
                    UsageEvent.Action.VIEW,
                    request,
View Full Code Here


            SQLException, AuthorizeException
    {
        // Wrap multipart request to get the submission info
        FileUploadRequest wrapper = new FileUploadRequest(request);

        Community community = Community.find(context, UIUtil.getIntParameter(
                wrapper, "community_id"));
        Collection collection = Collection.find(context, UIUtil
                .getIntParameter(wrapper, "collection_id"));

        File temp = wrapper.getFile("file");

        // Read the temp file as logo
        InputStream is = new BufferedInputStream(new FileInputStream(temp));
        Bitstream logoBS;

        if (collection == null)
        {
            logoBS = community.setLogo(is);
        }
        else
        {
            logoBS = collection.setLogo(is);
        }

        // Strip all but the last filename. It would be nice
        // to know which OS the file came from.
        String noPath = wrapper.getFilesystemName("file");

        while (noPath.indexOf('/') > -1)
        {
            noPath = noPath.substring(noPath.indexOf('/') + 1);
        }

        while (noPath.indexOf('\\') > -1)
        {
            noPath = noPath.substring(noPath.indexOf('\\') + 1);
        }

        logoBS.setName(noPath);
        logoBS.setSource(wrapper.getFilesystemName("file"));

        // Identify the format
        BitstreamFormat bf = FormatIdentifier.guessFormat(context, logoBS);
        logoBS.setFormat(bf);
        AuthorizeManager.addPolicy(context, logoBS, Constants.WRITE, context
                .getCurrentUser());
        logoBS.update();

        String jsp;
        DSpaceObject dso;
        if (collection == null)
        {
            community.update();

            // Show community edit page
            request.setAttribute("community", community);
            storeAuthorizeAttributeCommunityEdit(context, request, community);
            dso = community;
View Full Code Here

           
            Division results = search.addDivision("search-results","primary");
           
            if (searchScope instanceof Community)
            {
                Community community = (Community) searchScope;
                String communityName = community.getMetadata("name");
                results.setHead(T_head1_community.parameterize(communityName));
            }
            else if (searchScope instanceof Collection)
            {
                Collection collection = (Collection) searchScope;
View Full Code Here

        }
        else if (scopeDSO instanceof Community)
        {
            // The scope is a community, display all collections contained
            // within
            Community community = (Community) scopeDSO;
            scope.addOption("/",T_all_of_dspace);
            scope.addOption(community.getHandle(),community.getMetadata("name"));
            scope.setOptionSelected(community.getHandle());

            for (Collection collection : community.getCollections())
            {
                scope.addOption(collection.getHandle(),collection.getMetadata("name"));
            }
        }
        else if (scopeDSO instanceof Collection)
        {
            // The scope is a collection, display all parent collections.
            Collection collection = (Collection) scopeDSO;
            scope.addOption("/",T_all_of_dspace);
            scope.addOption(collection.getHandle(),collection.getMetadata("name"));
            scope.setOptionSelected(collection.getHandle());
           
            Community[] communities = collection.getCommunities()[0]
                    .getAllParents();
            for (Community community : communities)
            {
                scope.addOption(community.getHandle(),community.getMetadata("name"));
            }
        }
    }
View Full Code Here

    // get the things we need out of the service
    SWORDConfiguration swordConfig = swordService.getSwordConfig();
    SWORDUrlManager urlManager = swordService.getUrlManager();

    Community com = (Community) dso;
    Collection scol = new Collection();

    // prepare the parameters to be put in the sword collection
    String location = urlManager.getDepositLocation(com);
    scol.setLocation(location);

    // collection title is just the community name
    String title = com.getMetadata("name");
    if (title != null && !"".equals(title))
    {
      scol.setTitle(title);
    }

    // FIXME: the community has no obvious licence
    // the collection policy is the licence to which the collection adheres
    // String collectionPolicy = col.getLicense();

    // abstract is the short description of the collection
    String dcAbstract = com.getMetadata("short_description");
    if (dcAbstract != null && !"".equals(dcAbstract))
    {
      scol.setAbstract(dcAbstract);
    }
View Full Code Here

                    "/dspace-admin/authorize-policy-edit.jsp");
        }
        else if (button.equals("submit_community_select"))
        {
            // edit the collection's permissions
            Community target = Community.find(c, UIUtil.getIntParameter(
                    request, "community_id"));
            List policies = AuthorizeManager.getPolicies(c, target);

            request.setAttribute("community", target);
            request.setAttribute("policies", policies);
            JSPManager.showJSP(request, response,
                    "/dspace-admin/authorize-community-edit.jsp");
        }
        else if (button.equals("submit_collection_delete_policy"))
        {
            // delete a permission from a collection
            Collection collection = Collection.find(c, UIUtil.getIntParameter(
                    request, "collection_id"));
           
            AuthorizeUtil.authorizeManageCollectionPolicy(c, collection);
            ResourcePolicy policy = ResourcePolicy.find(c, UIUtil
                    .getIntParameter(request, "policy_id"));

            // do the remove
            policy.delete();

            // return to collection permission page
            request.setAttribute("collection", collection);

            List policies = AuthorizeManager.getPolicies(c, collection);
            request.setAttribute("policies", policies);

            JSPManager.showJSP(request, response,
                    "/dspace-admin/authorize-collection-edit.jsp");
        }
        else if (button.equals("submit_community_delete_policy"))
        {
            // delete a permission from a community
            Community community = Community.find(c, UIUtil.getIntParameter(
                    request, "community_id"));
           
            AuthorizeUtil.authorizeManageCommunityPolicy(c, community);
            ResourcePolicy policy = ResourcePolicy.find(c, UIUtil
                    .getIntParameter(request, "policy_id"));

            // do the remove
            policy.delete();

            // return to collection permission page
            request.setAttribute("community", community);

            List policies = AuthorizeManager.getPolicies(c, community);
            request.setAttribute("policies", policies);

            JSPManager.showJSP(request, response,
                    "/dspace-admin/authorize-community-edit.jsp");
        }
        else if (button.equals("submit_collection_edit_policy"))
        {
            // edit a collection's policy - set up and call policy editor
            Collection collection = Collection.find(c, UIUtil.getIntParameter(
                    request, "collection_id"));

            AuthorizeUtil.authorizeManageCollectionPolicy(c, collection);
            int policy_id = UIUtil.getIntParameter(request, "policy_id");
            ResourcePolicy policy = null;

            if (policy_id == -1)
            {
                // create new policy
                policy = ResourcePolicy.create(c);
                policy.setResource(collection);
                policy.update();
            }
            else
            {
                policy = ResourcePolicy.find(c, policy_id);
            }

            Group[] groups = Group.findAll(c, Group.NAME);
            EPerson[] epeople = EPerson.findAll(c, EPerson.EMAIL);

            // return to collection permission page
            request.setAttribute("edit_title", "Collection "
                    + collection.getID());
            request.setAttribute("policy", policy);
            request.setAttribute("groups", groups);
            request.setAttribute("epeople", epeople);
            request.setAttribute("id_name", "collection_id");
            request.setAttribute("id", "" + collection.getID());
            JSPManager.showJSP(request, response,
                    "/dspace-admin/authorize-policy-edit.jsp");
        }
        else if (button.equals("submit_community_edit_policy"))
        {
            // edit a community's policy - set up and call policy editor
            Community community = Community.find(c, UIUtil.getIntParameter(
                    request, "community_id"));
           
            AuthorizeUtil.authorizeManageCommunityPolicy(c, community);

            int policy_id = UIUtil.getIntParameter(request, "policy_id");
            ResourcePolicy policy = null;

            if (policy_id == -1)
            {
                // create new policy
                policy = ResourcePolicy.create(c);
                policy.setResource(community);
                policy.update();
            }
            else
            {
                policy = ResourcePolicy.find(c, policy_id);
            }

            Group[] groups = Group.findAll(c, Group.NAME);
            EPerson[] epeople = EPerson.findAll(c, EPerson.EMAIL);

            // return to collection permission page
            request
                    .setAttribute("edit_title", "Community "
                            + community.getID());
            request.setAttribute("policy", policy);
            request.setAttribute("groups", groups);
            request.setAttribute("epeople", epeople);
            request.setAttribute("id_name", "community_id");
            request.setAttribute("id", "" + community.getID());
            JSPManager.showJSP(request, response,
                    "/dspace-admin/authorize-policy-edit.jsp");
        }
        else if (button.equals("submit_collection_add_policy"))
        {
            // want to add a policy, create an empty one and invoke editor
            Collection collection = Collection.find(c, UIUtil.getIntParameter(
                    request, "collection_id"));

            AuthorizeUtil.authorizeManageCollectionPolicy(c, collection);
            ResourcePolicy policy = ResourcePolicy.create(c);
            policy.setResource(collection);
            policy.update();

            Group[] groups = Group.findAll(c, Group.NAME);
            EPerson[] epeople = EPerson.findAll(c, EPerson.EMAIL);

            // return to collection permission page
            request.setAttribute("edit_title", "Collection "
                    + collection.getID());
            request.setAttribute("policy", policy);
            request.setAttribute("groups", groups);
            request.setAttribute("epeople", epeople);
            request.setAttribute("id_name", "collection_id");
            request.setAttribute("id", "" + collection.getID());
            request.setAttribute("newpolicy", "true");

            JSPManager.showJSP(request, response,
                    "/dspace-admin/authorize-policy-edit.jsp");
        }
        else if (button.equals("submit_community_add_policy"))
        {
            // want to add a policy, create an empty one and invoke editor
            Community community = Community.find(c, UIUtil.getIntParameter(
                    request, "community_id"));

            AuthorizeUtil.authorizeManageCommunityPolicy(c, community);
            ResourcePolicy policy = ResourcePolicy.create(c);
            policy.setResource(community);
            policy.update();

            Group[] groups = Group.findAll(c, Group.NAME);
            EPerson[] epeople = EPerson.findAll(c, EPerson.EMAIL);

            // return to collection permission page
            request
                    .setAttribute("edit_title", "Community "
                            + community.getID());
            request.setAttribute("policy", policy);
            request.setAttribute("groups", groups);
            request.setAttribute("epeople", epeople);
            request.setAttribute("id_name", "community_id");
            request.setAttribute("id", "" + community.getID());
            request.setAttribute("newpolicy", "true");

            JSPManager.showJSP(request, response,
                    "/dspace-admin/authorize-policy-edit.jsp");
        }
        else if (button.equals("submit_save_policy"))
        {
            int policy_id = UIUtil.getIntParameter(request, "policy_id");
            int action_id = UIUtil.getIntParameter(request, "action_id");
            int group_id = UIUtil.getIntParameter(request, "group_id");
            int collection_id = UIUtil
                    .getIntParameter(request, "collection_id");
            int community_id = UIUtil.getIntParameter(request, "community_id");
            int item_id = UIUtil.getIntParameter(request, "item_id");

            Item item = null;
            Collection collection = null;
            Community community = null;
            String display_page = null;

            ResourcePolicy policy = ResourcePolicy.find(c, policy_id);
            AuthorizeUtil.authorizeManagePolicy(c, policy);
            Group group = Group.find(c, group_id);

            if (collection_id != -1)
            {
                collection = Collection.find(c, collection_id);

                // modify the policy
                policy.setAction(action_id);
                policy.setGroup(group);
                policy.update();

                // if it is a read, policy, modify the logo policy to match
                if (action_id == Constants.READ)
                {
                    // first get a list of READ policies from collection
                    List rps = AuthorizeManager.getPoliciesActionFilter(c,
                            collection, Constants.READ);

                    // remove all bitstream policies, then add READs
                    Bitstream bs = collection.getLogo();

                    if (bs != null)
                    {
                        AuthorizeManager.removeAllPolicies(c, bs);
                        AuthorizeManager.addPolicies(c, rps, bs);
                    }
                }

                // set up page attributes
                request.setAttribute("collection", collection);
                request.setAttribute("policies", AuthorizeManager.getPolicies(
                        c, collection));
                display_page = "/dspace-admin/authorize-collection-edit.jsp";
            }
            else if (community_id != -1)
            {
                community = Community.find(c, community_id);

                // modify the policy
                policy.setAction(action_id);
                policy.setGroup(group);
                policy.update();

                // if it is a read, policy, modify the logo policy to match
                if (action_id == Constants.READ)
                {
                    // first get a list of READ policies from collection
                    List rps = AuthorizeManager.getPoliciesActionFilter(c,
                            community, Constants.READ);

                    // remove all bitstream policies, then add READs
                    Bitstream bs = community.getLogo();

                    if (bs != null)
                    {
                        AuthorizeManager.removeAllPolicies(c, bs);
                        AuthorizeManager.addPolicies(c, rps, bs);
                    }
                }

                // set up page attributes
                request.setAttribute("community", community);
                request.setAttribute("policies", AuthorizeManager.getPolicies(
                        c, community));
                display_page = "/dspace-admin/authorize-community-edit.jsp";
            }
            else if (item_id != -1)
            {
                item = Item.find(c, item_id);

                // modify the policy
                policy.setAction(action_id);
                policy.setGroup(group);
                policy.update();

                // show edit form!
                prepItemEditForm(c, request, item);

                display_page = "/dspace-admin/authorize-item-edit.jsp";
            }

            // now return to previous state
            JSPManager.showJSP(request, response, display_page);
        }
        else if (button.equals("submit_cancel_policy"))
        {
            // delete the policy that we created if it's a new one
            if ((request.getParameter("newpolicy") != null))
            {
                int policy_id = UIUtil.getIntParameter(request, "policy_id");
                ResourcePolicy rp = ResourcePolicy.find(c, policy_id);
                AuthorizeUtil.authorizeManagePolicy(c, rp);
                rp.delete();
            }

            // return to the previous page
            int collection_id = UIUtil
                    .getIntParameter(request, "collection_id");
            int community_id = UIUtil.getIntParameter(request, "community_id");
            int item_id = UIUtil.getIntParameter(request, "item_id");
            String display_page = null;

            if (collection_id != -1)
            {
                // set up for return to collection edit page
                Collection t = Collection.find(c, collection_id);

                request.setAttribute("collection", t);
                request.setAttribute("policies", AuthorizeManager.getPolicies(
                        c, t));
                display_page = "/dspace-admin/authorize-collection-edit.jsp";
            }
            else if (community_id != -1)
            {
                // set up for return to community edit page
                Community t = Community.find(c, community_id);

                request.setAttribute("community", t);
                request.setAttribute("policies", AuthorizeManager.getPolicies(
                        c, t));
                display_page = "/dspace-admin/authorize-community-edit.jsp";
View Full Code Here

            unauthorized.setHead(T_head_resource);
            unauthorized.addPara(T_para_resource);
        }
        else if (dso instanceof Community)
        {
          Community community = (Community) dso;
          unauthorized.setHead(T_head_community);
            unauthorized.addPara(T_para_community.parameterize(community.getMetadata("name")));
        }
        else if (dso instanceof Collection)
        {
          Collection collection = (Collection) dso;
          unauthorized.setHead(T_head_collection);
View Full Code Here

                }
            }
      }
      else if (dso instanceof Community)
      {
        Community community = (Community) dso;
       
        // can they admin this collection?
            if (community.canEditBoolean())
            {
              context.setHead(T_context_head);
              context.addItemXref(contextPath+"/admin/community?communityID=" + community.getID(), T_context_edit_community);
              if (AuthorizeManager.isAdmin(this.context, dso))
                    context.addItem().addXref(contextPath+"/admin/export?communityID="+community.getID(), T_context_export_community );
                    context.addItem().addXref(contextPath+ "/csv/handle/"+dso.getHandle(),T_context_export_metadata );
            }
           
            // can they add to this community?
            if (AuthorizeManager.authorizeActionBoolean(this.context, community,Constants.ADD))
            {
              context.setHead(T_context_head);
              context.addItemXref(contextPath+"/admin/collection?createNew&communityID=" + community.getID(), T_context_create_collection);
                context.addItemXref(contextPath+"/admin/community?createNew&communityID=" + community.getID(), T_context_create_subcommunity);     
            }
      }
     
      if ("community-list".equals(this.sitemapURI))
      {
View Full Code Here

        service.addWorkspace(workspace);
      }
      else if (dso instanceof Community)
      {
        Community community = (Community) dso;
        Workspace workspace = new Workspace();
        workspace.setTitle(community.getMetadata("name"));

        List<Collection> collections = swordAuth.getAllowedCollections(swordContext, community);
        for (Collection collection : collections)
        {
          org.purl.sword.base.Collection scol = colGen.buildCollection(collection);
View Full Code Here

              options++;
            }
      }
      else if (dso instanceof Community)
      {
        Community community = (Community) dso;
       
        // can they admin this collection?
            if (community.canEditBoolean())
            {            
              context.addItemXref(contextPath+"/admin/community?communityID=" + community.getID(), T_context_edit_community);
              options++;
            }
           
            // can they add to this community?
            if (AuthorizeManager.authorizeActionBoolean(this.context, community,Constants.ADD))
            {         
              context.addItemXref(contextPath+"/admin/collection?createNew&communityID=" + community.getID(), T_context_create_collection);          
              context.addItemXref(contextPath+"/admin/community?createNew&communityID=" + community.getID(), T_context_create_subcommunity);
              options++;
            }
      }
     
      if ("community-list".equals(this.sitemapURI))
View Full Code Here

TOP

Related Classes of org.dspace.content.Community

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.