aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/redback/redback.xml11
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java25
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java2
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java6
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editRepository.jsp18
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp38
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java37
-rw-r--r--archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMerger.java4
8 files changed, 86 insertions, 55 deletions
diff --git a/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/redback/redback.xml b/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/redback/redback.xml
index ee57e70fd..3bb9ba48d 100644
--- a/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/redback/redback.xml
+++ b/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/redback/redback.xml
@@ -25,6 +25,11 @@
<name>archiva-run-indexer</name>
<description>Run Archiva Indexer</description>
</operation>
+ <operation>
+ <id>archiva-merge-stage</id>
+ <name>archiva-merge-stage</name>
+ <description>Merge Stage Repository</description>
+ </operation>
<operation>
<id>archiva-delete-artifact</id>
<name>archiva-delete-artifact</name>
@@ -252,6 +257,12 @@
<operation>archiva-delete-metadata</operation>
<resource>${resource}</resource>
</permission>
+ <permission>
+ <id>archiva-merge-repository</id>
+ <name>Archiva Merge Repository</name>
+ <operation>archiva-merge-repository</operation>
+ <resource>${resource}</resource>
+ </permission>
</permissions>
<childTemplates>
<childTemplate>archiva-repository-observer</childTemplate>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java
index ac8458a5c..510736d6a 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java
@@ -38,12 +38,11 @@ import org.codehaus.plexus.taskqueue.TaskQueueException;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
-import javax.inject.Inject;
-import javax.inject.Named;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
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"
@@ -104,7 +103,6 @@ public class MergeAction
}
public String doMerge()
- throws Exception
{
RepositorySession repositorySession = repositorySessionFactory.createSession();
try
@@ -132,10 +130,10 @@ public class MergeAction
return SUCCESS;
}
- catch ( Exception ex )
+ catch ( Exception e )
{
- ex.printStackTrace();
- addActionError( "Error occurred while merging the repositories." );
+ log.error( e.getMessage(), e );
+ addActionError( "Error occurred while merging the repositories: " + e.getMessage() );
return ERROR;
}
finally
@@ -175,10 +173,10 @@ public class MergeAction
return SUCCESS;
}
- catch ( Exception ex )
+ catch ( Exception e )
{
- ex.printStackTrace();
- addActionError( "Error occurred while merging the repositories." );
+ log.error( e.getMessage(), e );
+ addActionError( "Error occurred while merging the repositories: " + e.getMessage() );
return ERROR;
}
finally
@@ -288,12 +286,7 @@ public class MergeAction
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.addAll( map.values() );
}
private void mergeWithOutSnapshots( MetadataRepository metadataRepository, List<ArtifactMetadata> sourceArtifacts,
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java
index 6be92c44f..517633538 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java
@@ -196,7 +196,7 @@ public class AddManagedRepositoryAction
else if ( repoId.toLowerCase().contains( "stage" ) )
{
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() ) )
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java
index 5cf201d97..0ca001e28 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java
@@ -41,13 +41,13 @@ import org.codehaus.redback.integration.interceptor.SecureActionException;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
-import javax.inject.Inject;
-import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
/**
* Shows the Repositories Tab for the administrator.
@@ -150,7 +150,7 @@ public class RepositoriesAction
List<ManagedRepositoryConfiguration> managedRepositoriesList = new ArrayList<ManagedRepositoryConfiguration>();
for ( ManagedRepositoryConfiguration repoConfig : managedRepositories )
{
- if ( !repoConfig.getId().contains( "stage" ) )
+ if ( !repoConfig.getId().endsWith( "-stage" ) )
{
managedRepositoriesList.add( repoConfig );
}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editRepository.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editRepository.jsp
index f6ff874f7..8a2bfed8c 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editRepository.jsp
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editRepository.jsp
@@ -53,16 +53,14 @@
<s:label label="ID" name="repository.id" />
<%@ include file="/WEB-INF/jsp/admin/include/repositoryForm.jspf" %>
- <c:set var="stats" value="${stagingRepository == null}"/>
- <jsp:useBean id="stats" type="java.lang.Boolean" scope="page"/>
- <c:if
- test='<%= !stats.booleanValue() %>'>
- <s:checkbox name="stageNeeded" value="true" label="Create stage repository"/>
- </c:if>
- <c:if
- test='<%= stats.booleanValue() %>'>
- <s:checkbox id="stageNeeded" name="stageNeeded" value="false" label="Create stage repository"/>
- </c:if>
+ <c:choose>
+ <c:when test="${empty(stagingRepository)}">
+ <s:checkbox id="stageNeeded" name="stageNeeded" value="false" label="Create stage repository"/>
+ </c:when>
+ <c:otherwise>
+ <s:checkbox name="stageNeeded" value="true" label="Create stage repository"/>
+ </c:otherwise>
+ </c:choose>
<s:submit value="Update Repository"/>
</s:form>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp
index 655cb6838..1d0412351 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp
@@ -278,9 +278,8 @@
<c:set var="location" value="${repository.location}"/>
<jsp:useBean id="location" type="java.lang.String" scope="page"/>
- <c:if
- test='<%= !( (str.equalsIgnoreCase("internal") ) || (str.equalsIgnoreCase( "snapshots" )) ) &&
- new File (new File(location ).getParent() ,str + "-stage" ).exists()%>'>
+ <%-- TODO: fix this hard coding - make stage repository configuration more transparent than the actual ManagedRepositoryConfiguration --%>
+ <c:if test='<%= new File (new File(location ).getParent() ,str + "-stage" ).exists()%>'>
<tr>
<th>
stage repository location
@@ -289,23 +288,22 @@
${repository.location}${'-stage'}
</td>
</tr>
- <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}"/>
- <%--<s:hidden name="repository" value="%{repository}"/>--%>
- <table>
- <tr>
- <td><s:submit id="Merge" value="Merge"/></td>
- </tr>
-
- </table>
- </s:form>
- </redback:ifAuthorized>
- </td>
- </tr>
+ <redback:ifAuthorized permission="archiva-merge-repository" resource="${repository.id}">
+ <tr>
+ <th>Merge Actions</th>
+ <td>
+ <s:form action="merge" theme="simple">
+ <s:hidden name="repoid" value="%{#attr.repository.id}"/>
+ <%--<s:hidden name="repository" value="%{repository}"/>--%>
+ <table>
+ <tr>
+ <td><s:submit id="Merge" value="Merge"/></td>
+ </tr>
+ </table>
+ </s:form>
+ </td>
+ </tr>
+ </redback:ifAuthorized>
</c:if>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java
index b19570724..b4e985cd4 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java
@@ -44,6 +44,7 @@ import org.codehaus.redback.integration.interceptor.SecureActionException;
import org.easymock.MockControl;
import java.io.File;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -131,6 +132,36 @@ public class DeleteManagedRepositoryActionTest
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()
throws Exception
{
@@ -141,7 +172,7 @@ public class DeleteManagedRepositoryActionTest
archivaConfigurationControl.setReturnValue( configuration );
Configuration stageRepoConfiguration = new Configuration();
- stageRepoConfiguration.addManagedRepository( createSatingRepository() );
+ stageRepoConfiguration.addManagedRepository( createStagingRepository() );
archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
archivaConfigurationControl.replay();
@@ -292,7 +323,7 @@ public class DeleteManagedRepositoryActionTest
archivaConfigurationControl.setReturnValue( configuration, expectCountGetConfig );
Configuration stageRepoConfiguration = new Configuration();
- stageRepoConfiguration.addManagedRepository( createSatingRepository() );
+ stageRepoConfiguration.addManagedRepository( createStagingRepository() );
archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
archivaConfiguration.save( configuration );
@@ -351,7 +382,7 @@ public class DeleteManagedRepositoryActionTest
return r;
}
- private ManagedRepositoryConfiguration createSatingRepository()
+ private ManagedRepositoryConfiguration createStagingRepository()
{
ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration();
r.setId( REPO_ID + "-stage" );
diff --git a/archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMerger.java b/archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMerger.java
index 01e9ce1f3..1d8da4b75 100644
--- a/archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMerger.java
+++ b/archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMerger.java
@@ -37,8 +37,6 @@ import org.apache.maven.archiva.repository.metadata.RepositoryMetadataReader;
import org.apache.maven.archiva.repository.metadata.RepositoryMetadataWriter;
import org.springframework.stereotype.Service;
-import javax.inject.Inject;
-import javax.inject.Named;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -51,6 +49,8 @@ import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
+import javax.inject.Inject;
+import javax.inject.Named;
/**
* plexus.component role="org.apache.archiva.stagerepository.merge.RepositoryMerger" role-hint="maven2"