dion        2003/07/30 21:29:00

  Modified:    src/java/org/apache/maven/jelly/tags/maven MavenTag.java
                        MavenTagLibrary.java ConcatTag.java AddPathTag.java
  Added:       src/java/org/apache/maven/jelly/tags/maven UserCheck.java
  Log:
  Use the way of easily checking attributes for values.
  Add user check tag to replace the one in driver.jelly (MAVEN-623)
  
  Revision  Changes    Path
  1.9       +3 -6      maven/src/java/org/apache/maven/jelly/tags/maven/MavenTag.java
  
  Index: MavenTag.java
  ===================================================================
  RCS file: /home/cvs/maven/src/java/org/apache/maven/jelly/tags/maven/MavenTag.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- MavenTag.java     27 Jul 2003 23:33:57 -0000      1.8
  +++ MavenTag.java     31 Jul 2003 04:29:00 -0000      1.9
  @@ -94,12 +94,9 @@
        * @throws JellyTagException if anything goes wrong. FIXME
        */
       public void doTag( XMLOutput output )
  -        throws JellyTagException
  +        throws MissingAttributeException, JellyTagException
       {
  -        if ( getDescriptor() == null )
  -        {
  -            throw new MissingAttributeException( "descriptor" );
  -        }
  +        checkAttribute( getDescriptor(), "descriptor" );
   
           try
           {
  
  
  
  1.7       +2 -1      
maven/src/java/org/apache/maven/jelly/tags/maven/MavenTagLibrary.java
  
  Index: MavenTagLibrary.java
  ===================================================================
  RCS file: 
/home/cvs/maven/src/java/org/apache/maven/jelly/tags/maven/MavenTagLibrary.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MavenTagLibrary.java      31 Jul 2003 02:56:18 -0000      1.6
  +++ MavenTagLibrary.java      31 Jul 2003 04:29:00 -0000      1.7
  @@ -83,5 +83,6 @@
           registerTag( "exists", Exists.class );
           registerTag( "display", DisplayTag.class );
           registerTag( "set-plugin-property", PluginPropertyTag.class );
  +        registerTag( "user-check", UserCheck.class);
       }
   }
  
  
  
  1.8       +2 -5      maven/src/java/org/apache/maven/jelly/tags/maven/ConcatTag.java
  
  Index: ConcatTag.java
  ===================================================================
  RCS file: /home/cvs/maven/src/java/org/apache/maven/jelly/tags/maven/ConcatTag.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ConcatTag.java    11 Apr 2003 23:45:33 -0000      1.7
  +++ ConcatTag.java    31 Jul 2003 04:29:00 -0000      1.8
  @@ -105,10 +105,7 @@
           try
           {
               // Make sure we have an output file.
  -            if ( outputFile == null )
  -            {
  -                throw new MissingAttributeException( "outputFile" );
  -            }
  +            checkAttribute(outputFile, "outputFile");
   
               // Collect all the input files by invoking the body.
               invokeBody( output );
  
  
  
  1.11      +4 -11     maven/src/java/org/apache/maven/jelly/tags/maven/AddPathTag.java
  
  Index: AddPathTag.java
  ===================================================================
  RCS file: 
/home/cvs/maven/src/java/org/apache/maven/jelly/tags/maven/AddPathTag.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AddPathTag.java   31 Jul 2003 02:56:18 -0000      1.10
  +++ AddPathTag.java   31 Jul 2003 04:29:00 -0000      1.11
  @@ -89,7 +89,7 @@
        * @throws JellyTagException when anything goes wrong. FIXME
        */
       public void doTag( XMLOutput output )
  -        throws JellyTagException
  +        throws MissingAttributeException, JellyTagException
       {
           GrantProject project = getMavenContext().getAntProject();
   
  @@ -98,15 +98,8 @@
               throw new JellyTagException( "cannot find ant project" );
           }
   
  -        if ( getId() == null )
  -        {
  -            throw new MissingAttributeException( "id must be specified" );
  -        }
  -
  -        if ( getPath() == null )
  -        {
  -            throw new MissingAttributeException( "path" );
  -        }
  +        checkAttribute( getId(), "id must be specified" );
  +        checkAttribute( getPath(), "path must be specified" );
   
           if ( getId().equals( "maven.compile.src.set" ) )
           {
  
  
  
  1.1                  maven/src/java/org/apache/maven/jelly/tags/maven/UserCheck.java
  
  Index: UserCheck.java
  ===================================================================
  package org.apache.maven.jelly.tags.maven;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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 reproduce 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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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/>.
   *
   * ====================================================================
   */
  
  import org.apache.commons.jelly.JellyTagException;
  import org.apache.commons.jelly.MissingAttributeException;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.maven.jelly.tags.BaseTagSupport;
  
  /**
   * @author dion
   */
  public class UserCheck extends BaseTagSupport
  {
      /** the value that means no value has been set */
      private static String NO_VALUE = "USERNAME_NOT_SET";
      
      /** Error message */
      private static String ERROR = 
        "+------------------------------------------------------------------\n"
      + "| ERROR!\n"
      + "| \n"
      + "| You must specify a maven username in order to deploy the site!\n"
      + "| You can either set this property in your ~/build.properties\n"
      + "| or specify one on the command line:\n"
      + "|\n"
      + "| maven -Dmaven.username=${user.name} [goal]"
      + "+------------------------------------------------------------------";
      
      /** the user to check has a value */
      private String user;
  
      /* (non-Javadoc)
       * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
       */
      public void doTag(XMLOutput output) throws MissingAttributeException, 
JellyTagException
      {
          checkAttribute(user, "user");
          
          user = user.trim();
          if ( user.equals("") || user.equals(UserCheck.NO_VALUE))
          {
              throw new JellyTagException(UserCheck.ERROR);
          }
      }
  
      /**
       * @param aString the value for the user property
       */
      public void setUser(String aString)
      {
          user = aString;
      }
  
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to