List of usage examples for java.net URI URI
public URI(String str) throws URISyntaxException
From source file:com.rusticisoftware.tincan.Activity.java
public Activity(JsonNode jsonNode) throws URISyntaxException { this();/*w w w . j av a 2 s. co m*/ JsonNode idNode = jsonNode.path("id"); if (!idNode.isMissingNode()) { this.setId(new URI(idNode.textValue())); } JsonNode definitionNode = jsonNode.path("definition"); if (!definitionNode.isMissingNode()) { this.setDefinition(new ActivityDefinition(definitionNode)); } }
From source file:com.ibm.amc.resources.data.ActionStatusResponse.java
/** * Constructor./*from w ww.j a v a2 s .c o m*/ * * @param status * the action status */ public ActionStatusResponse(ActionStatus status) { actionId = status.getActionId(); userId = status.getUserId(); if (status.getApplianceId() != null) { try { resource = new URI("rest/appliances/" + status.getApplianceId()); } catch (URISyntaxException e) { } } action = status.getName(); description = NLS.formatMessage(userId, status.getDescriptionKey(), status.getDescriptionInserts()); state = status.getState().toString(); submitted = new Date(status.getSubmitted().getTime()); updated = new Date(status.getUpdated().getTime()); result = status.getResult(); if (status.getUpdates() != null) { updates = new ArrayList<ActionResponse>(status.getUpdates().size()); for (ActionStatusUpdate statusUpdate : status.getUpdates()) { if (statusUpdate.getCause() == null) { updates.add(new ActionResponse(userId, statusUpdate.getTimeStamp(), statusUpdate.getMessageKey(), statusUpdate.getMessageInserts())); } else { final ExceptionResponse response = new ExceptionResponse(userId, statusUpdate.getTimeStamp(), statusUpdate.getMessageKey(), statusUpdate.getMessageInserts()); response.cause = new ExceptionResponse(statusUpdate.getCause()); updates.add(response); } } } }
From source file:com.nesscomputing.service.discovery.client.ServiceURI.java
public ServiceURI(final String uri) throws URISyntaxException { this(new URI(uri)); }
From source file:edu.stanford.junction.addon.JunctionServiceFactory.java
@Override public void onMessageReceived(MessageHeader header, JSONObject message) { // TODO: verify you got an activity request // somehow get the Activity object // that means the request needs // * a host/*w w w.java 2 s.co m*/ // * an activity descriptor try { URI activityURI = new URI(message.getString("activity")); // TODO: support a factory mapping from serviceName => class String className = message.getString("serviceName"); Class c = null; try { c = Class.forName(className); } catch (Exception e) { System.out.println("Could not find class for service " + className + "."); } JunctionService service = null; Method method = null; try { method = c.getMethod("newInstance"); } catch (Exception e) { System.out.println("No newInstance method found for " + c + "."); } service = (JunctionService) method.invoke(null); String queryPart = activityURI.getQuery(); System.out.println("query part is " + queryPart); String localRole = "Unknown"; int i; if ((i = queryPart.indexOf("role=")) >= 0) { localRole = queryPart.substring(i + 14); if ((i = localRole.indexOf("&")) > 0) { localRole = localRole.substring(0, i); } } System.out.println("Setting service role to " + localRole); service.setRole(localRole); System.out.println("service actorID is " + service.getActorID()); //JunctionMaker.getInstance().newJunction(activityURI,service); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.apache.ambari.server.api.services.LocalUriInfo.java
public LocalUriInfo(String uri) { try {/*from www . ja v a2s . co m*/ this.uri = new URI(uri); } catch (URISyntaxException e) { throw new RuntimeException("URI syntax is not correct", e); } }
From source file:org.jtalks.tests.jcommune.mail.pochta.PochtaClient.java
/** * Get message by identifier/*from w ww . ja v a2 s . com*/ * * @param id the UUID type identifier * @return the message * @throws CouldNotGetMessageException */ public static String getMessage(String id) { RestTemplate client = new RestTemplate(); try { return client.getForObject(new URI(API_INBOXES_URL), String.class); } catch (Exception e) { throw new CouldNotGetMessageException(e); } }
From source file:org.eel.kitchen.jsonschema.format.URIFormatAttribute.java
@Override public void checkValue(final String fmt, final ValidationContext ctx, final ValidationReport report, final JsonNode value) { try {//from ww w . ja va 2s. co m new URI(value.textValue()); } catch (URISyntaxException ignored) { final Message.Builder msg = newMsg(fmt).setMessage("string is not a valid URI").addInfo("value", value); report.addMessage(msg.build()); } }
From source file:snoopware.api.UsergridSdkTest.java
@Test public void testUsergridAuth() throws IOException, URISyntaxException { Properties properties = new Properties(); properties.load(getClass().getResourceAsStream("/app.properties")); URI targetUri = new URI((String) properties.get("app.usergridUri")); String organizationId = (String) properties.get("org.id"); String applicationId = (String) properties.get("app.id"); Client client = new Client(organizationId, applicationId); String clientId = (String) properties.get("org.clientId"); String clientSecret = (String) properties.get("org.clientSecret"); client.authorizeAppClient(clientId, clientSecret); Client.Query queryUsers = client.queryUsers(); Assert.assertTrue(queryUsers.getResponse().getEntities().size() > 0); for (Entity entity : queryUsers.getResponse().getEntities()) { log.info("found username: " + entity.getProperties().get("username").asText()); }/*from w ww.j a v a 2 s . com*/ // { // ApiResponse res = client.apiRequest(HttpMethod.GET, null, null, // (String)properties.get("org.name"), (String)properties.get("app.name"), "user", "b"); // Assert.assertEquals("service_resource_not_found", res.getError()); // log.info(res.getStatus()); // } // // { // ApiResponse res = client.apiRequest(HttpMethod.GET, null, null, // (String)properties.get("org.name"), (String)properties.get("app.name"), "user", "bob"); // Assert.assertEquals(null, res.getError()); // } }
From source file:com.tweetlanes.android.urlservice.ApiService.java
public static HttpResponse postRequest(String url, String debugName) { HttpClient client = new DefaultHttpClient(); HttpPost request = new HttpPost(); HttpResponse response = null;//from ww w .j av a2 s.c o m try { request.setURI(new URI(url)); //Log.d("tweetlanes url fetch", url); response = client.execute(request); //Log.d(TAG, debugName + " complete"); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return response; }
From source file:com.ettrema.httpclient.PropFindMethod.java
public PropFindMethod(String sUri) { URI uri;/*from ww w .j a va 2 s .c o m*/ try { uri = new URI(sUri); } catch (URISyntaxException ex) { throw new RuntimeException(ex); } this.setURI(uri); }