List of usage examples for java.io UnsupportedEncodingException getStackTrace
public StackTraceElement[] getStackTrace()
From source file:org.bibsonomy.rest.RESTUtils.java
/** * a reader for the provided stream with the provided encoding. If the * encoding is not supported the default encoding is used * /* w w w . j a v a2 s .c om*/ * @param stream * @param encoding * @return the reader for the stream */ public static Reader getInputReaderForStream(final InputStream stream, final String encoding) { if (!present(stream)) return null; try { // returns InputStream with correct encoding return new InputStreamReader(stream, encoding); } catch (UnsupportedEncodingException ex) { // returns InputStream with default encoding if a exception // is thrown with utf-8 support log.fatal(ex.getStackTrace()); return new InputStreamReader(stream); } }
From source file:eu.eco2clouds.api.bonfire.client.rest.RestClient.java
/** * Performs a POST method against the API * @param url -> This URL is going to be converted to API_URL:BONFIRE_PORT/url * @param payload message sent in the post method * @return Response object encapsulation all the HTTP information, it returns <code>null</code> if there was an error. *//* w ww .j a v a 2 s. c o m*/ public static Response executePutMethod(String url, String payload, String username, String password) { Response response = null; try { PutMethod put = new PutMethod(url); // We define the request entity RequestEntity requestEntity = new StringRequestEntity(payload, BONFIRE_XML, null); put.setRequestEntity(requestEntity); response = executeMethod(put, BONFIRE_XML, username, password, url); } catch (UnsupportedEncodingException exception) { System.out.println("THE PAYLOAD ENCODING IS NOT SUPPORTED"); System.out.println("ERROR: " + exception.getMessage()); System.out.println("ERROR: " + exception.getStackTrace()); } return response; }
From source file:eu.eco2clouds.api.bonfire.client.rest.RestClient.java
/** * Performs a POST method against the API * @param url -> This URL is going to be converted to API_URL:BONFIRE_PORT/url * @param payload message sent in the post method * @param type specifies the content type of the request * @return Response object encapsulation all the HTTP information, it returns <code>null</code> if there was an error. */// w ww.j av a 2 s. com public static Response executePostMethod(String url, String username, String password, String payload, String type) { Response response = null; try { PostMethod post = new PostMethod(url); // We define the request entity RequestEntity requestEntity = new StringRequestEntity(payload, type, null); post.setRequestEntity(requestEntity); response = executeMethod(post, BONFIRE_XML, username, password, url); } catch (UnsupportedEncodingException exception) { System.out.println("THE PAYLOAD ENCODING IS NOT SUPPORTED"); System.out.println("ERROR: " + exception.getMessage()); System.out.println("ERROR: " + exception.getStackTrace()); } return response; }
From source file:org.apache.hadoop.mapreduce.v2.jobhistory.FileNameIndexUtils.java
/** * Helper function to decode the URL of the filename of the job-history * log file./*from w ww . j a v a2 s . c om*/ * * @param logFileName file name of the job-history file * @return URL decoded filename * @throws IOException */ public static String decodeJobHistoryFileName(String logFileName) throws IOException { String decodedFileName = null; try { decodedFileName = URLDecoder.decode(logFileName, "UTF-8"); } catch (UnsupportedEncodingException uee) { IOException ioe = new IOException(); ioe.initCause(uee); ioe.setStackTrace(uee.getStackTrace()); throw ioe; } return decodedFileName; }
From source file:org.apache.hadoop.mapreduce.v2.jobhistory.FileNameIndexUtils.java
/** * Helper function to encode the URL of the filename of the job-history * log file./*w ww.j av a 2s. c om*/ * * @param logFileName file name of the job-history file * @return URL encoded filename * @throws IOException */ public static String encodeJobHistoryFileName(String logFileName) throws IOException { String replacementDelimiterEscape = null; // Temporarily protect the escape delimiters from encoding if (logFileName.contains(DELIMITER_ESCAPE)) { replacementDelimiterEscape = nonOccursString(logFileName); logFileName = logFileName.replaceAll(DELIMITER_ESCAPE, replacementDelimiterEscape); } String encodedFileName = null; try { encodedFileName = URLEncoder.encode(logFileName, "UTF-8"); } catch (UnsupportedEncodingException uee) { IOException ioe = new IOException(); ioe.initCause(uee); ioe.setStackTrace(uee.getStackTrace()); throw ioe; } // Restore protected escape delimiters after encoding if (replacementDelimiterEscape != null) { encodedFileName = encodedFileName.replaceAll(replacementDelimiterEscape, DELIMITER_ESCAPE); } return encodedFileName; }
From source file:org.geomajas.plugin.deskmanager.domain.types.XmlSerialisationType.java
private Object fromXmlString(String xmlString) { if (xmlString == null) { return null; }/*ww w. j a v a 2 s . c o m*/ try { ByteArrayInputStream is = new ByteArrayInputStream(xmlString.getBytes(ENCODING)); XMLDecoder decoder = new XMLDecoder(is); return decoder.readObject(); } catch (UnsupportedEncodingException e) { LOG.warn(e.getLocalizedMessage()); IllegalArgumentException ex = new IllegalArgumentException("cannot disassemble the object"); ex.setStackTrace(e.getStackTrace()); throw ex; } }
From source file:edu.cornell.mannlib.vitro.webapp.controller.edit.DatapropEditController.java
public void doPost(HttpServletRequest request, HttpServletResponse response) { if (!isAuthorizedToDisplayPage(request, response, SimplePermission.EDIT_ONTOLOGY.ACTION)) { return;//from www . j a v a 2s .c om } VitroRequest vreq = new VitroRequest(request); final int NUM_COLS = 18; String datapropURI = request.getParameter("uri"); DataPropertyDao dpDao = vreq.getUnfilteredWebappDaoFactory().getDataPropertyDao(); DataPropertyDao dpDaoLangNeut = vreq.getLanguageNeutralWebappDaoFactory().getDataPropertyDao(); VClassDao vcDao = vreq.getLanguageNeutralWebappDaoFactory().getVClassDao(); VClassDao vcDaoWLang = vreq.getUnfilteredWebappDaoFactory().getVClassDao(); DataProperty dp = dpDao.getDataPropertyByURI(datapropURI); DataProperty pLangNeut = dpDaoLangNeut.getDataPropertyByURI(request.getParameter("uri")); PropertyGroupDao pgDao = vreq.getUnfilteredWebappDaoFactory().getPropertyGroupDao(); ArrayList results = new ArrayList(); results.add("data property"); // column 1 results.add("public display label"); // column 2 results.add("property group"); // column 3 results.add("ontology"); // column 4 results.add("RDF local name"); // column 5 results.add("domain class"); // column 6 results.add("range datatype"); // column 7 results.add("functional"); // column 8 results.add("public description"); // column 9 results.add("example"); // column 10 results.add("editor description"); // column 11 results.add("display level"); // column 12 results.add("update level"); // column 13 results.add("display tier"); // column 14 results.add("display limit"); // column 15 results.add("custom entry form"); // column 16 results.add("URI"); // column 17 results.add("publish level"); // column 18 RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); results.add(dp.getPickListName()); // column 1 results.add(dp.getPublicName() == null ? "(no public label)" : dp.getPublicName()); // column 2 if (dp.getGroupURI() != null) { PropertyGroup pGroup = pgDao.getGroupByURI(dp.getGroupURI()); if (pGroup != null) { results.add(pGroup.getName()); // column 3 } else { results.add(dp.getGroupURI()); } } else { results.add("(unspecified)"); } String ontologyName = null; if (dp.getNamespace() != null) { Ontology ont = vreq.getUnfilteredWebappDaoFactory().getOntologyDao() .getOntologyByURI(dp.getNamespace()); if ((ont != null) && (ont.getName() != null)) { ontologyName = ont.getName(); } } results.add(ontologyName == null ? "(not identified)" : ontologyName); // column 4 results.add(dp.getLocalName()); // column 5 // we support parents now, but not the simple getParent() style method //String parentPropertyStr = "<i>(datatype properties are not yet modeled in a property hierarchy)</i>"; // TODO - need multiple inheritance //results.add(parentPropertyStr); String domainStr = ""; if (pLangNeut.getDomainVClassURI() != null) { VClass domainClass = vcDao.getVClassByURI(pLangNeut.getDomainVClassURI()); VClass domainWLang = vcDaoWLang.getVClassByURI(pLangNeut.getDomainVClassURI()); if (domainClass != null && domainClass.getURI() != null && domainClass.getPickListName() != null) { try { if (domainClass.isAnonymous()) { domainStr = domainClass.getPickListName(); } else { domainStr = "<a href=\"vclassEdit?uri=" + URLEncoder.encode(domainClass.getURI(), "UTF-8") + "\">" + domainWLang.getPickListName() + "</a>"; } } catch (UnsupportedEncodingException e) { log.error(e, e); } } } results.add(domainStr); // column 6 String rangeStr = (dp.getRangeDatatypeURI() == null) ? "<i>untyped</i> (rdfs:Literal)" : dp.getRangeDatatypeURI(); results.add(rangeStr); // column 7 results.add(dp.getFunctional() ? "true" : "false"); // column 8 String publicDescriptionStr = (dp.getPublicDescription() == null) ? "" : dp.getPublicDescription(); // column 9 results.add(publicDescriptionStr); String exampleStr = (dp.getExample() == null) ? "" : dp.getExample(); // column 10 results.add(exampleStr); String descriptionStr = (dp.getDescription() == null) ? "" : dp.getDescription(); // column 11 results.add(descriptionStr); results.add(dp.getHiddenFromDisplayBelowRoleLevel() == null ? "(unspecified)" : dp.getHiddenFromDisplayBelowRoleLevel().getDisplayLabel()); // column 12 results.add(dp.getProhibitedFromUpdateBelowRoleLevel() == null ? "(unspecified)" : dp.getProhibitedFromUpdateBelowRoleLevel().getUpdateLabel()); // column 13 results.add(String.valueOf(dp.getDisplayTier())); // column 14 results.add(String.valueOf(dp.getDisplayLimit())); // column 15 results.add(dp.getCustomEntryForm() == null ? "(unspecified)" : dp.getCustomEntryForm()); // column 16 results.add(dp.getURI() == null ? "" : dp.getURI()); // column 17 results.add(dp.getHiddenFromPublishBelowRoleLevel() == null ? "(unspecified)" : dp.getHiddenFromPublishBelowRoleLevel().getDisplayLabel()); // column 18 request.setAttribute("results", results); request.setAttribute("columncount", NUM_COLS); request.setAttribute("suppressquery", "true"); boolean FORCE_NEW = true; EditProcessObject epo = super.createEpo(request, FORCE_NEW); FormObject foo = new FormObject(); HashMap OptionMap = new HashMap(); // add the options foo.setOptionLists(OptionMap); epo.setFormObject(foo); DataPropertyDao assertionsDpDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getDataPropertyDao(); List<DataProperty> superProps = getDataPropertiesForURIList( assertionsDpDao.getSuperPropertyURIs(dp.getURI(), false), assertionsDpDao); sortForPickList(superProps, vreq); request.setAttribute("superproperties", superProps); List<DataProperty> subProps = getDataPropertiesForURIList(assertionsDpDao.getSubPropertyURIs(dp.getURI()), assertionsDpDao); sortForPickList(subProps, vreq); request.setAttribute("subproperties", subProps); List<DataProperty> eqProps = getDataPropertiesForURIList( assertionsDpDao.getEquivalentPropertyURIs(dp.getURI()), assertionsDpDao); sortForPickList(eqProps, vreq); request.setAttribute("equivalentProperties", eqProps); ApplicationBean appBean = vreq.getAppBean(); request.setAttribute("epoKey", epo.getKey()); request.setAttribute("datatypeProperty", dp); request.setAttribute("bodyJsp", "/templates/edit/specific/dataprops_edit.jsp"); request.setAttribute("title", "Data Property Control Panel"); request.setAttribute("css", "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + appBean.getThemeDir() + "css/edit.css\"/>"); try { rd.forward(request, response); } catch (Exception e) { log.error("DatapropEditController could not forward to view."); log.error(e.getMessage()); log.error(e.getStackTrace()); } }
From source file:com.gimranov.zandy.app.task.APIRequest.java
/** * Issues the specified request, calling its specified handler as appropriate * * This should not be run from a UI thread * * @return/*from w w w .j a va 2 s .c o m*/ * @throws APIException */ public void issue(Database db, ServerCredentials cred) throws APIException { URI uri; // Add the API key, if missing and we have it if (!query.contains("key=") && key != null) { String suffix = (query.contains("?")) ? "&key=" + key : "?key=" + key; query = query + suffix; } // Force lower-case method = method.toLowerCase(); Log.i(TAG, "Request " + method + ": " + query); try { uri = new URI(query); } catch (URISyntaxException e1) { throw new APIException(APIException.INVALID_URI, "Invalid URI: " + query, this); } HttpClient client = new DefaultHttpClient(); // The default implementation includes an Expect: header, which // confuses the Zotero servers. client.getParams().setParameter("http.protocol.expect-continue", false); // We also need to send our data nice and raw. client.getParams().setParameter("http.protocol.content-charset", "UTF-8"); HttpGet get = new HttpGet(uri); HttpPost post = new HttpPost(uri); HttpPut put = new HttpPut(uri); HttpDelete delete = new HttpDelete(uri); for (HttpRequest request : Arrays.asList(get, post, put, delete)) { request.setHeader("Zotero-API-Version", "1"); } // There are several shared initialization routines for POST and PUT if ("post".equals(method) || "put".equals(method)) { if (ifMatch != null) { post.setHeader("If-Match", ifMatch); put.setHeader("If-Match", ifMatch); } if (contentType != null) { post.setHeader("Content-Type", contentType); put.setHeader("Content-Type", contentType); } if (body != null) { Log.d(TAG, "Request body: " + body); // Force the encoding to UTF-8 StringEntity entity; try { entity = new StringEntity(body, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new APIException(APIException.INVALID_UUID, "UnsupportedEncodingException. This shouldn't " + "be possible-- UTF-8 is certainly supported", this); } post.setEntity(entity); put.setEntity(entity); } } if ("get".equals(method)) { if (contentType != null) { get.setHeader("Content-Type", contentType); } } /* For requests that return Atom feeds or entries (XML): * ITEMS_ALL ] * ITEMS_FOR_COLLECTION ]- Except format=keys * ITEMS_CHILDREN ] * * ITEM_BY_KEY * COLLECTIONS_ALL * ITEM_NEW * ITEM_UPDATE * ITEM_ATTACHMENT_NEW * ITEM_ATTACHMENT_UPDATE */ if ("xml".equals(disposition)) { XMLResponseParser parse = new XMLResponseParser(this); // These types will always have a temporary key that we've // been using locally, and which should be replaced by the // incoming item key. if (type == ITEM_NEW || type == ITEM_ATTACHMENT_NEW) { parse.update(updateType, updateKey); } try { HttpResponse hr; if ("post".equals(method)) { hr = client.execute(post); } else if ("put".equals(method)) { hr = client.execute(put); } else { // We fall back on GET here, but there really // shouldn't be anything else, so we throw in that case // for good measure if (!"get".equals(method)) { throw new APIException(APIException.INVALID_METHOD, "Unexpected method: " + method, this); } hr = client.execute(get); } // Record the response code status = hr.getStatusLine().getStatusCode(); Log.d(TAG, status + " : " + hr.getStatusLine().getReasonPhrase()); if (status < 400) { HttpEntity he = hr.getEntity(); InputStream in = he.getContent(); parse.setInputStream(in); // Entry mode if the request is an update (PUT) or if it is a request // for a single item by key (ITEM_BY_KEY) int mode = ("put".equals(method) || type == APIRequest.ITEM_BY_KEY) ? XMLResponseParser.MODE_ENTRY : XMLResponseParser.MODE_FEED; try { parse.parse(mode, uri.toString(), db); } catch (RuntimeException e) { throw new RuntimeException("Parser threw exception on request: " + method + " " + query, e); } } else { ByteArrayOutputStream ostream = new ByteArrayOutputStream(); hr.getEntity().writeTo(ostream); Log.e(TAG, "Error Body: " + ostream.toString()); Log.e(TAG, "Request Body:" + body); if (status == 412) { // This is: "Precondition Failed", meaning that we provided // the wrong etag to update the item. That should mean that // there is a conflict between what we're sending (PUT) and // the server. We mark that ourselves and save the request // to the database, and also notify our handler. getHandler().onError(this, APIRequest.HTTP_ERROR_CONFLICT); } else { Log.e(TAG, "Response status " + status + " : " + ostream.toString()); getHandler().onError(this, APIRequest.HTTP_ERROR_UNSPECIFIED); } status = getHttpStatus() + REQ_FAILING; recordAttempt(db); // I'm not sure whether we should throw here throw new APIException(APIException.HTTP_ERROR, ostream.toString(), this); } } catch (Exception e) { StringBuilder sb = new StringBuilder(); for (StackTraceElement el : e.getStackTrace()) { sb.append(el.toString() + "\n"); } recordAttempt(db); throw new APIException(APIException.HTTP_ERROR, "An IOException was thrown: " + sb.toString(), this); } } // end if ("xml".equals(disposition)) {..} /* For requests that return non-XML data: * ITEMS_ALL ] * ITEMS_FOR_COLLECTION ]- For format=keys * ITEMS_CHILDREN ] * * No server response: * ITEM_DELETE * ITEM_MEMBERSHIP_ADD * ITEM_MEMBERSHIP_REMOVE * ITEM_ATTACHMENT_DELETE * * Currently not supported; return JSON: * ITEM_FIELDS * CREATOR_TYPES * ITEM_FIELDS_L10N * CREATOR_TYPES_L10N * * These ones use BasicResponseHandler, which gives us * the response as a basic string. This is only appropriate * for smaller responses, since it means we have to wait until * the entire response is received before parsing it, so we * don't use it for the XML responses. * * The disposition here is "none" or "raw". * * The JSON-returning requests, such as ITEM_FIELDS, are not currently * supported; they should have a disposition of their own. */ else { BasicResponseHandler brh = new BasicResponseHandler(); String resp; try { if ("post".equals(method)) { resp = client.execute(post, brh); } else if ("put".equals(method)) { resp = client.execute(put, brh); } else if ("delete".equals(method)) { resp = client.execute(delete, brh); } else { // We fall back on GET here, but there really // shouldn't be anything else, so we throw in that case // for good measure if (!"get".equals(method)) { throw new APIException(APIException.INVALID_METHOD, "Unexpected method: " + method, this); } resp = client.execute(get, brh); } } catch (IOException e) { StringBuilder sb = new StringBuilder(); for (StackTraceElement el : e.getStackTrace()) { sb.append(el.toString() + "\n"); } recordAttempt(db); throw new APIException(APIException.HTTP_ERROR, "An IOException was thrown: " + sb.toString(), this); } if ("raw".equals(disposition)) { /* * The output should be a newline-delimited set of alphanumeric * keys. */ String[] keys = resp.split("\n"); ArrayList<String> missing = new ArrayList<String>(); if (type == ITEMS_ALL || type == ITEMS_FOR_COLLECTION) { // Try to get a parent collection // Our query looks like this: // /users/5770/collections/2AJUSIU9/items int colloc = query.indexOf("/collections/"); int itemloc = query.indexOf("/items"); // The string "/collections/" is thirteen characters long ItemCollection coll = ItemCollection.load(query.substring(colloc + 13, itemloc), db); if (coll != null) { coll.loadChildren(db); // If this is a collection's key listing, we first look // for any synced keys we have that aren't in the list ArrayList<String> keyAL = new ArrayList<String>(Arrays.asList(keys)); ArrayList<Item> notThere = coll.notInKeys(keyAL); // We should then remove those memberships for (Item i : notThere) { coll.remove(i, true, db); } } ArrayList<Item> recd = new ArrayList<Item>(); for (int j = 0; j < keys.length; j++) { Item got = Item.load(keys[j], db); if (got == null) { missing.add(keys[j]); } else { // We can update the collection membership immediately if (coll != null) coll.add(got, true, db); recd.add(got); } } if (coll != null) { coll.saveChildren(db); coll.save(db); } Log.d(TAG, "Received " + keys.length + " keys, " + missing.size() + " missing ones"); Log.d(TAG, "Have " + (double) recd.size() / keys.length + " of list"); if (recd.size() == keys.length) { Log.d(TAG, "No new items"); succeeded(db); } else if ((double) recd.size() / keys.length < REREQUEST_CUTOFF) { Log.d(TAG, "Requesting full list"); APIRequest mReq; if (type == ITEMS_FOR_COLLECTION) { mReq = fetchItems(coll, false, cred); } else { mReq = fetchItems(false, cred); } mReq.status = REQ_NEW; mReq.save(db); } else { Log.d(TAG, "Requesting " + missing.size() + " items one by one"); APIRequest mReq; for (String key : missing) { // Queue request for the missing key mReq = fetchItem(key, cred); mReq.status = REQ_NEW; mReq.save(db); } // Queue request for the collection again, by key // XXX This is not the best way to make sure these // items are put in the correct collection. if (type == ITEMS_FOR_COLLECTION) { fetchItems(coll, true, cred).save(db); } } } else if (type == ITEMS_CHILDREN) { // Try to get a parent item // Our query looks like this: // /users/5770/items/2AJUSIU9/children int itemloc = query.indexOf("/items/"); int childloc = query.indexOf("/children"); // The string "/items/" is seven characters long Item item = Item.load(query.substring(itemloc + 7, childloc), db); ArrayList<Attachment> recd = new ArrayList<Attachment>(); for (int j = 0; j < keys.length; j++) { Attachment got = Attachment.load(keys[j], db); if (got == null) missing.add(keys[j]); else recd.add(got); } if ((double) recd.size() / keys.length < REREQUEST_CUTOFF) { APIRequest mReq; mReq = cred.prep(children(item)); mReq.status = REQ_NEW; mReq.save(db); } else { APIRequest mReq; for (String key : missing) { // Queue request for the missing key mReq = fetchItem(key, cred); mReq.status = REQ_NEW; mReq.save(db); } } } } else if ("json".equals(disposition)) { // TODO } else { /* Here, disposition should be "none" */ // Nothing to be done. } getHandler().onComplete(this); } }
From source file:edu.cornell.mannlib.vitro.webapp.controller.edit.PropertyEditController.java
@Override public void doPost(HttpServletRequest request, HttpServletResponse response) { if (!isAuthorizedToDisplayPage(request, response, SimplePermission.EDIT_ONTOLOGY.ACTION)) { return;/* w w w. j a v a 2s . c o m*/ } final int NUM_COLS = 26; VitroRequest vreq = new VitroRequest(request); ObjectPropertyDao propDao = vreq.getUnfilteredWebappDaoFactory().getObjectPropertyDao(); ObjectPropertyDao propDaoLangNeut = vreq.getLanguageNeutralWebappDaoFactory().getObjectPropertyDao(); VClassDao vcDao = vreq.getLanguageNeutralWebappDaoFactory().getVClassDao(); VClassDao vcDaoWLang = vreq.getUnfilteredWebappDaoFactory().getVClassDao(); PropertyGroupDao pgDao = vreq.getUnfilteredWebappDaoFactory().getPropertyGroupDao(); ObjectProperty p = propDao.getObjectPropertyByURI(request.getParameter("uri")); ObjectProperty pLangNeut = propDaoLangNeut.getObjectPropertyByURI(request.getParameter("uri")); request.setAttribute("property", p); ArrayList<String> results = new ArrayList<String>(); results.add("property"); // column 1 results.add("parent property"); // column 2 results.add("property group"); // column 3 results.add("ontology"); // column 4 results.add("RDF local name"); // column 5 results.add("public display label"); // column 6 results.add("domain class"); // column 7 results.add("range class"); // column 8 results.add("transitive"); // column 9 results.add("symmetric"); // column 10 results.add("functional"); // column 11 results.add("inverse functional"); // column 12 results.add("public description"); // column 13 results.add("example"); // column 14 results.add("editor description"); // column 15 results.add("display level"); // column 16 results.add("update level"); // column 17 results.add("display tier"); // column 18 results.add("display limit"); // column 15 results.add("collate by subclass"); // column 19 results.add("custom entry form"); // column 20 results.add("select from existing"); // column 21 results.add("offer create new"); // column 22 results.add("sort direction"); // column 23 results.add("URI"); // column 24 results.add("publish level"); // column 25 results.add(p.getPickListName()); // column 1 String parentPropertyStr = ""; if (p.getParentURI() != null) { ObjectProperty parent = propDao.getObjectPropertyByURI(p.getParentURI()); if (parent != null && parent.getURI() != null) { try { parentPropertyStr = "<a href=\"propertyEdit?uri=" + URLEncoder.encode(parent.getURI(), "UTF-8") + "\">" + parent.getPickListName() + "</a>"; } catch (UnsupportedEncodingException e) { log.error(e, e); } } } results.add(parentPropertyStr); // column 2 if (p.getGroupURI() != null) { PropertyGroup pGroup = pgDao.getGroupByURI(p.getGroupURI()); if (pGroup != null) { results.add(pGroup.getName()); // column 3 } else { results.add("(unnamed group)"); // column 3 } } else { results.add("(unspecified)"); // column 3 } String ontologyName = null; if (p.getNamespace() != null) { Ontology ont = vreq.getUnfilteredWebappDaoFactory().getOntologyDao().getOntologyByURI(p.getNamespace()); if ((ont != null) && (ont.getName() != null)) { ontologyName = ont.getName(); } } results.add(ontologyName == null ? "(not identified)" : ontologyName); // column 4 results.add(p.getLocalName()); // column 5 results.add(p.getDomainPublic() == null ? "(no public label)" : p.getDomainPublic()); // column 6 String domainStr = ""; if (pLangNeut.getDomainVClassURI() != null) { VClass domainClass = vcDao.getVClassByURI(pLangNeut.getDomainVClassURI()); VClass domainWLang = vcDaoWLang.getVClassByURI(pLangNeut.getDomainVClassURI()); if (domainClass != null && domainClass.getURI() != null && domainClass.getPickListName() != null) { try { if (domainClass.isAnonymous()) { domainStr = domainClass.getPickListName(); } else { domainStr = "<a href=\"vclassEdit?uri=" + URLEncoder.encode(domainClass.getURI(), "UTF-8") + "\">" + domainWLang.getPickListName() + "</a>"; } } catch (UnsupportedEncodingException e) { log.error(e, e); } } } results.add(domainStr); // column 7 String rangeStr = ""; if (pLangNeut.getRangeVClassURI() != null) { VClass rangeClass = vcDao.getVClassByURI(pLangNeut.getRangeVClassURI()); VClass rangeWLang = vcDaoWLang.getVClassByURI(pLangNeut.getRangeVClassURI()); if (rangeClass != null && rangeClass.getURI() != null && rangeClass.getPickListName() != null) { try { if (rangeClass.isAnonymous()) { rangeStr = rangeClass.getPickListName(); } else { rangeStr = "<a href=\"vclassEdit?uri=" + URLEncoder.encode(rangeClass.getURI(), "UTF-8") + "\">" + rangeWLang.getPickListName() + "</a>"; } } catch (UnsupportedEncodingException e) { log.error(e, e); } } } results.add(rangeStr); // column 8 results.add(p.getTransitive() ? "true" : "false"); // column 9 results.add(p.getSymmetric() ? "true" : "false"); // column 10 results.add(p.getFunctional() ? "true" : "false"); // column 11 results.add(p.getInverseFunctional() ? "true" : "false"); // column 12 String publicDescriptionStr = (p.getPublicDescription() == null) ? "" : p.getPublicDescription(); results.add(publicDescriptionStr); // column 13 String exampleStr = (p.getExample() == null) ? "" : p.getExample(); results.add(exampleStr); // column 14 String descriptionStr = (p.getDescription() == null) ? "" : p.getDescription(); results.add(descriptionStr); // column 15 results.add(p.getHiddenFromDisplayBelowRoleLevel() == null ? "(unspecified)" : p.getHiddenFromDisplayBelowRoleLevel().getDisplayLabel()); // column 16 results.add(p.getProhibitedFromUpdateBelowRoleLevel() == null ? "(unspecified)" : p.getProhibitedFromUpdateBelowRoleLevel().getUpdateLabel()); // column 17 results.add("property: " + p.getDomainDisplayTier() + ", inverse: " + p.getRangeDisplayTier()); // column 18 results.add("property: " + p.getDomainDisplayLimitInteger() + ", inverse: " + p.getRangeDisplayLimit()); results.add(p.getCollateBySubclass() ? "true" : "false"); // column 19 results.add(p.getCustomEntryForm() == null ? "(unspecified)" : p.getCustomEntryForm()); // column 20 results.add(p.getSelectFromExisting() ? "true" : "false"); // column 21 results.add(p.getOfferCreateNewOption() ? "true" : "false"); // column 22 results.add(p.getDomainEntitySortDirection() == null ? "ascending" : p.getDomainEntitySortDirection()); // column 23 results.add(p.getURI()); // column 24 results.add(p.getHiddenFromPublishBelowRoleLevel() == null ? "(unspecified)" : p.getHiddenFromPublishBelowRoleLevel().getDisplayLabel()); // column 25 request.setAttribute("results", results); request.setAttribute("columncount", NUM_COLS); request.setAttribute("suppressquery", "true"); EditProcessObject epo = super.createEpo(request, FORCE_NEW); FormObject foo = new FormObject(); HashMap<String, List<Option>> OptionMap = new HashMap<>(); foo.setOptionLists(OptionMap); epo.setFormObject(foo); // superproperties and subproperties ObjectPropertyDao opDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getObjectPropertyDao(); List<ObjectProperty> superProps = getObjectPropertiesForURIList( opDao.getSuperPropertyURIs(p.getURI(), false), opDao); sortForPickList(superProps, vreq); request.setAttribute("superproperties", superProps); List<ObjectProperty> subProps = getObjectPropertiesForURIList(opDao.getSubPropertyURIs(p.getURI()), opDao); sortForPickList(subProps, vreq); request.setAttribute("subproperties", subProps); // equivalent properties and faux properties List<ObjectProperty> eqProps = getObjectPropertiesForURIList(opDao.getEquivalentPropertyURIs(p.getURI()), opDao); sortForPickList(eqProps, vreq); request.setAttribute("equivalentProperties", eqProps); List<FauxProperty> fauxProps = vreq.getUnfilteredAssertionsWebappDaoFactory().getFauxPropertyDao() .getFauxPropertiesForBaseUri(p.getURI()); sortForPickList(fauxProps, vreq); request.setAttribute("fauxproperties", fauxProps); RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); request.setAttribute("epoKey", epo.getKey()); request.setAttribute("propertyWebapp", p); request.setAttribute("bodyJsp", "/templates/edit/specific/props_edit.jsp"); request.setAttribute("title", "Object Property Control Panel"); request.setAttribute("css", "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + vreq.getAppBean().getThemeDir() + "css/edit.css\"/>"); try { rd.forward(request, response); } catch (Exception e) { log.error("PropertyEditController could not forward to view."); log.error(e.getMessage()); log.error(e.getStackTrace()); } }