1 package org.apache.maven.jelly.tags.maven;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 }