From 7aacdb1bf1c208d5169a54e462828a5e5545c558 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 1 Mar 2012 10:28:52 +0000 Subject: [PATCH] [MRM-1610] Use Jackson as jaxrs provider for cxf for performance reasons fix some javascript mapping for redback part. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1295498 13f79535-47bb-0310-9956-ffa450edef68 --- .../resources/META-INF/spring-context.xml | 8 ++++- .../archiva-web/archiva-webapp-js/pom.xml | 16 ++++++++++ .../resources/META-INF/spring-context.xml | 1 + .../src/main/webapp/index.html | 11 +++++-- .../src/main/webapp/js/archiva/main.js | 4 +-- .../src/main/webapp/js/redback/redback.js | 2 +- .../src/main/webapp/js/redback/roles.js | 7 ++--- .../src/main/webapp/js/redback/user.js | 31 ++++++++++++------- .../src/main/webapp/js/redback/users.js | 6 ++-- 9 files changed, 60 insertions(+), 26 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml index 1342487ae..ea22360ee 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml @@ -39,11 +39,17 @@ + + + + + + - + diff --git a/archiva-modules/archiva-web/archiva-webapp-js/pom.xml b/archiva-modules/archiva-web/archiva-webapp-js/pom.xml index 636c40935..570121afd 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp-js/pom.xml @@ -526,6 +526,18 @@ jcl-over-slf4j runtime + + org.codehaus.jackson + jackson-jaxrs + + + org.codehaus.jackson + jackson-xc + + + org.codehaus.jackson + jackson-core-asl + org.apache.cxf cxf-bundle-jaxrs @@ -542,6 +554,10 @@ org.apache.geronimo.specs geronimo-javamail_1.4_spec + + org.codehaus.jettison + jettison + diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-webapp-js/src/main/resources/META-INF/spring-context.xml index bfd7209c3..c367a9e92 100755 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/resources/META-INF/spring-context.xml @@ -57,6 +57,7 @@ + diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html index 5c5cad17b..0ed27dfff 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html @@ -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/" }); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js index 66c212e3e..401c2b860 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js @@ -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(); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js index 4303569a9..414796efb 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js @@ -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'))); } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js index bdf6d28b1..749678d87 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js @@ -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(){ diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js index 944d83260..96a01fa45 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js @@ -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); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js index 2d581268c..c1e2b6ad1 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js @@ -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(); -- 2.39.5