List of usage examples for java.net URISyntaxException getMessage
public String getMessage()
From source file:org.apache.axis2.jaxws.description.impl.URIResolverImpl.java
public InputSource resolveEntity(String namespace, String schemaLocation, String baseUri) { if (log.isDebugEnabled()) { log.debug("resolveEntity: [" + namespace + "][" + schemaLocation + "][ " + baseUri + "]"); }//from www . jav a 2 s. com InputStream is = null; URI pathURI = null; String pathURIStr = null; if (log.isDebugEnabled()) { log.debug("Import location: " + schemaLocation + " parent document: " + baseUri); } if (baseUri != null) { try { // if the location is an absolute path, build a URL directly // from it if (log.isDebugEnabled()) { log.debug("Base URI not null"); } if (isAbsolute(schemaLocation)) { if (log.isDebugEnabled()) { log.debug("Retrieving input stream for absolute schema location: " + schemaLocation); } is = getInputStreamForURI(schemaLocation); } else { if (log.isDebugEnabled()) { log.debug("schemaLocation not in absolute path"); } try { pathURI = new URI(baseUri); } catch (URISyntaxException e) { // Got URISyntaxException, Creation of URI requires // that we use special escape characters in path. // The URI constructor below does this for us, so lets use that. if (log.isDebugEnabled()) { log.debug("Got URISyntaxException. Exception Message = " + e.getMessage()); log.debug("Implementing alternate way to create URI"); } pathURI = new URI(null, null, baseUri, null); } pathURIStr = schemaLocation; // If this is absolute we need to resolve the path without the // scheme information if (pathURI.isAbsolute()) { if (log.isDebugEnabled()) { log.debug("Parent document is at absolute location: " + pathURI.toString()); } URL url = new URL(baseUri); if (url != null) { URI tempURI; try { tempURI = new URI(url.getPath()); } catch (URISyntaxException e) { //Got URISyntaxException, Creation of URI requires // that we use special escape characters in path. // The URI constructor below does this for us, so lets use that. if (log.isDebugEnabled()) { log.debug("Got URISyntaxException. Exception Message = " + e.getMessage()); log.debug("Implementing alternate way to create URI"); } tempURI = new URI(null, null, url.getPath(), null); } URI resolvedURI = tempURI.resolve(schemaLocation); // Add back the scheme to the resolved path pathURIStr = constructPath(url, resolvedURI); if (log.isDebugEnabled()) { log.debug("Resolved this path to imported document: " + pathURIStr); } } } else { if (log.isDebugEnabled()) { log.debug("Parent document is at relative location: " + pathURI.toString()); } pathURI = pathURI.resolve(schemaLocation); pathURIStr = pathURI.toString(); if (log.isDebugEnabled()) { log.debug("Resolved this path to imported document: " + pathURIStr); } } // If path is absolute, build URL directly from it if (isAbsolute(pathURIStr)) { is = getInputStreamForURI(pathURIStr); } // if the location is relative, we need to resolve the // location using // the baseURI, then use the loadStrategy to gain an input // stream // because the URI will still be relative to the module if (is == null) { is = classLoader.getResourceAsStream(pathURI.toString()); } } } catch (Exception e) { if (log.isDebugEnabled()) { log.debug("Exception occured in resolveEntity, ignoring exception continuing processing " + e.getMessage()); log.debug(e); } } } if (is == null) { if (log.isDebugEnabled()) { log.debug("XSD input stream is null after resolving import for: " + schemaLocation + " from parent document: " + baseUri); } } else { if (log.isDebugEnabled()) { log.debug("XSD input stream is not null after resolving import for: " + schemaLocation + " from parent document: " + baseUri); } } InputSource returnInputSource = new InputSource(is); // We need to set the systemId. XmlSchema will use this value to maintain a collection of // imported XSDs that have been read. If this value is null, then circular XSDs will // cause infinite recursive reads. returnInputSource.setSystemId(pathURIStr != null ? pathURIStr : schemaLocation); if (log.isDebugEnabled()) { log.debug("returnInputSource :" + returnInputSource.getSystemId()); } return returnInputSource; }
From source file:org.apache.fop.afp.fonts.CharacterSetBuilder.java
/** * Returns an InputStream to a given file path and filename * * * @param accessor the resource accessor * @param filename the file name/*from w w w. j a v a 2 s . c om*/ * @param eventProducer for handling AFP related events * @return an inputStream * * @throws IOException in the event that an I/O exception of some sort has occurred */ protected InputStream openInputStream(ResourceAccessor accessor, String filename, AFPEventProducer eventProducer) throws IOException { URI uri; try { uri = new URI(filename.trim()); } catch (URISyntaxException e) { throw new FileNotFoundException("Invalid filename: " + filename + " (" + e.getMessage() + ")"); } if (LOG.isDebugEnabled()) { LOG.debug("Opening " + uri); } InputStream inputStream = accessor.createInputStream(uri); return inputStream; }
From source file:org.hfoss.posit.android.web.Communicator.java
/** * A wrapper(does some cleanup too) for sending HTTP GET requests to the URI * // w w w .j a v a2 s . c om * @param Uri * @return the request from the remote server */ public String doHTTPGET(String Uri) { if (Uri == null) throw new NullPointerException("The URL has to be passed"); String responseString = null; HttpGet httpGet = new HttpGet(); try { httpGet.setURI(new URI(Uri)); } catch (URISyntaxException e) { Log.e(TAG, "doHTTPGet " + e.getMessage()); e.printStackTrace(); return "[Error] " + e.getMessage(); } if (Utils.debug) { Log.i(TAG, "doHTTPGet Uri = " + Uri); } ResponseHandler<String> responseHandler = new BasicResponseHandler(); mStart = System.currentTimeMillis(); try { responseString = mHttpClient.execute(httpGet, responseHandler); } catch (ClientProtocolException e) { Log.e(TAG, "ClientProtocolException" + e.getMessage()); e.printStackTrace(); return "[Error] " + e.getMessage(); } catch (SocketTimeoutException e) { Log.e(TAG, "[Error: SocketTimeoutException]" + e.getMessage()); e.printStackTrace(); return "[Error] " + e.getMessage(); } catch (IOException e) { Log.e(TAG, e.getMessage()); e.printStackTrace(); return "[Error] " + e.getMessage(); } catch (Exception e) { Log.e(TAG, e.getMessage()); e.printStackTrace(); return "[Error] " + e.getMessage(); } long time = System.currentTimeMillis() - mStart; mTotalTime += time; Log.i(TAG, "TIME = " + time + " millisecs"); if (Utils.debug) Log.i(TAG, "doHTTPGet Response: " + responseString); return responseString; }
From source file:org.hfoss.posit.android.web.Communicator.java
/** * Sends a HttpPost request to the given URL. Any JSON * /*from www .ja v a 2s .co m*/ * @param Uri * the URL to send to/receive from * @param sendMap * the hashMap of data to send to the server as POST data * @return the response from the URL */ private String doHTTPPost(String Uri, HashMap<String, String> sendMap) { long startTime = System.currentTimeMillis(); if (Uri == null) throw new NullPointerException("The URL has to be passed"); String responseString = null; HttpPost post = new HttpPost(); if (Utils.debug) Log.i(TAG, "doHTTPPost() URI = " + Uri); try { post.setURI(new URI(Uri)); } catch (URISyntaxException e) { Log.e(TAG, "URISyntaxException " + e.getMessage()); e.printStackTrace(); return "[Error] " + e.getMessage(); } List<NameValuePair> nvp = PositHttpUtils.getNameValuePairs(sendMap); ResponseHandler<String> responseHandler = new BasicResponseHandler(); try { post.setEntity(new UrlEncodedFormEntity(nvp, HTTP.UTF_8)); } catch (UnsupportedEncodingException e) { Log.e(TAG, "UnsupportedEncodingException " + e.getMessage()); return "[Error] " + e.getMessage(); } mStart = System.currentTimeMillis(); try { responseString = mHttpClient.execute(post, responseHandler); Log.d(TAG, "doHTTPpost responseString = " + responseString); } catch (ClientProtocolException e) { Log.e(TAG, "ClientProtocolException" + e.getMessage()); e.printStackTrace(); return "[Error] " + e.getMessage(); } catch (IOException e) { Log.e(TAG, "IOException " + e.getMessage()); e.printStackTrace(); return "[Error] " + e.getMessage(); } catch (IllegalStateException e) { Log.e(TAG, "IllegalStateException: " + e.getMessage()); e.printStackTrace(); return "[Error] " + e.getMessage(); } catch (Exception e) { Log.e(TAG, "Exception on HttpPost " + e.getMessage()); e.printStackTrace(); return "[Error] " + e.getMessage(); } long time = System.currentTimeMillis() - startTime; mTotalTime += time; Log.i(TAG, "doHTTPpost response = " + responseString + " TIME = " + time + " millisecs"); return responseString; }
From source file:com.visionspace.jenkins.vstart.plugin.VSPluginPerformer.java
public boolean logToWorkspace(Long reportId, AbstractBuild build, BuildListener listener) { try {/*from w w w. j a v a 2 s . com*/ org.json.JSONObject report = vstObject.getReport(reportId); FilePath jPath = new FilePath(build.getWorkspace(), build.getWorkspace().toString() + "/VSTART_JSON"); if (!jPath.exists()) { jPath.mkdirs(); } String filePath = jPath + "/VSTART_JSON_" + build.getId() + ".json"; JSONArray reports; try { String content = new String(Files.readAllBytes(Paths.get(filePath))); reports = new JSONArray(content); } catch (IOException e) { Logger.getLogger(VSPluginPerformer.class.getName()).log(Level.WARNING, null, e); reports = new JSONArray(); } reports.put(report); PrintWriter wj = new PrintWriter(filePath); wj.println(reports.toString()); wj.close(); //TODO: check test case result /* if (report.getString("status").equals("PASSED")) { */ return true; /* } */ } catch (URISyntaxException ex) { Logger.getLogger(VSPluginPerformer.class.getName()).log(Level.SEVERE, null, ex); listener.getLogger().println("Error on performing the workspace logging -> " + ex.getReason()); } catch (IOException ex) { Logger.getLogger(VSPluginPerformer.class.getName()).log(Level.SEVERE, null, ex); listener.getLogger().println("Error on performing the workspace logging -> " + ex.toString()); } catch (InterruptedException ex) { Logger.getLogger(VSPluginPerformer.class.getName()).log(Level.SEVERE, null, ex); listener.getLogger().println("Error on performing the workspace logging -> " + ex.getMessage()); } return false; }
From source file:org.dspace.identifier.EZIDIdentifierProvider.java
@Override public String mint(Context context, DSpaceObject dso) throws IdentifierException { log.debug("mint for {}", dso); // Compose the request EZIDRequest request;/*from ww w . ja va2 s . c o m*/ try { request = createRequest(context, dso); } catch (URISyntaxException ex) { log.error(ex.getMessage()); throw new IdentifierException("DOI request not sent: " + ex.getMessage()); } // Send the request EZIDResponse response; try { Map<String, String> ezidMetadata = fillMetadataDefaults(crosswalkMetadata(dso), context, dso); response = request.mint(ezidMetadata); } catch (IOException ex) { log.error("Failed to send EZID request: {}", ex.getMessage()); throw new IdentifierException("DOI request not sent: " + ex.getMessage()); } catch (URISyntaxException ex) { log.error("Failed to send EZID request: {}", ex.getMessage()); throw new IdentifierException("DOI request not sent: " + ex.getMessage()); } // Good response? if (HttpURLConnection.HTTP_CREATED != response.getHttpStatusCode()) { log.error("EZID server responded: {} {}: {}", new String[] { String.valueOf(response.getHttpStatusCode()), response.getHttpReasonPhrase(), response.getEZIDStatusValue() }); throw new IdentifierException( "DOI not created: " + response.getHttpReasonPhrase() + ": " + response.getEZIDStatusValue()); } // Extract the DOI from the content blob if (response.isSuccess()) { String value = response.getEZIDStatusValue(); int end = value.indexOf('|'); // Following pipe is "shadow ARK" if (end < 0) { end = value.length(); } String doi = value.substring(0, end).trim(); String uri = uriForId(context, dso, doi); return uri; } else { log.error("EZID responded: {}", response.getEZIDStatusValue()); throw new IdentifierException("No DOI returned"); } }
From source file:org.dspace.identifier.EZIDIdentifierProvider.java
@Override public void delete(Context context, DSpaceObject dso) throws IdentifierException { log.debug("delete {}", dso); if (!(dso instanceof Item)) { throw new IllegalArgumentException("Unsupported type " + dso.getTypeText()); }//from www .ja v a2 s. c om Item item = (Item) dso; // delete from EZID DCValue[] metadata = item.getMetadata(MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null); List<String> remainder = new ArrayList<String>(); int skipped = 0; for (DCValue id : metadata) { if (!supports(id.value)) { remainder.add(id.value); continue; } EZIDResponse response; try { EZIDRequest request = createRequest(context, dso); response = request.delete(DOIToId(id.value, context, dso)); } catch (URISyntaxException e) { log.error("Bad URI in metadata value: {}", e.getMessage()); remainder.add(id.value); skipped++; continue; } catch (IOException e) { log.error("Failed request to EZID: {}", e.getMessage()); remainder.add(id.value); skipped++; continue; } if (!response.isSuccess()) { log.error("Unable to delete {} from DataCite: {}", id.value, response.getEZIDStatusValue()); remainder.add(id.value); skipped++; continue; } log.info("Deleted {}", id.value); } // delete from item item.clearMetadata(MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null); item.addMetadata(MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null, remainder.toArray(new String[remainder.size()])); try { item.update(); context.commit(); } catch (SQLException e) { log.error("Failed to re-add identifiers: {}", e.getMessage()); } catch (AuthorizeException e) { log.error("Failed to re-add identifiers: {}", e.getMessage()); } if (skipped > 0) { throw new IdentifierException(skipped + " identifiers could not be deleted."); } }
From source file:org.accada.epcis.repository.capture.CaptureOperationsModule.java
/** * TODO: javadoc!// w w w .j a va2 s . c o m * * @param textContent * @return * @throws InvalidFormatException */ private boolean checkUri(String textContent) throws InvalidFormatException { try { new URI(textContent); } catch (URISyntaxException e) { throw new InvalidFormatException(e.getMessage(), e); } return true; }
From source file:org.dspace.identifier.EZIDIdentifierProvider.java
@Override public void delete(Context context, DSpaceObject dso, String identifier) throws IdentifierException { log.debug("delete {} from {}", identifier, dso); if (!(dso instanceof Item)) { throw new IllegalArgumentException("Unsupported type " + dso.getTypeText()); }/* ww w . j a v a 2 s . co m*/ Item item = (Item) dso; DCValue[] metadata = item.getMetadata(MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null); List<String> remainder = new ArrayList<String>(); int skipped = 0; for (DCValue id : metadata) { if (!id.value.equals(idToDOI(identifier, context, dso))) { remainder.add(id.value); continue; } EZIDResponse response; try { EZIDRequest request = createRequest(context, dso); response = request.delete(DOIToId(id.value, context, dso)); } catch (URISyntaxException e) { log.error("Bad URI in metadata value {}: {}", id.value, e.getMessage()); remainder.add(id.value); skipped++; continue; } catch (IOException e) { log.error("Failed request to EZID: {}", e.getMessage()); remainder.add(id.value); skipped++; continue; } if (!response.isSuccess()) { log.error("Unable to delete {} from DataCite: {}", id.value, response.getEZIDStatusValue()); remainder.add(id.value); skipped++; continue; } log.info("Deleted {}", id.value); } // delete from item item.clearMetadata(MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null); item.addMetadata(MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null, remainder.toArray(new String[remainder.size()])); try { item.update(); context.commit(); } catch (SQLException e) { log.error("Failed to re-add identifiers: {}", e.getMessage()); } catch (AuthorizeException e) { log.error("Failed to re-add identifiers: {}", e.getMessage()); } if (skipped > 0) { throw new IdentifierException(identifier + " could not be deleted."); } }
From source file:ee.ria.xroad.proxy.serverproxy.ServerMessageProcessor.java
private void sendRequest(String serviceAddress, HttpSender httpSender) throws Exception { log.trace("sendRequest({})", serviceAddress); URI uri;//from www. ja v a2s.co m try { uri = new URI(serviceAddress); } catch (URISyntaxException e) { throw new CodedException(X_SERVICE_MALFORMED_URL, "Malformed service address '%s': %s", serviceAddress, e.getMessage()); } log.info("Sending request to {}", uri); String contentType = servletRequest.getHeader(HEADER_ORIGINAL_CONTENT_TYPE); // 6.7.x series security servers don't know to add the original content type header. // Not setting a content type will cause trouble with management requests to central server and // normal requests to 6.9.x servers that pass the request on to services that expect a certain content type. if (contentType == null) { // set the content type like version 6.7.x contentType = requestMessage.getSoapContentType(); } try (InputStream in = requestMessage.getSoapContent()) { opMonitoringData.setRequestOutTs(getEpochMillisecond()); httpSender.doPost(uri, in, CHUNKED_LENGTH, contentType); opMonitoringData.setResponseInTs(getEpochMillisecond()); } catch (Exception ex) { if (ex instanceof CodedException) { opMonitoringData.setResponseInTs(getEpochMillisecond()); } throw translateException(ex).withPrefix(X_SERVICE_FAILED_X); } }