]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1610] Use Jackson as jaxrs provider for cxf for performance reasons
authorOlivier Lamy <olamy@apache.org>
Thu, 1 Mar 2012 10:28:52 +0000 (10:28 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 1 Mar 2012 10:28:52 +0000 (10:28 +0000)
fix some javascript mapping for redback part.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1295498 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml
archiva-modules/archiva-web/archiva-webapp-js/pom.xml
archiva-modules/archiva-web/archiva-webapp-js/src/main/resources/META-INF/spring-context.xml
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js

index 1342487ae664c5b40e9f9937d8bd3edbe11e4719..ea22360ee78ed9158a115a444b9a9c2b46ede752 100644 (file)
   <context:component-scan
       base-package="org.apache.archiva.rest.services"/>
 
+  <bean id="jsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider">
+    <property name="mapper" ref="redbackJacksonMapper"/>
+  </bean>
+
+  <bean id="redbackJacksonMapper" class="org.codehaus.jackson.map.ObjectMapper">
+  </bean>
 
   <jaxrs:server id="archivaServices" address="/archivaServices">
 
     <jaxrs:providers>
-      <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
+      <ref bean="jsonProvider"/>
 
       <ref bean="authenticationInterceptor#rest"/>
       <ref bean="permissionInterceptor#rest"/>
index 636c40935b06751860517c37040309ce30e32b64..570121afd5b5058fbe115b4f0c50dfc6964c4f0a 100644 (file)
       <artifactId>jcl-over-slf4j</artifactId>
       <scope>runtime</scope>
     </dependency>
+    <dependency>
+      <groupId>org.codehaus.jackson</groupId>
+      <artifactId>jackson-jaxrs</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.jackson</groupId>
+      <artifactId>jackson-xc</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.jackson</groupId>
+      <artifactId>jackson-core-asl</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.apache.cxf</groupId>
       <artifactId>cxf-bundle-jaxrs</artifactId>
           <groupId>org.apache.geronimo.specs</groupId>
           <artifactId>geronimo-javamail_1.4_spec</artifactId>
         </exclusion>
+        <exclusion>
+          <groupId>org.codehaus.jettison</groupId>
+          <artifactId>jettison</artifactId>
+        </exclusion>
       </exclusions>
     </dependency>
     <dependency>
index bfd7209c33a77a6b658630570acc88a48a433a68..c367a9e922791a0e7dfd839d6807a638888cf2d4 100755 (executable)
@@ -57,6 +57,7 @@
   <jaxrs:server id="archivaUiServices" address="/archivaUiServices">
 
     <jaxrs:providers>
+      <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
       <ref bean="authenticationInterceptor#rest"/>
       <ref bean="permissionInterceptor#rest"/>
       <ref bean="archivaRestServiceExceptionMapper"/>
index 5c5cad17bd1b2c0dfbdea92e6fc1527a7e33a863..0ed27dfffa5d8bf9840fad5e94660fc980052124 100644 (file)
@@ -53,14 +53,19 @@ appendArchivaVersion=function(){
 buildLoadJsUrl=function(srcScript){
   return srcScript+"?"+appendArchivaVersion();
 }
+
+$.ajaxSetup({
+  dataType: 'json'
+});
+
 $.ajax(
   {
     url: "restServices/archivaUiServices/runtimeInfoService/archivaRuntimeInfo",
     dataType: 'json',
     success:function(data){
-        window.archivaDevMode=data.applicationRuntimeInfo.devMode;
-        window.archivaJavascriptLog=data.applicationRuntimeInfo.javascriptLog;
-        window.archivaRuntimeInfo=data.applicationRuntimeInfo;
+        window.archivaDevMode=data.devMode;
+        window.archivaJavascriptLog=data.javascriptLog;
+        window.archivaRuntimeInfo=data;
         require.config({
             baseUrl: "js/"
           });
index 66c212e3e032a8735ba7ed3d28568f8cb8511b46..401c2b8607ffede0ff8013208fbe132963402498 100644 (file)
@@ -73,7 +73,7 @@ $(function() {
     $.ajax({
       url: url,
       success: function(data){
-        var mappedOperations = $.map(data.operation, function(item) {
+        var mappedOperations = $.map(data, function(item) {
             return mapOperation(item);
         });
         window.redbackModel.operatioNames = $.map(mappedOperations, function(item){
@@ -143,7 +143,7 @@ $(function() {
       type: "GET",
       dataType: 'json',
       success: function(data) {
-        var adminExists = JSON.parse(data);
+        var adminExists = data;
         if (adminExists == false) {
           $("#create-admin-link").show();
           $("#login-link").hide();
index 4303569a993f56fdba6ddde66c6fc74e4ab80336..414796efb9ffb98accaefae34338043e9bdedbb4 100644 (file)
@@ -42,7 +42,7 @@ $(function() {
     $.ajax("restServices/redbackServices/loginService/isLogged", {
       type: "GET",
       success: function(data) {
-        userLogged = JSON.parse(data);
+        userLogged = data;
         if (successFn){
           successFn(userLogged == false ? null : jQuery.parseJSON($.cookie('redback_login')));
         }
index bdf6d28b1fcb176916a96658371266ce28f0dc98..749678d877df46af90628d2abaaabdb8c1a64c9a 100644 (file)
@@ -85,7 +85,7 @@ $(function() {
           type: "POST",
           dataType: 'json',
           contentType: 'application/json',
-          data: "{\"role\": " +  ko.toJSON(self)+"}",
+          data: ko.toJSON(self),
           success: function(data) {
             clearUserMessages();
             displaySuccessMessage($.i18n.prop("role.users.updated",this.name));
@@ -134,7 +134,7 @@ $(function() {
          type: "GET",
          dataType: 'json',
          success: function(data) {
-           var mappedRole = mapRole(data.role);
+           var mappedRole = mapRole(data);
            role.parentRoleNames(mappedRole.parentRoleNames());
            role.parentsRolesUsers(mappedRole.parentsRolesUsers());
            role.users(mappedRole.users());
@@ -215,7 +215,7 @@ $(function() {
         type: "GET",
         dataType: 'json',
         success: function(data) {
-          var mappedRoles = $.map(data.role, function(item) {
+          var mappedRoles = $.map(data, function(item) {
             return mapRole(item);
           });
           var rolesViewModel = new RolesViewModel();
@@ -263,7 +263,6 @@ $(function() {
       activateRoleUsersEditTab()
     }
     saveRoleDescription=function(){
-      $.log("saveRoleDescription:"+currentRole.description());
       currentRole.updateDescription();
     }
     saveUsers=function(){
index 944d83260e3afc9c32c0529ee040a723c3a0e24f..96a01fa450881f3953928730f6caa3f0efd8ad14 100644 (file)
@@ -95,12 +95,12 @@ $(function() {
       }
       var currentUser = this;
       $.ajax("restServices/redbackServices/userService/createUser", {
-          data: "{\"user\": " +  ko.toJSON(this)+"}",
+          data: ko.toJSON(this),
           contentType: 'application/json',
           type: "POST",
           dataType: 'json',
           success: function(result) {
-            var created = JSON.parse(result);
+            var created = result;
             if (created == true) {
               displaySuccessMessage( $.i18n.prop("user.created",currentUser.username()));
               if (successFnCallback){
@@ -130,12 +130,12 @@ $(function() {
       }
       var currentAdminUser = this;
       $.ajax("restServices/redbackServices/userService/createAdminUser", {
-          data: "{\"user\": " +  ko.toJSON(this)+"}",
+          data: ko.toJSON(this),
           contentType: 'application/json',
           type: "POST",
           dataType: 'json',
           success: function(result) {
-            var created = JSON.parse(result);
+            var created = result;
             if (created == true) {
               displaySuccessMessage( $.i18n.prop("user.admin.created"));
               var onSuccessCall=function(){
@@ -161,12 +161,12 @@ $(function() {
     this.update=function(){
       var currentUser = this;
       $.ajax("restServices/redbackServices/userService/updateUser", {
-          data: "{\"user\": " +  ko.toJSON(this)+"}",
+          data: ko.toJSON(this),
           contentType: 'application/json',
           type: "POST",
           dataType: 'json',
           success: function(result) {
-            var updated = JSON.parse(result);
+            var updated = result;
             if (updated == true) {
               clearUserMessages();
               displaySuccessMessage($.i18n.prop("user.updated",currentUser.username()));
@@ -207,7 +207,7 @@ $(function() {
       var curUser = this;
       clearUserMessages();
       $.ajax("restServices/redbackServices/roleManagementService/updateUserRoles", {
-          data: "{\"user\": " +  ko.toJSON(this)+"}",
+          data: ko.toJSON(this),
           contentType: 'application/json',
           type: "POST",
           dataType: 'json',
@@ -280,6 +280,13 @@ $(function() {
    */
   AdminUserViewModel=function() {
     this.user = new User("admin","","", "the administrator");
+    var self=this;
+    saveUser=function(){
+      if(! $("#user-create" ).valid() ) {
+        return;
+      }
+      self.user.createAdmin();
+    }
   }
 
   /**
@@ -343,12 +350,12 @@ $(function() {
     if (result == null) {
       logged = false;
     } else {
-      if (result.user) {
+      if (result.username) {
         logged = true;
       }
     }
     if (logged == true) {
-      var user = mapUser(result.user);
+      var user = mapUser(result);
       if (user.passwordChangeRequired()==true){
         changePasswordBox(true,false,user);
         return;
@@ -538,12 +545,12 @@ $(function() {
   editUserDetails=function(user){
     $("#modal-user-edit-err-message").html("");
     $.ajax("restServices/redbackServices/userService/updateMe", {
-        data: "{\"user\": " +  ko.toJSON(user)+"}",
+        data: ko.toJSON(user),
         contentType: 'application/json',
         type: "POST",
         dataType: 'json',
         success: function(result) {
-          var created = JSON.parse(result);
+          var created = result;
           // FIXME i18n
           if (created == true) {
             displaySuccessMessage( $.i18n.prop("user.details.updated"));
@@ -595,7 +602,7 @@ $(function() {
       url: url,
       success: function(result){
         $.log("changePassword#success result:"+result);
-        var user = mapUser(result.user);
+        var user = mapUser(result);
         if (user) {
           window.modalChangePasswordBox.modal('hide');
           $.log("changePassword#sucess,registration:"+registration);
index 2d581268c1e2e2923782192577e89474c43e3e7b..c1e2b6ad100d078834ec21593b9abee783f4d68d 100644 (file)
@@ -134,7 +134,7 @@ $(function() {
           type: "GET",
           dataType: 'json',
           success: function(data) {
-            var mappedRoles = $.map(data.role, function(item) {
+            var mappedRoles = $.map(data, function(item) {
               return item.name;
             });
             user.assignedRoles = ko.observableArray(mappedRoles);
@@ -193,7 +193,7 @@ $(function() {
         type: "GET",
         dataType: 'json',
         success: function(data) {
-          var mappedApplicationRoles = $.map(data.applicationRole, function(item) {
+          var mappedApplicationRoles = $.map(data, function(item) {
             return mapApplicationRoles(item);
           });
           viewModel.applicationRoles=ko.observableArray(mappedApplicationRoles);
@@ -242,7 +242,7 @@ $(function() {
         type: "GET",
         dataType: 'json',
         success: function(data) {
-          var mappedUsers = $.map(data.user, function(item) {
+          var mappedUsers = $.map(data, function(item) {
             return mapUser(item);
           });
           var usersViewModel = new UsersViewModel();