Package com.erudika.para.core

Examples of com.erudika.para.core.App


  private Inflector<ContainerRequestContext, Response> readTypesHandler() {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        String appid = RestUtils.getPrincipalAppid(ctx.getSecurityContext().getUserPrincipal());
        App app = dao.read(new App(appid).getId());
        if (app != null) {
          allTypes.addAll(app.getDatatypes());
        }
        return Response.ok(allTypes).build();
      }
    };
  }
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 = dao.read(new App(appid).getId());
        if (app != null) {
          app.resetSecret();
          app.update();
          return Response.ok(app.credentialsMap()).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();
          return Response.ok(app.credentialsMap()).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

              "'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.readApp(app);

            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

    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        String id = ctx.getUriInfo().getPathParameters().getFirst(Config._ID);
        String type = ctx.getUriInfo().getPathParameters().getFirst(Config._TYPE);
        String appid = Config.APP_NAME_NS; // TODO
        App app = dao.read(new App(appid).getId());
        if (app != null && !StringUtils.isBlank(type)) {
          if (app.getDatatypes().contains(type)) {
            if (StringUtils.isBlank(id)) {
              if (GET.equals(ctx.getMethod())) {
                return searchHandler(type).apply(ctx);
              } else if (POST.equals(ctx.getMethod())) {
                return createHandler(type).apply(ctx);
View Full Code Here

  private Inflector<ContainerRequestContext, Response> addRemoveTypesHandler() {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        String appid = Config.APP_NAME_NS; // TODO
        App app = dao.read(new App(appid).getId());
        Map<String, Object> tmap = RestUtils.getMapFromEntity(ctx.getEntityStream());
        if (app != null && tmap != null) {
          String datatype = (String) tmap.get("type");
          if (StringUtils.isBlank(datatype)) {
            if (POST.equals(ctx.getMethod())) {
              app.addDatatypes(datatype);
            } else if (DELETE.equals(ctx.getMethod())) {
              app.removeDatatypes(datatype);
            }
            return Response.ok(app.getDatatypes()).build();
          } else {
            return RestUtils.getStatusResponse(Response.Status.BAD_REQUEST, "'type' cannot be empty.");
          }
        } else {
          return RestUtils.getStatusResponse(Response.Status.BAD_REQUEST);
View Full Code Here

  private Inflector<ContainerRequestContext, Response> readTypesHandler() {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        String appid = Config.APP_NAME_NS; // TODO
        App app = dao.read(new App(appid).getId());
        if (app != null) {
          allTypes.addAll(app.getDatatypes());
        }
        return Response.ok(allTypes).build();
      }
    };
  }
View Full Code Here

  private Inflector<ContainerRequestContext, Response> keysHandler() {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        String appid = Config.APP_NAME_NS; // TODO
        App app = dao.read(new App(appid).getId());
        if (app != null) {
          app.resetSecret();
          app.update();
          return Response.ok(app.credentialsMap()).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);
        if (app.exists()) {
          return RestUtils.getStatusResponse(Response.Status.OK, "All set!");
        } else {
          app.setName(Config.APP_NAME);
          app.create();
          return Response.ok(app.credentialsMap()).build();
        }
      }
    };
  }
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.