List of usage examples for java.net URISyntaxException printStackTrace
public void printStackTrace()
From source file:net.refractions.udig.document.source.ShpDocUtils.java
/** * Gets the relative path with the url as the parent path and the absolute path as the child * path./*from www. ja va 2s . c o m*/ * * @param url * @param absolutePath * @return relative path */ public static String getRelativePath(URL url, String absolutePath) { if (absolutePath != null && absolutePath.trim().length() > 0) { try { final File parentFile = new File(new URI(url.toString())); final File parentDir = parentFile.getParentFile(); final File childFile = new File(absolutePath); return parentDir.toURI().relativize(childFile.toURI()).getPath(); } catch (URISyntaxException e) { // Should not happen as shapefile should be a valid file e.printStackTrace(); } } return null; }
From source file:org.vsepml.storm.sensapp.RestRequest.java
public static boolean isSensorRegistred(Sensor sensor) { URI target = null;//from w ww .ja v a2s. co m try { target = new URI(sensor.getUri().toString() + SENSOR_PATH + "/" + sensor.getName()); } catch (URISyntaxException e) { e.printStackTrace(); } HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(target); StatusLine status = null; try { status = client.execute(request).getStatusLine(); } catch (Exception e) { } if (status.getStatusCode() == 200) { return true; } return false; }
From source file:net.modelbased.proasense.storage.registry.RestRequest.java
public static String deleteSensor(URI uri, Sensor sensor) { URI target = null;/* www . ja v a 2s. c o m*/ try { target = new URI(uri.toString() + SENSOR_PATH + "/" + sensor.getName()); } catch (URISyntaxException e) { e.printStackTrace(); } HttpClient client = new DefaultHttpClient(); HttpDelete request = new HttpDelete(target); request.setHeader("Content-type", "application/json"); String response = null; try { response = resolveResponse(client.execute(request)); } catch (Exception e) { e.printStackTrace(); } return response; }
From source file:org.vsepml.storm.sensapp.RestRequest.java
public static boolean isCompositeRegistred(Composite composite) { URI target = null;//from w ww . j a va2 s. co m try { target = new URI(composite.getUri().toString() + COMPOSITE_PATH + "/" + composite.getName()); } catch (URISyntaxException e1) { e1.printStackTrace(); } HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(target); StatusLine status = null; try { status = client.execute(request).getStatusLine(); } catch (Exception e) { e.printStackTrace(); } if (status.getStatusCode() == 200) { return true; } return false; }
From source file:net.modelbased.proasense.storage.registry.RestRequest.java
public static boolean isSensorRegistered(Sensor sensor) { URI target = null;//w w w.ja v a 2s.co m try { target = new URI(sensor.getUri().toString() + SENSOR_PATH + "/" + sensor.getName()); } catch (URISyntaxException e) { e.printStackTrace(); } HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(target); StatusLine status = null; try { status = client.execute(request).getStatusLine(); } catch (Exception e) { } if (status.getStatusCode() == 200) { return true; } return false; }
From source file:org.opendatakit.dwc.server.HtmlUtil.java
public static final String createLinkWithProperties(String url, Map<String, String> properties) { StringBuilder urlBuilder = new StringBuilder(); try {//from w ww . ja va 2 s. c o m URI uri = new URI(url); String embeddedQuery = uri.getRawQuery(); if (embeddedQuery != null && embeddedQuery.length() != 0) { int i = url.indexOf(embeddedQuery); String path = url.substring(0, i - 1); urlBuilder.append(path); String[] pairs = embeddedQuery.split(HtmlConsts.PARAM_DELIMITER); for (String p : pairs) { String[] kv = p.split(BasicConsts.EQUALS); String v = URLDecoder.decode(kv[1], "UTF-8"); properties.put(kv[0], v); } } else { urlBuilder.append(url); } } catch (URISyntaxException e1) { e1.printStackTrace(); throw new IllegalArgumentException(e1); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } if (properties != null) { Set<Map.Entry<String, String>> propSet = properties.entrySet(); if (!propSet.isEmpty()) { urlBuilder.append(HtmlConsts.BEGIN_PARAM); boolean firstParam = true; for (Map.Entry<String, String> property : propSet) { if (firstParam) { firstParam = false; } else { urlBuilder.append(HtmlConsts.PARAM_DELIMITER); } String value = property.getValue(); if (value == null) { value = BasicConsts.NULL; } String valueEncoded; try { valueEncoded = URLEncoder.encode(value, HtmlConsts.UTF8_ENCODE); } catch (UnsupportedEncodingException e) { valueEncoded = BasicConsts.EMPTY_STRING; } urlBuilder.append(property.getKey() + BasicConsts.EQUALS + valueEncoded); } } } return urlBuilder.toString(); }
From source file:net.modelbased.proasense.storage.registry.RestRequest.java
public static boolean isCompositeRegistered(Composite composite) { URI target = null;/* w w w . ja v a 2 s . co m*/ try { target = new URI(composite.getUri().toString() + COMPOSITE_PATH + "/" + composite.getName()); } catch (URISyntaxException e1) { e1.printStackTrace(); } HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(target); StatusLine status = null; try { status = client.execute(request).getStatusLine(); } catch (Exception e) { e.printStackTrace(); } if (status.getStatusCode() == 200) { return true; } return false; }
From source file:net.modelbased.proasense.storage.registry.RestRequest.java
public static String postSensor(Sensor sensor) { String content = JsonPrinter.sensorToJson(sensor); URI target = null;//from w w w. ja va 2 s. co m try { target = new URI(sensor.getUri().toString() + SENSOR_PATH); } catch (URISyntaxException e1) { e1.printStackTrace(); } HttpClient client = new DefaultHttpClient(); HttpPost request = new HttpPost(target); request.setHeader("Content-type", "application/json"); String response = null; try { StringEntity seContent = new StringEntity(content); seContent.setContentType("text/json"); request.setEntity(seContent); response = resolveResponse(client.execute(request)); } catch (Exception e) { e.printStackTrace(); } return response; }
From source file:net.modelbased.proasense.storage.registry.RestRequest.java
public static String postComposite(Composite composite) { String content = JsonPrinter.compositeToJson(composite); URI target = null;/*from w w w .j a v a 2s . co m*/ try { target = new URI(composite.getUri().toString() + COMPOSITE_PATH); } catch (URISyntaxException e1) { e1.printStackTrace(); } HttpClient client = new DefaultHttpClient(); HttpPost request = new HttpPost(target); request.setHeader("Content-type", "application/json"); String response = null; try { StringEntity seContent = new StringEntity(content); seContent.setContentType("text/json"); request.setEntity(seContent); response = resolveResponse(client.execute(request)); } catch (Exception e) { e.printStackTrace(); } return response; }
From source file:net.modelbased.proasense.storage.registry.RestRequest.java
public static String putData(URI uri, String data) { URI target = null;//from w ww .j a v a 2 s. c om try { target = new URI(uri.toString() + DISPATCHER_PATH); } catch (URISyntaxException e1) { e1.printStackTrace(); } HttpClient client = new DefaultHttpClient(); HttpPut request = new HttpPut(target); request.setHeader("Content-type", "application/json"); String response = null; try { StringEntity seContent = new StringEntity(data); seContent.setContentType("text/json"); request.setEntity(seContent); response = resolveResponse(client.execute(request)); } catch (Exception e) { e.printStackTrace(); } if (response.trim().length() > 2) { throw new IllegalAccessError("Sensor not registred: " + response); } return response; }