コード例 #1
0
  @Override
  public Set<FormField> toFormFields(String name) {
    Set<FormField> set = new HashSet<FormField>();
    if (mOptions == null) return set;

    FormField f1 = new FormField(name);
    f1.setLabel(mLabel);
    f1.setDescription(mDescription);
    f1.setRequired(mRequired);
    if (mIsHidden) {
      f1.setType(FormField.TYPE_HIDDEN);
    } else {
      f1.setType(FormField.TYPE_LIST_SINGLE);
    }

    for (int i = 0; i < mOptions.size(); i++) {
      String label = mOptions.get(i).getLabel();
      ArrayList<String> options = mOptions.get(i).getValues();
      if ((options != null) && (options.size() > 0)) {
        String option = options.get(0);
        f1.addOption(new Option(label, option));
      }
    }
    if (mValues.size() > 0) {
      f1.addValue(getValueAsString(0));
    }
    set.add(f1);
    FormField f2 =
        new FormField(name + Specialization.SPECIALIZECHARACTER + Specialization.KEY_TYPE);
    f2.setType(FormField.TYPE_HIDDEN);
    f2.addValue(Parameter.TYPENAME_OPTION);
    set.add(f2);

    FormField f3 =
        new FormField(name + Specialization.SPECIALIZECHARACTER + Specialization.KEY_SUBTYPE);
    f3.setType(FormField.TYPE_HIDDEN);
    f3.addValue(mSubType);
    set.add(f3);

    if (mSubmitActionHint) {
      FormField f4 =
          new FormField(
              name + Specialization.SPECIALIZECHARACTER + Specialization.KEY_SUBMITACTIONHINT);
      f4.setType(FormField.TYPE_HIDDEN);
      f4.addValue(String.valueOf(mSubmitActionHint));
      set.add(f4);
    }

    return set;
  }
コード例 #2
0
  public void addFields(final DataForm serviceExtension) {
    for (PermissionType type : PermissionType.values()) {
      FormField field = new FormField(type.getSpecName());
      field.setLabel(type.getLabel());

      switch (type) {
        case readFile:
          field.setType(FormField.TYPE_LIST_MULTI);
          if (null != readPermissions) {
            addPermittedPaths(field, readPermissions);
          }
          break;
        case writeFile:
          field.setType(FormField.TYPE_LIST_MULTI);
          if (null != writePermissions) {
            addPermittedPaths(field, writePermissions);
          }
          break;
        case deleteFile:
          field.setType(FormField.TYPE_LIST_MULTI);
          if (null != deletePermissions) {
            addPermittedPaths(field, deletePermissions);
          }
          break;
        case executeProgram:
          field.setType(FormField.TYPE_LIST_MULTI);
          if (null != execPermissions) {
            addPermittedPaths(field, execPermissions);
          }
          break;
        case createFileLink:
          field.setType(FormField.TYPE_LIST_MULTI);
          if (null != linkPermissions) {
            addPermittedPaths(field, linkPermissions);
          }
          break;
        default:
          // Other types have no special formatting.
          field.setType(FormField.TYPE_BOOLEAN);
          field.addValue(permittedTypes.contains(type) ? "true" : "false");
      }

      serviceExtension.addField(field);
    }
  }
コード例 #3
0
 private void addPermittedPaths(final FormField field, final PathPermissions p) {
   for (String path : p.getPositiveRules()) {
     field.addValue(path);
   }
 }