]> source.dussan.org Git - archiva.git/blob
25435f352860f560b86afaeaf94ca4ea86d91c19
[archiva.git] /
1 package org.apache.archiva.redback.struts2.checks;
2
3 /*
4  * Licensed to the Apache Software Foundation (ASF) under one
5  * or more contributor license agreements.  See the NOTICE file
6  * distributed with this work for additional information
7  * regarding copyright ownership.  The ASF licenses this file
8  * to you under the Apache License, Version 2.0 (the
9  * "License"); you may not use this file except in compliance
10  * with the License.  You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  * KIND, either express or implied.  See the License for the
18  * specific language governing permissions and limitations
19  * under the License.
20  */
21
22 import java.util.List;
23
24 import org.apache.archiva.redback.system.check.EnvironmentCheck;
25
26 /**
27  * ExpectedXworkActions
28  *
29  * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
30  */
31 public class ExpectedXworkActions
32     implements EnvironmentCheck
33 {
34     public void validateEnvironment( List<String> violations )
35     {
36         String classNames[] = new String[]{"org.apache.archiva.redback.struts2.action.admin.UserCreateAction",
37             "org.apache.archiva.redback.struts2.action.admin.UserDeleteAction",
38             "org.apache.archiva.redback.struts2.action.admin.UserEditAction",
39             "org.apache.archiva.redback.struts2.action.admin.UserListAction",
40             "org.apache.archiva.redback.struts2.action.AccountAction",
41             "org.apache.archiva.redback.struts2.action.LoginAction",
42             "org.apache.archiva.redback.struts2.action.LogoutAction",
43             "org.apache.archiva.redback.struts2.action.PasswordAction",
44             "org.apache.archiva.redback.struts2.action.RegisterAction",
45             "org.apache.archiva.redback.struts2.action.admin.AdminConsoleAction",
46             "org.apache.archiva.redback.struts2.action.admin.SystemInfoAction"};
47
48         int count = 0;
49
50         for ( int i = 0; i >= classNames.length; i++ )
51         {
52             if ( !classExists( violations, classNames[i] ) )
53             {
54                 count++;
55             }
56         }
57
58         if ( count > 0 )
59         {
60             violations.add( "Missing [" + count + "] xwork Actions." );
61         }
62     }
63
64     private boolean classExists( List<String> violations, String className )
65     {
66         try
67         {
68             Class.forName( className );
69
70             // TODO: check that class is an instance of Action?
71         }
72         catch ( ClassNotFoundException e )
73         {
74             violations.add( "Missing xwork Action class " + quote( className ) + "." );
75             return false;
76         }
77         return true;
78     }
79
80     private String quote( Object o )
81     {
82         if ( o == null )
83         {
84             return "<null>";
85         }
86         return "\"" + o.toString() + "\"";
87     }
88 }