* @author Olivier Lamy
* @since 1.4-M4
*/
-@XmlRootElement (name = "archivaRuntimeConfiguration")
+@XmlRootElement(name = "archivaRuntimeConfiguration")
public class ArchivaRuntimeConfiguration
implements Serializable
{
private ArchivaLdapConfiguration archivaLdapConfiguration;
+ /**
+ * flag to know if redback configuration has been checked/migrated.
+ */
+ private boolean migratedFromRedbackConfiguration = false;
+
public ArchivaRuntimeConfiguration()
{
// no op
{
this.archivaLdapConfiguration = archivaLdapConfiguration;
}
+
+ public boolean isMigratedFromRedbackConfiguration()
+ {
+ return migratedFromRedbackConfiguration;
+ }
+
+ public void setMigratedFromRedbackConfiguration( boolean migratedFromRedbackConfiguration )
+ {
+ this.migratedFromRedbackConfiguration = migratedFromRedbackConfiguration;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "ArchivaRuntimeConfiguration{" +
+ "userManagerImpl='" + userManagerImpl + '\'' +
+ ", archivaLdapConfiguration=" + archivaLdapConfiguration +
+ ", migratedFromRedbackConfiguration=" + migratedFromRedbackConfiguration +
+ '}';
+ }
}
* under the License.
*/
+import net.sf.beanlib.provider.replicator.BeanReplicator;
import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ArchivaLdapConfiguration;
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
import org.apache.archiva.configuration.IndeterminateConfigurationException;
import org.apache.archiva.configuration.RuntimeConfiguration;
import org.apache.archiva.redback.components.registry.RegistryException;
+import org.apache.archiva.redback.configuration.UserConfiguration;
+import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Named;
+
/**
* @author Olivier Lamy
* @since 1.4-M4
*/
-@Service ( "archivaRuntimeConfigurationAdmin#default" )
+@Service( "archivaRuntimeConfigurationAdmin#default" )
public class DefaultArchivaRuntimeConfigurationAdmin
extends AbstractRepositoryAdmin
implements ArchivaRuntimeConfigurationAdmin
{
+ @Inject
+ @Named( value = "userConfiguration" )
+ UserConfiguration userConfiguration;
+
+ @PostConstruct
+ public void initialize()
+ throws RepositoryAdminException
+ {
+ ArchivaRuntimeConfiguration archivaRuntimeConfiguration = getArchivaRuntimeConfiguration();
+ // migrate or not data from redback
+ if ( !archivaRuntimeConfiguration.isMigratedFromRedbackConfiguration() )
+ {
+ // so migrate if available
+ String userManagerImpl = userConfiguration.getString( "user.manager.impl" );
+ if ( StringUtils.isNotEmpty( userManagerImpl ) )
+ {
+ archivaRuntimeConfiguration.setUserManagerImpl( userManagerImpl );
+ }
+
+ // now ldap
+
+ ArchivaLdapConfiguration archivaLdapConfiguration =
+ archivaRuntimeConfiguration.getArchivaLdapConfiguration();
+ if ( archivaLdapConfiguration == null )
+ {
+ archivaLdapConfiguration = new ArchivaLdapConfiguration();
+ archivaRuntimeConfiguration.setArchivaLdapConfiguration( archivaLdapConfiguration );
+ }
+
+ archivaLdapConfiguration.setHostName( userConfiguration.getString( "ldap.config.hostname", null ) );
+ archivaLdapConfiguration.setPort( userConfiguration.getInt( "ldap.config.port", -1 ) );
+ archivaLdapConfiguration.setSsl( userConfiguration.getBoolean( "ldap.config.ssl", false ) );
+ archivaLdapConfiguration.setBaseDn( userConfiguration.getConcatenatedList( "ldap.config.base.dn", null ) );
+ archivaLdapConfiguration.setContextFactory(
+ userConfiguration.getString( "ldap.config.context.factory", null ) );
+ archivaLdapConfiguration.setBindDn( userConfiguration.getConcatenatedList( "ldap.config.bind.dn", null ) );
+ archivaLdapConfiguration.setPassword( userConfiguration.getString( "ldap.config.password", null ) );
+ archivaLdapConfiguration.setAuthenticationMethod(
+ userConfiguration.getString( "ldap.config.authentication.method", null ) );
+
+ archivaRuntimeConfiguration.setMigratedFromRedbackConfiguration( true );
+
+ updateArchivaRuntimeConfiguration( archivaRuntimeConfiguration );
+ }
+
+ }
- public ArchivaRuntimeConfiguration getArchivaRuntimeConfigurationAdmin()
+ public ArchivaRuntimeConfiguration getArchivaRuntimeConfiguration()
throws RepositoryAdminException
{
return build( getArchivaConfiguration().getConfiguration().getRuntimeConfiguration() );
private ArchivaRuntimeConfiguration build( RuntimeConfiguration runtimeConfiguration )
{
- ArchivaRuntimeConfiguration archivaRuntimeConfiguration = new ArchivaRuntimeConfiguration();
- archivaRuntimeConfiguration.setUserManagerImpl( runtimeConfiguration.getUserManagerImpl() );
- return archivaRuntimeConfiguration;
+ return new BeanReplicator().replicateBean( runtimeConfiguration, ArchivaRuntimeConfiguration.class );
}
private RuntimeConfiguration build( ArchivaRuntimeConfiguration archivaRuntimeConfiguration )
{
- RuntimeConfiguration runtimeConfiguration = new RuntimeConfiguration();
- runtimeConfiguration.setUserManagerImpl( archivaRuntimeConfiguration.getUserManagerImpl() );
- return runtimeConfiguration;
+ return new BeanReplicator().replicateBean( archivaRuntimeConfiguration, RuntimeConfiguration.class );
}
}
$.log("displayRedbackError with array");
for(var i=0; i<obj.errorMessages.length; i++ ) {
if(obj.errorMessages[i].errorKey) {
- $.log("displayRedbackError with array loop");
displayErrorMessage($.i18n.prop( obj.errorMessages[i].errorKey, obj.errorMessages[i].args ),idToAppend);
}
+ if(obj.errorMessages[i].message) {
+ displayErrorMessage(obj.errorMessages[i].message,idToAppend);
+ }
}
} else {
- $.log("displayRedbackError no array");
displayErrorMessage($.i18n.prop( obj.errorMessages.errorKey, obj.errorMessages.args ),idToAppend);
}
}
displayErrorMessage($.i18n.prop( data.errorKey ),idToAppend);
} else if (data.errorMessages){
$.each(data.errorMessages, function(index, value) {
- displayErrorMessage( $.i18n.prop(data.errorMessages[index].errorKey,data.errorMessages[index].args?data.errorMessages[index].args:null),idToAppend);
+ if(data.errorMessages[index].errorKey) {
+ displayErrorMessage( $.i18n.prop(data.errorMessages[index].errorKey,data.errorMessages[index].args?data.errorMessages[index].args:null),idToAppend);
+ }
});
} else {
$.log("print data.errorMessage:"+data.errorMessage);
// utils javascript string extensions
//------------------------------------
+ String.prototype.isEmpty = function(str) {
+ return ($.trim(this ).length < 1);
+ }
+ String.prototype.isNotEmpty = function(str) {
+ return ($.trim(this ).length > 0);
+ }
+
String.prototype.endsWith = function(str) {
return (this.match(str+"$")==str)
}