本文整理汇总了Java中org.apache.cxf.jaxrs.utils.JAXRSUtils类的典型用法代码示例。如果您正苦于以下问题:Java JAXRSUtils类的具体用法?Java JAXRSUtils怎么用?Java JAXRSUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JAXRSUtils类属于org.apache.cxf.jaxrs.utils包,在下文中一共展示了JAXRSUtils类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getDataFormat
import org.apache.cxf.jaxrs.utils.JAXRSUtils; //导入依赖的package包/类
private DataFormat getDataFormat(MediaType mt) {
String type = JAXRSUtils.mediaTypeToString(mt);
DataFormat format = formats.get(type);
if (format != null) {
return format;
}
int subtypeIndex = type.lastIndexOf('+');
if (subtypeIndex != -1) {
// example, application/json+v1, should still be handled by JSON
// handler, etc
format = formats.get(type.substring(0, subtypeIndex));
}
if (format == null && formats.containsKey(MediaType.WILDCARD)) {
format = formats.get(MediaType.WILDCARD);
}
return format;
}
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:DataFormatProvider.java
示例2: validate
import org.apache.cxf.jaxrs.utils.JAXRSUtils; //导入依赖的package包/类
public ValidatorReport validate(Attachment docAttachment, String testcaseId) throws Exception {
Exchange exchange = JAXRSUtils.getCurrentMessage().getExchange();
ValidatorSubmission submission = new ValidatorSubmissionImpl();
exchange.put(ValidatorSubmission.class, submission);
ValidatorDocument doc = new ValidatorDocumentImpl();
submission.setDocument(doc);
submission.setTestcaseId(testcaseId);
doc.setFileName(CrigttFileUtils.buildSafeFileName(docAttachment.getContentDisposition().getParameter(ContentDispositionParameters.FILENAME)));
try (InputStream docInStream = docAttachment.getDataHandler().getInputStream()) {
doc.setContent(IOUtils.toByteArray(docInStream));
}
return this.validatorService.validate(submission);
}
开发者ID:esacinc,项目名称:crigtt,代码行数:19,代码来源:ValidatorWebServiceImpl.java
示例3: extract
import org.apache.cxf.jaxrs.utils.JAXRSUtils; //导入依赖的package包/类
protected SAML2ReceivedResponseTO extract(
final String spEntityID,
final String urlContext,
final String clientAddress,
final InputStream response) throws IOException {
String strForm = IOUtils.toString(response);
MultivaluedMap<String, String> params = JAXRSUtils.getStructuredParams(strForm, "&", false, false);
String samlResponse = params.getFirst(SSOConstants.SAML_RESPONSE);
if (StringUtils.isNotBlank(samlResponse)) {
samlResponse = URLDecoder.decode(samlResponse, StandardCharsets.UTF_8.name());
LOG.debug("Received SAML Response: {}", samlResponse);
}
String relayState = params.getFirst(SSOConstants.RELAY_STATE);
LOG.debug("Received Relay State: {}", relayState);
SAML2ReceivedResponseTO receivedResponseTO = new SAML2ReceivedResponseTO();
receivedResponseTO.setSpEntityID(spEntityID);
receivedResponseTO.setUrlContext(urlContext);
receivedResponseTO.setSamlResponse(samlResponse);
receivedResponseTO.setRelayState(relayState);
return receivedResponseTO;
}
开发者ID:apache,项目名称:syncope,代码行数:26,代码来源:AbstractSAML2SPServlet.java
示例4: filter
import org.apache.cxf.jaxrs.utils.JAXRSUtils; //导入依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
OidcClientTokenContext ctx = (OidcClientTokenContext) JAXRSUtils.getCurrentMessage().getContent(ClientTokenContext.class);
IdToken idToken = ctx.getIdToken();
String email = idToken.getEmail();
String hdParam = idToken.getStringProperty("hd");
boolean fromGsuite = config.getGSuiteDomain().equalsIgnoreCase(hdParam);
Set<String> externalAccounts = externalAccountsCache.get();
if (!fromGsuite && !externalAccounts.contains(email)) {
log.error("Unauthorized access from {}", hdParam);
ServerError err = new ServerError("E001", "Sorry you are not allowed to enter this site");
requestContext.abortWith(Response.status(Response.Status.UNAUTHORIZED).entity(err).type(MediaType.APPLICATION_JSON).build());
}
}
开发者ID:hlavki,项目名称:g-suite-identity-sync,代码行数:15,代码来源:GSuiteGroupAuthorizationFilter.java
示例5: getCurrentAuthPolicy
import org.apache.cxf.jaxrs.utils.JAXRSUtils; //导入依赖的package包/类
@Override
public AuthorizationPolicy getCurrentAuthPolicy() throws RMapApiException {
AuthorizationPolicy authorizationPolicy = null;
Message message = JAXRSUtils.getCurrentMessage();
authorizationPolicy = message.get(AuthorizationPolicy.class);
if (authorizationPolicy == null) {
throw new RMapApiException(ErrorCode.ER_COULD_NOT_RETRIEVE_AUTHPOLICY);
}
LOG.debug("Authorization policy retrieved with username {}", authorizationPolicy.getUserName());
return authorizationPolicy;
}
开发者ID:rmap-project,项目名称:rmap,代码行数:12,代码来源:ApiUserServiceImpl.java
示例6: filter
import org.apache.cxf.jaxrs.utils.JAXRSUtils; //导入依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
final Message message = JAXRSUtils.getCurrentMessage();
final Exchange exchange = message.getExchange();
final String methodName = String.valueOf(exchange.get(OPERATION_NAME_PROP));
message.put(HTTPClientPolicy.class, policyMap.get(methodName));
}
开发者ID:Microbule,项目名称:microbule,代码行数:8,代码来源:TimeoutFilter.java
示例7: writeTo
import org.apache.cxf.jaxrs.utils.JAXRSUtils; //导入依赖的package包/类
@Override
public void writeTo(ValidatorResponse resp, Class<?> type, Type genericType, Annotation[] annos, MediaType mediaType,
MultivaluedMap<String, Object> headers, OutputStream entityStream) throws IOException, WebApplicationException {
Exchange exchange = JAXRSUtils.getCurrentMessage().getExchange();
ValidatorRenderer renderer =
this.rendererContentTypes.keySet().stream().filter(mediaType::isCompatible).map(this.rendererContentTypes::get).findFirst().get();
headers.putSingle(ValidatorHeaders.RESP_FILE_NAME_NAME,
ValidatorUtils.buildResponseFileName(true, exchange.get(ValidatorSubmission.class), renderer.getType()));
MultivaluedMap<String, String> queryParams = new UriInfoImpl(exchange.getInMessage()).getQueryParameters();
Map<String, String> mergedQueryParams = new HashMap<>(this.defaultQueryParams);
queryParams.keySet().stream().forEach(queryParamName -> mergedQueryParams.put(queryParamName, queryParams.getFirst(queryParamName)));
Map<String, Object> renderOpts = new HashMap<>();
if (mergedQueryParams.containsKey(ValidatorParameters.FORMAT_NAME)) {
renderOpts.put(ValidatorRenderOptions.FORMAT_NAME, BooleanUtils.toBoolean(mergedQueryParams.get(ValidatorParameters.FORMAT_NAME)));
}
if (mergedQueryParams.containsKey(ValidatorParameters.TIME_ZONE_NAME)) {
renderOpts.put(ValidatorRenderOptions.TIME_ZONE_NAME,
TimeZone.getTimeZone(ZoneOffset.of(mergedQueryParams.get(ValidatorParameters.TIME_ZONE_NAME))));
}
try {
entityStream.write(renderer.render(resp, renderOpts));
} catch (Exception e) {
throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR);
}
}
开发者ID:esacinc,项目名称:crigtt,代码行数:33,代码来源:ValidatorRendererProvider.java
示例8: find
import org.apache.cxf.jaxrs.utils.JAXRSUtils; //导入依赖的package包/类
public static <T> T find(final Class<T> clazz) {
final Message m = JAXRSUtils.getCurrentMessage();
if (m != null) {
return JAXRSUtils.createContextValue(m, null, clazz);
}
final Exchange exchange = EXCHANGE.get();
if (exchange == null) {
throw new IllegalStateException("No CXF message usable for JAX-RS @Context injections in that thread so can't use " + clazz);
}
return JAXRSUtils.createContextValue(exchange.getInMessage(), null, clazz);
}
开发者ID:apache,项目名称:tomee,代码行数:12,代码来源:Contexts.java
示例9: toResponse
import org.apache.cxf.jaxrs.utils.JAXRSUtils; //导入依赖的package包/类
@Override
public Response toResponse(Throwable exception) {
SdcctHttpStatus respStatus = SdcctHttpStatus.INTERNAL_SERVER_ERROR;
OperationOutcome opOutcome = null;
if (exception instanceof FhirWsException) {
FhirWsException wsException = ((FhirWsException) exception);
respStatus = wsException.getResponseStatus();
if (wsException.hasOperationOutcome()) {
opOutcome = wsException.getOperationOutcome();
}
}
if (opOutcome == null) {
opOutcome = new OperationOutcomeBuilder().build();
}
// noinspection ThrowableResultOfMethodCallIgnored
ValidationException validationCause = SdcctExceptionUtils.findCause(exception, ValidationException.class);
if (validationCause != null) {
for (ValidationIssue validationIssue : validationCause.getResult().getIssues().getIssues()) {
opOutcome.addIssues(buildValidationIssueSource(buildValidationIssueDetails(new OperationOutcomeIssueBuilder()
.setType(buildValidationIssueType(validationIssue.getType())).setSeverity(IssueSeverity.valueOf(validationIssue.getSeverity().name()))
.setLocation(buildValidationLocation(validationIssue.getLocation()))
.setDetails(OperationOutcomeType.MSG_ERROR_PARSING, validationIssue.getMessage()), validationIssue), validationIssue).build());
}
}
if (!opOutcome.hasIssues()) {
opOutcome.addIssues(new OperationOutcomeIssueBuilder().build());
}
if (MessageUtils.getContextualBoolean(JAXRSUtils.getCurrentMessage(), WsPropertyNames.ERROR_STACK_TRACE, false)) {
try {
opOutcome.setText(new NarrativeImpl()
.setDiv(new DivImpl().addContent(new String(
this.xmlCodec.encode(new PreImpl().addContent(SdcctExceptionUtils.buildRootCauseStackTrace(exception)), null), StandardCharsets.UTF_8)))
.setStatus(new NarrativeStatusComponentImpl().setValue(NarrativeStatus.ADDITIONAL)));
} catch (Exception e) {
LOGGER.error("Unable to encode FHIR operation outcome narrative.", e);
}
}
return Response.status(respStatus).entity(opOutcome).build();
}
开发者ID:esacinc,项目名称:sdcct,代码行数:49,代码来源:FhirExceptionMapper.java
示例10: toResponse
import org.apache.cxf.jaxrs.utils.JAXRSUtils; //导入依赖的package包/类
@Override
public Response toResponse(final ResponseConstraintViolationException exception) {
return JAXRSUtils.toResponse(Response.Status.BAD_REQUEST);
}
开发者ID:apache,项目名称:tomee,代码行数:5,代码来源:CxfRsHttpListener.java
示例11: is404
import org.apache.cxf.jaxrs.utils.JAXRSUtils; //导入依赖的package包/类
private boolean is404(final Message message, final Response response) {
return response.getStatus() == HttpsURLConnection.HTTP_NOT_FOUND
&& message.getExchange().get(JAXRSUtils.EXCEPTION_FROM_MAPPER) == null;
}
开发者ID:apache,项目名称:tomee,代码行数:5,代码来源:CustomHandler.java
示例12: process
import org.apache.cxf.jaxrs.utils.JAXRSUtils; //导入依赖的package包/类
@Override
public void process(Exchange exchange) throws Exception {
String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
MultivaluedMap<String, String> queryMap = JAXRSUtils.getStructuredParams(queryString, "&", false, false);
for (Map.Entry<String, List<String>> eachQueryParam : queryMap.entrySet()) {
exchange.setProperty(eachQueryParam.getKey(), eachQueryParam.getValue());
}
}
开发者ID:arunma,项目名称:osgicxfcamelmultiparams,代码行数:13,代码来源:RestToBeanRouter.java
注:本文中的org.apache.cxf.jaxrs.utils.JAXRSUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论