]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1714] using LDAP can be configurable with the ui
authorOlivier Lamy <olamy@apache.org>
Fri, 23 Nov 2012 13:30:44 +0000 (13:30 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 23 Nov 2012 13:30:44 +0000 (13:30 +0000)
add beans

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1412882 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ArchivaRuntimeConfiguration.java [new file with mode: 0644]
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/runtime/ArchivaRuntimeConfigurationAdmin.java [new file with mode: 0644]
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultArchivaRuntimeConfigurationAdmin.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRuntimeConfigurationService.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java [new file with mode: 0644]

diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ArchivaRuntimeConfiguration.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ArchivaRuntimeConfiguration.java
new file mode 100644 (file)
index 0000000..b7a467b
--- /dev/null
@@ -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;
+    }
+}
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/runtime/ArchivaRuntimeConfigurationAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/runtime/ArchivaRuntimeConfigurationAdmin.java
new file mode 100644 (file)
index 0000000..5139f97
--- /dev/null
@@ -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;
+
+}
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultArchivaRuntimeConfigurationAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultArchivaRuntimeConfigurationAdmin.java
new file mode 100644 (file)
index 0000000..76e33f9
--- /dev/null
@@ -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;
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRuntimeConfigurationService.java
new file mode 100644 (file)
index 0000000..1b3e6b3
--- /dev/null
@@ -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;
+}
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java
new file mode 100644 (file)
index 0000000..b3ab173
--- /dev/null
@@ -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 );
+        }
+    }
+}
+
+