Package com.erudika.para.core

Examples of com.erudika.para.core.App


        String id = pathp.getFirst(Config._ID);
        String type = pathp.getFirst(Config._TYPE);
        String id2 = pathp.getFirst("id2");
        String type2 = pathp.getFirst("type2");
        String appid = RestUtils.getPrincipalAppid(ctx.getSecurityContext().getUserPrincipal());
        App app = RestUtils.getApp(appid);

        String typeSingular = (type == null) ? null : RestUtils.getAllTypes(app).get(type);
        type = (typeSingular == null) ? type : typeSingular;

        id2 = StringUtils.isBlank(id2) ? params.getFirst(Config._ID) : id2;
        type2 = StringUtils.isBlank(type2) ? params.getFirst(Config._TYPE) : type2;

        ParaObject pobj = Utils.toObject(type);
        pobj.setId(id);
        pobj = dao.read(app.getAppIdentifier(), pobj.getId());

        Pager pager = new Pager();
        pager.setPage(NumberUtils.toLong(params.getFirst("page"), 0));
        pager.setSortby(params.getFirst("sort"));
        pager.setDesc(Boolean.parseBoolean(params.containsKey("desc") ? params.getFirst("desc") : "true"));
View Full Code Here


  private Inflector<ContainerRequestContext, Response> listTypesHandler() {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        String appid = RestUtils.getPrincipalAppid(ctx.getSecurityContext().getUserPrincipal());
        App app = RestUtils.getApp(appid);
        if (app != null) {
          return Response.ok(RestUtils.getAllTypes(app)).build();
        }
        return RestUtils.getStatusResponse(Response.Status.NOT_FOUND, "App not found: " + appid);
      }
View Full Code Here

  private Inflector<ContainerRequestContext, Response> keysHandler() {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        String appid = RestUtils.getPrincipalAppid(ctx.getSecurityContext().getUserPrincipal());
        App app = RestUtils.getApp(appid);
        if (app != null) {
          app.resetSecret();
          app.update();
          Map<String, String> creds = app.getCredentials();
          creds.put("info", "Save the secret key! It is showed only once!");
          return Response.ok(creds).build();
        }
        return RestUtils.getStatusResponse(Response.Status.NOT_FOUND, "App not found: " + appid);
      }
View Full Code Here

  }

  private Inflector<ContainerRequestContext, Response> setupHandler() {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        App app = new App(Config.APP_NAME_NS); // the root app name
        if (app.exists()) {
          return RestUtils.getStatusResponse(Response.Status.OK, "All set!");
        } else {
          app.setName(Config.APP_NAME);
          app.create();
          Map<String, String> creds = app.getCredentials();
          creds.put("info", "Save the secret key! It is showed only once!");
          return Response.ok(creds).build();
        }
      }
    };
View Full Code Here

  private Inflector<ContainerRequestContext, Response> batchCreateHandler() {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        String appid = RestUtils.getPrincipalAppid(ctx.getSecurityContext().getUserPrincipal());
        App app = RestUtils.getApp(appid);
        return RestUtils.getBatchCreateResponse(app, ctx.getEntityStream());
      }
    };
  }
View Full Code Here

  private Inflector<ContainerRequestContext, Response> batchReadHandler() {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        String appid = RestUtils.getPrincipalAppid(ctx.getSecurityContext().getUserPrincipal());
        App app = RestUtils.getApp(appid);
        return RestUtils.getBatchReadResponse(app, ctx.getUriInfo().getQueryParameters().get("ids"));
      }
    };
  }
View Full Code Here

  private Inflector<ContainerRequestContext, Response> batchUpdateHandler() {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        String appid = RestUtils.getPrincipalAppid(ctx.getSecurityContext().getUserPrincipal());
        App app = RestUtils.getApp(appid);
        return RestUtils.getBatchUpdateResponse(app, ctx.getEntityStream());
      }
    };
  }
View Full Code Here

  private Inflector<ContainerRequestContext, Response> batchDeleteHandler() {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        String appid = RestUtils.getPrincipalAppid(ctx.getSecurityContext().getUserPrincipal());
        App app = RestUtils.getApp(appid);
        return RestUtils.getBatchDeleteResponse(app, ctx.getUriInfo().getQueryParameters().get("ids"));
      }
    };
  }
View Full Code Here

  private Inflector<ContainerRequestContext, Response> searchHandler(final String type) {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        String appid = RestUtils.getPrincipalAppid(ctx.getSecurityContext().getUserPrincipal());
        App app = RestUtils.getApp(appid);
        MultivaluedMap<String, String> params = ctx.getUriInfo().getQueryParameters();
        String queryType = ctx.getUriInfo().getPathParameters().getFirst("querytype");
        return Response.ok(buildQueryAndSearch(app, queryType, params, type)).build();
      }
    };
View Full Code Here

    if (!StringUtils.isBlank(appid) && auth != null) {
      Object principal = auth.getPrincipal();
      if (principal != null && principal instanceof App) {
        return (App) principal;
      } else {
        return Para.getDAO().read(Config.APP_NAME_NS, new App(appid).getId());
      }
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of com.erudika.para.core.App

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.