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-ffa450edef68archiva-MRM-980
@@ -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<ArtifactMetadata> 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<ArtifactMetadata> 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<ArtifactMetadata> sourceArtifacts = metadataRepository.getArtifacts( sourceRepoId ); | |||
sourceArtifacts.removeAll( conflictSourceArtifacts ); | |||
Filter<ArtifactMetadata> artifactsWithOutConflicts = | |||
new IncludesFilter<ArtifactMetadata>( 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<ArtifactMetadata> artifactsWithOutConflicts = | |||
new IncludesFilter<ArtifactMetadata>( 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<ArtifactMetadata> getConflictSourceArtifactsToBeDisplayed() | |||
public List<ArtifactMetadata> getConflictSourceArtifactsToBeDisplayed() | |||
{ | |||
return conflictSourceArtifactsToBeDisplayed; | |||
} | |||
@@ -233,15 +251,39 @@ public class MergeAction | |||
HashMap<String, ArtifactMetadata> map = new HashMap<String, ArtifactMetadata>(); | |||
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<ArtifactMetadata> sourceArtifacts, String sourceRepoId, String repoid ) | |||
throws Exception | |||
{ | |||
List<ArtifactMetadata> artifactsWithOutSnapshots = new ArrayList<ArtifactMetadata>(); | |||
for ( ArtifactMetadata metadata : sourceArtifacts ) | |||
{ | |||
if ( metadata.getProjectVersion().contains( "SNAPSHOT" ) ) | |||
{ | |||
artifactsWithOutSnapshots.add( metadata ); | |||
} | |||
else | |||
{ | |||
triggerAuditEvent( repoid, metadata.getId(), AuditEvent.MERGING_REPOSITORIES ); | |||
} | |||
} | |||
sourceArtifacts.removeAll( artifactsWithOutSnapshots ); | |||
Filter<ArtifactMetadata> artifactListWithOutSnapShots = new IncludesFilter<ArtifactMetadata>( sourceArtifacts ); | |||
repositoryMerger.merge( sourceRepoId, repoid, artifactListWithOutSnapShots ); | |||
} | |||
} | |||
@@ -41,6 +41,15 @@ | |||
<c:choose> | |||
<c:when test="${empty (conflictSourceArtifacts)}"> | |||
<h1>No conflicting artifacts</h1> | |||
<c:if test="${!repository.snapshots and repository.releases}"> | |||
<div class="warningbox"> | |||
<p> | |||
<strong>WARNING: Repository "${repoid}" does not allow to merge snapshots</strong> | |||
</p> | |||
</div> | |||
</c:if> | |||
<s:form method="post" action="merge" namespace="/admin" validate="false" theme="simple"> | |||
<s:hidden name="repoid"/> | |||
<div class="buttons"> | |||
@@ -50,6 +59,11 @@ | |||
</c:when> | |||
<c:otherwise> | |||
<div class="warningbox"> | |||
<c:if test="${!repository.snapshots and repository.releases}"> | |||
<p> | |||
<strong>WARNING: Repository "${repoid}" does not allow to merge snapshots</strong> | |||
</p> | |||
</c:if> | |||
<p> | |||
<strong>WARNING: The following are the artifacts in conflict.</strong> | |||
</p> | |||
@@ -85,7 +99,6 @@ | |||
</td> | |||
</tr> | |||
</table> | |||
</td> | |||
</tr> | |||
</table> |
@@ -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" %> | |||
<html> | |||
<head> | |||
@@ -30,17 +30,15 @@ | |||
<s:head/> | |||
<script type="text/javascript" src="<c:url value='/js/jquery-1.3.2.min.js'/>"></script> | |||
<script type="text/javascript"> | |||
$(document).ready(function() | |||
{ | |||
$(document).ready(function(){ | |||
$(".pom").hide(); | |||
$("a.expand").click(function( event ) | |||
{ | |||
event.preventDefault(); | |||
$(this).siblings("pre").toggle("slow"); | |||
}); | |||
$(".pom").hide(); | |||
$("a.expand").click(function(event){ | |||
event.preventDefault(); | |||
$(this).siblings("pre").toggle("slow"); | |||
}); | |||
}); | |||
}); | |||
</script> | |||
</head> | |||
@@ -105,7 +103,7 @@ | |||
</redback:ifAnyAuthorized> | |||
<c:url var="rssFeedIconUrl" value="/images/icons/rss-feed.png"/> | |||
<a href="/archiva/feeds/${repository.id}"> | |||
<img src="${rssFeedIconUrl}"/> | |||
<img src="${rssFeedIconUrl}" /> | |||
</a> | |||
</div> | |||
@@ -116,6 +114,47 @@ | |||
<h3 class="repository">${repository.name}</h3> | |||
<table class="infoTable"> | |||
<tr> | |||
<th>Identifier</th> | |||
<td> | |||
<code>${repository.id}</code> | |||
</td> | |||
</tr> | |||
<tr> | |||
<th>Name</th> | |||
<td> | |||
<code>${repository.name}</code> | |||
</td> | |||
</tr> | |||
<tr> | |||
<th>Directory</th> | |||
<td>${repository.location}</td> | |||
</tr> | |||
<c:if test="${!empty (repository.indexDir)}"> | |||
<tr> | |||
<th>Index Directory</th> | |||
<td>${repository.indexDir}</td> | |||
</tr> | |||
</c:if> | |||
<tr> | |||
<th>WebDAV URL</th> | |||
<td><a href="${baseUrl}/${repository.id}/">${baseUrl}/${repository.id}/</a></td> | |||
</tr> | |||
<tr> | |||
<th>Type</th> | |||
<%-- TODO: can probably just use layout appended to a key prefix in i18n to simplify this --%> | |||
<td> | |||
<c:choose> | |||
<c:when test="${repository.layout == 'default'}"> | |||
Maven 2.x Repository | |||
</c:when> | |||
<c:otherwise> | |||
Maven 1.x Repository | |||
</c:otherwise> | |||
</c:choose> | |||
</td> | |||
</tr> | |||
<c:if test="${!empty (repositoryToGroupMap[repository.id])}"> | |||
<tr> | |||
<th>Groups</th> | |||
<td> | |||
@@ -124,10 +163,20 @@ | |||
</c:forEach> | |||
</td> | |||
</tr> | |||
</c:if> | |||
<tr> | |||
<th>Releases Included</th> | |||
<td class="${repository.releases ? 'donemark' : 'errormark'} booleanIcon"> </td> | |||
</tr> | |||
<tr> | |||
<th>Snapshots Included</th> | |||
<td class="${repository.snapshots ? 'donemark' : 'errormark'} booleanIcon"> </td> | |||
</tr> | |||
<c:if test="${repository.snapshots}"> | |||
<tr> | |||
<th>Delete Released Snapshots</th> | |||
<td class="${repository.deleteReleasedSnapshots ? 'donemark' : 'errormark'} booleanIcon"></td> | |||
</tr> | |||
<td class="${repository.deleteReleasedSnapshots ? 'donemark' : 'errormark'} booleanIcon"> </td> | |||
</tr> | |||
<tr> | |||
<th>Repository Purge By Days Older Than</th> | |||
<td>${repository.daysOlder}</td> | |||
@@ -136,6 +185,12 @@ | |||
<th>Repository Purge By Retention Count</th> | |||
<td>${repository.retentionCount}</td> | |||
</tr> | |||
</c:if> | |||
<tr> | |||
<th>Scanned</th> | |||
<td class="${repository.scanned ? 'donemark' : 'errormark'} booleanIcon"> </td> | |||
</tr> | |||
<c:if test="${repository.scanned}"> | |||
<tr> | |||
<th>Scanning Cron</th> | |||
<td>${repository.refreshCronExpression}</td> | |||
@@ -145,6 +200,25 @@ | |||
Actions | |||
</th> | |||
<td> | |||
<redback:ifAuthorized permission="archiva-run-indexer"> | |||
<s:form action="indexRepository" theme="simple"> | |||
<s:hidden name="repoid" value="%{#attr.repository.id}"/> | |||
<table> | |||
<tr> | |||
<td><s:checkbox name="scanAll" value="scanAll"/>Process All Artifacts</td> | |||
</tr> | |||
<tr> | |||
<td><s:submit value="Scan Repository Now"/></td> | |||
</tr> | |||
</table> | |||
</s:form> | |||
</redback:ifAuthorized> | |||
</td> | |||
</tr> | |||
<tr> | |||
<th>Stats</th> | |||
<td> | |||
<c:set var="stats" value="${repositoryStatistics[repository.id]}"/> | |||
<c:choose> | |||
<c:when test="${empty (stats)}"> | |||
No Statistics Available. | |||
@@ -172,106 +246,13 @@ | |||
</c:choose> | |||
</td> | |||
</tr> | |||
<c:if test="${!empty (repositoryToGroupMap[repository.id])}"> | |||
<tr> | |||
<th>Groups</th> | |||
<td> | |||
<c:forEach items="${repositoryToGroupMap[repository.id]}" varStatus="i" var="group"> | |||
${group}<c:if test="${!i.last}">,</c:if> | |||
</c:forEach> | |||
</td> | |||
</tr> | |||
</c:if> | |||
<tr> | |||
<th>Releases Included</th> | |||
<td class="${repository.releases ? 'donemark' : 'errormark'} booleanIcon"></td> | |||
</tr> | |||
<tr> | |||
<th>Snapshots Included</th> | |||
<td class="${repository.snapshots ? 'donemark' : 'errormark'} booleanIcon"></td> | |||
</tr> | |||
<c:if test="${repository.snapshots}"> | |||
<tr> | |||
<th>Delete Released Snapshots</th> | |||
<td class="${repository.deleteReleasedSnapshots ? 'donemark' : 'errormark'} booleanIcon"></td> | |||
</tr> | |||
<tr> | |||
<th>Repository Purge By Days Older Than</th> | |||
<td>${repository.daysOlder}</td> | |||
</tr> | |||
<tr> | |||
<th>Repository Purge By Retention Count</th> | |||
<td>${repository.retentionCount}</td> | |||
</tr> | |||
</c:if> | |||
<tr> | |||
<th>Scanned</th> | |||
<td class="${repository.scanned ? 'donemark' : 'errormark'} booleanIcon"></td> | |||
</tr> | |||
<c:if test="${repository.scanned}"> | |||
<tr> | |||
<th>Scanning Cron</th> | |||
<td>${repository.refreshCronExpression}</td> | |||
</tr> | |||
<tr> | |||
<th> | |||
Actions | |||
</th> | |||
<td> | |||
<redback:ifAuthorized permission="archiva-run-indexer"> | |||
<s:form action="indexRepository" theme="simple"> | |||
<s:hidden name="repoid" value="%{#attr.repository.id}"/> | |||
<table> | |||
<tr> | |||
<td><s:checkbox name="scanAll" value="scanAll"/>Process All Artifacts</td> | |||
</tr> | |||
<tr> | |||
<td><s:submit value="Scan Repository Now"/></td> | |||
</tr> | |||
</table> | |||
</s:form> | |||
</redback:ifAuthorized> | |||
</td> | |||
</tr> | |||
<tr> | |||
<th>Stats</th> | |||
<td> | |||
<c:set var="stats" value="${repositoryStatistics[repository.id]}"/> | |||
<c:choose> | |||
<c:when test="${empty (stats)}"> | |||
No Statistics Available. | |||
</c:when> | |||
<c:otherwise> | |||
<table> | |||
<tr> | |||
<th>Last Scanned</th> | |||
<td>${stats.scanStartTime}</td> | |||
</tr> | |||
<tr> | |||
<th>Duration</th> | |||
<td>${stats.duration} ms</td> | |||
</tr> | |||
<tr> | |||
<th>Total File Count</th> | |||
<td>${stats.totalFileCount} | |||
</tr> | |||
<tr> | |||
<th>New Files Found</th> | |||
<td>${stats.newFileCount} | |||
</tr> | |||
</table> | |||
</c:otherwise> | |||
</c:choose> | |||
</td> | |||
</tr> | |||
</c:if> | |||
<tr> | |||
<th>POM Snippet</th> | |||
<td> | |||
<archiva:copy-paste-snippet object="${repository}" wrapper="toggle"/> | |||
</td> | |||
</tr> | |||
</c:if> | |||
<tr> | |||
<th>POM Snippet</th> | |||
<td> | |||
<archiva:copy-paste-snippet object="${repository}" wrapper="toggle" /> | |||
</td> | |||
</tr> | |||
<c:set var="str" value="${repository.id}" /> | |||
@@ -312,6 +293,7 @@ | |||
</c:if> | |||
</table> | |||
</div> |
@@ -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; |