Example #1
0
 public static Record RecordNameServices(Spec spec, String uiname) {
   try {
     Record test = spec.getRecordByWebUrl(uiname);
     return test;
   } catch (Exception e) {
     return null;
   }
 }
Example #2
0
 public static String ResourceNameServices(Spec spec, String uiname) {
   try {
     Record test = spec.getRecordByWebUrl(uiname);
     return test.getAuthorizationType();
   } catch (Exception e) {
     return uiname;
   }
 }
Example #3
0
 /**
  * CSPACE-2894 make permission names match the UI names when the app sends the data to the UI
  *
  * @param spec
  * @param servicename
  * @return
  */
 public static String ResourceNameUI(Spec spec, String servicename) {
   try {
     Record test = null;
     // can we do a simple match
     if (spec.hasRecord(servicename)) {
       test = spec.getRecord(servicename);
     } else if (spec.hasRecordByServicesUrl(servicename)) {
       test = spec.getRecordByServicesUrl(servicename);
     } else {
       // else loop thr the records and see if we can do an auth match
       for (Record r : spec.getAllRecords()) {
         if (r.isAuthorizationType(servicename)) {
           test = r;
         }
       }
     }
     return test.getWebURL();
   } catch (Exception e) {
     return servicename;
   }
 }
Example #4
0
  private void termlist(CSPRequestCache cache, Storage storage, UIRequest request, String path)
      throws UIException {
    try {
      // {tenant}/{tenantname}/{recordType}/termList/{termListType}
      // needs to be {tenant}/{tenantname}/{recordType}/termList/{fieldname}
      // as blanks etc are on a field basis not a vocab basis
      String[] bits = path.split("/");
      Record vb = this.spec.getRecord("vocab");
      Field f = (Field) r.getFieldTopLevel(bits[0]);
      if (f == null) {
        f = (Field) r.getFieldFullList(bits[0]);
      }
      // If the field isn't in this record, look for it in subrecords (e.g. contacts).
      if (f == null) {
        FieldSet[] subRecordFields = r.getAllSubRecords("GET");

        for (int i = 0; i < subRecordFields.length; i++) {
          FieldSet subRecordField = subRecordFields[i];
          Group group = (Group) subRecordField;

          if (group.usesRecord()) {
            Record subRecord = group.usesRecordId();
            f = (Field) subRecord.getFieldTopLevel(bits[0]);

            if (f == null) {
              f = (Field) subRecord.getFieldFullList(bits[0]);
            }

            if (f != null) {
              break;
            }
          }
        }
      }
      JSONArray result = new JSONArray();
      for (Instance ins : f.getAllAutocompleteInstances()) {
        JSONArray getallnames = ctl.get(storage, ins.getTitleRef(), vb);
        for (int i = 0; i < getallnames.length(); i++) {
          result.put(getallnames.get(i));
        }
      }
      JSONObject out = generateENUMField(storage, f, result, false);
      request.sendJSONResponse(out);
      int cacheMaxAgeSeconds = spec.getAdminData().getTermListCacheAge();
      if (cacheMaxAgeSeconds > 0) {
        request.setCacheMaxAgeSeconds(cacheMaxAgeSeconds);
      }
    } catch (JSONException e) {
      throw new UIException("JSONException during autocompletion", e);
    }
  }
Example #5
0
 public static String getPermissionView(Spec spec, String servicename) {
   try {
     Record test = null;
     // can we do a simple match
     if (spec.hasRecordByServicesUrl(servicename)) {
       test = spec.getRecordByServicesUrl(servicename);
     } else {
       // else loop thr the records and see if we can do an auth match
       for (Record r : spec.getAllRecords()) {
         if (r.isAuthorizationType(servicename)) {
           test = r;
         }
       }
     }
     if (test.getAuthorizationView()) {
       return "show";
     }
     return "none";
   } catch (Exception e) {
     // do not display as we don't know what this is
     return "none";
   }
 }
 public void configure(WebUI ui, Spec spec) {
   for (Record r : spec.getAllRecords()) {
     type_to_url.put(r.getID(), r.getWebURL());
   }
 }