/** * Do any processing of the information input by the user, and/or perform step processing (if no * user interaction required) * * <p>It is this method's job to save any data to the underlying database, as necessary, and * return error messages (if any) which can then be processed by the appropriate user interface * (JSP-UI or XML-UI) * * <p>NOTE: If this step is a non-interactive step (i.e. requires no UI), then it should perform * *all* of its processing in this method! * * @param context current DSpace context * @param request current servlet request object * @param response current servlet response object * @param subInfo submission info object * @return Status or error flag which will be processed by doPostProcessing() below! (if * STATUS_COMPLETE or 0 is returned, no errors occurred!) */ @Override public int doProcessing( Context context, HttpServletRequest request, HttpServletResponse response, SubmissionInfo subInfo) throws ServletException, IOException, SQLException, AuthorizeException, java.io.IOException { HttpSession session = request.getSession(); session.setAttribute("inProgress", "TRUE"); // check what submit button was pressed in User Interface String buttonPressed = Util.getSubmitButton(request, NEXT_BUTTON); if ("submit_grant".equalsIgnoreCase(buttonPressed) || "submit_no_cc".equalsIgnoreCase(buttonPressed)) { return processCC(context, request, response, subInfo); } String choiceButton = Util.getSubmitButton(request, SELECT_CHANGE); Enumeration e = request.getParameterNames(); String isFieldRequired = "FALSE"; while (e.hasMoreElements()) { String parameterName = (String) e.nextElement(); if (parameterName.equals("button_required")) { isFieldRequired = "TRUE"; break; } } session.setAttribute("isFieldRequired", isFieldRequired); if (choiceButton.equals(SELECT_CHANGE)) { Item item = subInfo.getSubmissionItem().getItem(); LicenseMetadataValue uriField = creativeCommonsService.getCCField("uri"); LicenseMetadataValue nameField = creativeCommonsService.getCCField("name"); String licenseUri = uriField.ccItemValue(item); if (licenseUri != null) // if (CreativeCommons.hasLicense(item, "dc", "rights", "uri", Item.ANY) // && !CreativeCommons.getRightsURI(item, "dc", "rights", "uri", Item.ANY).equals("")) { // CreativeCommons.setItemMetadata(item, licenseURI, "dc", "rights", "uri", // ConfigurationManager.getProperty("default.locale")); uriField.removeItemValue(context, item, licenseUri); if (ConfigurationManager.getBooleanProperty("cc.submit.setname")) { String licenseName = nameField.keyedItemValue(item, licenseUri); nameField.removeItemValue(context, item, licenseName); // CreativeCommons.setItemMetadata(item, CreativeCommons.getRightsName(item, "dc", // "rights", null, Item.ANY), "dc", "rights", null, // ConfigurationManager.getProperty("default.locale")); } if (ConfigurationManager.getBooleanProperty("cc.submit.addBitstream")) { creativeCommonsService.removeLicense(context, item); } removeRequiredAttributes(session); itemService.update(context, item); context.dispatchEvents(); } return STATUS_COMPLETE; } else if (buttonPressed.startsWith(PROGRESS_BAR_PREFIX) || buttonPressed.equals(PREVIOUS_BUTTON)) { removeRequiredAttributes(session); } if (buttonPressed.equals(NEXT_BUTTON) || buttonPressed.equals(CANCEL_BUTTON)) { return processCCWS(context, request, response, subInfo); } else { removeRequiredAttributes(session); session.removeAttribute("inProgress"); return STATUS_COMPLETE; } }
/** * Process the input from the CC license page using CC Web service * * @param context current DSpace context * @param request current servlet request object * @param response current servlet response object * @param subInfo submission info object * @return Status or error flag which will be processed by doPostProcessing() below! (if * STATUS_COMPLETE or 0 is returned, no errors occurred!) */ protected int processCCWS( Context context, HttpServletRequest request, HttpServletResponse response, SubmissionInfo subInfo) throws ServletException, IOException, SQLException, AuthorizeException { HttpSession session = request.getSession(); Map<String, String> map = new HashMap<String, String>(); String licenseclass = (request.getParameter("licenseclass_chooser") != null) ? request.getParameter("licenseclass_chooser") : ""; String jurisdiction = (ConfigurationManager.getProperty("cc.license.jurisdiction") != null) ? ConfigurationManager.getProperty("cc.license.jurisdiction") : ""; if (licenseclass.equals("standard")) { map.put("commercial", request.getParameter("commercial_chooser")); map.put("derivatives", request.getParameter("derivatives_chooser")); } else if (licenseclass.equals("recombo")) { map.put("sampling", request.getParameter("sampling_chooser")); } map.put("jurisdiction", jurisdiction); CCLookup ccLookup = new CCLookup(); LicenseMetadataValue uriField = creativeCommonsService.getCCField("uri"); LicenseMetadataValue nameField = creativeCommonsService.getCCField("name"); ccLookup.issue(licenseclass, map, ConfigurationManager.getProperty("cc.license.locale")); Item item = subInfo.getSubmissionItem().getItem(); if (licenseclass.equals("xmlui.Submission.submit.CCLicenseStep.no_license")) { // only remove any previous licenses String licenseUri = uriField.ccItemValue(item); if (licenseUri != null) { uriField.removeItemValue(context, item, licenseUri); if (ConfigurationManager.getBooleanProperty("cc.submit.setname")) { String licenseName = nameField.keyedItemValue(item, licenseUri); nameField.removeItemValue(context, item, licenseName); } if (ConfigurationManager.getBooleanProperty("cc.submit.addBitstream")) { creativeCommonsService.removeLicense(context, item); } itemService.update(context, item); context.dispatchEvents(); removeRequiredAttributes(session); } return STATUS_COMPLETE; } else if (licenseclass.equals("xmlui.Submission.submit.CCLicenseStep.select_change")) { removeRequiredAttributes(session); return STATUS_COMPLETE; } else if (ccLookup.isSuccess()) { uriField.addItemValue(context, item, ccLookup.getLicenseUrl()); if (ConfigurationManager.getBooleanProperty("cc.submit.addbitstream")) { creativeCommonsService.setLicenseRDF(context, item, ccLookup.getRdf()); } if (ConfigurationManager.getBooleanProperty("cc.submit.setname")) { nameField.addItemValue(context, item, ccLookup.getLicenseName()); } itemService.update(context, item); context.dispatchEvents(); removeRequiredAttributes(session); session.removeAttribute("inProgress"); } else { request.getSession().setAttribute("ccError", ccLookup.getErrorMessage()); String licenseUri = uriField.ccItemValue(item); if (licenseUri != null) { uriField.removeItemValue(context, item, licenseUri); } return STATUS_LICENSE_REJECTED; } return STATUS_COMPLETE; }