From 0ae2aff01efa67cb37124485dad4c6bf10bf58c2 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 19 Dec 2012 22:37:53 +0000 Subject: [PATCH] [MRM-1722] Use cookie settings from redback for rememberme feature fix issues on not saved redbackRuntimeConfiguration.properties git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1424183 13f79535-47bb-0310-9956-ffa450edef68 --- .../web/api/DefaultRuntimeInfoService.java | 11 +- .../archiva/web/api/RuntimeInfoService.java | 20 +-- .../web/model/ApplicationRuntimeInfo.java | 17 ++- .../src/main/webapp/js/archiva/archiva.js | 25 ++-- .../main/webapp/js/archiva/general-admin.js | 40 +++++- .../src/main/webapp/js/archiva/utils.js | 26 +++- .../src/main/webapp/js/knockout.simpleGrid.js | 124 +++++++++--------- .../src/main/webapp/js/redback/user.js | 10 ++ .../js/templates/archiva/general-admin.html | 60 +++++---- .../webapp/js/templates/redback/login.html | 2 +- 10 files changed, 210 insertions(+), 125 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultRuntimeInfoService.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultRuntimeInfoService.java index f28ce3266..e61297b77 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultRuntimeInfoService.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultRuntimeInfoService.java @@ -18,6 +18,8 @@ package org.apache.archiva.web.api; * under the License. */ +import org.apache.archiva.rest.api.services.ArchivaRestServiceException; +import org.apache.archiva.rest.api.services.ArchivaRuntimeConfigurationService; import org.apache.archiva.web.runtime.ArchivaRuntimeInfo; import org.apache.archiva.web.model.ApplicationRuntimeInfo; import org.apache.commons.lang.StringUtils; @@ -35,7 +37,7 @@ import java.util.Locale; /** * @author Olivier Lamy */ -@Service( "runtimeInfoService#rest" ) +@Service("runtimeInfoService#rest") public class DefaultRuntimeInfoService implements RuntimeInfoService { @@ -44,6 +46,9 @@ public class DefaultRuntimeInfoService private ArchivaRuntimeInfo archivaRuntimeInfo; + @Inject + private ArchivaRuntimeConfigurationService archivaRuntimeConfigurationService; + @Context protected HttpServletRequest httpServletRequest; @@ -54,6 +59,7 @@ public class DefaultRuntimeInfoService } public ApplicationRuntimeInfo getApplicationRuntimeInfo( String locale ) + throws ArchivaRestServiceException { ApplicationRuntimeInfo applicationRuntimeInfo = new ApplicationRuntimeInfo(); applicationRuntimeInfo.setBuildNumber( this.archivaRuntimeInfo.getBuildNumber() ); @@ -65,6 +71,9 @@ public class DefaultRuntimeInfoService new Locale( StringUtils.isEmpty( locale ) ? "en" : locale ) ); applicationRuntimeInfo.setTimestampStr( sfd.format( new Date( archivaRuntimeInfo.getTimestamp() ) ) ); + applicationRuntimeInfo.setRedbackRuntimeConfiguration( + archivaRuntimeConfigurationService.getRedbackRuntimeConfigurationAdmin() ); + return applicationRuntimeInfo; } diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/RuntimeInfoService.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/RuntimeInfoService.java index cb5b03e12..422176a71 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/RuntimeInfoService.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/RuntimeInfoService.java @@ -18,6 +18,7 @@ package org.apache.archiva.web.api; * under the License. */ +import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.web.model.ApplicationRuntimeInfo; import org.apache.archiva.redback.authorization.RedbackAuthorization; @@ -32,19 +33,20 @@ import javax.ws.rs.core.MediaType; * @author Olivier Lamy * @since 1.4-M3 */ -@Path( "/runtimeInfoService/" ) +@Path("/runtimeInfoService/") public interface RuntimeInfoService { - @Path( "archivaRuntimeInfo/{locale}" ) + @Path("archivaRuntimeInfo/{locale}") @GET - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @RedbackAuthorization( noRestriction = true ) - ApplicationRuntimeInfo getApplicationRuntimeInfo( @PathParam( "locale" ) String locale ); + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @RedbackAuthorization(noRestriction = true) + ApplicationRuntimeInfo getApplicationRuntimeInfo( @PathParam("locale") String locale ) + throws ArchivaRestServiceException; - @Path( "logMissingI18n" ) + @Path("logMissingI18n") @GET - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @RedbackAuthorization( noRestriction = true ) - Boolean logMissingI18n( @QueryParam( "key" ) String key ); + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @RedbackAuthorization(noRestriction = true) + Boolean logMissingI18n( @QueryParam("key") String key ); } diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/model/ApplicationRuntimeInfo.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/model/ApplicationRuntimeInfo.java index b5bc8cc91..85fdef76b 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/model/ApplicationRuntimeInfo.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/model/ApplicationRuntimeInfo.java @@ -18,6 +18,8 @@ package org.apache.archiva.web.model; * under the License. */ +import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration; + import javax.xml.bind.annotation.XmlRootElement; import java.util.Calendar; @@ -25,7 +27,7 @@ import java.util.Calendar; * @author Olivier Lamy * @since 1.4-M3 */ -@XmlRootElement( name = "applicationRuntimeInfo" ) +@XmlRootElement(name = "applicationRuntimeInfo") public class ApplicationRuntimeInfo { private boolean devMode = false; @@ -46,6 +48,8 @@ public class ApplicationRuntimeInfo private String timestampStr; + private RedbackRuntimeConfiguration redbackRuntimeConfiguration; + public ApplicationRuntimeInfo() { this.devMode = Boolean.getBoolean( "archiva.devMode" ); @@ -147,6 +151,16 @@ public class ApplicationRuntimeInfo this.timestampStr = timestampStr; } + public RedbackRuntimeConfiguration getRedbackRuntimeConfiguration() + { + return redbackRuntimeConfiguration; + } + + public void setRedbackRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration ) + { + this.redbackRuntimeConfiguration = redbackRuntimeConfiguration; + } + @Override public String toString() { @@ -161,6 +175,7 @@ public class ApplicationRuntimeInfo sb.append( ", logMissingI18n=" ).append( logMissingI18n ); sb.append( ", baseUrl='" ).append( baseUrl ).append( '\'' ); sb.append( ", timestampStr='" ).append( timestampStr ).append( '\'' ); + sb.append( ", redbackRuntimeConfiguration=" ).append( redbackRuntimeConfiguration ); sb.append( '}' ); return sb.toString(); } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/archiva.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/archiva.js index aeb3765c6..5a64e44eb 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/archiva.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/archiva.js @@ -96,25 +96,30 @@ $.ajax({ "archiva.search": "archiva/search", "archiva.proxy-connectors-rules": "archiva/proxy-connectors-rules", "archiva.docs": "archiva/docs", - "archiva.main": "archiva/main" + "archiva.main": "archiva/main", + "archiva.knockout.properties": "archiva/knockout-properties" } }); - requirejs(['jquery','jquery.tmpl','jquery.ui','i18n','sammy','startup','utils','domReady!','archiva.main'], function () { + requirejs(['jquery','jquery.tmpl','jquery.ui','i18n','sammy','startup','utils','domReady!','archiva.main','archiva.general-admin'], function () { loadi18n(function () { $.ajax({ url: "restServices/archivaUiServices/runtimeInfoService/archivaRuntimeInfo/"+usedLang(), dataType: 'json', success:function(data){ - window.archivaDevMode=data.devMode; - window.archivaJavascriptLog=data.javascriptLog; - window.archivaRuntimeInfo=data; + window.archivaDevMode=data.devMode; + window.archivaJavascriptLog=data.javascriptLog; + window.archivaRuntimeInfo=data; - require(['sammy','jquery','i18n','jquery.tmpl','archiva.main','utils','domReady!'],function () { - startArchivaApplication(); - $("#loadingDiv").hide(); - drawQuickSearchAutocomplete(); - }) + window.redbackRuntimeConfiguration=mapRedbackRuntimeConfiguration(data.redbackRuntimeConfiguration); + + $.log("security.rememberme.enabled key value:"+ window.redbackRuntimeConfiguration.findPropertyValue('security.rememberme.enabled')); + + require(['sammy','jquery','i18n','jquery.tmpl','archiva.main','utils','domReady!'],function () { + startArchivaApplication(); + $("#loadingDiv").hide(); + drawQuickSearchAutocomplete(); + }) } }) }); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js index 5675b3d77..8dc355f7a 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js @@ -17,7 +17,7 @@ * under the License. */ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout","knockout.simpleGrid", - "knockout.sortable","jquery.validate","bootstrap"] + "knockout.sortable","jquery.validate","bootstrap","archiva.knockout.properties"] , function(jquery,i18n,utils,jqueryTmpl,ko) { //------------------------- @@ -1169,6 +1169,16 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout" self.modified(true); $.log("configurationPropertiesEntries modified") }); + + this.findPropertyValue=function(key){ + for(var i=0;i" + val); + return val; + } + } + } } mapRedbackRuntimeConfiguration=function(data){ @@ -1252,6 +1262,24 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout" this.usedUserManagerImpls=ko.observableArray([]); + self.gridViewModel = new ko.simpleGrid.viewModel({ + data: self.redbackRuntimeConfiguration().configurationPropertiesEntries, + columns: [ + { + headerText: $.i18n.prop('redback.runtime.properties.key.label'), + rowText: "key" + }, + { + headerText: $.i18n.prop('redback.runtime.properties.value.label'), + rowText: "value" + } + ], + pageSize: 10,//self.redbackRuntimeConfiguration().configurationPropertiesEntries.length, + gridUpdateCallBack: function(){ + + } + }); + findUserManagerImplementationInformation=function(id){ for(var i= 0;i tag) - put directly in global namespace - factory(window.ko, jQuery); - } - })(function ($,ko,utils,i18n) { - - - ko.simpleGrid = { - // Defines a view model class you can use to populate a grid - viewModel: function (configuration) { - this.data = configuration.data; - this.currentPageIndex = ko.observable(0); - this.pageSize = configuration.pageSize || 5; - this.columns = configuration.columns; - - this.itemsOnCurrentPage = ko.computed(function () { - var startIndex = this.pageSize * this.currentPageIndex(); - return this.data.slice(startIndex, startIndex + this.pageSize); - }, this); - - this.maxPageIndex = ko.computed(function () { - return Math.ceil(ko.utils.unwrapObservable(this.data).length / this.pageSize); - }, this); - this.i18n=function(key){ - return $.i18n.prop(key); - }; - this.gridUpdateCallBack = configuration.gridUpdateCallBack; - this.pageLinksUpdateCallBack = configuration.pageLinksUpdateCallBack; - - } +(function(factory) { + if (typeof define === "function" && define.amd) { + // AMD anonymous module + define("knockout.simpleGrid",["jquery","knockout","utils","i18n"], factory); + } else { + // No module loader (plain - @@ -1013,44 +1013,46 @@
-
- - - - - - - - - - {{each(i, property) redbackRuntimeConfiguration().configurationPropertiesEntries}} - - - - - - {{/each}} - +
+
${$.i18n.prop('redback.runtime.properties.key.label')}${$.i18n.prop('redback.runtime.properties.value.label')}
- {{var key = property.key}} - - - -
+
+ id="redback-runtime-configuration-save"class="btn">${$.i18n.prop('save')}
- diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/redback/login.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/redback/login.html index 0baa26089..6e036cc17 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/redback/login.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/redback/login.html @@ -47,7 +47,7 @@