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 javax.xml.bind.annotation.XmlRootElement;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Olivier Lamy
|
* @author Olivier Lamy
|
||||||
* @since 1.4-M4
|
* @since 1.4-M4
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(name = "redbackRuntimeConfiguration")
|
@XmlRootElement( name = "redbackRuntimeConfiguration" )
|
||||||
public class ArchivaRuntimeConfiguration
|
public class ArchivaRuntimeConfiguration
|
||||||
implements Serializable
|
implements Serializable
|
||||||
{
|
{
|
||||||
|
@ -42,6 +44,11 @@ public class ArchivaRuntimeConfiguration
|
||||||
|
|
||||||
private Map<String, String> configurationProperties;
|
private Map<String, String> configurationProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* field to ease json mapping wrapper on <code>configurationProperties</code> field
|
||||||
|
*/
|
||||||
|
private List<PropertyEntry> configurationPropertiesEntries;
|
||||||
|
|
||||||
public ArchivaRuntimeConfiguration()
|
public ArchivaRuntimeConfiguration()
|
||||||
{
|
{
|
||||||
// no op
|
// no op
|
||||||
|
@ -91,6 +98,29 @@ public class ArchivaRuntimeConfiguration
|
||||||
this.configurationProperties = configurationProperties;
|
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
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,9 @@ package org.apache.archiva.admin.model.beans;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,6 +83,11 @@ public class LdapConfiguration
|
||||||
*/
|
*/
|
||||||
private Map<String, String> extraProperties = new HashMap<String, String>();
|
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()
|
public LdapConfiguration()
|
||||||
{
|
{
|
||||||
// no op
|
// no op
|
||||||
|
@ -185,4 +192,26 @@ public class LdapConfiguration
|
||||||
{
|
{
|
||||||
this.bindAuthenticatorEnabled = bindAuthenticatorEnabled;
|
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 =
|
ArchivaRuntimeConfiguration archivaRuntimeConfiguration =
|
||||||
new BeanReplicator().replicateBean( runtimeConfiguration, ArchivaRuntimeConfiguration.class );
|
new BeanReplicator().replicateBean( runtimeConfiguration, ArchivaRuntimeConfiguration.class );
|
||||||
|
|
||||||
|
if ( runtimeConfiguration.getLdapConfiguration() != null )
|
||||||
|
{
|
||||||
|
archivaRuntimeConfiguration.setLdapConfiguration(
|
||||||
|
new BeanReplicator().replicateBean( runtimeConfiguration.getLdapConfiguration(),
|
||||||
|
LdapConfiguration.class ) );
|
||||||
|
}
|
||||||
|
|
||||||
if ( archivaRuntimeConfiguration.getLdapConfiguration() == null )
|
if ( archivaRuntimeConfiguration.getLdapConfiguration() == null )
|
||||||
{
|
{
|
||||||
// prevent NPE
|
// 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.userManagerImpl=ko.observable(userManagerImpl);
|
||||||
this.archivaLdapConfiguration=ko.observable(archivaLdapConfiguration);
|
this.ldapConfiguration=ko.observable(ldapConfiguration);
|
||||||
this.migratedFromRedbackConfiguration=ko.observable(migratedFromRedbackConfiguration);
|
this.migratedFromRedbackConfiguration=ko.observable(migratedFromRedbackConfiguration);
|
||||||
this.configurationProperties=ko.observableArray(configurationProperties?configurationProperties:[]);
|
this.configurationPropertiesEntries=ko.observableArray(configurationPropertiesEntries?configurationPropertiesEntries:[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
mapArchivaRuntimeConfiguration=function(data){
|
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);
|
return new Entry(item.key, item.value);
|
||||||
});
|
});
|
||||||
if (!$.isArray(configurationProperties)){
|
if (!$.isArray(configurationPropertiesEntries)){
|
||||||
configurationProperties=[];
|
configurationPropertiesEntries=[];
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ArchivaRuntimeConfiguration(data.userManagerImpl,mapLdapConfiguration(data.ldapConfiguration),data.migratedFromRedbackConfiguration,
|
return new ArchivaRuntimeConfiguration(data.userManagerImpl,mapLdapConfiguration(data.ldapConfiguration),data.migratedFromRedbackConfiguration,
|
||||||
configurationProperties);
|
configurationPropertiesEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
LdapConfiguration=function(hostName,port,ssl,baseDn,contextFactory,bindDn,password,authenticationMethod,
|
LdapConfiguration=function(hostName,port,ssl,baseDn,contextFactory,bindDn,password,authenticationMethod,
|
||||||
extraProperties){
|
extraPropertiesEntries){
|
||||||
//private String hostName;
|
//private String hostName;
|
||||||
this.hostName=ko.observable(hostName);
|
this.hostName=ko.observable(hostName);
|
||||||
|
|
||||||
|
@ -1197,20 +1197,19 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
//private String authenticationMethod;
|
//private String authenticationMethod;
|
||||||
this.authenticationMethod=ko.observable(authenticationMethod);
|
this.authenticationMethod=ko.observable(authenticationMethod);
|
||||||
|
|
||||||
//private Map<String, String> extraProperties = new HashMap<String, String>();
|
this.extraPropertiesEntries=ko.observableArray(extraPropertiesEntries);
|
||||||
this.extraProperties=ko.observableArray(extraProperties);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mapLdapConfiguration=function(data){
|
mapLdapConfiguration=function(data){
|
||||||
if(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);
|
return new Entry(item.key, item.value);
|
||||||
});
|
});
|
||||||
if (!$.isArray(extraProperties)){
|
if (!$.isArray(extraPropertiesEntries)){
|
||||||
extraProperties=[];
|
extraPropertiesEntries=[];
|
||||||
}
|
}
|
||||||
return new ArchivaLdapConfiguration(data.hostName,data.port,data.ssl,data.baseDn,data.contextFactory,data.bindDn,data.password,
|
return new LdapConfiguration(data.hostName,data.port,data.ssl,data.baseDn,data.contextFactory,data.bindDn,data.password,
|
||||||
data.authenticationMethod,extraProperties);
|
data.authenticationMethod,extraPropertiesEntries);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue