List of usage examples for java.net URISyntaxException getMessage
public String getMessage()
From source file:fr.wseduc.webdav.WebDav.java
private Sardine getSardine(String uri, Message<JsonObject> message) { String host;/*from w w w .j a v a2s . c om*/ try { host = new URI(uri).getHost(); } catch (URISyntaxException e) { sendError(message, e.getMessage(), e); return null; } JsonObject credential = credentials.getJsonObject(host); Sardine sardine; if (credential != null) { if (credential.getBoolean("insecure", false)) { sardine = new SardineImpl() { @Override protected ConnectionSocketFactory createDefaultSecureSocketFactory() { SSLConnectionSocketFactory sf = null; TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { @Override public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } @Override public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { } @Override public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { } } }; try { SSLContext context = SSLContext.getInstance("TLS"); context.init(null, trustAllCerts, null); sf = new SSLConnectionSocketFactory(context, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); } catch (NoSuchAlgorithmException | KeyManagementException e) { logger.error(e.getMessage(), e); } return sf; } }; sardine.setCredentials(credential.getString("username"), credential.getString("password")); } else { sardine = SardineFactory.begin(credential.getString("username"), credential.getString("password")); } sardine.enablePreemptiveAuthentication(host); } else { sardine = SardineFactory.begin(); } return sardine; }
From source file:edu.internet2.middleware.psp.spml.request.AlternateIdentifier.java
/** {@inheritDoc} */ public String toXML(int indent) throws Spml2Exception { XmlBuffer buffer = new XmlBuffer(); try {/*from www .j av a2s . c o m*/ buffer.setNamespace(new URI(PspMarshallableCreator.URI)); } catch (URISyntaxException e) { throw new DSMLProfileException(e.getMessage(), e); } buffer.setPrefix(PspMarshallableCreator.PREFIX); buffer.setIndent(indent); buffer.addOpenStartTag("alternateIdentifier"); buffer.addAttribute("ID", getID()); if (m_targetID != null) { buffer.addAttribute("targetID", m_targetID); } buffer.closeEmptyElement(); return buffer.toString(); }
From source file:org.apache.fop.afp.util.AFPResourceAccessor.java
/** * Constructor for resource to be accessed via the {@link org.apache.fop.apps.FOUserAgent}. This * contructor takes a base URI for resolving font resource URIs. So, if fonts need to be * accessed, you can set the {@link org.apache.fop.fonts.FontManager}'s base URI instead of the * one on the {@link org.apache.fop.apps.FopFactory}. * * @param resourceResolver the resolver of resources * @param baseURI the custom base URI to resolve relative URIs against (may be null) *///from ww w . j a v a 2 s. c om public AFPResourceAccessor(InternalResourceResolver resourceResolver, String baseURI) { this.resourceResolver = resourceResolver; URI actualBaseURI = null; URIResolver uriResolver; if (baseURI == null) { actualBaseURI = null; uriResolver = new NullBaseURIResolver(); } else { try { actualBaseURI = InternalResourceResolver.getBaseURI(baseURI); uriResolver = new BaseURIResolver(); } catch (URISyntaxException use) { log.error("The URI given \"" + baseURI + "\" is invalid: " + use.getMessage()); actualBaseURI = null; uriResolver = new NullBaseURIResolver(); } } this.baseURI = actualBaseURI; this.uriResolver = uriResolver; }
From source file:com.couchbase.sqoop.manager.CouchbaseManagerTest.java
@Before public void setUp() { super.setUp(); try {// w w w . j av a 2 s . c o m URI uri = new URI(CouchbaseUtils.CONNECT_STRING); String user = CouchbaseUtils.COUCHBASE_USER_NAME; String pass = CouchbaseUtils.COUCHBASE_USER_PASS; cb = new CouchbaseClient(Arrays.asList(uri), user, user, pass); } catch (URISyntaxException e) { LOG.error("Bad URL" + e.getMessage()); fail(e.toString()); } catch (IOException e) { LOG.error("Couldn't connect to server" + e.getMessage()); fail(e.toString()); } }
From source file:ch.nexuscomputing.android.osciprimeics.calibration.HttpsTask.java
private Thread initThread() { return new Thread(new Runnable() { @Override//from w w w . j a v a 2s . co m public void run() { try { String resp = connect(); Calibration calibration = CalibrationParser.parse(resp); if (calibration != null) mCallback.onResponse(calibration); else { mCallback.onError("could not parse news"); } } catch (URISyntaxException e) { if (e.getMessage() != null) mCallback.onError("URISyntaxException: " + e.getMessage()); else mCallback.onError("unclassified error occured during the http task"); return; } catch (UnsupportedEncodingException e) { if (e.getMessage() != null) mCallback.onError("UnsupportedEncodingException: " + e.getMessage()); else mCallback.onError("unclassified error occured during the http task"); return; } catch (ClientProtocolException e) { if (e.getMessage() != null) mCallback.onError("ClientProtocolException: " + e.getMessage()); else mCallback.onError("unclassified error occured during the http task"); return; } catch (IOException e) { if (e.getMessage() != null) mCallback.onError("IOException: " + e.getMessage()); else mCallback.onError("unclassified error occured during the http task"); return; } catch (IllegalStateException e) { if (e.getMessage() != null) mCallback.onError("IOException: " + e.getMessage()); else mCallback.onError("unclassified error occured during the http task"); return; } mCallback.onFinish(); } }); }
From source file:ch.nexuscomputing.android.osciprimeics.news.HttpsTask.java
private Thread initThread() { return new Thread(new Runnable() { @Override//from ww w .java 2 s. c o m public void run() { try { String resp = connect(); News news = NewsParser.parse(resp); if (news != null) mCallback.onResponse(news); else { mCallback.onError("could not parse news"); } } catch (URISyntaxException e) { if (e.getMessage() != null) mCallback.onError("URISyntaxException: " + e.getMessage()); else mCallback.onError("unclassified error occured during the http task"); return; } catch (UnsupportedEncodingException e) { if (e.getMessage() != null) mCallback.onError("UnsupportedEncodingException: " + e.getMessage()); else mCallback.onError("unclassified error occured during the http task"); return; } catch (ClientProtocolException e) { if (e.getMessage() != null) mCallback.onError("ClientProtocolException: " + e.getMessage()); else mCallback.onError("unclassified error occured during the http task"); return; } catch (IOException e) { if (e.getMessage() != null) mCallback.onError("IOException: " + e.getMessage()); else mCallback.onError("unclassified error occured during the http task"); return; } catch (IllegalStateException e) { if (e.getMessage() != null) mCallback.onError("IOException: " + e.getMessage()); else mCallback.onError("unclassified error occured during the http task"); return; } mCallback.onFinish(); } }); }
From source file:info.rmapproject.core.model.impl.openrdf.ORMapEventCreationTest.java
/** * Test method for {@link info.rmapproject.core.model.impl.openrdf.ORMapEventCreation#ORMapEventCreation(info.rmapproject.core.model.RMapIri, info.rmapproject.core.model.event.RMapEventTargetType, info.rmapproject.core.model.RMapValue, java.util.List)}. *//*from w w w . j a v a2 s. c o m*/ @Test public void testORMapEventCreationRMapIriRMapEventTargetTypeRMapValueListOfRMapIri() throws Exception { List<java.net.URI> resourceList = new ArrayList<java.net.URI>(); try { IRI creatorIRI = vf.createIRI("http://orcid.org/0000-0003-2069-1219"); resourceList.add(new java.net.URI("http://rmap-info.org")); resourceList.add(new java.net.URI("https://rmap-project.atlassian.net/wiki/display/RMAPPS/RMap+Wiki")); RMapIri associatedAgent = ORAdapter.openRdfIri2RMapIri(creatorIRI); ORMapDiSCO disco = new ORMapDiSCO(associatedAgent, resourceList); // Make list of created objects List<IRI> iris = new ArrayList<IRI>(); IRI discoContext = disco.getDiscoContext(); iris.add(discoContext); Model model = disco.getAsModel(); assertEquals(4, model.size()); List<RMapIri> createdObjIds = new ArrayList<RMapIri>(); for (IRI iri : iris) { createdObjIds.add(ORAdapter.openRdfIri2RMapIri(iri)); } RMapRequestAgent requestAgent = new RMapRequestAgent(associatedAgent.getIri()); ORMapEventCreation event = new ORMapEventCreation(requestAgent, RMapEventTargetType.DISCO, null, createdObjIds); Date end = new Date(); event.setEndTime(end); Model eventModel = event.getAsModel(); assertEquals(7, eventModel.size()); IRI context = event.getContext(); for (Statement stmt : eventModel) { assertEquals(context, stmt.getContext()); } assertEquals(1, event.getCreatedObjectStatements().size()); assertEquals(createdObjIds.size(), event.getCreatedObjectIds().size()); assertEquals(RMapEventType.CREATION, event.getEventType()); assertEquals(RMapEventTargetType.DISCO, event.getEventTargetType()); //Date sdate = event.getStartTime(); //Date edate = event.getEndTime(); Statement tStmt = event.getTypeStatement(); assertEquals(RMAP.EVENT, tStmt.getObject()); IRI crEventId = eventmgr.createEvent(event, triplestore); assertEquals(context, crEventId); assertFalse(context.stringValue().equals(discoContext.stringValue())); assertTrue(eventmgr.isEventId(context, triplestore)); } catch (URISyntaxException e) { e.printStackTrace(); fail(e.getMessage()); } }
From source file:com.epam.ngb.cli.manager.command.handler.http.DatasetRegistrationHandler.java
/** * Performs a dataset registration request to NGB server and prints registration result to * StdOut if it is specified by the command line options * @return 0 if request completed successfully *//*from w w w . j a va2s. co m*/ @Override public int runCommand() { try { URIBuilder builder = new URIBuilder(serverParameters.getServerUrl() + getRequestUrl()); if (parentId != null) { builder.addParameter("parentId", String.valueOf(parentId)); } HttpPost post = new HttpPost(builder.build()); setDefaultHeader(post); if (isSecure()) { addAuthorizationToRequest(post); } RegistrationRequest registration = new RegistrationRequest(); registration.setName(name); registration.setItems(items); registration.setPrettyName(prettyName); String result = getPostResult(registration, post); checkAndPrintDatasetResult(result, printJson, printTable); } catch (URISyntaxException e) { throw new ApplicationException(e.getMessage(), e); } return 0; }
From source file:io.cloudslang.content.httpclient.consume.FinalLocationConsumer.java
public void consume(Map<String, String> returnResult) { URI location;/*from ww w .java 2 s.c o m*/ try { location = URIUtils.resolve(uri, targetHost, redirectLocations); } catch (URISyntaxException e) { //this is not a fatal error throw new IllegalArgumentException( "could not determine '" + CSHttpClient.FINAL_LOCATION + "': " + e.getMessage(), e); } returnResult.put(CSHttpClient.FINAL_LOCATION, location.toASCIIString()); }
From source file:io.druid.server.AsyncManagementForwardingServlet.java
@Override protected String rewriteTarget(HttpServletRequest request) { try {/*from w ww . ja va2 s.c o m*/ return new URIBuilder((String) request.getAttribute(BASE_URI_ATTRIBUTE)) .setPath(request.getAttribute(MODIFIED_PATH_ATTRIBUTE) != null ? (String) request.getAttribute(MODIFIED_PATH_ATTRIBUTE) : request.getRequestURI()) .setQuery(request.getQueryString()) // No need to encode-decode queryString, it is already encoded .build().toString(); } catch (URISyntaxException e) { log.error(e, "Unable to rewrite URI [%s]", e.getMessage()); throw Throwables.propagate(e); } }