Package com.erudika.para.core

Examples of com.erudika.para.core.App


  }

  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

          (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

    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

  private Inflector<ContainerRequestContext, Response> listTypesHandler() {
    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) {
          Map<String, String> allTypes = new HashMap<String, String>(app.getDatatypes());
          allTypes.putAll(coreTypes);
          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 = 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

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.