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

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

Introduction

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

Prototype

int SC_NOT_FOUND

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

Click Source Link

Document

<tt>404 Not Found</tt> (HTTP/1.0 - RFC 1945)

Usage

From source file:com.github.maven.plugin.client.impl.GithubClientImpl.java

public Set<String> listAvailableDownloads(String repositoryUrl) {
    assertStartsWith(repositoryUrl, GITHUB_REPOSITORY_URL_PREFIX, "repositoryUrl");

    final Set<String> downloads = new HashSet<String>();
    final GetMethod githubGet = new GetMethod(toRepositoryDownloadUrl(repositoryUrl));

    int response;

    try {/*from   w w  w. ja va 2s .c om*/

        response = httpClient.executeMethod(githubGet);
    } catch (IOException e) {
        throw new GithubRepositoryNotFoundException(
                "Cannot retrieve github repository " + repositoryUrl + " informations", e);
    }

    if (response == HttpStatus.SC_OK) {

        String githubResponse;

        try {

            githubResponse = githubGet.getResponseBodyAsString();
        } catch (IOException e) {
            throw new GithubRepositoryNotFoundException(
                    "Cannot retrieve github repository " + repositoryUrl + "  informations", e);
        }

        Pattern pattern = Pattern.compile(
                String.format("<a href=\"/downloads%s/?([^\"]+)\"", removeGithubUrlPart(repositoryUrl)));

        Matcher matcher = pattern.matcher(githubResponse);
        while (matcher.find()) {
            downloads.add(matcher.group(1));
        }

    } else if (response == HttpStatus.SC_NOT_FOUND) {
        throw new GithubRepositoryNotFoundException("Cannot found repository " + repositoryUrl);
    } else {
        throw new GithubRepositoryNotFoundException(
                "Cannot retrieve github repository " + repositoryUrl + " informations");
    }

    githubGet.releaseConnection();

    return downloads;
}

From source file:io.pravega.segmentstore.storage.impl.extendeds3.S3FileSystemImpl.java

@Synchronized
@Override//  w  w w  . j  a va2  s.  com
public void setObjectAcl(String bucketName, String key, AccessControlList acl) {
    AclSize retVal = aclMap.get(key);
    if (retVal == null) {
        throw new S3Exception("NoObject", HttpStatus.SC_NOT_FOUND, "NoSuchKey", key);
    }
    aclMap.put(key, retVal.withAcl(acl));
}

From source file:com.zimbra.qa.unittest.TestWsdlServlet.java

public void testWsdlServletInvalidPathForWsdl() throws Exception {
    doWsdlServletRequest(wsdlUrlBase + "NonExistentService.wsdl", true, HttpStatus.SC_NOT_FOUND);
}

From source file:com.zimbra.cs.store.http.HttpStoreManager.java

@Override
public boolean deleteFromStore(String locator, Mailbox mbox) throws IOException {
    HttpClient client = ZimbraHttpConnectionManager.getInternalHttpConnMgr().newHttpClient();
    DeleteMethod delete = new DeleteMethod(getDeleteUrl(mbox, locator));
    try {/* w  w w . ja va2 s  .  c  o  m*/
        int statusCode = HttpClientUtil.executeMethod(client, delete);
        if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_NO_CONTENT) {
            return true;
        } else if (statusCode == HttpStatus.SC_NOT_FOUND) {
            return false;
        } else {
            throw new IOException("unexpected return code during blob DELETE: " + delete.getStatusText());
        }
    } finally {
        delete.releaseConnection();
    }
}

From source file:com.cerema.cloud2.lib.resources.files.ExistenceCheckRemoteOperation.java

@Override
protected RemoteOperationResult run(OwnCloudClient client) {
    RemoteOperationResult result = null;
    HeadMethod head = null;//from  w w  w  .  j  av  a2s .c  om
    boolean previousFollowRedirects = client.getFollowRedirects();
    try {
        head = new HeadMethod(client.getWebdavUri() + WebdavUtils.encodePath(mPath));
        client.setFollowRedirects(false);
        int status = client.executeMethod(head, TIMEOUT, TIMEOUT);
        if (previousFollowRedirects) {
            mRedirectionPath = client.followRedirection(head);
            status = mRedirectionPath.getLastStatus();
        }
        client.exhaustResponse(head.getResponseBodyAsStream());
        boolean success = (status == HttpStatus.SC_OK && !mSuccessIfAbsent)
                || (status == HttpStatus.SC_NOT_FOUND && mSuccessIfAbsent);
        result = new RemoteOperationResult(success, status, head.getResponseHeaders());
        Log_OC.d(TAG,
                "Existence check for " + client.getWebdavUri() + WebdavUtils.encodePath(mPath)
                        + " targeting for " + (mSuccessIfAbsent ? " absence " : " existence ")
                        + "finished with HTTP status " + status + (!success ? "(FAIL)" : ""));

    } catch (Exception e) {
        result = new RemoteOperationResult(e);
        Log_OC.e(TAG,
                "Existence check for " + client.getWebdavUri() + WebdavUtils.encodePath(mPath)
                        + " targeting for " + (mSuccessIfAbsent ? " absence " : " existence ") + ": "
                        + result.getLogMessage(),
                result.getException());

    } finally {
        if (head != null)
            head.releaseConnection();
        client.setFollowRedirects(previousFollowRedirects);
    }
    return result;
}

From source file:com.zimbra.qa.unittest.TestWsdlServlet.java

public void testWsdlServletInvalidPathForXsd() throws Exception {
    doWsdlServletRequest(wsdlUrlBase + "NonExistent.xsd", true, HttpStatus.SC_NOT_FOUND);
    doWsdlServletRequest(wsdlUrlBase + "fred/NonExistent.xsd", true, HttpStatus.SC_NOT_FOUND);
}

From source file:com.eucalyptus.blockstorage.StorageReplyQueue.java

public void handle(ExceptionMessage muleMsg) {
    try {//from w  w w  .  j a v  a2 s  .c  o m
        Object requestMsg = muleMsg.getPayload();
        String requestString = requestMsg.toString();
        BaseMessage msg = (BaseMessage) BindingManager.getDefaultBinding().fromOM(requestString);
        Throwable ex = muleMsg.getException().getCause();
        StorageErrorMessageType errMsg = null;

        if (ex instanceof NoSuchVolumeException) {
            errMsg = new StorageErrorMessageType("NoSuchVolume", "Volume not found", HttpStatus.SC_NOT_FOUND,
                    msg.getCorrelationId());
            errMsg.setCorrelationId(msg.getCorrelationId());
        } else if (ex instanceof VolumeInUseException) {
            errMsg = new StorageErrorMessageType("VolumeInUse", "Volume in use", HttpStatus.SC_FORBIDDEN,
                    msg.getCorrelationId());
            errMsg.setCorrelationId(msg.getCorrelationId());
        } else if (ex instanceof NoSuchSnapshotException) {
            errMsg = new StorageErrorMessageType("NoSuchSnapshot", "Snapshot not found",
                    HttpStatus.SC_NOT_FOUND, msg.getCorrelationId());
            errMsg.setCorrelationId(msg.getCorrelationId());
        } else if (ex instanceof VolumeAlreadyExistsException) {
            errMsg = new StorageErrorMessageType("VolumeAlreadyExists", "Volume already exists",
                    HttpStatus.SC_CONFLICT, msg.getCorrelationId());
            errMsg.setCorrelationId(msg.getCorrelationId());
        } else if (ex instanceof VolumeNotReadyException) {
            errMsg = new StorageErrorMessageType("VolumeNotReady", "Volume not ready yet",
                    HttpStatus.SC_CONFLICT, msg.getCorrelationId());
            errMsg.setCorrelationId(msg.getCorrelationId());
        } else if (ex instanceof SnapshotInUseException) {
            errMsg = new StorageErrorMessageType("SnapshotInUse", "Snapshot in use", HttpStatus.SC_CONFLICT,
                    msg.getCorrelationId());
            errMsg.setCorrelationId(msg.getCorrelationId());
        } else {
            replies.putMessage(
                    new EucalyptusErrorMessageType(muleMsg.getComponentName(), msg, ex.getMessage()));
        }
        if (errMsg != null) {
            replies.putMessage(errMsg);
        }
    } catch (Exception e) {
        LOG.error(e);
    }
}

From source file:edu.ucsb.eucalyptus.ic.StorageReplyQueue.java

public void handle(ExceptionMessage muleMsg) {
    try {/*from   ww w.j  a  v  a  2s.c  o  m*/
        Object requestMsg = muleMsg.getPayload();
        String requestString = requestMsg.toString();
        BaseMessage msg = (BaseMessage) BindingManager.getBinding("msgs_eucalyptus_com").fromOM(requestString);
        Throwable ex = muleMsg.getException().getCause();
        StorageErrorMessageType errMsg = null;

        if (ex instanceof NoSuchVolumeException) {
            errMsg = new StorageErrorMessageType("NoSuchVolume", "Volume not found", HttpStatus.SC_NOT_FOUND,
                    msg.getCorrelationId());
            errMsg.setCorrelationId(msg.getCorrelationId());
        } else if (ex instanceof VolumeInUseException) {
            errMsg = new StorageErrorMessageType("VolumeInUse", "Volume in use", HttpStatus.SC_FORBIDDEN,
                    msg.getCorrelationId());
            errMsg.setCorrelationId(msg.getCorrelationId());
        } else if (ex instanceof NoSuchSnapshotException) {
            errMsg = new StorageErrorMessageType("NoSuchSnapshot", "Snapshot not found",
                    HttpStatus.SC_NOT_FOUND, msg.getCorrelationId());
            errMsg.setCorrelationId(msg.getCorrelationId());
        } else if (ex instanceof VolumeAlreadyExistsException) {
            errMsg = new StorageErrorMessageType("VolumeAlreadyExists", "Volume already exists",
                    HttpStatus.SC_CONFLICT, msg.getCorrelationId());
            errMsg.setCorrelationId(msg.getCorrelationId());
        } else if (ex instanceof VolumeNotReadyException) {
            errMsg = new StorageErrorMessageType("VolumeNotReady", "Volume not ready yet",
                    HttpStatus.SC_CONFLICT, msg.getCorrelationId());
            errMsg.setCorrelationId(msg.getCorrelationId());
        } else if (ex instanceof SnapshotInUseException) {
            errMsg = new StorageErrorMessageType("SnapshotInUse", "Snapshot in use", HttpStatus.SC_CONFLICT,
                    msg.getCorrelationId());
            errMsg.setCorrelationId(msg.getCorrelationId());
        } else {
            replies.putMessage(
                    new EucalyptusErrorMessageType(muleMsg.getComponentName(), msg, ex.getMessage()));
        }
        if (errMsg != null) {
            replies.putMessage(errMsg);
        }
    } catch (Exception e) {
        LOG.error(e);
    }
}

From source file:io.pravega.segmentstore.storage.impl.extendeds3.S3FileSystemImpl.java

@Synchronized
@Override//w w w . j  a v a2 s .co  m
public void setObjectAcl(SetObjectAclRequest request) {
    AclSize retVal = aclMap.get(request.getKey());
    if (retVal == null) {
        throw new S3Exception("NoObject", HttpStatus.SC_NOT_FOUND, "NoSuchKey", request.getKey());
    }
    aclMap.put(request.getKey(), retVal.withAcl(request.getAcl()));
}

From source file:com.thoughtworks.go.server.service.ScheduleServiceSecurityTest.java

@Test
public void shouldReturnAppropriateHttpResultIfTheStageIsInvalid() throws Exception {
    configHelper.addSecurityWithAdminConfig();
    configHelper.setOperatePermissionForGroup("defaultGroup", "jez");
    Username jez = new Username(new CaseInsensitiveString("jez"));
    HttpLocalizedOperationResult operationResult = new HttpLocalizedOperationResult();
    Stage resultStage = scheduleService.cancelAndTriggerRelevantStages(-23l, jez, operationResult);

    assertThat(resultStage, is(nullValue()));
    assertThat(operationResult.isSuccessful(), is(false));
    assertThat(operationResult.httpCode(), is(HttpStatus.SC_NOT_FOUND));
}