List of usage examples for java.net URISyntaxException printStackTrace
public void printStackTrace()
From source file:edu.ku.brc.util.WebStoreAttachmentMgr.java
private File getFileForIconName(final String iconName) { IconEntry entry = IconManager.getIconEntryByName(iconName); if (entry != null) { try {/*from w w w . ja va 2 s.co m*/ //System.err.println("****** entry.getUrl(): "+entry.getUrl().toExternalForm()); String fullPath = entry.getUrl().toExternalForm(); if (fullPath.startsWith("jar:")) { String[] segs = StringUtils.split(fullPath, "!"); if (segs.length != 2) return null; String jarPath = segs[1]; InputStream stream = IconManager.class.getResourceAsStream(jarPath); if (stream == null) { //send your exception or warning return null; } String fileName = FilenameUtils.getName(jarPath); File outfile = new File(downloadCacheDir, fileName); //System.err.println("Path: "+ path+"|"+jarPath+"|"+fileName); OutputStream resStreamOut; int readBytes; byte[] buffer = new byte[10240]; try { resStreamOut = new FileOutputStream(outfile); while ((readBytes = stream.read(buffer)) > 0) { resStreamOut.write(buffer, 0, readBytes); } resStreamOut.close(); stream.close(); return outfile; } catch (IOException e1) { e1.printStackTrace(); return null; } } else { return new File(entry.getUrl().toURI()); } } catch (URISyntaxException e) { e.printStackTrace(); } } return null; }
From source file:org.LexGrid.LexBIG.gui.LB_VSD_GUI.java
private URI getSelectedValueSetDef() { TableItem[] temp = valueSetDefTV_.getTable().getSelection(); if (temp.length == 1) { try {//from www. ja v a2s.c om return new URI(((ValueSetDefinition) temp[0].getData()).getValueSetDefinitionURI()); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; }
From source file:com.jp.miaulavirtual.DisplayMessageActivity.java
/** * Codifica la URL del archivo, lo descarga (si no existe) y lo guarda en Almacenamiento externo (SDCARD)//Android/data/com.jp.miaulavirtual/files * @return String - Tamao del archivo en formato del SI * @throws IOException/* ww w . j a v a2s .c o m*/ */ public int getDoc(Context mycontext, String url_back) throws IOException, SocketTimeoutException { URI uri; int id = 0; Log.d("Document", url); String request = null; // Codificamos la URL del archivo try { uri = new URI("http", "aulavirtual.uv.es", url, null); request = uri.toASCIIString(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } Log.d("Document", request); // Recheck cookie isn't expire Response resp = Jsoup.connect("http://aulavirtual.uv.es" + url_back).cookies(cookies).method(Method.GET) .timeout(10 * 1000).execute(); res = resp; Log.d("Document", "Respuesta2"); Log.d("Cookie", res.cookies().toString()); // Action in response of cookie checking if (res.hasCookie("ad_user_login")) { // El usuario y la contrasea son correctas al renovar la COOKIE (NO PUEDEN SER INCORRECTOS, YA ESTABA LOGUEADO) Log.d("Cookie", String.valueOf(a)); if (a == 2) { a = 1; new docDownload(url_back).execute(); //REejecutamos la tarea docDownload } } else if (res.hasCookie("fs_block_id")) { id = downloadFile(request); } else if (res.hasCookie("ad_session_id")) { // Cookie Vencida SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mycontext); Editor editor = prefs.edit(); // Cookie Vencida editor.remove("cookies"); editor.commit(); cookies = null; // eliminamos la cookie a = a + 1; // Aumentamos el contador Log.d("Cookie", "COOKIE VENCIDA"); new docDownload(url_back).execute(); //REejecutamos la tarea (POST) } else if (res.hasCookie("tupi_style") || res.hasCookie("zen_style")) { // Cookie correcta, sesin POST ya habilitada. GET correcto. Procede. id = downloadFile(request); } Log.d("ID", String.valueOf(id)); return id; }
From source file:com.freeme.filemanager.view.FileViewFragment.java
@Override public void onPick(FileInfo f) { try {//from w w w .jav a 2s . c o m Intent intent = Intent.parseUri(Uri.fromFile(new File(f.filePath)).toString(), 0); mActivity.setResult(Activity.RESULT_OK, intent); mActivity.finish(); return; } catch (URISyntaxException e) { e.printStackTrace(); } }
From source file:ca.nehil.rter.streamingapp.StreamingActivity.java
public String request(String resource) { try {// w ww .ja v a2 s . c o m return request(new URI(server_url + "/1.0/" + resource)); } catch (URISyntaxException e) { e.printStackTrace(); } return ""; }
From source file:i5.las2peer.services.videoAdapter.AdapterClass.java
private String[] getVideoLang(String[] objectIds, int size) { String[] languages = new String[size]; CloseableHttpResponse response = null; URI request = null;//w w w. java2s . c om try { for (int k = 0; k < size; k++) { // Get video details request = new URI("http://eiche:7071/video-details/videos/" + objectIds[k] + "?part=url,language"); CloseableHttpClient httpClient = HttpClients.createDefault(); HttpGet get = new HttpGet(request); response = httpClient.execute(get); // Parse the response BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuilder content = new StringBuilder(); String line; while (null != (line = rd.readLine())) { content.append(line); } JSONObject object = new JSONObject(content.toString()); // Save in a String array languages[k] = new String(object.getString("language")); } } catch (URISyntaxException e) { //System.out.println(e); e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return languages; }
From source file:org.protocoderrunner.apprunner.api.PNetwork.java
@ProtocoderScript @APIMethod(description = "Connect to a websocket server", example = "") @APIParam(params = { "uri", "function(status, data)" }) public WebSocketClient connectWebsocket(String uri, final connectWebsocketCB callbackfn) { Draft d = new Draft_17(); WebSocketClient webSocketClient = null; try {//from w w w. jav a2 s . co m webSocketClient = new WebSocketClient(new URI(uri), d) { @Override public void onOpen(ServerHandshake arg0) { mHandler.post(new Runnable() { @Override public void run() { callbackfn.event("onOpen", ""); } }); //Log.d(TAG, "onOpen"); } @Override public void onMessage(final String arg0) { mHandler.post(new Runnable() { @Override public void run() { callbackfn.event("onMessage", arg0); } }); //Log.d(TAG, "onMessage client"); } @Override public void onError(Exception arg0) { mHandler.post(new Runnable() { @Override public void run() { callbackfn.event("onError", ""); } }); //Log.d(TAG, "onError"); } @Override public void onClose(int arg0, String arg1, boolean arg2) { mHandler.post(new Runnable() { @Override public void run() { callbackfn.event("onClose", ""); } }); //Log.d(TAG, "onClose"); } }; webSocketClient.connect(); } catch (URISyntaxException e) { Log.d(TAG, "error"); callbackfn.event("error ", e.toString()); e.printStackTrace(); } return webSocketClient; }
From source file:org.modeshape.web.jcr.rest.AbstractRestTest.java
private <T extends HttpRequestBase> T newRequest(Class<T> clazz, InputStream inputStream, String contentType, String accepts, String... pathSegments) { String url = RestHelper.urlFrom(getServerContext(), pathSegments); try {//from www. java 2 s . c o m URIBuilder uriBuilder; try { uriBuilder = new URIBuilder(url); } catch (URISyntaxException e) { uriBuilder = new URIBuilder(URL_ENCODER.encode(url)); } T result = clazz.getConstructor(URI.class).newInstance(uriBuilder.build()); result.setHeader("Accept", accepts); result.setHeader("Content-Type", contentType); if (inputStream != null) { assertTrue("Invalid request clazz (requires an entity)", result instanceof HttpEntityEnclosingRequestBase); InputStreamEntity inputStreamEntity = new InputStreamEntity(inputStream, inputStream.available()); ((HttpEntityEnclosingRequestBase) result).setEntity(new BufferedHttpEntity(inputStreamEntity)); } return result; } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); return null; } }
From source file:edu.jhu.pha.vosync.rest.DropboxService.java
@Path("chunked_upload") @PUT/*from www . j a va 2 s. co m*/ @RolesAllowed({ "user", "rwshareuser" }) public Response chunkedUpload(@QueryParam("upload_id") String uploadId, @QueryParam("offset") long offset, InputStream fileDataInp) { final SciDriveUser user = ((SciDriveUser) security.getUserPrincipal()); VoSyncMetaStore voMeta = new VoSyncMetaStore(user.getName()); logger.debug("New chunk: " + uploadId + " " + offset); if (null == uploadId) { uploadId = RandomStringUtils.randomAlphanumeric(15); } Chunk newChunk = voMeta.getLastChunk(uploadId); if (offset != newChunk.getChunkStart()) { // return error with proper offset logger.error("Wrong offset: " + offset + " should be:" + newChunk.getChunkStart()); ResponseBuilder errorResp = Response.status(400); errorResp.entity(genChunkResponse(uploadId, newChunk.getChunkStart())); return errorResp.build(); } VospaceId identifier; try { String chunkNumberString = String.format("%07d", newChunk.getChunkNum()); identifier = new VospaceId(new NodePath( "/" + conf.getString("chunked_container") + "/" + uploadId + "/" + chunkNumberString)); DataNode node = (DataNode) NodeFactory.createNode(identifier, user.getName(), NodeType.DATA_NODE); node.getStorage().createContainer(new NodePath("/" + conf.getString("chunked_container"))); node.getStorage().putBytes(identifier.getNodePath(), fileDataInp); NodeInfo info = new NodeInfo(); node.getStorage().updateNodeInfo(identifier.getNodePath(), info); node.setNodeInfo(info); newChunk.setSize(info.getSize()); voMeta.putNewChunk(newChunk); byte[] resp = genChunkResponse(uploadId, newChunk.getChunkStart() + newChunk.getSize()); return Response.ok(resp).build(); } catch (URISyntaxException e) { e.printStackTrace(); throw new InternalServerErrorException(e.getMessage()); } }