mirror of https://github.com/apache/archiva.git
some low hanging fruit in the quest to improve the staging repository implementation
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1141002 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
506b6613ed
commit
31e93bb1c9
|
@ -24,6 +24,11 @@
|
||||||
<id>archiva-run-indexer</id>
|
<id>archiva-run-indexer</id>
|
||||||
<name>archiva-run-indexer</name>
|
<name>archiva-run-indexer</name>
|
||||||
<description>Run Archiva Indexer</description>
|
<description>Run Archiva Indexer</description>
|
||||||
|
</operation>
|
||||||
|
<operation>
|
||||||
|
<id>archiva-merge-stage</id>
|
||||||
|
<name>archiva-merge-stage</name>
|
||||||
|
<description>Merge Stage Repository</description>
|
||||||
</operation>
|
</operation>
|
||||||
<operation>
|
<operation>
|
||||||
<id>archiva-delete-artifact</id>
|
<id>archiva-delete-artifact</id>
|
||||||
|
@ -252,6 +257,12 @@
|
||||||
<operation>archiva-delete-metadata</operation>
|
<operation>archiva-delete-metadata</operation>
|
||||||
<resource>${resource}</resource>
|
<resource>${resource}</resource>
|
||||||
</permission>
|
</permission>
|
||||||
|
<permission>
|
||||||
|
<id>archiva-merge-repository</id>
|
||||||
|
<name>Archiva Merge Repository</name>
|
||||||
|
<operation>archiva-merge-repository</operation>
|
||||||
|
<resource>${resource}</resource>
|
||||||
|
</permission>
|
||||||
</permissions>
|
</permissions>
|
||||||
<childTemplates>
|
<childTemplates>
|
||||||
<childTemplate>archiva-repository-observer</childTemplate>
|
<childTemplate>archiva-repository-observer</childTemplate>
|
||||||
|
|
|
@ -38,12 +38,11 @@ import org.codehaus.plexus.taskqueue.TaskQueueException;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Named;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* plexus.component role="com.opensymphony.xwork2.Action" role-hint="mergeAction" instantiation-strategy="per-lookup"
|
* plexus.component role="com.opensymphony.xwork2.Action" role-hint="mergeAction" instantiation-strategy="per-lookup"
|
||||||
|
@ -104,7 +103,6 @@ public class MergeAction
|
||||||
}
|
}
|
||||||
|
|
||||||
public String doMerge()
|
public String doMerge()
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
RepositorySession repositorySession = repositorySessionFactory.createSession();
|
RepositorySession repositorySession = repositorySessionFactory.createSession();
|
||||||
try
|
try
|
||||||
|
@ -132,10 +130,10 @@ public class MergeAction
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
catch ( Exception ex )
|
catch ( Exception e )
|
||||||
{
|
{
|
||||||
ex.printStackTrace();
|
log.error( e.getMessage(), e );
|
||||||
addActionError( "Error occurred while merging the repositories." );
|
addActionError( "Error occurred while merging the repositories: " + e.getMessage() );
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -175,10 +173,10 @@ public class MergeAction
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
catch ( Exception ex )
|
catch ( Exception e )
|
||||||
{
|
{
|
||||||
ex.printStackTrace();
|
log.error( e.getMessage(), e );
|
||||||
addActionError( "Error occurred while merging the repositories." );
|
addActionError( "Error occurred while merging the repositories: " + e.getMessage() );
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -288,12 +286,7 @@ public class MergeAction
|
||||||
metadata.getNamespace() + metadata.getProject() + metadata.getProjectVersion() + metadata.getVersion();
|
metadata.getNamespace() + metadata.getProject() + metadata.getProjectVersion() + metadata.getVersion();
|
||||||
map.put( metadataId, metadata );
|
map.put( metadataId, metadata );
|
||||||
}
|
}
|
||||||
Iterator iterator = map.keySet().iterator();
|
conflictSourceArtifactsToBeDisplayed.addAll( map.values() );
|
||||||
|
|
||||||
while ( iterator.hasNext() )
|
|
||||||
{
|
|
||||||
conflictSourceArtifactsToBeDisplayed.add( map.get( iterator.next() ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mergeWithOutSnapshots( MetadataRepository metadataRepository, List<ArtifactMetadata> sourceArtifacts,
|
private void mergeWithOutSnapshots( MetadataRepository metadataRepository, List<ArtifactMetadata> sourceArtifacts,
|
||||||
|
|
|
@ -196,7 +196,7 @@ public class AddManagedRepositoryAction
|
||||||
else if ( repoId.toLowerCase().contains( "stage" ) )
|
else if ( repoId.toLowerCase().contains( "stage" ) )
|
||||||
{
|
{
|
||||||
addFieldError( "repository.id", "Unable to add new repository with id [" + repoId
|
addFieldError( "repository.id", "Unable to add new repository with id [" + repoId
|
||||||
+ "], rpository id cannot contains word stage" );
|
+ "], repository id cannot contains word stage" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !validator.validate( repository.getRefreshCronExpression() ) )
|
if ( !validator.validate( repository.getRefreshCronExpression() ) )
|
||||||
|
|
|
@ -41,13 +41,13 @@ import org.codehaus.redback.integration.interceptor.SecureActionException;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows the Repositories Tab for the administrator.
|
* Shows the Repositories Tab for the administrator.
|
||||||
|
@ -150,7 +150,7 @@ public class RepositoriesAction
|
||||||
List<ManagedRepositoryConfiguration> managedRepositoriesList = new ArrayList<ManagedRepositoryConfiguration>();
|
List<ManagedRepositoryConfiguration> managedRepositoriesList = new ArrayList<ManagedRepositoryConfiguration>();
|
||||||
for ( ManagedRepositoryConfiguration repoConfig : managedRepositories )
|
for ( ManagedRepositoryConfiguration repoConfig : managedRepositories )
|
||||||
{
|
{
|
||||||
if ( !repoConfig.getId().contains( "stage" ) )
|
if ( !repoConfig.getId().endsWith( "-stage" ) )
|
||||||
{
|
{
|
||||||
managedRepositoriesList.add( repoConfig );
|
managedRepositoriesList.add( repoConfig );
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,16 +53,14 @@
|
||||||
<s:label label="ID" name="repository.id" />
|
<s:label label="ID" name="repository.id" />
|
||||||
<%@ include file="/WEB-INF/jsp/admin/include/repositoryForm.jspf" %>
|
<%@ include file="/WEB-INF/jsp/admin/include/repositoryForm.jspf" %>
|
||||||
|
|
||||||
<c:set var="stats" value="${stagingRepository == null}"/>
|
<c:choose>
|
||||||
<jsp:useBean id="stats" type="java.lang.Boolean" scope="page"/>
|
<c:when test="${empty(stagingRepository)}">
|
||||||
<c:if
|
<s:checkbox id="stageNeeded" name="stageNeeded" value="false" label="Create stage repository"/>
|
||||||
test='<%= !stats.booleanValue() %>'>
|
</c:when>
|
||||||
<s:checkbox name="stageNeeded" value="true" label="Create stage repository"/>
|
<c:otherwise>
|
||||||
</c:if>
|
<s:checkbox name="stageNeeded" value="true" label="Create stage repository"/>
|
||||||
<c:if
|
</c:otherwise>
|
||||||
test='<%= stats.booleanValue() %>'>
|
</c:choose>
|
||||||
<s:checkbox id="stageNeeded" name="stageNeeded" value="false" label="Create stage repository"/>
|
|
||||||
</c:if>
|
|
||||||
<s:submit value="Update Repository"/>
|
<s:submit value="Update Repository"/>
|
||||||
</s:form>
|
</s:form>
|
||||||
|
|
||||||
|
|
|
@ -278,9 +278,8 @@
|
||||||
<c:set var="location" value="${repository.location}"/>
|
<c:set var="location" value="${repository.location}"/>
|
||||||
<jsp:useBean id="location" type="java.lang.String" scope="page"/>
|
<jsp:useBean id="location" type="java.lang.String" scope="page"/>
|
||||||
|
|
||||||
<c:if
|
<%-- TODO: fix this hard coding - make stage repository configuration more transparent than the actual ManagedRepositoryConfiguration --%>
|
||||||
test='<%= !( (str.equalsIgnoreCase("internal") ) || (str.equalsIgnoreCase( "snapshots" )) ) &&
|
<c:if test='<%= new File (new File(location ).getParent() ,str + "-stage" ).exists()%>'>
|
||||||
new File (new File(location ).getParent() ,str + "-stage" ).exists()%>'>
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
stage repository location
|
stage repository location
|
||||||
|
@ -289,23 +288,22 @@
|
||||||
${repository.location}${'-stage'}
|
${repository.location}${'-stage'}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<redback:ifAuthorized permission="archiva-merge-repository" resource="${repository.id}">
|
||||||
<th>Merge Actions</th>
|
<tr>
|
||||||
<td>
|
<th>Merge Actions</th>
|
||||||
<redback:ifAuthorized permission="archiva-run-indexer">
|
<td>
|
||||||
<s:form action="merge" theme="simple">
|
<s:form action="merge" theme="simple">
|
||||||
<s:hidden name="repoid" value="%{#attr.repository.id}"/>
|
<s:hidden name="repoid" value="%{#attr.repository.id}"/>
|
||||||
<%--<s:hidden name="repository" value="%{repository}"/>--%>
|
<%--<s:hidden name="repository" value="%{repository}"/>--%>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td><s:submit id="Merge" value="Merge"/></td>
|
<td><s:submit id="Merge" value="Merge"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</table>
|
||||||
</table>
|
</s:form>
|
||||||
</s:form>
|
</td>
|
||||||
</redback:ifAuthorized>
|
</tr>
|
||||||
</td>
|
</redback:ifAuthorized>
|
||||||
</tr>
|
|
||||||
|
|
||||||
|
|
||||||
</c:if>
|
</c:if>
|
||||||
|
|
|
@ -44,6 +44,7 @@ import org.codehaus.redback.integration.interceptor.SecureActionException;
|
||||||
import org.easymock.MockControl;
|
import org.easymock.MockControl;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -131,6 +132,36 @@ public class DeleteManagedRepositoryActionTest
|
||||||
assertEquals( 1, bundle.getAuthorizationTuples().size() );
|
assertEquals( 1, bundle.getAuthorizationTuples().size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testDeleteRepositoryAndReposUnderRepoGroup()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
repositoryStatisticsManager.deleteStatistics( metadataRepository, REPO_ID );
|
||||||
|
repositoryStatisticsManagerControl.replay();
|
||||||
|
|
||||||
|
Configuration configuration = prepDeletionTest( createRepository(), 6 );
|
||||||
|
List<String> repoIds = new ArrayList<String>();
|
||||||
|
repoIds.add( REPO_ID );
|
||||||
|
configuration.addRepositoryGroup( createRepoGroup( repoIds, "repo.group" ) );
|
||||||
|
|
||||||
|
prepareRoleManagerMock();
|
||||||
|
|
||||||
|
assertEquals( 1, configuration.getRepositoryGroups().size() );
|
||||||
|
|
||||||
|
MockControl control = mockAuditListeners();
|
||||||
|
when( respositorySession.getRepository() ).thenReturn( metadataRepository );
|
||||||
|
String status = action.deleteContents();
|
||||||
|
assertEquals( Action.SUCCESS, status );
|
||||||
|
|
||||||
|
assertTrue( configuration.getManagedRepositories().isEmpty() );
|
||||||
|
assertEquals( 0, configuration.getRepositoryGroups().get( 0 ).getRepositories().size() );
|
||||||
|
|
||||||
|
assertFalse( location.exists() );
|
||||||
|
|
||||||
|
repositoryStatisticsManagerControl.verify();
|
||||||
|
control.verify();
|
||||||
|
metadataRepositoryControl.verify();
|
||||||
|
}
|
||||||
|
|
||||||
public void testDeleteRepositoryConfirmation()
|
public void testDeleteRepositoryConfirmation()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -141,7 +172,7 @@ public class DeleteManagedRepositoryActionTest
|
||||||
archivaConfigurationControl.setReturnValue( configuration );
|
archivaConfigurationControl.setReturnValue( configuration );
|
||||||
|
|
||||||
Configuration stageRepoConfiguration = new Configuration();
|
Configuration stageRepoConfiguration = new Configuration();
|
||||||
stageRepoConfiguration.addManagedRepository( createSatingRepository() );
|
stageRepoConfiguration.addManagedRepository( createStagingRepository() );
|
||||||
archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
|
archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
|
||||||
|
|
||||||
archivaConfigurationControl.replay();
|
archivaConfigurationControl.replay();
|
||||||
|
@ -292,7 +323,7 @@ public class DeleteManagedRepositoryActionTest
|
||||||
archivaConfigurationControl.setReturnValue( configuration, expectCountGetConfig );
|
archivaConfigurationControl.setReturnValue( configuration, expectCountGetConfig );
|
||||||
|
|
||||||
Configuration stageRepoConfiguration = new Configuration();
|
Configuration stageRepoConfiguration = new Configuration();
|
||||||
stageRepoConfiguration.addManagedRepository( createSatingRepository() );
|
stageRepoConfiguration.addManagedRepository( createStagingRepository() );
|
||||||
archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
|
archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
|
||||||
|
|
||||||
archivaConfiguration.save( configuration );
|
archivaConfiguration.save( configuration );
|
||||||
|
@ -351,7 +382,7 @@ public class DeleteManagedRepositoryActionTest
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ManagedRepositoryConfiguration createSatingRepository()
|
private ManagedRepositoryConfiguration createStagingRepository()
|
||||||
{
|
{
|
||||||
ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration();
|
ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration();
|
||||||
r.setId( REPO_ID + "-stage" );
|
r.setId( REPO_ID + "-stage" );
|
||||||
|
|
|
@ -37,8 +37,6 @@ import org.apache.maven.archiva.repository.metadata.RepositoryMetadataReader;
|
||||||
import org.apache.maven.archiva.repository.metadata.RepositoryMetadataWriter;
|
import org.apache.maven.archiva.repository.metadata.RepositoryMetadataWriter;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Named;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
@ -51,6 +49,8 @@ import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* plexus.component role="org.apache.archiva.stagerepository.merge.RepositoryMerger" role-hint="maven2"
|
* plexus.component role="org.apache.archiva.stagerepository.merge.RepositoryMerger" role-hint="maven2"
|
||||||
|
|
Loading…
Reference in New Issue