예제 #1
0
  public static JSONObject getSessionJSON(HttpServletRequest req) throws Exception {
    HttpSession session = req.getSession();
    JSONObject data = new JSONObject();

    JSONArray vecs = new JSONArray();
    @SuppressWarnings("unchecked")
    Vector<String> destVec = (Vector<String>) session.getAttribute("destVec");
    if (destVec == null) {
      destVec = new Vector<String>();
      session.setAttribute("destVec", destVec);
    }
    for (String vec : destVec) {
      vecs.put(vec);
    }
    data.put("destVec", vecs);

    String zingFolder = "";
    if (destVec != null && destVec.size() > 0) {
      zingFolder = destVec.get(0);
    }
    data.put("zingFolder", zingFolder);

    String zingPat = (String) session.getAttribute("zingpat");
    if (zingPat == null) {
      zingPat = "";
      session.setAttribute("zingpat", zingPat);
    }
    data.put("zingPat", zingPat);

    String filter = (String) session.getAttribute("filter");
    if (filter == null) {
      filter = "";
      session.setAttribute("filter", filter);
    }
    data.put("filter", filter);

    String oldFilter = (String) session.getAttribute("oldFilter");
    if (oldFilter == null) {
      oldFilter = "";
      session.setAttribute("oldFilter", oldFilter);
    }
    data.put("oldFilter", oldFilter);

    String maxFlag = (String) session.getAttribute("maxFlag");
    if (maxFlag == null || maxFlag.length() == 0) {
      maxFlag = "no";
      session.setAttribute("maxFlag", "no");
    }
    boolean useMax = ("yes".equals(maxFlag));
    data.put("useMax", useMax);

    data.put("userName", session.getAttribute("userName"));
    data.put("actionCount", NewsAction.getActionCount());
    return data;
  }
예제 #2
0
  private JSONObject setSessionFromJSON() throws Exception {

    @SuppressWarnings("unchecked")
    Vector<String> destVec = (Vector<String>) session.getAttribute("destVec");
    if (destVec == null) {
      destVec = new Vector<String>();
      session.setAttribute("destVec", destVec);
    }

    String zingFolder = objIn.optString("zingFolder");
    if (zingFolder != null) {
      System.out.println("Got a zingFolder value: " + zingFolder);
      // first remove the folder if it exists later in the vector
      for (int i = 0; i < destVec.size(); i++) {
        if (destVec.elementAt(i).equals(zingFolder)) {
          destVec.remove(i);
          break;
        }
      }
      destVec.add(0, zingFolder);
    }

    String zingPat = objIn.optString("zingPat");
    if (zingPat != null) {
      System.out.println("Got a zingPat value: " + zingPat);
      session.setAttribute("zingpat", zingPat);
    }

    String filter = objIn.optString("filter");
    if (filter != null) {
      session.setAttribute("filter", filter);
    }

    String oldFilter = objIn.optString("oldFilter");
    if (oldFilter != null) {
      session.setAttribute("oldFilter", oldFilter);
    }

    if (objIn.has("maxFlag")) {
      // ask for the boolean only when something exists to check
      if (objIn.getBoolean("maxFlag")) {
        session.setAttribute("maxFlag", "yes");
      } else {
        session.setAttribute("maxFlag", "no");
      }
    }

    return getSessionJSON(req);
  }
예제 #3
0
 public boolean isReadOnly() throws Exception {
   return root.optBoolean("readonly");
 }
예제 #4
0
 public String getRole() throws Exception {
   return root.optString("role");
 }
예제 #5
0
 public long getTimeout() throws Exception {
   return root.optLong("timeout");
 }
예제 #6
0
 public String getCreator() throws Exception {
   return root.optString("creator");
 }
예제 #7
0
 public String getNotes() throws Exception {
   return root.optString("notes");
 }
예제 #8
0
 public String getId() throws Exception {
   return root.getString("id");
 }