]> source.dussan.org Git - archiva.git/commitdiff
add new service to ease ui
authorOlivier Lamy <olamy@apache.org>
Mon, 18 Feb 2013 20:31:24 +0000 (20:31 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 18 Feb 2013 20:31:24 +0000 (20:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1447477 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/RedbackImplementationInformations.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RedbackRuntimeConfigurationService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js

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 (file)
index 0000000..7bdafb4
--- /dev/null
@@ -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<UserManagerImplementationInformation> userManagerImplementationInformations;
+
+    private List<RBACManagerImplementationInformation> rbacManagerImplementationInformations;
+
+    public RedbackImplementationInformations()
+    {
+        // no op
+    }
+
+    public RedbackImplementationInformations(
+        List<UserManagerImplementationInformation> userManagerImplementationInformations,
+        List<RBACManagerImplementationInformation> rbacManagerImplementationInformations )
+    {
+        this.userManagerImplementationInformations = userManagerImplementationInformations;
+        this.rbacManagerImplementationInformations = rbacManagerImplementationInformations;
+    }
+
+    public List<UserManagerImplementationInformation> getUserManagerImplementationInformations()
+    {
+        return userManagerImplementationInformations;
+    }
+
+    public void setUserManagerImplementationInformations(
+        List<UserManagerImplementationInformation> userManagerImplementationInformations )
+    {
+        this.userManagerImplementationInformations = userManagerImplementationInformations;
+    }
+
+    public List<RBACManagerImplementationInformation> getRbacManagerImplementationInformations()
+    {
+        return rbacManagerImplementationInformations;
+    }
+
+    public void setRbacManagerImplementationInformations(
+        List<RBACManagerImplementationInformation> rbacManagerImplementationInformations )
+    {
+        this.rbacManagerImplementationInformations = rbacManagerImplementationInformations;
+    }
+}
index 3573b7f61aaefd00f8ee5713295024d9b3a7c123..e18a491702d95a27e612943bdf007bfd81ffd37f 100644 (file)
@@ -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;
 }
index afec6005ec6c1cb20a9f4c724e104b4fd45afa5d..a104f390a4fc983117a6db417d355ffc70bafe56 100644 (file)
@@ -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
     {
index d40b6e6636f8d88655c997a0943ab8fc852c571b..1de494da4b5545e2bed94970335e20e8c674cbf3 100644 (file)
@@ -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);
+            }
           }
-        }
-      });
+        });
 
       }
     });