ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1530984 [3/5] - in /ace/trunk: org.apache.ace.agent.itest/ org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/ org.apache.ace.agent.update.itest/ org.apache.ace.agent.update.itest/conf/ org.apache.ace.agent.update.itest/src/org/apac...
Date Thu, 10 Oct 2013 14:11:14 GMT
Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositorySerializer.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositorySerializer.java?rev=1530984&r1=1530983&r2=1530984&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositorySerializer.java
(original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositorySerializer.java
Thu Oct 10 14:11:13 2013
@@ -35,20 +35,16 @@ import com.thoughtworks.xstream.io.Hiera
 
 /**
  * Helper class that takes a RepositorySet<br>
- * TODO We might move out xstream at some time in the future; before that
- * time, it could be a smart idea to wrap xstream's writer in a delegate
- * object, so this will not require changes to the repositories
- * and objects.
+ * TODO We might move out xstream at some time in the future; before that time, it could
be a smart idea to wrap
+ * xstream's writer in a delegate object, so this will not require changes to the repositories
and objects.
  */
 class RepositorySerializer implements Converter {
-    @SuppressWarnings("unchecked")
     private final Map<String, ObjectRepositoryImpl> m_tagToRepo = new HashMap<String,
ObjectRepositoryImpl>();
 
     private final RepositorySet m_set;
 
     private final XStream m_stream;
 
-    @SuppressWarnings("unchecked")
     RepositorySerializer(RepositorySet set) {
         m_set = set;
         for (ObjectRepositoryImpl repo : m_set.getRepos()) {
@@ -59,16 +55,14 @@ class RepositorySerializer implements Co
         m_stream.registerConverter(this);
     }
 
-    @SuppressWarnings("unchecked")
     public void marshal(Object target, HierarchicalStreamWriter writer, MarshallingContext
context) {
         for (ObjectRepositoryImpl repo : m_set.getRepos()) {
             repo.marshal(writer);
         }
     }
 
-    @SuppressWarnings("unchecked")
     public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
{
-        while(reader.hasMoreChildren()) {
+        while (reader.hasMoreChildren()) {
             reader.moveDown();
             String nodeName = reader.getNodeName();
             ObjectRepositoryImpl o = m_tagToRepo.get(nodeName);
@@ -78,18 +72,16 @@ class RepositorySerializer implements Co
         return this;
     }
 
-    @SuppressWarnings("unchecked")
     public boolean canConvert(Class target) {
         return target == getClass();
     }
 
-    @SuppressWarnings("unchecked")
     public void toXML(OutputStream out) throws IOException {
         for (ObjectRepositoryImpl repo : m_set.getRepos()) {
             repo.setBusy(true);
         }
         try {
-        	GZIPOutputStream zout = new GZIPOutputStream(out);
+            GZIPOutputStream zout = new GZIPOutputStream(out);
             m_stream.toXML(this, zout);
             zout.finish();
         }
@@ -102,11 +94,11 @@ class RepositorySerializer implements Co
     }
 
     /**
-     * Reads the repositories with which this RepositoryRoot had been initialized with from
the
-     * given XML file.
-     * @param in The input stream.
+     * Reads the repositories with which this RepositoryRoot had been initialized with from
the given XML file.
+     * 
+     * @param in
+     *            The input stream.
      */
-    @SuppressWarnings("unchecked")
     public void fromXML(InputStream in) {
         // The repositories get cleared, since a user *could* add stuff before
         // checking out.
@@ -118,7 +110,7 @@ class RepositorySerializer implements Co
         try {
             Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
             if (in.available() > 0) {
-            	in = new GZIPInputStream(in);
+                in = new GZIPInputStream(in);
                 m_stream.fromXML(in, this);
             }
         }

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositorySet.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositorySet.java?rev=1530984&r1=1530983&r2=1530984&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositorySet.java
(original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositorySet.java
Thu Oct 10 14:11:13 2013
@@ -58,7 +58,6 @@ class RepositorySet {
 
     private final User m_user;
     private final Preferences m_prefs;
-    @SuppressWarnings("unchecked")
     private final ObjectRepositoryImpl[] m_repos;
     private final CachedRepository m_repository;
     private final String m_name;
@@ -73,7 +72,6 @@ class RepositorySet {
      * Basics
      * ********/
 
-    @SuppressWarnings("unchecked")
     /**
      * Creates a new <code>RepositorySet</code>. Notes:
      * <ul>
@@ -116,7 +114,6 @@ class RepositorySet {
         return m_user;
     }
 
-    @SuppressWarnings("unchecked")
     ObjectRepositoryImpl[] getRepos() {
         return m_repos;
     }
@@ -151,6 +148,7 @@ class RepositorySet {
     /**
      * Only call this after the repository has been deserialized.
      */
+    @SuppressWarnings("unchecked")
     void loadPreferences() {
         Preferences workingNode = m_prefs.node(PREFS_LOCAL_WORKING_STATE);
         Map<String, WorkingState> entries = new HashMap<String, WorkingState>();
@@ -247,7 +245,6 @@ class RepositorySet {
         return m_repository.isCurrent();
     }
 
-    @SuppressWarnings("unchecked")
     void clearRepositories() {
         for (ObjectRepositoryImpl repo : getRepos()) {
             repo.setBusy(true);
@@ -284,7 +281,7 @@ class RepositorySet {
         if (m_modifiedHandler != null) {
             throw new IllegalStateException("A handler is already registered; only one can
be used at a time.");
         }
-        Dictionary topic = new Hashtable();
+        Dictionary<String, Object> topic = new Hashtable<String, Object>();
         topic.put(EventConstants.EVENT_TOPIC, topics);
         topic.put(EventConstants.EVENT_FILTER, "(" + SessionFactory.SERVICE_SID + "=" + sessionID
+ ")");
         m_modifiedHandler = context.registerService(EventHandler.class.getName(), new ModifiedHandler(),
topic);
@@ -304,6 +301,7 @@ class RepositorySet {
         return result;
     }
 
+    @SuppressWarnings("unchecked")
     private void resetModified(boolean fill) {
         m_workingState.clear();
         if (fill) {

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/TargetPropertyResolver.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/TargetPropertyResolver.java?rev=1530984&r1=1530983&r2=1530984&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/TargetPropertyResolver.java
(original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/TargetPropertyResolver.java
Thu Oct 10 14:11:13 2013
@@ -25,9 +25,8 @@ import org.apache.ace.client.repository.
 import org.apache.ace.client.repository.object.TargetObject;
 
 /**
- * Top-level property resolver, also able to return collections
- * of distributions, features and artifacts linked to this target
- * repository object.
+ * Top-level property resolver, also able to return collections of distributions, features
and artifacts linked to this
+ * target repository object.
  */
 public class TargetPropertyResolver extends RepositoryPropertyResolver {
 
@@ -35,10 +34,11 @@ public class TargetPropertyResolver exte
         super(to);
     }
 
+    @SuppressWarnings("unchecked")
     public Collection<PropertyResolver> getDistributions() {
         List<PropertyResolver> list = new ArrayList<PropertyResolver>();
 
-        List<RepositoryObject> distributions = (List<RepositoryObject>)getChildren();
+        List<RepositoryObject> distributions = (List<RepositoryObject>) getChildren();
 
         for (RepositoryObject repo : distributions) {
             list.add(new RepositoryPropertyResolver(repo));

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/TargetRepositoryImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/TargetRepositoryImpl.java?rev=1530984&r1=1530983&r2=1530984&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/TargetRepositoryImpl.java
(original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/TargetRepositoryImpl.java
Thu Oct 10 14:11:13 2013
@@ -21,6 +21,7 @@ package org.apache.ace.client.repository
 import java.util.Map;
 
 import org.apache.ace.client.repository.object.TargetObject;
+import org.apache.ace.client.repository.repository.RepositoryConfiguration;
 import org.apache.ace.client.repository.repository.TargetRepository;
 
 import com.thoughtworks.xstream.io.HierarchicalStreamReader;
@@ -32,8 +33,8 @@ import com.thoughtworks.xstream.io.Hiera
 public class TargetRepositoryImpl extends ObjectRepositoryImpl<TargetObjectImpl, TargetObject>
implements TargetRepository {
     private final static String XML_NODE = "targets";
 
-    public TargetRepositoryImpl(ChangeNotifier notifier) {
-        super(notifier, XML_NODE);
+    public TargetRepositoryImpl(ChangeNotifier notifier, RepositoryConfiguration repoConfig)
{
+        super(notifier, XML_NODE, repoConfig);
     }
 
     @Override
@@ -42,11 +43,6 @@ public class TargetRepositoryImpl extend
     }
 
     @Override
-    TargetObjectImpl createNewInhabitant(Map<String, String> attributes) {
-        return new TargetObjectImpl(attributes, this);
-    }
-
-    @Override
     TargetObjectImpl createNewInhabitant(HierarchicalStreamReader reader) {
         return new TargetObjectImpl(reader, this);
     }

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/repository/ArtifactRepository.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/repository/ArtifactRepository.java?rev=1530984&r1=1530983&r2=1530984&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/repository/ArtifactRepository.java
(original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/repository/ArtifactRepository.java
Thu Oct 10 14:11:13 2013
@@ -95,15 +95,4 @@ public interface ArtifactRepository exte
      * @throws IOException
      */
     public boolean needsNewVersion(ArtifactObject artifact, TargetObject target, String targetID,
String fromVersion);
-
-	/**
-	 * Sets the OBR that this artifact repository should use to upload artifacts to.
-	 */
-	public void setObrBase(URL obrBase);
-
-    /**
-     * Gets the OBR that this artifact repository should use to upload artifacts to.
-     * Note that this method may return <code>null</code> if no base was set
earlier.
-     */
-    public URL getObrBase();
 }

Added: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/repository/RepositoryConfiguration.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/repository/RepositoryConfiguration.java?rev=1530984&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/repository/RepositoryConfiguration.java
(added)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/repository/RepositoryConfiguration.java
Thu Oct 10 14:11:13 2013
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+package org.apache.ace.client.repository.repository;
+
+import java.net.URL;
+
+/**
+ * Provides the configuration options for several of the repositories.
+ */
+public interface RepositoryConfiguration {
+
+    /**
+     * @return the number of deployment versions to retain per target, can be <tt>-1</tt>
(the default) if the number of
+     *         deployment versions per target is unbounded.
+     */
+    int getDeploymentVersionLimit();
+
+    /**
+     * @return the URL where the OBR can be accessed to store artifacts, never <code>null</code>.
Defaults to
+     *         <tt>http://localhost:8080/obr/</tt>.
+     */
+    URL getOBRLocation();
+
+    /**
+     * @return <code>true</code> (the default) if unregistered targets should
be shown in the target repository,
+     *         <code>false</code> to only show (pre-)registered targets.
+     */
+    boolean isShowUnregisteredTargets();
+
+}

Propchange: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/repository/RepositoryConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/repository/RepositoryConstants.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/repository/RepositoryConstants.java?rev=1530984&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/repository/RepositoryConstants.java
(added)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/repository/RepositoryConstants.java
Thu Oct 10 14:11:13 2013
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+package org.apache.ace.client.repository.repository;
+
+import java.net.URL;
+
+/**
+ * Constants used for the repository.
+ */
+public interface RepositoryConstants {
+    /**
+     * Configuration key for hiding or showing unregistered targets. The value should either
be a {@link Boolean} or a
+     * {@link String} containing <tt>true</tt> (= the default value) or <tt>false</tt>.
+     */
+    String KEY_SHOW_UNREGISTERED_TARGETS = "showunregisteredtargets";
+
+    /**
+     * Configuration key for limiting the number of deployment versions per target. In case
the number of deployment
+     * versions for a target hits this limit, the oldest deployment versions will be purged
for this target. The value
+     * should be an {@link Integer} or a {@link String} representing the integer value. A
value of <tt>-1</tt> (= the
+     * default in case no value is supplied) means that no limit is imposed, and that <em>all</em>
deployment versions
+     * are retained for each target.
+     */
+    String KEY_DEPLOYMENT_VERSION_LIMITS = "deploymentversionlimit";
+
+    /**
+     * Configuration key for defining where the OBR is located to store artifacts in. The
value should either be a
+     * {@link URL} or a String representing a valid URL. Defaults to <tt>http://localhost:8080/obr/</tt>.
+     */
+    String KEY_OBR_LOCATION = "obrlocation";
+
+}

Propchange: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/repository/RepositoryConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/stateful/impl/StatefulTargetRepositoryImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/stateful/impl/StatefulTargetRepositoryImpl.java?rev=1530984&r1=1530983&r2=1530984&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/stateful/impl/StatefulTargetRepositoryImpl.java
(original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/stateful/impl/StatefulTargetRepositoryImpl.java
Thu Oct 10 14:11:13 2013
@@ -46,6 +46,7 @@ import org.apache.ace.client.repository.
 import org.apache.ace.client.repository.object.DistributionObject;
 import org.apache.ace.client.repository.repository.ArtifactRepository;
 import org.apache.ace.client.repository.repository.DeploymentVersionRepository;
+import org.apache.ace.client.repository.repository.RepositoryConfiguration;
 import org.apache.ace.client.repository.repository.TargetRepository;
 import org.apache.ace.client.repository.stateful.StatefulTargetObject;
 import org.apache.ace.client.repository.stateful.StatefulTargetObject.ApprovalState;
@@ -62,8 +63,8 @@ import org.osgi.service.event.EventHandl
 import org.osgi.service.log.LogService;
 
 /**
- * Implements the StatefulTargetRepository. If an <code>AuditLogStore</code>
is present,
- * it will be used; it is assumed that the auditlog store is up to date.
+ * Implements the StatefulTargetRepository. If an <code>AuditLogStore</code>
is present, it will be used; it is assumed
+ * that the auditlog store is up to date.
  */
 public class StatefulTargetRepositoryImpl implements StatefulTargetRepository, EventHandler,
PreCommitMember {
     private BundleContext m_context; /* Injected by dependency manager */
@@ -77,13 +78,14 @@ public class StatefulTargetRepositoryImp
     // TODO: Make the concurrencyLevel of this concurrent hashmap settable?
     private Map<String, StatefulTargetObjectImpl> m_repository = new ConcurrentHashMap<String,
StatefulTargetObjectImpl>();
     private Map<String, StatefulTargetObjectImpl> m_index = new ConcurrentHashMap<String,
StatefulTargetObjectImpl>();
+
     private final String m_sessionID;
+    private final RepositoryConfiguration m_repoConfig;
     private boolean m_holdEvents = false;
-	private boolean m_showUnregisteredTargets;
 
-    public StatefulTargetRepositoryImpl(String sessionID, boolean showUnregisteredTargets)
{
+    public StatefulTargetRepositoryImpl(String sessionID, RepositoryConfiguration repoConfig)
{
         m_sessionID = sessionID;
-		m_showUnregisteredTargets = showUnregisteredTargets;
+        m_repoConfig = repoConfig;
     }
 
     public StatefulTargetObject create(Map<String, String> attributes, Map<String,
String> tags)
@@ -154,12 +156,13 @@ public class StatefulTargetRepositoryImp
     /**
      * Gets the <code>TargetObject</code> which is identified by the <code>targetID</code>.
      * 
-     * @param targetID A string representing a target ID.
-     * @return The <code>TargetObject</code> from the <code>TargetRepository</code>
which has the given
-     *         ID, or <code>null</code> if none can be found.
+     * @param targetID
+     *            A string representing a target ID.
+     * @return The <code>TargetObject</code> from the <code>TargetRepository</code>
which has the given ID, or
+     *         <code>null</code> if none can be found.
      */
     TargetObject getTargetObject(String targetID) {
-// synchronized(m_repository) {
+        // synchronized(m_repository) {
         try {
             List<TargetObject> targets =
                 m_targetRepository.get(m_context.createFilter("(" + TargetObject.KEY_ID +
"="
@@ -175,15 +178,16 @@ public class StatefulTargetRepositoryImp
             // The filter syntax is illegal, probably a bad target ID.
             return null;
         }
-// }
+        // }
     }
 
     /**
      * Gets the stateful representation of the given target ID.
      * 
-     * @param targetID A string representing a target ID.
-     * @return The <code>StatefulTargetyObjectImpl</code> which handles the given
ID,
-     *         or <code>null</code> if none can be found.
+     * @param targetID
+     *            A string representing a target ID.
+     * @return The <code>StatefulTargetyObjectImpl</code> which handles the given
ID, or <code>null</code> if none can
+     *         be found.
      */
     StatefulTargetObjectImpl getStatefulTargetObject(String targetID) {
         synchronized (m_repository) {
@@ -194,7 +198,8 @@ public class StatefulTargetRepositoryImp
     /**
      * Creates and registers a new stateful target object based on the given ID.
      * 
-     * @param targetID A string representing a target ID.
+     * @param targetID
+     *            A string representing a target ID.
      * @return The newly created and registered <code>StatefulTargetObjectImpl</code>.
      */
     private StatefulTargetObjectImpl createStateful(String targetID) {
@@ -210,10 +215,10 @@ public class StatefulTargetRepositoryImp
     }
 
     /**
-     * Removes the given entity from this object's repository, and notifies
-     * interested parties of this.
+     * Removes the given entity from this object's repository, and notifies interested parties
of this.
      * 
-     * @param entity The StatefulTargetObjectImpl to be removed.
+     * @param entity
+     *            The StatefulTargetObjectImpl to be removed.
      */
     void removeStateful(StatefulTargetObjectImpl entity) {
         synchronized (m_repository) {
@@ -224,12 +229,12 @@ public class StatefulTargetRepositoryImp
     }
 
     /**
-     * Adds the given stateful object to this object's repository, and notifies
-     * interested parties of this change.
+     * Adds the given stateful object to this object's repository, and notifies interested
parties of this change.
      * 
-     * @param stoi A <code>StatefulTargetObjectImpl</code> to be registered.
-     * @return <code>true</code> when this object has been added to the repository
-     *         and listeners have been notified, <code>false</code> otherwise.
+     * @param stoi
+     *            A <code>StatefulTargetObjectImpl</code> to be registered.
+     * @return <code>true</code> when this object has been added to the repository
and listeners have been notified,
+     *         <code>false</code> otherwise.
      */
     boolean add(StatefulTargetObjectImpl stoi) {
         if (!m_repository.containsKey(stoi)) {
@@ -246,9 +251,10 @@ public class StatefulTargetRepositoryImp
     /**
      * Gets all auditlog events which are related to a given target ID.
      * 
-     * @param targetID A string representing a target ID.
-     * @return a list of <code>AuditEvent</code>s related to this target ID,
-     *         ordered in the order they happened. If no events can be found, and empty list
will be returned.
+     * @param targetID
+     *            A string representing a target ID.
+     * @return a list of <code>AuditEvent</code>s related to this target ID,
ordered in the order they happened. If no
+     *         events can be found, and empty list will be returned.
      */
     List<Event> getAuditEvents(String targetID) {
         return getAuditEvents(getAllDescriptors(targetID));
@@ -257,7 +263,8 @@ public class StatefulTargetRepositoryImp
     /**
      * Gets all auditlog descriptors which are related to a given target.
      * 
-     * @param targetID The target ID
+     * @param targetID
+     *            The target ID
      * @return A list of LogDescriptors, in no particular order.
      */
     List<Descriptor> getAllDescriptors(String targetID) {
@@ -278,12 +285,13 @@ public class StatefulTargetRepositoryImp
     /**
      * Gets all audit log events for a target is has not yet 'seen'.
      * 
-     * @param all A list of all <code>LogDescriptor</code> from which to filter
-     *        the new ones.
-     * @param seen A list of <code>LogDescriptor</code> objects, which indicate
-     *        the items the target has already processed.
-     * @return All AuditLog events that are in the audit store, but are not identified
-     *         by <code>oldDescriptors</code>, ordered by 'happened-before'.
+     * @param all
+     *            A list of all <code>LogDescriptor</code> from which to filter
the new ones.
+     * @param seen
+     *            A list of <code>LogDescriptor</code> objects, which indicate
the items the target has already
+     *            processed.
+     * @return All AuditLog events that are in the audit store, but are not identified by
<code>oldDescriptors</code>,
+     *         ordered by 'happened-before'.
      */
     List<Event> getAuditEvents(List<Descriptor> events) {
         // Get all events from the audit log store, if possible.
@@ -326,13 +334,12 @@ public class StatefulTargetRepositoryImp
     }
 
     /**
-     * Based on the information in this stateful object, creates a <code>TargetObject</code>
-     * in the <code>TargetRepository</code>.
-     * This function is intended to be used for targets which are not yet represented
-     * in the <code>TargetRepository</code>; if they already are, an <code>IllegalArgumentException</code>
-     * will be thrown.
+     * Based on the information in this stateful object, creates a <code>TargetObject</code>
in the
+     * <code>TargetRepository</code>. This function is intended to be used for
targets which are not yet represented in
+     * the <code>TargetRepository</code>; if they already are, an <code>IllegalArgumentException</code>
will be thrown.
      * 
-     * @param targetID A string representing the ID of the new target.
+     * @param targetID
+     *            A string representing the ID of the new target.
      */
     void register(String targetID) {
         Map<String, String> attr = new HashMap<String, String>();
@@ -345,10 +352,13 @@ public class StatefulTargetRepositoryImp
     /**
      * Notifies interested parties of a change to a <code>StatefulTargetObject</code>.
      * 
-     * @param stoi The <code>StatefulTargetObject</code> which has changed.
-     * @param topic A topic string for posting the event.
-     * @param additionalProperties A Properties event, already containing some extra properties.
If
-     *        RepositoryObject.EVENT_ENTITY is used, it will be overwritten.
+     * @param stoi
+     *            The <code>StatefulTargetObject</code> which has changed.
+     * @param topic
+     *            A topic string for posting the event.
+     * @param additionalProperties
+     *            A Properties event, already containing some extra properties. If RepositoryObject.EVENT_ENTITY
is
+     *            used, it will be overwritten.
      */
     void notifyChanged(StatefulTargetObject stoi, String topic, Properties additionalProperties)
{
         additionalProperties.put(RepositoryObject.EVENT_ENTITY, stoi);
@@ -359,13 +369,19 @@ public class StatefulTargetRepositoryImp
     /**
      * Notifies interested parties of a change to a <code>StatefulTargetObject</code>.
      * 
-     * @param stoi The <code>StatefulTargetObject</code> which has changed.
-     * @param topic A topic string for posting the event.
+     * @param stoi
+     *            The <code>StatefulTargetObject</code> which has changed.
+     * @param topic
+     *            A topic string for posting the event.
      */
     void notifyChanged(StatefulTargetObject stoi, String topic) {
         notifyChanged(stoi, topic, new Properties());
     }
 
+    private boolean isShowUnregisteredTargets() {
+        return m_repoConfig.isShowUnregisteredTargets();
+    }
+
     /**
      * Reads the information sources to generate the stateful objects.
      */
@@ -373,8 +389,8 @@ public class StatefulTargetRepositoryImp
         synchronized (m_repository) {
             List<StatefulTargetObjectImpl> touched = new ArrayList<StatefulTargetObjectImpl>();
             touched.addAll(parseTargetRepository());
-            if (m_showUnregisteredTargets) {
-            	touched.addAll(parseAuditLog());
+            if (isShowUnregisteredTargets()) {
+                touched.addAll(parseAuditLog());
             }
 
             // Now, it is possible we have not touched all objects. Find out which these
are, and make
@@ -396,11 +412,11 @@ public class StatefulTargetRepositoryImp
     }
 
     /**
-     * Checks all inhabitants of the <code>TargetRepository</code> to see
-     * whether we already have a stateful representation of them.
+     * Checks all inhabitants of the <code>TargetRepository</code> to see whether
we already have a stateful
+     * representation of them.
      * 
-     * @param needsVerify states whether the objects which are 'touched' by this
-     *        actions should verify their existence.
+     * @param needsVerify
+     *            states whether the objects which are 'touched' by this actions should verify
their existence.
      * @return A list of all the target objects that have been touched by this action.
      */
     private List<StatefulTargetObjectImpl> parseTargetRepository() {
@@ -419,11 +435,10 @@ public class StatefulTargetRepositoryImp
     }
 
     /**
-     * Checks the audit log to see whether we already have a
-     * stateful object for all targets mentioned there.
+     * Checks the audit log to see whether we already have a stateful object for all targets
mentioned there.
      * 
-     * @param needsVerify states whether the objects which are 'touched' by this
-     *        actions should verify their existence.
+     * @param needsVerify
+     *            states whether the objects which are 'touched' by this actions should verify
their existence.
      */
     private List<StatefulTargetObjectImpl> parseAuditLog() {
         List<StatefulTargetObjectImpl> result = new ArrayList<StatefulTargetObjectImpl>();
@@ -445,9 +460,8 @@ public class StatefulTargetRepositoryImp
         }
 
         /*
-         * Note: the parsing of the audit log and the creation/notification of the
-         * stateful objects has been separated, to prevent calling updateAuditEvents()
-         * multiple times on targets which have more than one log.
+         * Note: the parsing of the audit log and the creation/notification of the stateful
objects has been separated,
+         * to prevent calling updateAuditEvents() multiple times on targets which have more
than one log.
          */
         synchronized (m_repository) {
             for (String targetID : targetIDs) {
@@ -465,12 +479,14 @@ public class StatefulTargetRepositoryImp
     }
 
     /**
-     * Approves the changes that will happen to the target based on the
-     * changes in the shop by generating a new deployment version.
+     * Approves the changes that will happen to the target based on the changes in the shop
by generating a new
+     * deployment version.
      * 
-     * @param targetID A string representing a target ID.
+     * @param targetID
+     *            A string representing a target ID.
      * @return The version identifier of the new deployment package.
-     * @throws java.io.IOException When there is a problem generating the deployment version.
+     * @throws java.io.IOException
+     *             When there is a problem generating the deployment version.
      */
     String approve(String targetID) throws IOException {
         DeploymentVersionObject mostRecentDeploymentVersion = getMostRecentDeploymentVersion(targetID);
@@ -482,19 +498,19 @@ public class StatefulTargetRepositoryImp
             nextVersion = nextVersion(mostRecentDeploymentVersion.getVersion());
         }
         return nextVersion;
-//        return generateDeploymentVersion(targetID).getVersion();
+        // return generateDeploymentVersion(targetID).getVersion();
     }
 
     /**
-     * Generates an array of bundle URLs which have to be deployed on
-     * the target, given the current state of the shop.
-     * TODO: In the future, we want to add support for multiple shops.
-     * TODO: Is this prone to concurrency issues with changes distribution- and
-     * feature objects?
+     * Generates an array of bundle URLs which have to be deployed on the target, given the
current state of the shop.
+     * TODO: In the future, we want to add support for multiple shops. TODO: Is this prone
to concurrency issues with
+     * changes distribution- and feature objects?
      * 
-     * @param targetID A string representing a target.
+     * @param targetID
+     *            A string representing a target.
      * @return An array of artifact URLs.
-     * @throws java.io.IOException When there is a problem processing an artifact for deployment.
+     * @throws java.io.IOException
+     *             When there is a problem processing an artifact for deployment.
      */
     DeploymentArtifact[] getNecessaryDeploymentArtifacts(String targetID, String version)
throws IOException {
         TargetObject to = getTargetObject(targetID);
@@ -638,7 +654,7 @@ public class StatefulTargetRepositoryImp
                             ArtifactObject processor = allProcessors.get(processorPID);
                             if (processor == null) {
                                 // this means we cannot create a useful version; return null.
-                            	m_log.log(LogService.LOG_ERROR, "Cannot gather necessary artifacts:
failed to find resource processor named '" + artifact.getProcessorPID() + "' for artifact
'" + artifact.getName() + "'!");
+                                m_log.log(LogService.LOG_ERROR, "Cannot gather necessary
artifacts: failed to find resource processor named '" + artifact.getProcessorPID() + "' for
artifact '" + artifact.getName() + "'!");
                                 return null;
                             }
                             result.add(processor);
@@ -652,13 +668,14 @@ public class StatefulTargetRepositoryImp
     }
 
     /**
-     * Generates a new deployment version for the the given target,
-     * based on the artifacts it is linked to by the distributions it is
-     * associated to.
+     * Generates a new deployment version for the the given target, based on the artifacts
it is linked to by the
+     * distributions it is associated to.
      * 
-     * @param targetID A string representing a target.
+     * @param targetID
+     *            A string representing a target.
      * @return A new DeploymentVersionObject, representing this new version for the target.
-     * @throws java.io.IOException When there is a problem determining the artifacts to be
deployed.
+     * @throws java.io.IOException
+     *             When there is a problem determining the artifacts to be deployed.
      */
     DeploymentVersionObject generateDeploymentVersion(String targetID) throws IOException
{
         Map<String, String> attr = new HashMap<String, String>();
@@ -691,13 +708,12 @@ public class StatefulTargetRepositoryImp
     }
 
     /**
-     * Generates the next version, based on the version passed in.
-     * The version is assumed to be an OSGi-version; for now, the next
-     * 'major' version is generated. In the future, we might want to do
-     * 'smarter' things here, like checking the impact of a new version
-     * and use the minor and micro versions, or attach some qualifier.
+     * Generates the next version, based on the version passed in. The version is assumed
to be an OSGi-version; for
+     * now, the next 'major' version is generated. In the future, we might want to do 'smarter'
things here, like
+     * checking the impact of a new version and use the minor and micro versions, or attach
some qualifier.
      * 
-     * @param version A string representing a deployment version's version.
+     * @param version
+     *            A string representing a deployment version's version.
      * @return A string representing the next version.
      */
     private static String nextVersion(String version) {
@@ -763,7 +779,7 @@ public class StatefulTargetRepositoryImp
                 }
             }
         }
-        
+
         if (RepositoryAdmin.PRIVATE_TOPIC_LOGIN.equals(topic) || RepositoryAdmin.PRIVATE_TOPIC_REFRESH.equals(topic))
{
             m_holdEvents = false;
             synchronized (m_repository) {
@@ -787,7 +803,7 @@ public class StatefulTargetRepositoryImp
             }
         }
     }
-    
+
     @Override
     public void reset() {
         synchronized (m_repository) {
@@ -808,8 +824,8 @@ public class StatefulTargetRepositoryImp
         }
         return false;
     }
-    
+
     private boolean preCommitHasChanges(StatefulTargetObjectImpl stoi) {
         return stoi.getApprovalState().equals(ApprovalState.Approved) && stoi.needsApprove();
     }
-}
\ No newline at end of file
+}

Modified: ace/trunk/org.apache.ace.client.repository/test/org/apache/ace/client/repository/impl/ArtifactTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/test/org/apache/ace/client/repository/impl/ArtifactTest.java?rev=1530984&r1=1530983&r2=1530984&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/test/org/apache/ace/client/repository/impl/ArtifactTest.java
(original)
+++ ace/trunk/org.apache.ace.client.repository/test/org/apache/ace/client/repository/impl/ArtifactTest.java
Thu Oct 10 14:11:13 2013
@@ -54,7 +54,7 @@ public class ArtifactTest {
             }
         });
 
-        m_artifactRepository = new ArtifactRepositoryImpl(TestUtils.createNullObject(ChangeNotifier.class));
+        m_artifactRepository = new ArtifactRepositoryImpl(TestUtils.createNullObject(ChangeNotifier.class),
new RepositoryConfigurationImpl());
         TestUtils.configureObject(m_artifactRepository, LogService.class);
         TestUtils.configureObject(m_artifactRepository, BundleContext.class, bc);
     }



Mime
View raw message