mirror of https://github.com/apache/archiva.git
fix bean mapping BeanReplicator does not replicate automatically object field
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1418347 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
69f428af71
commit
37612ad4f9
|
@ -20,14 +20,16 @@ package org.apache.archiva.admin.model.beans;
|
|||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Olivier Lamy
|
||||
* @since 1.4-M4
|
||||
*/
|
||||
@XmlRootElement(name = "redbackRuntimeConfiguration")
|
||||
@XmlRootElement( name = "redbackRuntimeConfiguration" )
|
||||
public class ArchivaRuntimeConfiguration
|
||||
implements Serializable
|
||||
{
|
||||
|
@ -42,6 +44,11 @@ public class ArchivaRuntimeConfiguration
|
|||
|
||||
private Map<String, String> configurationProperties;
|
||||
|
||||
/**
|
||||
* field to ease json mapping wrapper on <code>configurationProperties</code> field
|
||||
*/
|
||||
private List<PropertyEntry> configurationPropertiesEntries;
|
||||
|
||||
public ArchivaRuntimeConfiguration()
|
||||
{
|
||||
// no op
|
||||
|
@ -91,6 +98,29 @@ public class ArchivaRuntimeConfiguration
|
|||
this.configurationProperties = configurationProperties;
|
||||
}
|
||||
|
||||
public List<PropertyEntry> getConfigurationPropertiesEntries()
|
||||
{
|
||||
configurationPropertiesEntries = new ArrayList<PropertyEntry>( getConfigurationProperties().size() );
|
||||
for ( Map.Entry<String, String> entry : getConfigurationProperties().entrySet() )
|
||||
{
|
||||
configurationPropertiesEntries.add( new PropertyEntry( entry.getKey(), entry.getValue() ) );
|
||||
}
|
||||
return configurationPropertiesEntries;
|
||||
}
|
||||
|
||||
public void setConfigurationPropertiesEntries( List<PropertyEntry> configurationPropertiesEntries )
|
||||
{
|
||||
this.configurationPropertiesEntries = configurationPropertiesEntries;
|
||||
if ( configurationPropertiesEntries != null )
|
||||
{
|
||||
this.configurationProperties = new HashMap<String, String>( configurationPropertiesEntries.size() );
|
||||
for ( PropertyEntry propertyEntry : configurationPropertiesEntries )
|
||||
{
|
||||
this.configurationProperties.put( propertyEntry.getKey(), propertyEntry.getValue() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
@ -19,7 +19,9 @@ package org.apache.archiva.admin.model.beans;
|
|||
*/
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -81,6 +83,11 @@ public class LdapConfiguration
|
|||
*/
|
||||
private Map<String, String> extraProperties = new HashMap<String, String>();
|
||||
|
||||
/**
|
||||
* field to ease json mapping wrapper on <code>extraProperties</code> field
|
||||
*/
|
||||
private List<PropertyEntry> extraPropertiesEntries;
|
||||
|
||||
public LdapConfiguration()
|
||||
{
|
||||
// no op
|
||||
|
@ -185,4 +192,26 @@ public class LdapConfiguration
|
|||
{
|
||||
this.bindAuthenticatorEnabled = bindAuthenticatorEnabled;
|
||||
}
|
||||
|
||||
public List<PropertyEntry> getExtraPropertiesEntries()
|
||||
{
|
||||
extraPropertiesEntries = new ArrayList<PropertyEntry>( getExtraProperties().size() );
|
||||
for ( Map.Entry<String, String> entry : getExtraProperties().entrySet() )
|
||||
{
|
||||
extraPropertiesEntries.add( new PropertyEntry( entry.getKey(), entry.getValue() ) );
|
||||
}
|
||||
return extraPropertiesEntries;
|
||||
}
|
||||
|
||||
public void setExtraPropertiesEntries( List<PropertyEntry> extraPropertiesEntries )
|
||||
{
|
||||
this.extraPropertiesEntries = extraPropertiesEntries;
|
||||
if ( extraPropertiesEntries != null )
|
||||
{
|
||||
for ( PropertyEntry propertyEntry : extraPropertiesEntries )
|
||||
{
|
||||
this.extraProperties.put( propertyEntry.getKey(), propertyEntry.getValue() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,6 +142,13 @@ public class DefaultArchivaRuntimeConfigurationAdmin
|
|||
ArchivaRuntimeConfiguration archivaRuntimeConfiguration =
|
||||
new BeanReplicator().replicateBean( runtimeConfiguration, ArchivaRuntimeConfiguration.class );
|
||||
|
||||
if ( runtimeConfiguration.getLdapConfiguration() != null )
|
||||
{
|
||||
archivaRuntimeConfiguration.setLdapConfiguration(
|
||||
new BeanReplicator().replicateBean( runtimeConfiguration.getLdapConfiguration(),
|
||||
LdapConfiguration.class ) );
|
||||
}
|
||||
|
||||
if ( archivaRuntimeConfiguration.getLdapConfiguration() == null )
|
||||
{
|
||||
// prevent NPE
|
||||
|
|
|
@ -1151,28 +1151,28 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
|||
}
|
||||
|
||||
|
||||
ArchivaRuntimeConfiguration=function(userManagerImpl,archivaLdapConfiguration,migratedFromRedbackConfiguration,configurationProperties){
|
||||
ArchivaRuntimeConfiguration=function(userManagerImpl,ldapConfiguration,migratedFromRedbackConfiguration,configurationPropertiesEntries){
|
||||
this.userManagerImpl=ko.observable(userManagerImpl);
|
||||
this.archivaLdapConfiguration=ko.observable(archivaLdapConfiguration);
|
||||
this.ldapConfiguration=ko.observable(ldapConfiguration);
|
||||
this.migratedFromRedbackConfiguration=ko.observable(migratedFromRedbackConfiguration);
|
||||
this.configurationProperties=ko.observableArray(configurationProperties?configurationProperties:[]);
|
||||
this.configurationPropertiesEntries=ko.observableArray(configurationPropertiesEntries?configurationPropertiesEntries:[]);
|
||||
}
|
||||
|
||||
mapArchivaRuntimeConfiguration=function(data){
|
||||
|
||||
var configurationProperties = data.configurationProperties == null ? []: $.each(data.configurationProperties,function(item){
|
||||
var configurationPropertiesEntries = data.configurationPropertiesEntries == null ? []: $.each(data.configurationPropertiesEntries,function(item){
|
||||
return new Entry(item.key, item.value);
|
||||
});
|
||||
if (!$.isArray(configurationProperties)){
|
||||
configurationProperties=[];
|
||||
if (!$.isArray(configurationPropertiesEntries)){
|
||||
configurationPropertiesEntries=[];
|
||||
}
|
||||
|
||||
return new ArchivaRuntimeConfiguration(data.userManagerImpl,mapLdapConfiguration(data.ldapConfiguration),data.migratedFromRedbackConfiguration,
|
||||
configurationProperties);
|
||||
configurationPropertiesEntries);
|
||||
}
|
||||
|
||||
LdapConfiguration=function(hostName,port,ssl,baseDn,contextFactory,bindDn,password,authenticationMethod,
|
||||
extraProperties){
|
||||
extraPropertiesEntries){
|
||||
//private String hostName;
|
||||
this.hostName=ko.observable(hostName);
|
||||
|
||||
|
@ -1197,20 +1197,19 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
|||
//private String authenticationMethod;
|
||||
this.authenticationMethod=ko.observable(authenticationMethod);
|
||||
|
||||
//private Map<String, String> extraProperties = new HashMap<String, String>();
|
||||
this.extraProperties=ko.observableArray(extraProperties);
|
||||
this.extraPropertiesEntries=ko.observableArray(extraPropertiesEntries);
|
||||
}
|
||||
|
||||
mapLdapConfiguration=function(data){
|
||||
if(data){
|
||||
var extraProperties = data.extraProperties == null ? []: $.each(data.extraProperties,function(item){
|
||||
var extraPropertiesEntries = data.extraPropertiesEntries == null ? []: $.each(data.extraPropertiesEntries,function(item){
|
||||
return new Entry(item.key, item.value);
|
||||
});
|
||||
if (!$.isArray(extraProperties)){
|
||||
extraProperties=[];
|
||||
if (!$.isArray(extraPropertiesEntries)){
|
||||
extraPropertiesEntries=[];
|
||||
}
|
||||
return new ArchivaLdapConfiguration(data.hostName,data.port,data.ssl,data.baseDn,data.contextFactory,data.bindDn,data.password,
|
||||
data.authenticationMethod,extraProperties);
|
||||
return new LdapConfiguration(data.hostName,data.port,data.ssl,data.baseDn,data.contextFactory,data.bindDn,data.password,
|
||||
data.authenticationMethod,extraPropertiesEntries);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue