当前位置: 首页>>代码示例>>Java>>正文


Java HttpStatus类代码示例

本文整理汇总了Java中org.eclipse.jetty.http.HttpStatus的典型用法代码示例。如果您正苦于以下问题:Java HttpStatus类的具体用法?Java HttpStatus怎么用?Java HttpStatus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HttpStatus类属于org.eclipse.jetty.http包,在下文中一共展示了HttpStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRetry

import org.eclipse.jetty.http.HttpStatus; //导入依赖的package包/类
@Test
public void testRetry() throws Exception {
    SalesforceComponent sf = context().getComponent("salesforce", SalesforceComponent.class);
    String accessToken = sf.getSession().getAccessToken();

    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setSslContext(new SSLContextParameters().createSSLContext(context));
    HttpClient httpClient = new HttpClient(sslContextFactory);
    httpClient.setConnectTimeout(60000);
    httpClient.start();

    String uri = sf.getLoginConfig().getLoginUrl() + "/services/oauth2/revoke?token=" + accessToken;
    Request logoutGet = httpClient.newRequest(uri)
        .method(HttpMethod.GET)
        .timeout(1, TimeUnit.MINUTES);

    ContentResponse response = logoutGet.send();
    assertEquals(HttpStatus.OK_200, response.getStatus());

    JobInfo jobInfo = new JobInfo();
    jobInfo.setOperation(OperationEnum.INSERT);
    jobInfo.setContentType(ContentType.CSV);
    jobInfo.setObject(Merchandise__c.class.getSimpleName());
    createJob(jobInfo);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:BulkApiIntegrationTest.java

示例2: parseSendirResponse

import org.eclipse.jetty.http.HttpStatus; //导入依赖的package包/类
private void parseSendirResponse(final ContentResponse response) {

        final String responseContent = response.getContentAsString();

        if ((responseContent == null) || responseContent.isEmpty()) {
            throw new CommunicationException("Empty response received!");
        }

        if (responseContent.startsWith(SENDIR_SUCCESS)) {
            return;
        }

        if (responseContent.startsWith(SENDIR_BUSY)) {
            throw new DeviceBusyException("Device is busy!");
        }

        if ((response.getStatus() != HttpStatus.OK_200) || responseContent.startsWith(SENDIR_ERROR)) {
            throw new CommunicationException(String.format("Failed to send IR code: %s", responseContent));
        }
    }
 
开发者ID:alexmaret,项目名称:openhab-binding-zmote,代码行数:21,代码来源:ZMoteV2Client.java

示例3: writeErrorResponse

import org.eclipse.jetty.http.HttpStatus; //导入依赖的package包/类
private void writeErrorResponse(String errorMessage, HttpServletResponse resp)
{
    _logger.debug("entering");
    byte[] responseBodyBytes =
            UTF_8.encode(new ErrorJsonResponse(errorMessage).toString()).array();

    resp.setHeader("Content-Type", "application/json");
    resp.setStatus(HttpStatus.INTERNAL_SERVER_ERROR_500);
    try
    {
        resp.getOutputStream().write(responseBodyBytes);
    }
    catch (IOException e)
    {
       _logger.error(e.getMessage(), e);
    }
    _logger.debug("exiting");
}
 
开发者ID:capergroup,项目名称:bayou,代码行数:19,代码来源:SizeConstrainedPostBodyServlet.java

示例4: doPost

import org.eclipse.jetty.http.HttpStatus; //导入依赖的package包/类
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp, String requestBody) throws IOException
{
    _logger.debug("entering");
    try
    {
        doPostHelp(req, resp, requestBody);
    }
    catch (Throwable e)
    {
        _logger.error(e.getMessage(), e);
        JSONObject responseBody = new ErrorJsonResponse("Unexpected exception during synthesis.");
        if(resp != null)
            resp.setStatus(HttpStatus.INTERNAL_SERVER_ERROR_500);
        writeObjectToServletOutputStream(responseBody, resp);
    }
    finally
    {
        _logger.debug("exiting");
    }
}
 
开发者ID:capergroup,项目名称:bayou,代码行数:22,代码来源:ApiSynthesisServlet.java

示例5: applyAccessControlHeaderIfAllowed

import org.eclipse.jetty.http.HttpStatus; //导入依赖的package包/类
/**
 * If the given request's origin is present and a member of the allowed origins as decided by corsHeaderSetter
 * sets the response Access-Control-Allow-Origin header to the request's origin.
 *
 * If not, sets the response code to 403 via resp.
 *
 * @param req the http request
 * @param resp the http response
 * @param corsHeaderSetter the source of truth on allowed origins
 * @return whether req represents a request from an allowed origin.
 */
default boolean applyAccessControlHeaderIfAllowed(HttpServletRequest req, HttpServletResponse resp,
                                                  CorsHeaderSetter corsHeaderSetter)
{
    Logger _logger = LogManager.getLogger(CorsAwareServlet.class.getName());
    _logger.debug("entering");

    // only allow CORS processing from origins we approve
    boolean requestFromAllowedOrigin = corsHeaderSetter.applyAccessControlHeaderIfAllowed(req, resp);

    if(!requestFromAllowedOrigin)
    {
        resp.setStatus(HttpStatus.FORBIDDEN_403);
        _logger.warn("request from unauthorized origin.");
    }

    _logger.debug("exiting");
    return requestFromAllowedOrigin;
}
 
开发者ID:capergroup,项目名称:bayou,代码行数:30,代码来源:CorsAwareServlet.java

示例6: testGetDataSourcePermissions

import org.eclipse.jetty.http.HttpStatus; //导入依赖的package包/类
@Test
public void testGetDataSourcePermissions() {
    final DocRef docRef = createDocument();

    final String authorisedUsername = UUID.randomUUID().toString();
    final String unauthorisedUsername = UUID.randomUUID().toString();
    final String unauthenticatedUsername = UUID.randomUUID().toString();

    giveDocumentPermission(authenticatedUser(authorisedUsername), docRef.getUuid(), DocumentPermission.READ);

    final Response authorisedResponse = queryClient.getDataSource(authenticatedUser(authorisedUsername), docRef);
    assertEquals(HttpStatus.OK_200, authorisedResponse.getStatus());

    final Response unauthorisedResponse = queryClient.getDataSource(authenticatedUser(unauthorisedUsername), docRef);
    assertEquals(HttpStatus.FORBIDDEN_403, unauthorisedResponse.getStatus());

    final Response unauthenticatedResponse = queryClient.getDataSource(unauthenticatedUser(unauthenticatedUsername), docRef);
    assertEquals(HttpStatus.UNAUTHORIZED_401, unauthenticatedResponse.getStatus());

    // Create index, update, authorised get, unauthorised get
    checkAuditLogs(4);
}
 
开发者ID:gchq,项目名称:stroom-query,代码行数:23,代码来源:QueryResourceIT.java

示例7: get

import org.eclipse.jetty.http.HttpStatus; //导入依赖的package包/类
@Override
public Response get(final ServiceUser user,
                    final String uuid){
    return SimpleAuditWrapper.withUser(user)
            .withAuthSupplier(() -> authorisationService.isAuthorised(user,
                    new DocRef.Builder()
                            .type(this.service.getType())
                            .uuid(uuid)
                            .build(),
                    DocumentPermission.READ))
            .withResponse(() -> service.get(user, uuid)
                    .map(d -> Response.ok(d).build())
                    .orElse(Response.status(HttpStatus.NOT_FOUND_404)
                            .build()))
            .withPopulateAudit((eventDetail, response, exception) -> {
                eventDetail.setTypeId("GET_DOC_REF");
                eventDetail.setDescription("Get a single doc ref");
            }).callAndAudit(eventLoggingService);
}
 
开发者ID:gchq,项目名称:stroom-query,代码行数:20,代码来源:AuditedDocRefResourceImpl.java

示例8: getInfo

import org.eclipse.jetty.http.HttpStatus; //导入依赖的package包/类
@Override
public Response getInfo(final ServiceUser user,
                        final String uuid){
    return SimpleAuditWrapper.withUser(user)
            .withAuthSupplier(() -> authorisationService.isAuthorised(user,
                    new DocRef.Builder()
                            .type(this.service.getType())
                            .uuid(uuid)
                            .build(),
                    DocumentPermission.READ))
            .withResponse(() -> service.getInfo(user, uuid)
                    .map(d -> Response.ok(d).build())
                    .orElse(Response.status(HttpStatus.NOT_FOUND_404)
                            .build()))
            .withPopulateAudit((eventDetail, response, exception) -> {
                eventDetail.setTypeId("GET_DOC_REF_INFO");
                eventDetail.setDescription("Get info for a single doc ref");
            }).callAndAudit(eventLoggingService);
}
 
开发者ID:gchq,项目名称:stroom-query,代码行数:20,代码来源:AuditedDocRefResourceImpl.java

示例9: createDocument

import org.eclipse.jetty.http.HttpStatus; //导入依赖的package包/类
@Override
public Response createDocument(final ServiceUser user,
                               final String uuid,
                               final String name,
                               final String parentFolderUUID){
    return SimpleAuditWrapper.withUser(user)
            .withAuthSupplier(() -> authorisationService.isAuthorised(user,
                    new DocRef.Builder()
                            .type(DocumentPermission.FOLDER)
                            .uuid(parentFolderUUID)
                            .build(),
                    DocumentPermission.CREATE.getTypedPermission(service.getType())))
            .withResponse(() -> service.createDocument(user, uuid, name)
                    .map(d -> Response.ok(d).build())
                    .orElse(Response.status(HttpStatus.NOT_FOUND_404)
                            .build()))
            .withPopulateAudit((eventDetail, response, exception) -> {
                eventDetail.setTypeId("CREATE_DOC_REF");
                eventDetail.setDescription("Create a Doc Ref");
            }).callAndAudit(eventLoggingService);
}
 
开发者ID:gchq,项目名称:stroom-query,代码行数:22,代码来源:AuditedDocRefResourceImpl.java

示例10: moveDocument

import org.eclipse.jetty.http.HttpStatus; //导入依赖的package包/类
@Override
public Response moveDocument(final ServiceUser user,
                             final String uuid,
                             final String parentFolderUUID){
    return SimpleAuditWrapper.withUser(user)
            .withAuthSupplier(() ->   authorisationService.isAuthorised(user,
                        new DocRef.Builder()
                                .type(this.service.getType())
                                .uuid(uuid)
                                .build(),
                        DocumentPermission.READ) &&
                    authorisationService.isAuthorised(user,
                            new DocRef.Builder()
                                    .type(DocumentPermission.FOLDER)
                                    .uuid(parentFolderUUID)
                                    .build(),
                            DocumentPermission.CREATE.getTypedPermission(service.getType())))
            .withResponse(() -> service.moveDocument(user, uuid)
                    .map(d -> Response.ok(d).build())
                    .orElse(Response.status(HttpStatus.NOT_FOUND_404)
                            .build()))
            .withPopulateAudit((eventDetail, response, exception) -> {
                eventDetail.setTypeId("MOVE_DOC_REF");
                eventDetail.setDescription("Move a Doc Ref");
            }).callAndAudit(eventLoggingService);
}
 
开发者ID:gchq,项目名称:stroom-query,代码行数:27,代码来源:AuditedDocRefResourceImpl.java

示例11: deleteDocument

import org.eclipse.jetty.http.HttpStatus; //导入依赖的package包/类
@Override
public Response deleteDocument(final ServiceUser user,
                               final String uuid){
    return SimpleAuditWrapper.withUser(user)
            .withAuthSupplier(() -> authorisationService.isAuthorised(user,
                    new DocRef.Builder()
                            .type(this.service.getType())
                            .uuid(uuid)
                            .build(),
                    DocumentPermission.DELETE))
            .withResponse(() -> service.deleteDocument(user, uuid).map(d -> Response.ok(d).build())
                    .orElse(Response.status(HttpStatus.NOT_FOUND_404)
                            .build()))
            .withPopulateAudit((eventDetail, response, exception) -> {
                eventDetail.setTypeId("DELETE_DOC_REF");
                eventDetail.setDescription("Delete a Doc Ref");
            }).callAndAudit(eventLoggingService);
}
 
开发者ID:gchq,项目名称:stroom-query,代码行数:19,代码来源:AuditedDocRefResourceImpl.java

示例12: importDocument

import org.eclipse.jetty.http.HttpStatus; //导入依赖的package包/类
@Override
public Response importDocument(final ServiceUser user,
                               final String uuid,
                               final String name,
                               final Boolean confirmed,
                               final Map<String, String> dataMap){
    return SimpleAuditWrapper.withUser(user)
            .withDefaultAuthSupplier()
            .withResponse(() -> service.importDocument(user, uuid, name, confirmed, dataMap)
                    .map(d -> Response.ok(d).build())
                    .orElse(Response.status(HttpStatus.NOT_FOUND_404)
                            .build()))
            .withPopulateAudit((eventDetail, response, exception) -> {
                eventDetail.setTypeId("IMPORT_DOC_REF");
                eventDetail.setDescription("Import a Doc Ref");
            }).callAndAudit(eventLoggingService);
}
 
开发者ID:gchq,项目名称:stroom-query,代码行数:18,代码来源:AuditedDocRefResourceImpl.java

示例13: exportDocument

import org.eclipse.jetty.http.HttpStatus; //导入依赖的package包/类
@Override
public Response exportDocument(final ServiceUser user,
                               final String uuid){

    return SimpleAuditWrapper.withUser(user)
            .withAuthSupplier(() -> authorisationService.isAuthorised(user,
                    new DocRef.Builder()
                            .type(this.service.getType())
                            .uuid(uuid)
                            .build(),
                    DocumentPermission.EXPORT))
            .withResponse(() -> {
                final ExportDTO result = service.exportDocument(user, uuid);
                if (result.getValues().size() > 0) {
                    return Response.ok(result).build();
                } else {
                    return Response.status(HttpStatus.NOT_FOUND_404)
                            .entity(result)
                            .build();
                }
            })
            .withPopulateAudit((eventDetail, response, exception) -> {
                eventDetail.setTypeId("EXPORT_DOC_REF");
                eventDetail.setDescription("Export a single doc ref");
            }).callAndAudit(eventLoggingService);
}
 
开发者ID:gchq,项目名称:stroom-query,代码行数:27,代码来源:AuditedDocRefResourceImpl.java

示例14: getDataSource

import org.eclipse.jetty.http.HttpStatus; //导入依赖的package包/类
@Override
public Response getDataSource(final ServiceUser user,
                              final DocRef docRef){
    return DocRefAuditWrapper.<T>withUser(user)
            .withDocRef(docRef)
            .withDocRefEntity(d -> docRefService.get(user, docRef.getUuid()))
            .withAuthSupplier(d -> authorisationService.isAuthorised(user,
                    d,
                    DocumentPermission.READ))
            .withResponse(docRefEntity -> service.getDataSource(user, docRef)
                    .map(d -> Response.ok(d).build())
                    .orElse(Response.status(HttpStatus.NOT_FOUND_404)
                            .build()))
            .withPopulateAudit((eventDetail, response, exception) -> {
                eventDetail.setTypeId("GET_DATA_SOURCE");
                eventDetail.setDescription("Get Datasource For Document");

                final Search search = new Search();
                eventDetail.setSearch(search);

                final Outcome outcome = new Outcome();
                outcome.setSuccess(null != exception);
                search.setOutcome(outcome);
            }).callAndAudit(eventLoggingService);
}
 
开发者ID:gchq,项目名称:stroom-query,代码行数:26,代码来源:AuditedQueryResourceImpl.java

示例15: login

import org.eclipse.jetty.http.HttpStatus; //导入依赖的package包/类
public void login() throws Exception {
    JSONObject sessionRes, loginRes = httpClient.Get(this.getUrl(buildUrl(LOGIN)));
    if (loginRes != null) {            
        httpClient.COOKIES = (Header[]) loginRes.get("COOKIE");
        httpClient.COOKIES = (Header[]) loginRes.get("COOKIE");
        sessionRes = httpClient.post(this.getUrl(buildUrl(SESSION)), "");
        if (sessionRes.get("status").equals(HttpStatus.CREATED_201)) {
            DLogger.Log("session created");
            httpClient.COOKIES = (Header[]) sessionRes.get("COOKIE");
        } else {
            DLogger.Log("session not available status : ", sessionRes.get("status"));
        }
        httpClient.LOGIN_KEY = true;
    } else {
        httpClient.LOGIN_KEY = null;
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:18,代码来源:QCRestClient.java


注:本文中的org.eclipse.jetty.http.HttpStatus类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。