⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 authorizeadminservlet.java

📁 dspace 用j2ee架构的一个数字图书馆.开源程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            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"));            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"));            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"));            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);            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);                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";            }            else if (item_id != -1)            {                // set up for return to item edit page                Item t = Item.find(c, item_id);                // show edit form!                prepItemEditForm(c, request, t);                display_page = "/dspace-admin/authorize-item-edit.jsp";            }            JSPManager.showJSP(request, response, display_page);        }        else if (button.equals("submit_advanced_clear"))        {            // remove all policies for a set of objects            int collection_id = UIUtil                    .getIntParameter(request, "collection_id");            int resource_type = UIUtil                    .getIntParameter(request, "resource_type");            // if it's to bitstreams, do it to bundles too            PolicySet.setPolicies(c, Constants.COLLECTION, collection_id,                    resource_type, 0, 0, false, true);            if (resource_type == Constants.BITSTREAM)            {                PolicySet.setPolicies(c, Constants.COLLECTION, collection_id,                        Constants.BUNDLE, 0, 0, false, true);            }            // return to the main page            showMainPage(c, request, response);        }        else if (button.equals("submit_advanced_add"))        {            // add a policy to a set of objects            int collection_id = UIUtil                    .getIntParameter(request, "collection_id");            int resource_type = UIUtil                    .getIntParameter(request, "resource_type");            int action_id = UIUtil.getIntParameter(request, "action_id");            int group_id = UIUtil.getIntParameter(request, "group_id");            PolicySet.setPolicies(c, Constants.COLLECTION, collection_id,                    resource_type, action_id, group_id, false, false);            // if it's a bitstream, do it to the bundle too            if (resource_type == Constants.BITSTREAM)            {                PolicySet.setPolicies(c, Constants.COLLECTION, collection_id,                        Constants.BUNDLE, action_id, group_id, false, false);            }            // return to the main page            showMainPage(c, request, response);        }        else if (button.equals("submit_collection_select"))        {            // edit the collection's permissions            Collection collection = Collection.find(c, UIUtil.getIntParameter(                    request, "collection_id"));            List policies = AuthorizeManager.getPolicies(c, collection);            request.setAttribute("collection", collection);            request.setAttribute("policies", policies);            JSPManager.showJSP(request, response,                    "/dspace-admin/authorize-collection-edit.jsp");        }        else        {            // return to the main page            showMainPage(c, request, response);        }        c.complete();    }    void showMainPage(Context c, HttpServletRequest request,            HttpServletResponse response) throws ServletException, IOException,            SQLException, AuthorizeException    {        JSPManager.showJSP(request, response,                "/dspace-admin/authorize-main.jsp");    }    void prepItemEditForm(Context c, HttpServletRequest request, Item item)            throws SQLException    {        List item_policies = AuthorizeManager.getPolicies(c, item);        // Put bundle and bitstream policies in their own hashes        Map bundle_policies = new HashMap();        Map bitstream_policies = new HashMap();        Bundle[] bundles = item.getBundles();        for (int i = 0; i < bundles.length; i++)        {            Bundle myBundle = bundles[i];            List myPolicies = AuthorizeManager.getPolicies(c, myBundle);            // add bundle's policies to bundle_policies map            bundle_policies.put(new Integer(myBundle.getID()), myPolicies);            // go through all bundle's bitstreams, add to bitstream map            Bitstream[] bitstreams = myBundle.getBitstreams();            for (int j = 0; j < bitstreams.length; j++)            {                Bitstream myBitstream = bitstreams[j];                myPolicies = AuthorizeManager.getPolicies(c, myBitstream);                bitstream_policies.put(new Integer(myBitstream.getID()),                        myPolicies);            }        }        request.setAttribute("item", item);        request.setAttribute("item_policies", item_policies);        request.setAttribute("bundles", bundles);        request.setAttribute("bundle_policies", bundle_policies);        request.setAttribute("bitstream_policies", bitstream_policies);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -