View Javadoc

1   package org.apache.maven.jelly.tags.maven;
2   
3   /* ====================================================================
4    *   Licensed to the Apache Software Foundation (ASF) under one or more
5    *   contributor license agreements.  See the NOTICE file distributed with
6    *   this work for additional information regarding copyright ownership.
7    *   The ASF licenses this file to You under the Apache License, Version 2.0
8    *   (the "License"); you may not use this file except in compliance with
9    *   the License.  You may obtain a copy of the License at
10   *
11   *       http://www.apache.org/licenses/LICENSE-2.0
12   *
13   *   Unless required by applicable law or agreed to in writing, software
14   *   distributed under the License is distributed on an "AS IS" BASIS,
15   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   *   See the License for the specific language governing permissions and
17   *   limitations under the License.
18   * ====================================================================
19   */
20  
21  import org.apache.commons.jelly.JellyTagException;
22  import org.apache.commons.jelly.MissingAttributeException;
23  import org.apache.commons.jelly.XMLOutput;
24  import org.apache.maven.jelly.tags.BaseTagSupport;
25  
26  /**
27   * A tag to check if a user name is set.
28   */
29  public class UserCheck
30      extends BaseTagSupport
31  {
32      /** the value that means no value has been set */
33      private static final String NO_VALUE = "USERNAME_NOT_SET";
34  
35      /** Error message */
36      private static final String ERROR = "\n+------------------------------------------------------------------\n"
37          + "| ERROR!\n" + "| \n" + "| You must specify a maven username in order to deploy the site!\n"
38          + "| You can either set this property in your ~/build.properties\n" + "| or specify one on the command line:\n"
39          + "|\n" + "| maven -Dmaven.username=${user.name} [goal]\n"
40          + "+------------------------------------------------------------------\n";
41  
42      /** the user to check has a value */
43      private String user;
44  
45      /**
46       * @see org.apache.commons.jelly.Tag#doTag(XMLOutput)
47       */
48      public void doTag( XMLOutput output )
49          throws MissingAttributeException, JellyTagException
50      {
51          checkAttribute( user, "user" );
52  
53          user = user.trim();
54          if ( "".equals( user ) || UserCheck.NO_VALUE.equals( user ) )
55          {
56              throw new JellyTagException( UserCheck.ERROR );
57          }
58      }
59  
60      /**
61       * @param aString the value for the user property
62       */
63      public void setUser( String aString )
64      {
65          user = aString;
66      }
67  
68  }