Ejemplo n.º 1
0
  @Override
  public String toString() {
    StringBuffer buff = new StringBuffer();
    buff.append("\nCate ID: " + _id).append("\tCate Name: " + _name);
    for (AccessRule rule : _rulesList) {
      buff.append("\nRule auth type: " + rule.getAccessType())
          .append("\nRule recur type: " + rule.getRecurrence().getName())
          .append("\tRecur value: " + rule.getRecurrence().getRecurValue());

      for (TimeRange tr : rule.getTimeRangeList()) {
        buff.append("\nStart Time: " + tr.getStartTime().toString())
            .append("\tEnd Time: " + tr.getEndTime().toString());
      }
    }

    for (ClientAppInfo appInfo : _managedAppsMap.keySet()) {
      buff.append("\nManaged App: " + appInfo.getAppName())
          .append(", " + appInfo.getAppPkgname())
          .append(", " + appInfo.getAppClassname());
    }

    return buff.toString();
  }
Ejemplo n.º 2
0
  public JSONObject toJsonObject() throws JSONException {
    JSONArray jsonRulesAry = new JSONArray();
    if (_rulesList != null) {
      for (int k = 0; k < _rulesList.size(); k++) {
        AccessRule aRule = _rulesList.get(k);

        JSONObject jsonRuleObj = new JSONObject();
        jsonRuleObj.put(TAGNAME_RULE_AUTH_TYPE, aRule.getAccessType());
        jsonRuleObj.put(TAGNAME_RULE_REPEAT_TYPE, aRule.getRecurType());
        jsonRuleObj.put(TAGNAME_RULE_REPEAT_VALUE, aRule.getRecurrence().getRecurValue());

        JSONArray jsonTrsAry = new JSONArray();
        List<TimeRange> trsList = aRule.getTimeRangeList();
        for (TimeRange tr : trsList) {
          JSONObject jsonTrObj = new JSONObject();
          jsonTrObj.put(TAGNAME_RULE_REPEAT_STARTTIME, tr.getStartTime().toString());
          jsonTrObj.put(TAGNAME_RULE_REPEAT_ENDTIME, tr.getEndTime().toString());

          jsonTrsAry.put(jsonTrObj);
        }

        jsonRuleObj.put(TAGNAME_ACCESS_TIMERANGES, jsonTrsAry);
        jsonRulesAry.put(jsonRuleObj);
      }
    }

    JSONObject result = new JSONObject();

    result.put(TAGNAME_ACCESS_CATE_ID, _id);
    result.put(TAGNAME_ACCESS_CATE_NAME, _name);

    String managedAppTypesStr = "";
    if (managedAppTypesIdSet != null && managedAppTypesIdSet.size() > 0) {
      for (Integer appTypeId : managedAppTypesIdSet) {
        managedAppTypesStr += DataManager.getInstance().getAppTypeName(appTypeId);
      }
    }
    result.put(TAGNAME_APPLICATION_TYPES, managedAppTypesStr);

    result.put(TAGNAME_ACCESS_RULES, jsonRulesAry);

    return result;
  }