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.eviware.soapui.impl.rest.mock.RestMockDispatcherTest.java

@Test
public void shouldReturnNoResponseFoundWhenThereIsNoMatchingAction() throws Exception {
    when(restMockService.findBestMatchedOperation(anyString(), any(HttpMethod.class))).thenReturn(null);
    when(restMockService.getPath()).thenReturn("/");
    when(request.getPathInfo()).thenReturn("/");

    restMockDispatcher.dispatchRequest(request, response);

    verify(response).setStatus(HttpStatus.SC_NOT_FOUND);
}

From source file:com.owncloud.android.operations.RemoteOperationResult.java

private RemoteOperationResult(boolean success, int httpCode) {
    mSuccess = success;//from www  .  j  a v a2 s  .com
    mHttpCode = httpCode;

    if (success) {
        mCode = ResultCode.OK;

    } else if (httpCode > 0) {
        switch (httpCode) {
        case HttpStatus.SC_UNAUTHORIZED:
            mCode = ResultCode.UNAUTHORIZED;
            break;
        case HttpStatus.SC_NOT_FOUND:
            mCode = ResultCode.FILE_NOT_FOUND;
            break;
        case HttpStatus.SC_INTERNAL_SERVER_ERROR:
            mCode = ResultCode.INSTANCE_NOT_CONFIGURED;
            break;
        case HttpStatus.SC_CONFLICT:
            mCode = ResultCode.CONFLICT;
            break;
        case HttpStatus.SC_INSUFFICIENT_STORAGE:
            mCode = ResultCode.QUOTA_EXCEEDED;
            break;
        default:
            mCode = ResultCode.UNHANDLED_HTTP_CODE;
            Log_OC.d(TAG, "RemoteOperationResult has processed UNHANDLED_HTTP_CODE: " + httpCode);
        }
    }
}

From source file:com.eviware.soapui.impl.rest.mock.RestMockDispatcher.java

private RestMockResult createNotFoundResponse(RestMockRequest restMockRequest) {
    restMockRequest.getHttpResponse().setStatus(HttpStatus.SC_NOT_FOUND);
    return new RestMockResult(restMockRequest);
}

From source file:com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation.java

@Override
protected RemoteOperationResult run(OwnCloudClient client) {
    if (!isOnline()) {
        return new RemoteOperationResult(RemoteOperationResult.ResultCode.NO_NETWORK_CONNECTION);
    }/* w ww. ja v  a  2s  .  com*/
    RemoteOperationResult result = null;
    HeadMethod head = null;
    try {
        head = new HeadMethod(client.getWebdavUri() + WebdavUtils.encodePath(mPath));
        int status = client.executeMethod(head, TIMEOUT, TIMEOUT);
        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();
    }
    return result;
}

From source file:com.bbva.arq.devops.ae.mirrorgate.jenkins.plugin.service.DefaultMirrorGateServiceTest.java

@Test
public void testFailedConnectionTest() throws IOException {
    when(htppClient.executeMethod(any(GetMethod.class))).thenReturn(HttpStatus.SC_NOT_FOUND);

    assertEquals(service.testConnection().getResponseCode(), HttpStatus.SC_NOT_FOUND);
}

From source file:jetbrains.buildServer.symbols.DownloadSymbolsControllerTest.java

@Test
public void request_pdb_two_slashes_in_url() throws Exception {
    myRequest.setRequestURI("mock", "/app/symbols//index2.txt'");
    doGet();//  w  ww. ja v a 2s  . co m
    assertEquals(HttpStatus.SC_NOT_FOUND, myResponse.getStatus());
}

From source file:com.owncloud.android.oc_framework.operations.RemoteOperationResult.java

private RemoteOperationResult(boolean success, int httpCode) {
    mSuccess = success;//from ww  w. ja v a2  s.  c o m
    mHttpCode = httpCode;

    if (success) {
        mCode = ResultCode.OK;

    } else if (httpCode > 0) {
        switch (httpCode) {
        case HttpStatus.SC_UNAUTHORIZED:
            mCode = ResultCode.UNAUTHORIZED;
            break;
        case HttpStatus.SC_NOT_FOUND:
            mCode = ResultCode.FILE_NOT_FOUND;
            break;
        case HttpStatus.SC_INTERNAL_SERVER_ERROR:
            mCode = ResultCode.INSTANCE_NOT_CONFIGURED;
            break;
        case HttpStatus.SC_CONFLICT:
            mCode = ResultCode.CONFLICT;
            break;
        case HttpStatus.SC_INSUFFICIENT_STORAGE:
            mCode = ResultCode.QUOTA_EXCEEDED;
            break;
        default:
            mCode = ResultCode.UNHANDLED_HTTP_CODE;
            Log.d(TAG, "RemoteOperationResult has processed UNHANDLED_HTTP_CODE: " + httpCode);
        }
    }
}

From source file:jetbrains.buildServer.symbols.DownloadSymbolsControllerTest.java

@Test
public void request_pdb_invalid_url() throws Exception {
    myRequest.setRequestURI("mock", "/app/symbols/foo");
    doGet();// w  ww . j  a v  a2  s  .c  om
    assertEquals(HttpStatus.SC_NOT_FOUND, myResponse.getStatus());
}

From source file:jetbrains.buildServer.symbols.DownloadSymbolsControllerTest.java

@Test
public void request_not_existent_pdb() throws Exception {
    myRequest.setRequestURI("mock", "/app/symbols/fileName/FileId2/fileName");
    doGet();//from w  w w  .  j a  va  2 s  .c om
    assertEquals(HttpStatus.SC_NOT_FOUND, myResponse.getStatus());
}

From source file:eu.alefzero.owncloud.authenticator.ConnectionCheckerRunnable.java

private boolean tryConnection(Uri uri) {
    WebdavClient wc = new WebdavClient();
    wc.allowSelfsignedCertificates();/* w w  w  .j  a v a2  s .com*/
    GetMethod get = new GetMethod(uri.toString());
    boolean retval = false;
    try {
        int status = wc.executeMethod(get, TRY_CONNECTION_TIMEOUT);
        switch (status) {
        case HttpStatus.SC_OK: {
            String response = get.getResponseBodyAsString();
            JSONObject json = new JSONObject(response);
            if (!json.getBoolean("installed")) {
                mLatestResult = ResultType.INSTANCE_NOT_CONFIGURED;
                break;
            }
            mOCVersion = new OwnCloudVersion(json.getString("version"));
            if (!mOCVersion.isVersionValid())
                break;
            retval = true;
            break;
        }
        case HttpStatus.SC_NOT_FOUND:
            mLatestResult = ResultType.FILE_NOT_FOUND;
            break;
        case HttpStatus.SC_INTERNAL_SERVER_ERROR:
            mLatestResult = ResultType.INSTANCE_NOT_CONFIGURED;
            break;
        default:
            mLatestResult = ResultType.UNKNOWN_ERROR;
            Log.e(TAG, "Not handled status received from server: " + status);
        }

    } catch (Exception e) {
        if (e instanceof UnknownHostException || e instanceof ConnectException
                || e instanceof SocketTimeoutException) {
            mLatestResult = ResultType.HOST_NOT_AVAILABLE;
        } else if (e instanceof JSONException) {
            mLatestResult = ResultType.INSTANCE_NOT_CONFIGURED;
        } else if (e instanceof SSLHandshakeException) {
            mLatestResult = ResultType.SSL_INIT_ERROR;
        } else {
            mLatestResult = ResultType.UNKNOWN_ERROR;
        }
        e.printStackTrace();
    }

    return retval;
}