aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-09-11 21:30:31 +0000
committerOlivier Lamy <olamy@apache.org>2012-09-11 21:30:31 +0000
commit0b904bd4d8f45faba81716074efccc954ad93c83 (patch)
treefa75f599662738f8e81ab3c4106b9de86d1c05b3 /archiva-modules/archiva-base
parent0495fe9bc690864d03f8e704d2882dba8b4a4c76 (diff)
downloadarchiva-0b904bd4d8f45faba81716074efccc954ad93c83.tar.gz
archiva-0b904bd4d8f45faba81716074efccc954ad93c83.zip
[MRM-648] Add description field to the different types of repositories and proxies
configuration and rest service implemented. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1383621 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base')
-rw-r--r--archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo8
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/AbstractRepository.java16
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ManagedRepository.java16
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java23
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java19
5 files changed, 67 insertions, 15 deletions
diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo
index 3dc20787e..1c02c812b 100644
--- a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo
+++ b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo
@@ -421,6 +421,14 @@
The directory for the indexes of this repository.
</description>
</field>
+ <field>
+ <name>description</name>
+ <version>1.0.0+</version>
+ <type>String</type>
+ <description>
+ The description of this repository.
+ </description>
+ </field>
</fields>
<codeSegments>
<codeSegment>
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/AbstractRepository.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/AbstractRepository.java
index 772841d3a..bb90fcabf 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/AbstractRepository.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/AbstractRepository.java
@@ -36,6 +36,11 @@ public class AbstractRepository
private String indexDirectory;
+ /**
+ * @since 1.4-M3
+ */
+ private String description;
+
public AbstractRepository()
{
// no op
@@ -90,6 +95,16 @@ public class AbstractRepository
this.indexDirectory = indexDirectory;
}
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription( String description )
+ {
+ this.description = description;
+ }
+
public int hashCode()
{
int result = 17;
@@ -124,6 +139,7 @@ public class AbstractRepository
sb.append( ", name='" ).append( name ).append( '\'' );
sb.append( ", layout='" ).append( layout ).append( '\'' );
sb.append( ", indexDirectory='" ).append( indexDirectory ).append( '\'' );
+ sb.append( ", description='" ).append( description ).append( '\'' );
sb.append( '}' );
return sb.toString();
}
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ManagedRepository.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ManagedRepository.java
index 394631990..a1bbbc1ab 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ManagedRepository.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ManagedRepository.java
@@ -26,7 +26,7 @@ import java.io.Serializable;
* @author Olivier Lamy
* @since 1.4-M1
*/
-@XmlRootElement( name = "managedRepository" )
+@XmlRootElement (name = "managedRepository")
public class ManagedRepository
extends AbstractRepository
implements Serializable
@@ -95,6 +95,20 @@ public class ManagedRepository
this.stageRepoNeeded = stageRepoNeeded;
}
+ /**
+ *
+ * @since 1.4-M3
+ */
+ public ManagedRepository( String id, String name, String location, String layout, boolean snapshots,
+ boolean releases, boolean blockRedeployments, String cronExpression, String indexDir,
+ boolean scanned, int daysOlder, int retentionCount, boolean deleteReleasedSnapshots,
+ boolean stageRepoNeeded, String description )
+ {
+ this( id, name, location, layout, snapshots, releases, blockRedeployments, cronExpression, indexDir, scanned,
+ daysOlder, retentionCount, deleteReleasedSnapshots, stageRepoNeeded );
+ setDescription( description );
+ }
+
public String getCronExpression()
{
return cronExpression;
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java
index d181654a9..30d74f704 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java
@@ -36,7 +36,9 @@ import org.apache.archiva.metadata.repository.MetadataRepositoryException;
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
+import org.apache.archiva.redback.components.taskqueue.TaskQueueException;
import org.apache.archiva.redback.role.RoleManager;
+import org.apache.archiva.redback.role.RoleManagerException;
import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
import org.apache.archiva.scheduler.repository.RepositoryTask;
import org.apache.archiva.security.common.ArchivaRoleConstants;
@@ -46,8 +48,6 @@ import org.apache.maven.index.NexusIndexer;
import org.apache.maven.index.context.IndexCreator;
import org.apache.maven.index.context.IndexingContext;
import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException;
-import org.apache.archiva.redback.role.RoleManagerException;
-import org.apache.archiva.redback.components.taskqueue.TaskQueueException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@@ -72,7 +72,7 @@ import java.util.Map;
*
* @author Olivier Lamy
*/
-@Service( "managedRepositoryAdmin#default" )
+@Service ( "managedRepositoryAdmin#default" )
public class DefaultManagedRepositoryAdmin
extends AbstractRepositoryAdmin
implements ManagedRepositoryAdmin
@@ -83,7 +83,7 @@ public class DefaultManagedRepositoryAdmin
public static final String STAGE_REPO_ID_END = "-stage";
@Inject
- @Named( value = "archivaTaskScheduler#repository" )
+ @Named ( value = "archivaTaskScheduler#repository" )
private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
@Inject
@@ -170,7 +170,7 @@ public class DefaultManagedRepositoryAdmin
repoConfig.isBlockRedeployments(), repoConfig.getRefreshCronExpression(),
repoConfig.getIndexDir(), repoConfig.isScanned(), repoConfig.getDaysOlder(),
repoConfig.getRetentionCount(), repoConfig.isDeleteReleasedSnapshots(), false );
-
+ repo.setDescription( repoConfig.getDescription() );
managedRepos.add( repo );
}
@@ -218,8 +218,8 @@ public class DefaultManagedRepositoryAdmin
managedRepository.isReleases(), managedRepository.isSnapshots(), needStageRepo,
managedRepository.getCronExpression(), managedRepository.getIndexDirectory(),
managedRepository.getDaysOlder(), managedRepository.getRetentionCount(),
- managedRepository.isDeleteReleasedSnapshots(), auditInformation,
- getArchivaConfiguration().getConfiguration() ) != null;
+ managedRepository.isDeleteReleasedSnapshots(), managedRepository.getDescription(),
+ auditInformation, getArchivaConfiguration().getConfiguration() ) != null;
createIndexContext( managedRepository );
return res;
@@ -231,7 +231,7 @@ public class DefaultManagedRepositoryAdmin
boolean releasesIncluded, boolean snapshotsIncluded,
boolean stageRepoNeeded, String cronExpression,
String indexDir, int daysOlder, int retentionCount,
- boolean deteleReleasedSnapshots,
+ boolean deteleReleasedSnapshots, String description,
AuditInformation auditInformation,
Configuration config )
throws RepositoryAdminException
@@ -252,6 +252,7 @@ public class DefaultManagedRepositoryAdmin
repository.setRetentionCount( retentionCount );
repository.setDeleteReleasedSnapshots( deteleReleasedSnapshots );
repository.setIndexDir( indexDir );
+ repository.setDescription( description );
try
{
@@ -480,8 +481,8 @@ public class DefaultManagedRepositoryAdmin
managedRepository.isReleases(), managedRepository.isSnapshots(), needStageRepo,
managedRepository.getCronExpression(), managedRepository.getIndexDirectory(),
managedRepository.getDaysOlder(), managedRepository.getRetentionCount(),
- managedRepository.isDeleteReleasedSnapshots(), auditInformation,
- getArchivaConfiguration().getConfiguration() );
+ managedRepository.isDeleteReleasedSnapshots(), managedRepository.getDescription(),
+ auditInformation, getArchivaConfiguration().getConfiguration() );
// Save the repository configuration.
RepositorySession repositorySession = getRepositorySessionFactory().createSession();
@@ -634,6 +635,8 @@ public class DefaultManagedRepositoryAdmin
stagingRepository.setRetentionCount( repository.getRetentionCount() );
stagingRepository.setScanned( repository.isScanned() );
stagingRepository.setSnapshots( repository.isSnapshots() );
+ // do not duplicate description
+ //stagingRepository.getDescription("")
return stagingRepository;
}
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java
index 343cebb7c..b1fa302ef 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java
@@ -37,6 +37,7 @@ public class ManagedRepositoryAdminTest
String repoId = "test-new-one";
+
String repoLocation = APPSERVER_BASE_PATH + File.separator + repoId;
@Test
@@ -85,12 +86,19 @@ public class ManagedRepositoryAdminTest
repo.setName( "test repo" );
repo.setLocation( repoLocation );
repo.setCronExpression( "0 0 * * * ?" );
+ repo.setDescription( "cool repo" );
managedRepositoryAdmin.addManagedRepository( repo, false, getFakeAuditInformation() );
repos = managedRepositoryAdmin.getManagedRepositories();
assertNotNull( repos );
assertEquals( initialSize + 1, repos.size() );
- assertNotNull( managedRepositoryAdmin.getManagedRepository( repoId ) );
+ ManagedRepository managedRepository = managedRepositoryAdmin.getManagedRepository( repoId );
+
+ assertNotNull( managedRepository );
+
+ assertEquals( "test repo", managedRepository.getName() );
+
+ assertEquals( "cool repo", managedRepository.getDescription() );
assertTemplateRoleExists( repoId );
@@ -142,6 +150,10 @@ public class ManagedRepositoryAdminTest
repo.setName( newName );
+ String description = "so great repository";
+
+ repo.setDescription( description );
+
repo.setLocation( repoLocation );
repo.setCronExpression( "0 0 * * * ?" );
@@ -152,6 +164,7 @@ public class ManagedRepositoryAdminTest
assertEquals( newName, repo.getName() );
assertEquals( new File( repoLocation ).getCanonicalPath(), new File( repo.getLocation() ).getCanonicalPath() );
assertTrue( new File( repoLocation ).exists() );
+ assertEquals( description, repo.getDescription() );
assertTemplateRoleExists( repoId );
@@ -300,12 +313,11 @@ public class ManagedRepositoryAdminTest
assertAuditListenerCallAndUpdateAddAndDelete( true );
mockAuditListener.clearEvents();
-
+
new File( repoLocation + STAGE_REPO_ID_END ).delete();
assertFalse( new File( repoLocation + STAGE_REPO_ID_END ).exists() );
}
-
//----------------------------------
// utility methods
//----------------------------------
@@ -368,5 +380,4 @@ public class ManagedRepositoryAdminTest
}
-
}