Package com.adito.core.stringreplacement

Examples of com.adito.core.stringreplacement.VariableReplacement


     * This is the *only* place replacement and encoding of the network
     * place URI elements should occur as it is the only time when we
     * have all the supporting objects (Session, Policy, Resource).
     */
   
    VariableReplacement r = new VariableReplacement();
    r.setLaunchSession(getLaunchSession());
   
    // User info. Encoded
    String userinfo = null;   
    if(!Util.isNullOrTrimmedBlank(getNetworkPlace().getUsername())) {
        String username = r.replace(getNetworkPlace().getUsername());
        String password = null;
        if(!Util.isNullOrTrimmedBlank(getNetworkPlace().getPassword())) {
            password = r.replace(getNetworkPlace().getPassword());
        }
            userinfo = DAVUtilities.encodeURIUserInfo(username + (password == null ? "" : ":" + password));
    }
   
    // Host. TODO check host only contains SPACE,a-z,A-Z and - and doesn't begin with -
    String host = null;
    //if(getStore().getProvider().getHostRequirement() == VFSProvider.ELEMENT_REQUIRED) {   
    if(!Util.isNullOrTrimmedBlank(getNetworkPlace().getHost())) {   
      host = r.replace(getNetworkPlace().getHost());
    }

    // Port. Integer. A port of -1 signifies default (0 means default in network place)
    int port = -1;
    // This test seems wrong because as all provider don't have port required.
    // It means that the port saved in the database won't never be used.
    //if(getStore().getProvider().getPortRequirement()  == VFSProvider.ELEMENT_REQUIRED && getNetworkPlace().getPort() > 0) {
    // replace by this one which test if port > 0 (different to the default port).
      if(getNetworkPlace().getPort() > 0) {   
      port = getNetworkPlace().getPort();
    }

    // Path. Always required. Replaced and encoded.
    String path = DAVUtilities.encodePath(r.replace(getNetworkPlace().getPath().replace('\\', '/')), charset);
        if(!Util.isNullOrTrimmedBlank(path) && !path.startsWith("/") && !path.startsWith("./")) {
          path = "/" + path;
        }
       
        // Query String. TODO we need to support
View Full Code Here


        }
    }
   
    Request buildLocalTunnel(Tunnel tunnel, LaunchSession launchSession) throws IOException {
      // Process destination host and port for replacement variables
      VariableReplacement r = new VariableReplacement();
      r.setLaunchSession(launchSession);
      String destHost = r.replace(tunnel.getDestination().getHost());
     
        ByteArrayWriter msg = new ByteArrayWriter();
        msg.writeString(launchSession == null ? "" : launchSession.getId());
        msg.writeInt(tunnel.getResourceId());
        msg.writeString(tunnel.getResourceName());
View Full Code Here

     *
     * @see java.lang.Thread#run()
     */
    public void run() {
      // Process destination host and port for replacement variables
      VariableReplacement r = new VariableReplacement();
      r.setLaunchSession(launchSession);
      String destHost = r.replace(tunnel.getDestination().getHost());
     
      ByteArrayWriter msg = new ByteArrayWriter();
     
      try {
       
View Full Code Here

          log.debug("Parsing parameters.");
        for (Iterator i = shortcut.getParameters().entrySet().iterator(); i.hasNext();) {
            Map.Entry entry = (Map.Entry) i.next();           
            String content = (String) entry.getValue();
           
            VariableReplacement r = new VariableReplacement();
            r.setApplicationShortcut(app, null);
            r.setServletRequest(request);
            r.setLaunchSession(launchSession);
           
            entry.setValue(r.replace(content));
        }

        if (log.isDebugEnabled())
          log.debug("Template loaded, doing standard replacements.");

        VariableReplacement r = new VariableReplacement();
        r.setApplicationShortcut(app, shortcut.getParameters());
        r.setServletRequest(request);
        r.setLaunchSession(launchSession);       
        String templateText = r.replace(template.toString());

        ReplacementEngine engine = new ReplacementEngine();

        String tunnels = request.getParameter("tunnels");
        if (tunnels != null && !tunnels.equals("")) {
View Full Code Here

TOP

Related Classes of com.adito.core.stringreplacement.VariableReplacement

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.