List of usage examples for java.net MalformedURLException printStackTrace
public void printStackTrace()
From source file:eu.impact_project.wsclient.XmlServiceProvider.java
private Service createServiceObjectFor(Node service) { int id = Integer.valueOf(service.getAttributes().getNamedItem("id").getTextContent()); String urlString = ""; String title = ""; String description = ""; NodeList nodes = service.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); String nodeName = node.getLocalName(); if (nodeName != null && nodeName.equals("url")) urlString = node.getTextContent(); else if (nodeName != null && nodeName.equals("title")) title = node.getTextContent(); else if (nodeName != null && nodeName.equals("description")) description = node.getTextContent().trim(); }// w w w . j a v a 2 s.c o m URL wsdlUrl = null; try { wsdlUrl = new URL(urlString); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (DOMException e) { // TODO Auto-generated catch block e.printStackTrace(); } Service result = new XmlService(id, title, description, wsdlUrl); return result; }
From source file:eu.optimis.mi.gui.server.MonitoringManagerWebServiceImpl.java
public List<MonitoringResource> getIdMetricDateListMonitoringResources(String id, String level, String metricName, String dfrom, String dto) { String xml = new String(""); String urlString = MMANAGER_URL + "QueryResources/date/metric/" + metricName + "/" + level + "/" + id + "/" + dfrom + "." + dto; try {/*from w w w . j av a 2 s . c om*/ URL url = new URL(urlString); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Accept", "application/XML"); if (conn.getResponseCode() != 200) { throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); } BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); System.out.println("Output from Server... \n" + dfrom.toString()); String li; while ((li = br.readLine()) != null) { xml = xml.concat(li); } conn.disconnect(); } catch (MalformedURLException e) { logger.debug("Could get resources from the URL:" + urlString); e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } XmlUtil util = new XmlUtil(); List<MonitoringResource> list; if (xml != null && xml.contains("metric_name")) { list = util.getMonitoringRsModel(xml); } else { list = new ArrayList<MonitoringResource>(); } return list; }
From source file:org.openbaton.autoscaling.core.detection.DetectionEngine.java
@Override public List<Item> queryPMJob(List<String> hostnames, List<String> metrics, String period) throws MonitoringException { log.debug("Requesting measurement results for hosts: " + hostnames + " on metrics: " + metrics + " (period: " + period + ")"); List<Item> items = new ArrayList<>(); for (String metric : metrics) { for (String hostName : hostnames) { try { URL url = new URL("http://" + monitorUrl + "/monitor/" + hostName + "/" + metric); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Accept", "application/json"); if (conn.getResponseCode() != 200) { throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); }//from w w w .ja v a 2s .co m BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); String output; while ((output = br.readLine()) != null) { log.debug("Measurement result for host " + hostName + " on metric " + metric + " is " + output); Item item = new Item(); item.setHostname(hostName); item.setHostId(hostName); item.setLastValue(output); item.setValue(output); item.setMetric(metric); items.add(item); } conn.disconnect(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } return items; }
From source file:py.pol.una.ii.pw.controller.RestEasyCliente.java
public void setCliente() { try {//from w w w . j av a 2 s . c om ClientRequest request = new ClientRequest("http://localhost:8080/EjbJaxRS-web/rest/clientes"); request.accept("application/json"); Clientes pr = new Clientes(); pr.setNombre(nombre); pr.setApellido(apellido); Gson p = new Gson(); request.body("application/json", p.toJson(pr)); ClientResponse<String> response = request.post(String.class); FacesMessage msg = new FacesMessage("Cliente", response.getEntity()); FacesContext.getCurrentInstance().addMessage(null, msg); nombre = null; apellido = null; } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.openmrs.module.dhisreport.web.controller.LocationMappingController.java
@RequestMapping(value = "/module/dhisreport/mapLocations", method = RequestMethod.GET) public void showConfigForm(ModelMap model, WebRequest webRequest) { DHIS2ReportingService service = Context.getService(DHIS2ReportingService.class); HttpDhis2Server server = service.getDhis2Server(); String dhisurl = Context.getAdministrationService().getGlobalProperty("dhisreport.dhis2URL"); String dhisusername = Context.getAdministrationService().getGlobalProperty("dhisreport.dhis2UserName"); String dhispassword = Context.getAdministrationService().getGlobalProperty("dhisreport.dhis2Password"); URL url = null;/*from w ww.j av a 2 s .co m*/ try { url = new URL(dhisurl); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } model.addAttribute("locationList", Context.getLocationService().getAllLocations()); Metadata metadata = null; List<OrganizationUnit> ou = null; Dhis2ServerController connection = new Dhis2ServerController(); boolean val = connection.testConnection(url, dhisusername, dhispassword, server, webRequest, model); if (val == true) { try { metadata = getDHIS2OrganizationUnits(); } catch (Exception e) { log.debug("Error in Unmarshalling"); e.printStackTrace(); } if (metadata != null) { ou = metadata.getOrganizationUnits().getOrganizationUnits(); model.addAttribute("orgunits", ou); HashMap<String, String> hm = new HashMap<String, String>(); List<Location> locationList = new ArrayList<Location>(); locationList.addAll(Context.getLocationService().getAllLocations()); for (Location l : locationList) { for (LocationAttribute la : l.getActiveAttributes()) { if (la.getAttributeType().getName().equals("CODE")) { if (la.getValue() != null) { for (OrganizationUnit o : ou) { if (la.getValue().equals(o.getCode())) { hm.put(l.getName(), o.getName()); } } } } } } model.addAttribute("map", hm); return; } } webRequest.setAttribute(WebConstants.OPENMRS_MSG_ATTR, Context.getMessageSourceService().getMessage("dhisreport.currentConnectionFail"), WebRequest.SCOPE_SESSION); model.addAttribute("orgunits", ou); }
From source file:eu.impact_project.wsclient.HtmlServiceProvider.java
public HtmlServiceProvider(URL url) throws ConfigurationException { configUrl = url;//from www.j a v a 2s. co m try { serverUrl = new URL(configUrl.toString() + "/synapse/"); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } loadServices(); }
From source file:py.pol.una.ii.pw.controller.RestEasyCliente.java
public void modificarCliente() { try {//from ww w .jav a2 s . com ClientRequest request = new ClientRequest("http://localhost:8080/EjbJaxRS-web/rest/clientes"); request.accept("application/json"); /*Cliente pr = new Cliente();*/ Clientes clienteModificado = new Clientes(); //clienteModificado.setId(idM); clienteModificado.setNombre(nombreM); clienteModificado.setApellido(apellidosM); Gson p = new Gson(); request.body("application/json", p.toJson(clienteModificado)); ClientResponse<String> response = request.put(String.class); FacesMessage msg = new FacesMessage("Clientes", response.getEntity()); FacesContext.getCurrentInstance().addMessage(null, msg); idM = null; nombreM = null; apellidosM = null; } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
From source file:net.refractions.udig.catalog.wmsc.server.TileImageReadWriter.java
public TileImageReadWriter(AbstractOpenWebService<?, ?> service, String baseDir) { try {// w ww.j av a2 s.com server = service.getInfo().getSource().toURL(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } this.baseTileFolder = baseDir + File.separator + baseSubTileFolder; }
From source file:com.jpeterson.littles3.bo.FileS3ObjectTest.java
/** * Test that an instance is serializable. *///from w ww. j a va 2 s . c om public void test_serialization() { FileS3Object s3Object, reconstitutedS3Object; ByteArrayInputStream bais; ByteArrayOutputStream baos; ObjectInputStream ois; ObjectOutputStream oos; URL storageUrl = null; try { storageUrl = new URL("file:///c:/"); } catch (MalformedURLException e1) { e1.printStackTrace(); fail("Unexpected exception"); } s3Object = new FileS3Object("bucket", "key", storageUrl); try { baos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(baos); oos.writeObject(s3Object); bais = new ByteArrayInputStream(baos.toByteArray()); ois = new ObjectInputStream(bais); reconstitutedS3Object = (FileS3Object) ois.readObject(); assertEquals("Unexpected value", "bucket", reconstitutedS3Object.getBucket()); assertEquals("Unexpected value", "key", reconstitutedS3Object.getKey()); assertEquals("Unexpected value", storageUrl, reconstitutedS3Object.getStorageUrl()); } catch (IOException e) { e.printStackTrace(); fail("Unexpected exception"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Unexpected exception"); } }
From source file:com.brightcove.zartan.encode.ZencodeAPI.java
@Override public Verifiable submitTranscode(TranscodeInfo transcode, TranscodeEnvironment env, Account acc) { VerifiableTranscode toVerify = new VerifiableTranscode(transcode, env, acc, TranscodeEntryPointEnum.ZENCODE_API); toVerify.setTranscodeTime(System.currentTimeMillis()); ZencoderCredentials zc = null;/*from w w w .j a v a 2 s . c om*/ for (Credentials c : acc.getCredentials()) { if (c instanceof ZencoderCredentials) { zc = (ZencoderCredentials) c; break; } } // TODO:throw if zc is bad // TODO:throw if env has a bad url URI targetURL = null; try { targetURL = new URL(env.getTranscodeApiUrl()).toURI(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } JsonNode response = encodeFile(transcode, targetURL, zc); System.out.println(response); for (JsonNode rend : response.get("outputs")) { toVerify.addTranscodedFile(new TranscodedVideoFile(rend.get("url").asText(), transcode.getOptionById(rend.get("label").asLong()))); } return toVerify; }