aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-database/src
diff options
context:
space:
mode:
authorJoakim Erdfelt <joakime@apache.org>2007-05-09 22:03:49 +0000
committerJoakim Erdfelt <joakime@apache.org>2007-05-09 22:03:49 +0000
commit711bb6c0c6e885dfa33120e4222b0be11d80b36b (patch)
treee55ceccf19cc44889a2fbb8e6bdb7e75742d2668 /archiva-database/src
parent21b1ac804be223d0702bd9dc774c14214d61f0c3 (diff)
downloadarchiva-711bb6c0c6e885dfa33120e4222b0be11d80b36b.tar.gz
archiva-711bb6c0c6e885dfa33120e4222b0be11d80b36b.zip
Updates to Database scanner, updater, task, consumers, and admin screens.
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@536680 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-database/src')
-rw-r--r--archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseConsumers.java157
-rw-r--r--archiva-database/src/main/java/org/apache/maven/archiva/database/updater/JdoDatabaseUpdater.java2
2 files changed, 158 insertions, 1 deletions
diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseConsumers.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseConsumers.java
new file mode 100644
index 000000000..6c4f65ffb
--- /dev/null
+++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseConsumers.java
@@ -0,0 +1,157 @@
+package org.apache.maven.archiva.database.updater;
+
+/*
+ * 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 org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.Predicate;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.DatabaseScanningConfiguration;
+import org.apache.maven.archiva.consumers.DatabaseCleanupConsumer;
+import org.apache.maven.archiva.consumers.DatabaseUnprocessedArtifactConsumer;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * DatabaseConsumers
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ *
+ * @plexus.component role="org.apache.maven.archiva.database.updater.DatabaseConsumers"
+ */
+public class DatabaseConsumers
+ implements Initializable
+{
+ /**
+ * @plexus.requirement
+ */
+ private ArchivaConfiguration archivaConfiguration;
+
+ /**
+ * @plexus.requirement role="org.apache.maven.archiva.consumers.DatabaseUnprocessedArtifactConsumer"
+ */
+ private List availableUnprocessedConsumers;
+
+ /**
+ * @plexus.requirement role="org.apache.maven.archiva.consumers.DatabaseCleanupConsumer"
+ */
+ private List availableCleanupConsumers;
+
+ private SelectedCleanupConsumersPredicate selectedCleanupConsumers;
+
+ private SelectedUnprocessedConsumersPredicate selectedUnprocessedConsumers;
+
+ class SelectedUnprocessedConsumersPredicate
+ implements Predicate
+ {
+ public boolean evaluate( Object object )
+ {
+ boolean satisfies = false;
+
+ if ( object instanceof DatabaseUnprocessedArtifactConsumer )
+ {
+ DatabaseUnprocessedArtifactConsumer consumer = (DatabaseUnprocessedArtifactConsumer) object;
+ DatabaseScanningConfiguration config = archivaConfiguration.getConfiguration().getDatabaseScanning();
+
+ return config.getUnprocessedConsumers().contains( consumer.getId() );
+ }
+
+ return satisfies;
+ }
+ }
+
+ class SelectedCleanupConsumersPredicate
+ implements Predicate
+ {
+ public boolean evaluate( Object object )
+ {
+ boolean satisfies = false;
+
+ if ( object instanceof DatabaseCleanupConsumer )
+ {
+ DatabaseCleanupConsumer consumer = (DatabaseCleanupConsumer) object;
+ DatabaseScanningConfiguration config = archivaConfiguration.getConfiguration().getDatabaseScanning();
+
+ return config.getUnprocessedConsumers().contains( consumer.getId() );
+ }
+
+ return satisfies;
+ }
+ }
+
+ public void initialize()
+ throws InitializationException
+ {
+ selectedCleanupConsumers = new SelectedCleanupConsumersPredicate();
+ selectedUnprocessedConsumers = new SelectedUnprocessedConsumersPredicate();
+ }
+
+ /**
+ * Get the {@link List} of {@link DatabaseUnprocessedArtifactConsumer} objects
+ * for those consumers selected due to the configuration.
+ *
+ * @return the list of selected {@link DatabaseUnprocessedArtifactConsumer} objects.
+ */
+ public List getSelectedUnprocessedConsumers()
+ {
+ List ret = new ArrayList();
+ ret.addAll( CollectionUtils.select( availableUnprocessedConsumers, selectedUnprocessedConsumers ) );
+ return ret;
+ }
+
+ /**
+ * Get the {@link List} of {@link DatabaseCleanupConsumer} objects for those
+ * consumers selected due to the configuration.
+ *
+ * @return the list of selected {@link DatabaseCleanupConsumer} objects.
+ */
+ public List getSelectedCleanupConsumers()
+ {
+ List ret = new ArrayList();
+ ret.addAll( CollectionUtils.select( availableCleanupConsumers, selectedCleanupConsumers ) );
+ return ret;
+ }
+
+ /**
+ * Get the complete {@link List} of {@link DatabaseUnprocessedArtifactConsumer} objects
+ * that are available in the system, regardless of configuration.
+ *
+ * @return the list of all available {@link DatabaseUnprocessedArtifactConsumer} objects.
+ */
+ public List getAvailableUnprocessedConsumers()
+ {
+ return Collections.unmodifiableList( this.availableUnprocessedConsumers );
+ }
+
+ /**
+ * Get the complete {@link List} of {@link DatabaseCleanupConsumer} objects
+ * that are available in the system, regardless of configuration.
+ *
+ * @return the list of all available {@link DatabaseCleanupConsumer} objects.
+ */
+ public List getAvailableCleanupConsumers()
+ {
+ return Collections.unmodifiableList( this.availableCleanupConsumers );
+ }
+}
diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/JdoDatabaseUpdater.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/JdoDatabaseUpdater.java
index 98a5d5635..69172a33a 100644
--- a/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/JdoDatabaseUpdater.java
+++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/JdoDatabaseUpdater.java
@@ -217,7 +217,7 @@ public class JdoDatabaseUpdater
}
this.activeUnprocessedConsumers.addAll( getActiveConsumerList( dbScanning.getUnprocessedConsumers() ) );
- this.activeProcessedConsumers.addAll( getActiveConsumerList( dbScanning.getProcessedConsumers() ) );
+ this.activeProcessedConsumers.addAll( getActiveConsumerList( dbScanning.getCleanupConsumers() ) );
}
private List getActiveConsumerList( List potentialConsumerList )