Package com.erudika.para.core

Examples of com.erudika.para.core.App


            (d.getTime() + (Config.REQUEST_EXPIRES_AFTER_SEC * 1000)));

        if (!StringUtils.isBlank(appid)) {
          if (!StringUtils.isBlank(date)) {
            if (!requestExpired) {
              App app = new App();
              app.setId(appid);
              app = app.getDao().read(appid);

              if (app != null) {
                if (signer.isValidSignature(request, app.getSecret())) {
                  SecurityContextHolder.getContext().setAuthentication(new AppAuthentication(app));
                } else {
                  RestUtils.returnStatusResponse(response, HttpServletResponse.SC_FORBIDDEN,
                      "Request signature is invalid.");
                  return;
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);
        App app = RestUtils.getPrincipalApp();
        if (app != null) {
          if (!StringUtils.isBlank(typePlural)) {
            String type = RestUtils.getAllTypes(app).get(typePlural);
            if (type == null) {
              type = typePlural;
View Full Code Here

        MultivaluedMap<String, String> pathp = ctx.getUriInfo().getPathParameters();
        String id = pathp.getFirst(Config._ID);
        String type = pathp.getFirst(Config._TYPE);
        String id2 = pathp.getFirst("id2");
        String type2 = pathp.getFirst("type2");
        App app = RestUtils.getPrincipalApp();

        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) {
        App app = RestUtils.getPrincipalApp();
        if (app != null) {
          return Response.ok(RestUtils.getAllTypes(app)).build();
        }
        return RestUtils.getStatusResponse(Response.Status.NOT_FOUND, "App not found.");
      }
View Full Code Here

  }

  private Inflector<ContainerRequestContext, Response> keysHandler() {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        App app = RestUtils.getPrincipalApp();
        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.");
      }
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) {
        App app = RestUtils.getPrincipalApp();
        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) {
        App app = RestUtils.getPrincipalApp();
        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) {
        App app = RestUtils.getPrincipalApp();
        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) {
        App app = RestUtils.getPrincipalApp();
        return RestUtils.getBatchDeleteResponse(app, ctx.getUriInfo().getQueryParameters().get("ids"));
      }
    };
  }
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.