[MRM-1714] using LDAP can be configurable with the ui

add beans

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1412882 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-11-23 13:30:44 +00:00
parent d6c925094a
commit 6e7126ba3c
5 changed files with 287 additions and 0 deletions

View File

@ -0,0 +1,48 @@
package org.apache.archiva.admin.model.beans;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
/**
* @author Olivier Lamy
* @since 1.4-M4
*/
@XmlRootElement ( name = "archivaRuntimeConfiguration" )
public class ArchivaRuntimeConfiguration
implements Serializable
{
private String userManagerImpl = "jdo";
public ArchivaRuntimeConfiguration()
{
// no op
}
public String getUserManagerImpl()
{
return userManagerImpl;
}
public void setUserManagerImpl( String userManagerImpl )
{
this.userManagerImpl = userManagerImpl;
}
}

View File

@ -0,0 +1,36 @@
package org.apache.archiva.admin.model.runtime;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
/**
* @author Olivier Lamy
* @since 1.4-M4
*/
public interface ArchivaRuntimeConfigurationAdmin
{
ArchivaRuntimeConfiguration getArchivaRuntimeConfigurationAdmin()
throws RepositoryAdminException;
void updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration )
throws RepositoryAdminException;
}

View File

@ -0,0 +1,81 @@
package org.apache.archiva.admin.repository.runtime;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.archiva.admin.model.RepositoryAdminException;
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.Configuration;
import org.apache.archiva.configuration.IndeterminateConfigurationException;
import org.apache.archiva.configuration.RuntimeConfiguration;
import org.apache.archiva.redback.components.registry.RegistryException;
import org.springframework.stereotype.Service;
/**
* @author Olivier Lamy
* @since 1.4-M4
*/
@Service ( "archivaRuntimeConfigurationAdmin#default" )
public class DefaultArchivaRuntimeConfigurationAdmin
extends AbstractRepositoryAdmin
implements ArchivaRuntimeConfigurationAdmin
{
public ArchivaRuntimeConfiguration getArchivaRuntimeConfigurationAdmin()
throws RepositoryAdminException
{
return build( getArchivaConfiguration().getConfiguration().getRuntimeConfiguration() );
}
public void updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration )
throws RepositoryAdminException
{
RuntimeConfiguration runtimeConfiguration = build( archivaRuntimeConfiguration );
Configuration configuration = getArchivaConfiguration().getConfiguration();
configuration.setRuntimeConfiguration( runtimeConfiguration );
try
{
getArchivaConfiguration().save( configuration );
}
catch ( RegistryException e )
{
throw new RepositoryAdminException( e.getMessage(), e );
}
catch ( IndeterminateConfigurationException e )
{
throw new RepositoryAdminException( e.getMessage(), e );
}
}
private ArchivaRuntimeConfiguration build( RuntimeConfiguration runtimeConfiguration )
{
ArchivaRuntimeConfiguration archivaRuntimeConfiguration = new ArchivaRuntimeConfiguration();
archivaRuntimeConfiguration.setUserManagerImpl( runtimeConfiguration.getUserManagerImpl() );
return archivaRuntimeConfiguration;
}
private RuntimeConfiguration build( ArchivaRuntimeConfiguration archivaRuntimeConfiguration )
{
RuntimeConfiguration runtimeConfiguration = new RuntimeConfiguration();
runtimeConfiguration.setUserManagerImpl( archivaRuntimeConfiguration.getUserManagerImpl() );
return runtimeConfiguration;
}
}

View File

@ -0,0 +1,53 @@
package org.apache.archiva.rest.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
import org.apache.archiva.redback.authorization.RedbackAuthorization;
import org.apache.archiva.security.common.ArchivaRoleConstants;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
/**
* @author Olivier Lamy
* @since 1.4-M4
*/
@Path ( "/archivaRuntimeConfigurationService/" )
public interface ArchivaRuntimeConfigurationService
{
@Path ( "archivaRuntimeConfiguration" )
@GET
@Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
@RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
ArchivaRuntimeConfiguration getArchivaRuntimeConfigurationAdmin()
throws ArchivaRestServiceException;
@Path ( "archivaRuntimeConfiguration" )
@PUT
@Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
@Consumes ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
@RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
Boolean updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration )
throws ArchivaRestServiceException;
}

View File

@ -0,0 +1,69 @@
package org.apache.archiva.rest.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.ArchivaRuntimeConfigurationService;
import org.springframework.stereotype.Service;
import javax.inject.Inject;
/**
* @author Olivier Lamy
* @since 1.4-M4
*/
@Service ( "archivaRuntimeConfigurationService#rest" )
public class DefaultArchivaRuntimeConfigurationService
extends AbstractRestService
implements ArchivaRuntimeConfigurationService
{
@Inject
private ArchivaRuntimeConfigurationAdmin archivaRuntimeConfigurationAdmin;
public ArchivaRuntimeConfiguration getArchivaRuntimeConfigurationAdmin()
throws ArchivaRestServiceException
{
try
{
return archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfigurationAdmin();
}
catch ( RepositoryAdminException e )
{
throw new ArchivaRestServiceException( e.getMessage(), e );
}
}
public Boolean updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration )
throws ArchivaRestServiceException
{
try
{
archivaRuntimeConfigurationAdmin.updateArchivaRuntimeConfiguration( archivaRuntimeConfiguration );
}
catch ( RepositoryAdminException e )
{
throw new ArchivaRestServiceException( e.getMessage(), e );
}
}
}