Package com.ibm.jscript.std

Examples of com.ibm.jscript.std.ObjectObject


      }
      this.cache = null;
      this.id = null;
      this.unid = null;
    }
    ObjectObject o = new ObjectObject(jsContext);
    try {
      if(StringUtil.isNotEmpty(id)) {
        Database database = ExtLibUtil.getCurrentDatabase();
        Vector v = new Vector();
        v.add(FORM);
        v.add(id);
        ViewEntry e = database.getView("AllSnippetsById").getEntryByKey(v);
        if(e!=null) {
          Document doc = e.getDocument();
          Properties p = new Properties();
          String props = doc.getItemValueString("Properties");
          if(StringUtil.isNotEmpty(props)) {
            p.load(new StringReader(props));
          }
          String endpoint = p.getProperty("endpoint");
          if(StringUtil.isNotEmpty(endpoint)) {
            o.put("endpoint", FBSString.get(endpoint));
          }
          String baseDocUrl = doc.getItemValueString("basedocurl");
          if(StringUtil.isNotEmpty(baseDocUrl)) {
            o.put("doc_url", FBSString.get(baseDocUrl));
          }
          String json = doc.getItemValueString("Json");
          if(StringUtil.isNotEmpty(json)) {
            FBSValue value = (FBSValue)JsonParser.fromJson(new JsonJavaScriptFactory(jsContext), json);
            o.put("items", value);
          }
          fixAPIObject(o,baseDocUrl,unid);
        }
      }
    } catch(Exception ex) {
View Full Code Here


      result = new ArrayObject();
      o.put("items", result);
    }
    int count = items.getArrayLength();
    for(int i=0; i<count; i++) {
      ObjectObject item = (ObjectObject)items.getArrayElement(i);
      // Fix the unid if it doesn't exist
      fixSnippetUnid(item);
      // And then filter it, or just fix it
      if(result!=items) {
        String oid = item.get("unid").stringValue();
        if(oid.equals(unid)) {
          fixItem(item,baseDocUrl);
          result.addArrayValue(item);
          return;
        }
View Full Code Here

      }
    }
    return false;
  }
  private ObjectObject addParam(ArrayObject a, FBSValue name, FBSValue value, FBSValue type, FBSValue description) throws Exception {
    ObjectObject o = new ObjectObject();
    o.put("name",name);
    o.put("value",value);
    o.put("type",type);
    o.put("description",description);
        a.addArrayValue(o);
        return o;
  }
View Full Code Here

        return o;
  }
 
 
  public Object loadParameters(Object o) throws Exception {
    ObjectObject item = (ObjectObject)o;
    ArrayObject a = new ArrayObject(jsContext);

    FBSValue a1 = (FBSValue)item.get("uriParameters");
    if(a1.isArray()) {
      for(int i=0; i<a1.getArrayLength(); i++) {
        a.addArrayValue(a1.getArrayValue(i));
      }
    }
   
    FBSValue a2 = (FBSValue)item.get("queryParameters");
    if(a2.isArray()) {
      for(int i=0; i<a2.getArrayLength(); i++) {
        a.addArrayValue(a2.getArrayValue(i));
      }
    }
   
    FBSValue a3 = (FBSValue)item.get("headers");
    if(a3.isArray()) {
      for(int i=0; i<a3.getArrayLength(); i++) {
        a.addArrayValue(a3.getArrayValue(i));
      }
    }

    // Add a pseudo query string parameter
    boolean qstring = item.get("queryString").booleanValue();
    if(qstring) {
      ObjectObject qs = addParam(a, FBSString.get("query-string"), FBSString.emptyString, FBSUtility.wrap("string"), FBSUtility.wrap("Extra query string parameters, as they would appear in the URL (a=1&b=2...)"));
      qs.put("optional", FBSBoolean.TRUE);
    }
   
    // Now, add the pseudo entries for the POST/PUT content
    FBSValue v = item.get("http_method");
    if(v.isString()) {
      String m = v.stringValue();
      if(m.equalsIgnoreCase("post")||m.equalsIgnoreCase("put")) {
        ObjectObject ct = addParam(a, FBSString.get("post_content_type"), item.get("post_content_type"), FBSUtility.wrap("string"), FBSUtility.wrap("Content-Type header of the payload"));
        ct.put("optional", FBSBoolean.TRUE);
        ObjectObject bd = addParam(a, FBSString.get("post_content"), item.get("post_content"), FBSUtility.wrap("textarea"), FBSUtility.wrap("Text content sent to the service"));
        bd.put("optional", FBSBoolean.TRUE);
      }
    }
    return a;
  }
View Full Code Here

      for(int i=0; i<ss.length; i++) {
          Matcher paramsMatcher = paramsPattern.matcher(ss[i]);
          while(paramsMatcher.find()){
            String s = paramsMatcher.group(1);
            String[] all = StringUtil.splitString(s, '|', true);
          FBSDefaultObject o = new ObjectObject(JavaScriptUtil.getJSContext());
            for(int j=0; j<all.length; j++) {
              String[] p = StringUtil.splitString(all[j], '=', true);
              if(p.length==1) {
                o.put("name", FBSString.get(p[0]));
              } else if(p.length>1) {
                o.put(p[0],FBSString.get(p[1]));
              }
            }
            FBSString propName = (FBSString)o.get("name");
            if(propName!=null) {
              String v = env.getPropertyValueByName(propName.stringValue());
              if(StringUtil.isNotEmpty(v)) {
                o.put("value", FBSString.get(v));
              }
            }
            params.addArrayValue(o);
          }
      }
View Full Code Here

  public static synchronized FBSValue getJobProgressJavaScript(String jobId) {
    try {
      AsyncAction action = getActions().get(jobId);
      if(action!=null) {
        synchronized(action) {
          ObjectObject o = new ObjectObject();
          o.put("exists", FBSBoolean.TRUE);
          o.put("running", FBSUtility.wrap(action.isRunning()));
          o.put("runCount", FBSUtility.wrap(action.getRunCount()));
          o.put("statusTs", FBSUtility.wrap(action.getStatusTs()));
          o.put("cancelled", FBSUtility.wrap(action.isCancelled()));
          o.put("label", FBSUtility.wrap(action.getActionLabel()));
          o.put("taskLabel", FBSUtility.wrap(action.getTaskLabel()));
          o.put("taskCompletion", FBSUtility.wrap(action.getTaskCompletion()));
          o.put("fullCompletion", FBSUtility.wrap(action.getTotalCompletion()));
          return o;
        }
      } else {
        ObjectObject o = new ObjectObject();
        o.put("exists", FBSBoolean.FALSE);
        o.put("running", FBSBoolean.FALSE);
        o.put("runCount", FBSNumber.Zero);
        o.put("cancelled", FBSBoolean.FALSE);
        o.put("statusTs", FBSNumber.Zero);
        o.put("label", FBSString.emptyString);
        o.put("taskLabel", FBSString.emptyString);
        o.put("taskCompletion", FBSNumber.Zero);
        o.put("fullCompletion", FBSNumber.Zero);
        return o;
      }
    } catch(InterpretException ex) {
      Platform.getInstance().log(ex);
    }
View Full Code Here

TOP

Related Classes of com.ibm.jscript.std.ObjectObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.