archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1400901 - in /archiva/trunk/archiva-modules: archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/ archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/ archiva-web/archiva-...
Date Mon, 22 Oct 2012 14:49:26 GMT
Author: olamy
Date: Mon Oct 22 14:49:23 2012
New Revision: 1400901

URL: http://svn.apache.org/viewvc?rev=1400901&view=rev
Log:
[MRM-1703] Cannot delete project with the ui.

Modified:
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/AbstractDefaultRepositoryContent.java
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/ManagedDefaultRepositoryContent.java
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/ManagedLegacyRepositoryContent.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html
    archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java
    archiva/trunk/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java
    archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java?rev=1400901&r1=1400900&r2=1400901&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java
Mon Oct 22 14:49:23 2012
@@ -32,8 +32,6 @@ import java.util.Set;
 /**
  * ManagedRepositoryContent interface for interacting with a managed repository in an abstract
way,
  * without the need for processing based on filesystem paths, or working with the database.
- *
- *
  */
 public interface ManagedRepositoryContent
 {
@@ -57,14 +55,23 @@ public interface ManagedRepositoryConten
         throws ContentNotFoundException;
 
     /**
-     * @since 1.4-M3
      * @param groupId
      * @throws ContentNotFoundException
+     * @since 1.4-M3
      */
     void deleteGroupId( String groupId )
         throws ContentNotFoundException;
 
     /**
+     *
+     * @param namespace groupId for maven
+     * @param projectId artifactId for maven
+     * @throws ContentNotFoundException
+     */
+    void deleteProject( String namespace, String projectId )
+        throws RepositoryException;
+
+    /**
      * <p>
      * Convenience method to get the repository id.
      * </p>

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/AbstractDefaultRepositoryContent.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/AbstractDefaultRepositoryContent.java?rev=1400901&r1=1400900&r2=1400901&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/AbstractDefaultRepositoryContent.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/AbstractDefaultRepositoryContent.java
Mon Oct 22 14:49:23 2012
@@ -19,16 +19,16 @@ package org.apache.archiva.repository.co
  * under the License.
  */
 
+import org.apache.archiva.common.utils.VersionUtil;
 import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
 import org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider;
 import org.apache.archiva.metadata.repository.storage.maven2.Maven2RepositoryPathTranslator;
-import org.apache.commons.lang.StringUtils;
-import org.apache.archiva.common.utils.VersionUtil;
 import org.apache.archiva.model.ArchivaArtifact;
 import org.apache.archiva.model.ArtifactReference;
 import org.apache.archiva.model.ProjectReference;
 import org.apache.archiva.model.VersionedReference;
 import org.apache.archiva.repository.layout.LayoutException;
+import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -38,8 +38,6 @@ import java.util.List;
 
 /**
  * AbstractDefaultRepositoryContent - common methods for working with default (maven 2) layout.
- *
- *
  */
 public abstract class AbstractDefaultRepositoryContent
 {
@@ -120,9 +118,13 @@ public abstract class AbstractDefaultRep
         {
             throw new IllegalArgumentException( "Artifact reference cannot be null" );
         }
-
-        String baseVersion = VersionUtil.getBaseVersion( reference.getVersion() );
-        return toPath( reference.getGroupId(), reference.getArtifactId(), baseVersion, reference.getVersion(),
+        if ( reference.getVersion() != null )
+        {
+            String baseVersion = VersionUtil.getBaseVersion( reference.getVersion() );
+            return toPath( reference.getGroupId(), reference.getArtifactId(), baseVersion,
reference.getVersion(),
+                           reference.getClassifier(), reference.getType() );
+        }
+        return toPath( reference.getGroupId(), reference.getArtifactId(), null, null,
                        reference.getClassifier(), reference.getType() );
     }
 

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/ManagedDefaultRepositoryContent.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/ManagedDefaultRepositoryContent.java?rev=1400901&r1=1400900&r2=1400901&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/ManagedDefaultRepositoryContent.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/ManagedDefaultRepositoryContent.java
Mon Oct 22 14:49:23 2012
@@ -29,6 +29,7 @@ import org.apache.archiva.model.ProjectR
 import org.apache.archiva.model.VersionedReference;
 import org.apache.archiva.repository.ContentNotFoundException;
 import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.RepositoryException;
 import org.apache.archiva.repository.layout.LayoutException;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
@@ -45,17 +46,15 @@ import java.util.Set;
 
 /**
  * ManagedDefaultRepositoryContent
- *
- *
  */
-@Service( "managedRepositoryContent#default" )
-@Scope( "prototype" )
+@Service ("managedRepositoryContent#default")
+@Scope ("prototype")
 public class ManagedDefaultRepositoryContent
     extends AbstractDefaultRepositoryContent
     implements ManagedRepositoryContent
 {
     @Inject
-    @Named( value = "fileTypes" )
+    @Named (value = "fileTypes")
     private FileTypes filetypes;
 
     private ManagedRepository repository;
@@ -78,6 +77,36 @@ public class ManagedDefaultRepositoryCon
         }
     }
 
+    public void deleteProject( String namespace, String projectId )
+        throws RepositoryException, ContentNotFoundException
+    {
+        ArtifactReference artifactReference = new ArtifactReference();
+        artifactReference.setGroupId( namespace );
+        artifactReference.setArtifactId( projectId );
+        String path = toPath( artifactReference );
+        File directory = new File( getRepoRoot(), path );
+        if ( !directory.exists() )
+        {
+            throw new ContentNotFoundException( "cannot found project " + namespace + ":"
+ projectId );
+        }
+        if ( directory.isDirectory() )
+        {
+            try
+            {
+                FileUtils.deleteDirectory( directory );
+            }
+            catch ( IOException e )
+            {
+                throw new RepositoryException( e.getMessage(), e );
+            }
+        }
+        else
+        {
+            log.warn( "project {}:{} is not a directory", namespace, projectId );
+        }
+
+    }
+
     public void deleteArtifact( ArtifactReference artifactReference )
     {
         String path = toPath( artifactReference );

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/ManagedLegacyRepositoryContent.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/ManagedLegacyRepositoryContent.java?rev=1400901&r1=1400900&r2=1400901&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/ManagedLegacyRepositoryContent.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/ManagedLegacyRepositoryContent.java
Mon Oct 22 14:49:23 2012
@@ -28,6 +28,7 @@ import org.apache.archiva.model.ProjectR
 import org.apache.archiva.model.VersionedReference;
 import org.apache.archiva.repository.ContentNotFoundException;
 import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.RepositoryException;
 import org.apache.archiva.repository.layout.LayoutException;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
@@ -128,6 +129,12 @@ public class ManagedLegacyRepositoryCont
         }
     }
 
+    public void deleteProject( String namespace, String projectId )
+        throws RepositoryException
+    {
+        // TODO implements ??
+    }
+
     private void deleteSupportFiles( File repoFile )
     {
         deleteSupportFile( repoFile, ".sha1" );

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java?rev=1400901&r1=1400900&r2=1400901&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java
Mon Oct 22 14:49:23 2012
@@ -20,13 +20,13 @@ package org.apache.archiva.rest.api.serv
  */
 
 import org.apache.archiva.maven2.model.Artifact;
-import org.apache.archiva.metadata.model.ArtifactMetadata;
 import org.apache.archiva.redback.authorization.RedbackAuthorization;
 import org.apache.archiva.repository.scanner.RepositoryScanStatistics;
 import org.apache.archiva.rest.api.model.ArtifactTransferRequest;
 import org.apache.archiva.security.common.ArchivaRoleConstants;
 
 import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
@@ -34,67 +34,66 @@ import javax.ws.rs.PathParam;
 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-M1
  */
-@Path ( "/repositoriesService/" )
+@Path ("/repositoriesService/")
 public interface RepositoriesService
 {
 
-    @Path ( "scanRepository" )
+    @Path ("scanRepository")
     @GET
-    @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
} )
-    @RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER )
+    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
})
+    @RedbackAuthorization (permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER)
     /**
      * index repository
      */
-    Boolean scanRepository( @QueryParam ( "repositoryId" ) String repositoryId,
-                            @QueryParam ( "fullScan" ) boolean fullScan )
+    Boolean scanRepository( @QueryParam ("repositoryId") String repositoryId,
+                            @QueryParam ("fullScan") boolean fullScan )
         throws ArchivaRestServiceException;
 
 
-    @Path ( "scanRepositoryDirectoriesNow/{repositoryId}" )
+    @Path ("scanRepositoryDirectoriesNow/{repositoryId}")
     @GET
-    @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
} )
-    @RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER )
+    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
})
+    @RedbackAuthorization (permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER)
     /**
      * scan directories
      * @since 1.4-M3
      */
-    RepositoryScanStatistics scanRepositoryDirectoriesNow( @PathParam ( "repositoryId" )
String repositoryId )
+    RepositoryScanStatistics scanRepositoryDirectoriesNow( @PathParam ("repositoryId") String
repositoryId )
         throws ArchivaRestServiceException;
 
 
-    @Path ( "alreadyScanning/{repositoryId}" )
+    @Path ("alreadyScanning/{repositoryId}")
     @GET
-    @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
} )
-    @RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER )
-    Boolean alreadyScanning( @PathParam ( "repositoryId" ) String repositoryId )
+    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
})
+    @RedbackAuthorization (permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER)
+    Boolean alreadyScanning( @PathParam ("repositoryId") String repositoryId )
         throws ArchivaRestServiceException;
 
-    @Path ( "removeScanningTaskFromQueue/{repositoryId}" )
+    @Path ("removeScanningTaskFromQueue/{repositoryId}")
     @GET
-    @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
} )
-    @RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER )
-    Boolean removeScanningTaskFromQueue( @PathParam ( "repositoryId" ) String repositoryId
)
+    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
})
+    @RedbackAuthorization (permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER)
+    Boolean removeScanningTaskFromQueue( @PathParam ("repositoryId") String repositoryId
)
         throws ArchivaRestServiceException;
 
-    @Path ( "scanRepositoryNow" )
+    @Path ("scanRepositoryNow")
     @GET
-    @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
} )
-    @RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER )
-    Boolean scanRepositoryNow( @QueryParam ( "repositoryId" ) String repositoryId,
-                               @QueryParam ( "fullScan" ) boolean fullScan )
+    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
})
+    @RedbackAuthorization (permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER)
+    Boolean scanRepositoryNow( @QueryParam ("repositoryId") String repositoryId,
+                               @QueryParam ("fullScan") boolean fullScan )
         throws ArchivaRestServiceException;
 
-    @Path ( "copyArtifact" )
+    @Path ("copyArtifact")
     @POST
-    @Consumes ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
-    @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
} )
-    @RedbackAuthorization ( noPermission = true )
+    @Consumes ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
})
+    @RedbackAuthorization (noPermission = true)
     /**
      * permissions are checked in impl
      * will copy an artifact from the source repository to the target repository
@@ -102,21 +101,21 @@ public interface RepositoriesService
     Boolean copyArtifact( ArtifactTransferRequest artifactTransferRequest )
         throws ArchivaRestServiceException;
 
-    @Path ( "scheduleDownloadRemoteIndex" )
+    @Path ("scheduleDownloadRemoteIndex")
     @GET
-    @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
} )
-    @RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER )
-    Boolean scheduleDownloadRemoteIndex( @QueryParam ( "repositoryId" ) String repositoryId,
-                                         @QueryParam ( "now" ) boolean now,
-                                         @QueryParam ( "fullDownload" ) boolean fullDownload
)
+    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
})
+    @RedbackAuthorization (permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER)
+    Boolean scheduleDownloadRemoteIndex( @QueryParam ("repositoryId") String repositoryId,
+                                         @QueryParam ("now") boolean now,
+                                         @QueryParam ("fullDownload") boolean fullDownload
)
         throws ArchivaRestServiceException;
 
 
-    @Path ( "deleteArtifact" )
+    @Path ("deleteArtifact")
     @POST
-    @Consumes ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
-    @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
} )
-    @RedbackAuthorization ( noPermission = true )
+    @Consumes ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
})
+    @RedbackAuthorization (noPermission = true)
     /**
      * <b>permissions are checked in impl</b>
      * @since 1.4-M2
@@ -124,25 +123,35 @@ public interface RepositoriesService
     Boolean deleteArtifact( Artifact artifact )
         throws ArchivaRestServiceException;
 
-    @Path ( "isAuthorizedToDeleteArtifacts/{repositoryId}" )
+    @Path ("isAuthorizedToDeleteArtifacts/{repositoryId}")
     @GET
-    @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
} )
-    @RedbackAuthorization ( noPermission = true, noRestriction = true )
-    Boolean isAuthorizedToDeleteArtifacts( @PathParam ( "repositoryId" ) String repoId )
+    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
})
+    @RedbackAuthorization (noPermission = true, noRestriction = true)
+    Boolean isAuthorizedToDeleteArtifacts( @PathParam ("repositoryId") String repoId )
         throws ArchivaRestServiceException;
 
-    @Path ( "deleteGroupId" )
+    @Path ("deleteGroupId")
     @GET
-    @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
} )
-    @RedbackAuthorization ( noPermission = true )
+    @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
})
+    @RedbackAuthorization (noPermission = true)
     /**
      * <b>permissions are checked in impl</b>
      * @since 1.4-M3
      */
-    Boolean deleteGroupId( @QueryParam ( "groupId" ) String groupId,
-                           @QueryParam ( "repositoryId" ) String repositoryId )
+    Boolean deleteGroupId( @QueryParam ("groupId") String groupId, @QueryParam ("repositoryId")
String repositoryId )
         throws ArchivaRestServiceException;
 
+    @Path ( "project/{repositoryId}/{groupId}/{projectId}" )
+    @DELETE
+    @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
} )
+    @RedbackAuthorization ( noPermission = true )
+    /**
+     * <b>permissions are checked in impl</b>
+     * @since 1.4-M4
+     */
+    Boolean deleteProject( @PathParam ( "groupId" ) String groupId, @PathParam ( "projectId"
) String projectId,
+                           @PathParam ( "repositoryId" ) String repositoryId )
+        throws ArchivaRestServiceException;
 
 
 }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java?rev=1400901&r1=1400900&r2=1400901&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
Mon Oct 22 14:49:23 2012
@@ -851,7 +851,7 @@ public class DefaultRepositoriesService
 
         if ( StringUtils.isEmpty( groupId ) )
         {
-            throw new ArchivaRestServiceException( "artifact.groupId cannot be null", 400,
null );
+            throw new ArchivaRestServiceException( "groupId cannot be null", 400, null );
         }
 
         RepositorySession repositorySession = repositorySessionFactory.createSession();
@@ -886,6 +886,70 @@ public class DefaultRepositoriesService
         return true;
     }
 
+    public Boolean deleteProject( String groupId, String projectId, String repositoryId )
+        throws ArchivaRestServiceException
+    {
+        if ( StringUtils.isEmpty( repositoryId ) )
+        {
+            throw new ArchivaRestServiceException( "repositoryId cannot be null", 400, null
);
+        }
+
+        if ( !isAuthorizedToDeleteArtifacts( repositoryId ) )
+        {
+            throw new ArchivaRestServiceException( "not authorized to delete artifacts",
403, null );
+        }
+
+        if ( StringUtils.isEmpty( groupId ) )
+        {
+            throw new ArchivaRestServiceException( "groupId cannot be null", 400, null );
+        }
+
+        if ( StringUtils.isEmpty( projectId ) )
+        {
+            throw new ArchivaRestServiceException( "artifactId cannot be null", 400, null
);
+        }
+
+        RepositorySession repositorySession = repositorySessionFactory.createSession();
+
+        try
+        {
+            ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent(
repositoryId );
+
+            repository.deleteProject( groupId, projectId );
+        }
+        catch ( ContentNotFoundException e )
+        {
+            log.warn( "skip ContentNotFoundException: {}", e.getMessage() );
+        }
+        catch ( RepositoryException e )
+        {
+            log.error( e.getMessage(), e );
+            throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(),
500, e );
+        }
+
+        try
+        {
+
+            MetadataRepository metadataRepository = repositorySession.getRepository();
+
+            metadataRepository.removeProject( repositoryId, groupId, projectId );
+
+            metadataRepository.save();
+        }
+        catch ( MetadataRepositoryException e )
+        {
+            log.error( e.getMessage(), e );
+            throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(),
500, e );
+        }
+        finally
+        {
+
+            repositorySession.close();
+        }
+        return true;
+
+    }
+
     public Boolean isAuthorizedToDeleteArtifacts( String repoId )
         throws ArchivaRestServiceException
     {

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js?rev=1400901&r1=1400900&r2=1400901&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
Mon Oct 22 14:49:23 2012
@@ -176,37 +176,37 @@ function(jquery,ui,sammy,tmpl,i18n,jquer
       
       var self = this;
       this.artifactMenuItems = ko.observableArray([
-              {  text : $.i18n.prop('menu.artifacts') , id: null},
-              {  text : $.i18n.prop('menu.artifacts.search') , id: "menu-find-search-a",
href: "#search" , func: function(){displaySearch(this)}},
-              {  text : $.i18n.prop('menu.artifacts.browse') , id: "menu-find-browse-a",
href: "#browse" , func: function(){displayBrowse(true)}},
-              {  text : $.i18n.prop('menu.artifacts.upload') , id: "menu-find-upload-a",
href: "#upload" , redback: "{permissions: ['archiva-upload-repository']}", func: function(){displayUploadArtifact(true)}}
+        {  text : $.i18n.prop('menu.artifacts') , id: null},
+        {  text : $.i18n.prop('menu.artifacts.search') , id: "menu-find-search-a", href:
"#search" , func: function(){displaySearch(this)}},
+        {  text : $.i18n.prop('menu.artifacts.browse') , id: "menu-find-browse-a", href:
"#browse" , func: function(){displayBrowse(true)}},
+        {  text : $.i18n.prop('menu.artifacts.upload') , id: "menu-find-upload-a", href:
"#upload" , redback: "{permissions: ['archiva-upload-repository']}", func: function(){displayUploadArtifact(true)}}
       ]);
       this.administrationMenuItems = ko.observableArray([
-              {  text : $.i18n.prop('menu.administration') , id: null},
-              {  text : $.i18n.prop('menu.repository.groups')        , id: "menu-repository-groups-list-a"
    , href: "#repositorygroup"  , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayRepositoryGroups()}},
-              {  text : $.i18n.prop('menu.repositories')             , id: "menu-repositories-list-a"
          , href: "#repositorylist"   , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayRepositoriesGrid()}},
-              {  text : $.i18n.prop('menu.proxy-connectors')         , id: "menu-proxy-connectors-list-a"
      , href: "#proxyconnectors"  , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayProxyConnectors()}},
-              {  text : $.i18n.prop('menu.proxy-connectors-rules')   , id: "menu.proxy-connectors-rules-list-a"
, href: "#proxyconnectorsrules" , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayProxyConnectorsRules()}},
-              {  text : $.i18n.prop('menu.network-proxies')          , id: "menu-network-proxies-list-a"
       , href: "#networkproxies"   , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayNetworkProxies()}},
-              {  text : $.i18n.prop('menu.legacy-artifact-support')  , id: "menu-legacy-support-list-a"
        , href: "#legacy"           , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayLegacyArtifactPathSupport()}},
-              {  text : $.i18n.prop('menu.repository-scanning')      , id: "menu-repository-scanning-list-a"
   , href: "#scanningList"     , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayRepositoryScanning()}},
-              {  text : $.i18n.prop('menu.network-configuration')    , id: "menu-network-configuration-list-a"
 , href: "#network"          , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayNetworkConfiguration()}},
-              {  text : $.i18n.prop('menu.system-status')            , id: "menu-system-status-list-a"
         , href: "#status"           , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displaySystemStatus()}},
-              {  text : $.i18n.prop('menu.appearance-configuration') , id: "menu-appearance-list-a"
            , href: "#appearance"       , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayAppearanceConfiguration()}},
-              {  text : $.i18n.prop('menu.ui-configuration')         , id: "menu-ui-configuration-list-a"
      , href: "#uiconfig"         , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayUiConfiguration()}},
-              {  text : $.i18n.prop('menu.reports')                  , id: "menu-report-list-a"
                , href: "#reports"         , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayReportsPage()}}
+        {  text : $.i18n.prop('menu.administration') , id: null},
+        {  text : $.i18n.prop('menu.repository.groups')        , id: "menu-repository-groups-list-a"
    , href: "#repositorygroup"  , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayRepositoryGroups()}},
+        {  text : $.i18n.prop('menu.repositories')             , id: "menu-repositories-list-a"
          , href: "#repositorylist"   , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayRepositoriesGrid()}},
+        {  text : $.i18n.prop('menu.proxy-connectors')         , id: "menu-proxy-connectors-list-a"
      , href: "#proxyconnectors"  , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayProxyConnectors()}},
+        {  text : $.i18n.prop('menu.proxy-connectors-rules')   , id: "menu.proxy-connectors-rules-list-a"
, href: "#proxyconnectorsrules" , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayProxyConnectorsRules()}},
+        {  text : $.i18n.prop('menu.network-proxies')          , id: "menu-network-proxies-list-a"
       , href: "#networkproxies"   , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayNetworkProxies()}},
+        {  text : $.i18n.prop('menu.legacy-artifact-support')  , id: "menu-legacy-support-list-a"
        , href: "#legacy"           , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayLegacyArtifactPathSupport()}},
+        {  text : $.i18n.prop('menu.repository-scanning')      , id: "menu-repository-scanning-list-a"
   , href: "#scanningList"     , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayRepositoryScanning()}},
+        {  text : $.i18n.prop('menu.network-configuration')    , id: "menu-network-configuration-list-a"
 , href: "#network"          , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayNetworkConfiguration()}},
+        {  text : $.i18n.prop('menu.system-status')            , id: "menu-system-status-list-a"
         , href: "#status"           , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displaySystemStatus()}},
+        {  text : $.i18n.prop('menu.appearance-configuration') , id: "menu-appearance-list-a"
            , href: "#appearance"       , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayAppearanceConfiguration()}},
+        {  text : $.i18n.prop('menu.ui-configuration')         , id: "menu-ui-configuration-list-a"
      , href: "#uiconfig"         , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayUiConfiguration()}},
+        {  text : $.i18n.prop('menu.reports')                  , id: "menu-report-list-a"
                , href: "#reports"         , redback: "{permissions: ['archiva-manage-configuration']}",
func: function(){displayReportsPage()}}
       ]);
       
       this.usersMenuItems = ko.observableArray([
-              {  text : $.i18n.prop('menu.users') , id: null},
-              {  text : $.i18n.prop('menu.users.manage')    , id: "menu-users-list-a", href:
"#users" , redback: "{permissions: ['archiva-manage-users']}", func: function(){displayUsersGrid()}},
-              {  text : $.i18n.prop('menu.users.roles')     , id: "menu-roles-list-a", href:
"#roles" , redback: "{permissions: ['archiva-manage-users']}", func: function(){displayRolesGrid()}}
+        {  text : $.i18n.prop('menu.users') , id: null},
+        {  text : $.i18n.prop('menu.users.manage')    , id: "menu-users-list-a", href: "#users"
, redback: "{permissions: ['archiva-manage-users']}", func: function(){displayUsersGrid()}},
+        {  text : $.i18n.prop('menu.users.roles')     , id: "menu-roles-list-a", href: "#roles"
, redback: "{permissions: ['archiva-manage-users']}", func: function(){displayRolesGrid()}}
       ]);
 
       this.docsMenuItems = ko.observableArray([
-              {  text : $.i18n.prop('menu.docs') , id: null},
-              {  text : $.i18n.prop('menu.docs.rest')    , id: "menu-docs-rest-list-a", href:
"#docs-rest", target: "", func: function(){displayRestDocs()}},
-              {  text : $.i18n.prop('menu.docs.users')   , id: "menu-docs-users-list-a",
href: "http://archiva.apache.org/docs/"+window.archivaRuntimeInfo.version, target: "_blank",
func: function(){displayUsersDocs()}}
+        {  text : $.i18n.prop('menu.docs') , id: null},
+        {  text : $.i18n.prop('menu.docs.rest')    , id: "menu-docs-rest-list-a", href: "#docs-rest",
target: "", func: function(){displayRestDocs()}},
+        {  text : $.i18n.prop('menu.docs.users')   , id: "menu-docs-users-list-a", href:
"http://archiva.apache.org/docs/"+window.archivaRuntimeInfo.version, target: "_blank", func:
function(){displayUsersDocs()}}
       ]);
 
       this.activeMenuId = ko.observable();

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js?rev=1400901&r1=1400900&r2=1400901&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
Mon Oct 22 14:49:23 2012
@@ -195,6 +195,7 @@ function(jquery,i18n,jqueryTmpl,bootstra
     }
 
     this.save=function(){
+      $.log('managedrepo save');
       var valid = $("#main-content").find("#managed-repository-edit-form").valid();
       if (valid==false) {
           return;

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js?rev=1400901&r1=1400900&r2=1400901&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
Mon Oct 22 14:49:23 2012
@@ -86,6 +86,55 @@ define("archiva.search",["jquery","i18n"
       return hasKarma('archiva-delete-artifact');
     }
 
+    deleteProject=function(groupId,projectId){
+      $.log("deleteProject:"+groupId+"/"+projectId);
+
+      var repoId=getSelectedBrowsingRepository();
+      if(!repoId){
+        var escapedGroupId=escapeDot(groupId );
+        var selected = $("#main-content" ).find("#delete-"+escapedGroupId );
+        selected.attr("data-content",$.i18n.prop('projectId.delete.missing.repoId'))
+        selected.popover({
+          html:true,
+          template: '<div class="popover"><div class="arrow"></div><div
class="popover-inner"><div class="popover-content"><p></p></div></div></div>',
+          placement:'top',
+          trigger:'manual'});
+        selected.popover('show');
+        selected.mouseover(function(){
+          selected.popover("destroy");
+        });
+        return;
+      }
+
+
+      var previousHash=getUrlHash();
+      $.log("previousHash:"+previousHash);
+      openDialogConfirm(function(){
+        $("#dialog-confirm-modal-ok").button('loading');
+        $.ajax({
+          url:"restServices/archivaServices/repositoriesService/project/"+repoId+"/"+groupId+"/"+projectId,
+          type:"DELETE",
+          dataType:"json",
+          success:function(data){
+            window.sammyArchivaApplication.setLocation(previousHash);
+            refreshContent();
+            displaySuccessMessage( $.i18n.prop("projectId.deleted", groupId,projectId));
+          },
+          error:function(data){
+            displayRestError(data,"user-messages");
+          },
+          complete:function(){
+            $("#dialog-confirm-modal-ok").button('reset');
+            closeDialogConfirm();
+          }
+        });
+      }, $.i18n.prop('ok'),
+          $.i18n.prop('cancel'),
+          $.i18n.prop('projectId.delete.confirm.title'),
+          $.i18n.prop('projectId.delete.confirm.save',groupId));
+      }
+    }
+
     deleteGroupId=function(groupId){
 
       var repoId=getSelectedBrowsingRepository();
@@ -129,7 +178,7 @@ define("archiva.search",["jquery","i18n"
           $.i18n.prop('cancel'),
           $.i18n.prop('groupId.delete.confirm.title'),
           $.i18n.prop('groupId.delete.confirm.save',groupId));
-    }
+
   }
 
   calculateBreadCrumbEntries=function(groupId){

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html?rev=1400901&r1=1400900&r2=1400901&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html
Mon Oct 22 14:49:23 2012
@@ -53,7 +53,7 @@
         {{if browseResultEntry.project}}
           {{if deleteKarma}}
             <li class="browse-list-project">
-              <img id="delete-${browseResultEntry.name}" src="images/trash.png" data-bind="click:function(){deleteGroupId(browseResultEntry.name)}"/>
+              <img id="delete-${browseResultEntry.name}" src="images/trash.png" data-bind="click:function(){deleteProject(groupId,displayEntry(browseResultEntry.name))}"/>
               <a href="#" data-bind="click:function(){displayProjectEntry(browseResultEntry.name)}">${displayEntry(browseResultEntry.name)}</a>
             </li>
           {{else}}

Modified: archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java?rev=1400901&r1=1400900&r2=1400901&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java
(original)
+++ archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java
Mon Oct 22 14:49:23 2012
@@ -160,13 +160,12 @@ public interface MetadataRepository
         throws MetadataResolutionException;
 
     /**
-     *
      * @param repoId
      * @param namespace
      * @param projectId
      * @param projectVersion
-     * @since 1.4-M4
      * @throws MetadataResolutionException
+     * @since 1.4-M4
      */
     void removeProjectVersion( String repoId, String namespace, String projectId, String
projectVersion )
         throws MetadataRepositoryException;
@@ -175,6 +174,18 @@ public interface MetadataRepository
                                                String projectVersion )
         throws MetadataResolutionException;
 
+    /**
+     * remove a project
+     * @param repositoryId
+     * @param namespace
+     * @param projectId
+     * @throws MetadataRepositoryException
+     * @since 1.4-M4
+     */
+    void removeProject( String repositoryId, String namespace, String projectId )
+        throws MetadataRepositoryException;
+
+
     void save();
 
     void close()

Modified: archiva/trunk/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java?rev=1400901&r1=1400900&r2=1400901&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java
(original)
+++ archiva/trunk/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java
Mon Oct 22 14:49:23 2012
@@ -1162,6 +1162,11 @@ public class FileMetadataRepository
         return projectVersions;
     }
 
+    public void removeProject( String repositoryId, String namespace, String projectId )
+        throws MetadataRepositoryException
+    {
+        // TODO
+    }
 
     public void removeProjectVersion( String repoId, String namespace, String projectId,
String projectVersion )
         throws MetadataRepositoryException

Modified: archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java?rev=1400901&r1=1400900&r2=1400901&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
(original)
+++ archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
Mon Oct 22 14:49:23 2012
@@ -62,6 +62,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
@@ -367,6 +368,35 @@ public class JcrMetadataRepository
         }
     }
 
+    public void removeProject( String repositoryId, String namespace, String projectId )
+        throws MetadataRepositoryException
+    {
+        try
+        {
+            Node root = getJcrSession().getRootNode();
+            String namespacePath = getNamespacePath( repositoryId, namespace );
+
+            if ( root.hasNode( namespacePath ) )
+            {
+                Iterator<Node> nodeIterator = JcrUtils.getChildNodes( root.getNode(
namespacePath ) ).iterator();
+                while ( nodeIterator.hasNext() )
+                {
+                    Node node = nodeIterator.next();
+                    if ( node.isNodeType( PROJECT_NODE_TYPE ) && projectId.equals(
node.getName() ) )
+                    {
+                        node.remove();
+                    }
+                }
+
+            }
+        }
+        catch ( RepositoryException e )
+        {
+            throw new MetadataRepositoryException( e.getMessage(), e );
+        }
+
+    }
+
     public List<String> getMetadataFacets( String repositoryId, String facetId )
         throws MetadataRepositoryException
     {



Mime
View raw message