/** * We are just starting the upload process. Record where we came from, so if they hit "cancel" we * know where to send them. If we have problems, just clear it. */ private void captureReferringUrl(VitroRequest vreq) { String referrer = vreq.getHeader("Referer"); if (referrer == null) { vreq.getSession().removeAttribute(ATTRIBUTE_REFERRING_PAGE); } else { vreq.getSession().setAttribute(ATTRIBUTE_REFERRING_PAGE, referrer); } }
private void processMergeResourceRequest(VitroRequest vreq) { String uri1 = vreq.getParameter("uri1"); // get primary uri String uri2 = vreq.getParameter("uri2"); // get secondary uri String usePrimaryLabelOnlyStr = vreq.getParameter("usePrimaryLabelOnly"); ; boolean usePrimaryLabelOnly = usePrimaryLabelOnlyStr != null && !usePrimaryLabelOnlyStr.isEmpty(); if (uri1 != null) { JenaIngestUtils utils = new JenaIngestUtils(); /* * get baseOnt and infOnt models */ OntModel baseOntModel = ModelAccess.on(getServletContext()).getOntModel(FULL_ASSERTIONS); OntModel tboxOntModel = ModelAccess.on(getServletContext()).getOntModel(TBOX_UNION); /* * calling method that does the merge operation. */ MergeResult result = utils.doMerge(uri1, uri2, baseOntModel, tboxOntModel, usePrimaryLabelOnly); vreq.getSession().setAttribute("leftoverModel", result.getLeftoverModel()); vreq.setAttribute("result", result); vreq.setAttribute("title", "Merge Resources"); vreq.setAttribute("bodyJsp", MERGE_RESULT); } else { vreq.setAttribute("title", "Merge Resources"); vreq.setAttribute("bodyJsp", MERGE_RESOURCES); } }
@Override protected ResponseValues processRequest(VitroRequest vreq) { // get the EditConfiguration EditConfigurationVTwo configuration = EditConfigurationUtils.getEditConfiguration(vreq); if (configuration == null) throw new Error("No edit configuration found."); // get the EditSubmission MultiValueEditSubmission submission = new MultiValueEditSubmission(vreq.getParameterMap(), configuration); EditSubmissionUtils.putEditSubmissionInSession(vreq.getSession(), submission); // if errors, return error response ResponseValues errorResponse = doValidationErrors(vreq, configuration, submission); if (errorResponse != null) return errorResponse; // get the models to work with in case the write model and query model are not the defaults OntModel queryModel = configuration.getQueryModelSelector().getModel(vreq, getServletContext()); OntModel writeModel = configuration.getWriteModelSelector().getModel(vreq, getServletContext()); // If data property check for back button confusion boolean isBackButton = checkForBackButtonConfusion(configuration, vreq, queryModel); if (isBackButton) { // Process back button issues and do a return here return doProcessBackButton(configuration, submission, vreq); } // Otherwise, process as usual AdditionsAndRetractions changes; try { ProcessRdfForm prf = new ProcessRdfForm(configuration, new NewURIMakerVitro(vreq.getWebappDaoFactory())); changes = prf.process(configuration, submission); } catch (Exception e) { throw new Error(e); } if (configuration.isUseDependentResourceDelete()) changes = ProcessRdfForm.addDependentDeletes(changes, queryModel); N3EditUtils.preprocessModels(changes, configuration, vreq); ProcessRdfForm.applyChangesToWriteModel( changes, queryModel, writeModel, EditN3Utils.getEditorUri(vreq)); // Here we are trying to get the entity to return to URL, // More involved processing for data property apparently String entityToReturnTo = N3EditUtils.processEntityToReturnTo(configuration, submission, vreq); // For data property processing, need to update edit configuration for back button N3EditUtils.updateEditConfigurationForBackButton(configuration, submission, vreq, writeModel); PostEditCleanupController.doPostEditCleanup(vreq); return PostEditCleanupController.doPostEditRedirect(vreq, entityToReturnTo); }
private IdentifierBundle getIdentifiers() { HttpSession session = vreq.getSession(); ServletContext context = session.getServletContext(); IdentifierBundle ids = ServletIdentifierBundleFactory.getIdBundleForRequest(vreq, session, context); if (ids == null) { return new ArrayIdentifierBundle(); } else { return ids; } }
/** Get the policy from the request, or from the servlet context. */ private PolicyIface getPolicies() { ServletContext servletContext = vreq.getSession().getServletContext(); PolicyIface policy = RequestPolicyList.getPolicies(vreq); if (isEmptyPolicy(policy)) { policy = ServletPolicyList.getPolicies(servletContext); if (isEmptyPolicy(policy)) { log.error("No policy found in request at " + RequestPolicyList.POLICY_LIST); policy = new PolicyList(); } } return policy; }
private void processMergeResultRequest(VitroRequest vreq, HttpServletResponse response) { Model lmodel = (Model) vreq.getSession().getAttribute("leftoverModel"); response.setContentType("RDF/XML-ABBREV"); try { OutputStream outStream = response.getOutputStream(); outStream.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>".getBytes()); lmodel.write(outStream, "RDF/XML-ABBREV"); outStream.flush(); outStream.close(); } catch (IOException ioe) { throw new RuntimeException(ioe); } }
/** Get the model type from the request, or from the session. */ protected WhichService getModelType(VitroRequest vreq) { String modelType = vreq.getParameter("modelType"); if (modelType != null) { if (modelType.equals(CONFIGURATION.toString())) { return CONFIGURATION; } else { return CONTENT; } } if (vreq.getSession().getAttribute(WHICH_MODEL_MAKER) == CONFIGURATION) { return CONFIGURATION; } else { return CONTENT; } }
private void doRenameBNodes( VitroRequest vreq, String namespaceEtc, boolean patternBoolean, String pattern, String[] sourceModel) { OntModel source = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM); String property = vreq.getParameter("property"); Boolean csv2rdf = false; try { csv2rdf = Boolean.parseBoolean(vreq.getParameter("csv2rdf")); } catch (Exception e) { log.error(e, e); } if (csv2rdf) { source.addSubModel((Model) vreq.getSession().getAttribute("csv2rdfResult")); } else { for (int i = 0; i < sourceModel.length; i++) { Model m = getModel(sourceModel[i], vreq); source.addSubModel(m); } } Model destination = (csv2rdf) ? ModelFactory.createDefaultModel() : getModel(vreq.getParameter("destinationModelName"), vreq); JenaIngestUtils utils = new JenaIngestUtils(); destination.enterCriticalSection(Lock.WRITE); try { if (!patternBoolean) { destination.add(utils.renameBNodes(source, namespaceEtc, vreq.getJenaOntModel())); } else { destination.add( utils.renameBNodesByPattern( source, namespaceEtc, vreq.getJenaOntModel(), pattern, property)); } if (csv2rdf) { Model ultimateDestination = getModel(vreq.getParameter("destinationModelName"), vreq); ultimateDestination.add(destination); } } finally { destination.leaveCriticalSection(); } }
/** * When we complete the process, by success or by cancellation, go to the initial referring page. * If there wasn't one, go to the individual display page. */ private String exitPageUrl(VitroRequest vreq, String entityUri) { String referrer = (String) vreq.getSession().getAttribute(ATTRIBUTE_REFERRING_PAGE); if (referrer != null) { return referrer; } String defaultNamespace = getDefaultNamespace(); if (defaultNamespace == null) { return ""; } else if (!entityUri.startsWith(defaultNamespace)) { return ""; } else { String tail = entityUri.substring(defaultNamespace.length()); if (!tail.startsWith("/")) { tail = "/" + tail; } return "display" + tail; } }
private void processContentModelsRequest(VitroRequest vreq) { ModelMaker vsmm = ModelAccess.on(getServletContext()).getModelMaker(CONTENT); vreq.getSession().setAttribute(WHICH_MODEL_MAKER, CONTENT); showModelList(vreq, vsmm, CONTENT); }
private String getConfigFilePath(String filename) { return vreq.getSession().getServletContext().getRealPath(CONFIG_FILE_PATH + filename); }