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:org.kaloz.datafeed.processor.infrastructure.integration.InstrumentPriceLoadPredicate.java

@Override
public boolean matches(Exchange exchange) {
    JsonMessage message = exchange.getIn().getBody(JsonMessage.class);
    return exchange.getIn().getHeader(MESSAGE_TYPE, String.class).equals(InstrumentPriceRequestMessage.TYPE)
            && message.getErrorCode() == HttpStatus.SC_NOT_FOUND;
}

From source file:org.kaloz.datafeed.processor.infrastructure.integration.InstrumentPriceLoadPredicateTest.java

@Test
public void testValidMessage() {
    when(message.getHeader(eq(JmsMessagingConsts.MESSAGE_TYPE), eq(String.class)))
            .thenReturn(InstrumentPriceRequestMessage.TYPE);
    when(jsonMessage.getErrorCode()).thenReturn(HttpStatus.SC_NOT_FOUND);

    boolean result = obj.matches(exchange);

    assertEquals(true, result);/*from ww w.  jav a2s  . co m*/
}

From source file:org.kaloz.datafeed.processor.infrastructure.integration.InstrumentPriceLoadPredicateTest.java

@Test
public void testNotRelevantMessageMessageType() {
    when(message.getHeader(eq(JmsMessagingConsts.MESSAGE_TYPE), eq(String.class)))
            .thenReturn(InstrumentPriceListRequestMessage.TYPE);
    when(jsonMessage.getErrorCode()).thenReturn(HttpStatus.SC_NOT_FOUND);

    boolean result = obj.matches(exchange);

    assertEquals(false, result);//from  w w w . jav  a 2 s. c  o m
}

From source file:org.kei.android.phone.cellhistory.towers.request.OpenCellIdRequestEntity.java

@Override
public int decode(final String url, final HttpConnection connection, final int timeout) throws Exception {
    int ret = OK;
    final GetMethod getMethod = new GetMethod(url);
    getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
            new DefaultHttpMethodRetryHandler(1, false));
    // socket timeout (connection timeout already set in HttpClient)
    getMethod.getParams().setSoTimeout(timeout);
    final int resCode = getMethod.execute(new HttpState(), connection);
    final InputStream response = getMethod.getResponseBodyAsStream();
    final DataInputStream dis = new DataInputStream(response);
    if (resCode == HttpStatus.SC_OK) {
        final int av = dis.available();
        final byte[] json = new byte[av];
        dis.readFully(json);//from   ww  w  .j  a  va2 s. c  om
        final String sjson = new String(json);
        final String ljson = sjson.toLowerCase(Locale.US);
        if (ljson.indexOf("err") == -1) {
            final JSONObject object = new JSONObject(sjson);
            String lat, lng;
            lat = object.getString("lat");
            lng = object.getString("lon");
            ti.setCellLatitude(Double.parseDouble(lat));
            ti.setCellLongitude(Double.parseDouble(lng));
        } else if (ljson.indexOf("not found") != -1)
            ret = NOT_FOUND;
        else
            ret = EXCEPTION;
    } else if (resCode == HttpStatus.SC_NOT_FOUND)
        ret = NOT_FOUND;
    else if (resCode == HttpStatus.SC_INTERNAL_SERVER_ERROR)
        ret = BAD_REQUEST;
    else
        ret = EXCEPTION;
    getMethod.releaseConnection();
    return ret;
}

From source file:org.ldp4j.server.frontend.ServerFrontendITest.java

@Test
@Category({ ExceptionPath.class })
@OperateOnDeployment(DEPLOYMENT)// w  w w .j  ava 2s  .  c  om
public void testConstraintReportNotFound(@ArquillianResource final URL url) throws Exception {
    LOGGER.info("Started {}", testName.getMethodName());
    HELPER.base(url);
    HELPER.setLegacy(false);

    HttpGet get = HELPER.newRequest(MyApplication.ROOT_PERSON_CONTAINER_PATH + "?ldp:constrainedBy=12312312321",
            HttpGet.class);
    Metadata getResponse = HELPER.httpRequest(get);
    assertThat(getResponse.status, equalTo(HttpStatus.SC_NOT_FOUND));
    assertThat(getResponse.body, equalTo("Unknown constraint report '12312312321'"));
    assertThat(getResponse.contentType, startsWith("text/plain"));
    assertThat(getResponse.language, equalTo(Locale.ENGLISH));
}

From source file:org.linagora.linshare.webservice.interceptor.SoapExceptionInterceptor.java

private void generateSoapFault(Fault fault, BusinessException e) {
    fault.setFaultCode(createQName(e.getErrorCode().getCode()));
    fault.setMessage(e.getMessage());//from   w  w w. j ava  2  s .  c o  m

    switch (e.getErrorCode()) {
    case WEBSERVICE_FAULT:
        fault.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
        break;
    case WEBSERVICE_FORBIDDEN:
        fault.setStatusCode(HttpStatus.SC_FORBIDDEN);
        break;
    case FORBIDDEN:
        fault.setStatusCode(HttpStatus.SC_FORBIDDEN);
        break;
    case USER_NOT_FOUND:
        fault.setStatusCode(HttpStatus.SC_NOT_FOUND);
        break;
    case WEBSERVICE_NOT_FOUND:
        fault.setStatusCode(HttpStatus.SC_NOT_FOUND);
        break;
    default:
        fault.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
    }
}

From source file:org.lucterios.engine.transport.HttpTransportImpl.java

protected InputStream transfertFileFromServer(String aWebFile, MapContext aParams) throws LucteriosException {
    downloadFinished();//  w  ww . ja  va  2  s  .co  m
    java.net.URL path_url = getUrl(aWebFile);
    InputStream data = null;
    String param_txt = "";
    int repeat_loop_index = 3;
    while (repeat_loop_index > 0) {
        try {
            param_txt = getMethodByParameters(aParams, path_url);

            // Execute the POST method
            int statusCode = m_Cnx.executeMethod(getHostCnx(), method);
            if (statusCode == HttpStatus.SC_OK) {
                data = method.getResponseBodyAsStream();
                if (data != null)
                    repeat_loop_index = 0;
                else
                    repeat_loop_index--;
            } else {
                repeat_loop_index--;
                if ((statusCode != HttpStatus.SC_NOT_FOUND) || (repeat_loop_index <= 0))
                    throw new TransportException(
                            method.getStatusLine().getReasonPhrase() + ":" + path_url.toString(),
                            TransportException.TYPE_HTTP, statusCode, param_txt, "");
            }
        } catch (java.net.ConnectException ce) {
            repeat_loop_index--;
            checkException(data, repeat_loop_index, param_txt, ce, "");
        } catch (java.net.UnknownHostException uhe) {
            repeat_loop_index--;
            checkException(data, repeat_loop_index, param_txt, uhe, "Serveur inconnu:");
        } catch (IOException ioe) {
            repeat_loop_index--;
            checkException(data, repeat_loop_index, param_txt, ioe, "");
        }
    }
    checkException(data, repeat_loop_index, param_txt, null, "");
    return data;
}

From source file:org.lucterios.engine.transport.HttpTransportImpl.java

public int getFileLength(String aWebFile) throws LucteriosException {
    Logging.getInstance().writeLog("### HEADER ###", aWebFile, 2);
    int size = 0;
    String value = "";
    java.net.URL path_url = getUrl(aWebFile);
    int repeat_loop_index = 3;
    while (repeat_loop_index > 0) {
        try {// w  w  w.  ja  va  2 s.c  o  m
            header = new HeadMethod(path_url.toString());
            try {
                // Execute the HEADER method
                int statusCode = m_Cnx.executeMethod(getHostCnx(), header);
                if (statusCode == HttpStatus.SC_OK) {
                    value = header.getResponseHeader("Content-Length").getValue();
                    if (value != null) {
                        size = Integer.parseInt(value);
                        repeat_loop_index = 0;
                    } else
                        repeat_loop_index--;
                } else {
                    repeat_loop_index--;
                    if ((statusCode != HttpStatus.SC_NOT_FOUND) || (repeat_loop_index <= 0))
                        throw new TransportException(header.getStatusLine().getReasonPhrase(),
                                TransportException.TYPE_HTTP, statusCode, "", "");
                }
            } finally {
                downloadFinished();
            }
        } catch (java.net.ConnectException ce) {
            repeat_loop_index--;
            throw new LucteriosException("Erreur de Header", aWebFile, value, ce);
        } catch (java.net.UnknownHostException uhe) {
            repeat_loop_index--;
            throw new LucteriosException("Erreur de Header", aWebFile, value, uhe);
        } catch (IOException ioe) {
            repeat_loop_index--;
            throw new LucteriosException("Erreur de Header", aWebFile, value, ioe);
        }
    }
    return size;
}

From source file:org.mule.examples.leagues.FunctionalTestCase.java

@Test
public void teamNotFound() throws Exception {
    given().log().all().header("Accept", "application/json").expect().response()
            .statusCode(HttpStatus.SC_NOT_FOUND).when().get("/teams/" + NEW_TEAM_ID);
}

From source file:org.mule.transport.servlet.jetty.functional.JettyEndpointsAndWebappTestCase.java

private void assertNotFound(String url) throws IOException {
    GetMethod method = new GetMethod(url);
    int statusCode = new HttpClient().executeMethod(method);
    assertEquals(HttpStatus.SC_NOT_FOUND, statusCode);
}