* under the License.
*/
+import org.apache.archiva.admin.AuditInformation;
import org.apache.archiva.admin.repository.RepositoryAdminException;
import java.util.List;
List<LegacyArtifactPath> getLegacyArtifactPaths()
throws RepositoryAdminException;
- void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath )
+ void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath, AuditInformation auditInformation )
throws RepositoryAdminException;
- void deleteLegacyArtifactPath( String path )
+ void deleteLegacyArtifactPath( String path, AuditInformation auditInformation )
throws RepositoryAdminException;
}
*/
import net.sf.beanlib.provider.replicator.BeanReplicator;
+import org.apache.archiva.admin.AuditInformation;
import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
import org.apache.archiva.admin.repository.RepositoryAdminException;
import org.apache.maven.archiva.configuration.Configuration;
/**
* @author Olivier Lamy
*/
-@Service("archivaAdministration#default")
+@Service( "archivaAdministration#default" )
public class DefaultArchivaAdministration
extends AbstractRepositoryAdmin
implements ArchivaAdministration
return legacyArtifactPaths;
}
- public void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath )
+ public void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath, AuditInformation auditInformation )
throws RepositoryAdminException
{
Configuration configuration = getArchivaConfiguration().getConfiguration();
saveConfiguration( configuration );
}
- public void deleteLegacyArtifactPath( String path )
+ public void deleteLegacyArtifactPath( String path, AuditInformation auditInformation )
throws RepositoryAdminException
{
Configuration configuration = getArchivaConfiguration().getConfiguration();
int initialSize = archivaAdministration.getLegacyArtifactPaths().size();
LegacyArtifactPath legacyArtifactPath = new LegacyArtifactPath( "foo", "bar" );
- archivaAdministration.addLegacyArtifactPath( legacyArtifactPath );
+ archivaAdministration.addLegacyArtifactPath( legacyArtifactPath, getFakeAuditInformation() );
assertTrue( archivaAdministration.getLegacyArtifactPaths().contains( new LegacyArtifactPath( "foo", "bar" ) ) );
assertEquals( initialSize + 1, archivaAdministration.getLegacyArtifactPaths().size() );
- archivaAdministration.deleteLegacyArtifactPath( legacyArtifactPath.getPath() );
+ archivaAdministration.deleteLegacyArtifactPath( legacyArtifactPath.getPath(), getFakeAuditInformation() );
assertFalse(
archivaAdministration.getLegacyArtifactPaths().contains( new LegacyArtifactPath( "foo", "bar" ) ) );
--- /dev/null
+package org.apache.archiva.rest.api.model;
+/*
+ * 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
+ */
+@XmlRootElement( name = "legacyArtifactPath" )
+public class LegacyArtifactPath
+ implements Serializable
+{
+ /**
+ * The legacy path.
+ */
+ private String path;
+
+ /**
+ * The artifact reference, as " [groupId] :
+ * [artifactId] : [version] : [classifier] : [type] ".
+ */
+ private String artifact;
+
+ public LegacyArtifactPath()
+ {
+ // no op
+ }
+
+ public LegacyArtifactPath( String path, String artifact )
+ {
+ this.path = path;
+ this.artifact = artifact;
+ }
+
+ public String getPath()
+ {
+ return path;
+ }
+
+ public void setPath( String path )
+ {
+ this.path = path;
+ }
+
+ public String getArtifact()
+ {
+ return artifact;
+ }
+
+ public void setArtifact( String artifact )
+ {
+ this.artifact = artifact;
+ }
+
+ public boolean match( String path )
+ {
+ return path.equals( this.path );
+ }
+
+ public String getGroupId()
+ {
+ return artifact.split( ":" )[0];
+ }
+
+ public String getArtifactId()
+ {
+ return artifact.split( ":" )[1];
+ }
+
+ public String getVersion()
+ {
+ return artifact.split( ":" )[2];
+ }
+
+ public String getClassifier()
+ {
+ String classifier = artifact.split( ":" )[3];
+ return classifier.length() > 0 ? classifier : null;
+ }
+
+ public String getType()
+ {
+ return artifact.split( ":" )[4];
+ }
+}
--- /dev/null
+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.repository.RepositoryAdminException;
+import org.apache.archiva.rest.api.model.LegacyArtifactPath;
+import org.apache.archiva.security.common.ArchivaRoleConstants;
+import org.codehaus.plexus.redback.authorization.RedbackAuthorization;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+@Path( "/archivaAdministrationService/" )
+public interface ArchivaAdministrationService
+{
+ @Path( "getLegacyArtifactPaths" )
+ @GET
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
+ @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
+ List<LegacyArtifactPath> getLegacyArtifactPaths()
+ throws RepositoryAdminException;
+
+ @Path( "addLegacyArtifactPath" )
+ @POST
+ @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
+ @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
+ void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath )
+ throws RepositoryAdminException;
+
+ @Path( "deleteLegacyArtifactPath" )
+ @GET
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
+ @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
+ Boolean deleteLegacyArtifactPath( @QueryParam( "path" ) String path )
+ throws RepositoryAdminException;
+}
--- /dev/null
+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 net.sf.beanlib.provider.replicator.BeanReplicator;
+import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.repository.admin.ArchivaAdministration;
+import org.apache.archiva.rest.api.model.LegacyArtifactPath;
+import org.apache.archiva.rest.api.services.ArchivaAdministrationService;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+@Service( "archivaAdministrationService#default" )
+public class DefaultArchivaAdministrationService
+ extends AbstractRestService
+ implements ArchivaAdministrationService
+{
+ @Inject
+ private ArchivaAdministration archivaAdministration;
+
+ public List<LegacyArtifactPath> getLegacyArtifactPaths()
+ throws RepositoryAdminException
+ {
+ List<LegacyArtifactPath> legacyArtifactPaths = new ArrayList<LegacyArtifactPath>();
+ for ( org.apache.archiva.admin.repository.admin.LegacyArtifactPath legacyArtifactPath : archivaAdministration.getLegacyArtifactPaths() )
+ {
+ legacyArtifactPaths.add(
+ new BeanReplicator().replicateBean( legacyArtifactPath, LegacyArtifactPath.class ) );
+ }
+ return legacyArtifactPaths;
+ }
+
+ public void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath )
+ throws RepositoryAdminException
+ {
+ archivaAdministration.addLegacyArtifactPath( new BeanReplicator().replicateBean( legacyArtifactPath,
+ org.apache.archiva.admin.repository.admin.LegacyArtifactPath.class ),
+ getAuditInformation() );
+ }
+
+ public Boolean deleteLegacyArtifactPath( String path )
+ throws RepositoryAdminException
+ {
+ archivaAdministration.deleteLegacyArtifactPath( path, getAuditInformation() );
+ return Boolean.TRUE;
+ }
+}
<ref bean="repositoryGroupService#rest"/>
<ref bean="proxyConnectorService#rest"/>
<ref bean="networkProxyService#rest"/>
+ <ref bean="archivaAdministrationService#default"/>
</jaxrs:serviceBeans>
<jaxrs:outInterceptors>
import org.apache.archiva.rest.api.model.ManagedRepository;
+import org.apache.archiva.rest.api.services.ArchivaAdministrationService;
import org.apache.archiva.rest.api.services.ManagedRepositoriesService;
import org.apache.archiva.rest.api.services.NetworkProxyService;
import org.apache.archiva.rest.api.services.PingService;
return service;
}
+ protected ArchivaAdministrationService getArchivaAdministrationService()
+ {
+ ArchivaAdministrationService service =
+ JAXRSClientFactory.create( "http://localhost:" + port + "/services/archivaServices/",
+ ArchivaAdministrationService.class );
+
+ WebClient.client( service ).header( "Authorization", authorizationHeader );
+ WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
+ return service;
+ }
+
protected ManagedRepository getTestManagedRepository()
{
String location = new File( FileUtil.getBasedir(), "target/test-repo" ).getAbsolutePath();
--- /dev/null
+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.junit.Test;
+
+/**
+ * @author Olivier Lamy
+ */
+public class ArchivaAdministrationServiceTest
+ extends AbstractArchivaRestTest
+{
+ @Test
+ public void getAllLegacyPaths()
+ throws Exception
+ {
+ assertNotNull( getArchivaAdministrationService().getLegacyArtifactPaths() );
+ assertFalse( getArchivaAdministrationService().getLegacyArtifactPaths().isEmpty() );
+ }
+}
try
{
- getArchivaAdministration().addLegacyArtifactPath( legacyArtifactPath );
+ getArchivaAdministration().addLegacyArtifactPath( legacyArtifactPath, getAuditInformation() );
}
catch ( RepositoryAdminException e )
{
log.info( "remove [" + path + "] from legacy artifact path resolution" );\r
try\r
{\r
- getArchivaAdministration().deleteLegacyArtifactPath( path );\r
+ getArchivaAdministration().deleteLegacyArtifactPath( path, getAuditInformation() );\r
}\r
catch ( RepositoryAdminException e )\r
{\r