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

📄 collectionwizardservlet.java

📁 dspace 用j2ee架构的一个数字图书馆.开源程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            // Give it the needed permission            AuthorizeManager.addPolicy(context, collection,                    Constants.DEFAULT_ITEM_READ, g);            AuthorizeManager.addPolicy(context, collection,                    Constants.DEFAULT_BITSTREAM_READ, g);            break;        case PERM_SUBMIT:            g = collection.getSubmitters();            break;        case PERM_WF1:            g = collection.getWorkflowGroup(1);            break;        case PERM_WF2:            g = collection.getWorkflowGroup(2);            break;        case PERM_WF3:            g = collection.getWorkflowGroup(3);            break;        case PERM_ADMIN:            g = collection.getAdministrators();            break;        }        // Add people and groups from the form to the group        int[] eperson_ids = UIUtil.getIntParameters(request, "eperson_id");        int[] group_ids = UIUtil.getIntParameters(request, "group_ids");                if (eperson_ids != null)        {            for (int i = 0; i < eperson_ids.length; i++)            {                EPerson eperson = EPerson.find(context, eperson_ids[i]);                if (eperson != null)                {                    g.addMember(eperson);                }            }        }                if (group_ids != null)        {            for (int i = 0; i < group_ids.length; i++)            {                Group group = Group.find(context, group_ids[i]);                            if (group != null)                {                    g.addMember(group);                }            }        }                // Update group        g.update();        showNextPage(context, request, response, collection, permission);        context.complete();    }    /**     * process input from basic info page     *      * @param context     * @param request     * @param response     * @param collection     * @throws SQLException     * @throws ServletException     * @throws IOException     * @throws AuthorizeException     */    private void processBasicInfo(Context context, HttpServletRequest request,            HttpServletResponse response) throws SQLException,            ServletException, IOException, AuthorizeException    {        // Wrap multipart request to get the submission info        FileUploadRequest wrapper = new FileUploadRequest(request);        Collection collection = Collection.find(context, UIUtil                .getIntParameter(wrapper, "collection_id"));        if (collection == null)        {            log.warn(LogManager.getHeader(context, "integrity_error", UIUtil                    .getRequestLogInfo(wrapper)));            JSPManager.showIntegrityError(request, response);            return;        }        // Get metadata        collection.setMetadata("name", wrapper.getParameter("name"));        collection.setMetadata("short_description", wrapper                .getParameter("short_description"));        collection.setMetadata("introductory_text", wrapper                .getParameter("introductory_text"));        collection.setMetadata("copyright_text", wrapper                .getParameter("copyright_text"));        collection.setMetadata("side_bar_text", wrapper                .getParameter("side_bar_text"));        collection.setMetadata("provenance_description", wrapper                .getParameter("provenance_description"));        // Need to be more careful about license -- make sure it's null if        // nothing was entered        String license = wrapper.getParameter("license");        if ((license != null) || "".equals(license))        {            collection.setLicense(license);        }        File temp = wrapper.getFile("file");        if (temp != null)        {            // Read the temp file as logo            InputStream is = new BufferedInputStream(new FileInputStream(temp));            Bitstream 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);            logoBS.update();            // Remove temp file            temp.delete();        }        collection.update();        // Now work out what next page is        showNextPage(context, request, response, collection, BASIC_INFO);        context.complete();    }    /**     * Process input from default item page     *      * @param context     *            DSpace context     * @param request     *            HTTP request     * @param response     *            HTTP response     * @param collection     *            Collection we're editing     */    private void processDefaultItem(Context context,            HttpServletRequest request, HttpServletResponse response,            Collection collection) throws SQLException, ServletException,            IOException, AuthorizeException    {        Item item = collection.getTemplateItem();        for (int i = 0; i < 10; i++)        {            int dcTypeID = UIUtil.getIntParameter(request, "dctype_" + i);            String value = request.getParameter("value_" + i);            String lang = request.getParameter("lang_" + i);            if ((dcTypeID != -1) && (value != null) && !value.equals(""))            {                MetadataField field = MetadataField.find(context,dcTypeID);                MetadataSchema schema = MetadataSchema.find(context,field.getSchemaID());                item.addMetadata(schema.getName(),field.getElement(), field.getQualifier(), lang, value);            }        }        item.update();        // Now work out what next page is        showNextPage(context, request, response, collection, DEFAULT_ITEM);        context.complete();    }    /**     * Work out which page to show next, and show it     *      * @param context     * @param request     * @param response     * @param collection     * @param stage     *            the stage the user just finished, or if PERMISSIONS, the     *            particular permissions page     * @throws SQLException     * @throws ServletException     * @throws IOException     * @throws AuthorizeException     */    private void showNextPage(Context context, HttpServletRequest request,            HttpServletResponse response, Collection collection, int stage)            throws SQLException, ServletException, IOException,            AuthorizeException    {        // Put collection in request attributes, as most JSPs will need it        request.setAttribute("collection", collection);        // FIXME: Not a nice hack -- do we show the MIT users checkbox?        if (Group.findByName(context, "MIT Users") != null)        {            request.setAttribute("mitgroup", new Boolean(true));        }        log.debug(LogManager.getHeader(context, "nextpage", "stage=" + stage));        switch (stage)        {        case BASIC_INFO:            // Next page is 'permission to read' page iff ITEM_DEFAULT_READ            // for anonymous group is NOT there            List anonReadPols = AuthorizeManager.getPoliciesActionFilter(                    context, collection, Constants.DEFAULT_ITEM_READ);            // At this stage, if there's any ITEM_DEFAULT_READ, it can only            // be an anonymous one.            if (anonReadPols.size() == 0)            {                request.setAttribute("permission", new Integer(PERM_READ));                JSPManager.showJSP(request, response,                        "/dspace-admin/wizard-permissions.jsp");                break;            }        case PERM_READ:            // Next page is 'permission to submit' iff there's a submit group            // defined            if (collection.getSubmitters() != null)            {                request.setAttribute("permission", new Integer(PERM_SUBMIT));                JSPManager.showJSP(request, response,                        "/dspace-admin/wizard-permissions.jsp");                break;            }        case PERM_SUBMIT:            // Next page is 'workflow step 1' iff there's a wf step 1 group            // defined            if (collection.getWorkflowGroup(1) != null)            {                request.setAttribute("permission", new Integer(PERM_WF1));                JSPManager.showJSP(request, response,                        "/dspace-admin/wizard-permissions.jsp");                break;            }        case PERM_WF1:            // Next page is 'workflow step 2' iff there's a wf step 2 group            // defined            if (collection.getWorkflowGroup(2) != null)            {                request.setAttribute("permission", new Integer(PERM_WF2));                JSPManager.showJSP(request, response,                        "/dspace-admin/wizard-permissions.jsp");                break;            }        case PERM_WF2:            // Next page is 'workflow step 3' iff there's a wf step 2 group            // defined            if (collection.getWorkflowGroup(3) != null)            {                request.setAttribute("permission", new Integer(PERM_WF3));                JSPManager.showJSP(request, response,                        "/dspace-admin/wizard-permissions.jsp");                break;            }        case PERM_WF3:            // Next page is 'collection administrator' iff there's a collection            // administrator group            if (collection.getAdministrators() != null)            {                request.setAttribute("permission", new Integer(PERM_ADMIN));                JSPManager.showJSP(request, response,                        "/dspace-admin/wizard-permissions.jsp");                break;            }        case PERM_ADMIN:            // Next page is 'default item' iff there's a default item            if (collection.getTemplateItem() != null)            {                MetadataField[] types = MetadataField.findAll(context);                request.setAttribute("dctypes", types);                JSPManager.showJSP(request, response,                        "/dspace-admin/wizard-default-item.jsp");                break;            }        case DEFAULT_ITEM:            // Next page is 'summary page (the last page)            // sort of a hack to pass the community ID to the edit collection            // page,            // which needs it in other contexts            if (collection != null)            {                Community[] communities = collection.getCommunities();                request.setAttribute("community", communities[0]);                if (AuthorizeManager.isAdmin(context))                {                    // set a variable to show all buttons                    request.setAttribute("admin_button", new Boolean(true));                }            }            JSPManager.showJSP(request, response, "/tools/edit-collection.jsp");            break;        }    }}

⌨️ 快捷键说明

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