diff --git a/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/UserManagementAction.java b/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/UserManagementAction.java index 7e796c59d..f6834fed8 100644 --- a/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/UserManagementAction.java +++ b/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/UserManagementAction.java @@ -17,11 +17,12 @@ package org.apache.maven.archiva.web.action.admin; * limitations under the License. */ +import com.opensymphony.xwork.Preparable; import org.codehaus.plexus.security.rbac.RBACManager; +import org.codehaus.plexus.security.system.SecuritySession; import org.codehaus.plexus.security.user.User; import org.codehaus.plexus.security.user.UserManager; import org.codehaus.plexus.security.user.UserNotFoundException; -import org.codehaus.plexus.security.system.SecuritySession; import org.codehaus.plexus.xwork.action.PlexusActionSupport; import java.util.ArrayList; @@ -37,9 +38,8 @@ import java.util.List; * role-hint="userManagement" */ public class UserManagementAction - extends PlexusActionSupport + extends PlexusActionSupport implements Preparable { - /** * @plexus.requirement */ @@ -52,12 +52,12 @@ public class UserManagementAction private User user; + private boolean save = false; + private String email; private String fullName; - private boolean locked; - private String username; private String principal; @@ -70,24 +70,49 @@ public class UserManagementAction private String resourceName; + public void prepare() + throws Exception + { + + if ( username != null ) + { + user = userManager.findUser( username ); + + principal = user.getPrincipal().toString(); + fullName = user.getFullName(); + email = user.getEmail(); + + if ( principal != null && rbacManager.userAssignmentExists( principal ) ) + { + assignedRoles = new ArrayList( rbacManager.getAssignedRoles( principal ) ); + availableRoles = new ArrayList( rbacManager.getUnassignedRoles( principal ) ); + } + else + { + assignedRoles = new ArrayList(); + availableRoles = rbacManager.getAllAssignableRoles(); + } + } + } + /** * for this method username should be populated * * @return */ - public String findUser() + public String input() { try { - if ( username == null ) - { - return INPUT; - } - else + if ( username != null ) { user = userManager.findUser( username ); return SUCCESS; } + else + { + return INPUT; + } } catch ( UserNotFoundException ne ) { @@ -96,51 +121,25 @@ public class UserManagementAction } } - /** - * For this method, principal should be populated - * - * @throws Exception - */ - public String display() - throws Exception - { - - user = userManager.findUser( username ); - - principal = user.getPrincipal().toString(); - fullName = user.getFullName(); - email = user.getEmail(); - locked = user.isLocked(); - - // for displaying the potential repositories to be displayed, remove the global resource - // from the list - resources = rbacManager.getAllResources(); - //resources.remove( rbacManager.getGlobalResource() ); - - // check if the user has any roles assigned to them, and populate the lists for - // rendering assign and remove roles links - if ( principal != null && rbacManager.userAssignmentExists( principal ) ) - { - assignedRoles = new ArrayList( rbacManager.getAssignedRoles( principal ) ); - availableRoles = new ArrayList( rbacManager.getUnassignedRoles( principal ) ); - } - else - { - assignedRoles = new ArrayList(); - availableRoles = rbacManager.getAllAssignableRoles(); - } - - return SUCCESS; - } - public String save() throws Exception { + if ( !save ) + { + return INPUT; + } + User temp = userManager.findUser( username ); - temp.setEmail( email ); - temp.setFullName( fullName ); - temp.setLocked( locked ); + if ( email != null ) + { + temp.setEmail( email ); + } + + if ( fullName != null ) + { + temp.setFullName( fullName ); + } temp = userManager.updateUser( temp ); @@ -195,16 +194,6 @@ public class UserManagementAction this.fullName = fullName; } - public boolean isLocked() - { - return locked; - } - - public void setLocked( boolean locked ) - { - this.locked = locked; - } - public String getPrincipal() { return principal; @@ -254,4 +243,14 @@ public class UserManagementAction { this.resourceName = resourceName; } + + public boolean isSave() + { + return save; + } + + public void setSave( boolean save ) + { + this.save = save; + } } diff --git a/archiva-webapp/src/main/resources/xwork.xml b/archiva-webapp/src/main/resources/xwork.xml index 877fe93b3..d102f8e2e 100644 --- a/archiva-webapp/src/main/resources/xwork.xml +++ b/archiva-webapp/src/main/resources/xwork.xml @@ -253,18 +253,22 @@ - - /WEB-INF/jsp/user.jsp + + /WEB-INF/jsp/admin/user.jsp + userManagement + - - /WEB-INF/jsp/userDetails.jsp + + /WEB-INF/jsp/admin/userDetails.jsp + user + - - /WEB-INF/jsp/findUser.jsp + + /WEB-INF/jsp/admin/findUser.jsp user @@ -275,7 +279,7 @@ user - + diff --git a/archiva-webapp/src/main/webapp/WEB-INF/jsp/findUser.jsp b/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/findUser.jsp similarity index 100% rename from archiva-webapp/src/main/webapp/WEB-INF/jsp/findUser.jsp rename to archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/findUser.jsp diff --git a/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/user.jsp b/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/user.jsp new file mode 100644 index 000000000..337e7ad99 --- /dev/null +++ b/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/user.jsp @@ -0,0 +1,99 @@ +<%-- + ~ Copyright 2005-2006 The Apache Software Foundation. + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --%> + +<%@ taglib prefix="ww" uri="/webwork" %> +<%@ taglib prefix="pss" uri="plexusSecuritySystem" %> + + + User Management + + + + + +
+ +
+ +
+
+
+ + + + \ No newline at end of file diff --git a/archiva-webapp/src/main/webapp/WEB-INF/jsp/userDetails.jsp b/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/userDetails.jsp similarity index 100% rename from archiva-webapp/src/main/webapp/WEB-INF/jsp/userDetails.jsp rename to archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/userDetails.jsp diff --git a/archiva-webapp/src/main/webapp/WEB-INF/jsp/user.jsp b/archiva-webapp/src/main/webapp/WEB-INF/jsp/user.jsp deleted file mode 100644 index 2f240ec96..000000000 --- a/archiva-webapp/src/main/webapp/WEB-INF/jsp/user.jsp +++ /dev/null @@ -1,182 +0,0 @@ -<%-- - ~ Copyright 2005-2006 The Apache Software Foundation. - ~ - ~ Licensed under the Apache License, Version 2.0 (the "License"); - ~ you may not use this file except in compliance with the License. - ~ You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --%> - -<%@ taglib prefix="ww" uri="/webwork" %> -<%@ taglib prefix="pss" uri="plexusSecuritySystem" %> - - - User Management - - - - - -
- -
- -
-
-
- - - - \ No newline at end of file