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); } }
private void doExecuteWorkflow(VitroRequest vreq) { String workflowURI = vreq.getParameter("workflowURI"); String workflowStepURI = vreq.getParameter("workflowStepURI"); OntModel jenaOntModel = (OntModel) getModel("vitro:jenaOntModel", vreq); new JenaIngestWorkflowProcessor(jenaOntModel.getIndividual(workflowURI), getModelMaker(vreq)) .run(jenaOntModel.getIndividual(workflowStepURI)); }
private void processExecuteWorkflowRequest(VitroRequest vreq) { String workflowURIStr = vreq.getParameter("workflowURI"); String workflowStepURIStr = vreq.getParameter("workflowStepURI"); if (workflowURIStr != null && workflowStepURIStr != null) { doExecuteWorkflow(vreq); vreq.setAttribute("title", "IngestMenu"); vreq.setAttribute("bodyJsp", INGEST_MENU_JSP); } else if (workflowURIStr != null) { // Select the workflow step at which to start OntModel jenaOntModel = (OntModel) getModel("vitro:jenaOntModel", vreq); vreq.setAttribute( "workflowSteps", new JenaIngestWorkflowProcessor( jenaOntModel.getIndividual(workflowURIStr), getModelMaker(vreq)) .getWorkflowSteps(null)); vreq.setAttribute("title", "Choose Workflow Step"); vreq.setAttribute("bodyJsp", WORKFLOW_STEP_JSP); } else { OntModel jenaOntModel = ModelAccess.on(getServletContext()).getOntModel(); jenaOntModel.enterCriticalSection(Lock.READ); List<Individual> savedQueryList = new LinkedList<Individual>(); try { Resource workflowClassRes = WorkflowOntology.Workflow; savedQueryList.addAll(jenaOntModel.listIndividuals(workflowClassRes).toList()); } finally { jenaOntModel.leaveCriticalSection(); } vreq.setAttribute("workflows", savedQueryList); vreq.setAttribute("title", "Execute Workflow"); vreq.setAttribute("bodyJsp", EXECUTE_WORKFLOW_JSP); } }
private void processRenameBNodesURISelectRequest(VitroRequest vreq, ModelMaker maker) { String namespaceEtcStr = vreq.getParameter("namespaceEtcStr"); String pattern = vreq.getParameter("pattern"); String concatenate = vreq.getParameter("concatenate"); String[] sourceModel = vreq.getParameterValues("sourceModelName"); if (namespaceEtcStr != null) { if (namespaceEtcStr.isEmpty()) { if ("true".equals(vreq.getParameter("csv2rdf"))) { processCsv2rdfRequest(vreq); return; } else { vreq.setAttribute("errorMsg", "Please enter a value."); processRenameBNodesRequest(vreq, maker); return; } } if (concatenate.equals("integer")) { doRenameBNodes(vreq, namespaceEtcStr, false, null, sourceModel); } else { pattern = pattern.trim(); doRenameBNodes(vreq, namespaceEtcStr, true, pattern, sourceModel); } vreq.setAttribute("title", "Ingest Menu"); vreq.setAttribute("bodyJsp", INGEST_MENU_JSP); } else { vreq.setAttribute("title", "URI Select"); vreq.setAttribute("bodyJsp", RENAME_BNODES_URI_SELECT_JSP); } }
private long doExecuteSparql(VitroRequest vreq) { OntModel jenaOntModel = ModelAccess.on(getServletContext()).getOntModel(); OntModel source = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM); String[] sourceModel = vreq.getParameterValues("sourceModelName"); for (int i = 0; i < sourceModel.length; i++) { Model m = getModel(sourceModel[i], vreq); source.addSubModel(m); } Model destination = getModel(vreq.getParameter("destinationModelName"), vreq); String sparqlQueryStr = vreq.getParameter("sparqlQueryStr"); String savedQueryURIStr = vreq.getParameter("savedQuery"); String queryStr; if (savedQueryURIStr.length() == 0) { log.debug("Using entered query"); queryStr = sparqlQueryStr; } else { Property queryStrProp = ResourceFactory.createProperty(SPARQL_QUERYSTR_PROP); jenaOntModel.enterCriticalSection(Lock.READ); try { Individual ind = jenaOntModel.getIndividual(savedQueryURIStr); log.debug("Using query " + savedQueryURIStr); queryStr = ((Literal) ind.getPropertyValue(queryStrProp)).getLexicalForm(); queryStr = StringEscapeUtils.unescapeHtml( queryStr); // !!! We need to turn off automatic HTML-escaping for data property // editing. } finally { jenaOntModel.leaveCriticalSection(); } } Model tempModel = ModelFactory.createDefaultModel(); Query query = SparqlQueryUtils.create(queryStr); QueryExecution qexec = QueryExecutionFactory.create(query, source); try { qexec.execConstruct(tempModel); } catch (QueryExecException qee) { qexec.execDescribe(tempModel); } destination.enterCriticalSection(Lock.WRITE); try { if (destination instanceof OntModel) { ((OntModel) destination).getBaseModel().notifyEvent(new EditEvent(null, true)); } else { destination.notifyEvent(new EditEvent(null, true)); } destination.add(tempModel); } finally { if (destination instanceof OntModel) { ((OntModel) destination).getBaseModel().notifyEvent(new EditEvent(null, false)); } else { destination.notifyEvent(new EditEvent(null, false)); } destination.leaveCriticalSection(); } return tempModel.size(); }
public void doSubtractModels(VitroRequest vreq) { String modela = vreq.getParameter("modela"); String modelb = vreq.getParameter("modelb"); String destination = vreq.getParameter("destinationModelName"); Model ma = getModel(modela, vreq); Model mb = getModel(modelb, vreq); Model destinationModel = getModel(destination, vreq); if (!destination.equals(modela)) destinationModel.add(ma.difference(mb)); else ma.remove(mb); }
@Override public Map<String, String> generateDataVisualization( VitroRequest vitroRequest, Log log, Dataset dataset) throws MalformedQueryParametersException { String egoURI = vitroRequest.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY); String visMode = vitroRequest.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY); ModelConstructor constructQueryRunner = new CoPIGrantCountConstructQueryRunner(egoURI, dataset, log); Model constructedModel = constructQueryRunner.getConstructedModel(); QueryRunner<CollaborationData> queryManager = new CoPIGrantCountQueryRunner(egoURI, constructedModel, log); CollaborationData investigatorNodesAndEdges = queryManager.getQueryResult(); /* * We will be using the same visualization package for both sparkline & co-pi * flash vis. We will use "VIS_MODE_KEY" as a modifier to differentiate * between these two. The default will be to render the co-pi network vis. * */ if (VisualizationFrameworkConstants.COPIS_COUNT_PER_YEAR_VIS_MODE.equalsIgnoreCase(visMode)) { /* * When the csv file is required - based on which sparkline visualization will * be rendered. * */ return prepareCoPIsCountPerYearDataResponse(investigatorNodesAndEdges); } else if (VisualizationFrameworkConstants.COPIS_LIST_VIS_MODE.equalsIgnoreCase(visMode)) { /* * When the csv file is required - based on which sparkline visualization will * be rendered. * */ return prepareCoPIsListDataResponse(investigatorNodesAndEdges); } else if (VisualizationFrameworkConstants.COPI_NETWORK_DOWNLOAD_VIS_MODE.equalsIgnoreCase( visMode)) { /* * When the csv file is required - based on which sparkline visualization will * be rendered. * */ return prepareNetworkDownloadDataResponse(investigatorNodesAndEdges); } else { /* * When the graphML file is required - based on which co-pi network * visualization will be rendered. * */ return prepareNetworkStreamDataResponse(investigatorNodesAndEdges); } }
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(); } }
private void processOutputModelRequest(VitroRequest vreq, HttpServletResponse response) { String modelNameStr = vreq.getParameter("modelName"); Model model = getModel(modelNameStr, vreq); JenaOutputUtils.setNameSpacePrefixes(model, vreq.getWebappDaoFactory()); model.enterCriticalSection(Lock.READ); try { OutputStream out = response.getOutputStream(); response.setContentType("application/x-turtle"); // out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".getBytes()); model.write(out, "TTL"); out.flush(); out.close(); } catch (com.hp.hpl.jena.shared.CannotEncodeCharacterException cece) { // there's got to be a better way to do this byte[] badCharBytes = String.valueOf(cece.getBadChar()).getBytes(); String errorMsg = "Cannot encode character with byte values: (decimal) "; for (int i = 0; i < badCharBytes.length; i++) { errorMsg += badCharBytes[i]; } throw new RuntimeException(errorMsg, cece); } catch (Exception e) { log.error(e, e); } finally { model.leaveCriticalSection(); } }
private void processLoadRDFDataRequest(VitroRequest vreq, ModelMaker maker) { String docLoc = vreq.getParameter("docLoc"); String filePath = vreq.getParameter("filePath"); String modelName = vreq.getParameter("modelName"); String languageParam = null; String language = ((languageParam = vreq.getParameter("language")) != null) ? languageParam : "RDF/XML"; if (docLoc != null && modelName != null) { doLoadRDFData(modelName, docLoc, filePath, language, maker); vreq.setAttribute("title", "Ingest Menu"); vreq.setAttribute("bodyJsp", INGEST_MENU_JSP); } else { vreq.setAttribute("title", "Load RDF Data"); vreq.setAttribute("bodyJsp", LOAD_RDF_DATA_JSP); } }
private void processCreateModelRequest( VitroRequest vreq, ModelMaker maker, WhichService modelType) { String modelName = vreq.getParameter("modelName"); if (modelName != null) { try { URI graphURI = new URI(modelName); if (graphURI.getScheme() == null) { String origName = modelName; modelName = CREATED_GRAPH_BASE_URI + modelName; log.info("The model name has been changed from " + origName + " to " + modelName); } doCreateModel(modelName, maker); showModelList(vreq, maker, modelType); } catch (URISyntaxException e) { throw new RuntimeException("the model name must be a valid URI"); } } else { vreq.setAttribute("modelType", modelType.toString()); vreq.setAttribute("title", "Create New Model"); vreq.setAttribute("bodyJsp", CREATE_MODEL_JSP); } }
private void processCleanLiteralsRequest(VitroRequest vreq) { String modelNameStr = vreq.getParameter("modelName"); Model model = getModel(modelNameStr, vreq); doCleanLiterals(model); vreq.setAttribute("title", "Ingest Menu"); vreq.setAttribute("bodyJsp", INGEST_MENU_JSP); }
private void processRenameResourceRequest(VitroRequest vreq) { String oldNamespace = vreq.getParameter("oldNamespace"); String newNamespace = vreq.getParameter("newNamespace"); String errorMsg = ""; if (oldNamespace != null) { if (oldNamespace.isEmpty() && !newNamespace.isEmpty()) { errorMsg = "Please enter the old namespace to be changed."; } else if (!oldNamespace.isEmpty() && newNamespace.isEmpty()) { errorMsg = "Please enter the new namespace."; } else if (oldNamespace.isEmpty() && newNamespace.isEmpty()) { errorMsg = "Please enter the namespaces."; } else if (oldNamespace.equals(newNamespace)) { errorMsg = "Please enter two different namespaces."; } if (!errorMsg.isEmpty()) { vreq.setAttribute("errorMsg", errorMsg); vreq.setAttribute("oldNamespace", oldNamespace); vreq.setAttribute("newNamespace", newNamespace); vreq.setAttribute("title", "Rename Resource"); vreq.setAttribute("bodyJsp", RENAME_RESOURCE); } else { String result = doRename(oldNamespace, newNamespace); vreq.setAttribute("result", result); vreq.setAttribute("title", "Rename Resources"); vreq.setAttribute("bodyJsp", RENAME_RESULT); } } else { vreq.setAttribute("title", "Rename Resource"); vreq.setAttribute("bodyJsp", RENAME_RESOURCE); } }
/** * Handle the different actions. If not specified, the default action is to show the intro screen. */ private ResponseValues buildTheResponse(VitroRequest vreq) { String action = vreq.getParameter(PARAMETER_ACTION); try { Individual entity = validateEntityUri(vreq); if (ACTION_UPLOAD.equals(action)) { return doUploadImage(vreq, entity); } else if (ACTION_SAVE.equals(action)) { return doCreateThumbnail(vreq, entity); } else if (ACTION_DELETE.equals(action)) { captureReferringUrl(vreq); return doDeleteImage(vreq, entity); } else if (ACTION_DELETE_EDIT.equals(action)) { return doDeleteThenEdit(vreq, entity); } else { captureReferringUrl(vreq); return doIntroScreen(vreq, entity); } } catch (UserMistakeException e) { // Can't find the entity? Complain. return showAddImagePageWithError(vreq, null, e.getMessage()); } catch (Exception e) { // We weren't expecting this - log it, and apologize to the user. return new ExceptionResponseValues(e); } }
private void processDetachModelRequest( VitroRequest vreq, ModelMaker maker, WhichService modelType) { String modelName = vreq.getParameter("modelName"); if (modelName != null) { doDetachModel(modelName); } showModelList(vreq, maker, modelType); }
private void doSmushSingleModel(VitroRequest vreq) { OntModel source = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM); String[] sourceModel = vreq.getParameterValues("sourceModelName"); for (int i = 0; i < sourceModel.length; i++) { Model m = getModel(sourceModel[i], vreq); source.addSubModel(m); } Model destination = getModel(vreq.getParameter("destinationModelName"), vreq); String propertyURIStr = vreq.getParameter("propertyURI"); Property prop = ResourceFactory.createProperty(propertyURIStr); JenaIngestUtils utils = new JenaIngestUtils(); destination.enterCriticalSection(Lock.WRITE); try { destination.add(utils.smushResources(source, prop)); } finally { destination.leaveCriticalSection(); } }
private void processCsv2rdfRequest(VitroRequest vreq) { String csvUrl = vreq.getParameter("csvUrl"); if (csvUrl != null) { /*doExecuteCsv2Rdf(vreq);*/ vreq.setAttribute("title", "IngestMenu"); vreq.setAttribute("bodyJsp", INGEST_MENU_JSP); } else { vreq.setAttribute("title", "Convert CSV to RDF"); vreq.setAttribute("bodyJsp", CSV2RDF_JSP); } }
private void processGenerateTBoxRequest(VitroRequest vreq) { String testParam = vreq.getParameter("sourceModelName"); if (testParam != null) { doGenerateTBox(vreq); vreq.setAttribute("title", "Ingest Menu"); vreq.setAttribute("bodyJsp", INGEST_MENU_JSP); } else { vreq.setAttribute("title", "Generate TBox from Assertions Data"); vreq.setAttribute("bodyJsp", GENERATE_TBOX_JSP); } }
private void processSubtractModelRequest(VitroRequest vreq) { String modela = vreq.getParameter("modela"); if (modela != null) { doSubtractModels(vreq); vreq.setAttribute("title", "IngestMenu"); vreq.setAttribute("bodyJsp", INGEST_MENU_JSP); } else { vreq.setAttribute("title", "Subtract Models"); vreq.setAttribute("bodyJsp", SUBTRACT_MODELS_JSP); } }
private void processSplitPropertyValuesRequest(VitroRequest vreq) { String splitRegex = vreq.getParameter("splitRegex"); if (splitRegex != null) { doSplitPropertyValues(vreq); vreq.setAttribute("title", "IngestMenu"); vreq.setAttribute("bodyJsp", INGEST_MENU_JSP); } else { vreq.setAttribute("title", "Split PropertyValues"); vreq.setAttribute("bodyJsp", SPLIT_PROPERTY_VALUES_JSP); } }
private void processProcessStringsRequest(VitroRequest vreq) { String className = vreq.getParameter("className"); if (className != null) { doProcessStrings(vreq); vreq.setAttribute("title", "IngestMenu"); vreq.setAttribute("bodyJsp", INGEST_MENU_JSP); } else { vreq.setAttribute("title", "Process Strings"); vreq.setAttribute("bodyJsp", PROCESS_STRINGS_JSP); } }
private void processSmushSingleModelRequest(VitroRequest vreq) { String propertyURIStr = vreq.getParameter("propertyURI"); if (propertyURIStr != null) { doSmushSingleModel(vreq); vreq.setAttribute("title", "Ingest Menu"); vreq.setAttribute("bodyJsp", INGEST_MENU_JSP); } else { vreq.setAttribute("title", "Smush Resources"); vreq.setAttribute("bodyJsp", SMUSH_JSP); } }
public void doGenerateTBox(VitroRequest vreq) { OntModel source = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM); String[] sourceModel = vreq.getParameterValues("sourceModelName"); for (int i = 0; i < sourceModel.length; i++) { Model m = getModel(sourceModel[i], vreq); source.addSubModel(m); } String destinationModelStr = vreq.getParameter("destinationModelName"); Model destination = getModel(destinationModelStr, vreq); destination.add((new JenaIngestUtils()).generateTBox(source)); }
@Override protected void doRequest(VitroRequest vreq, HttpServletResponse response) { String errorMsg = null; String rankPredicate = vreq.getParameter(RANK_PREDICATE_PARAMETER_NAME); if (rankPredicate == null) { errorMsg = "No rank parameter specified"; log.error(errorMsg); doError(response, errorMsg, HttpServletResponse.SC_BAD_REQUEST); return; } String[] individualUris = vreq.getParameterValues(INDIVIDUAL_PREDICATE_PARAMETER_NAME); if (individualUris == null || individualUris.length == 0) { errorMsg = "No individuals specified"; log.error(errorMsg); doError(response, errorMsg, HttpServletResponse.SC_BAD_REQUEST); return; } WebappDaoFactory wadf = vreq.getWebappDaoFactory(); if (vreq.getWebappDaoFactory() == null) { errorMsg = "No WebappDaoFactory available"; log.error(errorMsg); doError(response, errorMsg, HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } DataPropertyStatementDao dpsDao = wadf.getDataPropertyStatementDao(); if (dpsDao == null) { errorMsg = "No DataPropertyStatementDao available"; log.error(errorMsg); doError(response, errorMsg, HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } // check permissions // TODO: (bdc34)This is not yet implemented, must check the IDs against the policies for // permissons before doing an edit! // rjy7 This should be inherited from the superclass boolean hasPermission = true; if (!hasPermission) { // if not okay, send error message doError(response, "Insufficent permissions", HttpStatus.SC_UNAUTHORIZED); return; } // This may not be the most efficient way. Should we instead build up a Model of retractions and // additions, so // we only hit the database once? reorderIndividuals(individualUris, vreq, rankPredicate); response.setStatus(HttpServletResponse.SC_OK); }
/** We got their main image - go to the Crop Image page. */ private TemplateResponseValues showCropImagePage( VitroRequest vreq, Individual entity, String imageUrl, Dimensions dimensions) { String placeholderUrl = vreq.getParameter(PARAMETER_PLACEHOLDER_URL); TemplateResponseValues rv = new TemplateResponseValues(TEMPLATE_CROP); rv.put(BODY_MAIN_IMAGE_URL, UrlBuilder.getUrl(imageUrl)); rv.put(BODY_MAIN_IMAGE_HEIGHT, dimensions.height); rv.put(BODY_MAIN_IMAGE_WIDTH, dimensions.width); rv.put(BODY_FORM_ACTION, formAction(entity.getURI(), ACTION_SAVE, placeholderUrl)); rv.put(BODY_CANCEL_URL, exitPageUrl(vreq, entity.getURI())); rv.put(BODY_TITLE, "Crop Photo" + forName(entity)); return rv; }
// Get URL pattern for return public static String getPostEditUrlPattern( VitroRequest vreq, EditConfigurationVTwo editConfig) { String cancel = vreq.getParameter("cancel"); String urlPattern = null; String urlPatternToReturnTo = null; String urlPatternToCancelTo = null; if (editConfig != null) { urlPatternToReturnTo = editConfig.getUrlPatternToReturnTo(); urlPatternToCancelTo = vreq.getParameter("url"); } // If a different cancel return path has been designated, use it. Otherwise, use the regular // return path. if (cancel != null && cancel.equals("true") && !StringUtils.isEmpty(urlPatternToCancelTo)) { urlPattern = urlPatternToCancelTo; } else if (!StringUtils.isEmpty(urlPatternToReturnTo)) { urlPattern = urlPatternToReturnTo; } else { urlPattern = "/individual"; } return urlPattern; }
/** We need to be talking about an actual Individual here. */ private Individual validateEntityUri(VitroRequest vreq) throws UserMistakeException { String entityUri = vreq.getParameter(PARAMETER_ENTITY_URI); if (entityUri == null) { throw new UserMistakeException("No entity URI was provided"); } Individual entity = vreq.getFullWebappDaoFactory().getIndividualDao().getIndividualByURI(entityUri); if (entity == null) { throw new UserMistakeException( "This URI is not recognized as belonging to anyone: '" + entityUri + "'"); } return entity; }
/** The individual has an image - go to the Replace Image page. */ private TemplateResponseValues showReplaceImagePage( VitroRequest vreq, Individual entity, ImageInfo imageInfo) { String placeholderUrl = vreq.getParameter(PARAMETER_PLACEHOLDER_URL); TemplateResponseValues rv = new TemplateResponseValues(TEMPLATE_REPLACE); rv.put(BODY_THUMBNAIL_URL, UrlBuilder.getUrl(imageInfo.getThumbnail().getBytestreamAliasUrl())); rv.put(BODY_DELETE_URL, formAction(entity.getURI(), ACTION_DELETE_EDIT, placeholderUrl)); rv.put(BODY_FORM_ACTION, formAction(entity.getURI(), ACTION_UPLOAD, placeholderUrl)); rv.put(BODY_CANCEL_URL, exitPageUrl(vreq, entity.getURI())); rv.put(BODY_TITLE, "Replace image" + forName(entity)); rv.put(BODY_MAX_FILE_SIZE, MAXIMUM_FILE_SIZE / (1024 * 1024)); rv.put(BODY_THUMBNAIL_HEIGHT, THUMBNAIL_HEIGHT); rv.put(BODY_THUMBNAIL_WIDTH, THUMBNAIL_WIDTH); return rv; }
/** 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 processPermanentURIRequest(VitroRequest vreq, ModelMaker maker) { String modelName = vreq.getParameter("modelName"); String oldModel = vreq.getParameter("oldModel"); String newModel = vreq.getParameter("newModel"); String oldNamespace = vreq.getParameter("oldNamespace"); String newNamespace = vreq.getParameter("newNamespace"); String dNamespace = vreq.getParameter("defaultNamespace"); newNamespace = (newNamespace == null || newNamespace.isEmpty()) ? oldNamespace : newNamespace; newNamespace = (dNamespace != null) ? dNamespace : newNamespace; if (modelName != null) { Model m = maker.getModel(modelName); List<String> namespaceList = new ArrayList<>(); ResIterator resItr = m.listResourcesWithProperty((Property) null); if (resItr != null) { while (resItr.hasNext()) { String namespace = resItr.nextResource().getNameSpace(); if (!namespaceList.contains(namespace)) { namespaceList.add(namespace); } } } else { namespaceList.add("no resources present"); } String defaultNamespace = vreq.getUnfilteredWebappDaoFactory().getDefaultNamespace(); vreq.setAttribute("modelName", modelName); vreq.setAttribute("defaultNamespace", defaultNamespace); vreq.setAttribute("namespaceList", namespaceList); vreq.setAttribute("title", "Permanent URI"); vreq.setAttribute("bodyJsp", PERMANENT_URI); } else if (oldModel != null) { JenaIngestUtils utils = new JenaIngestUtils(); utils.doPermanentURI(oldModel, newModel, oldNamespace, newNamespace, maker, vreq); vreq.setAttribute("title", "Ingest Menu"); vreq.setAttribute("bodyJsp", INGEST_MENU_JSP); } }