Package com.erudika.para.core

Examples of com.erudika.para.core.App


          }
        }

        Para.getDAO().createAll(appid, objects);

        App app = getApp(appid);
        Utils.asyncExecute(new Runnable() {
          public void run() {
            registerNewTypes(app, objects.toArray(new ParaObject[objects.size()]));
          }
        });
View Full Code Here


              "'X-Amz-Date' header/parameter is not set!");
        } else {
          if (requestExpired) {
            RestUtils.returnStatusResponse(response, HttpServletResponse.SC_BAD_REQUEST, "Request has expired.");
          } else if (!StringUtils.isBlank(id)) {
            App app = new App();
            app.setId(id);
            app = app.getDao().read(id);

            if (app != null) {
              if (signer.isValidSignature(request, app.getSecret())) {
                SecurityContextHolder.getContext().setAuthentication(new AppAuthentication(app));
              } else {
                RestUtils.returnStatusResponse(response, HttpServletResponse.SC_FORBIDDEN,
                    "Signature is invalid.");
              }
View Full Code Here

  private Inflector<ContainerRequestContext, Response> typeCrudHandler() {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        String typePlural = ctx.getUriInfo().getPathParameters().getFirst(Config._TYPE);
        String appid = RestUtils.getPrincipalAppid(ctx.getSecurityContext().getUserPrincipal());
        App app = RestUtils.getApp(appid);
        if (app != null && !StringUtils.isBlank(typePlural)) {
          String type = RestUtils.getCoreTypes().get(typePlural);
          if (type == null) {
            type = app.getDatatypes().get(typePlural);
          }
          if (type == null) {
            type = typePlural;
          }
          return crudHandler(app, type).apply(ctx);
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) {
          Map<String, String> allTypes = new HashMap<String, String>(app.getDatatypes());
          allTypes.putAll(RestUtils.getCoreTypes());
          return Response.ok(allTypes).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> typeCrudHandler() {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        String typePlural = ctx.getUriInfo().getPathParameters().getFirst(Config._TYPE);
        String appid = RestUtils.getPrincipalAppid(ctx.getSecurityContext().getUserPrincipal());
        App app = RestUtils.getApp(appid);
        if (app != null && !StringUtils.isBlank(typePlural)) {
          String type = RestUtils.getAllTypes(app).get(typePlural);
          if (type == null) {
            type = typePlural;
          }
View Full Code Here

        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

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.