From af232e9cf02577c634327c5ab6fc1f2d7c8082b2 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 18 Feb 2013 20:31:24 +0000 Subject: [PATCH] add new service to ease ui git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1447477 13f79535-47bb-0310-9956-ffa450edef68 --- .../RedbackImplementationInformations.java | 69 ++++++++++++ .../RedbackRuntimeConfigurationService.java | 16 ++- ...ultRedbackRuntimeConfigurationService.java | 8 ++ .../main/webapp/js/archiva/general-admin.js | 102 +++++++++--------- 4 files changed, 140 insertions(+), 55 deletions(-) create mode 100644 archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/RedbackImplementationInformations.java diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/RedbackImplementationInformations.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/RedbackImplementationInformations.java new file mode 100644 index 000000000..7bdafb48f --- /dev/null +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/RedbackImplementationInformations.java @@ -0,0 +1,69 @@ +package org.apache.archiva.rest.api.model; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +/** + * @author Olivier Lamy + * @since 1.4-M4 + */ +@XmlRootElement( name = "redbackImplementationInformations" ) +public class RedbackImplementationInformations +{ + private List userManagerImplementationInformations; + + private List rbacManagerImplementationInformations; + + public RedbackImplementationInformations() + { + // no op + } + + public RedbackImplementationInformations( + List userManagerImplementationInformations, + List rbacManagerImplementationInformations ) + { + this.userManagerImplementationInformations = userManagerImplementationInformations; + this.rbacManagerImplementationInformations = rbacManagerImplementationInformations; + } + + public List getUserManagerImplementationInformations() + { + return userManagerImplementationInformations; + } + + public void setUserManagerImplementationInformations( + List userManagerImplementationInformations ) + { + this.userManagerImplementationInformations = userManagerImplementationInformations; + } + + public List getRbacManagerImplementationInformations() + { + return rbacManagerImplementationInformations; + } + + public void setRbacManagerImplementationInformations( + List rbacManagerImplementationInformations ) + { + this.rbacManagerImplementationInformations = rbacManagerImplementationInformations; + } +} diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RedbackRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RedbackRuntimeConfigurationService.java index 3573b7f61..e18a49170 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RedbackRuntimeConfigurationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RedbackRuntimeConfigurationService.java @@ -22,6 +22,7 @@ import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration; import org.apache.archiva.admin.model.beans.LdapConfiguration; import org.apache.archiva.redback.authorization.RedbackAuthorization; import org.apache.archiva.rest.api.model.RBACManagerImplementationInformation; +import org.apache.archiva.rest.api.model.RedbackImplementationInformations; import org.apache.archiva.rest.api.model.UserManagerImplementationInformation; import org.apache.archiva.security.common.ArchivaRoleConstants; @@ -71,6 +72,13 @@ public interface RedbackRuntimeConfigurationService throws ArchivaRestServiceException; + @Path("redbackImplementationInformations") + @GET + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION) + RedbackImplementationInformations getRedbackImplementationInformations() + throws ArchivaRestServiceException; + @Path( "checkLdapConnection" ) @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @@ -78,11 +86,11 @@ public interface RedbackRuntimeConfigurationService Boolean checkLdapConnection() throws ArchivaRestServiceException; - @Path( "checkLdapConnection" ) + @Path("checkLdapConnection") @POST - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION) Boolean checkLdapConnection( LdapConfiguration ldapConfiguration ) throws ArchivaRestServiceException; } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java index afec6005e..a104f390a 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java @@ -36,6 +36,7 @@ import org.apache.archiva.redback.policy.PasswordRule; import org.apache.archiva.redback.rbac.RBACManager; import org.apache.archiva.redback.users.UserManager; import org.apache.archiva.rest.api.model.RBACManagerImplementationInformation; +import org.apache.archiva.rest.api.model.RedbackImplementationInformations; import org.apache.archiva.rest.api.model.UserManagerImplementationInformation; import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.rest.api.services.RedbackRuntimeConfigurationService; @@ -230,6 +231,13 @@ public class DefaultRedbackRuntimeConfigurationService return informations; } + public RedbackImplementationInformations getRedbackImplementationInformations() + throws ArchivaRestServiceException + { + return new RedbackImplementationInformations( getUserManagerImplementationInformations(), + getRbacManagerImplementationInformations() ); + } + public Boolean checkLdapConnection() throws ArchivaRestServiceException { diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js index d40b6e663..1de494da4 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js @@ -1697,61 +1697,61 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout" var mainContent = $("#main-content"); mainContent.html(mediumSpinnerImg()); - $.ajax("restServices/archivaServices/redbackRuntimeConfigurationService/userManagerImplementationInformations", { + $.ajax("restServices/archivaServices/redbackRuntimeConfigurationService/redbackImplementationInformations", { type: "GET", dataType: 'json', success: function(data) { - var userManagerImplementationInformations=mapManagerImplementationInformations(data); - $.ajax("restServices/archivaServices/redbackRuntimeConfigurationService/redbackRuntimeConfiguration", { - type: "GET", - dataType: 'json', - success: function(data) { - var redbackRuntimeConfiguration = mapRedbackRuntimeConfiguration(data); - var redbackRuntimeConfigurationViewModel = - new RedbackRuntimeConfigurationViewModel(redbackRuntimeConfiguration,userManagerImplementationInformations); - - var groups=[]; - var useLdap = $.inArray("ldap",redbackRuntimeConfiguration.usedUserManagerImpls)>0 - ||$.inArray("ldap",redbackRuntimeConfiguration.rbacManagerImpls)>0; - $.log("useLdap:"+useLdap); - if(useLdap){ - // load ldap roles - $.ajax("restServices/redbackServices/ldapGroupMappingService/ldapGroups", { - type: "GET", - dataType: 'json', - success: function(data){ - groups = mapStringList(data); - $.log("groups number:"+groups.length); - redbackRuntimeConfiguration.ldapGroups=ko.observableArray(groups); - } - } ) - .always( - function() { - $.log("complete"); - - // load ldap group mappings if any - $.ajax("restServices/redbackServices/ldapGroupMappingService", { - type: "GET", - dataType: 'json', - success: function(data) { - var groupMappings=mapLdapGroupMappings(data,redbackRuntimeConfigurationViewModel.modifyLdapGroupMapping); - - $.ajax("restServices/redbackServices/roleManagementService/allRoles", { - type: "GET", - dataType: 'json', - success: function(data) { - displayRuntimeConfigurationScreen(redbackRuntimeConfigurationViewModel,data,groupMappings,groups); - } - }); - } - }); - } - ); - } else { - displayRuntimeConfigurationScreen(redbackRuntimeConfigurationViewModel,null,null); + var userManagerImplementationInformations=data?mapManagerImplementationInformations(data.userManagerImplementationInformations):[]; + $.ajax("restServices/archivaServices/redbackRuntimeConfigurationService/redbackRuntimeConfiguration", { + type: "GET", + dataType: 'json', + success: function(data) { + var redbackRuntimeConfiguration = mapRedbackRuntimeConfiguration(data); + var redbackRuntimeConfigurationViewModel = + new RedbackRuntimeConfigurationViewModel(redbackRuntimeConfiguration,userManagerImplementationInformations); + + var groups=[]; + var useLdap = $.inArray("ldap",redbackRuntimeConfiguration.usedUserManagerImpls)>0 + ||$.inArray("ldap",redbackRuntimeConfiguration.rbacManagerImpls)>0; + $.log("useLdap:"+useLdap); + if(useLdap){ + // load ldap roles + $.ajax("restServices/redbackServices/ldapGroupMappingService/ldapGroups", { + type: "GET", + dataType: 'json', + success: function(data){ + groups = mapStringList(data); + $.log("groups number:"+groups.length); + redbackRuntimeConfiguration.ldapGroups=ko.observableArray(groups); + } + } ) + .always( + function() { + $.log("complete"); + + // load ldap group mappings if any + $.ajax("restServices/redbackServices/ldapGroupMappingService", { + type: "GET", + dataType: 'json', + success: function(data) { + var groupMappings=mapLdapGroupMappings(data,redbackRuntimeConfigurationViewModel.modifyLdapGroupMapping); + + $.ajax("restServices/redbackServices/roleManagementService/allRoles", { + type: "GET", + dataType: 'json', + success: function(data) { + displayRuntimeConfigurationScreen(redbackRuntimeConfigurationViewModel,data,groupMappings,groups); + } + }); + } + }); + } + ); + } else { + displayRuntimeConfigurationScreen(redbackRuntimeConfigurationViewModel,null,null); + } } - } - }); + }); } }); -- 2.39.5