List of usage examples for java.net URISyntaxException getMessage
public String getMessage()
From source file:org.apache.hadoop.hive.ql.session.SessionState.java
public void delete_resources(ResourceType t, List<String> values) { Set<String> resources = resourceMaps.getResourceSet(t); if (resources == null || resources.isEmpty()) { return;//from w ww . j a va2 s.c o m } Map<String, Set<String>> resourcePathMap = resourceMaps.getResourcePathMap(t); Map<String, Set<String>> reverseResourcePathMap = resourceMaps.getReverseResourcePathMap(t); List<String> deleteList = new LinkedList<String>(); for (String value : values) { String key = value; try { if (ResourceDownloader.isIvyUri(value)) { key = ResourceDownloader.createURI(value).getAuthority(); } } catch (URISyntaxException e) { throw new RuntimeException("Invalid uri string " + value + ", " + e.getMessage()); } // get all the dependencies to delete Set<String> resourcePaths = resourcePathMap.get(key); if (resourcePaths == null) { return; } for (String resourceValue : resourcePaths) { reverseResourcePathMap.get(resourceValue).remove(key); // delete a dependency only if no other resource depends on it. if (reverseResourcePathMap.get(resourceValue).isEmpty()) { deleteList.add(resourceValue); reverseResourcePathMap.remove(resourceValue); } } resourcePathMap.remove(key); } t.postHook(resources, deleteList); resources.removeAll(deleteList); }
From source file:org.dasein.cloud.zimory.ZimoryMethod.java
public @Nullable String getString(@Nonnull String resource) throws InternalException, CloudException { if (logger.isTraceEnabled()) { logger.trace("ENTER - " + Zimory.class.getName() + ".getString(" + resource + ")"); }/* w w w . ja v a2 s .c o m*/ try { String target = getEndpoint(resource); if (wire.isDebugEnabled()) { wire.debug(""); wire.debug(">>> [GET (" + (new Date()) + ")] -> " + target + " >--------------------------------------------------------------------------------------"); } try { URI uri; try { uri = new URI(target); } catch (URISyntaxException e) { throw new ZimoryConfigurationException(e); } HttpClient client = getClient(uri); try { ProviderContext ctx = provider.getContext(); if (ctx == null) { throw new NoContextException(); } HttpGet get = new HttpGet(target); if (wire.isDebugEnabled()) { wire.debug(get.getRequestLine().toString()); for (Header header : get.getAllHeaders()) { wire.debug(header.getName() + ": " + header.getValue()); } wire.debug(""); } HttpResponse response; StatusLine status; try { APITrace.trace(provider, "GET " + resource); response = client.execute(get); status = response.getStatusLine(); } catch (IOException e) { logger.error("Failed to execute HTTP request due to a cloud I/O error: " + e.getMessage()); throw new CloudException(e); } if (logger.isDebugEnabled()) { logger.debug("HTTP Status " + status); } Header[] headers = response.getAllHeaders(); if (wire.isDebugEnabled()) { wire.debug(status.toString()); for (Header h : headers) { if (h.getValue() != null) { wire.debug(h.getName() + ": " + h.getValue().trim()); } else { wire.debug(h.getName() + ":"); } } wire.debug(""); } if (status.getStatusCode() == NOT_FOUND) { return null; } if (status.getStatusCode() != OK && status.getStatusCode() != NO_CONTENT) { logger.error("Expected OK for GET request, got " + status.getStatusCode()); HttpEntity entity = response.getEntity(); String body; if (entity == null) { throw new ZimoryException(CloudErrorType.GENERAL, status.getStatusCode(), status.getReasonPhrase(), status.getReasonPhrase()); } try { body = EntityUtils.toString(entity); } catch (IOException e) { throw new ZimoryException(e); } if (wire.isDebugEnabled()) { wire.debug(body); } wire.debug(""); if (status.getStatusCode() == BAD_REQUEST && body.contains("could not be found")) { return null; } throw new ZimoryException(CloudErrorType.GENERAL, status.getStatusCode(), status.getReasonPhrase(), body); } else { HttpEntity entity = response.getEntity(); if (entity == null) { return ""; } String body; try { body = EntityUtils.toString(entity); } catch (IOException e) { throw new ZimoryException(e); } if (wire.isDebugEnabled()) { wire.debug(body); } wire.debug(""); return body; } } finally { try { client.getConnectionManager().shutdown(); } catch (Throwable ignore) { } } } finally { if (wire.isDebugEnabled()) { wire.debug("<<< [GET (" + (new Date()) + ")] -> " + target + " <--------------------------------------------------------------------------------------"); wire.debug(""); } } } finally { if (logger.isTraceEnabled()) { logger.trace("EXIT - " + Zimory.class.getName() + ".getString()"); } } }
From source file:org.dasein.cloud.zimory.ZimoryMethod.java
public void delete(@Nonnull String resource) throws InternalException, CloudException { if (logger.isTraceEnabled()) { logger.trace("ENTER - " + Zimory.class.getName() + ".delete(" + resource + ")"); }//from w w w . j a va 2 s . c o m try { String target = getEndpoint(resource); if (wire.isDebugEnabled()) { wire.debug(""); wire.debug(">>> [DELETE (" + (new Date()) + ")] -> " + target + " >--------------------------------------------------------------------------------------"); } try { URI uri; try { uri = new URI(target); } catch (URISyntaxException e) { throw new ZimoryConfigurationException(e); } HttpClient client = getClient(uri); try { ProviderContext ctx = provider.getContext(); if (ctx == null) { throw new NoContextException(); } HttpDelete delete = new HttpDelete(target); if (wire.isDebugEnabled()) { wire.debug(delete.getRequestLine().toString()); for (Header header : delete.getAllHeaders()) { wire.debug(header.getName() + ": " + header.getValue()); } wire.debug(""); } HttpResponse response; StatusLine status; try { APITrace.trace(provider, "DELETE " + resource); response = client.execute(delete); status = response.getStatusLine(); } catch (IOException e) { logger.error("Failed to execute HTTP request due to a cloud I/O error: " + e.getMessage()); throw new CloudException(e); } if (logger.isDebugEnabled()) { logger.debug("HTTP Status " + status); } Header[] headers = response.getAllHeaders(); if (wire.isDebugEnabled()) { wire.debug(status.toString()); for (Header h : headers) { if (h.getValue() != null) { wire.debug(h.getName() + ": " + h.getValue().trim()); } else { wire.debug(h.getName() + ":"); } } wire.debug(""); } if (status.getStatusCode() == NOT_FOUND) { throw new CloudException("No such endpoint: " + resource); } if (status.getStatusCode() != OK && status.getStatusCode() != NO_CONTENT) { logger.error("Expected OK or NO CONTENT for DELETE request, got " + status.getStatusCode()); HttpEntity entity = response.getEntity(); if (entity == null) { throw new ZimoryException(CloudErrorType.GENERAL, status.getStatusCode(), status.getReasonPhrase(), status.getReasonPhrase()); } String body; try { body = EntityUtils.toString(entity); } catch (IOException e) { throw new ZimoryException(e); } if (wire.isDebugEnabled()) { wire.debug(body); } wire.debug(""); throw new ZimoryException(CloudErrorType.GENERAL, status.getStatusCode(), status.getReasonPhrase(), body); } } finally { try { client.getConnectionManager().shutdown(); } catch (Throwable ignore) { } } } finally { if (wire.isDebugEnabled()) { wire.debug("<<< [DELETE (" + (new Date()) + ")] -> " + target + " <--------------------------------------------------------------------------------------"); wire.debug(""); } } } finally { if (logger.isTraceEnabled()) { logger.trace("EXIT - " + Zimory.class.getName() + ".delete()"); } } }
From source file:com.googlecode.jdeltasync.DeltaSyncClient.java
/** * Slightly modified version of {@link DefaultRedirectStrategy#getLocationURI(HttpRequest, HttpResponse, HttpContext)} * which also adds the query string from the original request URI to the new URI. *///w w w .ja va 2 s . c om private URI getRedirectLocationURI(IDeltaSyncSession session, HttpUriRequest request, HttpResponse response, HttpContext context) throws DeltaSyncException { //get the location header to find out where to redirect to Header locationHeader = response.getFirstHeader("location"); if (locationHeader == null) { // got a redirect response, but no location header throw new DeltaSyncException( "Received redirect response " + response.getStatusLine() + " but no location header"); } String location = locationHeader.getValue(); if (session.getLogger().isDebugEnabled()) { session.getLogger().debug("Redirect requested to location '" + location + "'"); } URI uri = null; try { uri = new URI(location); if (request.getURI().getRawQuery() != null) { String query = request.getURI().getRawQuery(); uri = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath(), query, uri.getFragment()); } } catch (URISyntaxException ex) { throw new DeltaSyncException("Invalid redirect URI: " + location, ex); } final HttpClientContext clientContext = HttpClientContext.adapt(context); final RequestConfig config = clientContext.getRequestConfig(); // rfc2616 demands the location value be a complete URI // Location = "Location" ":" absoluteURI try { if (!uri.isAbsolute()) { if (config.isRelativeRedirectsAllowed()) { throw new DeltaSyncException("Relative redirect location '" + uri + "' not allowed"); } // Adjust location URI HttpHost target = clientContext.getTargetHost(); if (target == null) { throw new IllegalStateException("Target host not available " + "in the HTTP context"); } URI requestURI = new URI(request.getRequestLine().getUri()); URI absoluteRequestURI = URIUtils.rewriteURI(requestURI, target, false); uri = URIUtils.resolve(absoluteRequestURI, uri); } } catch (URISyntaxException ex) { throw new DeltaSyncException(ex.getMessage(), ex); } RedirectLocations redirectLocations = (RedirectLocations) clientContext .getAttribute("http.protocol.redirect-locations"); if (redirectLocations == null) { redirectLocations = new RedirectLocations(); context.setAttribute("http.protocol.redirect-locations", redirectLocations); } if (config.isCircularRedirectsAllowed()) { URI redirectURI; if (uri.getFragment() != null) { try { HttpHost target = new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme()); redirectURI = URIUtils.rewriteURI(uri, target, true); } catch (URISyntaxException ex) { throw new DeltaSyncException(ex.getMessage(), ex); } } else { redirectURI = uri; } if (redirectLocations.contains(redirectURI)) { throw new DeltaSyncException("Circular redirect to '" + redirectURI + "'"); } else { redirectLocations.add(redirectURI); } } return uri; }
From source file:de.betterform.connector.SchemaValidator.java
/** * validate the instance according to the schema specified on the model * * @return false if the instance is not valid *//*from ww w . java 2 s .com*/ public boolean validateSchema(Model model, Node instance) throws XFormsException { boolean valid = true; String message; if (LOGGER.isDebugEnabled()) LOGGER.debug("SchemaValidator.validateSchema: validating instance"); //needed if we want to load schemas from Model + set it as "schemaLocation" attribute String schemas = model.getElement().getAttributeNS(NamespaceConstants.XFORMS_NS, "schema"); if (schemas != null && !schemas.equals("")) { // valid=false; //add schemas to element //shouldn't it be done on a copy of the doc ? Element el = null; if (instance.getNodeType() == Node.ELEMENT_NODE) el = (Element) instance; else if (instance.getNodeType() == Node.DOCUMENT_NODE) el = ((Document) instance).getDocumentElement(); else { if (LOGGER.isDebugEnabled()) LOGGER.debug("instance node type is: " + instance.getNodeType()); } String prefix = NamespaceResolver.getPrefix(el, NamespaceConstants.XMLSCHEMA_INSTANCE_NS); //test if with targetNamespace or not //if more than one schema : namespaces are mandatory ! (optional only for 1) StringTokenizer tokenizer = new StringTokenizer(schemas, " ", false); String schemaLocations = null; String noNamespaceSchemaLocation = null; while (tokenizer.hasMoreElements()) { String token = (String) tokenizer.nextElement(); //check that it is an URL URI uri = null; try { uri = new java.net.URI(token); } catch (java.net.URISyntaxException ex) { if (LOGGER.isDebugEnabled()) LOGGER.debug(token + " is not an URI"); } if (uri != null) { String ns; try { ns = this.getSchemaNamespace(uri); if (ns != null && !ns.equals("")) { if (schemaLocations == null) schemaLocations = ns + " " + token; else schemaLocations = schemaLocations + " " + ns + " " + token; ///add the namespace declaration if it is not on the instance? //TODO: how to know with which prefix ? String nsPrefix = NamespaceResolver.getPrefix(el, ns); if (nsPrefix == null) { //namespace not declared ! LOGGER.warn("SchemaValidator: targetNamespace " + ns + " of schema " + token + " is not declared in instance: declaring it as default..."); el.setAttributeNS(NamespaceConstants.XMLNS_NS, NamespaceConstants.XMLNS_PREFIX, ns); } } else if (noNamespaceSchemaLocation == null) noNamespaceSchemaLocation = token; else { //we have more than one schema without namespace LOGGER.warn("SchemaValidator: There is more than one schema without namespace !"); } } catch (Exception ex) { LOGGER.warn( "Exception while trying to load schema: " + uri.toString() + ": " + ex.getMessage(), ex); //in case there was an exception: do nothing, do not set the schema } } } //write schemaLocations found if (schemaLocations != null && !schemaLocations.equals("")) el.setAttributeNS(NamespaceConstants.XMLSCHEMA_INSTANCE_NS, prefix + ":schemaLocation", schemaLocations); if (noNamespaceSchemaLocation != null) el.setAttributeNS(NamespaceConstants.XMLSCHEMA_INSTANCE_NS, prefix + ":noNamespaceSchemaLocation", noNamespaceSchemaLocation); //save and parse the doc ValidationErrorHandler handler = null; File f; try { //save document f = File.createTempFile("instance", ".xml"); f.deleteOnExit(); TransformerFactory trFact = TransformerFactory.newInstance(); Transformer trans = trFact.newTransformer(); DOMSource source = new DOMSource(el); StreamResult result = new StreamResult(f); trans.transform(source, result); if (LOGGER.isDebugEnabled()) LOGGER.debug("Validator.validateSchema: file temporarily saved in " + f.getAbsolutePath()); //parse it with error handler to validate it handler = new ValidationErrorHandler(); SAXParserFactory parserFact = SAXParserFactory.newInstance(); parserFact.setValidating(true); parserFact.setNamespaceAware(true); SAXParser parser = parserFact.newSAXParser(); XMLReader reader = parser.getXMLReader(); //validation activated reader.setFeature("http://xml.org/sax/features/validation", true); //schema validation activated reader.setFeature("http://apache.org/xml/features/validation/schema", true); //used only to validate the schema, not the instance //reader.setFeature( "http://apache.org/xml/features/validation/schema-full-checking", true); //validate only if there is a grammar reader.setFeature("http://apache.org/xml/features/validation/dynamic", true); parser.parse(f, handler); } catch (Exception ex) { LOGGER.warn("Validator.validateSchema: Exception in XMLSchema validation: " + ex.getMessage(), ex); //throw new XFormsException("XMLSchema validation failed. "+message); } //if no exception if (handler != null && handler.isValid()) valid = true; else { message = handler.getMessage(); //TODO: find a way to get the error message displayed throw new XFormsException("XMLSchema validation failed. " + message); } if (LOGGER.isDebugEnabled()) LOGGER.debug("Validator.validateSchema: result=" + valid); } return valid; }
From source file:com.google.vrtoolkit.cardboard.samples.treasurehunt.MainActivity.java
private void connectWebSocket() { URI uri;/* ww w . j a v a2 s. c om*/ try { //uri = new URI("ws://192.168.0.105:6437/"); uri = new URI("ws://172.20.10.4:6437/"); } catch (URISyntaxException e) { e.printStackTrace(); return; } mWebSocketClient = new WebSocketClient(uri) { @Override public void onOpen(ServerHandshake serverHandshake) { Log.i("Websocket", "Opened"); } @Override public void onMessage(String s) { final String message = s; //Log.i("Websocket_message", s); try { JSONObject obj = new JSONObject(s); JSONArray pos = obj.getJSONArray("hands").getJSONObject(0).getJSONArray("palmPosition"); handPos[0] = (float) pos.getDouble(0); handPos[1] = (float) pos.getDouble(1); handPos[2] = (float) pos.getDouble(2); Log.i("Websocket_json", String.format("(%f, %f, %f)", handPos[0], handPos[1], handPos[2])); } catch (JSONException e) { Log.i("Websocket_json", "Not the right json obj"); } } @Override public void onClose(int i, String s, boolean b) { Log.i("Websocket", "Closed " + s); } @Override public void onError(Exception e) { Log.i("Websocket", "Error " + e.getMessage()); } }; mWebSocketClient.connect(); }
From source file:com.almende.eve.transport.http.AgentServlet.java
/** * Send a JSON-RPC message to an agent Usage: POST /servlet/{agentId} With a * JSON-RPC request as body. Response will be a JSON-RPC response. * // w w w . jav a 2 s .c o m * @param req * the req * @param resp * the resp * @throws IOException * Signals that an I/O exception has occurred. * @throws ServletException * the servlet exception */ @Override public void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws IOException, ServletException { // retrieve the agent url and the request body final String body = StringUtil.streamToString(req.getInputStream()); final String agentUrl = req.getRequestURI(); String agentId; try { agentId = httpTransport.getAgentId(new URI(agentUrl)); } catch (URISyntaxException e) { throw new ServletException(AGENTURLWARNING, e); } if (agentId == null || agentId.equals("")) { resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "No agentId found in url."); resp.flushBuffer(); return; } if (host.hasPrivate(agentId) && !handleSession(req, resp)) { if (!resp.isCommitted()) { resp.sendError(HttpServletResponse.SC_UNAUTHORIZED); } resp.flushBuffer(); return; } // Attach the claimed senderId, or null if not given. String senderUrl = req.getHeader("X-Eve-SenderUrl"); if (senderUrl == null || senderUrl.equals("")) { senderUrl = "web://" + req.getRemoteUser() + "@" + req.getRemoteAddr(); } final String tag = new UUID().toString(); final SyncCallback<String> callback = new SyncCallback<String>(); final AsyncCallbackQueue<String> callbacks = host.getCallbackQueue("HttpTransport", String.class); callbacks.push(tag, "", callback); //TODO: check if it's base64 encoded data, decode to byte[] and call receive byte[]. host.receive(agentId, body, URI.create(senderUrl), tag); try { final Object message = callback.get(); // return response resp.addHeader("Content-Type", "application/json"); resp.getWriter().println(message.toString()); resp.getWriter().close(); } catch (final Exception e) { LOG.log(Level.WARNING, "Http Sync receive raised exception.", e); resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Receiver raised exception:" + e.getMessage()); } resp.flushBuffer(); }
From source file:io.github.tavernaextras.biocatalogue.integration.Integration.java
/** * Adds a processor to the current workflow. * The processor is specified by WSDL location and the operation name. * //ww w .j a v a2s . co m * @param processorResource Resource to add to the current workflow. * @return Outcome of inserting the processor into the current workflow as a * HTML-formatted string (with no opening and closing HTML tags). */ public static JComponent insertProcessorIntoCurrentWorkflow(ResourceLink processorResource) { // check if this type of resource can be added to workflow diagram TYPE resourceType = Resource.getResourceTypeFromResourceURL(processorResource.getHref()); if (resourceType.isSuitableForAddingToWorkflowDiagram()) { switch (resourceType) { case SOAPOperation: SoapOperation soapOp = (SoapOperation) processorResource; try { SoapService soapService = BioCatalogueClient.getInstance() .getBioCatalogueSoapService(soapOp.getAncestors().getSoapService().getHref()); try { WSDLServiceDescription myServiceDescription = new WSDLServiceDescription(); myServiceDescription.setOperation(soapOp.getName()); myServiceDescription.setUse("literal"); // or "encoded" myServiceDescription.setStyle("document"); // or "rpc" myServiceDescription.setURI(new URI(soapService.getWsdlLocation())); myServiceDescription .setDescription(StringEscapeUtils.escapeHtml(soapService.getDescription())); // TODO - not sure where this is used if (WorkflowView.importServiceDescription(myServiceDescription, false) != null) { return (new JLabel( "Selected " + TYPE.SOAPOperation.getTypeName() + " was successfully added to the current workflow", ResourceManager.getImageIcon(ResourceManager.TICK_ICON), JLabel.CENTER)); } else { return (new JLabel("<html><center>Taverna was unable to add selected " + TYPE.SOAPOperation.getTypeName() + " as a service to the current workflow.<br>This could be because the service is currently not accessible.</center></html>", ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); } } catch (URISyntaxException e) { logger.error("Couldn't add " + TYPE.SOAPOperation + " to the current workflow", e); return (new JLabel( "<html>Could not add the selected " + TYPE.SOAPOperation.getTypeName() + " to the current workflow.<br>" + "Log file will containt additional details about this error.</html>", ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); } } catch (Exception e) { logger.error("Failed to fetch required details to add this " + TYPE.SOAPOperation + " into the current workflow.", e); return (new JLabel( "<html>Failed to fetch required details to add this<br>" + TYPE.SOAPOperation.getTypeName() + " into the current workflow.</html>", ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); } case RESTMethod: // received object may only contain limited data, therefore need to fetch full details first try { RestMethod restMethod = BioCatalogueClient.getInstance() .getBioCatalogueRestMethod(processorResource.getHref()); // actual import of the service into the workflow RESTFromBioCatalogueServiceDescription restServiceDescription = createRESTServiceDescriptionFromRESTMethod( restMethod); WorkflowView.importServiceDescription(restServiceDescription, false); // prepare result of the operation to be shown in the the waiting dialog window String warnings = extractWarningsFromRESTServiceDescription(restServiceDescription, false); JLabel outcomes = new JLabel( "<html>Selected " + TYPE.RESTMethod.getTypeName() + " was successfully added to the current workflow" + warnings + "</html>", ResourceManager.getImageIcon(warnings.length() > 0 ? ResourceManager.WARNING_ICON : ResourceManager.TICK_ICON), JLabel.CENTER); outcomes.setIconTextGap(20); return (outcomes); } catch (UnsupportedHTTPMethodException e) { logger.error(e); return (new JLabel(e.getMessage(), ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); } catch (Exception e) { logger.error("Failed to fetch required details to add this " + TYPE.RESTMethod + " as a service to the current workflow.", e); return (new JLabel( "<html>Failed to fetch required details to add this " + TYPE.RESTMethod.getTypeName() + "<br>" + "as a service to the current workflow.</html>", ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); } // type not currently supported, but maybe in the future? default: return (new JLabel( "Adding " + resourceType.getCollectionName() + " to the current workflow is not yet possible", ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); } } // definitely not supported type return (new JLabel( "<html>It is not possible to add resources of the provided type<br>" + "into the current workflow.</html>", ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); }
From source file:org.dasein.cloud.tier3.APIHandler.java
public void delete(@Nonnull String resource, @Nonnull String id, @Nullable NameValuePair... parameters) throws InternalException, CloudException { if (logger.isTraceEnabled()) { logger.trace("ENTER - " + APIHandler.class.getName() + ".delete(" + resource + "," + id + "," + Arrays.toString(parameters) + ")"); }//w w w .ja va 2 s .co m try { String target = getEndpoint(resource, id, parameters); if (wire.isDebugEnabled()) { wire.debug(""); wire.debug(">>> [DELETE (" + (new Date()) + ")] -> " + target + " >--------------------------------------------------------------------------------------"); } try { URI uri; try { uri = new URI(target); } catch (URISyntaxException e) { throw new ConfigurationException(e); } HttpClient client = getClient(uri); try { ProviderContext ctx = provider.getContext(); if (ctx == null) { throw new NoContextException(); } HttpDelete delete = new HttpDelete(target); delete.addHeader("Accept", "application/json"); delete.addHeader("Content-type", "application/json"); delete.addHeader("Cookie", provider.logon()); if (wire.isDebugEnabled()) { wire.debug(delete.getRequestLine().toString()); for (Header header : delete.getAllHeaders()) { wire.debug(header.getName() + ": " + header.getValue()); } wire.debug(""); } HttpResponse apiResponse; StatusLine status; try { APITrace.trace(provider, "DELETE " + resource); apiResponse = client.execute(delete); status = apiResponse.getStatusLine(); } catch (IOException e) { logger.error("Failed to execute HTTP request due to a cloud I/O error: " + e.getMessage()); throw new CloudException(e); } if (logger.isDebugEnabled()) { logger.debug("HTTP Status " + status); } Header[] headers = apiResponse.getAllHeaders(); if (wire.isDebugEnabled()) { wire.debug(status.toString()); for (Header h : headers) { if (h.getValue() != null) { wire.debug(h.getName() + ": " + h.getValue().trim()); } else { wire.debug(h.getName() + ":"); } } wire.debug(""); } if (status.getStatusCode() == NOT_FOUND) { throw new CloudException("No such endpoint: " + target); } if (status.getStatusCode() != NO_CONTENT) { logger.error("Expected NO CONTENT for DELETE request, got " + status.getStatusCode()); HttpEntity entity = apiResponse.getEntity(); if (entity == null) { throw new Tier3Exception(CloudErrorType.GENERAL, status.getStatusCode(), status.getReasonPhrase(), status.getReasonPhrase()); } String body; try { body = EntityUtils.toString(entity); } catch (IOException e) { throw new Tier3Exception(e); } if (wire.isDebugEnabled()) { wire.debug(body); } wire.debug(""); throw new Tier3Exception(CloudErrorType.GENERAL, status.getStatusCode(), status.getReasonPhrase(), body); } } finally { try { client.getConnectionManager().shutdown(); } catch (Throwable ignore) { } } } finally { if (wire.isDebugEnabled()) { wire.debug("<<< [DELETE (" + (new Date()) + ")] -> " + target + " <--------------------------------------------------------------------------------------"); wire.debug(""); } } } finally { if (logger.isTraceEnabled()) { logger.trace("EXIT - " + APIHandler.class.getName() + ".delete()"); } } }