@DefaultHandler
  public Resolution view() throws JSONException, IOException {
    application = findApplication(name, version);

    if (application == null) {
      getContext()
          .getValidationErrors()
          .addGlobalError(
              new LocalizableError("app.notfound", name + (version != null ? " v" + version : "")));
      return new ForwardResolution("/WEB-INF/jsp/error.jsp");
    }

    RedirectResolution login =
        new RedirectResolution(LoginActionBean.class)
            .addParameter("name", name) // binded parameters not included ?
            .addParameter("version", version)
            .addParameter("debug", debug)
            .includeRequestParameters(true);

    loginUrl = login.getUrl(context.getLocale());

    String username = context.getRequest().getRemoteUser();
    if (application.isAuthenticatedRequired() && username == null) {
      return login;
    }

    if (username != null) {
      user = new JSONObject();
      user.put("name", username);
      JSONObject roles = new JSONObject();
      user.put("roles", roles);
      for (String role : Authorizations.getRoles(context.getRequest())) {
        roles.put(role, Boolean.TRUE);
      }
    }

    buildComponentSourceHTML();

    appConfigJSON = application.toJSON(context.getRequest(), false, false);
    this.viewerType = retrieveViewerType();

    // make hashmap for jsonobject.
    this.globalLayout = new HashMap<String, Object>();
    JSONObject layout = application.getGlobalLayout();
    Iterator<String> keys = layout.keys();
    while (keys.hasNext()) {
      String key = keys.next();
      this.globalLayout.put(key, layout.get(key));
    }
    return new ForwardResolution("/WEB-INF/jsp/app.jsp");
  }
示例#2
0
  @Override
  public void deleteInBatch(final Iterable<M> entities) {
    Iterator<M> iter = entities.iterator();
    if (entities == null || !iter.hasNext()) {
      return;
    }

    Set models = Sets.newHashSet(iter);

    boolean logicDeleteableEntity = LogicDeleteable.class.isAssignableFrom(this.entityClass);

    if (logicDeleteableEntity) {
      String ql = String.format(LOGIC_DELETE_ALL_QUERY_STRING, entityName);
      repositoryHelper.batchUpdate(ql, models);
    } else {
      String ql = String.format(DELETE_ALL_QUERY_STRING, entityName);
      repositoryHelper.batchUpdate(ql, models);
    }
  }