private String getPrefix(ResourcePath path) { String prefix = "/" + path.head().name(); return prefix; }
private String getPrefix(ResourcePath path) { if (path.segments().size() < 1) { return null; } String prefix = "/" + path.head().name(); return prefix; }
public Stream<T> objects(ResourcePath path) { if (path.isEmpty()) { return this.objects.stream(); } String name = path.head().name(); ObjectsTree<T> wildcardChild = this.children.get("*"); Stream<T> wildcardSubs = null; if ( wildcardChild != null ) { wildcardSubs = wildcardChild.objects.stream(); } ObjectsTree<T> child = this.children.get(name); Stream<T> childSubs = null; if (child != null) { childSubs = child.objects(path.subPath()); } if ( wildcardSubs != null && childSubs != null ) { return Stream.concat( childSubs, wildcardSubs ); } if ( wildcardSubs != null ) { return wildcardSubs; } if ( childSubs != null ) { return childSubs; } List<T> empty = Collections.emptyList(); return empty.stream(); }
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 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); }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof ByteBuf) { bytesRead += ((ByteBuf) msg).readableBytes(); startTime = startTime != 0 ? startTime : System.currentTimeMillis(); } else if (msg instanceof DefaultHttpRequest) { DefaultHttpRequest req = (DefaultHttpRequest) msg; event = new AnalyticsEvent(); startTime = startTime != 0 ? startTime : System.currentTimeMillis(); event.setTimestamp(startTime); event.setMethod(req.getMethod().name()); event.setUri(req.getUri()); event.clientAddress(ctx.channel().remoteAddress()); //event.uri(req.resourcePath().toString()); } else if (msg instanceof ResourceRequest) { ResourceRequest req = (ResourceRequest) msg; event.setApplication(req.resourcePath().head().toString()); event.setUserId(req.requestContext().securityContext().getSubject()); event.setApiRequest(true); } super.channelRead(ctx, msg); }
if (!htmlApp.head().name().equals(this.id)) { htmlApp.prependSegment(this.id);