@Override public RequestAttributes requestAttributes() { return delegate.requestAttributes(); }
@Override public SecurityContext securityContext() { return delegate.securityContext(); }
@Override public Pagination pagination() { return delegate.pagination(); }
if (ctx.returnFields() != null && !ctx.returnFields().child(LiveOak.MEMBERS).isEmpty()) { ReturnFields membersReturnFields = ctx.returnFields().child(LiveOak.MEMBERS); if (!membersReturnFields.isAll()) { membersReturnFields.forEach((fieldName) -> { ResourceParams resourceParams = ctx.resourceParams(); if (resourceParams != null && resourceParams.contains("hint")) { String hint = resourceParams.value("hint"); members.add(new MongoEmbeddedObjectResource(this, dbCursor.explain())); } else { Sorting sorting = ctx.sorting(); if (sorting != null) { BasicDBObject sortingObject = new BasicDBObject(); Pagination pagination = ctx.pagination(); if (pagination != null) { dbCursor.limit(pagination.limit());
public QueryResults queryTable(String table, String id, RequestContext ctx) throws SQLException, IOException { Catalog cat = parent.catalog(); Table t = cat.tableById(table); try (Connection con = parent.connection()) { String q = ctx.resourceParams().value("q"); if (id == null) { if (q != null) { return queryBuilder.querySelectFromTable(con, t, replaceIdsWithColumnNames(ctx.sorting()), ctx.pagination(), q); } else { return queryBuilder.querySelectFromTable(con, t, replaceIdsWithColumnNames(ctx.sorting()), ctx.pagination()); } } else { return queryBuilder.querySelectFromTableWhereId(con, t, id); } } }
if (childPath.equals(ctx.resourcePath())) { LinkedList<ResourcePath.Segment> segments = new LinkedList(ctx.resourcePath().segments()); if (ctx.requestType() == RequestType.UPDATE) { BasicDBObject fileInfo = new BasicDBObject("filename", name).append("owner", ctx.securityContext().getSubject()); if (last != null) { fileInfo.append("parent", last.getId()); } else if (childPath.segments().size() == ctx.resourcePath().segments().size()) { return null; } else {
ResourceParams resourceParams = ctx.resourceParams(); if (resourceParams != null) { if (resourceParams.contains("q")) { if (ctx.returnFields() != null && !ctx.returnFields().isAll()) { ctx.returnFields().forEach((fieldName) -> { returnFields.put(fieldName, true); }); int count = ctx.pagination().offset() >= totalCount ? 0 : totalCount - ctx.pagination().offset(); count = count < ctx.pagination().limit() ? count : ctx.pagination().limit();
@Override public void readProperties(RequestContext ctx, PropertySink sink) throws Exception { try { RequestContext ctxToAuthorize = ctx.requestAttributes().getAttribute(AuthzConstants.ATTR_REQUEST_CONTEXT, RequestContext.class); ResourceState reqStateToAuthorize = ctx.requestAttributes().getAttribute(AuthzConstants.ATTR_REQUEST_RESOURCE_STATE, ResourceState.class); ResourceState respStateToAuthorize = ctx.requestAttributes().getAttribute(AuthzConstants.ATTR_RESPONSE_RESOURCE_STATE, ResourceState.class); if (ctxToAuthorize == null) { if (log.isTraceEnabled()) { if (ctxToAuthorize.securityContext() != null && ctxToAuthorize.securityContext().getRealm() != null) { String realm = ctxToAuthorize.securityContext().getRealm(); if (realm.equals("liveoak-admin") || realm.equals("master")) { // TODO: Hardcoded realms and 'admin' role is just temporary solution boolean accepted = ctxToAuthorize.securityContext().getRoles().contains("admin"); writeAuthzResponse(sink, accepted); return;
@Override public ResourceParams resourceParams() { return delegate.resourceParams(); }
for (String name: ctx.resourceParams().names()) { if ("offset".equals(name) || "limit".equals(name)) { continue; List<String> values = ctx.resourceParams().values(name); for (String value: values) { uriBuilder.addParam(name, value); int offset = ctx.pagination().offset(); int limit = ctx.pagination().limit();
@Override public ResourcePath resourcePath() { return delegate.resourcePath(); }
@Override public void createMember(RequestContext ctx, ResourceState state, Responder responder) throws Exception { String action = ctx.resourceParams().value("action"); if (action == null || (!action.equals(CREATE) && !action.equals(UPDATE) && !action.equals(MERGE) && !action.equals(DELETE))) { List<ResourcePath.Segment> thisPath = ctx.resourcePath().segments();
List<MockInMemoryResource> members = new ArrayList<>(this.members.values()); Sorting sorting = ctx.sorting(); if (sorting != null) { for (Sorting.Spec spec : sorting.specs()) { Pagination pagination = ctx.pagination(); if (pagination != null) { int offset = pagination.offset();
@Override public void encode() throws Exception { //we should only read the members if they are going to be returned in the response //otherwise it could be an expensive operation when all we are requesting is metadata (ie count) //or if the count > 0 (eg no member should be returned). if (requestContext().returnFields().included(LiveOak.MEMBERS) && requestContext().pagination().limit() > 0) { resource().readMembers(requestContext(), new MyResourceSink()); } else { encodeNext(); } }
@Override public RequestType requestType() { return delegate.requestType(); }
Application app = msg.inReplyTo().requestContext().application(); if (app != null && app instanceof InternalApplication) { ResourcePath htmlAppPath = ((InternalApplication)app).htmlApplicationResourcePath(); .requestAttributes(msg.inReplyTo().requestContext().requestAttributes()).build(); ctx.channel().pipeline().fireChannelRead(htmlAppRequest); return;
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; }
@Override public Sorting sorting() { return delegate.sorting(); }
@Override public void dispose() { delegate.dispose(); }
@Override public Application application() { return delegate.application(); }