You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ace.apache.org by ma...@apache.org on 2013/07/01 23:35:12 UTC

svn commit: r1498706 - in /ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository: ./ helper/base/ impl/ stateful/impl/

Author: marrs
Date: Mon Jul  1 21:35:11 2013
New Revision: 1498706

URL: http://svn.apache.org/r1498706
Log:
Added proper support for removing attributes and tags. Improved error messages and stack traces in the artifact preprocessor base code. Improved the velocity preprocessor to also upload when on 'https', not only 'http'.

Modified:
    ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/RepositoryObject.java
    ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/helper/base/ArtifactPreprocessorBase.java
    ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/helper/base/VelocityArtifactPreprocessor.java
    ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositoryObjectImpl.java
    ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/stateful/impl/StatefulTargetObjectImpl.java

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/RepositoryObject.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/RepositoryObject.java?rev=1498706&r1=1498705&r2=1498706&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/RepositoryObject.java (original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/RepositoryObject.java Mon Jul  1 21:35:11 2013
@@ -48,6 +48,10 @@ public interface RepositoryObject extend
      */
     public String addAttribute(String key, String value);
     /**
+     * Removes a names attribute from this object's attributes.
+     */
+    public String removeAttribute(String key);
+    /**
      * Gets a named attribute. Returns <code>null<code> when the attribute named by
      * <code>key</code> does not exist.
      */
@@ -63,6 +67,10 @@ public interface RepositoryObject extend
      */
     public String addTag(String key, String value);
     /**
+     * Removes a named tag from this object's attributes.
+     */
+    public String removeTag(String key);
+    /**
      * Gets a named tag. Returns <code>null<code> when the attribute named by
      * <code>key</code> does not exist.
      */

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/helper/base/ArtifactPreprocessorBase.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/helper/base/ArtifactPreprocessorBase.java?rev=1498706&r1=1498705&r2=1498706&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/helper/base/ArtifactPreprocessorBase.java (original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/helper/base/ArtifactPreprocessorBase.java Mon Jul  1 21:35:11 2013
@@ -138,12 +138,11 @@ public abstract class ArtifactPreprocess
                         location = connection.getHeaderField("Location");
                         break;
                     case HttpURLConnection.HTTP_CONFLICT:
-                        throw new IOException("Artifact already exists in storage.");
+                        throw new IOException("Artifact already exists in storage: " + name);
                     case HttpURLConnection.HTTP_INTERNAL_ERROR:
-                        throw new IOException("The storage server returned an internal server error.");
+                        throw new IOException("The storage server returned an internal server error while trying to upload " + name);
                     default:
-                        throw new IOException("The storage server returned code " + responseCode + " writing to "
-                            + url.toString());
+                        throw new IOException("The storage server returned code " + responseCode + " writing to " + url.toString());
                 }
             }
         }

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/helper/base/VelocityArtifactPreprocessor.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/helper/base/VelocityArtifactPreprocessor.java?rev=1498706&r1=1498705&r2=1498706&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/helper/base/VelocityArtifactPreprocessor.java (original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/helper/base/VelocityArtifactPreprocessor.java Mon Jul  1 21:35:11 2013
@@ -126,10 +126,12 @@ public class VelocityArtifactPreprocesso
         String name = getFilename(url, targetID, version);
 
         String location = null;
-        if(obrBase.getProtocol().equals("http")){
+        String protocol = obrBase.getProtocol();
+        if ("http".equals(protocol) || "https".equals(protocol)) {
             // upload the new resource to the OBR
             location = upload(new ByteArrayInputStream(result), name, ConfigurationHelper.MIMETYPE, obrBase);
-        } else {
+        }
+        else {
             // this is only to support the unit tests
             location = obrBase + name;
         }

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositoryObjectImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositoryObjectImpl.java?rev=1498706&r1=1498705&r2=1498706&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositoryObjectImpl.java (original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositoryObjectImpl.java Mon Jul  1 21:35:11 2013
@@ -163,24 +163,73 @@ public class RepositoryObjectImpl<T exte
     }
 
     public String addAttribute(String key, String value) {
+        if (value == null || key == null) {
+            throw new IllegalArgumentException("Invalid key/value pair: " + key + "/" + value);
+        }
         for (String s : getDefiningKeys()) {
             if (s.equals(key)) {
                 throw new UnsupportedOperationException("The defining attribute " + key + " is not allowed to be changed.");
             }
         }
+        String result = null;
         synchronized (m_attributes) {
             ensureCurrent();
-            notifyChanged(null);
-            return m_attributes.put(key, value);
+            result = m_attributes.get(key);
+            if (!value.equals(result)) {
+                result = m_attributes.put(key, value);
+                notifyChanged(null);
+            }
         }
+        return result;
+    }
+    
+    @Override
+    public String removeAttribute(String key) {
+        for (String s : getDefiningKeys()) {
+            if (s.equals(key)) {
+                throw new UnsupportedOperationException("The defining attribute " + key + " is not allowed to be changed.");
+            }
+        }
+        String result = null;
+        synchronized (m_attributes) {
+            ensureCurrent();
+            result = m_attributes.get(key);
+            if (result != null) {
+                result = m_attributes.remove(key);
+                notifyChanged(null);
+            }
+        }
+        return result;
     }
 
     public String addTag(String key, String value) {
+        if (value == null || key == null) {
+            throw new IllegalArgumentException("Invalid key/value pair: " + key + "/" + value);
+        }
+        String result = null;
+        synchronized (m_attributes) {
+            ensureCurrent();
+            result = m_tags.get(key);
+            if (!value.equals(result)) {
+                result = m_tags.put(key, value);
+                notifyChanged(null);
+            }
+        }
+        return result;
+    }
+    
+    @Override
+    public String removeTag(String key) {
+        String result = null;
         synchronized (m_attributes) {
             ensureCurrent();
-            notifyChanged(null);
-            return m_tags.put(key, value);
+            result = m_tags.get(key);
+            if (result != null) {
+                result = m_tags.remove(key);
+                notifyChanged(null);
+            }
         }
+        return result;
     }
 
     public String getAttribute(String key) {

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/stateful/impl/StatefulTargetObjectImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/stateful/impl/StatefulTargetObjectImpl.java?rev=1498706&r1=1498705&r2=1498706&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/stateful/impl/StatefulTargetObjectImpl.java (original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/stateful/impl/StatefulTargetObjectImpl.java Mon Jul  1 21:35:11 2013
@@ -463,6 +463,13 @@ public class StatefulTargetObjectImpl im
             return m_targetObject.addAttribute(key, value);
         }
     }
+    
+    public String removeAttribute(String key) {
+        synchronized(m_lock) {
+            ensureTargetPresent();
+            return m_targetObject.removeAttribute(key);
+        }
+    }
 
     public String addTag(String key, String value) {
         synchronized(m_lock) {
@@ -470,6 +477,13 @@ public class StatefulTargetObjectImpl im
             return m_targetObject.addTag(key, value);
         }
     }
+    
+    public String removeTag(String key) {
+        synchronized(m_lock) {
+            ensureTargetPresent();
+            return m_targetObject.removeTag(key);
+        }
+    }
 
     public String getAttribute(String key) {
         // retrieve from both