~ under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.archiva</groupId>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-lucene-consumers</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>stage-repository-merge</artifactId>
+ <version>1.4-MRM-980-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-signature-consumers</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
- <groupId>org.apache.archiva</groupId> <!-- FIXME: temporary coupling to plugin, should be runtime -->
+ <groupId>org.apache.archiva</groupId>
+ <!-- FIXME: temporary coupling to plugin, should be runtime -->
<artifactId>maven2-repository</artifactId>
</dependency>
</dependencies>
</excludes>
</configuration>
</plugin>
- -->
+ -->
<!-- hack for jetty:run, archiva web config files are checked in /WEB-INF/ dir -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<phase>compile</phase>
<configuration>
<tasks>
- <mkdir dir="${basedir}/target/archiva/WEB-INF/" />
+ <mkdir dir="${basedir}/target/archiva/WEB-INF/"/>
<copy todir="${basedir}/target/archiva/WEB-INF/">
- <fileset dir="${basedir}/target" includes="classes/" excludes="**/struts.xml" />
+ <fileset dir="${basedir}/target" includes="classes/" excludes="**/struts.xml"/>
</copy>
</tasks>
</configuration>
<configuration>
<tasks>
<copy todir="${basedir}/appserver-base">
- <fileset dir="src/appserver-base" />
+ <fileset dir="src/appserver-base"/>
</copy>
</tasks>
</configuration>
<execution>
<id>unpack-redback-war</id>
<goals>
- <goal>unpack</goal>
+ <goal>unpack</goal>
</goals>
<phase>compile</phase>
<configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.codehaus.redback</groupId>
- <artifactId>redback-struts2-content</artifactId>
- <version>${redback.version}</version>
- <type>war</type>
- <overWrite>false</overWrite>
- <outputDirectory>${project.build.directory}/redback</outputDirectory>
- <excludes>**/struts-security.xml</excludes>
- </artifactItem>
- </artifactItems>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-struts2-content</artifactId>
+ <version>${redback.version}</version>
+ <type>war</type>
+ <overWrite>false</overWrite>
+ <outputDirectory>${project.build.directory}/redback</outputDirectory>
+ <excludes>**/struts-security.xml</excludes>
+ </artifactItem>
+ </artifactItems>
</configuration>
</execution>
</executions>
<!-- Some versions of maven-war-plugin (snapshots) have this incorrectly defaulted to true.
Specifically setting this to false to avoid accidental jar file creation. -->
<archiveClasses>false</archiveClasses>
- <dependentWarExcludes>META-INF/**,WEB-INF/web.xml,WEB-INF/classes/xwork.xml,WEB-INF/lib/**</dependentWarExcludes>
- <warSourceExcludes>WEB-INF/lib/xalan-*.jar,WEB-INF/lib/velocity-dep-*.jar,WEB-INF/lib/xml-apis-*.jar,WEB-INF/lib/wstx-asl-*.jar,WEB-INF/lib/stax-utils-*.jar,WEB-INF/lib/xercesImpl-*.jar</warSourceExcludes>
- </configuration>
+ <dependentWarExcludes>META-INF/**,WEB-INF/web.xml,WEB-INF/classes/xwork.xml,WEB-INF/lib/**
+ </dependentWarExcludes>
+ <warSourceExcludes>
+ WEB-INF/lib/xalan-*.jar,WEB-INF/lib/velocity-dep-*.jar,WEB-INF/lib/xml-apis-*.jar,WEB-INF/lib/wstx-asl-*.jar,WEB-INF/lib/stax-utils-*.jar,WEB-INF/lib/xercesImpl-*.jar
+ </warSourceExcludes>
+ </configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
--- /dev/null
+package org.apache.maven.archiva.web.action;
+
+/*
+ * 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.
+ */
+
+import com.opensymphony.xwork2.Validateable;
+import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.audit.Auditable;
+import org.apache.archiva.stagerepository.merge.Maven2RepositoryMerger;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+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;
+
+/**
+ * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="mergeAction" instantiation-strategy="per-lookup"
+ */
+public class MergeAction
+ extends PlexusActionSupport
+ implements Validateable, Preparable, Auditable
+
+{
+ /**
+ * @plexus.requirement role="org.apache.archiva.stagerepository.merge.RepositoryMerger" role-hint="maven2"
+ */
+ private Maven2RepositoryMerger repositoryMerger;
+
+ /**
+ * @plexus.requirement role-hint="default"
+ */
+ private ArchivaConfiguration configuration;
+
+ private ManagedRepositoryConfiguration repository;
+
+ private String repoid;
+
+ private String targetRepoId;
+
+ private final String action = "merge";
+
+ List<ArtifactMetadata> conflictList;
+
+ public String doMerge()
+ {
+ targetRepoId = repoid + "-stage";
+ Configuration config = configuration.getConfiguration();
+ ManagedRepositoryConfiguration targetRepoConfig = config.findManagedRepositoryById( targetRepoId );
+
+ if ( targetRepoConfig != null )
+ {
+
+ try
+ {
+ repositoryMerger.merge( repoid, targetRepoId );
+ }
+ catch ( Exception e )
+ {
+ return ERROR;
+ }
+ return SUCCESS;
+ }
+ else
+ {
+ return ERROR;
+ }
+ }
+
+ public String mergeWithOutConlficts()
+ {
+
+ targetRepoId = repoid + "-stage";
+
+ try
+ {
+ conflictList = repositoryMerger.mergeWithOutConflictArtifacts( repoid, targetRepoId );
+ }
+ catch ( Exception e )
+ {
+ return ERROR;
+ }
+
+ return SUCCESS;
+ }
+
+ public void prepare()
+ throws Exception
+ {
+ this.repository = new ManagedRepositoryConfiguration();
+ }
+
+ public ManagedRepositoryConfiguration getRepository()
+ {
+ return repository;
+ }
+
+ public void setRepository( ManagedRepositoryConfiguration repository )
+ {
+ this.repository = repository;
+ }
+
+ public String getRepoid()
+ {
+ return repoid;
+ }
+
+ public void setRepoid( String repoid )
+ {
+ this.repoid = repoid;
+ }
+}
* The model for this action.
*/
private ManagedRepositoryConfiguration repository;
-
+
+ private boolean stageNeeded;
+
private String action = "addRepository";
public void prepare()
return INPUT;
}
-
+
public String confirmAdd()
{
return save();
}
-
+
public String commit()
{
File location = new File( repository.getLocation() );
if( location.exists() )
- {
+ {
return CONFIRM;
}
-
+
return save();
}
-
+
private String save()
{
Configuration configuration = archivaConfiguration.getConfiguration();
-
+
String result;
try
{
addRepository( repository, configuration );
triggerAuditEvent( repository.getId(), null, AuditEvent.ADD_MANAGED_REPO );
addRepositoryRoles( repository );
+
+ if ( stageNeeded )
+ {
+ ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig();
+
+ addRepository( stagingRepository, configuration );
+ triggerAuditEvent( stagingRepository.getId(), null, AuditEvent.ADD_MANAGED_REPO );
+ addRepositoryRoles( stagingRepository );
+
+ }
+
result = saveConfiguration( configuration );
}
catch ( RoleManagerException e )
- {
+ {
addActionError( "Role Manager Exception: " + e.getMessage() );
result = INPUT;
}
catch ( IOException e )
- {
+ {
addActionError( "Role Manager Exception: " + e.getMessage() );
result = INPUT;
}
return result;
}
+ private ManagedRepositoryConfiguration getStageRepoConfig()
+ {
+ ManagedRepositoryConfiguration stagingRepository = new ManagedRepositoryConfiguration();
+ stagingRepository.setId( repository.getId() + "-stage" );
+ stagingRepository.setLayout( repository.getLayout() );
+ stagingRepository.setName( repository.getName() + "-stage" );
+ stagingRepository.setBlockRedeployments( repository.isBlockRedeployments() );
+ stagingRepository.setDaysOlder( repository.getDaysOlder() );
+ stagingRepository.setDeleteReleasedSnapshots( repository.isDeleteReleasedSnapshots() );
+ stagingRepository.setIndexDir( repository.getIndexDir() );
+ String path = repository.getLocation();
+ int lastIndex = path.lastIndexOf( '/' );
+ stagingRepository.setLocation( path.substring( 0, lastIndex ) + "/" + stagingRepository.getId() );
+ stagingRepository.setRefreshCronExpression( repository.getRefreshCronExpression() );
+ stagingRepository.setReleases( repository.isReleases() );
+ stagingRepository.setRetentionCount( repository.getRetentionCount() );
+ stagingRepository.setScanned( repository.isScanned() );
+ stagingRepository.setSnapshots( repository.isSnapshots() );
+ return stagingRepository;
+ }
+
@Override
public void validate()
{
addFieldError( "repository.id", "Unable to add new repository with id [" + repoId
+ "], that id already exists as a repository group." );
}
-
+ else if ( repoId.toLowerCase().contains( "stage" ) )
+ {
+ addFieldError( "repository.id", "Unable to add new repository with id [" + repoId +
+ "], rpository id cannot contains word stage" );
+ }
+
if ( !validator.validate( repository.getRefreshCronExpression() ) )
{
addFieldError( "repository.refreshCronExpression", "Invalid cron expression." );
{
this.repository = repository;
}
+
+
+ public void setStageNeeded( boolean stageNeeded )
+ {
+ this.stageNeeded = stageNeeded;
+ }
public String getAction()
{
private final String action = "editRepository";
+ private boolean stageNeeded;
+
/**
* @plexus.requirement
*/
addRepository( repository, configuration );
triggerAuditEvent( repository.getId(), null, AuditEvent.MODIFY_MANAGED_REPO );
addRepositoryRoles( repository );
+
+ if ( stageNeeded )
+ {
+ ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig();
+// if(new File( stagingRepository.getLocation()).exists())
+ addRepository( stagingRepository, configuration );
+ triggerAuditEvent( stagingRepository.getId(), null, AuditEvent.ADD_MANAGED_REPO );
+ addRepositoryRoles( stagingRepository );
+
+ }
+
result = saveConfiguration( configuration );
if ( resetStats )
{
return result;
}
+ private ManagedRepositoryConfiguration getStageRepoConfig()
+ {
+ ManagedRepositoryConfiguration stagingRepository = new ManagedRepositoryConfiguration();
+ stagingRepository.setId( repository.getId() + "-stage" );
+ stagingRepository.setLayout( repository.getLayout() );
+ stagingRepository.setName( repository.getName() + "-stage" );
+ stagingRepository.setBlockRedeployments( repository.isBlockRedeployments() );
+ stagingRepository.setDaysOlder( repository.getDaysOlder() );
+ stagingRepository.setDeleteReleasedSnapshots( repository.isDeleteReleasedSnapshots() );
+ stagingRepository.setIndexDir( repository.getIndexDir() );
+ String path = repository.getLocation();
+ int lastIndex = path.lastIndexOf( '/' );
+ stagingRepository.setLocation( path.substring( 0, lastIndex ) + "/" + stagingRepository.getId() );
+ stagingRepository.setRefreshCronExpression( repository.getRefreshCronExpression() );
+ stagingRepository.setReleases( repository.isReleases() );
+ stagingRepository.setRetentionCount( repository.getRetentionCount() );
+ stagingRepository.setScanned( repository.isScanned() );
+ stagingRepository.setSnapshots( repository.isSnapshots() );
+ return stagingRepository;
+ }
+
@Override
public void validate()
{
this.repository = repository;
}
+ public boolean isStageNeeded()
+ {
+ return stageNeeded;
+ }
+
+ public void setStageNeeded( boolean stageNeeded )
+ {
+ this.stageNeeded = stageNeeded;
+ }
+
public String getAction()
{
return action;
return bundle;
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public void prepare()
{
Configuration config = archivaConfiguration.getConfiguration();
public List<ManagedRepositoryConfiguration> getManagedRepositories()
{
- return managedRepositories;
+ List<ManagedRepositoryConfiguration> managedRepositoriesList = new ArrayList<ManagedRepositoryConfiguration>();
+ for ( ManagedRepositoryConfiguration repoConfig : managedRepositories )
+ {
+ if ( !repoConfig.getId().contains( "stage" ) )
+ {
+ managedRepositoriesList.add( repoConfig );
+ }
+ }
+ return managedRepositoriesList;
}
public List<RemoteRepositoryConfiguration> getRemoteRepositories()
-->
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
- "http://struts.apache.org/dtds/struts-2.0.dtd">
+ "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- Include plexus-security xwork configurations. -->
include a result for 'error' -->
<result name="error">/WEB-INF/jsp/generalError.jsp</result>
<result name="access_to_no_repos">/WEB-INF/jsp/accessToNoRepos.jsp</result>
-
+
</global-results>
</package>
-
+
<!-- Configuration for the default package. -->
<package name="default" extends="base" namespace="/">
<result>/WEB-INF/jsp/results.jsp</result>
<result name="error">/WEB-INF/jsp/quickSearch.jsp</result>
</action>
-
+
<action name="quickSearch" class="searchAction" method="quickSearch">
<result name="input">/WEB-INF/jsp/quickSearch.jsp</result>
<result>/WEB-INF/jsp/results.jsp</result>
<result name="input">/WEB-INF/jsp/findArtifact.jsp</result>
</action>
- <action name="upload" class="uploadAction" method="input">
+ <action name="upload" class="uploadAction" method="input">
<result name="input">/WEB-INF/jsp/upload.jsp</result>
<result name="error">/WEB-INF/jsp/upload.jsp</result>
<result name="success">/WEB-INF/jsp/upload.jsp</result>
<interceptor-ref name="fileUpload"/>
</action>
- <action name="deleteArtifact" class="deleteArtifactAction" method="input">
+ <action name="deleteArtifact" class="deleteArtifactAction" method="input">
<result name="input">/WEB-INF/jsp/deleteArtifact.jsp</result>
<result name="error">/WEB-INF/jsp/deleteArtifact.jsp</result>
<result name="success">/WEB-INF/jsp/deleteArtifact.jsp</result>
<result name="artifact" type="redirect">
/browse/${databaseResults.get(0).getNamespace()}/${databaseResults.get(0).getProject()}/${databaseResults.get(0).getVersion()}
</result>
- </action>
+ </action>
<action name="browse" class="browseAction" method="browse">
<result>/WEB-INF/jsp/browse.jsp</result>
<result>/WEB-INF/jsp/showArtifact.jsp</result>
</action>
- <action name="addMetadataProperty" class="showArtifactAction" method="addMetadataProperty">
+ <action name="addMetadataProperty" class="showArtifactAction" method="addMetadataProperty">
<result name="input">/WEB-INF/jsp/showArtifact.jsp</result>
<result name="success">/WEB-INF/jsp/showArtifact.jsp</result>
</action>
<action name="index" class="repositoriesAction" method="input">
<result name="input">/WEB-INF/jsp/admin/repositories.jsp</result>
</action>
-
+
<!-- .\ REPOSITORY GROUPS \._______________________________________ -->
-
+
<action name="repositoryGroups" class="repositoryGroupsAction" method="input">
<result name="input">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
</action>
-
+
<action name="addRepositoryGroup" class="repositoryGroupsAction" method="addRepositoryGroup">
<result name="input">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
<result name="error">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
<result name="success" type="redirect-action">repositoryGroups</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
-
+
<action name="confirmDeleteRepositoryGroup" class="deleteRepositoryGroupAction" method="confirmDelete">
<result name="input">/WEB-INF/jsp/admin/deleteRepositoryGroup.jsp</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
-
+
<action name="deleteRepositoryGroup" class="deleteRepositoryGroupAction" method="delete">
<result name="input">/WEB-INF/jsp/admin/deleteRepositoryGroup.jsp</result>
<result name="error">/WEB-INF/jsp/admin/deleteRepositoryGroup.jsp</result>
<result name="success" type="redirect-action">repositoryGroups</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
-
+
<action name="addRepositoryToGroup" class="repositoryGroupsAction" method="addRepositoryToGroup">
<result name="input">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
<result name="error">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
<result name="success" type="redirect-action">repositoryGroups</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
-
+
<action name="removeRepositoryFromGroup" class="repositoryGroupsAction" method="removeRepositoryFromGroup">
<result name="input">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
<result name="error">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
<result name="success" type="redirect-action">repositoryGroups</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
-
+
<action name="sortDownRepositoryFromGroup" class="sortRepositoriesAction" method="sortDown">
<result name="input">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
<result name="error">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
<result name="success" type="redirect-action">repositoryGroups</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
-
+
<action name="sortUpRepositoryFromGroup" class="sortRepositoriesAction" method="sortUp">
<result name="input">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
<result name="error">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
<action name="indexRepository" class="schedulerAction" method="scanRepository">
<result type="redirect-action">repositories</result>
</action>
-
+
<action name="addRepository" class="addManagedRepositoryAction" method="input">
<result name="input">/WEB-INF/jsp/admin/addRepository.jsp</result>
<result name="error">/WEB-INF/jsp/admin/addRepository.jsp</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
- <action name="deleteRemoteRepository" class="deleteRemoteRepositoryAction" method="delete">
+ <action name="conflictsArtifacts" class="mergeAction" method="mergeWithOutConlficts" >
+ <result name="success"> /WEB-INF/jsp/mergeActionResults.jsp</result>
+ <interceptor-ref name="configuredPrepareParamsStack"/>
+ </action>
+
+ <action name="merge" class="mergeAction" method="doMerge" >
+ <!--<result name="input"> /WEB-INF/jsp/mergeAction.jsp</result>-->
+ <!--<result name="conflictsAvailable"> /WEB-INF/jsp/mergeExcludeConflicts.jsp</result>-->
+ <result name="success"> /WEB-INF/jsp/mergeActionResults.jsp</result>
+ <interceptor-ref name="configuredPrepareParamsStack"/>
+ </action>
+
+
+ <action name="deleteRemoteRepository" class="deleteRemoteRepositoryAction" method="input">
<result name="input">/WEB-INF/jsp/admin/deleteRemoteRepository.jsp</result>
<result name="error">/WEB-INF/jsp/admin/deleteRemoteRepository.jsp</result>
<result name="success" type="redirect-action">repositories</result>
<result name="success" type="redirect-action">proxyConnectors</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
-
+
<action name="enableProxyConnector" class="enableProxyConnectorAction" method="confirm">
<result name="input">/WEB-INF/jsp/admin/enableProxyConnector.jsp</result>
<result name="success" type="redirect-action">proxyConnectors</result>
<result name="blank">/WEB-INF/jsp/reports/blankReport.jsp</result>
<result>/WEB-INF/jsp/reports/basicReport.jsp</result>
</action>
-
+
<action name="generateStatisticsReport" class="generateReport" method="generateStatistics">
<result name="input">/WEB-INF/jsp/reports/pickReport.jsp</result>
<result name="blank">/WEB-INF/jsp/reports/blankReport.jsp</result>
<result>/WEB-INF/jsp/reports/statisticsReport.jsp</result>
</action>
-
+
<!-- TODO: make report filename dynamic -->
<action name="downloadStatsReport" class="generateReport" method="downloadStatisticsReport">
<result name="input">/WEB-INF/jsp/reports/pickReport.jsp</result>
<param name="contentDisposition">attachment; filename="archiva_statistics_report.csv"</param>
</result>
</action>
-
+
<!-- audit logs -->
<action name="queryAuditLogReport" class="viewAuditLogReport" method="input">
<result name="input">/WEB-INF/jsp/reports/auditLogReport.jsp</result>
</action>
-
+
<action name="viewAuditLogReport" class="viewAuditLogReport">
<result name="input">/WEB-INF/jsp/reports/auditLogReport.jsp</result>
<result>/WEB-INF/jsp/reports/auditLogReport.jsp</result>
</action>
-
+
</package>
</struts>
<s:form method="post" action="addRepository!commit" namespace="/admin" validate="true">
<s:textfield name="repository.id" label="Identifier" size="10" required="true"/>
<%@ include file="/WEB-INF/jsp/admin/include/repositoryForm.jspf" %>
+ <s:checkbox name="stageNeeded" value="stageNeeded" label="Create stage repository"/>
<s:submit value="Add Repository"/>
</s:form>
<s:hidden name="repository.id"/>
<s:label label="ID" name="repository.id" />
<%@ include file="/WEB-INF/jsp/admin/include/repositoryForm.jspf" %>
+ <s:checkbox name="stageNeeded" value="stageNeeded" label="Create stage repository"/>
<s:submit value="Update Repository"/>
</s:form>
<s:checkbox name="repository.scanned" value="repository.scanned" label="Scannable"/>
<s:checkbox name="repository.deleteReleasedSnapshots" value="repository.deleteReleasedSnapshots"
label="Delete Released Snapshots"/>
-
-
<%@ 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(){
-
- $(".pom").hide();
- $("a.expand").click(function(event){
- event.preventDefault();
- $(this).siblings("pre").toggle("slow");
- });
-
- });
+ $(document).ready(function()
+ {
+
+ $(".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>
<table class="infoTable">
<tr>
- <th>Identifier</th>
+ <th>Groups</th>
<td>
- <code>${repository.id}</code>
+ <c:forEach items="${repositoryToGroupMap[repository.id]}" varStatus="i" var="group">
+ ${group}<c:if test="${!i.last}">,</c:if>
+ </c:forEach>
</td>
</tr>
<tr>
- <th>Name</th>
- <td>
- <code>${repository.name}</code>
- </td>
+ <th>Delete Released Snapshots</th>
+ <td class="${repository.deleteReleasedSnapshots ? 'donemark' : 'errormark'} booleanIcon"></td>
</tr>
<tr>
- <th>Directory</th>
- <td>${repository.location}</td>
+ <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 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>
+ <th>Scanning Cron</th>
+ <td>${repository.refreshCronExpression}</td>
</tr>
<tr>
- <th>Type</th>
- <%-- TODO: can probably just use layout appended to a key prefix in i18n to simplify this --%>
+ <th>
+ Actions
+ </th>
<td>
<c:choose>
- <c:when test="${repository.layout == 'default'}">
- Maven 2.x Repository
+ <c:when test="${empty (stats)}">
+ No Statistics Available.
</c:when>
<c:otherwise>
- Maven 1.x Repository
+ <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>
<th>Groups</th>
<td>
<c:forEach items="${repositoryToGroupMap[repository.id]}" varStatus="i" var="group">
- ${group}<c:if test="${!i.last}">,</c:if>
+ ${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>
+ <td class="${repository.releases ? 'donemark' : 'errormark'} booleanIcon"></td>
</tr>
<tr>
<th>Snapshots Included</th>
- <td class="${repository.snapshots ? 'donemark' : 'errormark'} booleanIcon"> </td>
+ <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>
+ <td class="${repository.deleteReleasedSnapshots ? 'donemark' : 'errormark'} booleanIcon"></td>
</tr>
<tr>
<th>Repository Purge By Days Older Than</th>
</c:if>
<tr>
<th>Scanned</th>
- <td class="${repository.scanned ? 'donemark' : 'errormark'} booleanIcon"> </td>
+ <td class="${repository.scanned ? 'donemark' : 'errormark'} booleanIcon"></td>
</tr>
<c:if test="${repository.scanned}">
<tr>
<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: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>
<tr>
<th>Stats</th>
<td>
<tr>
<th>POM Snippet</th>
<td>
- <archiva:copy-paste-snippet object="${repository}" wrapper="toggle" />
+ <archiva:copy-paste-snippet object="${repository}" wrapper="toggle"/>
</td>
+
</tr>
+
+
+<c:set var="str" value="${repository.id}"/>
+<jsp:useBean id="str" type="java.lang.String"/>
+<c:if test='<%= !( (str.equalsIgnoreCase("internal") ) || (str.equalsIgnoreCase( "snapshots" )) )%>'>
+ <tr>
+ <th>Merge Actions</th>
+ <td >
+ <redback:ifAuthorized permission="archiva-run-indexer">
+ <s:form action="merge" theme="simple">
+ <s:hidden name="repoid" value="%{#attr.repository.id}"/>
+ <table>
+ <tr>
+ <td><s:submit value="Merge All"/></td>
+ </tr>
+
+ </table>
+ </s:form>
+ </redback:ifAuthorized>
+ </td>
+ <td align="left">
+ <redback:ifAuthorized permission="archiva-run-indexer">
+ <s:form action="conflictsArtifacts" theme="simple">
+ <s:hidden name="repoid" value="%{#attr.repository.id}"/>
+ <table>
+ <tr>
+ <td align="left" ><s:submit value="Merge With skip"/></td>
+ </tr>
+
+ </table>
+ </s:form>
+ </redback:ifAuthorized>
+ </td>
+</tr>
+
+</c:if>
+
+
+
</table>
</div>
--- /dev/null
+<%--
+ ~ 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.
+ --%>
+
+<%-- http://www.opensymphony.com/webwork/wikidocs/File%20Upload%20Interceptor.html --%>
+
+<%@ page contentType="text/html; charset=UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+
+<s:hidden name="repository.id"/>
+ <s:label label="ID" name="repository.id" />
+
+<s:textfield name="repository.name" label="Name" size="50" required="true"/>
+<s:textfield name="repository.location" label="Directory" size="50" required="true"/>
+<s:textfield name="repository.indexDir" label="Index Directory" size="50"/>
+<s:select list="#@java.util.LinkedHashMap@{'default' : 'Maven 2.x Repository', 'legacy' : 'Maven 1.x Repository'}"
+ name="repository.layout" label="Type"/>
+<s:textfield name="repository.refreshCronExpression" label="Cron" size="40" required="true"/>
+<s:textfield name="repository.daysOlder" label="Repository Purge By Days Older Than" size="5"/>
+<s:textfield name="repository.retentionCount" label="Repository Purge By Retention Count" size="5"/>
+<s:checkbox name="repository.releases" value="repository.releases" label="Releases Included"/>
+<s:checkbox name="repository.blockRedeployments" value="repository.blockRedeployments" label="Block Re-deployment of Released Artifacts"/>
+<s:checkbox name="repository.snapshots" value="repository.snapshots" label="Snapshots Included"/>
+<s:checkbox name="repository.scanned" value="repository.scanned" label="Scannable"/>
+<s:checkbox name="repository.deleteReleasedSnapshots" value="repository.deleteReleasedSnapshots"
+ label="Delete Released Snapshots"/>
\ No newline at end of file
--- /dev/null
+<%--
+ ~ 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.
+ --%>
+
+<%-- http://www.opensymphony.com/webwork/wikidocs/File%20Upload%20Interceptor.html --%>
+
+<%@ page contentType="text/html; charset=UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+
+<html>
+<head>
+ <title>Merge Repositories</title>
+ <s:head/>
+</head>
+
+<body>
+<h1>Merge Repositories</h1>
+
+<div id="contentArea">
+
+ <s:actionerror/>
+ <s:actionmessage/>
+ <s:form action="merge!doMerge" method="post" namespace="/admin" validate="false">
+ <s:hidden name="repository.id"/>
+ <%--<s:label label="ID" name="repoid" value="repository.id"/>--%>
+ <%--<%@ include file="/WEB-INF/jsp/include/mergeActionForm.jspf" %>--%>
+
+ <s:submit/>
+ </s:form>
+</div>
+
+</body>
+</html>
--- /dev/null
+<%--
+ ~ 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.
+ --%>
+
+<%-- http://www.opensymphony.com/webwork/wikidocs/File%20Upload%20Interceptor.html --%>
+
+<%@ page contentType="text/html; charset=UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+
+<html>
+<head>
+ <title>Merge Repositories</title>
+ <s:head/>
+</head>
+
+<body>
+<h1>Merge Repositories</h1>
+
+<div id="contentArea">
+
+ <s:actionerror/>
+ <s:actionmessage/>
+ <h1>successfully done the merging</h1>
+</div>
+
+</body>
+</html>
--- /dev/null
+<%--
+ ~ 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" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+
+<html>
+<head>
+ <title>Admin: Add Managed Repository</title>
+ <s:head/>
+</head>
+
+<body>
+
+<h1>Admin: Add Managed Repository</h1>
+
+ <div class="warningbox">
+ <p>
+ <strong>WARNING: There Are some conflicts Artifacts.</strong>
+ </p>
+ </div>
+
+ <p>
+ Are you sure you want to merge the Repository
+ <%--<c:choose>--%>
+ <%--<c:when test="${action == 'merge'}">add</c:when>--%>
+ <%--<c:otherwise>update</c:otherwise>--%>
+ <%--</c:choose>--%>
+
+ </p>
+
+ <div class="infobox">
+ <table class="infotable">
+ <tr>
+ <td>ID:</td>
+ <td><code>${repository.id}</code></td>
+ </tr>
+ <tr>
+ <td>Name:</td>
+ <td>${repository.name}</td>
+ </tr>
+ <tr>
+ <td>Directory:</td>
+ <td>${repository.location}</td>
+ </tr>
+ <tr>
+ <td>Index Directory:</td>
+ <td>${repository.indexDir}</td>
+ </tr>
+ <tr>
+ <td>Type:</td>
+ <%--td>${repository.layout}</td--%>
+ <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>
+ <tr>
+ <td>Cron:</td>
+ <td>${repository.refreshCronExpression}</td>
+ </tr>
+ <tr>
+ <td>Repository Purge By Days Older Than:</td>
+ <td>${repository.daysOlder}</td>
+ </tr>
+ <tr>
+ <td>Repository Purge By Retention Count:</td>
+ <td>${repository.retentionCount}</td>
+ </tr>
+ <tr>
+ <td>Releases Included:</td>
+ <td class="${repository.releases ? 'donemark' : 'errormark'} booleanIcon">
+ </tr>
+ <tr>
+ <td>Snapshots Included:</td>
+ <td class="${repository.snapshots ? 'donemark' : 'errormark'} booleanIcon">
+ </tr>
+ <tr>
+ <td>Scannable:</td>
+ <td class="${repository.scanned ? 'donemark' : 'errormark'} booleanIcon">
+ </tr>
+ <tr>
+ <td>Delete Released Snapshots:</td>
+ <td class="${repository.deleteReleasedSnapshots ? 'donemark' : 'errormark'} booleanIcon">
+ </tr>
+ </table>
+ </div>
+
+ <s:form method="post" action="%{action}" namespace="/admin" validate="true" theme="simple">
+ <div class="buttons">
+ <s:hidden name="repository.id" value="%{#attr.repository.id}"/>
+ <s:hidden name="repository.name" value="%{#attr.repository.name}"/>
+ <s:hidden name="repository.location" value="%{#attr.repository.location}"/>
+ <s:hidden name="repository.indexDir" value="%{#attr.repository.indexDir}"/>
+ <s:hidden name="repository.layout" value="%{#attr.repository.layout}"/>
+ <s:hidden name="repository.refreshCronExpression" value="%{#attr.repository.refreshCronExpression}"/>
+ <s:hidden name="repository.daysOlder" value="%{#attr.repository.daysOlder}"/>
+ <s:hidden name="repository.retentionCount" value="%{#attr.repository.retentionCount}"/>
+ <s:hidden name="repository.releases" value="%{#attr.repository.releases}"/>
+ <s:hidden name="repository.snapshots" value="%{#attr.repository.snapshots}"/>
+ <s:hidden name="repository.scanned" value="%{#attr.repository.scanned}"/>
+ <s:hidden name="repository.deleteReleasedSnapshots" value="%{#attr.repository.deleteReleasedSnapshots}"/>
+
+ <%--<c:choose>--%>
+
+ <s:submit value="Save" method="merge"/>
+ <%--<c:when test="${action == 'addRepository'}">--%>
+ <%--<s:submit value="Save" method="confirmAdd"/>--%>
+ <%--</c:when>--%>
+ <%--<c:otherwise>--%>
+ <%--<s:submit value="Save" method="confirmUpdate"/>--%>
+ <%--</c:otherwise>--%>
+ <%--</c:choose>--%>
+
+ <s:submit value="Cancel" method="execute"/>
+ </div>
+ </s:form>
+
+</body>
+</html>
import org.apache.archiva.metadata.repository.filter.IncludesFilter;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
-import org.apache.maven.archiva.repository.RepositoryContentFactory;
-import org.apache.maven.archiva.repository.ManagedRepositoryContent;
-import org.apache.maven.archiva.repository.RepositoryNotFoundException;
import org.apache.maven.archiva.repository.RepositoryException;
import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException;
import org.apache.maven.archiva.repository.metadata.RepositoryMetadataWriter;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.model.ArchivaArtifact;
import org.apache.maven.archiva.model.ArchivaRepositoryMetadata;
import org.apache.maven.archiva.common.utils.VersionComparator;
import org.apache.maven.archiva.common.utils.VersionUtil;
this.configuration = configuration;
}
- public void setMetadataRepository( MetadataRepository metadataRepository )
+ public void setMetadataRepository( MetadataRepository metadataRepository )
{
this.metadataRepository = metadataRepository;
}
// TODO when UI needs a subset to merge
public void merge( String sourceRepoId, String targetRepoId, Filter<ArtifactMetadata> filter )
+ throws Exception
{
-
+ List<ArtifactMetadata> sourceArtifacts = metadataRepository.getArtifacts( sourceRepoId );
+ for ( ArtifactMetadata metadata : sourceArtifacts )
+ {
+ if ( filter.accept( metadata ) )
+ {
+ createFolderStructure( sourceRepoId, targetRepoId, metadata );
+ }
+ }
}
private void createFolderStructure( String sourceRepoId, String targetRepoId, ArtifactMetadata artifactMetadata )
String sourceRepoPath = sourceRepoConfig.getLocation();
- String artifactPath =
- pathTranslator.toPath( artifactMetadata.getNamespace(), artifactMetadata.getProject(),
- artifactMetadata.getProjectVersion(), artifactMetadata.getId() );
+ String artifactPath = pathTranslator.toPath( artifactMetadata.getNamespace(), artifactMetadata.getProject(),
+ artifactMetadata.getProjectVersion(), artifactMetadata.getId() );
File sourceArtifactFile = new File( sourceRepoPath, artifactPath );
// pom file copying
String fileName = artifactMetadata.getProject() + "-" + artifactMetadata.getVersion() + ".pom";
- // pom file copying
+ // pom file copying
// TODO need to use path translator to get the pom file path
// String fileName = artifactMetadata.getProject() + "-" + artifactMetadata.getVersion() + ".pom";
//
// updating version metadata files
File versionMetaDataFileInSourceRepo =
pathTranslator.toFile( new File( sourceRepoPath ), artifactMetadata.getNamespace(),
- artifactMetadata.getProject(), artifactMetadata.getVersion(), METADATA_FILENAME );
+ artifactMetadata.getProject(), artifactMetadata.getVersion(),
+ METADATA_FILENAME );
String relativePathToVersionMetadataFile =
versionMetaDataFileInSourceRepo.getAbsolutePath().split( sourceRepoPath )[1];
File versionMetaDataFileInTargetRepo = new File( targetRepoPath, relativePathToVersionMetadataFile );
}
return metadata;
}
+
+ public List<ArtifactMetadata> mergeWithOutConflictArtifacts( String sourceRepo, String targetRepo )
+ throws Exception
+ {
+
+ List<ArtifactMetadata> targetArtifacts = metadataRepository.getArtifacts( targetRepo );
+ List<ArtifactMetadata> sourceArtifacts = metadataRepository.getArtifacts( sourceRepo );
+ List<ArtifactMetadata> conflictsArtifacts = new ArrayList<ArtifactMetadata>();
+
+ for ( ArtifactMetadata targerArtifact : targetArtifacts )
+ {
+
+ for ( ArtifactMetadata sourceArtifact : sourceArtifacts )
+ {
+
+ if ( isEquals( targerArtifact, sourceArtifact ) )
+ {
+ if ( !conflictsArtifacts.contains( sourceArtifact ) )
+ {
+ conflictsArtifacts.add( sourceArtifact );
+
+ }
+
+ }
+
+ }
+ }
+
+ sourceArtifacts.removeAll( conflictsArtifacts );
+ Filter<ArtifactMetadata> artifactsWithOutConflicts = new IncludesFilter<ArtifactMetadata>( sourceArtifacts );
+ merge( sourceRepo, targetRepo, artifactsWithOutConflicts );
+ return conflictsArtifacts;
+ }
+
+ private boolean isEquals( ArtifactMetadata sourceArtifact, ArtifactMetadata targetArtifact )
+ {
+ boolean isSame = false;
+
+ 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;
+ }
+ }
+
+ return isSame;
+ }
}
void merge( String sourceRepoId, String targetRepoId )
throws Exception;
- void merge( String sourceRepoId, String targetRepoId, Filter<ArtifactMetadata> filter );
+ void merge( String sourceRepoId, String targetRepoId, Filter<ArtifactMetadata> filter ) throws Exception;
}
import java.util.List;
import java.util.ArrayList;
+import java.io.File;
public class Maven2RepositoryMergerTest
extends PlexusInSpringTestCase
super.setUp();
MockitoAnnotations.initMocks( this );
metadataRepository = mock( MetadataRepository.class );
+ repositoryMerger = (Maven2RepositoryMerger) lookup( RepositoryMerger.class, "maven2" );
+ repositoryMerger.setMetadataRepository( metadataRepository );
+ }
+
+ private List<ArtifactMetadata> getArtifacts()
+ {
+ List<ArtifactMetadata> metadata = new ArrayList<ArtifactMetadata>();
+ ArtifactMetadata artifact1 = new ArtifactMetadata();
+ artifact1.setNamespace( "com.example.test" );
+ artifact1.setProject( "test-artifact" );
+ artifact1.setVersion( "1.0-SNAPSHOT" );
+ artifact1.setProjectVersion( "1.0-SNAPSHOT" );
+ artifact1.setId( "test-artifact-1.0-20100308.230825-1.jar" );
+
+ metadata.add( artifact1 );
+ return metadata;
+ }
+ public void testMerge()
+ throws Exception
+ {
ArchivaConfiguration configuration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class );
Configuration c = new Configuration();
ManagedRepositoryConfiguration testRepo = new ManagedRepositoryConfiguration();
c.addManagedRepository( targetRepo );
configuration.save( c );
- repositoryMerger = (Maven2RepositoryMerger) lookup( RepositoryMerger.class, "maven2" );
- repositoryMerger.setMetadataRepository( metadataRepository );
+ when( metadataRepository.getArtifacts( TEST_REPO_ID ) ).thenReturn( getArtifacts() );
+ repositoryMerger.merge( TEST_REPO_ID, "target-rep" );
+ verify( metadataRepository ).getArtifacts( TEST_REPO_ID );
}
- private List<ArtifactMetadata> getArtifacts()
+ public void testMergeWithOutConflictArtifacts()
+ throws Exception
{
- List<ArtifactMetadata> metadata = new ArrayList<ArtifactMetadata>();
+ String sourceRepoId = "source-repo";
ArtifactMetadata artifact1 = new ArtifactMetadata();
- artifact1.setNamespace( "com.example.test" );
- artifact1.setProject( "test-artifact" );
- artifact1.setVersion( "1.0-SNAPSHOT" );
- artifact1.setProjectVersion( "1.0-SNAPSHOT" );
- artifact1.setId( "test-artifact-1.0-20100308.230825-1.jar" );
+ artifact1.setNamespace( "org.testng" );
+ artifact1.setProject( "testng" );
+ artifact1.setVersion( "5.8" );
+ artifact1.setProjectVersion( "5.8" );
+ artifact1.setId( "testng-5.8-jdk15.jar" );
+ artifact1.setRepositoryId( sourceRepoId );
- metadata.add( artifact1 );
- return metadata;
- }
+ List<ArtifactMetadata> sourceRepoArtifactsList = getArtifacts();
+ sourceRepoArtifactsList.add( artifact1 );
+ List<ArtifactMetadata> targetRepoArtifactsList = getArtifacts();
- public void testMerge()
- throws Exception
- {
- when( metadataRepository.getArtifacts( TEST_REPO_ID ) ).thenReturn( getArtifacts() );
- repositoryMerger.merge( TEST_REPO_ID, "target-rep" );
+ ArchivaConfiguration configuration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class );
+ Configuration c = new Configuration();
+ ManagedRepositoryConfiguration testRepo = new ManagedRepositoryConfiguration();
+ testRepo.setId( TEST_REPO_ID );
+ testRepo.setLocation( getTestPath( "target/test-repository" ) );
+
+ String sourceRepo = "src/test/resources/test-repository-with-conflict-artifacts";
+ ManagedRepositoryConfiguration testRepoWithConflicts = new ManagedRepositoryConfiguration();
+ testRepoWithConflicts.setId( sourceRepoId );
+ testRepoWithConflicts.setLocation( getTestPath( sourceRepo ) );
+
+ RepositoryScanningConfiguration repoScanConfig = new RepositoryScanningConfiguration();
+ List<String> knownContentConsumers = new ArrayList<String>();
+ knownContentConsumers.add( "metadata-updater" );
+ repoScanConfig.setKnownContentConsumers( knownContentConsumers );
+ c.setRepositoryScanning( repoScanConfig );
+
+ c.addManagedRepository( testRepo );
+ c.addManagedRepository( testRepoWithConflicts );
+ configuration.save( c );
+
+ File targetRepoFile = new File( getTestPath(
+ "/target/test-repository/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100308.230825-1.jar" ) );
+ targetRepoFile.setReadOnly();
+
+ when( metadataRepository.getArtifacts( sourceRepoId ) ).thenReturn( sourceRepoArtifactsList );
+ when( metadataRepository.getArtifacts( TEST_REPO_ID ) ).thenReturn( targetRepoArtifactsList );
+
+ assertEquals( 1, repositoryMerger.mergeWithOutConflictArtifacts( sourceRepoId, TEST_REPO_ID ).size() );
verify( metadataRepository ).getArtifacts( TEST_REPO_ID );
}
+
}
\ No newline at end of file
--- /dev/null
+invalid path
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+ <groupId>com.example.test</groupId>
+ <artifactId>test-artifact</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <versioning>
+ <snapshot>
+ <timestamp>20100310.014828</timestamp>
+ <buildNumber>2</buildNumber>
+ </snapshot>
+ <lastUpdated>20100310014828</lastUpdated>
+ </versioning>
+</metadata>
--- /dev/null
+aad6835e3e7a4a9de5318ce9183eab54
\ No newline at end of file
--- /dev/null
+73669371dc2fdae2fa9a129932ed0932d62d9e6b
\ No newline at end of file
--- /dev/null
+cc2236dd70af3667080a786c7dcb4a9b
\ No newline at end of file
--- /dev/null
+edf5938e646956f445c6ecb719d44579cdeed974
\ No newline at end of file
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.example.test</groupId>
+ <artifactId>test-artifact</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>test-artifact</name>
+ <url>http://maven.apache.org</url>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <distributionManagement>
+ <repository>
+ <id>test-repo</id>
+ <url>file:${basedir}/repository</url>
+ </repository>
+ </distributionManagement>
+</project>
--- /dev/null
+ce7eeb9586dc4992dc961d9f3a28006b
\ No newline at end of file
--- /dev/null
+be040c8462fd31d4e03749e3586afbb21f43594e
\ No newline at end of file
--- /dev/null
+e034e44b0d9f3968ebfbc66c71b41ba0
\ No newline at end of file
--- /dev/null
+ca8d1408b05d125d0307dbd23063e5aa04235d35
\ No newline at end of file
--- /dev/null
+a47f0edab0271fc55a3db38098f5f78a
\ No newline at end of file
--- /dev/null
+af4c914ef8f80be2a8241fb4d40cff11f4348c0f
\ No newline at end of file
--- /dev/null
+37786de9e272ed6db8541855e0e2d5dc
\ No newline at end of file
--- /dev/null
+bb1ca7834422926d0cb79ef303b715bc17f41661
\ No newline at end of file
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.example.test</groupId>
+ <artifactId>test-artifact</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>test-artifact</name>
+ <url>http://maven.apache.org</url>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <distributionManagement>
+ <repository>
+ <id>test</id>
+ <url>file:${basedir}/repository</url>
+ </repository>
+ </distributionManagement>
+</project>
--- /dev/null
+0612c49b1ac80983bfda08616330a4b8
\ No newline at end of file
--- /dev/null
+156d6062060743bf28df306e067914d3d692b571
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+ <groupId>com.example.test</groupId>
+ <artifactId>test-artifact</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <versioning>
+ <snapshot>
+ <timestamp>20100310.014828</timestamp>
+ <buildNumber>2</buildNumber>
+ </snapshot>
+ <lastUpdated>20100310014828</lastUpdated>
+ </versioning>
+</metadata>
--- /dev/null
+4c0a7072d66cfe2deebd3eb998332ccb
\ No newline at end of file
--- /dev/null
+64c28127c4923ff352021bdfdad448d2d881ef3b
\ No newline at end of file
--- /dev/null
+e20c52f8ef51c1cbd52348d40d22422da649578b testng-5.8-jdk15.jar
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <!--
+ This POM cannot be used to build TestNG; it should only be used as part of a Maven
+ repository upload bundle.
+
+ See the guide to creating a bundle here:
+ http://maven.apache.org/guides/mini/guide-central-repository-upload.html
+ -->
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <name>TestNG</name>
+ <version>5.8</version>
+ <description>TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use.</description>
+ <url>http://testng.org</url>
+
+ <licenses>
+ <license>
+ <name>Apache License, Version 2.0</name>
+ <url>http://apache.org/licenses/LICENSE-2.0</url>
+ </license>
+ </licenses>
+
+ <scm>
+ <connection>scm:svn:http://testng.googlecode.com/svn/trunk/</connection>
+ <developerConnection>scm:svn:http://testng.googlecode.com/svn/trunk/</developerConnection>
+ <url>http://testng.googlecode.com/svn/trunk</url>
+ </scm>
+
+ <dependencies>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.6.5</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ </dependency>
+ <dependency>
+ <groupId>qdox</groupId>
+ <artifactId>qdox</artifactId>
+ <version>1.6.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.beanshell</groupId>
+ <artifactId>bsh</artifactId>
+ <version>2.0b4</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
--- /dev/null
+71df4387b8c96e5d2226cfa1e36acaebb96ba0f2 /home/maven/repository-staging/to-ibiblio/maven2/org/testng/testng/5.8/testng-5.8.pom