當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。