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 34725b45c..b50bf0ac9 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 @@ -22,13 +22,16 @@ package org.apache.maven.archiva.web.action; import com.opensymphony.xwork2.Validateable; import com.opensymphony.xwork2.Preparable; import org.apache.archiva.audit.Auditable; +import org.apache.archiva.audit.AuditEvent; import org.apache.archiva.stagerepository.merge.Maven2RepositoryMerger; import org.apache.archiva.metadata.model.ArtifactMetadata; +import org.apache.archiva.metadata.repository.filter.Filter; +import org.apache.archiva.metadata.repository.filter.IncludesFilter; +import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import java.io.File; import java.util.List; /** @@ -49,6 +52,11 @@ public class MergeAction */ private ArchivaConfiguration configuration; + /** + * @plexus.requirement role-hint="default" + */ + private MetadataRepository metadataRepository; + private ManagedRepositoryConfiguration repository; private String repoid; @@ -57,9 +65,13 @@ public class MergeAction private final String action = "merge"; - List conflictList; + private final String noConflicts = "NO CONFLICTS"; - public String doMerge() + private final String hasConflicts = "CONFLICTS"; + + private List conflictSourceArtifacts; + + public String getConflicts() { targetRepoId = repoid + "-stage"; Configuration config = configuration.getConfiguration(); @@ -67,18 +79,56 @@ public class MergeAction if ( targetRepoConfig != null ) { + return hasConflicts; - try + } + else + { + return ERROR; + } + } + + public String doMerge() + throws Exception + { + try + { + List sourceArtifacts = metadataRepository.getArtifacts( targetRepoId ); + repositoryMerger.merge( targetRepoId, repoid ); + triggerAuditEvent( targetRepoId, "file-eshan", AuditEvent.MERGING_REPOSITORIES ); + + for ( ArtifactMetadata metadata : sourceArtifacts ) { - repositoryMerger.merge( repoid, targetRepoId ); - } - catch ( Exception e ) - { - return ERROR; + triggerAuditEvent( targetRepoId, metadata.getId(), AuditEvent.MERGING_REPOSITORIES ); } return SUCCESS; } - else + catch ( Exception ex ) + { + return ERROR; + } + } + + public String mergeBySkippingConflicts() + { + try + { + List sourceArtifacts = metadataRepository.getArtifacts( targetRepoId ); + sourceArtifacts.removeAll( conflictSourceArtifacts ); + Filter artifactsWithOutConflicts = + new IncludesFilter( sourceArtifacts ); + repositoryMerger.merge( targetRepoId, repoid, artifactsWithOutConflicts ); + + for ( ArtifactMetadata metadata : sourceArtifacts ) + { + + triggerAuditEvent( targetRepoId, metadata.getId(), AuditEvent.MERGING_REPOSITORIES ); +// + } + return SUCCESS; + + } + catch ( Exception ex ) { return ERROR; } @@ -91,22 +141,15 @@ public class MergeAction try { - conflictList = repositoryMerger.mergeWithOutConflictArtifacts( repoid, targetRepoId ); + conflictSourceArtifacts = repositoryMerger.getConflictsartifacts( targetRepoId, repoid ); } catch ( Exception e ) { return ERROR; } - return SUCCESS; } - public void prepare() - throws Exception - { - this.repository = new ManagedRepositoryConfiguration(); - } - public ManagedRepositoryConfiguration getRepository() { return repository; @@ -117,6 +160,24 @@ public class MergeAction this.repository = repository; } + public void prepare() + throws Exception + { + targetRepoId = repoid + "-stage"; + conflictSourceArtifacts = repositoryMerger.getConflictsartifacts( targetRepoId, repoid ); + this.repository = new ManagedRepositoryConfiguration(); + } + + public String getTargetRepoId() + { + return targetRepoId; + } + + public void setTargetRepoId( String targetRepoId ) + { + this.targetRepoId = targetRepoId; + } + public String getRepoid() { return repoid; @@ -126,4 +187,15 @@ public class MergeAction { this.repoid = repoid; } + + public List getConflictSourceArtifacts() + { + return conflictSourceArtifacts; + } + + public void setConflictSourceArtifacts( List conflictSourceArtifacts ) + { + this.conflictSourceArtifacts = conflictSourceArtifacts; + } } + diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml index 64d3760cb..5379220ff 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml @@ -359,18 +359,12 @@ - - /WEB-INF/jsp/mergeActionResults.jsp - - - - - - - /WEB-INF/jsp/mergeActionResults.jsp - - + + /WEB-INF/jsp/mergeExcludeConflicts.jsp + /WEB-INF/jsp/mergeActionResults.jsp + + /WEB-INF/jsp/admin/deleteRemoteRepository.jsp 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 dd65ea461..7721cac1e 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 @@ -1,21 +1,22 @@ +<%@ page import="java.io.File" %> <%-- - ~ 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. - --%> +~ 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. +--%> <%@ page contentType="text/html; charset=UTF-8" %> <%@ taglib prefix="s" uri="/struts-tags" %> @@ -115,63 +116,6 @@

${repository.name}

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -202,12 +136,6 @@ - - - - - - @@ -217,25 +145,6 @@ Actions - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - + - +
Groups - - ${group}, - -
Delete Released Snapshots
Repository Purge By Days Older Than${repository.daysOlder}
Repository Purge By Retention Count${repository.retentionCount}
Scanning Cron${repository.refreshCronExpression}
- Actions - - - - No Statistics Available. - - - - - - - - - - - - - - - - - -
Last Scanned${stats.scanStartTime}
Duration${stats.duration} ms
Total File Count${stats.totalFileCount} -
New Files Found${stats.newFileCount} -
-
-
-
Groups @@ -180,20 +124,10 @@
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. @@ -263,51 +172,144 @@
POM Snippet - -
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 + +
Merge Actions - - - - - - - + + + + -
-
-
-
- - - - - - - + + + + + + + + - +
+ stage repository location + + ${repository.location}${'-stage'} +
Merge Actions + + + + <%----%> + + + + -
-
-
-
+
+
+
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/mergeExcludeConflicts.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/mergeExcludeConflicts.jsp index e1d7a3bd4..720675a5c 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/mergeExcludeConflicts.jsp +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/mergeExcludeConflicts.jsp @@ -23,121 +23,78 @@ - Admin: Add Managed Repository + Admin: Merge Staging Repository -

Admin: Add Managed Repository

+

Admin: Merge Staging Repository

-
-

- WARNING: There Are some conflicts Artifacts. -

-
+

+ Are you sure you want to merge the repository? +

-

- Are you sure you want to merge the Repository - <%----%> - <%--add--%> - <%--update--%> - <%----%> +

+ -

- -
-
- - - - - - - - - - - - - - - - - - - <%--td>${repository.layout} - - - - - - - - - - - - - - - - - - - - - - - - - - -
ID:${repository.id}
Name:${repository.name}
Directory:${repository.location}
Index Directory:${repository.indexDir}
Type: - - - Maven 2.x Repository - - - Maven 1.x Repository - - -
Cron:${repository.refreshCronExpression}
Repository Purge By Days Older Than:${repository.daysOlder}
Repository Purge By Retention Count:${repository.retentionCount}
Releases Included: -
Snapshots Included: -
Scannable: -
Delete Released Snapshots: -
-
- - -
- - - - - - - - - - - - - - <%----%> - - - <%----%> - <%----%> - <%----%> - <%----%> - <%----%> - <%----%> - <%----%> - - -
-
+ + +

No conflicting artifacts

+ + +
+ +
+
+
+ +
+

+ WARNING: The following are the artifacts in conflict. +

+
+ + + Artifact Id : + ${artifact.id} + + + + + + +
+ + + + + +
+ + + + +
+ +
+
+ + + + +
+ +
+
+
+
+ + +
+
+ + diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEvent.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEvent.java index 4712520a9..13b91bca3 100644 --- a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEvent.java +++ b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEvent.java @@ -69,6 +69,8 @@ public class AuditEvent public static final String REMOVE_SCANNED = "Removed in Filesystem"; + public static final String MERGING_REPOSITORIES = "Merging repositories"; + // configuration events public static final String ADD_MANAGED_REPO = "Added Managed Repository"; diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/MetadataAuditListener.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/MetadataAuditListener.java index 6a67960b2..66383892e 100644 --- a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/MetadataAuditListener.java +++ b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/MetadataAuditListener.java @@ -33,7 +33,8 @@ public class MetadataAuditListener public void auditEvent( AuditEvent event ) { // for now we only log upload events, some of the others are quite noisy - if ( event.getAction().equals( AuditEvent.CREATE_FILE ) || event.getAction().equals( AuditEvent.UPLOAD_FILE ) ) + if ( event.getAction().equals( AuditEvent.CREATE_FILE ) || event.getAction().equals( AuditEvent.UPLOAD_FILE ) || + event.getAction().equals( AuditEvent.MERGING_REPOSITORIES ) ) { auditManager.addAuditEvent( event ); } 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 51cfb469e..ca71277e6 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 @@ -89,6 +89,7 @@ public class Maven2RepositoryMerger List artifactsInSourceRepo = metadataRepository.getArtifacts( sourceRepoId ); for ( ArtifactMetadata artifactMetadata : artifactsInSourceRepo ) { + artifactMetadata.setRepositoryId( targetRepoId ); createFolderStructure( sourceRepoId, targetRepoId, artifactMetadata ); } } @@ -325,7 +326,7 @@ public class Maven2RepositoryMerger return metadata; } - public List mergeWithOutConflictArtifacts( String sourceRepo, String targetRepo ) + public List getConflictsartifacts( String sourceRepo, String targetRepo ) throws Exception { @@ -354,7 +355,7 @@ public class Maven2RepositoryMerger sourceArtifacts.removeAll( conflictsArtifacts ); Filter artifactsWithOutConflicts = new IncludesFilter( sourceArtifacts ); - merge( sourceRepo, targetRepo, artifactsWithOutConflicts ); +// merge( sourceRepo, targetRepo, artifactsWithOutConflicts ); return conflictsArtifacts; } diff --git a/archiva-modules/plugins/stage-repository-merge/src/test/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMergerTest.java b/archiva-modules/plugins/stage-repository-merge/src/test/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMergerTest.java index 916af4038..5773d1bba 100644 --- a/archiva-modules/plugins/stage-repository-merge/src/test/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMergerTest.java +++ b/archiva-modules/plugins/stage-repository-merge/src/test/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMergerTest.java @@ -154,7 +154,7 @@ public class Maven2RepositoryMergerTest when( metadataRepository.getArtifacts( sourceRepoId ) ).thenReturn( sourceRepoArtifactsList ); when( metadataRepository.getArtifacts( TEST_REPO_ID ) ).thenReturn( targetRepoArtifactsList ); - assertEquals( 1, repositoryMerger.mergeWithOutConflictArtifacts( sourceRepoId, TEST_REPO_ID ).size() ); + assertEquals( 1, repositoryMerger.getConflictsartifacts( sourceRepoId, TEST_REPO_ID ).size() ); verify( metadataRepository ).getArtifacts( TEST_REPO_ID ); }