Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /antelope/src/ise/antelope/tasks/

antelope
Discussion topic

Back to topic list

CVS update: /antelope/src/ise/antelope/tasks/

Author danson
Full name Dale Anson
Date 2004-10-12 20:59:39 PDT
Message User: danson
Date: 04/10/12 20:59:39

Modified:
 /antelope/src/ise/an​telope/tasks/
  PostTask.java

Log:
 updates, added cookie handling

File Changes:

Directory: /antelope/src/ise/an​telope/tasks/
====================​====================​====

File [changed]: PostTask.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/tasks/PostTas​k.java?r1=1.5&r2​=1.6
Delta lines: +311 -362
-----------------------
--- PostTask.java 13 Oct 2004 01:42:49 -0000 1.5
+++ PostTask.java 13 Oct 2004 03:59:33 -0000 1.6
@@ -1,56 +1,56 @@
 /*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reprodconnectione the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This prodconnectiont includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowlegement may appear in the software itself,
- * if and wherever sconnectionh third-party acknowlegements normally appear.
- *
- * 4. The names "The Jakarta Project", "Ant", and "Apache Software
- * Foundation" must not be used to endorse or promote prodconnectionts derived
- * from this software without prior written permission. For written
- * permission, please contact apache at apache dot org.
- *
- * 5. Prodconnectionts derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================​====================​====================​========
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
+* The Apache Software License, Version 1.1
+*
+* Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+* reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* 1. Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reprodconnectione the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+*
+* 3. The end-user documentation included with the redistribution, if
+* any, must include the following acknowlegement:
+* "This prodconnectiont includes software developed by the
+* Apache Software Foundation (http://www.apache.org/)."
+* Alternately, this acknowlegement may appear in the software itself,
+* if and wherever sconnectionh third-party acknowlegements normally appear.
+*
+* 4. The names "The Jakarta Project", "Ant", and "Apache Software
+* Foundation" must not be used to endorse or promote prodconnectionts derived
+* from this software without prior written permission. For written
+* permission, please contact apache at apache dot org.
+*
+* 5. Prodconnectionts derived from this software may not be called "Apache"
+* nor may "Apache" appear in their names without prior written
+* permission of the Apache Group.
+*
+* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+* SUCH DAMAGE.
+* ====================​====================​====================​========
+*
+* This software consists of voluntary contributions made by many
+* individuals on behalf of the Apache Software Foundation. For more
+* information on the Apache Software Foundation, please see
+* <http://www.apache.org/>.
+*/
 package ise.antelope.tasks;
 import java.io.BufferedReader;
 import java.io.DataOutputStream;
@@ -87,7 +87,7 @@
  * and the appropriate property values will be filled in at run time.
  *
  * @author Dale Anson, danson at germane-software dot com
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
  */
 public class PostTask extends Task {
 
@@ -109,7 +109,7 @@
     private boolean verbose = true;
     /** want to keep the server response? */
     private boolean wantResponse = true;
-
+ /** store output in a property */
     private String property = null;
     
     /** how long to wait for a response from the server */
@@ -117,8 +117,8 @@
     /** fail on error? */
     private boolean failOnError = false;
 
- private String cookiePrefix = null;
- private boolean useCookies = false;
+ // storage for cookies
+ private static Hashtable cookieStorage = new Hashtable();
 
     /** connection to the server */
     private URLConnection connection = null;
@@ -126,12 +126,13 @@
     private Thread currentRunner = null;
 
 
+
     /**
      * Set the url to post to. Required.
      *
      * @param name the url to post to.
      */
- public void setTo(URL name) {
+ public void setTo( URL name ) {
         to = name;
     }
 
@@ -141,7 +142,7 @@
      *
      * @param f the file
      */
- public void setFile(File f) {
+ public void setFile( File f ) {
         propsFile = f;
     }
 
@@ -152,7 +153,7 @@
      *
      * @param f the file
      */
- public void setLogfile(File f) {
+ public void setLogfile( File f ) {
         log = f;
     }
 
@@ -163,7 +164,7 @@
      *
      * @param b append or not
      */
- public void setAppend(boolean b) {
+ public void setAppend( boolean b ) {
         append = b;
     }
 
@@ -174,7 +175,7 @@
      *
      * @param b true = verbose
      */
- public void setVerbose(boolean b) {
+ public void setVerbose( boolean b ) {
         verbose = b;
     }
 
@@ -185,11 +186,11 @@
      *
      * @param b print/log server response
      */
- public void setWantresponse(boolean b) {
+ public void setWantresponse( boolean b ) {
         wantResponse = b;
     }
     
- public void setProperty(String name) {
+ public void setProperty( String name ) {
         property = name;
     }
 
@@ -198,7 +199,7 @@
      *
      * @param encoding The new encoding value
      */
- public void setEncoding(String encoding) {
+ public void setEncoding( String encoding ) {
         this.encoding = encoding;
     }
 
@@ -216,7 +217,7 @@
      *
      * @param wait time to wait in seconds, set to 0 to wait forever.
      */
- public void setMaxwait(int wait) {
+ public void setMaxwait( int wait ) {
         maxwait = wait * 1000;
     }
 
@@ -226,48 +227,29 @@
      *
      * @param fail true = fail the build, default is false
      */
- public void setFailonerror(boolean fail) {
+ public void setFailonerror( boolean fail ) {
         failOnError = fail;
     }
 
     /**
- * Sets the cookieprefix attribute of the PostTask object
- *
- * @param prefix The new cookieprefix value
- */
- public void setCookieprefix(String prefix) {
- cookiePrefix = prefix;
- }
-
- /**
- * Sets the usecookies attribute of the PostTask object
- *
- * @param use The new usecookies value
- */
- public void setUsecookies(boolean use) {
- useCookies = use;
- }
-
-
- /**
      * Adds a name/value pair to post. Optional.
      *
      * @param p A property pair to send as part of the post.
      * @exception BuildException When name and/or value are missing.
      */
- public void addConfiguredProp(Prop p) throws BuildException {
+ public void addConfiguredProp( Prop p ) throws BuildException {
         String name = p.getName();
- if (name == null) {
- throw new BuildException("name is null", getLocation());
+ if ( name == null ) {
+ throw new BuildException( "name is null", getLocation() );
         }
         String value = p.getValue();
- if (value == null) {
- value = getProject().getProperty(name);
+ if ( value == null ) {
+ value = getProject().getProperty( name );
         }
- if (value == null) {
- throw new BuildException("value is null", getLocation());
+ if ( value == null ) {
+ throw new BuildException( "value is null", getLocation() );
         }
- props.put(name, value);
+ props.put( name, value );
     }
 
 
@@ -276,7 +258,7 @@
      *
      * @param text The feature to be added to the Text attribute
      */
- public void addText(String text) {
+ public void addText( String text ) {
         textProps = text;
     }
 
@@ -287,12 +269,13 @@
      * @exception BuildException On any error.
      */
     public void execute() throws BuildException {
- if (to == null) {
- throw new BuildException("'to' attribute is required", getLocation());
+ if ( to == null ) {
+ throw new BuildException( "'to' attribute is required", getLocation() );
         }
         final String content = getContent();
         try {
- log("Opening connection for post to " + to.toString() + "...");
+ if ( verbose )
+ log( "Opening connection for post to " + to.toString() + "..." );
 
             // do the POST
             Thread runner =
@@ -302,77 +285,70 @@
                         try {
                             // set the url connection properties
                             connection = to.openConnection();
- connection.setDoInput(true);
- connection.setDoOutput(true);
- connection.setUseCaches(false);
+ connection.setDoInput( true );
+ connection.setDoOutput( true );
+ connection.setUseCaches( false );
                             connection.setRequestProperty(
                                     "Content-Type",
- "application/x-www-f​orm-urlencoded");
+ "application/x-www-f​orm-urlencoded" );
 
- if (useCookies && cookiePrefix != null) {
- Hashtable map = getProject().getProperties();
- for (Iterator it = map.keySet().iterator(); it.hasNext(); ) {
+ // check if there are cookies to be included
+ for ( Iterator it = cookieStorage.keySet​().iterator(); it.hasNext(); ) {
                                     StringBuffer sb = new StringBuffer();
                                     Object name = it.next();
- if (name != null) {
+ if ( name != null ) {
                                         String key = name.toString();
- if (key.startsWith(cookiePrefix)) {
- sb.append("$Version=\"1\";");
- key = key.substring(cookie​Prefix.length());
- Object value = map.get(name);
- if (value == null)
- value = "";
- sb.append(key).appen​d("=").append(value.​toString()).append("​;");
- sb.append("$Path=\​"").append(to.getPat​h()).append("\";");​
- connection.addReques​tProperty("Cookie", sb.toString());
- }
+ Cookie cookie = ( Cookie ) cookieStorage.get( name );
+ if ( to.getPath().startsWith( cookie.getPath() ) ) {
+ connection.addRequestProperty( "Cookie", cookie.toString() );
                                     }
                                 }
                             }
 
                             // do the post
- if (verbose) {
- log("Connected, sending data...");
+ if ( verbose ) {
+ log( "Connected, sending data..." );
                             }
- out = new DataOutputStream(con​nection.getOutputStr​eam());
- if (verbose) {
- log(content);
+ out = new DataOutputStream( connection.getOutputStream() );
+ if ( verbose ) {
+ log( content );
                             }
- out.writeBytes(content);
+ out.writeBytes( content );
                             out.flush();
- if (verbose) {
- log("Data sent.");
+ if ( verbose ) {
+ log( "Data sent." );
                             }
                         }
- catch (Exception e) {
- if (failOnError) {
- throw new BuildException(e, getLocation());
+ catch ( Exception e ) {
+ if ( failOnError ) {
+ throw new BuildException( e, getLocation() );
                             }
                         }
                         finally {
                             try {
                                 out.close();
                             }
- catch (Exception e) {
+ catch ( Exception e ) {
                                 // ignored
                             }
                         }
                     }
- };
+ }
+ ;
             runner.run();
- runner.join(maxwait);
- if (runner.isAlive()) {
+ runner.join( maxwait );
+ if ( runner.isAlive() ) {
                 runner.interrupt();
- if (failOnError) {
- throw new BuildException("maxwait exceeded, unable to send data", getLocation());
+ if ( failOnError ) {
+ throw new BuildException( "maxwait exceeded, unable to send data", getLocation() );
                 }
- return;
+ return ;
             }
 
             // read the response, if any, optionally writing it to a file
- if (wantResponse) {
- if (verbose) {
- log("Waiting for response...");
+ if ( wantResponse ) {
+ if ( verbose ) {
+ log( "Waiting for response..." );
                 }
                 runner =
                     new Thread() {
@@ -382,154 +358,118 @@
                             PrintWriter pw = null;
                             BufferedReader in = null;
                             try {
- if (connection instanceof HttpURLConnection) {
- if (cookiePrefix != null) {
- Map map = ((HttpURLConnection) connection).getHeaderFields();
- for (Iterator it = map.keySet().iterator(); it.hasNext(); ) {
- String name = (String) it.next();
- if (name != null && name.equals("Set-Cookie")) {
- List cookies = (List)map.get(name);
- for (Iterator c = cookies.iterator(); c.hasNext(); ) {
- String cookie = (String)c.next();
- String key = cookie.substring(0, cookie.indexOf("="));
- String value = cookie.substring(coo​kie.indexOf("=") + 1, cookie.lastIndexOf(";"));
- getProject().setProp​erty(cookiePrefix + key, value);
- }
+ if ( connection instanceof HttpURLConnection ) {
+ // read and store cookies
+ Map map = ( ( HttpURLConnection ) connection ).getHeaderFields();
+ for ( Iterator it = map.keySet().iterator(); it.hasNext(); ) {
+ String name = ( String ) it.next();
+ if ( name != null && name.equals( "Set-Cookie" ) ) {
+ List cookies = ( List ) map.get( name );
+ for ( Iterator c = cookies.iterator(); c.hasNext(); ) {
+ String raw = ( String ) c.next();
+ Cookie cookie = new Cookie( raw );
+ cookieStorage.put( cookie.getId(), cookie );
                                             }
                                         }
                                     }
- if (verbose) {
- log(String.valueOf((​(HttpURLConnection) connection).getRespo​nseCode()));
- log(((HttpURLConnection) connection).getRespo​nseMessage());
+ if ( verbose ) {
+ log( String.valueOf( ( ( HttpURLConnection ) connection ).getResponseCode() ) );
+ log( ( ( HttpURLConnection ) connection ).getResponseMessage() );
                                         StringBuffer sb = new StringBuffer();
- Map map = ((HttpURLConnection) connection).getHeaderFields();
- for (Iterator it = map.keySet().iterator(); it.hasNext(); ) {
- String name = (String) it.next();
- sb.append(name).append("=");
- List values = (List) map.get(name);
- if (values != null) {
- if (values.size() == 1)
- sb.append(values.get(0));
- else if (values.size() > 1) {
- sb.append("[");
- for (Iterator v = values.iterator(); v.hasNext(); ) {
- sb.append(v.next()).​append(",");
+ map = ( ( HttpURLConnection ) connection ).getHeaderFields();
+ for ( Iterator it = map.keySet().iterator(); it.hasNext(); ) {
+ String name = ( String ) it.next();
+ sb.append( name ).append( "=" );
+ List values = ( List ) map.get( name );
+ if ( values != null ) {
+ if ( values.size() == 1 )
+ sb.append( values.get( 0 ) );
+ else if ( values.size() > 1 ) {
+ sb.append( "[" );
+ for ( Iterator v = values.iterator(); v.hasNext(); ) {
+ sb.append( v.next() ).append( "," );
                                                     }
- sb.append("]");
+ sb.append( "]" );
                                                 }
                                             }
- sb.append("\n");
- log(sb.toString());
+ sb.append( "\n" );
+ log( sb.toString() );
                                         }
                                     }
                                 }
                                 in = new BufferedReader(
- new InputStreamReader(co​nnection.getInputStr​eam()));
- if (log != null) {
- fw = new PrintWriter(new FileWriter(log, append));
+ new InputStreamReader( connection.getInputStream() ) );
+ if ( log != null ) {
+ fw = new PrintWriter( new FileWriter( log, append ) );
                                 }
- if (property != null) {
+ if ( property != null ) {
                                     sw = new StringWriter();
- pw = new PrintWriter(sw);
+ pw = new PrintWriter( sw );
                                 }
                                 String line;
- while (null != ((line = in.readLine()))) {
- if (currentRunner != this) {
+ while ( null != ( ( line = in.readLine() ) ) ) {
+ if ( currentRunner != this ) {
                                         break;
                                     }
                                     //line = URLDecoder.decode( line, "UTF-8" );
- if (verbose) {
- log(line);
+ if ( verbose ) {
+ log( line );
                                     }
- if (fw != null) {
- fw.println(line);
+ if ( fw != null ) {
+ fw.println( line );
                                     }
- if (pw != null) {
- pw.println(line);
+ if ( pw != null ) {
+ pw.println( line );
                                     }
                                 }
                             }
- catch (Exception e) {
+ catch ( Exception e ) {
                                 e.printStackTrace();
- if (failOnError) {
- throw new BuildException(e, getLocation());
+ if ( failOnError ) {
+ throw new BuildException( e, getLocation() );
                                 }
                             }
                             finally {
                                 try {
                                     in.close();
                                 }
- catch (Exception e) {
+ catch ( Exception e ) {
                                     // ignored
                                 }
                                 try {
- if (fw != null) {
+ if ( fw != null ) {
                                         fw.flush();
                                         fw.close();
                                     }
                                 }
- catch (Exception e) {
+ catch ( Exception e ) {
                                     // ignored
                                 }
                             }
- if (property != null && sw != null) {
- getProject().setProp​erty(property, sw.toString());
+ if ( property != null && sw != null ) {
+ getProject().setProperty( property, sw.toString() );
                             }
                         }
                     };
                 currentRunner = runner;
                 runner.run();
- runner.join(maxwait);
- if (runner.isAlive()) {
+ runner.join( maxwait );
+ if ( runner.isAlive() ) {
                     currentRunner = null;
                     runner.interrupt();
- if (failOnError) {
- throw new BuildException("maxwait exceeded, unable to receive data", getLocation());
- }
- }
- }
- log("Post complete.");
- }
- catch (Exception e) {
- if (failOnError) {
- throw new BuildException(e);
- }
- }
- }
-
-
- /**
- * Builds and formats the message to send to the server.
- *
- * @return the message to send to the server, UTF-8 encoded.
- */
- private String getContent() {
- if (propsFile != null) {
- loadFile(propsFile);
+ if ( failOnError ) {
+ throw new BuildException( "maxwait exceeded, unable to receive data", getLocation() );
         }
-
- if (textProps != null) {
- loadTextProps(textProps);
         }
-
- StringBuffer content = new StringBuffer();
- try {
- Enumeration enum = props.keys();
- while (enum.hasMoreElements()) {
- String name = (String) enum.nextElement();
- String value = (String) props.get(name);
- content.append(URLEn​coder.encode(name, encoding));
- content.append("=");
- content.append(URLEn​coder.encode(value, encoding));
- if (enum.hasMoreElements()) {
- content.append("&");
                 }
+ if ( verbose )
+ log( "Post complete." );
             }
+ catch ( Exception e ) {
+ if ( failOnError ) {
+ throw new BuildException( e );
         }
- catch (Exception e) {
- // ignored
         }
- return content.toString();
     }
 
 
@@ -539,24 +479,24 @@
      * @param file file to load
      * @exception BuildException Description of the Exception
      */
- private void loadFile(File file) throws BuildException {
+ private void loadFile( File file ) throws BuildException {
         Properties fileprops = new Properties();
         try {
- if (file.exists()) {
- FileInputStream fis = new FileInputStream(file);
+ if ( file.exists() ) {
+ FileInputStream fis = new FileInputStream( file );
                 try {
- fileprops.load(fis);
+ fileprops.load( fis );
                 }
                 finally {
- if (fis != null) {
+ if ( fis != null ) {
                         fis.close();
                     }
                 }
- addProperties(fileprops);
+ addProperties( fileprops );
             }
             else {
- log("Unable to find property file: " + file.getAbsolutePath(),
- Project.MSG_VERBOSE);
+ log( "Unable to find property file: " + file.getAbsolutePath(),
+ Project.MSG_VERBOSE );
          }
          log( "Post complete." );
       }
@@ -586,8 +526,8 @@
       try {
          Enumeration en = props.keys();
          while ( en.hasMoreElements() ) {
- String name = (String)en.nextElement();
- String value = (String)props.get( name );
+ String name = ( String ) en.nextElement();
+ String value = ( String ) props.get( name );
             content.append( URLEncoder.encode( name, encoding ) );
             content.append( "=" );
             content.append( URLEncoder.encode( value, encoding ) );
@@ -595,11 +535,13 @@
                content.append( "&" );
             }
         }
- catch (IOException ex) {
- if (failOnError) {
- throw new BuildException(ex, getLocation());
+ }
+ catch ( IOException ex ) {
+ if ( failOnError ) {
+ throw new BuildException( ex, getLocation() );
             }
         }
+ return content.toString();
     }
 
 
@@ -608,22 +550,22 @@
      *
      * @param tp
      */
- private void loadTextProps(String tp) {
+ private void loadTextProps( String tp ) {
         Properties p = new Properties();
         Project project = getProject();
- StringTokenizer st = new StringTokenizer(tp, "$");
- while (st.hasMoreTokens()) {
+ StringTokenizer st = new StringTokenizer( tp, "$" );
+ while ( st.hasMoreTokens() ) {
             String token = st.nextToken();
- int start = token.indexOf("{");
- int end = token.indexOf("}");
- if (start > -1 && end > -1 && end > start) {
- String name = token.substring(start + 1, end - start);
- String value = project.getProperty(name);
- if (value != null)
- p.setProperty(name, value);
+ int start = token.indexOf( "{" );
+ int end = token.indexOf( "}" );
+ if ( start > -1 && end > -1 && end > start ) {
+ String name = token.substring( start + 1, end - start );
+ String value = project.getProperty( name );
+ if ( value != null )
+ p.setProperty( name, value );
             }
         }
- addProperties(p);
+ addProperties( p );
     }
 
 
@@ -633,13 +575,13 @@
      *
      * @param fileprops The feature to be added to the Properties attribute
      */
- private void addProperties(Properties fileprops) {
- resolveAllProperties​(fileprops);
+ private void addProperties( Properties fileprops ) {
+ resolveAllProperties( fileprops );
         Enumeration e = fileprops.keys();
- while (e.hasMoreElements()) {
- String name = (String) e.nextElement();
- String value = fileprops.getProperty(name);
- props.put(name, value);
+ while ( e.hasMoreElements() ) {
+ String name = ( String ) e.nextElement();
+ String value = fileprops.getProperty( name );
+ props.put( name, value );
         }
     }
 
@@ -651,38 +593,38 @@
      * @param fileprops Description of the Parameter
      * @exception BuildException Description of the Exception
      */
- private void resolveAllProperties(Properties fileprops) throws BuildException {
- for (Enumeration e = fileprops.keys(); e.hasMoreElements(); ) {
- String name = (String) e.nextElement();
- String value = fileprops.getProperty(name);
+ private void resolveAllProperties( Properties fileprops ) throws BuildException {
+ for ( Enumeration e = fileprops.keys(); e.hasMoreElements(); ) {
+ String name = ( String ) e.nextElement();
+ String value = fileprops.getProperty( name );
 
             boolean resolved = false;
- while (!resolved) {
+ while ( !resolved ) {
                 Vector fragments = new Vector();
                 Vector propertyRefs = new Vector();
                 /// this is the Ant 1.5 way of doing it. The Ant 1.6 PropertyHelper
                 /// should be used -- eventually.
- ProjectHelper.parseP​ropertyString(value,​ fragments,
- propertyRefs);
+ ProjectHelper.parseP​ropertyString( value, fragments,
+ propertyRefs );
 
                 resolved = true;
- if (propertyRefs.size() != 0) {
+ if ( propertyRefs.size() != 0 ) {
                     StringBuffer sb = new StringBuffer();
                     Enumeration i = fragments.elements();
                     Enumeration j = propertyRefs.elements();
- while (i.hasMoreElements()) {
- String fragment = (String) i.nextElement();
- if (fragment == null) {
- String propertyName = (String) j.nextElement();
- if (propertyName.equals(name)) {
- throw new BuildException("Property " + name
+ while ( i.hasMoreElements() ) {
+ String fragment = ( String ) i.nextElement();
+ if ( fragment == null ) {
+ String propertyName = ( String ) j.nextElement();
+ if ( propertyName.equals( name ) ) {
+ throw new BuildException( "Property " + name
                                          + " was circularly "
- + "defined.");
+ + "defined." );
                             }
- fragment = getProject().getProp​erty(propertyName);
- if (fragment == null) {
- if (fileprops.containsK​ey(propertyName)) {
- fragment = fileprops.getPropert​y(propertyName);
+ fragment = getProject().getProperty( propertyName );
+ if ( fragment == null ) {
+ if ( fileprops.containsKey( propertyName ) ) {
+ fragment = fileprops.getProperty( propertyName );
                                     resolved = false;
                                 }
                                 else {
@@ -690,10 +632,10 @@
                                 }
                             }
                         }
- sb.append(fragment);
+ sb.append( fragment );
                     }
                     value = sb.toString();
- fileprops.put(name, value);
+ fileprops.put( name, value );
                 }
             }
         }
@@ -704,29 +646,34 @@
         private String value;
         private String domain;
         private String path;
+ private long id = new Date().getTime();
         
- public Cookie(String raw) {
- String[] args = raw.split("[;]");
- for (int i = 0; i < args.length; i++) {
- String part = args[i];
- String[] parts = part.split("[=]");
- parts[0] = parts[0].trim();
- if (parts[0].equals("$Path") || parts[0].equals("Path"))
- path = parts[1];
- else if (parts[0].equals("$Version") || parts[0].equals("Version"))
- path = parts[1];
- else {
- name = parts[0];
- value = parts[1];
- }
+ public Cookie( String raw ) {
+ String[] args = raw.split( "[;]" );
+ for ( int i = 0; i < args.length; i++ ) {
+ String part = args[ i ];
+ String[] parts = part.split( "[=]" );
+ parts[ 0 ] = parts[ 0 ].trim();
+ if ( i == 0 ) {
+ name = parts[ 0 ];
+ value = parts[ 1 ];
+ }
+ else if ( parts[ 0 ].equals( "Path" ) )
+ path = parts[ 1 ];
+ else if ( parts[ 0 ].equals( "Domain" ) )
+ domain = parts[ 1 ];
             }
         }
         
- public Cookie(String name, String value) {
+ public Cookie( String name, String value ) {
             this.name = name;
             this.value = value;
         }
         
+ public String getId() {
+ return String.valueOf( id );
+ }
+
         public String getName() {
             return name;
         }
@@ -735,7 +682,7 @@
             return value;
         }
         
- public void setDomain(String domain) {
+ public void setDomain( String domain ) {
             this.domain = domain;
         }
         
@@ -743,7 +690,7 @@
             return domain;
         }
         
- public void setPath(String path) {
+ public void setPath( String path ) {
             this.path = path;
         }
         
@@ -753,10 +700,12 @@
         
         public String toString() {
             StringBuffer sb = new StringBuffer();
- sb.append("$Version=\"1\";");
- sb.append(name).appe​nd("=").append(value​).append(";");
- if (path != null)
- sb.append("$Path=\​"").append(path).app​end("\";");
+ sb.append( name ).append( "=" ).append( value ).append( ";" );
+ if ( domain != null )
+ sb.append( "Domain=" ).append( domain ).append( ";" );
+ if ( path != null )
+ sb.append( "Path=" ).append( path ).append( ";" );
+ sb.append( "Version=\"1\";" );
             return sb.toString();
         }
     }




--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@ante​lope.tigris.org
For additional commands, e-mail: cvs-help at antelope dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /antelope/src/ise/antelope/tasks/ danson Dale Anson 2004-10-12 20:59:39 PDT
Messages per page: