import org.apache.archiva.common.utils.VersionComparator;
import org.apache.archiva.common.utils.VersionUtil;
import org.apache.archiva.maven2.metadata.MavenMetadataReader;
+import org.apache.archiva.maven2.model.Artifact;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.MetadataRepositoryException;
import org.apache.archiva.repository.scanner.RepositoryScanStatistics;
import org.apache.archiva.repository.scanner.RepositoryScanner;
import org.apache.archiva.repository.scanner.RepositoryScannerException;
-import org.apache.archiva.maven2.model.Artifact;
import org.apache.archiva.rest.api.model.ArtifactTransferRequest;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.RepositoriesService;
* @author Olivier Lamy
* @since 1.4-M1
*/
-@Service( "repositoriesService#rest" )
+@Service ( "repositoriesService#rest" )
public class DefaultRepositoriesService
extends AbstractRestService
implements RepositoriesService
private Logger log = LoggerFactory.getLogger( getClass() );
@Inject
- @Named( value = "archivaTaskScheduler#repository" )
+ @Named ( value = "archivaTaskScheduler#repository" )
private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
@Inject
- @Named( value = "taskExecutor#indexing" )
+ @Named ( value = "taskExecutor#indexing" )
private ArchivaIndexingTaskExecutor archivaIndexingTaskExecutor;
@Inject
private RepositoryContentFactory repositoryFactory;
@Inject
- @Named( value = "archivaTaskScheduler#repository" )
+ @Named ( value = "archivaTaskScheduler#repository" )
private ArchivaTaskScheduler scheduler;
@Inject
private DownloadRemoteIndexScheduler downloadRemoteIndexScheduler;
@Inject
- @Named( value = "repositorySessionFactory" )
+ @Named ( value = "repositorySessionFactory" )
protected RepositorySessionFactory repositorySessionFactory;
@Inject
throw new ArchivaRestServiceException( "artifact.groupId cannot be null", 400, null );
}
+ RepositorySession repositorySession = repositorySessionFactory.createSession();
+
try
{
ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent( repositoryId );
repository.deleteGroupId( groupId );
+ MetadataRepository metadataRepository = repositorySession.getRepository();
+
+ metadataRepository.removeNamespace( repositoryId, groupId );
+
+ metadataRepository.save();
+ }
+ catch ( MetadataRepositoryException e )
+ {
+ log.error( e.getMessage(), e );
+ throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
}
catch ( RepositoryException e )
{
log.error( e.getMessage(), e );
throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
}
+ finally
+ {
+
+ repositorySession.close();
+ }
return true;
}
assertTrue( "directory not exists", directory.exists() );
RepositoriesService repositoriesService = getRepositoriesService( authorizationHeader );
- repositoriesService.deleteGroupId( "org.apache.karaf.features", SOURCE_REPO_ID );
+ repositoriesService.deleteGroupId( "org.apache.karaf", SOURCE_REPO_ID );
assertFalse( "directory not exists", directory.exists() );
Assertions.assertThat( browseResult.getBrowseResultEntries() ).isNotNull().isEmpty();
- log.info( "browseResult: {}", browseResult );
+ browseResult = browseService.browseGroupId( "org.apache.karaf", SOURCE_REPO_ID );
+
+ assertNotNull( browseResult );
+
+ Assertions.assertThat( browseResult.getBrowseResultEntries() ).isNotNull().isEmpty();
+
+ log.info( "browseResult empty: {}", browseResult );
}
finally
{
}
}
+ public void removeNamespace( String repositoryId, String projectId )
+ throws MetadataRepositoryException
+ {
+ try
+ {
+ Node root = getJcrSession().getRootNode();
+ String path = getNamespacePath( repositoryId, projectId );
+ if ( root.hasNode( path ) )
+ {
+ Node node = root.getNode( path );
+ if ( node.isNodeType( NAMESPACE_NODE_TYPE ) )
+ {
+ node.remove();
+ }
+ }
+ }
+ catch ( RepositoryException e )
+ {
+ throw new MetadataRepositoryException( e.getMessage(), e );
+ }
+ }
+
public void removeMetadataFacets( String repositoryId, String facetId )
throws MetadataRepositoryException
{