List of usage examples for java.net URISyntaxException printStackTrace
public void printStackTrace()
From source file:ezbake.azkaban.manager.ScheduleManager.java
/** * Class for scheduling a flow in Azkaban * * @param azkabanUri The Azkaban URL/*from w w w. j av a 2 s .c o m*/ * @param username The username to use * @param password The password for the username */ public ScheduleManager(URI azkabanUri, String username, String password) { try { this.schedulerUri = new URIBuilder(azkabanUri).setPath("/schedule").build(); } catch (URISyntaxException e) { e.printStackTrace(); } final AuthenticationManager azkabanAuthenticator = new AuthenticationManager(schedulerUri, username, password); final AuthenticationResult result = azkabanAuthenticator.login(); if (result.hasError()) { throw new IllegalStateException(result.getError()); } this.sessionId = result.getSessionId(); }
From source file:hu.fnf.devel.wishbox.ui.MainPage.java
private Container getItemContiner() { IndexedContainer container = new IndexedContainer(); container.addContainerProperty("First", String.class, "1st"); container.addContainerProperty("Second", String.class, "2nd"); // WebClient client = WebClient.create("http://195.228.45.136:8181/cxf/test"); // client = client.accept("application/json") // .type("application/json") // .path("/say/list"); // TestResp testResp = client.get(TestResp.class); if (getSession().getAttribute("state") == null) { UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); getSession().setAttribute("user", user); URI uri = null;/*from w ww . j a v a 2 s. c om*/ try { uri = new URI(("http://jenna.fnf.hu/gateway/persistence/user/" + user.getUserId())); } catch (URISyntaxException e) { e.printStackTrace(); } String plainCreds = "API_KEY:API_PASS"; byte[] plainCredsBytes = plainCreds.getBytes(); byte[] base64CredsBytes = Base64.encodeBase64(plainCredsBytes); String base64Creds = new String(base64CredsBytes); HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", "Basic " + base64Creds); HttpEntity<String> request = new HttpEntity<String>(headers); RestTemplate restTemplate = new RestTemplate(); ResponseEntity<String> response = restTemplate.exchange(uri, HttpMethod.GET, request, String.class); JsonFactory factory = new JsonFactory(); ObjectMapper m = new ObjectMapper(factory); JsonNode rootNode = null; try { rootNode = m.readTree(response.getBody()); } catch (IOException e) { e.printStackTrace(); } Iterator<Map.Entry<String, JsonNode>> fieldsIterator = rootNode.fields(); while (fieldsIterator.hasNext()) { Map.Entry<String, JsonNode> field = fieldsIterator.next(); if (!field.getKey().startsWith("_")) { getSession().setAttribute(field.getKey(), field.getValue().asText()); } else { } System.out.println("Key: " + field.getKey() + ":\t" + field.getValue()); } getSession().setAttribute("state", "loaded"); } com.vaadin.data.Item item = container.addItem(((User) getSession().getAttribute("user")).getNickname()); item.getItemProperty("First").setValue(getSession().getAttribute("firstName").toString()); item.getItemProperty("Second").setValue(getSession().getAttribute("lastName").toString()); return container; }
From source file:com.ge.predix.test.utils.ZoneHelper.java
public String getZoneSpecificUrl(final String zoneId) { URI uri = null;/*from w w w. j av a2s . c o m*/ String zoneurl = null; try { uri = new URI(this.acsBaseUrl); } catch (URISyntaxException e) { e.printStackTrace(); } // if running locally, acsDomain is not needed in uri if (this.acsCFDomain == null || this.acsCFDomain.isEmpty()) { zoneurl = uri.getScheme() + "://" + zoneId + "." + this.cfBaseDomain; } else { zoneurl = uri.getScheme() + "://" + zoneId + "." + this.acsCFDomain + "." + this.cfBaseDomain; } if (uri.getPort() != -1) { zoneurl += ":" + uri.getPort(); } return zoneurl; }
From source file:com.mp3tunes.android.player.RemoteAlbumArtHandler.java
private String getRemoteArtworkForLocalTrack(Track t) { String id = "stYqie5s3hGAz_VW3cXxwQ"; String render = "json"; String album = t.getAlbumTitle(); String artist = t.getArtistName(); List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("_id", id)); params.add(new BasicNameValuePair("_render", render)); params.add(new BasicNameValuePair("album", album)); params.add(new BasicNameValuePair("artist", artist)); try {//from w ww . ja v a2 s. com URI uri = URIUtils.createURI("http", "pipes.yahoo.com", -1, "/pipes/pipe.run", URLEncodedUtils.format(params, "UTF-8"), null); HttpGet get = new HttpGet(uri); Log.w("Mp3Tunes", "Url: " + get.getURI().toString()); HttpClient client = new DefaultHttpClient(); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String response = client.execute(get, responseHandler); client.getConnectionManager().shutdown(); JSONObject obj = new JSONObject(response); JSONObject value = obj.getJSONObject("value"); JSONArray items = value.getJSONArray("items"); JSONObject item = items.getJSONObject(0); JSONObject image = item.getJSONObject("image"); return image.getString("url"); } catch (URISyntaxException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } return null; }
From source file:com.viettel.viettellib.json.me.JSONParser.java
/** * /* w ww .j a v a2 s. c o m*/ * Mo ta chuc nang cua ham * @author: BangHN * @param address * @param method * @return * @throws URISyntaxException * @return: json string * @throws: */ public String excuteHttpRequest(String address, String method) { String jsonStr = ""; String url = null; //Tao duong dan truy cap try { URI uri = new URI("http", "maps.googleapis.com", "/maps/api/geocode/json", "address=" + address + "&sensor=true", null); url = uri.toASCIIString(); } catch (URISyntaxException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //1.truy vn server http://10.0.0.103/ltjoomla2106/index.php?option=com_json&format=json&id=15&task=requestdb /*to 1 client: chc nng ging nh trnh duyt*/ DefaultHttpClient client = new DefaultHttpClient(); /*to bin post y d liu: --> to header ca giao thc http*/ if (method == "POST") { HttpPost postObj = new HttpPost(url); /*t cc gi tr cn post vo bin http header*/ try { //ly v response l d liu chui JSON /*bm nt submit form trn trnh duyt*/ HttpResponse jsonString = client.execute(postObj); jsonStr = EntityUtils.toString(jsonString.getEntity()); Log.e("JSON STRiNG", jsonStr); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (method == "GET") { HttpGet getObj = new HttpGet(url); /*t cc gi tr cn post vo bin http header*/ try { //ly v response l d liu chui JSON /*bm nt submit form trn trnh duyt*/ HttpResponse jsonString = client.execute(getObj); jsonStr = EntityUtils.toString(jsonString.getEntity()); Log.e("JSON STRiNG", jsonStr); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return jsonStr; }
From source file:com.mollie.api.MollieClient.java
/** * Perform a http call. This method is used by the resource specific classes. * Please use the payments() method to perform operations on payments. * * @param method the http method to use//from w w w . j a v a 2 s . c o m * @param apiMethod the api method to call * @param httpBody the contents to send to the server. * @return result of the http call * @throws MollieException when the api key is not set or when there is a * problem communicating with the mollie server. * @see #performHttpCall(String method, String apiMethod) */ public String performHttpCall(String method, String apiMethod, String httpBody) throws MollieException { URI uri = null; String result = null; if (_apiKey == null || _apiKey.trim().equals("")) { throw new MollieException("You have not set an api key. Please use setApiKey() to set the API key."); } try { URIBuilder ub = new URIBuilder(this._apiEndpoint + "/" + API_VERSION + "/" + apiMethod); uri = ub.build(); } catch (URISyntaxException e) { e.printStackTrace(); } if (uri != null) { CloseableHttpClient httpclient = HttpClientBuilder.create().build(); HttpRequestBase action = null; HttpResponse response = null; if (method.equals(HTTP_POST)) { action = new HttpPost(uri); } else if (method.equals(HTTP_DELETE)) { action = new HttpDelete(uri); } else { action = new HttpGet(uri); } if (httpBody != null && action instanceof HttpPost) { StringEntity entity = new StringEntity(httpBody, ContentType.APPLICATION_JSON); ((HttpPost) action).setEntity(entity); } action.setHeader("Authorization", "Bearer " + this._apiKey); action.setHeader("Accept", ContentType.APPLICATION_JSON.getMimeType()); try { response = httpclient.execute(action); HttpEntity entity = response.getEntity(); StringWriter sw = new StringWriter(); IOUtils.copy(entity.getContent(), sw, "UTF-8"); result = sw.toString(); EntityUtils.consume(entity); } catch (Exception e) { throw new MollieException("Unable to communicate with Mollie"); } try { httpclient.close(); } catch (IOException e) { e.printStackTrace(); } } return result; }
From source file:org.apache.hama.ml.ann.NeuralNetwork.java
/** * Read the model meta-data from the specified location. * /*w ww. j a v a2 s . c o m*/ * @throws IOException */ protected void readFromModel() throws IOException { Preconditions.checkArgument(this.modelPath != null, "Model path has not been set."); Configuration conf = new Configuration(); FSDataInputStream is = null; try { URI uri = new URI(this.modelPath); FileSystem fs = FileSystem.get(uri, conf); is = new FSDataInputStream(fs.open(new Path(modelPath))); this.readFields(is); } catch (URISyntaxException e) { e.printStackTrace(); } finally { Closeables.close(is, false); } }
From source file:org.apache.hama.ml.ann.NeuralNetwork.java
/** * Write the model data to specified location. * /* w w w. j a v a 2s . c o m*/ * @throws IOException */ public void writeModelToFile() throws IOException { Preconditions.checkArgument(this.modelPath != null, "Model path has not been set."); Configuration conf = new Configuration(); FSDataOutputStream is = null; try { URI uri = new URI(this.modelPath); FileSystem fs = FileSystem.get(uri, conf); is = fs.create(new Path(this.modelPath), true); this.write(is); } catch (URISyntaxException e) { e.printStackTrace(); } Closeables.close(is, false); }
From source file:i5.las2peer.services.videoAdapter.AdapterClass.java
protected static String getResponse(String uri) { CloseableHttpResponse response = null; URI httpRequest;//from w w w .ja v a2s . c o m String preferenceString = null; try { httpRequest = new URI(uri); CloseableHttpClient httpPreferenceService = HttpClients.createDefault(); HttpGet getPreferences = new HttpGet(httpRequest); response = httpPreferenceService.execute(getPreferences); HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); preferenceString = convertStreamToString(instream); //System.out.println("RESPONSE: " + preferenceString); instream.close(); } } 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 preferenceString; }
From source file:org.megam.deccanplato.provider.box.handler.FileImpl.java
/** * @return/*from w w w .j a va 2s. c o m*/ */ private Map<String, String> view() { Map<String, String> outMap = new HashMap<>(); final String BOX_DOWNLOAD = "/files/" + args.get(FILE_ID); Map<String, String> headerMap = new HashMap<String, String>(); headerMap.put("Authorization", "BoxAuth api_key=" + args.get(API_KEY) + "&auth_token=" + args.get(TOKEN)); TransportTools tools = new TransportTools(BOX_URI + BOX_DOWNLOAD, null, headerMap); String responseBody = null; TransportResponse response = null; try { response = TransportMachinery.get(tools); responseBody = response.entityToString(); System.out.println("OUTPUT:" + responseBody); } catch (ClientProtocolException ce) { ce.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } catch (URISyntaxException e) { e.printStackTrace(); } outMap.put(OUTPUT, responseBody); return outMap; }