Example usage for org.apache.commons.httpclient HttpStatus SC_OK

List of usage examples for org.apache.commons.httpclient HttpStatus SC_OK

Introduction

In this page you can find the example usage for org.apache.commons.httpclient HttpStatus SC_OK.

Prototype

int SC_OK

To view the source code for org.apache.commons.httpclient HttpStatus SC_OK.

Click Source Link

Document

<tt>200 OK</tt> (HTTP/1.0 - RFC 1945)

Usage

From source file:it.eng.spagobi.engines.talend.client.SpagoBITalendEngineClient_0_5_0.java

public boolean deployJob(JobDeploymentDescriptor jobDeploymentDescriptor, File executableJobFiles)
        throws EngineUnavailableException, AuthenticationFailedException, ServiceInvocationFailedException {

    HttpClient client;//w  w  w  .j a v  a  2  s .  co  m
    PostMethod method;
    File deploymentDescriptorFile;
    boolean result = false;

    client = new HttpClient();
    method = new PostMethod(getServiceUrl(JOB_UPLOAD_SERVICE));
    deploymentDescriptorFile = null;

    try {
        deploymentDescriptorFile = File.createTempFile("deploymentDescriptor", ".xml"); //$NON-NLS-1$ //$NON-NLS-2$
        FileWriter writer = new FileWriter(deploymentDescriptorFile);
        writer.write(jobDeploymentDescriptor.toXml());
        writer.flush();
        writer.close();

        Part[] parts = { new FilePart(executableJobFiles.getName(), executableJobFiles),
                new FilePart("deploymentDescriptor", deploymentDescriptorFile) }; //$NON-NLS-1$

        method.setRequestEntity(new MultipartRequestEntity(parts, method.getParams()));

        client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);

        int status = client.executeMethod(method);
        if (status == HttpStatus.SC_OK) {
            if (method.getResponseBodyAsString().equalsIgnoreCase("OK")) //$NON-NLS-1$
                result = true;
        } else {
            throw new ServiceInvocationFailedException(
                    Messages.getString("SpagoBITalendEngineClient_0_5_0.serviceExcFailed") + JOB_UPLOAD_SERVICE, //$NON-NLS-1$
                    method.getStatusLine().toString(),
                    method.getResponseBodyAsString());
        }
    } catch (HttpException e) {
        throw new EngineUnavailableException(
                Messages.getString("SpagoBITalendEngineClient_0_5_0.protocolViolation") + e.getMessage()); //$NON-NLS-1$
    } catch (IOException e) {
        throw new EngineUnavailableException(
                Messages.getString("SpagoBITalendEngineClient_0_5_0.transportError") + e.getMessage()); //$NON-NLS-1$
    } finally {
        method.releaseConnection();
        if (deploymentDescriptorFile != null)
            deploymentDescriptorFile.delete();
    }

    return result;
}

From source file:com.owncloud.android.lib.resources.activities.GetRemoteActivitiesOperation.java

private boolean isSuccess(int status) {
    return (status == HttpStatus.SC_OK || status == HttpStatus.SC_NOT_MODIFIED);
}

From source file:edu.ku.brc.util.WebStoreAttachmentMgr.java

private void testKey() throws WebStoreAttachmentKeyException {
    if (testKeyURLStr == null)
        return; // skip test if there is not test url.

    GetMethod method = new GetMethod(testKeyURLStr);
    String r = "" + (new Random()).nextInt();
    method.setQueryString(new NameValuePair[] { new NameValuePair("random", r),
            new NameValuePair("token", generateToken(r)) });

    HttpClient client = new HttpClient();
    client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);

    try {/*from   w w  w . ja  v a2  s  . c om*/
        int status = client.executeMethod(method);
        updateServerTimeDelta(method);
        if (status == HttpStatus.SC_OK) {
            return;
        } else if (status == HttpStatus.SC_FORBIDDEN) {
            throw new WebStoreAttachmentKeyException("Attachment key is invalid.");
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        method.releaseConnection();
    }
    throw new WebStoreAttachmentKeyException("Problem verifying attachment key.");
}

From source file:com.mirth.connect.client.core.UpdateClient.java

public void registerUser(User user) throws ClientException {
    HttpClientParams httpClientParams = new HttpClientParams();
    HttpConnectionManager httpConnectionManager = new SimpleHttpConnectionManager();
    httpClientParams.setSoTimeout(10 * 1000);
    httpConnectionManager.getParams().setConnectionTimeout(10 * 1000);
    httpConnectionManager.getParams().setSoTimeout(10 * 1000);
    HttpClient httpClient = new HttpClient(httpClientParams, httpConnectionManager);

    PostMethod post = new PostMethod(client.getUpdateSettings().getUpdateUrl() + URL_REGISTRATION);
    NameValuePair[] params = { new NameValuePair("serverId", client.getServerId()),
            new NameValuePair("version", client.getVersion()),
            new NameValuePair("user", serializer.toXML(user)) };
    post.setRequestBody(params);/* ww  w . j a v a2 s.c  om*/

    try {
        int statusCode = httpClient.executeMethod(post);

        if ((statusCode != HttpStatus.SC_OK) && (statusCode != HttpStatus.SC_MOVED_TEMPORARILY)) {
            throw new Exception("Failed to connect to update server: " + post.getStatusLine());
        }
    } catch (Exception e) {
        throw new ClientException(e);
    } finally {
        post.releaseConnection();
    }
}

From source file:net.neurowork.cenatic.centraldir.workers.xml.OrganizacionXmlImporter.java

public void buscarOrganizacion(String token) {
    Organizacion organizacion = null;/*w  ww .j av  a  2  s. co m*/
    if (logger.isDebugEnabled())
        logger.debug("Buscando Organizaciones para Satelite: " + satelite);

    HttpClient httpclient = XMLRestWorker.getHttpClient();

    GetMethod get = new GetMethod(restUrl.getOrganizacionUrl());
    get.addRequestHeader("Accept", "application/xml");
    NameValuePair tokenParam = new NameValuePair("token", token);
    int id = 0;
    //      if(satelite.getLastOrgId() != null) 
    //         id = satelite.getLastOrgId();

    int leap = idLeap;

    while (true) {
        id = id + 1;

        if (logger.isTraceEnabled()) {
            logger.trace("Buscando Organizacion con id: " + id + " en el Satelite: " + satelite);
        }

        NameValuePair passwordParam = new NameValuePair("id", String.valueOf(id));
        NameValuePair[] params = new NameValuePair[] { tokenParam, passwordParam };

        get.setQueryString(params);
        String queryString = get.getQueryString();

        int statusCode;
        try {
            if (logger.isTraceEnabled()) {
                logger.trace("Query String: " + queryString);
            }

            statusCode = httpclient.executeMethod(get);
            if (statusCode != HttpStatus.SC_OK) {
                logger.error("Method failed: " + get.getStatusLine());
            } else {
                String xmlString = get.getResponseBodyAsString();
                if (logger.isInfoEnabled()) {
                    logger.info("Xml Received.");
                }

                String xmlHash = XMLRestWorker.constructXmlHash(xmlString);

                organizacion = organizacionService.findByHash(xmlHash);
                if (organizacion == null) {
                    organizacion = parseOrganizacion(xmlString);
                    if (organizacion == null) {
                        leap--;
                        if (leap <= 0) {
                            logger.info("Se lleg al fin de las Organizaciones. Saliendo del Satelite: "
                                    + satelite);
                            break;
                        } else {
                            logger.info("Leap: " + leap);
                        }
                    } else {
                        if (organizacion.getSatelites() == null) {
                            organizacion.setSatelites(new HashSet<OrganizacionSatelite>());
                        }
                        boolean sateliteFound = false;
                        for (OrganizacionSatelite sat : organizacion.getSatelites()) {
                            if (sat.getSatelite().getName().equals(satelite.getName())) {
                                sateliteFound = true;
                                break;
                            }
                        }
                        if (!sateliteFound) {
                            OrganizacionSatelite newSat = new OrganizacionSatelite();
                            newSat.setSatelite(satelite);
                            newSat.setOrganizacion(organizacion);
                            organizacion.getSatelites().add(newSat);
                        }

                        organizacion.setXmlHash(xmlHash);
                        organizacionService.saveOrganization(organizacion);

                        int numEmpresas = 0;
                        if (satelite.getNumEmpresas() != null) {
                            numEmpresas = satelite.getNumEmpresas();
                        }
                        numEmpresas++;

                        Date now = new Date();
                        satelite.setNumEmpresas(numEmpresas);
                        satelite.setLastRetrieval(new Timestamp(now.getTime()));
                        satelite.setLastOrgId(id);
                        sateliteService.saveSatelite(satelite);
                    }
                } else {
                    if (logger.isInfoEnabled()) {
                        logger.info("Organizacion with id: " + id + " already in centraldir");
                    }
                }
            }
        } catch (HttpException e) {
            logger.error(e.getMessage());
        } catch (IOException e) {
            logger.error(e.getMessage());
        } catch (ParserConfigurationException e) {
            logger.error(e.getMessage());
        } catch (SAXException e) {
            logger.error(e.getMessage());
        } catch (ServiceException e) {
            logger.error(e.getMessage());
        } catch (NoSuchAlgorithmException e) {
            logger.error(e.getMessage());
        } finally {
            get.releaseConnection();
        }
    }
}

From source file:com.intellij.coldFusion.mxunit.CfmlUnitRemoteTestsRunner.java

public static void executeScript(final CfmlUnitRunnerParameters params,
        final ProcessHandler processHandler/*final String webPath,
                                           final String componentFilePath,
                                           final String methodName,
                                           final ProcessHandler processHandler*/, final Project project)
        throws ExecutionException {
    final Ref<ExecutionException> ref = new Ref<>();

    ApplicationManager.getApplication().assertIsDispatchThread();

    ApplicationManager.getApplication().executeOnPooledThread(() -> {
        try {//from w w  w.  j  av  a2s .c  om
            final VirtualFile componentFile = LocalFileSystem.getInstance()
                    .refreshAndFindFileByPath(params.getPath());
            if (componentFile == null) {
                throw new ExecutionException("File " + params.getPath() + " not found");
            }

            // creating script files
            final VirtualFile directory = componentFile.getParent();
            final String launcherFileName = "mxunit-launcher.cfc";//generateUniqueName("mxunit-launcher", project);
            LOG.debug("Copying script file" + launcherFileName + " to component folder: " + directory);
            createFile(project, directory, launcherFileName, getLauncherText("/scripts/mxunit-launcher.cfc"));

            final String resultsFileName = "mxunit-result-capture.cfc";//generateUniqueName("mxunit-result-capture", project);
            LOG.debug("Copying results capture file " + resultsFileName + " to component folder: " + directory);
            createFile(project, directory, resultsFileName,
                    getLauncherText("/scripts/mxunit-result-capture.cfc"));

            // retrieving data through URL
            String webPath = params.getWebPath();
            if (webPath.endsWith("/") || webPath.endsWith("\\")) {
                webPath = webPath.substring(0, webPath.length() - 1);
            }
            String agentPath = webPath.substring(0, webPath.lastIndexOf('/')) + "/" + launcherFileName;
            LOG.debug("Retrieving data from coldfusion server by " + agentPath + " URL");
            BufferedReader reader = null;
            String agentUrl;
            if (params.getScope() == CfmlUnitRunnerParameters.Scope.Directory) {
                agentUrl = agentPath + "?method=executeDirectory&directoryName=" + componentFile.getName();
            } else {
                agentUrl = agentPath + "?method=executeTestCase&componentName="
                        + componentFile.getNameWithoutExtension();
                if (params.getScope() == CfmlUnitRunnerParameters.Scope.Method) {
                    agentUrl += "&methodName=" + params.getMethod();
                }
            }
            HttpMethod method = null;
            try {
                LOG.debug("Retrieving test results from: " + agentUrl);
                /*
                final FileObject httpFile = getManager().resolveFile(agentUrl);
                        
                reader = new BufferedReader(new InputStreamReader(httpFile.getContent().getInputStream()));
                */
                HttpClient client = new HttpClient();
                method = new GetMethod(agentUrl);
                int statusCode = client.executeMethod(method);
                if (statusCode != HttpStatus.SC_OK) {
                    LOG.debug("Http request failed: " + method.getStatusLine());
                    processHandler.notifyTextAvailable("Http request failed: " + method.getStatusLine(),
                            ProcessOutputTypes.SYSTEM);
                }
                final InputStream responseStream = method.getResponseBodyAsStream();
                reader = new BufferedReader(new InputStreamReader(responseStream));
                String line;
                while (!processHandler.isProcessTerminating() && !processHandler.isProcessTerminated()
                        && (line = reader.readLine()) != null) {
                    if (!StringUtil.isEmptyOrSpaces(line)) {
                        LOG.debug("MXUnit: " + line);
                        processHandler.notifyTextAvailable(line + "\n", ProcessOutputTypes.SYSTEM);
                    }
                }
            } catch (IOException e) {
                LOG.warn(e);
                processHandler.notifyTextAvailable(
                        "Failed to retrieve test results from the server at " + agentUrl + "\n",
                        ProcessOutputTypes.SYSTEM);
            } finally {
                if (method != null) {
                    method.releaseConnection();
                }
                if (reader != null) {
                    try {
                        reader.close();
                    } catch (IOException e) {
                        // ignore
                    }
                }
            }
            LOG.debug("Cleaning temporary files");
            deleteFile(project, directory.findChild(launcherFileName));
            deleteFile(project, directory.findChild(resultsFileName));
            if (!processHandler.isProcessTerminated() && !processHandler.isProcessTerminating()) {
                processHandler.destroyProcess();
            }
        } catch (ExecutionException e) {
            ref.set(e);
        }
    });
    if (!ref.isNull()) {
        throw ref.get();
    }
}

From source file:davmail.DavGateway.java

/**
 * Get latest released version from SourceForge.
 *
 * @return latest version/*from  ww w. j a  v a  2  s  . co m*/
 */
public static String getReleasedVersion() {
    String version = null;
    if (!Settings.getBooleanProperty("davmail.disableUpdateCheck")) {
        BufferedReader versionReader = null;
        GetMethod getMethod = new GetMethod(HTTP_DAVMAIL_SOURCEFORGE_NET_VERSION_TXT);
        try {
            HttpClient httpClient = DavGatewayHttpClientFacade
                    .getInstance(HTTP_DAVMAIL_SOURCEFORGE_NET_VERSION_TXT);
            int status = httpClient.executeMethod(getMethod);
            if (status == HttpStatus.SC_OK) {
                versionReader = new BufferedReader(new InputStreamReader(getMethod.getResponseBodyAsStream()));
                version = versionReader.readLine();
                LOGGER.debug("DavMail released version: " + version);
            }
        } catch (IOException e) {
            DavGatewayTray.debug(new BundleMessage("LOG_UNABLE_TO_GET_RELEASED_VERSION"));
        } finally {
            if (versionReader != null) {
                try {
                    versionReader.close();
                } catch (IOException e) {
                    // ignore
                }
            }
            getMethod.releaseConnection();
        }
    }
    return version;
}

From source file:com.dotcms.publisher.pusher.PushPublisher.java

@Override
public PublisherConfig process(final PublishStatus status) throws DotPublishingException {
    if (LicenseUtil.getLevel() < 300)
        throw new RuntimeException("need an enterprise pro license to run this bundler");

    PublishAuditHistory currentStatusHistory = null;
    try {//from  www .j ava 2 s .c  o m
        //Compressing bundle
        File bundleRoot = BundlerUtil.getBundleRoot(config);

        ArrayList<File> list = new ArrayList<File>(1);
        list.add(bundleRoot);
        File bundle = new File(
                bundleRoot + File.separator + ".." + File.separator + config.getId() + ".tar.gz");
        PushUtils.compressFiles(list, bundle, bundleRoot.getAbsolutePath());

        //Retriving enpoints and init client
        List<PublishingEndPoint> endpoints = ((PushPublisherConfig) config).getEndpoints();
        Map<String, List<PublishingEndPoint>> endpointsMap = new HashMap<String, List<PublishingEndPoint>>();
        List<PublishingEndPoint> buffer = null;
        //Organize the endpoints grouping them by groupId
        for (PublishingEndPoint pEndPoint : endpoints) {

            String gid = UtilMethods.isSet(pEndPoint.getGroupId()) ? pEndPoint.getGroupId() : pEndPoint.getId();

            if (endpointsMap.get(gid) == null)
                buffer = new ArrayList<PublishingEndPoint>();
            else
                buffer = endpointsMap.get(gid);

            buffer.add(pEndPoint);

            // put in map with either the group key or the id if no group is set
            endpointsMap.put(gid, buffer);

        }

        ClientConfig cc = new DefaultClientConfig();

        if (Config.getStringProperty("TRUSTSTORE_PATH") != null
                && !Config.getStringProperty("TRUSTSTORE_PATH").trim().equals(""))
            cc.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
                    new HTTPSProperties(tFactory.getHostnameVerifier(), tFactory.getSSLContext()));
        Client client = Client.create(cc);

        //Updating audit table
        currentStatusHistory = pubAuditAPI.getPublishAuditStatus(config.getId()).getStatusPojo();

        currentStatusHistory.setPublishStart(new Date());
        pubAuditAPI.updatePublishAuditStatus(config.getId(), PublishAuditStatus.Status.SENDING_TO_ENDPOINTS,
                currentStatusHistory);
        //Increment numTries
        currentStatusHistory.addNumTries();

        boolean hasError = false;
        int errorCounter = 0;

        for (String group : endpointsMap.keySet()) {
            List<PublishingEndPoint> groupList = endpointsMap.get(group);

            boolean sent = false;
            for (PublishingEndPoint endpoint : groupList) {
                EndpointDetail detail = new EndpointDetail();
                try {
                    FormDataMultiPart form = new FormDataMultiPart();
                    form.field("AUTH_TOKEN", retriveKeyString(
                            PublicEncryptionFactory.decryptString(endpoint.getAuthKey().toString())));

                    form.field("GROUP_ID", UtilMethods.isSet(endpoint.getGroupId()) ? endpoint.getGroupId()
                            : endpoint.getId());

                    form.field("ENDPOINT_ID", endpoint.getId());
                    form.bodyPart(new FileDataBodyPart("bundle", bundle, MediaType.MULTIPART_FORM_DATA_TYPE));

                    //Sending bundle to endpoint
                    WebResource resource = client.resource(endpoint.toURL() + "/api/bundlePublisher/publish");

                    ClientResponse response = resource.type(MediaType.MULTIPART_FORM_DATA)
                            .post(ClientResponse.class, form);

                    if (response.getClientResponseStatus().getStatusCode() == HttpStatus.SC_OK) {
                        detail.setStatus(PublishAuditStatus.Status.BUNDLE_SENT_SUCCESSFULLY.getCode());
                        detail.setInfo("Everything ok");
                        sent = true;
                    } else {
                        detail.setStatus(PublishAuditStatus.Status.FAILED_TO_SENT.getCode());
                        detail.setInfo("Returned " + response.getClientResponseStatus().getStatusCode()
                                + " status code " + "for the endpoint " + endpoint.getId() + "with address "
                                + endpoint.getAddress());
                    }
                } catch (Exception e) {
                    hasError = true;
                    detail.setStatus(PublishAuditStatus.Status.FAILED_TO_SENT.getCode());

                    String error = "An error occured for the endpoint " + endpoint.getId() + " with address "
                            + endpoint.getAddress() + ".  Error: " + e.getMessage();

                    detail.setInfo(error);

                    Logger.error(this.getClass(), error);
                }

                currentStatusHistory.addOrUpdateEndpoint(group, endpoint.getId(), detail);

                if (sent)
                    break;
            }

            if (!sent) {
                hasError = true;
                errorCounter++;
            }
        }

        if (!hasError) {
            //Updating audit table
            currentStatusHistory.setPublishEnd(new Date());
            pubAuditAPI.updatePublishAuditStatus(config.getId(),
                    PublishAuditStatus.Status.BUNDLE_SENT_SUCCESSFULLY, currentStatusHistory);

            //Deleting queue records
            //pubAPI.deleteElementsFromPublishQueueTable(config.getId());
        } else {
            if (errorCounter == endpointsMap.size()) {
                pubAuditAPI.updatePublishAuditStatus(config.getId(),
                        PublishAuditStatus.Status.FAILED_TO_SEND_TO_ALL_GROUPS, currentStatusHistory);
            } else {
                pubAuditAPI.updatePublishAuditStatus(config.getId(),
                        PublishAuditStatus.Status.FAILED_TO_SEND_TO_SOME_GROUPS, currentStatusHistory);
            }
        }

        return config;

    } catch (Exception e) {
        //Updating audit table
        try {
            pubAuditAPI.updatePublishAuditStatus(config.getId(), PublishAuditStatus.Status.FAILED_TO_PUBLISH,
                    currentStatusHistory);
        } catch (DotPublisherException e1) {
            throw new DotPublishingException(e.getMessage());
        }

        Logger.error(this.getClass(), e.getMessage(), e);
        throw new DotPublishingException(e.getMessage());

    }
}

From source file:edu.unc.lib.dl.ui.service.FedoraContentService.java

private void streamData(String simplepid, Datastream datastream, String slug, HttpServletResponse response,
        boolean asAttachment, int retryServerError) throws FedoraException, IOException {
    OutputStream outStream = response.getOutputStream();

    String dataUrl = fedoraUtil.getFedoraUrl() + "/objects/" + simplepid + "/datastreams/"
            + datastream.getName() + "/content";

    HttpClient client = HttpClientUtil.getAuthenticatedClient(dataUrl, accessClient.getUsername(),
            accessClient.getPassword());
    client.getParams().setAuthenticationPreemptive(true);
    GetMethod method = new GetMethod(dataUrl);
    method.addRequestHeader(HttpClientUtil.FORWARDED_GROUPS_HEADER, GroupsThreadStore.getGroupString());

    try {//from  w  w w . j a  v  a 2s. c o m
        client.executeMethod(method);

        if (method.getStatusCode() == HttpStatus.SC_OK) {
            if (response != null) {
                PID pid = new PID(simplepid);

                // Adjusting content related headers

                // Use the content length from Fedora it is not provided or negative, in which case use solr's
                long contentLength;
                try {
                    String contentLengthString = method.getResponseHeader("content-length").getValue();
                    contentLength = Long.parseLong(contentLengthString);
                } catch (Exception e) {
                    // If the content length wasn't provided or wasn't a number, set it to -1
                    contentLength = -1L;
                }
                if (contentLength < 0L) {
                    contentLength = datastream.getFilesize();
                }
                response.setHeader("Content-Length", Long.toString(contentLength));

                // Use Fedora's content type unless it is unset or octet-stream
                String mimeType;
                try {
                    mimeType = method.getResponseHeader("content-type").getValue();
                    if (mimeType == null || "application/octet-stream".equals(mimeType)) {
                        if ("mp3".equals(datastream.getExtension())) {
                            mimeType = "audio/mpeg";
                        } else {
                            mimeType = datastream.getMimetype();
                        }
                    }
                } catch (Exception e) {
                    mimeType = datastream.getMimetype();
                }
                response.setHeader("Content-Type", mimeType);

                // Setting the filename header for the response
                if (slug == null) {
                    slug = pid.getPid();
                }
                // For metadata types files, append the datastream name
                if (datastream.getDatastreamCategory().equals(DatastreamCategory.METADATA)
                        || datastream.getDatastreamCategory().equals(DatastreamCategory.ADMINISTRATIVE)) {
                    slug += "_" + datastream.getName();
                }
                // Add the file extension unless its already in there.
                if (datastream.getExtension() != null && datastream.getExtension().length() > 0
                        && !slug.toLowerCase().endsWith("." + datastream.getExtension())
                        && !"unknown".equals(datastream.getExtension())) {
                    slug += "." + datastream.getExtension();
                }
                if (asAttachment) {
                    response.setHeader("content-disposition", "attachment; filename=\"" + slug + "\"");
                } else {
                    response.setHeader("content-disposition", "inline; filename=\"" + slug + "\"");
                }
            }

            // Stream the content
            FileIOUtil.stream(outStream, method);
        } else if (method.getStatusCode() == HttpStatus.SC_FORBIDDEN) {
            throw new AuthorizationException(
                    "User does not have sufficient permissions to retrieve the specified object");
        } else {
            // Retry server errors
            if (method.getStatusCode() == 500 && retryServerError > 0) {
                LOG.warn("Failed to retrieve " + dataUrl + ", retrying.");
                this.streamData(simplepid, datastream, slug, response, asAttachment, retryServerError - 1);
            } else {
                throw new ResourceNotFoundException("Failure to stream fedora content due to response of: "
                        + method.getStatusLine().toString() + "\nPath was: " + dataUrl);
            }
        }
    } catch (ClientAbortException e) {
        if (LOG.isDebugEnabled())
            LOG.debug("User client aborted request to stream Fedora content for " + simplepid, e);
    } catch (HttpException e) {
        LOG.error("Error while attempting to stream Fedora content for " + simplepid, e);
    } catch (IOException e) {
        LOG.warn("Problem retrieving " + dataUrl + " for " + simplepid, e);
    } finally {
        if (method != null)
            method.releaseConnection();
    }
}

From source file:com.bigdata.rdf.sail.remoting.GraphRepositoryClient.java

/**
 * @see {@link GraphRepository#delete(String)}
 *///  w  w w . java  2 s. c  o  m
public void delete(String rdfXml) throws Exception {

    // DELETE
    DeleteMethod del = new DeleteMethod(servletURL);
    try {

        // add the range header
        if (rdfXml != null) {
            String triples = "triples[" + trim(rdfXml) + "]";
            Header range = new Header(GraphRepositoryServlet.HTTP_RANGE, triples);
            del.addRequestHeader(range);
        }

        // Execute the method.
        int sc = getHttpClient().executeMethod(del);
        if (sc != HttpStatus.SC_OK) {
            throw new IOException("HTTP-DELETE failed: " + del.getStatusLine());
        }

    } finally {
        // Release the connection.
        del.releaseConnection();
    }

}