1 package org.apache.tomcat.maven.plugin.tomcat6;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import org.apache.maven.plugin.AbstractMojo;
22 import org.apache.maven.plugin.MojoExecutionException;
23 import org.apache.maven.plugins.annotations.Component;
24 import org.apache.maven.plugins.annotations.Parameter;
25 import org.apache.maven.settings.Settings;
26 import org.apache.tomcat.maven.common.deployer.TomcatManagerResponse;
27 import org.apache.tomcat.maven.common.messages.MessagesProvider;
28
29
30
31
32
33
34
35 public abstract class AbstractI18NTomcat6Mojo
36 extends AbstractMojo
37 {
38
39 @Component
40 protected Settings settings;
41
42 @Component(role = MessagesProvider.class)
43 protected MessagesProvider messagesProvider;
44
45
46
47
48
49
50
51
52
53 @Parameter(property = "maven.tomcat.path", defaultValue = "/${project.artifactId}", required = true)
54 protected String path;
55
56
57 protected String getPath()
58 {
59 return path;
60 }
61
62
63
64
65
66
67
68 protected void checkTomcatResponse( TomcatManagerResponse tomcatResponse )
69 throws MojoExecutionException
70 {
71 int statusCode = tomcatResponse.getStatusCode();
72
73 if ( statusCode >= 400 )
74 {
75 getLog().error( messagesProvider.getMessage( "tomcatHttpStatusError", statusCode,
76 tomcatResponse.getReasonPhrase() ) );
77
78 throw new MojoExecutionException(
79 messagesProvider.getMessage( "tomcatHttpStatusError", statusCode,
80 tomcatResponse.getReasonPhrase() ) + ": "
81 + tomcatResponse.getHttpResponseBody() );
82 }
83 }
84 }