public StompSubscription(StompConnection connection, String destination, String subscriptionId, MediaType mediaType, ResourceCodec codec) { this.connection = connection; this.destination = destination; this.subscriptionId = subscriptionId; this.mediaType = mediaType; this.codec = codec; this.resourcePath = new ResourcePath(destination); }
private MediaType contentType(RequestContext ctx) { try { MediaType mediaType = (MediaType) ctx.requestAttributes().getAttribute(HttpHeaders.Names.CONTENT_TYPE); if (mediaType != null) { return mediaType; } } catch (NullPointerException e) { log.trace("Unable to retrieve Content-Type header from Request. Defaulting to 'application/json'."); } return MediaType.JSON; }
private RequestContext createPolicyReq() { RequestAttributes attribs = new DefaultRequestAttributes(); attribs.setAttribute(AuthzConstants.ATTR_REQUEST_CONTEXT, ctxToAuthorize); attribs.setAttribute(AuthzConstants.ATTR_REQUEST_RESOURCE_STATE, reqStateToAuthorize); attribs.setAttribute(AuthzConstants.ATTR_RESPONSE_RESOURCE_STATE, respStateToAuthorize); return new RequestContext.Builder().requestAttributes(attribs).build(); }
private DefaultResourceRequest(ResourceRequest original) { this.requestType = original.requestType(); this.resourcePath = original.resourcePath(); this.requestId = original.requestId(); }
public StatusResource(URI uri, ResourceProcessingException e) { this.uri = uri; this.error = e; id = new ResourcePath(uri.toString()).tail().toString(); }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg instanceof ResourceResponse) { ((ResourceResponse) msg).inReplyTo().requestContext().dispose(); } super.write(ctx, msg, promise); }
@Override public UUID requestId() { return this.inReplyTo.requestId(); }
public RootEncodingDriver(RequestContext requestContext, ResourceEncoder encoder, Resource resource, Runnable completionHandler, Consumer<Throwable> errorHandler) { super(resource, requestContext.returnFields()); this.requestContext = requestContext; this.encoder = encoder; this.completionHandler = completionHandler; this.errorHandler = errorHandler; }
public ResourceCodec getResourceCodec(MediaType mediaType) { for (CodecRegistration each : this.codecs) { if (each.mediaType.equals(mediaType)) { return each.codec; } } return null; }
@Override public MediaTypeMatcher mediaTypeMatcher() { return delegate.mediaTypeMatcher(); } }
@Override public void onDispose(Runnable runnable) { delegate.onDispose(runnable); } }
public ResourceRequest request() { if (this.request != null) { return this.request; } return this.response.inReplyTo(); }
private MediaType accept(RequestContext ctx) { try { MediaType mediaType = (MediaType) ctx.requestAttributes().getAttribute(HttpHeaders.Names.ACCEPT); if (mediaType != null) { return mediaType; } } catch (NullPointerException e) { log.trace("Unable to retrieve Accept header from Request. Defaulting to 'application/json'."); } return MediaType.JSON; }
public StateEncodingDriver(RequestContext ctx, StateEncoder stateEncoder, ResourceState resourceState) { super(resourceState, ctx.returnFields()); this.stateEncoder = stateEncoder; }
@Override public void onDispose(Runnable runnable) { delegate.onDispose(runnable); } }
private String getBearerToken(RequestContext requestContext) { String auth = requestContext.requestAttributes().getAttribute(HttpHeaders.Names.AUTHORIZATION, String.class); if (auth != null) { String[] a = auth.split(" "); if (a.length == 2 && a[0].equalsIgnoreCase(AUTH_TYPE)) { return a[1]; } } return null; }