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 DefaultResourceRef(ResourceRef parent, String id) throws URISyntaxException { this.resourcePath = new ResourcePath(parent.uri() + "/" + id); this.parent = parent; uri(new URI(resourcePath.toString())); }
public ObjectsTree<T> findLeaf(ResourcePath path) { if (path.isEmpty()) { return this; } String id = path.head().name(); ObjectsTree<T> child = this.children.get(id); if (child == null) { child = new ObjectsTree<>(); this.children.put(path.head().name(), child); } // For now, support * just at the end if (id.equals("*") && !path.subPath().isEmpty()) { throw new IllegalArgumentException("* supported just at the end. Remaining path is " + path.subPath()); } return child.findLeaf(path.subPath()); }
public StatusResource(URI uri, ResourceProcessingException e) { this.uri = uri; this.error = e; id = new ResourcePath(uri.toString()).tail().toString(); }
protected void addURIPolicyRule(ResourcePath resourcePath, Collection<String> requestTypes, Collection<String> allowedRoles, Collection<String> deniedRoles, Collection<String> allowedUsers, Collection<String> deniedUsers) { RolesContainer rolesContainer = new RolesContainer() .addAllAllowedRoles(allowedRoles).addAllDeniedRoles(deniedRoles) .addAllAllowedUsers(allowedUsers).addAllDeniedUsers(deniedUsers); URIPolicyRule rule = new URIPolicyRule(resourcePath, requestTypes, rolesContainer); // We want to support '/foo/bar*' which is mapped to both '/foo/bar' and '/foo/bar/*' String tailName = resourcePath.tail().name(); if (tailName.endsWith("*") && !tailName.equals("*")) { String lastSegment = tailName.substring(0, tailName.length() - 1); resourcePath = resourcePath.parent(); resourcePath.appendSegment(lastSegment); ResourcePath wildcardPath = new ResourcePath(resourcePath); wildcardPath.appendSegment("*"); this.rulesTree.addObject(rule, resourcePath); this.rulesTree.addObject(rule, wildcardPath); } else { this.rulesTree.addObject(rule, resourcePath); } log.debug("Added new URIPolicyRule for resourcePath " + resourcePath + ". Rule: " + rule); } }
String prefix = new ResourcePath(state.uri().toString()).parent().parent().toString() + "/" + refTable.id() + "/"; List<String> currentUris = prefixElements(extractPksFromResults(results, refTable), prefix);
@Override public String redirectURL() { if (resourcePath != null) { return resourcePath.toString(); } else { return redirectURI.toString(); } }
public synchronized void updateApplication(InternalApplication application) throws IOException { ObjectNode tree = read(); tree.put("name", application.name()); ResourcePath htmlAppPath = application.htmlApplicationResourcePath(); if (htmlAppPath != null) { if (htmlAppPath.head().name().equals(application.id())) { htmlAppPath = htmlAppPath.subPath(); } tree.put("html-app", htmlAppPath.toString()); } tree.put("visible", application.visible()); String versioningResourceId = application.versionResourceId(); if (versioningResourceId != null) { tree.put("version-resource-id", versioningResourceId); } write(tree); }
htmlApp = new ResourcePath((String) value); if (!htmlApp.head().name().equals(this.id)) { htmlApp.prependSegment(this.id);
List<ResourcePath.Segment> thisPath = ctx.resourcePath().segments(); ResourcePath uri = new ResourcePath(member.uri().toString()); List<ResourcePath.Segment> pathSegments = uri.segments(); if (pathSegments.size() != 4 && pathSegments.size() != 3) { throw new IllegalArgumentException("Uri out of scope: " + uri);
protected ResourcePath applicationResourcePath() { ResourcePath path = new ResourcePath(); path.prependSegment(this.parent().id()); return path; }
if (!childState.getPropertyNames().isEmpty() || !childState.members().isEmpty()) { ResourcePath childResourcePath = new ResourcePath(currentResourcePath); childResourcePath.appendSegment(childState.id()); RequestContext reqToAuthorize = new RequestContext.Builder() .resourcePath(childResourcePath)
private List<Interceptor> getInterceptors(String chainName, ResourceRequest request) { List<Interceptor> result = new LinkedList<>(); List<InterceptorConfigEntry> chainConfigEntries = interceptorsConfig.get().getChainConfig(chainName); for (InterceptorConfigEntry configEntry : chainConfigEntries) { String interceptorName = configEntry.getInterceptorName(); Interceptor interceptor = interceptors.get(interceptorName); if (interceptor == null) { log.warnf("No interceptor under key '%s'", interceptorName); continue; } // Verify resourcePath matches if (configEntry.getResourcePathMapping() != null && request != null) { ResourcePath interceptorResPath = new ResourcePath(configEntry.getResourcePathMapping()); if (!interceptorResPath.isParentOf(request.resourcePath())) { continue; } } // Verify requestType matches if (configEntry.getRequestTypeMapping() != null && request != null) { if (!request.requestType().matches(configEntry.getRequestTypeMapping())) { continue; } } result.add(interceptor); } return result; }
List<ResourcePath.Segment> segments = request.resourcePath().segments(); String filename = segments.size() < 1 ? "unknown" : segments.get(segments.size()-1).name(); factory.createAttribute(original, "filename", filename); request.resourcePath().toString(), filename, contentType, "binary", Charset.forName("utf-8"), clen);
public boolean equals(Object obj) { if (obj instanceof ResourcePath == false) { return false; } return segments().equals(((ResourcePath) obj).segments()); }
private String getPrefix(ResourcePath path) { String prefix = "/" + path.head().name(); return prefix; }
@Override public GridFSResourcePath subPath() { return new GridFSResourcePath(super.subPath()); }
@Override public Resource member(RequestContext ctx, String id) throws Exception { if (BATCH_ENDPOINT.equals(id)) { return new PgSqlBatchResource(this, BATCH_ENDPOINT); } String tableId = id; boolean schemaReq = false; ResourcePath.Segment tail = ctx.resourcePath() != null ? ctx.resourcePath().tail() : null; if (tail != null && tail.matrixParameters().containsKey("schema")) { tableId = tail.name(); schemaReq = true; } List<String> tables = catalog().tableIds(); int pos = tables.indexOf(tableId); if (pos == -1) { return null; } else if (schemaReq) { return new PgSqlTableSchemaResource(this, tail.name()); } else { return new PgSqlTableResource(this, tables.get(pos)); } }