Java 类javax.ws.rs.core.HttpHeaders 实例源码
项目:ThermalComfortBack
文件:AuthorizationFilter.java
private void checkPermissions(ContainerRequestContext requestContext, List<Role> allowedRoles) throws Exception {
// Check if the user contains one of the allowed roles
// Throw an Exception if the user has not permission to execute the method
if(allowedRoles.isEmpty())
return;
String authorizationHeader
= requestContext.getHeaderString(HttpHeaders.AUTHORIZATION);
String token = authorizationHeader
.substring(AUTHENTICATION_SCHEME.length()).trim();
List<String> roles = new ArrayList();
if (!JWT.decode(token).getClaim("gty").isNull() && JWT.decode(token).getClaim("gty").asString().equals("client-credentials")) {
roles.add("service");
} else {
roles = JWT.decode(token).getClaim("roles").asList(String.class);
}
for(String role: roles) {
if(allowedRoles.contains(Role.valueOf(role)))
return;
}
throw new WebApplicationException(
Response.status(Response.Status.FORBIDDEN).build());
}
项目:personium-core
文件:NullResource.java
/**
* このパスに新たなファイルを配置する.
* @param contentType Content-Typeヘッダ
* @param inputStream リクエストボディ
* @return Jax-RS Responseオブジェクトト
*/
@WriteAPI
@PUT
public final Response put(
@HeaderParam(HttpHeaders.CONTENT_TYPE) final String contentType,
final InputStream inputStream) {
// アクセス制御
this.davRsCmp.checkAccessContext(this.davRsCmp.getAccessContext(), BoxPrivilege.WRITE);
// 途中のパスが存在しないときは409エラー
/*
* A PUT that would result in the creation of a resource without an
* appropriately scoped parent collection MUST fail with a 409 (Conflict).
*/
if (!DavCommon.isValidResourceName(this.davRsCmp.getDavCmp().getName())) {
throw PersoniumCoreException.Dav.RESOURCE_NAME_INVALID;
}
if (this.isParentNull) {
throw PersoniumCoreException.Dav.HAS_NOT_PARENT.params(this.davRsCmp.getParent().getUrl());
}
return this.davRsCmp.getDavCmp().putForCreate(contentType, inputStream).build();
}
项目:jersey-2.x-webapp-for-servlet-container
文件:BookResourceIntegrationTest.java
@Test
public void testAddBookWithNecessaryFields() throws Exception {
Book book = new Book();
book.setTitle("How to Win Friends & Influence People");
book.setAuthor("Dale Carnegie");
book.setIsbn("067142517X");
book.setPages(299);
Entity<Book> bookEntity = Entity.entity(book, MediaType.APPLICATION_JSON);
Response response = target("books")
.request(MediaType.APPLICATION_JSON)
.header(HttpHeaders.AUTHORIZATION, authHeaderValue)
.post(bookEntity);
assertEquals(201, response.getStatus());
assertNotNull(response.getHeaderString("Location"));
Book bookResponse = response.readEntity(Book.class);
assertEquals("How to Win Friends & Influence People", bookResponse.getTitle());
assertEquals("Dale Carnegie", bookResponse.getAuthor());
assertEquals("067142517X", bookResponse.getIsbn());
assertEquals(299, bookResponse.getPages().intValue());
assertEquals(204, cleanUp(bookResponse.getId()).getStatus());
}
项目:osc-core
文件:ManagerApis.java
@ApiOperation(value = "Query Virtual Machine information",
notes = "Query VM information based on VM UUID, IP, MAC or Flow 6-field-tuple. Request can include all search "
+ "criteria. If found, the respond will include the VM "
+ "information based on the information provided for query. For example, if IP is provided, "
+ "response will include a map entry where the key is the IP and the value is the VM information.<br>",
response = QueryVmInfoResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"),
@ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) })
@Path("/queryVmInfo")
@POST
public Response queryVMInfo(@Context HttpHeaders headers,
@ApiParam(required = true) QueryVmInfoRequest queryVmInfo) {
log.info("Query VM info request: " + queryVmInfo);
this.userContext.setUser(OscAuthFilter.getUsername(headers));
return this.apiUtil.getResponse(this.queryVmInfoService, queryVmInfo);
}
项目:opencps-v2
文件:RegistrationManagementImpl.java
@Override
public Response submitting(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
User user, ServiceContext serviceContext, long registrationId) {
BackendAuth auth = new BackendAuthImpl();
try {
if (!auth.isAuth(serviceContext)) {
throw new UnauthenticationException();
}
Registration registration = RegistrationLocalServiceUtil.updateSubmitting(registrationId, true);
return Response.status(200).entity(registration).build();
} catch (Exception e) {
return processException(e);
}
}
项目:com-liferay-apio-architect
文件:HALPageMessageMapper.java
@Override
public void onFinishItem(
JSONObjectBuilder pageJSONObjectBuilder,
JSONObjectBuilder itemJSONObjectBuilder, T model, Class<T> modelClass,
HttpHeaders httpHeaders) {
Optional<Representor<T, Object>> optional =
representableManager.getRepresentorOptional(modelClass);
optional.map(
Representor::getTypes
).ifPresent(
types -> pageJSONObjectBuilder.nestedField(
"_embedded", types.get(0)
).arrayValue(
).add(
itemJSONObjectBuilder
)
);
}
项目:opencps-v2
文件:RegistrationFormManagementImpl.java
@Override
public Response deleteFormbyRegId(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
User user, ServiceContext serviceContext, long id, String referenceUid) {
BackendAuth auth = new BackendAuthImpl();
try {
if (!auth.isAuth(serviceContext)) {
throw new UnauthenticationException();
}
long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));
RegistrationFormActions action = new RegistrationFormActionsImpl();
action.deleteRegistrationForm(groupId, id, referenceUid);
return Response.status(HttpURLConnection.HTTP_NO_CONTENT).build();
} catch (Exception e) {
return processException(e);
}
}
项目:microprofile-jwt-auth
文件:RequiredClaimsTest.java
@RunAsClient
@Test(groups = TEST_GROUP_JWT,
description = "Verify that the exp claim is as expected")
public void verifyExpiration() throws Exception {
Reporter.log("Begin verifyExpiration\n");
String uri = baseURL.toExternalForm() + "/endp/verifyExpiration";
WebTarget echoEndpointTarget = ClientBuilder.newClient()
.target(uri)
.queryParam(Claims.exp.name(), expClaim)
.queryParam(Claims.auth_time.name(), authTimeClaim);
Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
String replyString = response.readEntity(String.class);
JsonReader jsonReader = Json.createReader(new StringReader(replyString));
JsonObject reply = jsonReader.readObject();
Reporter.log(reply.toString());
Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
项目:opencps-v2
文件:RegistrationLogManagementImpl.java
@Override
public Response addRegistrationByRegistrationId(HttpServletRequest request, HttpHeaders header, Company company,
Locale locale, User user, ServiceContext serviceContext, long registrationId, String author, String payload,
String content) {
// TODO Auto-generated method stub
BackendAuth auth = new BackendAuthImpl();
long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));
try {
if(!auth.isAuth(serviceContext)){
throw new UnauthenticationException();
}
RegistrationLogActions action = new RegistrationLogActionsImpl();
RegistrationLog registrationLog = action.addRegistrationLogById(groupId, registrationId, author, content, payload, serviceContext);
RegistrationLogModel result = RegistrationLogUtils.mappingToRegistrationLogModel(registrationLog);
return Response.status(200).entity(result).build();
} catch (Exception e) {
// TODO: handle exception
return processException(e);
}
}
项目:opencps-v2
文件:PaymentFileManagement.java
@PUT
@Path("/{id}/payments/{referenceUid}/approval")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "update DossierFile")
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns"),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response updatePaymentFileApproval(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext,
@ApiParam(value = "id of dossier", required = true) @PathParam("id") String id,
@ApiParam(value = "reference of paymentFile", required = true) @PathParam("referenceUid") String referenceUid,
@ApiParam(value = "Attachment files") @Multipart("file") Attachment file,
@ApiParam(value = "Metadata of PaymentFile") @Multipart("approveDatetime") String approveDatetime,
@ApiParam(value = "Metadata of PaymentFile") @Multipart("accountUserName") String accountUserName,
@ApiParam(value = "Metadata of PaymentFile") @Multipart("govAgencyTaxNo") String govAgencyTaxNo,
@ApiParam(value = "Metadata of PaymentFile") @Multipart("invoiceTemplateNo") String invoiceTemplateNo,
@ApiParam(value = "Metadata of PaymentFile") @Multipart("invoiceIssueNo") String invoiceIssueNo,
@ApiParam(value = "Metadata of PaymentFile") @Multipart("invoiceNo") String invoiceNo);
项目:jb-hub-client
文件:RtHubTest.java
/**
* RtHub return Request with UserAgent.
* @throws Exception If fails
*/
@Test
public void userAgent() throws Exception {
final MkContainer container = new MkGrizzlyContainer()
.next(
new MkAnswer.Simple("hello, world!")
).start();
new RtHub(
container.home()
).entry().fetch();
container.stop();
MatcherAssert.assertThat(
container.take().headers(),
Matchers.hasEntry(
Matchers.equalTo(HttpHeaders.USER_AGENT),
Matchers.hasItem(
String.format(
"jb-hub-api-client %s %s %s",
Manifests.read("Hub-Version"),
Manifests.read("Hub-Build"),
Manifests.read("Hub-Date")
)
)
)
);
}
项目:osc-core
文件:VirtualSystemApis.java
@ApiOperation(value = "Creates a Traffic Policy Mapping",
notes = "Creates a Traffic Policy Mapping owned by Virtual System provided",
response = BaseJobResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"),
@ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) })
@Path("/{vsId}/securityGroupInterfaces")
@POST
public Response createSecutiryGroupInterface(@Context HttpHeaders headers,
@ApiParam(value = "The Virtual System Id") @PathParam("vsId") Long vsId,
@ApiParam(required = true) SecurityGroupInterfaceDto sgiDto) {
logger.info("Creating Security Group Interface ...");
this.userContext.setUser(OscAuthFilter.getUsername(headers));
this.apiUtil.setParentIdOrThrow(sgiDto, vsId, "Traffic Policy Mapping");
return this.apiUtil.getResponseForBaseRequest(this.addSecurityGroupInterfaceService,
new BaseRequest<SecurityGroupInterfaceDto>(sgiDto));
}
项目:osc-core
文件:DistributedApplianceApis.java
@ApiOperation(value = "Updates a Distributed Appliance",
notes = "Updates a Distributed Appliance and sync's it immediately.",
response = BaseJobResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"),
@ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) })
@Path("/{distributedApplianceId}")
@PUT
public Response updateDistributedAppliance(@Context HttpHeaders headers,
@ApiParam(value = "The Id of the Distributed Appliance",
required = true) @PathParam("distributedApplianceId") Long distributedApplianceId,
@ApiParam(required = true) DistributedApplianceDto daDto) {
logger.info("Updating Distributed Appliance " + distributedApplianceId);
this.userContext.setUser(OscAuthFilter.getUsername(headers));
this.apiUtil.setIdOrThrow(daDto, distributedApplianceId, "DistributedAppliance");
return this.apiUtil.getResponseForBaseRequest(this.updateDistributedApplianceService,
new BaseRequest<DistributedApplianceDto>(daDto));
}
项目:opencps-v2
文件:ServiceConfigManagement.java
@PUT
@Path("/{id}/processes/{optionId}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@ApiOperation(value = "Add ProcessOption", response = ProcessOptionInputModel.class)
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a ProcessOption was updated", response = ProcessOptionInputModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response updateProcessOption(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext,
@ApiParam(value = "serviceconfigId for get detail") @PathParam("id") long id,
@ApiParam(value = "processOptionId for get detail") @PathParam("optionId") long optionId,
@ApiParam(value = "input model for ProcessOption") @BeanParam ProcessOptionInputModel input);
项目:osc-core
文件:ManagerConnectorApis.java
@ApiOperation(value = "Creates an Manager Connector",
notes = "Creates an Manager Connector and sync's it immediately.<br/> "
+ "If we are unable to connect to the manager using the credentials provided, this call will fail.<br/>"
+ "To skip validation of IP and credentials 'skipRemoteValidation' flag can be used.",
response = BaseJobResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"), @ApiResponse(code = 400,
message = "In case of any error validating the information",
response = ErrorCodeDto.class) })
@POST
public Response createApplianceManagerConnector(@Context HttpHeaders headers,
@ApiParam(required = true) ApplianceManagerConnectorRequest amcRequest) {
logger.info("Creating Appliance Manager Connector...");
this.userContext.setUser(OscAuthFilter.getUsername(headers));
Response responseForBaseRequest = this.apiUtil.getResponseForBaseRequest(this.addService,
new DryRunRequest<>(amcRequest, amcRequest.isSkipRemoteValidation()));
return responseForBaseRequest;
}
项目:osc-core
文件:VirtualSystemApis.java
@ApiOperation(value = "Retrieves the Deployment Specification",
notes = "Retrieves a Deployment Specification specified by its owning Virtual System and Deployment Spec Id",
response = ApplianceManagerConnectorDto.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"),
@ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) })
@Path("/{vsId}/deploymentSpecs/{dsId}")
@GET
public DeploymentSpecDto getDeploymentSpec(@Context HttpHeaders headers,
@ApiParam(value = "The Virtual System Id") @PathParam("vsId") Long vsId,
@ApiParam(value = "The Deployment Specification Id") @PathParam("dsId") Long dsId) {
logger.info("getting Deployment Spec " + dsId);
this.userContext.setUser(OscAuthFilter.getUsername(headers));
GetDtoFromEntityRequest getDtoRequest = new GetDtoFromEntityRequest();
getDtoRequest.setEntityId(dsId);
getDtoRequest.setEntityName("DeploymentSpec");
GetDtoFromEntityServiceApi<DeploymentSpecDto> getDtoService = this.getDtoFromEntityServiceFactory.getService(DeploymentSpecDto.class);
DeploymentSpecDto dto = this.apiUtil.submitBaseRequestToService(getDtoService, getDtoRequest).getDto();
this.apiUtil.validateParentIdMatches(dto, vsId, "SecurityGroup");
return dto;
}
项目:dotwebstack-framework
文件:RequestParameterExtractor.java
/**
* Extracts the body from the supplied request.
*/
private static void extractBodyParameter(final RequestParameters requestParameters,
final ContainerRequestContext ctx, final Optional<Parameter> parameter) throws IOException {
String body = extractBody(ctx);
if (body == null) {
return;
}
requestParameters.setRawBody(body);
if (!parameter.isPresent()) {
return;
}
if (ctx.getHeaders().get(HttpHeaders.CONTENT_TYPE).stream().filter(
header -> ContentType.APPLICATION_JSON.toString().startsWith(header)).findAny().orElse(
null) == null) {
return;
}
ObjectMapper objectMapper = new ObjectMapper();
Map json = objectMapper.readValue(body, Map.class);
if (json.keySet().size() == 1) {
requestParameters.putAll(json);
}
}
项目:osc-core
文件:VirtualizationConnectorApis.java
@ApiOperation(value = "Retrieves the Virtualization Connector by Id",
notes = "Password information is not returned as it is sensitive information",
response = VirtualizationConnectorDto.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"),
@ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) })
@Path("/{vcId}")
@GET
public VirtualizationConnectorDto getVirtualizationConnector(@Context HttpHeaders headers,
@ApiParam(value = "The Virtualization Connector Id") @PathParam("vcId") Long vcId) {
logger.info("getting Virtualization Connector " + vcId);
this.userContext.setUser(OscAuthFilter.getUsername(headers));
GetDtoFromEntityRequest getDtoRequest = new GetDtoFromEntityRequest();
getDtoRequest.setEntityId(vcId);
getDtoRequest.setEntityName("VirtualizationConnector");
return this.apiUtil
.submitBaseRequestToService(this.getDtoFromEntityServiceFactory.getService(VirtualizationConnectorDto.class), getDtoRequest)
.getDto();
}
项目:microprofile-jwt-auth
文件:ProviderInjectionTest.java
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
description = "Verify that the injected token issuer claim is as expected")
public void verifyIssuerClaim2() throws Exception {
Reporter.log("Begin verifyIssuerClaim");
String uri = baseURL.toExternalForm() + "/endp/verifyInjectedIssuer";
WebTarget echoEndpointTarget = ClientBuilder.newClient()
.target(uri)
.queryParam(Claims.iss.name(), TCKConstants.TEST_ISSUER)
.queryParam(Claims.auth_time.name(), authTimeClaim);
Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
String replyString = response.readEntity(String.class);
JsonReader jsonReader = Json.createReader(new StringReader(replyString));
JsonObject reply = jsonReader.readObject();
Reporter.log(reply.toString());
Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
项目:keycloak-protocol-cas
文件:ServiceResponseHelper.java
public static Response createResponse(Response.Status status, MediaType mediaType, CASServiceResponse serviceResponse) {
Response.ResponseBuilder builder = Response.status(status)
.header(HttpHeaders.CONTENT_TYPE, mediaType.withCharset("utf-8"));
if (MediaType.APPLICATION_JSON_TYPE.equals(mediaType)) {
return builder.entity(ServiceResponseMarshaller.marshalJson(serviceResponse)).build();
} else {
return builder.entity(ServiceResponseMarshaller.marshalXml(serviceResponse)).build();
}
}
项目:Java-9-Programming-Blueprints
文件:ConversationService.java
public boolean sendMessage(Message message) {
Response r = getWebTarget().path("conversations")
.request()
.header(HttpHeaders.AUTHORIZATION, getAuthorizationHeader())
.post(Entity.json(message));
return r.getStatus() == Response.Status.CREATED.getStatusCode();
}
项目:com-liferay-apio-architect
文件:MockPageWriter.java
/**
* Writes a Collection of {@link RootModel}, with the hierarchy of embedded
* models and multiple fields.
*
* @param httpHeaders the request's {@code HttpHeaders}
* @param pageMessageMapper the {@link PageMessageMapper} to use for writing
* the JSON object
*/
public static JsonObject write(
HttpHeaders httpHeaders,
PageMessageMapper<RootModel> pageMessageMapper) {
RequestInfo requestInfo = getRequestInfo(httpHeaders);
Collection<RootModel> items = Arrays.asList(
() -> "1", () -> "2", () -> "3");
PageItems<RootModel> pageItems = new PageItems<>(items, 9);
Pagination pagination = new Pagination(3, 2);
Path path = new Path("name", "id");
Page<RootModel> page = new Page<>(
RootModel.class, pageItems, pagination, path);
PageWriter<RootModel> pageWriter = PageWriter.create(
builder -> builder.page(
page
).pageMessageMapper(
pageMessageMapper
).pathFunction(
MockWriterUtil::identifierToPath
).resourceNameFunction(
__ -> Optional.of("models")
).representorFunction(
MockWriterUtil::getRepresentorOptional
).requestInfo(
requestInfo
).build());
return new Gson().fromJson(pageWriter.write(), JsonObject.class);
}
项目:opencps-v2
文件:DeliverablesManagement.java
@POST
@Path("/deliverables/agency/{agencyNo}/type/{typeCode}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@ApiOperation(value = "Get list dataform by agencyNo and typeCode")
@ApiResponses(value = {
@ApiResponse (code = HttpURLConnection.HTTP_OK, message = "Return a list dataform"),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not Found", response = ExceptionModel.class),
@ApiResponse (code = HttpURLConnection.HTTP_FORBIDDEN, message = "Accsess denied", response = ExceptionModel.class) })
public Response getDataFormByTypeCode (@Context HttpServletRequest request, @Context HttpHeaders header, @Context Company company,
@Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
@ApiParam(value = "id for agency", required = true) @PathParam("agencyNo") String agencyNo,
@ApiParam(value = "id for type", required = true) @PathParam("typeCode") String typeCode,
@FormParam("keyword") String keyword);
项目:opencps-v2
文件:EmployeeManagement.java
@DELETE
@Path("/{id}")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response delete(@Context HttpServletRequest request, @Context HttpHeaders header, @Context Company company,
@Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
@DefaultValue("0") @PathParam("id") long id);
项目:keycloak-jaxrs-client-authfilter
文件:BasicAuthFilter.java
@Override
public void filter( final ClientRequestContext requestContext )
throws IOException
{
final String pair = _username + ":" + _password;
final String header = "Basic " + Base64.getEncoder().encodeToString( pair.getBytes() );
requestContext.getHeaders().add( HttpHeaders.AUTHORIZATION, header );
}
项目:opencps-v2
文件:ServiceProcessManagement.java
@POST
@Path("/{id}/steps")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Add the ProcessStep of a ServiceProcess", response = ProcessStepInputModel.class)
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a ProcessStep was added", response = ProcessStepInputModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response addProcessStep(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext, @PathParam("id") long id, @BeanParam ProcessStepInputModel input);
项目:com-liferay-apio-architect
文件:SingleModelMessageMapperTest.java
@Test
public void testMessageMapperIsEmptyByDefaultAndSupportsMapping() {
SingleModelMessageMapper<Integer> singleModelMessageMapper =
() -> "mediaType";
HttpHeaders httpHeaders = Mockito.mock(HttpHeaders.class);
SingleModel<Integer> singleModel = new SingleModel<>(3, Integer.class);
assertThat(
singleModelMessageMapper.supports(singleModel, httpHeaders),
is(true));
}
项目:personium-core
文件:CellResource.java
/**
* PROPFINDメソッドの処理.
* @param requestBodyXml Request Body
* @param depth Depth Header
* @param contentLength Content-Length Header
* @param transferEncoding Transfer-Encoding Header
* @return JAX-RS Response
*/
@WebDAVMethod.PROPFIND
public Response propfind(final Reader requestBodyXml,
@DefaultValue("0") @HeaderParam(PersoniumCoreUtils.HttpHeaders.DEPTH) final String depth,
@HeaderParam(HttpHeaders.CONTENT_LENGTH) final Long contentLength,
@HeaderParam("Transfer-Encoding") final String transferEncoding) {
// Access Control
this.cellRsCmp.checkAccessContext(this.cellRsCmp.getAccessContext(), CellPrivilege.PROPFIND);
return this.cellRsCmp.doPropfind(requestBodyXml, depth, contentLength, transferEncoding,
CellPrivilege.ACL_READ);
}
项目:opencps-v2
文件:EmployeeManagement.java
@PUT
@Path("/{id}/photo")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response uploadEmployeePhoto(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext, @PathParam("id") long id, @Multipart("file") Attachment attachment,
@Multipart("fileName") String fileName, @Multipart("fileType") String fileType,
@Multipart("fileSize") long fileSize);
项目:opencps-v2
文件:JobposManagement.java
@DELETE
@Path("/{id}")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response delete(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
@DefaultValue("0") @PathParam("id") long id);
项目:incubator-servicecomb-java-chassis
文件:TestVertxServerRequestToHttpServletRequest.java
@Test
public void testGetContentType() {
new Expectations() {
{
vertxRequest.getHeader(HttpHeaders.CONTENT_TYPE);
result = "json";
}
};
Assert.assertEquals("json", request.getContentType());
}
项目:ctsms
文件:FileDavResourceBase.java
protected javax.ws.rs.core.Response davPut(InputStream input, Long id, String fileName,
long contentLength, HttpHeaders httpHeaders)
throws AuthenticationException, AuthorisationException, ServiceException {
// @Context final UriInfo uriInfo,
// @Context final Providers providers,
/* Workaround for Jersey issue #154 (see https://jersey.dev.java.net/issues/show_bug.cgi?id=154): Jersey will throw an exception and abstain from calling a method if the
* method expects a JAXB element body while the actual Content-Length is zero. */
// final Contact entity = contentLength == 0 ? new Contact(matchCode, null, null, null) : providers.getMessageBodyReader(Contact.class, Contact.class,
// new Annotation[0], new MediaType("application", "address+xml")).readFrom(Contact.class, Contact.class, new Annotation[0],
// new MediaType("application", "address+xml"), httpHeaders.getRequestHeaders(), entityStream);
/* End of #154 workaround */
FileOutVO out = getFileFromDavFileName(id, fileName);
FileInVO in = new FileInVO();
FileStreamInVO stream = new FileStreamInVO();
stream.setStream(input);
stream.setMimeType(httpHeaders.getMediaType().toString());
stream.setSize(contentLength);
if (out != null) {
FileBean.copyFileOutToIn(in, out);
stream.setFileName(out.getFileName());
WebUtil.getServiceLocator().getFileService().updateFile(getAuth(), in, stream);
} else {
FileBean.initFileDefaultValues(in, id, getFileModule());
in.setTitle(fileName);
// in.setComment(value);
in.setLogicalPath(TMP_FILE_LOGICAL_PATH);
stream.setFileName(fileName);
WebUtil.getServiceLocator().getFileService().addFile(getAuth(), in, stream);
}
return javax.ws.rs.core.Response.noContent().build();
}
项目:opencps-v2
文件:ApplicantManagement.java
@DELETE
@Path("{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@ApiOperation(value = "Remove a applicant", response = ApplicantModel.class)
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the applicant was removed", response = ApplicantModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class) })
public Response deleteApplicant(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext, @PathParam("id") long id);
项目:osc-core
文件:ServerMgmtApis.java
/**
* Delete SSL certificate entry
*/
@ApiOperation(value = "Deletes a SSL certificate entry",
notes = "Deletes a SSL certificate entry if not referenced by any available connector or manager")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successful operation"),
@ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class)
})
@Path("/sslcertificate/{alias}")
@OscAuth
@DELETE
public Response deleteSslCertificate(@Context HttpHeaders headers, @ApiParam(value = "SSL certificate alias") @PathParam("alias") String alias) {
logger.info("Deleting SSL certificate from trust store with alias: " + alias);
this.userContext.setUser(OscAuthFilter.getUsername(headers));
return this.apiUtil.getResponse(this.deleteSslCertificateService, new DeleteSslEntryRequest(alias));
}
项目:opencps-v2
文件:DeliverableTypesManagement.java
@PUT
@Path("/{id}/formreport")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "update FormScript")
@ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns"),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response updateDeliverableTypeFormReport(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext,
@ApiParam(value = "id of DeliverableType", required = true) @PathParam("id") long deliverableTypeId,
@ApiParam(value = "formReport of dossierfile", required = true) @FormParam("formReport") String formReport);
项目:osc-core
文件:DistributedApplianceApis.java
@ApiOperation(value = "Deletes a Distributed Appliance",
notes = "Triggers a Job to clean up all artifacts by Distributed Appliance references objects.",
response = BaseJobResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"),
@ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) })
@Path("/{distributedApplianceId}")
@DELETE
public Response deleteDistributedAppliance(@Context HttpHeaders headers,
@ApiParam(value = "The Id of the Distributed Appliance Appliance",
required = true) @PathParam("distributedApplianceId") Long distributedApplianceId) {
logger.info("Deleting Distributed Appliance " + distributedApplianceId);
this.userContext.setUser(OscAuthFilter.getUsername(headers));
return this.apiUtil.getResponseForBaseRequest(this.deleteDistributedApplianceService,
new BaseDeleteRequest(distributedApplianceId, false)); // false as this is not force delete
}
项目:opencps-v2
文件:ResourceUserManagement.java
@GET
@Path("/{className}/{classPK}/cloning/{sourcePK}")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response clone(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
@DefaultValue(StringPool.BLANK) @PathParam("className") String className, @DefaultValue(StringPool.BLANK) @PathParam("classPK") String classPK,
@DefaultValue(StringPool.BLANK) @PathParam("sourcePK") String sourcePK);
项目:incubator-servicecomb-java-chassis
文件:TestBodyProcessor.java
@Test
public void testSetValueRawJson() throws Exception {
createClientRequest();
createRawJsonProcessor();
processor.setValue(clientRequest, "value");
Assert.assertEquals(MediaType.APPLICATION_JSON, headers.get(HttpHeaders.CONTENT_TYPE));
Assert.assertEquals("value", outputBodyBuffer.toString());
}