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


Java HttpStatus.CREATED_201属性代码示例

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


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

示例1: generateX509Certificate

@Override
public String generateX509Certificate(String csr, String keyUsage, int expiryTime) {
    
    // Key Usage value used in Go - https://golang.org/src/crypto/x509/x509.go?s=18153:18173#L558
    // we're only interested in ExtKeyUsageClientAuth - with value of 2
    
    final String extKeyUsage = ZTSConsts.ZTS_CERT_USAGE_CLIENT.equals(keyUsage) ? "2" : null;

    ContentResponse response = null;
    for (int i = 0; i < requestRetryCount; i++) {
        if ((response = processX509CertRequest(csr, extKeyUsage, expiryTime, i + 1)) != null) {
            break;
        }
    }
    if (response == null) {
        return null;
    }
    
    if (response.getStatus() != HttpStatus.CREATED_201) {
        LOGGER.error("unable to fetch requested uri '" + x509CertUri +
                "' status: " + response.getStatus());
        return null;
    }

    String data = response.getContentAsString();
    if (data == null || data.isEmpty()) {
        LOGGER.error("received empty response from uri '" + x509CertUri +
                "' status: " + response.getStatus());
        return null;
    }

    X509CertSignObject pemCert = null;
    try {
        pemCert = JSON.fromString(data, X509CertSignObject.class);
    } catch (Exception ex) {
        LOGGER.error("unable to decode object from '" + x509CertUri +
                "' error: " + ex.getMessage());
    }
    return (pemCert != null) ? pemCert.getPem() : null;
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:40,代码来源:HttpCertSigner.java

示例2: generateSSHCertificate

@Override
public String generateSSHCertificate(String sshKeyReq) {

    ContentResponse response = null;
    for (int i = 0; i < requestRetryCount; i++) {
        if ((response = processSSHKeyRequest(sshKeyReq, i + 1)) != null) {
            break;
        }
    }
    if (response == null) {
        return null;
    }

    if (response.getStatus() != HttpStatus.CREATED_201) {
        LOGGER.error("generateSSHCertificate: unable to fetch requested uri '" + sshCertUri +
                "' status: " + response.getStatus());
        return null;
    }

    String data = response.getContentAsString();
    if (data == null || data.isEmpty()) {
        LOGGER.error("generateSSHCertificate: received empty response from uri '" + sshCertUri +
                "' status: " + response.getStatus());
        return null;
    }

    SSHCertificate cert = null;
    try {
        cert = JSON.fromString(data, SSHCertificate.class);
    } catch (Exception ex) {
        LOGGER.error("generateSSHCertificate: unable to decode object from '" + sshCertUri +
                "' error: " + ex.getMessage());
    }
    return (cert != null) ? cert.getOpensshkey() : null;
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:35,代码来源:HttpCertSigner.java

示例3: addCompetitionGroup

@POST
@UnitOfWork
@ApiOperation(value = "Add a Competition Group")
@ApiResponses({
        @ApiResponse(
                code = HttpStatus.CREATED_201,
                message = ApiResponseConstants.Created.MESSAGE,
                responseHeaders = {
                        @ResponseHeader(
                                name = ApiResponseConstants.Created.Headers.NAME,
                                description = ApiResponseConstants.Created.Headers.DESCRIPTION,
                                response = String.class
                        )
                }
        ),
        @ApiResponse(
                code = HttpStatus.UNPROCESSABLE_ENTITY_422,
                message = "Failed validation",
                response = ValidationErrorMessage.class
        )
})
public Response addCompetitionGroup(
        @Valid @ApiParam(value = "Competition Group") AddCompetitionGroupRequest request
) throws AddEntityException {
    CompetitionGroupAddPayload addPayload = competitionGroupMapper.toDomainAddPayload(request);
    CompetitionGroup domainEntity = competitionGroupEntityService.add(addPayload);
    CompetitionGroupApiEntity entity = competitionGroupMapper.toApiEntity(domainEntity);
    return Response.created(UriBuilder.fromPath("/competitionGroups/{competitionGroupId}")
            .build(entity.getId()))
            .build();
}
 
开发者ID:caeos,项目名称:coner-core,代码行数:31,代码来源:CompetitionGroupsResource.java

示例4: addRun

@POST
@UnitOfWork
@ApiOperation(value = "Add a new run")
@ApiResponses({
        @ApiResponse(
                code = HttpStatus.CREATED_201,
                message = ApiResponseConstants.Created.MESSAGE,
                responseHeaders = {
                        @ResponseHeader(
                                name = ApiResponseConstants.Created.Headers.NAME,
                                description = ApiResponseConstants.Created.Headers.DESCRIPTION,
                                response = String.class
                        )
                }
        ),
        @ApiResponse(
                code = HttpStatus.NOT_FOUND_404,
                response = ErrorMessage.class,
                message = "No event with given ID"
        ),
        @ApiResponse(
                code = HttpStatus.UNPROCESSABLE_ENTITY_422,
                response = ValidationErrorMessage.class,
                message = "Failed validation"
        )
})
public Response addRun(
        @PathParam("eventId") @ApiParam(value = "Event ID", required = true) String eventId,
        @Valid @ApiParam(value = "Run", required = true) AddRunRequest request
) throws AddEntityException, EntityNotFoundException {
    RunAddPayload addPayload = runMapper.toDomainAddPayload(request, eventId);
    Run domainEntity = runEntityService.add(addPayload);
    RunApiEntity run = runMapper.toApiEntity(domainEntity);
    return Response.created(UriBuilder.fromPath("/events/{eventId}/runs/{runId}")
                                    .build(eventId, run.getId()))
            .build();
}
 
开发者ID:caeos,项目名称:coner-core,代码行数:37,代码来源:EventRunsResource.java

示例5: addEvent

@POST
@UnitOfWork
@ApiOperation(value = "Add an Event", response = Response.class)
@ApiResponses({
        @ApiResponse(
                code = HttpStatus.CREATED_201,
                message = ApiResponseConstants.Created.MESSAGE,
                responseHeaders = {
                        @ResponseHeader(
                                name = ApiResponseConstants.Created.Headers.NAME,
                                description = ApiResponseConstants.Created.Headers.DESCRIPTION,
                                response = String.class
                        )
                }
        ),
        @ApiResponse(
                code = HttpStatus.UNPROCESSABLE_ENTITY_422,
                response = ValidationErrorMessage.class,
                message = "Failed validation"
        )
})
public Response addEvent(
        @Valid @ApiParam(value = "Event", required = true) AddEventRequest request
) throws AddEntityException {
    EventAddPayload addPayload = eventMapper.toDomainAddPayload(request);
    Event domainEntity = eventEntityService.add(addPayload);
    EventApiEntity eventApiEntity = eventMapper.toApiEntity(domainEntity);
    return Response.created(UriBuilder.fromPath("/events/{eventId}")
            .build(eventApiEntity.getId()))
            .build();
}
 
开发者ID:caeos,项目名称:coner-core,代码行数:31,代码来源:EventsResource.java

示例6: addRegistration

@POST
@UnitOfWork
@ApiOperation(value = "Add a new registration")
@ApiResponses({
        @ApiResponse(
                code = HttpStatus.CREATED_201,
                message = ApiResponseConstants.Created.MESSAGE,
                responseHeaders = {
                        @ResponseHeader(
                                name = ApiResponseConstants.Created.Headers.NAME,
                                description = ApiResponseConstants.Created.Headers.DESCRIPTION,
                                response = String.class
                        )
                }
        ),
        @ApiResponse(
                code = HttpStatus.NOT_FOUND_404,
                response = ErrorMessage.class,
                message = "No event with given ID"
        ),
        @ApiResponse(
                code = HttpStatus.UNPROCESSABLE_ENTITY_422,
                response = ValidationErrorMessage.class,
                message = "Failed validation"
        )
})
public Response addRegistration(
        @PathParam("eventId") @ApiParam(value = "Event ID", required = true) String eventId,
        @Valid @ApiParam(value = "Registration", required = true) AddRegistrationRequest request
) throws AddEntityException, EntityNotFoundException {
    RegistrationAddPayload addPayload = registrationMapper.toDomainAddPayload(request, eventId);
    Registration domainEntity = eventRegistrationService.add(addPayload);
    RegistrationApiEntity registration = registrationMapper.toApiEntity(domainEntity);
    return Response.created(UriBuilder.fromPath("/events/{eventId}/registrations/{registrationId}")
            .build(eventId, registration.getId()))
            .build();
}
 
开发者ID:caeos,项目名称:coner-core,代码行数:37,代码来源:EventRegistrationsResource.java

示例7: add

@POST
@UnitOfWork
@ApiOperation(
        value = "Add a new Handicap Group Set",
        notes = "Optionally include a set of Handicap Group entities with ID to associate them"
)
@ApiResponses({
        @ApiResponse(
                code = HttpStatus.CREATED_201,
                message = ApiResponseConstants.Created.MESSAGE,
                responseHeaders = {
                        @ResponseHeader(
                                name = ApiResponseConstants.Created.Headers.NAME,
                                description = ApiResponseConstants.Created.Headers.DESCRIPTION,
                                response = String.class
                        )
                }
        ),
        @ApiResponse(
                code = HttpStatus.UNPROCESSABLE_ENTITY_422,
                message = "Failed validation",
                response = ValidationErrorMessage.class
        )
})
public Response add(
        @Valid @NotNull @ApiParam(value = "Handicap Group Set") AddHandicapGroupSetRequest request
) throws AddEntityException {
    HandicapGroupSetAddPayload addPayload = handicapGroupSetMapper.toDomainAddPayload(request);
    HandicapGroupSet domainEntity = handicapGroupSetService.add(addPayload);
    HandicapGroupSetApiEntity entity = handicapGroupSetMapper.toApiEntity(domainEntity);
    return Response.created(UriBuilder.fromPath("/handicapGroups/sets/{handicapGroupSetId}")
            .build(entity.getId()))
            .build();
}
 
开发者ID:caeos,项目名称:coner-core,代码行数:34,代码来源:HandicapGroupSetsResource.java

示例8: add

@POST
@UnitOfWork
@ApiOperation(
        value = "Add a new Competition Group Set",
        notes = "Optionally include a list of Competition Group entities with ID to associate them"
)
@ApiResponses({
        @ApiResponse(
                code = HttpStatus.CREATED_201,
                message = ApiResponseConstants.Created.MESSAGE,
                responseHeaders = {
                        @ResponseHeader(
                                name = ApiResponseConstants.Created.Headers.NAME,
                                description = ApiResponseConstants.Created.Headers.DESCRIPTION,
                                response = String.class
                        )
                }
        ),
        @ApiResponse(
                code = HttpStatus.UNPROCESSABLE_ENTITY_422,
                message = "Failed validation",
                response = ValidationErrorMessage.class
        )
})
public Response add(
        @Valid @ApiParam(value = "Competition Group Set") AddCompetitionGroupSetRequest request
) throws AddEntityException {
    CompetitionGroupSetAddPayload addPayload = competitionGroupSetMapper.toDomainAddPayload(request);
    CompetitionGroupSet domainEntity = competitionGroupSetService.add(addPayload);
    CompetitionGroupSetApiEntity entity = competitionGroupSetMapper.toApiEntity(domainEntity);
    return Response.created(UriBuilder.fromPath("/competitionGroups/sets/{competitionGroupSetId}")
            .build(entity.getId()))
            .build();
}
 
开发者ID:caeos,项目名称:coner-core,代码行数:34,代码来源:CompetitionGroupSetsResource.java

示例9: addHandicapGroup

@POST
@UnitOfWork
@ApiOperation(value = "Add a Handicap Group")
@ApiResponses({
        @ApiResponse(
                code = HttpStatus.CREATED_201,
                message = ApiResponseConstants.Created.MESSAGE,
                responseHeaders = {
                        @ResponseHeader(
                                name = ApiResponseConstants.Created.Headers.NAME,
                                description = ApiResponseConstants.Created.Headers.DESCRIPTION,
                                response = String.class
                        )
                }
        ),
        @ApiResponse(
                code = HttpStatus.UNPROCESSABLE_ENTITY_422,
                message = "Failed validation",
                response = ValidationErrorMessage.class
        )
})
public Response addHandicapGroup(
        @Valid @ApiParam(value = "Handicap Group") AddHandicapGroupRequest request
) throws AddEntityException {
    HandicapGroupAddPayload addPayload = handicapGroupMapper.toDomainAddPayload(request);
    HandicapGroup domainEntity = handicapGroupEntityService.add(addPayload);
    HandicapGroupApiEntity entity = handicapGroupMapper.toApiEntity(domainEntity);
    return Response.created(UriBuilder.fromPath("/handicapGroups/{handicapGroupId}")
            .build(entity.getId()))
            .build();
}
 
开发者ID:caeos,项目名称:coner-core,代码行数:31,代码来源:HandicapGroupsResource.java

示例10: addRawTimeToFirstRunInSequenceLackingOne

@POST
@Path("/rawTimes")
@UnitOfWork
@ApiOperation(
        value = "Add a raw time to the first run in sequence lacking one, "
                + "or to a new run created on-the-fly if no runs lack a raw time"
)
@ApiResponses({
        @ApiResponse(
                code = HttpStatus.OK_200,
                message = "Assigned the given raw time to an existing run which was the first in sequence "
                        + "lacking one already",

                response = RunApiEntity.class
        ),
        @ApiResponse(
                code = HttpStatus.CREATED_201,
                message = "Created a new run entity with the given raw time. From the perspective of this "
                        + "service, this isn't strictly an error, but would probably only come about due to an "
                        + "exceptional circumstance which may spell trouble for event operations, such as a "
                        + "false start/stop trip, a driver starting without the knowledge of the workers, etc.",
                responseHeaders = {
                        @ResponseHeader(
                                name = ApiResponseConstants.Created.Headers.NAME,
                                description = ApiResponseConstants.Created.Headers.DESCRIPTION
                        )
                },
                response = RunApiEntity.class
        ),
        @ApiResponse(
                code = HttpStatus.NOT_FOUND_404,
                response = ErrorMessage.class,
                message = "No event with given ID"
        ),
        @ApiResponse(
                code = HttpStatus.UNPROCESSABLE_ENTITY_422,
                response = ValidationErrorMessage.class,
                message = "Failed validation"
        )
})
public Response addRawTimeToFirstRunInSequenceLackingOne(
        @PathParam("eventId") @ApiParam(value = "Event ID", required = true) String eventId,
        @Valid @ApiParam(value = "Time", required = true) AddRawTimeToFirstRunLackingRequest request
) throws AddEntityException, EntityNotFoundException {
    RunAddTimePayload inPayload = runMapper.toDomainAddTimePayload(request, eventId);
    RunTimeAddedPayload outPayload = runEntityService.addTimeToFirstRunInSequenceWithoutRawTime(inPayload);
    RunApiEntity run = runMapper.toApiEntity(outPayload.getRun());
    switch (outPayload.getOutcome()) {
        case RUN_RAWTIME_ASSIGNED_TO_EXISTING:
            return Response.ok(run, MediaType.APPLICATION_JSON).build();
        case RUN_ADDED_WITH_RAWTIME:
            return Response.created(UriBuilder.fromPath("/events/{eventId}/runs/{runId}")
                                            .build(eventId, run.getId()))
                    .entity(run)
                    .type(MediaType.APPLICATION_JSON)
                    .build();
        default:
            throw new RuntimeException("Unknown outcome: " + outPayload.getOutcome());
    }
}
 
开发者ID:caeos,项目名称:coner-core,代码行数:60,代码来源:EventRunsResource.java


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