Examples of PlaygroundEnvironment


Examples of nsf.playground.environments.PlaygroundEnvironment

   * Gets the URL to load the container JavaScript for the current container/environment.
   * @return The URL to load the container JavaScript for the current container/environment.
   * @throws Exception Thrown if there is an error getting the container URL.
   */
  public String getContainerUrl() throws Exception {
    PlaygroundEnvironment e = PlaygroundEnvironment.getCurrentEnvironment();
    //Even though getId will already be encoded, we encode it again because when Shindig decodes it we want to
    //make sure it matches the id of the container (which is URL encoded when registered with Shindig)
    String url = CONTAINER_JS + URLEncoder.encode(e.getId(), "UTF-8");
    return url;
  }
View Full Code Here

Examples of nsf.playground.environments.PlaygroundEnvironment

    environments.clear();
  }

  public synchronized String getPreferredEnvironment() throws IOException {
    updateCache();
    PlaygroundEnvironment pref = findPreferredEnvironment();
    if(pref!=null) {
      return pref.getName();
    }
    return null;
  }
View Full Code Here

Examples of nsf.playground.environments.PlaygroundEnvironment

  public synchronized PlaygroundEnvironment getEnvironment(String name) throws IOException {
    updateCache();
    if(!StringUtil.isEmpty(name)) {
      if(StringUtil.equals(name,CUSTOM)) {
        PlaygroundEnvironment e = getCustomEnvironment();
        if(e!=null) {
          return e;
        }
      } else {
        PlaygroundEnvironment e = environments.get(name);
        if(e!=null) {
          return e;
        }
      }
    }
View Full Code Here

Examples of nsf.playground.environments.PlaygroundEnvironment

          envName = (String)ctx.getExternalContext().getSessionMap().get("environment");
        }
      }
      if(StringUtil.isNotEmpty(envName)) {
        if(StringUtil.equals(envName,CUSTOM)) {
          PlaygroundEnvironment e = getCustomEnvironment();
          if(e!=null) {
            return e;
          }
        } else {
          PlaygroundEnvironment e = environments.get(envName);
          if(e!=null) {
            return e;
          }
        }
      }
View Full Code Here

Examples of nsf.playground.environments.PlaygroundEnvironment

    return null;
  }

  public PlaygroundEnvironment findPreferredEnvironment() throws IOException {
    updateCache();
    PlaygroundEnvironment first = null;
    if(!environments.isEmpty()) {
      for(PlaygroundEnvironment e: environments.values()) {
        if(e.isPreferred()) {
          return e;
        }
View Full Code Here

Examples of nsf.playground.environments.PlaygroundEnvironment

  }

  public PlaygroundEnvironment getCustomEnvironment() {
    // The environment is stored on per session (user)
    Map<String,Object> sc = ExtLibUtil.getSessionScope();
    PlaygroundEnvironment env = (PlaygroundEnvironment)sc.get("custom-env");
    if(env==null) {
      env = new PlaygroundEnvironment(CUSTOM) {
        {
          setDescription("This is a custom, transient environment that can be defined to point to your own servers, or use our own OAuth keys");
          // Set all the default properties
          List<nsf.playground.extension.Endpoints.Property> props = Endpoints.categories.getAllProperties();
          for(int i=0; i<props.size(); i++) {
View Full Code Here

Examples of nsf.playground.environments.PlaygroundEnvironment

        if(v!=null) {
          ViewEntryCollection vc = v.getAllEntries();
          for(ViewEntry e=vc.getFirstEntry(); e!=null; e=vc.getNextEntry()) {
            Document d = e.getDocument();
            try {
              PlaygroundEnvironment env = readEnvironment(d);
              if(envs.length==0 || StringUtil.contains(envs, env.getName())) {
                env.setNotesUrl(d.getNotesURL());
                environments.put(env.getName(), env);
                if(TRACE) {
                  System.out.println("Loading environment: "+env.getName());
                }
                allEnvs.add(env.getName());
              }
            } finally {
              d.recycle();
            }
          }
View Full Code Here

Examples of nsf.playground.environments.PlaygroundEnvironment

      d.copyAllItems(doc.getDocument(), true);
      doc.setDocument(doc.getDocument());
    }
  }
  public PlaygroundEnvironment readEnvironment(Document d) throws NotesException, IOException {
    PlaygroundEnvironment env = new PlaygroundEnvironment();
    return readEnvironment(env, d);
  }
View Full Code Here

Examples of nsf.playground.environments.PlaygroundEnvironment

  }
 
    private static Pattern paramsPattern = Pattern.compile("%\\{(.*?)\\}");
   
  public FBSDefaultObject extractParams(String[] ss) throws InterpretException {
    PlaygroundEnvironment env = PlaygroundEnvironment.getCurrentEnvironment();
   
    ArrayObject params = new ArrayObject(JavaScriptUtil.getJSContext());
    if(ss!=null) {
      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

Examples of nsf.playground.environments.PlaygroundEnvironment

    // The API explorer sets the current environment as a request header
    // If this parameter exists, then we initialize it
    String envName = request.getHeader("x-env");
    if(StringUtil.isNotEmpty(envName)) {
      DataAccessBean dataAccess = DataAccessBean.get();
      PlaygroundEnvironment env = dataAccess.getCurrentEnvironment(envName);
      env.prepareEndpoints();
    }
    super.service(request, response);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.