archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1400323 - in /archiva/trunk/archiva-modules: archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/ archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/...
Date Fri, 19 Oct 2012 22:47:19 GMT
Author: olamy
Date: Fri Oct 19 22:47:19 2012
New Revision: 1400323

URL: http://svn.apache.org/viewvc?rev=1400323&view=rev
Log:
[MRM-1701] metadatas are not removed when a snapshot is purged.

Modified:
    archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.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/redback/user.js

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java?rev=1400323&r1=1400322&r2=1400323&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java
Fri Oct 19 22:47:19 2012
@@ -20,16 +20,24 @@ package org.apache.archiva.consumers.cor
  */
 
 import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.common.utils.VersionUtil;
+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.metadata.repository.MetadataResolutionException;
 import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.repository.events.RepositoryListener;
+import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet;
 import org.apache.archiva.model.ArtifactReference;
+import org.apache.archiva.repository.ContentNotFoundException;
 import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.events.RepositoryListener;
+import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.File;
 import java.io.FilenameFilter;
+import java.util.Collection;
 import java.util.List;
 import java.util.Set;
 
@@ -39,7 +47,7 @@ import java.util.Set;
 public abstract class AbstractRepositoryPurge
     implements RepositoryPurge
 {
-    protected Logger log = LoggerFactory.getLogger( AbstractRepositoryPurge.class );
+    protected Logger log = LoggerFactory.getLogger( getClass() );
 
     protected final ManagedRepositoryContent repository;
 
@@ -83,7 +91,82 @@ public abstract class AbstractRepository
 
                 // TODO: this needs to be logged
                 artifactFile.delete();
-                //repository.deleteArtifact( reference );
+                try
+                {
+                    repository.deleteArtifact( reference );
+                }
+                catch ( ContentNotFoundException e )
+                {
+                    log.warn( "skip error deleting artifact {}: {}", reference, e.getMessage()
);
+                }
+
+                try
+                {
+                    metadataRepository.removeProjectVersion( repository.getId(), reference.getGroupId(),
+                                                             reference.getArtifactId(), reference.getVersion()
);
+                }
+                catch ( MetadataRepositoryException e )
+                {
+                    log.warn( "skip error removeProjectVersion artifact {}: {}", reference,
e.getMessage() );
+                }
+
+                boolean snapshotVersion = VersionUtil.isSnapshot( reference.getVersion()
);
+
+                try
+                {
+                    if ( snapshotVersion )
+                    {
+                        String baseVersion = VersionUtil.getBaseVersion( reference.getVersion()
);
+                        Collection<ArtifactMetadata> artifacts =
+                            metadataRepository.getArtifacts( repository.getId(), reference.getGroupId(),
+                                                             reference.getArtifactId(), baseVersion
);
+                        // cleanup snapshots metadata
+                        for ( ArtifactMetadata artifactMetadata : artifacts )
+                        {
+
+                            // TODO: mismatch between artifact (snapshot) version and project
(base) version here
+                            if ( artifactMetadata.getVersion().equals( reference.getVersion()
) )
+                            {
+                                if ( StringUtils.isNotBlank( reference.getClassifier() )
)
+                                {
+
+                                    // cleanup facet which contains classifier information
+                                    MavenArtifactFacet mavenArtifactFacet =
+                                        (MavenArtifactFacet) artifactMetadata.getFacet( MavenArtifactFacet.FACET_ID
);
+
+                                    if ( StringUtils.equals( reference.getClassifier(),
+                                                             mavenArtifactFacet.getClassifier()
) )
+                                    {
+                                        artifactMetadata.removeFacet( MavenArtifactFacet.FACET_ID
);
+                                        String groupId = reference.getGroupId(), artifactId
= reference.getArtifactId(),
+                                            version = reference.getVersion();
+                                        MavenArtifactFacet mavenArtifactFacetToCompare =
new MavenArtifactFacet();
+                                        mavenArtifactFacetToCompare.setClassifier( reference.getClassifier()
);
+                                        metadataRepository.removeArtifact( repository.getId(),
groupId, artifactId,
+                                                                           version, mavenArtifactFacetToCompare
);
+                                        metadataRepository.save();
+                                    }
+
+                                }
+                                else
+                                {
+                                    metadataRepository.removeArtifact( artifactMetadata,
VersionUtil.getBaseVersion(
+                                        reference.getVersion() ) );
+                                }
+
+                            }
+                        }
+                    }
+                }
+                catch ( MetadataResolutionException e )
+                {
+                    log.warn( "skip error deleting metadata {}: {}", reference, e.getMessage()
);
+                }
+                catch ( MetadataRepositoryException e )
+                {
+                    e.printStackTrace();  //To change body of catch statement use File |
Settings | File Templates.
+                }
+
                 repositorySession.save();
 
                 triggerAuditEvent( repository.getRepository().getId(), ArtifactReference.toKey(
reference ),

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=1400323&r1=1400322&r2=1400323&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
Fri Oct 19 22:47:19 2012
@@ -766,9 +766,6 @@ public class DefaultRepositoriesService
                             artifactMetadata.removeFacet( MavenArtifactFacet.FACET_ID );
                             String groupId = artifact.getGroupId(), artifactId = artifact.getArtifactId(),
version =
                                 artifact.getVersion();
-                            //metadataRepository.updateArtifact( repositoryId, groupId, artifactId,
version,
-                            //                                   artifactMetadata );
-                            // String repositoryId, String namespace, String project, String
version, String projectId, MetadataFacet metadataFacet
                             MavenArtifactFacet mavenArtifactFacetToCompare = new MavenArtifactFacet();
                             mavenArtifactFacetToCompare.setClassifier( artifact.getClassifier()
);
                             metadataRepository.removeArtifact( repositoryId, groupId, artifactId,
version,

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js?rev=1400323&r1=1400322&r2=1400323&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js
Fri Oct 19 22:47:19 2012
@@ -77,7 +77,7 @@ function(jquery,utils,i18n,jqueryValidat
     this.modified=ko.observable(false);
 
     this.rememberme=false;
-    this.password=null;
+
     this.logged=false;
 
     this.remove = function() {
@@ -413,7 +413,7 @@ function(jquery,utils,i18n,jqueryValidat
       // FIXME check validated
       user.rememberme=window.redbackModel.rememberme;
       if(user.rememberme){
-        user.password=window.redbackModel.password;
+        user.password(window.redbackModel.password);
       }
       $.log("user.rememberme:"+(user.rememberme));
       reccordLoginCookie(user);



Mime
View raw message