protected JSONObject getJsonComplexTrigger(
     ScheduleType scheduleType,
     MonthOfYear month,
     WeekOfMonth weekOfMonth,
     List<DayOfWeek> daysOfWeek,
     Date startDate,
     Date endDate) {
   JSONObject trigger = new JSONObject();
   trigger.put(
       "uiPassParam",
       new JSONString(scheduleEditorWizardPanel.getScheduleType().name())); // $NON-NLS-1$
   if (month != null) {
     JSONArray jsonArray = new JSONArray();
     jsonArray.set(0, new JSONString(Integer.toString(month.ordinal())));
     trigger.put("monthsOfYear", jsonArray); // $NON-NLS-1$
   }
   if (weekOfMonth != null) {
     JSONArray jsonArray = new JSONArray();
     jsonArray.set(0, new JSONString(Integer.toString(weekOfMonth.ordinal())));
     trigger.put("weeksOfMonth", jsonArray); // $NON-NLS-1$
   }
   if (daysOfWeek != null) {
     JSONArray jsonArray = new JSONArray();
     int index = 0;
     for (DayOfWeek dayOfWeek : daysOfWeek) {
       jsonArray.set(index++, new JSONString(Integer.toString(dayOfWeek.ordinal())));
     }
     trigger.put("daysOfWeek", jsonArray); // $NON-NLS-1$
   }
   addJsonStartEnd(trigger, startDate, endDate);
   return trigger;
 }
Пример #2
0
  private void saveSecuritySettings(final AsyncCallback<Boolean> callback) {
    JSONObject jsNewRoleAssignments = new JSONObject();
    JSONArray jsLogicalRoleAssignments = new JSONArray();
    int x = 0;
    for (Map.Entry<String, List<String>> roleAssignment : newRoleAssignments.entrySet()) {
      JSONArray jsLogicalRoles = new JSONArray();
      int y = 0;
      for (String logicalRoleName : roleAssignment.getValue()) {
        jsLogicalRoles.set(y++, new JSONString(logicalRoleName));
      }
      JSONObject jsRoleAssignment = new JSONObject();
      jsRoleAssignment.put("roleName", new JSONString(roleAssignment.getKey()));
      jsRoleAssignment.put("logicalRoles", jsLogicalRoles);
      jsLogicalRoleAssignments.set(x++, jsRoleAssignment);
    }
    jsNewRoleAssignments.put("logicalRoleAssignments", jsLogicalRoleAssignments);
    RequestBuilder saveSettingRequestBuilder =
        new RequestBuilder(RequestBuilder.PUT, contextURL + "api/userrole/roleAssignments");
    saveSettingRequestBuilder.setHeader(
        "Content-Type", "application/json"); // $NON-NLS-1$//$NON-NLS-2$
    WaitPopup.getInstance().setVisible(true);
    try {
      saveSettingRequestBuilder.sendRequest(
          jsNewRoleAssignments.toString(),
          new RequestCallback() {

            @Override
            public void onError(Request request, Throwable exception) {
              WaitPopup.getInstance().setVisible(false);
              callback.onFailure(exception);
            }

            @Override
            public void onResponseReceived(Request request, Response response) {
              WaitPopup.getInstance().setVisible(false);
              if (response.getStatusCode() == 200) {
                masterRoleMap.putAll(newRoleAssignments);
                newRoleAssignments.clear();
                callback.onSuccess(true);
              } else {
                callback.onSuccess(false);
              }
            }
          });
    } catch (RequestException e) {
      WaitPopup.getInstance().setVisible(false);
      callback.onFailure(e);
    }
  }
Пример #3
0
 private static JSONArray intArrayToJSONArray(int[] values) {
   JSONArray vals = new JSONArray();
   for (int i = 0, len = values.length; i < len; i++) {
     vals.set(i, new JSONNumber(values[i]));
   }
   return vals;
 }
Пример #4
0
  /** Show publish dialog. */
  public void publish(String msg) {
    JSONObject data = new JSONObject();
    data.put("method", new JSONString("stream.publish"));
    data.put("message", new JSONString(msg));

    JSONObject attachment = new JSONObject();
    attachment.put("name", new JSONString("Mancala"));
    attachment.put("caption", new JSONString("The Board Game"));
    attachment.put("description", new JSONString(msg));
    attachment.put("href", new JSONString("http://10.mymancala.appspot.com"));
    data.put("attachment", attachment);

    JSONObject actionLink = new JSONObject();
    actionLink.put("text", new JSONString("Mancala"));
    actionLink.put("href", new JSONString("http://10.mymancala.appspot.com"));

    JSONArray actionLinks = new JSONArray();
    actionLinks.set(0, actionLink);
    data.put("action_links", actionLinks);

    data.put("user_message_prompt", new JSONString("Share your thoughts about Mancala"));

    /*
     * Execute facebook method
     */
    fbCore.ui(data.getJavaScriptObject(), new Callback());
  }
Пример #5
0
  @Override
  public JSONObject toJSONObject() {
    JSONObject object = super.toJSONObject();

    ImageDataFilterChain chain = m_filters;

    if ((null != chain) && (chain.size() > 0)) {
      JSONArray filters = new JSONArray();

      JSONObject filter = new JSONObject();

      filter.put("active", JSONBoolean.getInstance(chain.isActive()));

      for (ImageDataFilter<?> ifilter : chain.getFilters()) {
        if (null != ifilter) {
          JSONObject make = ifilter.toJSONObject();

          if (null != make) {
            filters.set(filters.size(), make);
          }
        }
      }
      filter.put("filters", filters);

      object.put("filter", filter);
    }
    return object;
  }
 private void call(final JSONValue... params) {
   final JSONArray aryParams = new JSONArray();
   for (final JSONValue p : params) {
     aryParams.set(aryParams.size(), p);
   }
   nativeCall(aryParams.getJavaScriptObject());
 }
Пример #7
0
  private static JSONValue toJSON(SerValue serValue) {
    if (serValue.isString()) {
      return new JSONString(serValue.asString());

    } else if (serValue.isReal()) {
      return new JSONNumber(serValue.asReal());

    } else if (serValue.isArray()) {
      SerArray serArray = serValue.asArray();
      JSONArray jsonArray = new JSONArray();
      for (int i = 0; i != serArray.size(); ++i) {
        jsonArray.set(i, toJSON(serArray.get(i)));
      }
      return jsonArray;

    } else if (serValue.isObject()) {
      SerObject serObject = serValue.asObject();
      JSONObject jsonObject = new JSONObject();
      for (String key : serObject.keySet()) {
        jsonObject.put(key, toJSON(serObject.get(key)));
      }
      return jsonObject;

    } else {
      throw new IllegalArgumentException();
    }
  }
  public static <Type> JSONValue toJSON(
      Map<String, Type> value, AbstractJsonEncoderDecoder<Type> encoder, Style style) {
    if (value == null) {
      return JSONNull.getInstance();
    }

    switch (style) {
      case DEFAULT:
      case SIMPLE:
        {
          JSONObject rc = new JSONObject();
          for (Entry<String, Type> t : value.entrySet()) {
            rc.put(t.getKey(), encoder.encode(t.getValue()));
          }
          return rc;
        }
      case JETTISON_NATURAL:
        {
          JSONObject rc = new JSONObject();
          JSONArray entries = new JSONArray();
          int i = 0;
          for (Entry<String, Type> t : value.entrySet()) {
            JSONObject entry = new JSONObject();
            entry.put("key", new JSONString(t.getKey()));
            entry.put("value", encoder.encode(t.getValue()));
            entries.set(i++, entry);
          }
          rc.put("entry", entries);
          return rc;
        }
      default:
        throw new UnsupportedOperationException(
            "The encoding style is not yet suppored: " + style.name());
    }
  }
Пример #9
0
  /** Render publish */
  public void streamPublish() {

    JSONObject streamPublish = new JSONObject();
    streamPublish.put("method", new JSONString("stream.publish"));
    streamPublish.put(
        "message", new JSONString("Getting education about Facebook Connect and GwtFB"));

    JSONObject attachment = new JSONObject();
    attachment.put("name", new JSONString("GwtFB"));
    attachment.put("caption", new JSONString("The Facebook Connect Javascript SDK and GWT"));
    attachment.put(
        "description",
        new JSONString(
            "A small GWT library that allows you to interact with Facebook Javascript SDK in GWT "));
    attachment.put("href", new JSONString("http://www.gwtfb.com"));
    streamPublish.put("attachment", attachment);

    JSONObject actionLink = new JSONObject();
    actionLink.put("text", new JSONString("Code"));
    actionLink.put("href", new JSONString("http://www.gwtfb.com"));

    JSONArray actionLinks = new JSONArray();
    actionLinks.set(0, actionLink);
    streamPublish.put("action_links", actionLinks);

    streamPublish.put(
        "user_message_prompt", new JSONString("Share your thoughts about Connect and GWT"));

    fbCore.ui(streamPublish.getJavaScriptObject(), new Callback());
  }
Пример #10
0
 private JSONArray toArray(Iterable<? extends QueryElement> elements) {
   JSONArray a = new JSONArray();
   int i = 0;
   for (QueryElement element : elements) {
     a.set(i++, element.accept(this));
   }
   return a;
 }
Пример #11
0
  public JSONObject getJSON() {
    JSONObject commandObj = new JSONObject();
    JSONString type = new JSONString(this.getClass().getName());
    JSONString componentID = new JSONString(getComponentID());
    JSONString componentDescription = new JSONString(getComponentDescription());
    JSONString fileName = new JSONString(getFileName());
    JSONNumber xcoor = new JSONNumber(getLeft());
    JSONNumber ycoor = new JSONNumber(getTop());

    commandObj.put("type", type);
    commandObj.put("componentID", componentID);
    commandObj.put("componentDescription", componentDescription);
    commandObj.put("fileName", fileName);
    commandObj.put("xcoor", xcoor);
    commandObj.put("ycoor", ycoor);

    HashMap<String, Port> ports2 = getPorts();
    Collection<Port> values = ports2.values();

    JSONArray ports = new JSONArray();

    for (Port port : values) {
      JSONObject portobj = new JSONObject();
      JSONString porttype = new JSONString(port.getClass().getName());
      JSONArray dataSet = new JSONArray();
      for (DataDefinitionEntry dataDefinitionEntry : port.getDataSet()) {
        JSONObject entry = new JSONObject();
        JSONNumber order = new JSONNumber(dataDefinitionEntry.getOrder());
        JSONString fieldName = new JSONString(dataDefinitionEntry.getFieldName());
        JSONString fieldType = new JSONString(dataDefinitionEntry.getFieldType());
        entry.put("order", order);
        entry.put("fieldName", fieldName);
        entry.put("fieldType", fieldType);
        dataSet.set(dataSet.size(), entry);
      }
      portobj.put("porttype", porttype);
      portobj.put("dataSet", dataSet);
      ports.set(ports.size(), portobj);
    }
    commandObj.put("ports", ports);

    return commandObj;
  }
  protected JSONObject getJsonComplexTrigger(
      ScheduleType scheduleType, MonthOfYear month, int dayOfMonth, Date startDate, Date endDate) {
    JSONObject trigger = new JSONObject();
    trigger.put(
        "uiPassParam",
        new JSONString(scheduleEditorWizardPanel.getScheduleType().name())); // $NON-NLS-1$

    if (month != null) {
      JSONArray jsonArray = new JSONArray();
      jsonArray.set(0, new JSONString(Integer.toString(month.ordinal())));
      trigger.put("monthsOfYear", jsonArray); // $NON-NLS-1$
    }

    JSONArray jsonArray = new JSONArray();
    jsonArray.set(0, new JSONString(Integer.toString(dayOfMonth)));
    trigger.put("daysOfMonth", jsonArray); // $NON-NLS-1$

    addJsonStartEnd(trigger, startDate, endDate);
    return trigger;
  }
 public static <Type> JSONValue toJSON(byte[] value, AbstractJsonEncoderDecoder<Type> encoder) {
   if (value == null) {
     return JSONNull.getInstance();
   }
   JSONArray rc = new JSONArray();
   int i = 0;
   for (byte t : value) {
     rc.set(i++, new JSONNumber(t));
   }
   return rc;
 }
 public static <Type> JSONValue toJSON(
     Collection<Type> value, AbstractJsonEncoderDecoder<Type> encoder) {
   if (value == null) {
     return JSONNull.getInstance();
   }
   JSONArray rc = new JSONArray();
   int i = 0;
   for (Type t : value) {
     rc.set(i++, encoder.encode(t));
   }
   return rc;
 }
  /**
   * JSONObject-Array
   *
   * <p>タグバリュー型のJSONObjectを生成する
   *
   * @param key
   * @param value
   * @return
   */
  public JSONObject tagValue(String key, JSONObject[] value) {
    JSONObject arrayObj = new JSONObject();
    JSONArray array = new JSONArray();

    int i = 0;
    for (JSONObject currentValue : value) {
      array.set(i++, currentValue);
    }
    arrayObj.put(key, array);

    return arrayObj;
  }
  // TODO(sbeutel): new map method to handle other key values than String
  public static <KeyType, ValueType> JSONValue toJSON(
      Map<KeyType, ValueType> value,
      AbstractJsonEncoderDecoder<KeyType> keyEncoder,
      AbstractJsonEncoderDecoder<ValueType> valueEncoder,
      Style style) {
    if (value == null) {
      return JSONNull.getInstance();
    }

    switch (style) {
      case DEFAULT:
      case SIMPLE:
        {
          JSONObject rc = new JSONObject();

          for (Entry<KeyType, ValueType> t : value.entrySet()) {
            // TODO find a way to check only once
            JSONValue k = keyEncoder.encode(t.getKey());
            if (k.isString() != null) {
              rc.put(k.isString().stringValue(), valueEncoder.encode(t.getValue()));
            } else {
              rc.put(k.toString(), valueEncoder.encode(t.getValue()));
            }
          }
          return rc;
        }
      case JETTISON_NATURAL:
        {
          JSONObject rc = new JSONObject();
          JSONArray entries = new JSONArray();
          int i = 0;
          for (Entry<KeyType, ValueType> t : value.entrySet()) {
            JSONObject entry = new JSONObject();
            // TODO find a way to check only once
            JSONValue k = keyEncoder.encode(t.getKey());
            if (k.isString() != null) {
              entry.put("key", k);
            } else {
              entry.put("key", new JSONString(k.toString()));
            }
            entry.put("value", valueEncoder.encode(t.getValue()));
            entries.set(i++, entry);
          }
          rc.put("entry", entries);
          return rc;
        }
      default:
        throw new UnsupportedOperationException(
            "The encoding style is not yet supported: " + style.name());
    }
  }
Пример #17
0
 protected JSONObject writeStringRepeated(
     JSONObject jsonObject, String fieldLabel, Collection<String> fieldStringRepeated) {
   if (jsonObject != null
       && fieldLabel != null
       && fieldStringRepeated != null
       && !fieldStringRepeated.isEmpty()) {
     JSONArray fieldJSONArray = new JSONArray();
     int i = 0;
     for (String fieldString : fieldStringRepeated) {
       fieldJSONArray.set(i++, new JSONString(fieldString));
     }
     jsonObject.put(fieldLabel, fieldJSONArray);
   }
   return jsonObject;
 }
Пример #18
0
 protected JSONObject writeBooleanRepeated(
     JSONObject jsonObject, String fieldLabel, Collection<Boolean> fieldBooleanRepeated) {
   if (jsonObject != null
       && fieldLabel != null
       && fieldBooleanRepeated != null
       && !fieldBooleanRepeated.isEmpty()) {
     JSONArray fieldJSONArray = new JSONArray();
     int i = 0;
     for (Boolean fieldBoolean : fieldBooleanRepeated) {
       fieldJSONArray.set(i++, JSONBoolean.getInstance(fieldBoolean.booleanValue()));
     }
     jsonObject.put(fieldLabel, fieldJSONArray);
   }
   return jsonObject;
 }
Пример #19
0
 protected JSONObject writeDoubleRepeated(
     JSONObject jsonObject, String fieldLabel, Collection<Double> fieldDoubleRepeated) {
   if (jsonObject != null
       && fieldLabel != null
       && fieldDoubleRepeated != null
       && !fieldDoubleRepeated.isEmpty()) {
     JSONArray fieldJSONArray = new JSONArray();
     int i = 0;
     for (Double fieldDouble : fieldDoubleRepeated) {
       fieldJSONArray.set(i++, new JSONNumber(fieldDouble.doubleValue()));
     }
     jsonObject.put(fieldLabel, fieldJSONArray);
   }
   return jsonObject;
 }
Пример #20
0
 protected JSONObject writeFloatRepeated(
     JSONObject jsonObject, String fieldLabel, Collection<Float> fieldFloatRepeated) {
   if (jsonObject != null
       && fieldLabel != null
       && fieldFloatRepeated != null
       && !fieldFloatRepeated.isEmpty()) {
     JSONArray fieldJSONArray = new JSONArray();
     int i = 0;
     for (Float fieldFloat : fieldFloatRepeated) {
       fieldJSONArray.set(i++, new JSONNumber(fieldFloat.floatValue()));
     }
     jsonObject.put(fieldLabel, fieldJSONArray);
   }
   return jsonObject;
 }
Пример #21
0
 protected JSONObject writeIntegerRepeated(
     JSONObject jsonObject, String fieldLabel, Collection<Integer> fieldIntegerRepeated) {
   if (jsonObject != null
       && fieldLabel != null
       && fieldIntegerRepeated != null
       && !fieldIntegerRepeated.isEmpty()) {
     JSONArray fieldJSONArray = new JSONArray();
     int i = 0;
     for (Integer fieldInteger : fieldIntegerRepeated) {
       fieldJSONArray.set(i++, new JSONNumber(fieldInteger.intValue()));
     }
     jsonObject.put(fieldLabel, fieldJSONArray);
   }
   return jsonObject;
 }
  @Override
  public JSONObject toJSONObject() {
    JSONObject object = super.toJSONObject();

    JSONArray filters = new JSONArray();

    for (ImageDataFilter<?> filter : m_filters) {
      if (null != filter) {
        JSONObject make = filter.toJSONObject();

        if (null != make) {
          filters.set(filters.size(), make);
        }
      }
    }
    object.put("filters", filters);

    return object;
  }
Пример #23
0
 protected JSONObject writeStreamRepeated(
     JSONObject jsonObject, String fieldLabel, Collection<JsonStream> fieldStreamRepeated)
     throws IOException {
   if (jsonObject != null
       && fieldLabel != null
       && fieldStreamRepeated != null
       && !fieldStreamRepeated.isEmpty()) {
     JSONArray fieldJSONArray = new JSONArray();
     int i = 0;
     for (JsonStream fieldStream : fieldStreamRepeated) {
       if (fieldStream instanceof GWTJsonStream) {
         GWTJsonStream fieldGWTJsonStream = (GWTJsonStream) fieldStream;
         fieldJSONArray.set(i++, fieldGWTJsonStream.getJSONObject());
       } else {
         throw new IOException("Failed to write repeated stream field " + fieldLabel);
       }
     }
     jsonObject.put(fieldLabel, fieldJSONArray);
   }
   return jsonObject;
 }
Пример #24
0
  @Override
  public JSONObject toJSON() {
    JSONObject returnObject = new JSONObject();

    if (currentOrganism != null) {
      returnObject.put(FeatureStringEnum.CURRENT_ORGANISM.getValue(), currentOrganism.toJSON());
    }

    if (currentBookmark != null) {
      returnObject.put(
          FeatureStringEnum.CURRENT_BOOKMARK.getValue(),
          BookmarkInfoConverter.convertBookmarkInfoToJSONObject(currentBookmark));
    }
    //        if(currentSequence!=null){
    //            returnObject.put("currentSequence",currentSequence.toJSON());
    //        }
    //        if(currentSequenceList!=null){
    //            JSONArray sequenceListArray = new JSONArray();
    //            for(SequenceInfo sequenceInfo : currentSequenceList){
    //                sequenceListArray.set(sequenceListArray.size(),sequenceInfo.toJSON());
    //            }
    //            returnObject.put("currentSequenceList",sequenceListArray);
    //        }
    if (organismList != null) {
      JSONArray organismListArray = new JSONArray();
      for (OrganismInfo organismInfo : organismList) {
        organismListArray.set(organismListArray.size(), organismInfo.toJSON());
      }
      returnObject.put("organismList", organismListArray);
    }
    if (currentStartBp != null) {
      returnObject.put("currentStartBp", new JSONNumber(currentStartBp));
    }
    if (currentEndBp != null) {
      returnObject.put("currentEndBp", new JSONNumber(currentEndBp));
    }

    return returnObject;
  }
  private void handleWizardPanels(final JSONObject schedule, final JsJobTrigger trigger) {
    if (hasParams) {
      showScheduleParamsDialog(trigger, schedule);
    } else if (isEmailConfValid) {
      showScheduleEmailDialog(schedule);
    } else {
      // submit
      JSONObject scheduleRequest = (JSONObject) JSONParser.parseStrict(schedule.toString());

      if (editJob != null) {
        JSONArray scheduleParams = new JSONArray();

        for (int i = 0; i < editJob.getJobParams().length(); i++) {
          JsJobParam param = editJob.getJobParams().get(i);
          JsArrayString paramValue = (JsArrayString) JavaScriptObject.createArray().cast();
          paramValue.push(param.getValue());
          JsSchedulingParameter p = (JsSchedulingParameter) JavaScriptObject.createObject().cast();
          p.setName(param.getName());
          p.setType("string"); // $NON-NLS-1$
          p.setStringValue(paramValue);
          scheduleParams.set(i, new JSONObject(p));
        }

        scheduleRequest.put("jobParameters", scheduleParams); // $NON-NLS-1$

        String actionClass =
            editJob.getJobParamValue("ActionAdapterQuartzJob-ActionClass"); // $NON-NLS-1$
        if (!StringUtils.isEmpty(actionClass)) {
          scheduleRequest.put("actionClass", new JSONString(actionClass)); // $NON-NLS-1$
        }
      }

      RequestBuilder scheduleFileRequestBuilder =
          new RequestBuilder(RequestBuilder.POST, contextURL + "api/scheduler/job"); // $NON-NLS-1$
      scheduleFileRequestBuilder.setHeader(
          "Content-Type", "application/json"); // $NON-NLS-1$//$NON-NLS-2$
      scheduleFileRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");

      try {
        scheduleFileRequestBuilder.sendRequest(
            scheduleRequest.toString(),
            new RequestCallback() {
              public void onError(Request request, Throwable exception) {
                MessageDialogBox dialogBox =
                    new MessageDialogBox(
                        Messages.getString("error"),
                        exception.toString(),
                        false,
                        false,
                        true); //$NON-NLS-1$
                dialogBox.center();
                setDone(false);
              }

              public void onResponseReceived(Request request, Response response) {
                if (response.getStatusCode() == 200) {
                  setDone(true);
                  ScheduleRecurrenceDialog.this.hide();
                  if (callback != null) {
                    callback.okPressed();
                  }
                  if (showSuccessDialog) {
                    if (!PerspectiveManager.getInstance()
                        .getActivePerspective()
                        .getId()
                        .equals(PerspectiveManager.SCHEDULES_PERSPECTIVE)) {
                      ScheduleCreateStatusDialog successDialog = new ScheduleCreateStatusDialog();
                      successDialog.center();
                    } else {
                      MessageDialogBox dialogBox =
                          new MessageDialogBox(
                              Messages.getString("scheduleUpdatedTitle"),
                              Messages.getString(
                                  "scheduleUpdatedMessage"), //$NON-NLS-1$ //$NON-NLS-2$
                              false,
                              false,
                              true);
                      dialogBox.center();
                    }
                  }
                } else {
                  MessageDialogBox dialogBox =
                      new MessageDialogBox(
                          Messages.getString("error"), // $NON-NLS-1$
                          response.getText(),
                          false,
                          false,
                          true);
                  dialogBox.center();
                  setDone(false);
                }
              }
            });
      } catch (RequestException e) {
        MessageDialogBox dialogBox =
            new MessageDialogBox(
                Messages.getString("error"),
                e.toString(), // $NON-NLS-1$
                false,
                false,
                true);
        dialogBox.center();
        setDone(false);
      }

      setDone(true);
    }
  }
Пример #26
0
 public static ESBPacket getAssetFilter() {
   ESBPacket filter = new ESBPacket();
   JSONArray extensions = new JSONArray();
   extensions.set(extensions.size(), new JSONString("fla"));
   extensions.set(extensions.size(), new JSONString("7z"));
   extensions.set(extensions.size(), new JSONString("deb"));
   extensions.set(extensions.size(), new JSONString("gz"));
   extensions.set(extensions.size(), new JSONString("wmv"));
   extensions.set(extensions.size(), new JSONString("pkg"));
   extensions.set(extensions.size(), new JSONString("rar"));
   extensions.set(extensions.size(), new JSONString("rpm"));
   extensions.set(extensions.size(), new JSONString("sit"));
   extensions.set(extensions.size(), new JSONString("sitx"));
   extensions.set(extensions.size(), new JSONString("zip"));
   extensions.set(extensions.size(), new JSONString("zipx"));
   extensions.set(extensions.size(), new JSONString("csv"));
   extensions.set(extensions.size(), new JSONString("dat"));
   extensions.set(extensions.size(), new JSONString("efx"));
   extensions.set(extensions.size(), new JSONString("epub"));
   extensions.set(extensions.size(), new JSONString("gbr"));
   extensions.set(extensions.size(), new JSONString("ged"));
   extensions.set(extensions.size(), new JSONString("ibooks"));
   extensions.set(extensions.size(), new JSONString("sdf"));
   extensions.set(extensions.size(), new JSONString("tar"));
   extensions.set(extensions.size(), new JSONString("vcf"));
   extensions.set(extensions.size(), new JSONString("accdb"));
   extensions.set(extensions.size(), new JSONString("db"));
   extensions.set(extensions.size(), new JSONString("dbf"));
   extensions.set(extensions.size(), new JSONString("mdb"));
   extensions.set(extensions.size(), new JSONString("sql"));
   extensions.set(extensions.size(), new JSONString("app"));
   extensions.set(extensions.size(), new JSONString("bat"));
   extensions.set(extensions.size(), new JSONString("cgi"));
   extensions.set(extensions.size(), new JSONString("com"));
   extensions.set(extensions.size(), new JSONString("exe"));
   extensions.set(extensions.size(), new JSONString("gadget"));
   extensions.set(extensions.size(), new JSONString("jar"));
   extensions.set(extensions.size(), new JSONString("msi"));
   extensions.set(extensions.size(), new JSONString("pif"));
   extensions.set(extensions.size(), new JSONString("vb"));
   extensions.set(extensions.size(), new JSONString("wsf"));
   extensions.set(extensions.size(), new JSONString("fnt"));
   extensions.set(extensions.size(), new JSONString("fon"));
   extensions.set(extensions.size(), new JSONString("otf"));
   extensions.set(extensions.size(), new JSONString("ttf"));
   extensions.set(extensions.size(), new JSONString("3dm"));
   extensions.set(extensions.size(), new JSONString("3ds"));
   extensions.set(extensions.size(), new JSONString("dwg"));
   extensions.set(extensions.size(), new JSONString("eps"));
   extensions.set(extensions.size(), new JSONString("ps"));
   extensions.set(extensions.size(), new JSONString("svg"));
   extensions.set(extensions.size(), new JSONString("indd"));
   extensions.set(extensions.size(), new JSONString("pct"));
   extensions.set(extensions.size(), new JSONString("pdf"));
   extensions.set(extensions.size(), new JSONString("xlr"));
   extensions.set(extensions.size(), new JSONString("xls"));
   extensions.set(extensions.size(), new JSONString("xlsx"));
   extensions.set(extensions.size(), new JSONString("doc"));
   extensions.set(extensions.size(), new JSONString("docx"));
   extensions.set(extensions.size(), new JSONString("log"));
   extensions.set(extensions.size(), new JSONString("msg"));
   extensions.set(extensions.size(), new JSONString("odt"));
   extensions.set(extensions.size(), new JSONString("pages"));
   extensions.set(extensions.size(), new JSONString("rtf"));
   extensions.set(extensions.size(), new JSONString("tex"));
   extensions.set(extensions.size(), new JSONString("txt"));
   extensions.set(extensions.size(), new JSONString("wpd"));
   extensions.set(extensions.size(), new JSONString("wps"));
   extensions.set(extensions.size(), new JSONString("3g2"));
   extensions.set(extensions.size(), new JSONString("3gp"));
   extensions.set(extensions.size(), new JSONString("asf"));
   extensions.set(extensions.size(), new JSONString("asx"));
   extensions.set(extensions.size(), new JSONString("avi"));
   extensions.set(extensions.size(), new JSONString("flv"));
   extensions.set(extensions.size(), new JSONString("mov"));
   extensions.set(extensions.size(), new JSONString("mp4"));
   extensions.set(extensions.size(), new JSONString("mpg"));
   extensions.set(extensions.size(), new JSONString("rm"));
   extensions.set(extensions.size(), new JSONString("srt"));
   extensions.set(extensions.size(), new JSONString("swf"));
   extensions.set(extensions.size(), new JSONString("vob"));
   extensions.set(extensions.size(), new JSONString("rpf"));
   extensions.set(extensions.size(), new JSONString("rlr"));
   extensions.set(extensions.size(), new JSONString("rlk"));
   extensions.set(extensions.size(), new JSONString("tcf"));
   extensions.set(extensions.size(), new JSONString("tpf"));
   extensions.set(extensions.size(), new JSONString("tdf"));
   extensions.set(extensions.size(), new JSONString("tsz"));
   extensions.set(extensions.size(), new JSONString("tcz"));
   filter.put("0", extensions);
   extensions = new JSONArray();
   extensions.set(extensions.size(), new JSONString("aif"));
   extensions.set(extensions.size(), new JSONString("iff"));
   extensions.set(extensions.size(), new JSONString("m3u"));
   extensions.set(extensions.size(), new JSONString("m4a"));
   extensions.set(extensions.size(), new JSONString("mid"));
   extensions.set(extensions.size(), new JSONString("mp3"));
   extensions.set(extensions.size(), new JSONString("mpa"));
   extensions.set(extensions.size(), new JSONString("ra"));
   extensions.set(extensions.size(), new JSONString("swa"));
   extensions.set(extensions.size(), new JSONString("wav"));
   extensions.set(extensions.size(), new JSONString("wma"));
   filter.put("10", extensions);
   extensions = new JSONArray();
   extensions.set(extensions.size(), new JSONString("gif"));
   extensions.set(extensions.size(), new JSONString("giff"));
   extensions.set(extensions.size(), new JSONString("jpeg"));
   extensions.set(extensions.size(), new JSONString("jpg"));
   extensions.set(extensions.size(), new JSONString("png"));
   filter.put("50", extensions);
   extensions = new JSONArray();
   extensions.set(extensions.size(), new JSONString("key"));
   extensions.set(extensions.size(), new JSONString("pps"));
   extensions.set(extensions.size(), new JSONString("ppt"));
   extensions.set(extensions.size(), new JSONString("pptx"));
   extensions.set(extensions.size(), new JSONString("yuv"));
   extensions.set(extensions.size(), new JSONString("psd"));
   extensions.set(extensions.size(), new JSONString("dds"));
   filter.put("100", extensions);
   extensions = new JSONArray();
   extensions.set(extensions.size(), new JSONString("pspimage"));
   extensions.set(extensions.size(), new JSONString("tga"));
   extensions.set(extensions.size(), new JSONString("tif"));
   extensions.set(extensions.size(), new JSONString("tiff"));
   filter.put("200", extensions);
   extensions = new JSONArray();
   extensions.set(extensions.size(), new JSONString("bmp"));
   extensions.set(extensions.size(), new JSONString("dng"));
   filter.put("400", extensions);
   return filter;
 }
Пример #27
0
  /**
   * Prepares a JSON object
   *
   * @return JSONObject the whole query
   */
  private JSONObject prepareJSONObject() {

    JSONNumber selectedVoId = new JSONNumber(voId);

    // attributes object !! login !!
    JSONObject attrs = new JSONObject();

    if (!namespace.isEmpty() && !namespace.equals("mu")) {
      attrs.put(
          "urn:perun:user:attribute-def:def:login-namespace:" + namespace, new JSONString(login));
    }

    attrs.put("urn:perun:member:attribute-def:def:mail", new JSONString(email));

    // create new form of candidate
    JSONObject newCandidate = new JSONObject();
    newCandidate.put("attributes", attrs);
    newCandidate.put("additionalUserExtSources", null);
    newCandidate.put("id", null);
    newCandidate.put("firstName", new JSONString(""));
    newCandidate.put("lastName", new JSONString(name));
    newCandidate.put("middleName", null);
    newCandidate.put("titleAfter", null);
    newCandidate.put("titleBefore", null);

    if (!certDN.isEmpty() && !caCertDN.isEmpty()) {

      JSONObject userExtSource = new JSONObject();
      userExtSource.put("id", null);
      userExtSource.put("login", new JSONString(certDN));
      // we do not trust manually added certs
      userExtSource.put("loa", new JSONNumber(0));

      // create ext source
      JSONObject extSource = new JSONObject();
      extSource.put("id", null);
      extSource.put("name", new JSONString(caCertDN));
      extSource.put("type", new JSONString("cz.metacentrum.perun.core.impl.ExtSourceX509"));

      userExtSource.put("extSource", extSource);
      newCandidate.put("userExtSource", userExtSource);

    } else {
      newCandidate.put("userExtSource", null);
    }

    JSONArray array = new JSONArray();

    for (int i = 0; i < users.size(); i++) {

      JSONObject user = new JSONObject(users.get(i));

      JSONValue id = user.get("id");
      JSONValue firstName = user.get("firstName");
      JSONValue lastName = user.get("lastName");
      JSONValue middleName = user.get("middleName");
      JSONValue titleAfter = user.get("titleAfter");
      JSONValue titleBefore = user.get("titleBefore");
      JSONValue service = user.get("serviceUser");
      JSONValue sponsored = user.get("sponsoredUser");

      JSONObject newUser = new JSONObject();
      newUser.put("id", id);
      newUser.put("firstName", firstName);
      newUser.put("lastName", lastName);
      newUser.put("middleName", middleName);
      newUser.put("titleAfter", titleAfter);
      newUser.put("titleBefore", titleBefore);
      newUser.put("serviceUser", service);
      newUser.put("sponsoredUser", sponsored);

      array.set(i, newUser);
    }

    // create whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("vo", selectedVoId);
    jsonQuery.put("candidate", newCandidate);
    jsonQuery.put("specificUserOwners", array);
    jsonQuery.put("specificUserType", new JSONString(specificUserType));

    return jsonQuery;
  }