ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project ProjectRefTask.java
Date Thu, 04 Jul 2002 00:36:37 GMT
donaldp     2002/07/03 17:36:37

  Modified:    antlib/src/java/org/apache/antlib/project
                        ProjectRefTask.java
  Log:
  Make sure project name is vlaidate prior to being added to set
  
  Revision  Changes    Path
  1.3       +30 -6     jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/ProjectRefTask.java
  
  Index: ProjectRefTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/ProjectRefTask.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ProjectRefTask.java	2 Jul 2002 10:48:38 -0000	1.2
  +++ ProjectRefTask.java	4 Jul 2002 00:36:37 -0000	1.3
  @@ -15,6 +15,8 @@
   import org.apache.myrmidon.interfaces.workspace.ProjectRef;
   import org.apache.myrmidon.interfaces.workspace.ProjectRefSet;
   import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
  +import org.apache.myrmidon.interfaces.property.NameValidatorManager;
  +import org.apache.myrmidon.interfaces.property.NameValidator;
   
   /**
    * A task that adds a project reference to the current project.
  @@ -64,14 +66,22 @@
       public void execute()
           throws TaskException
       {
  -        if( m_name == null )
  +        validate();
  +
  +        try
           {
  -            final String message = REZ.getString( "projectref.no-name.error" );
  -            throw new TaskException( message );
  +            final NameValidatorManager validatorManager =
  +                (NameValidatorManager)getService( NameValidatorManager.class );
  +            final NameValidator validator =
  +                validatorManager.getValidator( NameValidatorManager.PROJECT_STYLE );
  +            validator.validate( m_name );
           }
  -        if( m_location == null )
  +        catch( final Exception e )
           {
  -            final String message = REZ.getString( "projectref.no-location.error" );
  +            final String message =
  +                REZ.getString( "projectref.bad-name.error",
  +                               m_name,
  +                               e );
               throw new TaskException( message );
           }
   
  @@ -81,5 +91,19 @@
   
           final ProjectRefSet projectRefs = (ProjectRefSet)getContext().getProperty( ProjectRefSet.KEY
);
           projectRefs.addProjectRef( ref );
  +    }
  +
  +    private void validate() throws TaskException
  +    {
  +        if( m_name == null )
  +        {
  +            final String message = REZ.getString( "projectref.no-name.error" );
  +            throw new TaskException( message );
  +        }
  +        if( m_location == null )
  +        {
  +            final String message = REZ.getString( "projectref.no-location.error" );
  +            throw new TaskException( message );
  +        }
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message