/**
* @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
private Maven2RepositoryMerger repositoryMerger;
/**
- * @plexus.requirement role-hint="default"
+ * @plexus.requirement
*/
- private ArchivaConfiguration configuration;
+ protected ArchivaConfiguration archivaConfiguration;
/**
* @plexus.requirement role-hint="default"
private final String action = "merge";
- private final String noConflicts = "NO CONFLICTS";
-
private final String hasConflicts = "CONFLICTS";
private List<ArtifactMetadata> conflictSourceArtifacts;
public String getConflicts()
{
sourceRepoId = repoid + "-stage";
- Configuration config = configuration.getConfiguration();
+ Configuration config = archivaConfiguration.getConfiguration();
ManagedRepositoryConfiguration targetRepoConfig = config.findManagedRepositoryById( sourceRepoId );
if ( targetRepoConfig != null )
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;
}
{
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;
}
}
addActionMessage( "Repository '" + sourceRepoId + "' successfully merged to '" + repoid + "'." );
-
+
return SUCCESS;
}
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 );
}
this.conflictSourceArtifacts = conflictSourceArtifacts;
}
- public List<ArtifactMetadata> getConflictSourceArtifactsToBeDisplayed()
+ public List<ArtifactMetadata> getConflictSourceArtifactsToBeDisplayed()
{
return conflictSourceArtifactsToBeDisplayed;
}
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 );
+ }
}
<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">
</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>
</td>
</tr>
</table>
-
</td>
</tr>
</table>
<%@ 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>
<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>
</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>
<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>
</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>
<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>
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: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}" />
</c:if>
+
</table>
</div>
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 );
}
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;