From: Maria Odea B. Ching Date: Sun, 8 Aug 2010 05:19:33 +0000 (+0000) Subject: [MRM-1398],[MRM-1401],[MRM-1403] X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=93cd044c22708ac18587a24bf601fc8c5b762385;p=archiva.git [MRM-1398],[MRM-1401],[MRM-1403] submitted by Patti Arachchige Eshan Sudharaka o fixed repositories page o do not merge snapshot artifacts o fixed problem when merging artifacts with classifier git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-MRM-980@983343 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java index 0b9d439a7..ff252a151 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java @@ -41,7 +41,8 @@ import java.util.Iterator; /** * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="mergeAction" instantiation-strategy="per-lookup" */ -public class MergeAction +public class + MergeAction extends PlexusActionSupport implements Validateable, Preparable, Auditable @@ -52,9 +53,9 @@ public class MergeAction private Maven2RepositoryMerger repositoryMerger; /** - * @plexus.requirement role-hint="default" + * @plexus.requirement */ - private ArchivaConfiguration configuration; + protected ArchivaConfiguration archivaConfiguration; /** * @plexus.requirement role-hint="default" @@ -74,8 +75,6 @@ public class MergeAction private final String action = "merge"; - private final String noConflicts = "NO CONFLICTS"; - private final String hasConflicts = "CONFLICTS"; private List conflictSourceArtifacts; @@ -85,7 +84,7 @@ public class MergeAction public String getConflicts() { sourceRepoId = repoid + "-stage"; - Configuration config = configuration.getConfiguration(); + Configuration config = archivaConfiguration.getConfiguration(); ManagedRepositoryConfiguration targetRepoConfig = config.findManagedRepositoryById( sourceRepoId ); if ( targetRepoConfig != null ) @@ -105,20 +104,29 @@ public class MergeAction try { List sourceArtifacts = metadataRepository.getArtifacts( sourceRepoId ); - repositoryMerger.merge( sourceRepoId, repoid ); - scheduler.scanRepository(); - for ( ArtifactMetadata metadata : sourceArtifacts ) + if ( repository.isReleases() && !repository.isSnapshots() ) { - triggerAuditEvent( repoid, metadata.getId(), AuditEvent.MERGING_REPOSITORIES ); + mergeWithOutSnapshots( sourceArtifacts, sourceRepoId, repoid ); } + else + { + repositoryMerger.merge( sourceRepoId, repoid ); + + for ( ArtifactMetadata metadata : sourceArtifacts ) + { + triggerAuditEvent( repoid, metadata.getId(), AuditEvent.MERGING_REPOSITORIES ); + } + } + scheduler.scanRepository(); addActionMessage( "Repository '" + sourceRepoId + "' successfully merged to '" + repoid + "'." ); - + return SUCCESS; } catch ( Exception ex ) { + ex.printStackTrace(); addActionError( "Error occurred while merging the repositories." ); return ERROR; } @@ -130,22 +138,30 @@ public class MergeAction { List sourceArtifacts = metadataRepository.getArtifacts( sourceRepoId ); sourceArtifacts.removeAll( conflictSourceArtifacts ); - Filter artifactsWithOutConflicts = - new IncludesFilter( sourceArtifacts ); - repositoryMerger.merge( sourceRepoId, repoid, artifactsWithOutConflicts ); - scheduler.scanRepository(); - for ( ArtifactMetadata metadata : sourceArtifacts ) + if ( repository.isReleases() && !repository.isSnapshots() ) { - triggerAuditEvent( repoid, metadata.getId(), AuditEvent.MERGING_REPOSITORIES ); + mergeWithOutSnapshots( sourceArtifacts, sourceRepoId, repoid ); } + else + { + Filter artifactsWithOutConflicts = + new IncludesFilter( sourceArtifacts ); + repositoryMerger.merge( sourceRepoId, repoid, artifactsWithOutConflicts ); + for ( ArtifactMetadata metadata : sourceArtifacts ) + { + triggerAuditEvent( repoid, metadata.getId(), AuditEvent.MERGING_REPOSITORIES ); + } + } + scheduler.scanRepository(); addActionMessage( "Repository '" + sourceRepoId + "' successfully merged to '" + repoid + "'." ); return SUCCESS; } catch ( Exception ex ) { + ex.printStackTrace(); addActionError( "Error occurred while merging the repositories." ); return ERROR; } @@ -167,7 +183,7 @@ public class MergeAction } addActionMessage( "Repository '" + sourceRepoId + "' successfully merged to '" + repoid + "'." ); - + return SUCCESS; } @@ -187,7 +203,9 @@ public class MergeAction sourceRepoId = repoid + "-stage"; conflictSourceArtifacts = repositoryMerger.getConflictsartifacts( sourceRepoId, repoid ); this.scheduler.setRepoid( repoid ); - this.repository = new ManagedRepositoryConfiguration(); + + Configuration config = archivaConfiguration.getConfiguration(); + this.repository = config.findManagedRepositoryById( repoid ); setConflictSourceArtifactsToBeDisplayed( conflictSourceArtifacts ); } @@ -221,7 +239,7 @@ public class MergeAction this.conflictSourceArtifacts = conflictSourceArtifacts; } - public List getConflictSourceArtifactsToBeDisplayed() + public List getConflictSourceArtifactsToBeDisplayed() { return conflictSourceArtifactsToBeDisplayed; } @@ -233,15 +251,39 @@ public class MergeAction HashMap map = new HashMap(); for ( ArtifactMetadata metadata : conflictSourceArtifacts ) { - String metadataId = metadata.getNamespace() + metadata.getProject() + metadata.getProjectVersion() + metadata.getVersion(); - map.put( metadataId, metadata ); + String metadataId = + metadata.getNamespace() + metadata.getProject() + metadata.getProjectVersion() + metadata.getVersion(); + map.put( metadataId, metadata ); } Iterator iterator = map.keySet().iterator(); while ( iterator.hasNext() ) { - conflictSourceArtifactsToBeDisplayed.add( map.get(iterator.next() )); + conflictSourceArtifactsToBeDisplayed.add( map.get( iterator.next() ) ); } } + + private void mergeWithOutSnapshots( List sourceArtifacts, String sourceRepoId, String repoid ) + throws Exception + { + List artifactsWithOutSnapshots = new ArrayList(); + for ( ArtifactMetadata metadata : sourceArtifacts ) + { + + if ( metadata.getProjectVersion().contains( "SNAPSHOT" ) ) + { + artifactsWithOutSnapshots.add( metadata ); + } + else + { + triggerAuditEvent( repoid, metadata.getId(), AuditEvent.MERGING_REPOSITORIES ); + } + + } + sourceArtifacts.removeAll( artifactsWithOutSnapshots ); + + Filter artifactListWithOutSnapShots = new IncludesFilter( sourceArtifacts ); + repositoryMerger.merge( sourceRepoId, repoid, artifactListWithOutSnapShots ); + } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/mergeExcludeConflicts.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/mergeExcludeConflicts.jsp index 371368423..8ccbfda68 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/mergeExcludeConflicts.jsp +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/mergeExcludeConflicts.jsp @@ -41,6 +41,15 @@

No conflicting artifacts

+ + +
+

+ WARNING: Repository "${repoid}" does not allow to merge snapshots +

+
+
+
@@ -50,6 +59,11 @@
+ +

+ WARNING: Repository "${repoid}" does not allow to merge snapshots +

+

WARNING: The following are the artifacts in conflict.

@@ -85,7 +99,6 @@ - diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp index 7721cac1e..5c84137f8 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp @@ -22,7 +22,7 @@ <%@ taglib prefix="s" uri="/struts-tags" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="redback" uri="http://plexus.codehaus.org/redback/taglib-1.0" %> -<%@ taglib prefix="archiva" uri="/WEB-INF/taglib.tld" %> +<%@ taglib prefix="archiva" uri="/WEB-INF/taglib.tld" %> @@ -30,17 +30,15 @@ @@ -105,7 +103,7 @@ - +
@@ -116,6 +114,47 @@

${repository.name}

+ + + + + + + + + + + + + + + + + + + + + + + + + <%-- TODO: can probably just use layout appended to a key prefix in i18n to simplify this --%> + + + + + + + + + + + + + - - + + @@ -136,6 +185,12 @@ + + + + + + @@ -145,6 +200,25 @@ Actions + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -312,6 +293,7 @@ +
Identifier + ${repository.id} +
Name + ${repository.name} +
Directory${repository.location}
Index Directory${repository.indexDir}
WebDAV URL${baseUrl}/${repository.id}/
Type + + + Maven 2.x Repository + + + Maven 1.x Repository + + +
Groups @@ -124,10 +163,20 @@
Releases Included
Snapshots Included
Delete Released Snapshots
Repository Purge By Days Older Than ${repository.daysOlder}Repository Purge By Retention Count ${repository.retentionCount}
Scanned
Scanning Cron ${repository.refreshCronExpression} + + + + + + + + + + +
Process All Artifacts
+
+
+
Stats + No Statistics Available. @@ -172,106 +246,13 @@
Groups - - ${group}, - -
Releases Included
Snapshots Included
Delete Released Snapshots
Repository Purge By Days Older Than${repository.daysOlder}
Repository Purge By Retention Count${repository.retentionCount}
Scanned
Scanning Cron${repository.refreshCronExpression}
- Actions - - - - - - - - - - - -
Process All Artifacts
-
-
-
Stats - - - - No Statistics Available. - - - - - - - - - - - - - - - - - -
Last Scanned${stats.scanStartTime}
Duration${stats.duration} ms
Total File Count${stats.totalFileCount} -
New Files Found${stats.newFileCount} -
-
-
-
POM Snippet - -
POM Snippet + +
diff --git a/archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMerger.java b/archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMerger.java index 7b8fe7b86..943b667d6 100644 --- a/archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMerger.java +++ b/archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMerger.java @@ -173,7 +173,7 @@ public class Maven2RepositoryMerger File targetPomFile = new File( targetRepoPath, artifactPath.substring( 0, lastIndex ) + "/" + artifactPath.substring( lastIndex + 1 ).substring( 0, last ) + ".pom" ); - if ( !targetPomFile.exists() ) + if ( !targetPomFile.exists() && sourcePomFile.exists() ) { copyFile( sourcePomFile, targetPomFile ); } @@ -358,15 +358,12 @@ public class Maven2RepositoryMerger if ( ( sourceArtifact.getNamespace().equals( targetArtifact.getNamespace() ) ) && ( sourceArtifact.getProject().equals( targetArtifact.getProject() ) ) && - ( sourceArtifact.getVersion().equals( targetArtifact.getVersion() ) ) && ( sourceArtifact.getId().equals( targetArtifact.getId() ) ) && ( sourceArtifact.getProjectVersion().equals( targetArtifact.getProjectVersion() ) ) ) { - if ( sourceArtifact.getId().equals( targetArtifact.getId() ) ) - { - isSame = true; - } + isSame = true; + } return isSame;