List of usage examples for java.net URISyntaxException printStackTrace
public void printStackTrace()
From source file:eu.optimis.ecoefficiencytool.rest.client.EcoEfficiencyToolRESTClientIP.java
/** * Predicts IPs overall eco-efficiency upon a VM migration to a yet unknown * physical host./* w ww .j a v a 2s .c o m*/ * * @param vmId VM identifier of the VM to be migrated. * @param timeSpan Specifies the amount of time in the future in which the * prediction will be made. * @param type Type of eco-efficiency forecast: energy (energy?) or * ecological (ecological?) efficiency. * @return Eco-efficiency forecast of the IP. */ public synchronized String forecastIPEcoEfficiencyVMMigrationUnknownPlacement(String vmId, String type, Long timeSpan) { String ret = null; try { WebResource resource = client.resource(this.getAddress()).path("infrastructure") .path("forecastecoefficiencyVMMigrationUnknownPlacement"); if (timeSpan != null) { resource = resource.queryParam("timeSpan", timeSpan.toString()); } if (type != null) { resource = resource.queryParam("type", type); } if (vmId == null) { log.error("vmId can not be null"); return null; } else { resource = resource.queryParam("vmId", vmId); } ret = resource.type(MediaType.APPLICATION_XML).accept(MediaType.TEXT_PLAIN).get(String.class); } catch (UniformInterfaceException ex) { ClientResponse cr = ex.getResponse(); log.error(cr.getStatus()); ex.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ret; }
From source file:eu.optimis.ecoefficiencytool.rest.client.EcoEfficiencyToolRESTClientIP.java
/** * Forecasts the ecoefficiency of a node. VMs in the "ovfs" parameter which * exist in the system will be considered as undeployments, while * non-present VMs specified in the "ovfs" parameter will be treated as new * deployments.//from w w w .j a v a 2s . co m * * @param nodeId Physical node identifier. * @param ovfs List of OVF descriptors of the VMs to deploy (if not existing * in the node) or undeploy (if existing in the node), generated using * EMOTIVEs OVFWrapper (see Installation Guide). * @param timeSpan Specifies the amount of time in the future in which the * prediction will be made. * @param type Type of eco-efficiency forecast: energy (energy?) or * ecological (ecological?) efficiency. * @return Eco-efficiency forecast of the node. */ public String forecastNodeEcoEfficiency(String nodeId, List<String> ovfs, Long timeSpan, String type) { String ret = null; try { if (nodeId != null) { WebResource resource = client.resource(this.getAddress()).path("infrastructure").path(nodeId) .path("forecastecoefficiency"); if (timeSpan != null) { resource = resource.queryParam("timeSpan", timeSpan.toString()); } if (type != null) { resource = resource.queryParam("type", type); } ListStrings ovfList = new ListStrings(); if (ovfs != null) { for (String ovf : ovfs) { ovfList.add(ovf); } } ret = resource.type(MediaType.APPLICATION_XML).accept(MediaType.TEXT_PLAIN).post(String.class, ovfList); } } catch (UniformInterfaceException ex) { ClientResponse cr = ex.getResponse(); log.error(cr.getStatus()); ex.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ret; }
From source file:eu.optimis.ecoefficiencytool.rest.client.EcoEfficiencyToolRESTClientIP.java
/** * Assesses the eco-efficiency of a set of nodes. The IP is implicit, since * it is the one which owns the nodes and executes this method. * * @param nodeList List containing the nodes IDs whose ecoefficiency wants * to be evaluated./*w ww . java 2 s.c o m*/ * @param type Type of eco-efficiency assessment: energy (energy?) or * ecological (ecological?) efficiency. * @return Eco-efficiency evaluation of the set of requested nodes. */ public List<String> assessMultipleNodesEcoEfficiency(List<String> nodeList, String type) { List<String> ret = null; try { if (nodeList != null) { ListStrings nodes = new ListStrings(); for (String nodeId : nodeList) { nodes.add(nodeId); } //ListStrings ecoAssessments = new ListStrings(); WebResource resource = client.resource(this.getAddress()).path("infrastructure").path("multiple") .path("assessecoefficiency"); if (type != null) { resource = resource.queryParam("type", type); } //ecoAssessments = resource.type(MediaType.APPLICATION_XML).accept(MediaType.APPLICATION_XML).post(ListStrings.class, nodes); ret = resource.type(MediaType.APPLICATION_XML).accept(MediaType.APPLICATION_XML) .post(ListStrings.class, nodes); /* * ret = new LinkedList<String>(); for (String ecoAssessment : * ecoAssessments) { ret.add(ecoAssessment); } */ } } catch (UniformInterfaceException ex) { ClientResponse cr = ex.getResponse(); log.error(cr.getStatus()); ex.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ret; }
From source file:eu.optimis.ecoefficiencytool.rest.client.EcoEfficiencyToolRESTClientIP.java
/** * Predicts the eco-efficiency of a set of nodes. The IP is implicit, since * it is the one which owns the nodes and executes this method. * * @param nodeList List containing the nodes IDs whose ecoefficiency wants * to be predicted.// w w w . j av a2 s. c o m * @param type Type of eco-efficiency forecast: energy (energy?) or * ecological (ecological?) efficiency. * @return Eco-efficiency prediction of the set of requested nodes. */ public List<String> forecastMultipleNodesEcoEfficiency(List<String> nodeList, String type) { List<String> ret = null; try { if (nodeList != null) { ListStrings nodes = new ListStrings(); for (String nodeId : nodeList) { nodes.add(nodeId); } //ListStrings ecoForecasts = new ListStrings(); WebResource resource = client.resource(this.getAddress()).path("infrastructure").path("multiple") .path("forecastecoefficiency"); if (type != null) { resource = resource.queryParam("type", type); } //ecoForecasts = resource.type(MediaType.APPLICATION_XML).accept(MediaType.APPLICATION_XML).post(ListStrings.class, nodes); ret = resource.type(MediaType.APPLICATION_XML).accept(MediaType.APPLICATION_XML) .post(ListStrings.class, nodes); /* * ret = new LinkedList<String>(); for (String ecoForecast : * ecoForecasts) { ret.add(ecoForecast); } */ } } catch (UniformInterfaceException ex) { ClientResponse cr = ex.getResponse(); log.error(cr.getStatus()); ex.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ret; }
From source file:eu.optimis.ecoefficiencytool.rest.client.EcoEfficiencyToolRESTClientIP.java
/** * Predicts IPs overall eco-efficiency upon a VM deployment in a known * physical host./*from w w w. ja va 2s.c om*/ * * @param ovfDom OVF descriptor of the VM to be deployed, generated using * EMOTIVEs OVFWrapper (see Installation Guide). * @param destNode Physical node where the VM will be deployed. * @param activeNodes List of active physical nodes. * @param timeSpan Specifies the amount of time in the future in which the * prediction will be made. * @param type Type of eco-efficiency forecast: energy (energy?) or * ecological (ecological?) efficiency. * @return Eco-efficiency forecast of the IP. */ public synchronized String forecastIPEcoEfficiencyVMDeploymentKnownPlacement(OVFWrapper ovfDom, String destNode, List<String> activeNodes, String type, Long timeSpan) { String ret = null; try { WebResource resource = client.resource(this.getAddress()).path("infrastructure") .path("forecastecoefficiencyVMDeploymentKnownPlacement"); if (timeSpan != null) { resource = resource.queryParam("timeSpan", timeSpan.toString()); } if (type != null) { resource = resource.queryParam("type", type); } if (destNode == null) { log.error("destNode can not be null"); return null; } else { resource = resource.queryParam("destNode", destNode); } ListStrings ovfPlusActiveNodes = new ListStrings(); ovfPlusActiveNodes.add(ovfDom.toString()); for (String activeNode : activeNodes) { ovfPlusActiveNodes.add(activeNode); } ret = resource.type(MediaType.APPLICATION_XML).accept(MediaType.TEXT_PLAIN).post(String.class, ovfPlusActiveNodes); } catch (UniformInterfaceException ex) { ClientResponse cr = ex.getResponse(); log.error(cr.getStatus()); ex.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ret; }
From source file:eu.optimis.ecoefficiencytool.rest.client.EcoEfficiencyToolRESTClientIP.java
/** * Predicts IPs overall eco-efficiency upon a VM migration to a known * physical host.//from w w w . java 2s. c o m * * @param vmId VM identifier of the VM to be migrated. * @param destNode Physical node where the VM will be migrated to. * @param activeNodes List of active physical nodes. * @param timeSpan Specifies the amount of time in the future in which the * prediction will be made. * @param type Type of eco-efficiency forecast: energy (energy?) or * ecological (ecological?) efficiency. * @return Eco-efficiency forecast of the IP. */ public synchronized String forecastIPEcoEfficiencyVMMigrationKnownPlacement(String vmId, String destNode, List<String> activeNodes, String type, Long timeSpan) { String ret = null; try { WebResource resource = client.resource(this.getAddress()).path("infrastructure") .path("forecastecoefficiencyVMMigrationKnownPlacement"); if (timeSpan != null) { resource = resource.queryParam("timeSpan", timeSpan.toString()); } if (type != null) { resource = resource.queryParam("type", type); } if (destNode == null) { log.error("destNode can not be null"); return null; } else { resource = resource.queryParam("destNode", destNode); } if (vmId == null) { log.error("vmId can not be null"); return null; } else { resource = resource.queryParam("vmId", vmId); } ListStrings activeNodesList = new ListStrings(); for (String activeNode : activeNodes) { activeNodesList.add(activeNode); } ret = resource.type(MediaType.APPLICATION_XML).accept(MediaType.TEXT_PLAIN).post(String.class, activeNodesList); } catch (UniformInterfaceException ex) { ClientResponse cr = ex.getResponse(); log.error(cr.getStatus()); ex.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ret; }
From source file:org.dasein.cloud.azure.AzureMethod.java
protected @Nonnull HttpClient getClient() throws CloudException, InternalException { ProviderContext ctx = provider.getContext(); if (ctx == null) { throw new AzureConfigException("No context was defined for this request"); }//from w w w .java 2s. com String endpoint = ctx.getEndpoint(); if (endpoint == null) { throw new AzureConfigException("No cloud endpoint was defined"); } boolean ssl = endpoint.startsWith("https"); int targetPort; try { URI uri = new URI(endpoint); targetPort = uri.getPort(); if (targetPort < 1) { targetPort = (ssl ? 443 : 80); } } catch (URISyntaxException e) { throw new AzureConfigException(e); } HttpParams params = new BasicHttpParams(); SchemeRegistry registry = new SchemeRegistry(); try { registry.register( new Scheme(ssl ? "https" : "http", targetPort, new AzureSSLSocketFactory(new AzureX509(ctx)))); } catch (KeyManagementException e) { e.printStackTrace(); throw new InternalException(e); } catch (UnrecoverableKeyException e) { e.printStackTrace(); throw new InternalException(e); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); throw new InternalException(e); } catch (KeyStoreException e) { e.printStackTrace(); throw new InternalException(e); } HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, HTTP.UTF_8); HttpProtocolParams.setUserAgent(params, "Dasein Cloud"); params.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 10000); params.setParameter(CoreConnectionPNames.SO_TIMEOUT, 300000); Properties p = ctx.getCustomProperties(); if (p != null) { String proxyHost = p.getProperty("proxyHost"); String proxyPort = p.getProperty("proxyPort"); if (proxyHost != null) { int port = 0; if (proxyPort != null && proxyPort.length() > 0) { port = Integer.parseInt(proxyPort); } params.setParameter(ConnRoutePNames.DEFAULT_PROXY, new HttpHost(proxyHost, port, ssl ? "https" : "http")); } } ClientConnectionManager ccm = new ThreadSafeClientConnManager(registry); return new DefaultHttpClient(ccm, params); }
From source file:com.marketplace.io.Sender.java
/** * Perform a simple HTTP Put request/* w w w. ja v a 2s . co m*/ * * @param data * information that needs to be sent * @param url * the location to send the information to * @throws ConnectivityException * thrown if there was a problem connecting with the database */ public void doBasicHttpPut(String data, String url) throws ConnectivityException { HttpResponse httpResponse = null; StringEntity stringEntity = null; try { httpPut = new HttpPut(); httpPut.setURI(new URI(url)); httpPut.setHeader("Content-Type", "application/json"); } catch (URISyntaxException e) { throw new ConnectivityException("Error occured while setting URL"); } try { stringEntity = new StringEntity(data, "UTF-8"); if (stringEntity != null) { httpPut.setEntity(stringEntity); httpResponse = httpClient.execute(httpPut); HttpEntity entity = httpResponse.getEntity(); if (entity != null) { entity.getContent().close(); } } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { throw new ConnectivityException("Error occured in Client Protocol"); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.ardnezar.lookapp.PeerConnectionClient.java
public void createPeerConnection(final EglBase.Context renderEGLContext, final VideoRenderer.Callbacks localRender, final VideoRenderer.Callbacks remoteRender, final PeerConnectionEvents events, final PeerConnectionParameters peerConnectionParameters) { this.peerConnectionParameters = peerConnectionParameters; this.events = events; videoCallEnabled = peerConnectionParameters.videoCallEnabled; ////from ww w . j a v a 2 s . com // PeerConnectionFactory.initializeAndroidGlobals(, true, true, // false); // factory = new PeerConnectionFactory(); // if (peerConnectionParameters == null) { // Log.e(TAG, "Creating peer connection without initializing factory."); // return; // } this.localRender = localRender; this.remoteRender = remoteRender; executor.execute(new Runnable() { @Override public void run() { createMediaConstraintsInternal(); // createPeerConnectionInternal(renderEGLContext, iceServers); if (mediaStream == null) { mediaStream = factory.createLocalMediaStream("ARDAMS"); if (videoCallEnabled) { String cameraDeviceName = CameraEnumerationAndroid.getDeviceName(0); String frontCameraDeviceName = CameraEnumerationAndroid.getNameOfFrontFacingDevice(); if (numberOfCameras > 1 && frontCameraDeviceName != null) { cameraDeviceName = frontCameraDeviceName; } Log.d(TAG, "Opening camera: " + cameraDeviceName); videoCapturer = VideoCapturerAndroid.create(cameraDeviceName, null, peerConnectionParameters.captureToTexture ? renderEGLContext : null); if (videoCapturer == null) { reportError("Failed to open camera"); return; } mediaStream.addTrack(createVideoTrack(videoCapturer)); } mediaStream.addTrack( factory.createAudioTrack(AUDIO_TRACK_ID, factory.createAudioSource(audioConstraints))); } try { manager = new Manager(new URI(mHost)); client = manager.socket("/"); } catch (URISyntaxException e) { e.printStackTrace(); } client.on(INIT_MESSAGE, messageHandler.onInitMessage).on(TEXT_MESSAGE, messageHandler.onTextMessage) // .on(INVITE_MESSAGE, messageHandler.onInviteMessage) // .on(READY_MESSAGE, messageHandler.onReadyMessage) // .on(OFFER_MESSAGE, messageHandler.onOfferMessage) // .on(ANSWER_MESSAGE, messageHandler.onAnswerMessage) // .on(ICE_CANDIDATE_MESSAGE, messageHandler.onCandidateMessage) .on(RTC_MESSAGE, messageHandler.onRtcMessage) .on(LEAVE_MESSAGE, messageHandler.onLeaveMessage) .on(AVAILABLE_USERS_MESSAGE, messageHandler.onAvailablePeersMessage) .on(PRESENCE_MESSAGE, messageHandler.onPresenceMessage); client.connect(); } }); }
From source file:com.roamprocess1.roaming4world.ui.messages.MessageActivity.java
public void imageSharing(Intent data, String type) { // Get the Uri of the selected file Uri uri = data.getData();// w w w.j ava2s . c o m Log.d("imageSharing - type", type + " @"); Log.d("File Uri: ", uri.toString() + " #"); // Get the path String path = null; try { path = getPath(this, uri); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } Log.d("File Path: ", path + " #"); if (path != null) { String userNum = prefs.getString(stored_user_country_code, "") + prefs.getString(stored_user_mobile_no, ""); String fileName = System.currentTimeMillis() + getFileFormat(path); String msg; if (type.equals("video")) { msg = "VID-" + userNum + "-" + fileName; } else if (type.equals("audio")) { msg = "AUD-" + userNum + "-" + fileName; } else { msg = "IMG-" + userNum + "-" + fileName; } String numb = prefs.getString(stored_chatuserNumber, ""); Log.d("nnumb", numb + " #"); String savefileuri = saveImage(path, fileName, stripNumber(numb)); if (savefileuri.equals(FILE_SIZE_ERROR + "")) { Toast toast = Toast.makeText(getApplicationContext(), "you upload file size is exceed to 30 MB", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } else if (!savefileuri.equals("")) { Log.d("msg1", msg + " !"); sendInitmsg(msg, numb); new AsyncTaskUploadFile(savefileuri, msg).execute(); } else { Toast.makeText(getApplicationContext(), "File not found", Toast.LENGTH_SHORT).show(); } } }