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); }
public void setHtmlApplicationPath(String path) { this.htmlAppPath = new ResourcePath(path); }
public ResourcePath resourcePath() { return new ResourcePath(resourcePath); }
public ResourcePath parent() { if (this.segments.isEmpty()) { return new ResourcePath(); } return new ResourcePath(segments.subList(0, segments.size() - 1)); }
public ResourcePath subPath() { if (this.segments.isEmpty()) { return new ResourcePath(); } return new ResourcePath(segments.subList(1, segments.size())); }
public HttpSubscription(HttpClient httpClient, String path, URI destination, ResourceCodec codec, SecurityContext securityContext) { this.id = UUID.randomUUID().toString(); this.httpClient = httpClient; this.resourcePath = new ResourcePath(path); this.destination = destination; this.codec = codec; this.securityContext = securityContext; }
public GridFSResourcePath top(int count) { List<Segment> segs = segments(); if (segs == null || segs.size() == 0) { segs = null; } else { segs = segs.subList(0, count); } return new GridFSResourcePath(new ResourcePath(segs)); }
public DefaultResourceRef(URI uri) { this.resourcePath = new ResourcePath(uri.getPath().toString()); uri(uri); }
public StatusResource(URI uri, ResourceProcessingException e) { this.uri = uri; this.error = e; id = new ResourcePath(uri.toString()).tail().toString(); }
public DefaultResourceRef(ResourceRef parent, String id) throws URISyntaxException { this.resourcePath = new ResourcePath(parent.uri() + "/" + id); this.parent = parent; uri(new URI(resourcePath.toString())); }
/** * Perform an asynchronous READ action. * * @param context The request context. * @param path The path portion of the resource's URI. * @param handler Asynchronously result handler. */ @Override public void read(RequestContext context, String path, Consumer<ClientResourceResponse> handler) { ResourceRequest request = new DefaultResourceRequest.Builder(RequestType.READ, new ResourcePath(path)) .requestContext(context) .build(); this.connection.write(new ClientRequest(request, handler)); }
/** * Perform an asynchronous DELETE action. * * @param context The request context. * @param path The path portion of the resource's URI. * @param handler Asynchronously result handler. */ @Override public void delete(RequestContext context, String path, Consumer<ClientResourceResponse> handler) { ResourceRequest request = new DefaultResourceRequest.Builder(RequestType.DELETE, new ResourcePath(path)) .requestContext(context) .build(); this.connection.write(new ClientRequest(request, handler)); }
default void handleConfigObject(ObjectsTree<Object> configVars, String name, Object value, String... path) { if (value != null) { if (value instanceof ResourceState) { updateConfigEnvVars(configVars, (ResourceState) value, append(name, path)); } else if (value instanceof List) { ((List) value).forEach(obj->handleConfigObject(configVars, name, obj, path)); } else { String val = value.toString(); int start = val.indexOf("${"); int end = val.indexOf("}", start); if (end > start) { configVars.addObject(value, new ResourcePath(append(name, path))); } } } }
default void readConfigEnvVars(ObjectsTree<Object> configVars, RequestContext ctx, PropertySink sink) { boolean runtimeValuePresent = ctx.resourceParams().value("runtime") != null; boolean runtimeRequested = runtimeValuePresent ? Boolean.parseBoolean(ctx.resourceParams().value("runtime")) : ctx.resourceParams().names().contains("runtime"); // If runtime is not set, we replace the config values if (!runtimeRequested && configVars != null) { sink.replaceConfig((names, object) -> { ResourcePath path = new ResourcePath(names); List<Object> values = configVars.objects(path).collect(Collectors.toList()); if (values != null && values.size() == 1) { return values.get(0); } return object; }); } }
protected ResourcePath resourcePathOf(Resource resource) { ResourcePath path = new ResourcePath(); Resource current = resource; while (current != null) { if (!current.id().equals("")) { path.prependSegment(current.id()); } current = current.parent(); } return path; }
protected ResourcePath applicationResourcePath() { ResourcePath path = new ResourcePath(); path.prependSegment(this.parent().id()); return path; }
private String selfHrefId(String field, Object val) { if (val == null || val instanceof ResourceState == false) { throw new RuntimeException("Invalid value for '" + field + "': " + val); } String href = null; if (val instanceof ResourceRef) { href = ((ResourceRef) val).uri().toString(); if (href == null) { throw new RuntimeException("Not a valid resource reference - empty uri - for '" + field + "': " + val); } } else { Object self = ((ResourceState) val).getProperty(LiveOak.SELF); if (self == null || self instanceof ResourceState == false) { throw new RuntimeException("Not a valid resource reference - no 'self' - for '" + field + "': " + val); } href = ((ResourceState) self).getPropertyAsString(LiveOak.HREF); if (href == null) { throw new RuntimeException("Not a valid resource reference - no 'self/href' - for '" + field + "': " + val); } } return new ResourcePath(href).tail().toString(); }
/** * Perform an asynchronous CREATE action. * * @param context The request context. * @param path The path portion of the resource's URI. * @param state The inbound state to use during creation. * @param handler Asynchronously result handler. */ @Override public void create(RequestContext context, String path, ResourceState state, Consumer<ClientResourceResponse> handler) { ResourceRequest request = new DefaultResourceRequest.Builder(RequestType.CREATE, new ResourcePath(path)) .resourceState(state) .requestContext(context) .build(); this.connection.write(new ClientRequest(request, handler)); }
public void configure(URIPolicy policy, URIPolicyConfig uriPolicyConfig) { this.rulesTree = new ObjectsTree<>(); for (URIPolicyConfigRule cfgRule : uriPolicyConfig.getRules()) { addURIPolicyRule(new ResourcePath(cfgRule.getUriPattern()), cfgRule.getRequestTypes(), cfgRule.getAllowedRoles(), cfgRule.getDeniedRoles(), cfgRule.getAllowedUsers(), cfgRule.getDeniedUsers()); } policy.setRulesTree(this.rulesTree); log.debug("URIPolicy configuration updated successfully"); }
@Override public void onOutbound(OutboundInterceptorContext context) throws Exception { ResourceResponse response = context.response(); if (context.request().requestType() == RequestType.READ && response.responseType() == ResourceResponse.ResponseType.READ && response.state() != null) { ResourcePath resourcePath = new ResourcePath(response.resource().uri().toString()); SecurityContext securityContext = context.request().requestContext().securityContext(); // Process just members of response.state() and not the state itself as resource has been already authorized at onInbound processMembers(resourcePath, response.state(), securityContext, new Consumer<ResourceState>() { @Override public void accept(ResourceState authorizedState) { response.setState(authorizedState); context.forward(); } }); } else { super.onOutbound(context); } }