ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ange...@apache.org
Subject svn commit: r1244465 - in /ace/trunk: ace-client-repository-api/src/main/java/org/apache/ace/client/repository/object/ ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ ace-client-repository-impl/src/main/java/org/apache/a...
Date Wed, 15 Feb 2012 12:41:24 GMT
Author: angelos
Date: Wed Feb 15 12:41:24 2012
New Revision: 1244465

URL: http://svn.apache.org/viewvc?rev=1244465&view=rev
Log:
ACE-214 Added a KEY_RESOURCE_ID to artifacts, which will be used to allow updating of resources
in deploymentpackages when using RepositoryBased deployment.

Modified:
    ace/trunk/ace-client-repository-api/src/main/java/org/apache/ace/client/repository/object/ArtifactObject.java
    ace/trunk/ace-client-repository-api/src/main/java/org/apache/ace/client/repository/object/DeploymentArtifact.java
    ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactObjectImpl.java
    ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/stateful/impl/StatefulGatewayRepositoryImpl.java
    ace/trunk/ace-deployment-provider-base/src/main/java/org/apache/ace/deployment/provider/impl/ArtifactDataImpl.java
    ace/trunk/ace-deployment-provider-repositorybased/src/main/java/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProvider.java
    ace/trunk/ace-deployment-provider-repositorybased/src/test/java/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderTest.java
    ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/repositoryadmin/RepositoryAdminTest.java

Modified: ace/trunk/ace-client-repository-api/src/main/java/org/apache/ace/client/repository/object/ArtifactObject.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-client-repository-api/src/main/java/org/apache/ace/client/repository/object/ArtifactObject.java?rev=1244465&r1=1244464&r2=1244465&view=diff
==============================================================================
--- ace/trunk/ace-client-repository-api/src/main/java/org/apache/ace/client/repository/object/ArtifactObject.java
(original)
+++ ace/trunk/ace-client-repository-api/src/main/java/org/apache/ace/client/repository/object/ArtifactObject.java
Wed Feb 15 12:41:24 2012
@@ -33,6 +33,11 @@ public interface ArtifactObject extends 
      */
     public static final String KEY_URL = "url";
     /**
+     * Attribute key, stating the unique name for this resource. Different versions of the
same logical resource
+     * can share the same Id.
+     */
+    public static final String KEY_RESOURCE_ID = "resourceId";
+    /**
      * Key to be used in the <code>ArtifactObject</code>'s attributes.
      * Indicates the PID of the resource processor that should be used to process this artifact.
      * For a bundle, it is empty.
@@ -90,6 +95,10 @@ public interface ArtifactObject extends 
      */
     public String getURL();
     /**
+     * Returns a ResourceId, if that has been customized. 
+     */
+    public String getResourceId();
+    /**
      * Return a descriptive name for this object. May return <code>null</code>.
      */
     public String getName();

Modified: ace/trunk/ace-client-repository-api/src/main/java/org/apache/ace/client/repository/object/DeploymentArtifact.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-client-repository-api/src/main/java/org/apache/ace/client/repository/object/DeploymentArtifact.java?rev=1244465&r1=1244464&r2=1244465&view=diff
==============================================================================
--- ace/trunk/ace-client-repository-api/src/main/java/org/apache/ace/client/repository/object/DeploymentArtifact.java
(original)
+++ ace/trunk/ace-client-repository-api/src/main/java/org/apache/ace/client/repository/object/DeploymentArtifact.java
Wed Feb 15 12:41:24 2012
@@ -37,6 +37,12 @@ public interface DeploymentArtifact {
     public static final String DIRECTIVE_KEY_PROCESSORID = "Resource-Processor";
 
     /**
+     * Key, intended to be used for artifacts which have a resourceID that's different
+     * from their generated name (based on URL).
+     */
+    public static final String DIRECTIVE_KEY_RESOURCE_ID = "Resource-ID";
+
+    /**
      * Key, intended to be used for matching processed (see ArtifactPreprocessor) to their
      * 'original' one.
      */

Modified: ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactObjectImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactObjectImpl.java?rev=1244465&r1=1244464&r2=1244465&view=diff
==============================================================================
--- ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactObjectImpl.java
(original)
+++ ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactObjectImpl.java
Wed Feb 15 12:41:24 2012
@@ -100,6 +100,10 @@ public class ArtifactObjectImpl extends 
         return getAttribute(KEY_URL);
     }
 
+    public String getResourceId() {
+        return getAttribute(KEY_RESOURCE_ID);
+    }
+
     public String getMimetype() {
         return getAttribute(KEY_MIMETYPE);
     }

Modified: ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/stateful/impl/StatefulGatewayRepositoryImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/stateful/impl/StatefulGatewayRepositoryImpl.java?rev=1244465&r1=1244464&r2=1244465&view=diff
==============================================================================
--- ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/stateful/impl/StatefulGatewayRepositoryImpl.java
(original)
+++ ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/stateful/impl/StatefulGatewayRepositoryImpl.java
Wed Feb 15 12:41:24 2012
@@ -19,7 +19,6 @@
 package org.apache.ace.client.repository.stateful.impl;
 
 import java.io.IOException;
-import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -546,6 +545,9 @@ public class StatefulGatewayRepositoryIm
             Map<String, String> directives = new HashMap<String, String>();
             directives.put(DeploymentArtifact.DIRECTIVE_KEY_PROCESSORID, artifact.getProcessorPID());
             directives.put(DeploymentArtifact.DIRECTIVE_KEY_BASEURL, artifact.getURL());
+            if (artifact.getResourceId() != null) {
+                directives.put(DeploymentArtifact.DIRECTIVE_KEY_RESOURCE_ID, artifact.getResourceId());
+            }
             
             String repositoryPath = getRepositoryPath(artifact, path);
             if (repositoryPath != null) {

Modified: ace/trunk/ace-deployment-provider-base/src/main/java/org/apache/ace/deployment/provider/impl/ArtifactDataImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-deployment-provider-base/src/main/java/org/apache/ace/deployment/provider/impl/ArtifactDataImpl.java?rev=1244465&r1=1244464&r2=1244465&view=diff
==============================================================================
--- ace/trunk/ace-deployment-provider-base/src/main/java/org/apache/ace/deployment/provider/impl/ArtifactDataImpl.java
(original)
+++ ace/trunk/ace-deployment-provider-base/src/main/java/org/apache/ace/deployment/provider/impl/ArtifactDataImpl.java
Wed Feb 15 12:41:24 2012
@@ -66,6 +66,10 @@ public class ArtifactDataImpl implements
         this(url, null, null, null, directives, hasChanged);
     }
 
+    public ArtifactDataImpl(String filename, URL url, Map<String, String> directives,
boolean hasChanged) {
+        this(url, null, null, filename, directives, hasChanged);
+    }
+
     /**
      * Constructs an ArtifactDataImpl object.
      * @param filename The filename of the bundle. If passed, it must only contain characters
[A-Za-z0-9._-]; can be null.

Modified: ace/trunk/ace-deployment-provider-repositorybased/src/main/java/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProvider.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-deployment-provider-repositorybased/src/main/java/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProvider.java?rev=1244465&r1=1244464&r2=1244465&view=diff
==============================================================================
--- ace/trunk/ace-deployment-provider-repositorybased/src/main/java/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProvider.java
(original)
+++ ace/trunk/ace-deployment-provider-repositorybased/src/main/java/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProvider.java
Wed Feb 15 12:41:24 2012
@@ -41,7 +41,9 @@ import javax.xml.xpath.XPathExpressionEx
 import javax.xml.xpath.XPathFactory;
 import javax.xml.xpath.XPathVariableResolver;
 
+import org.apache.ace.client.repository.helper.ArtifactHelper;
 import org.apache.ace.client.repository.helper.bundle.BundleHelper;
+import org.apache.ace.client.repository.object.ArtifactObject;
 import org.apache.ace.client.repository.object.DeploymentArtifact;
 import org.apache.ace.deployment.provider.ArtifactData;
 import org.apache.ace.deployment.provider.DeploymentProvider;
@@ -219,7 +221,8 @@ public class RepositoryBasedProvider imp
             }
             else {
                 // it is an artifact.
-                result.add(new ArtifactDataImpl(pair.getUrl(), directives, true));
+                String filename = directives.remove(DeploymentArtifact.DIRECTIVE_KEY_RESOURCE_ID);
+                result.add(new ArtifactDataImpl(filename, pair.getUrl(), directives, true));
             }
 
         }

Modified: ace/trunk/ace-deployment-provider-repositorybased/src/test/java/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-deployment-provider-repositorybased/src/test/java/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderTest.java?rev=1244465&r1=1244464&r2=1244465&view=diff
==============================================================================
--- ace/trunk/ace-deployment-provider-repositorybased/src/test/java/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderTest.java
(original)
+++ ace/trunk/ace-deployment-provider-repositorybased/src/test/java/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderTest.java
Wed Feb 15 12:41:24 2012
@@ -41,7 +41,9 @@ import javax.xml.transform.TransformerFa
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
+import org.apache.ace.client.repository.helper.ArtifactHelper;
 import org.apache.ace.client.repository.helper.bundle.BundleHelper;
+import org.apache.ace.client.repository.object.ArtifactObject;
 import org.apache.ace.client.repository.object.DeploymentArtifact;
 import org.apache.ace.deployment.provider.ArtifactData;
 import org.apache.ace.deployment.provider.impl.ArtifactDataImpl;
@@ -101,6 +103,7 @@ public class RepositoryBasedProviderTest
 
     private ArtifactData RESOURCEPROCESSOR1;
     private ArtifactData ARTIFACT1;
+    private ArtifactData ARTIFACT2;
 
     @SuppressWarnings("serial")
     @BeforeMethod(alwaysRun = true)
@@ -155,6 +158,10 @@ public class RepositoryBasedProviderTest
         attr = new HashMap<String, String>();
         attr.put(DeploymentArtifact.DIRECTIVE_KEY_PROCESSORID, "my.processor.pid");
         ARTIFACT1 = new ArtifactDataImpl(FileUtils.createTempFile(m_tempDirectory).toURI().toURL(),
attr, false);
+        attr = new HashMap<String, String>();
+        attr.put(DeploymentArtifact.DIRECTIVE_KEY_PROCESSORID, "my.processor.pid");
+        attr.put(DeploymentArtifact.DIRECTIVE_KEY_RESOURCE_ID, "Artifact2");
+        ARTIFACT2 = new ArtifactDataImpl(FileUtils.createTempFile(m_tempDirectory).toURI().toURL(),
attr, false);
     }
 
     private String generateValidTestXml() {
@@ -194,7 +201,7 @@ public class RepositoryBasedProviderTest
         versions.appendChild(generateDeploymentVersion(doc, EMPTYVERSIONGATEWAY, VERSION1,
new String[] {BUNDLE1.getUrl().toString(), BundleHelper.KEY_SYMBOLICNAME, BUNDLE1.getSymbolicName(),
BundleHelper.KEY_VERSION, BUNDLE1.getVersion()}));
         versions.appendChild(generateDeploymentVersion(doc, EMPTYVERSIONGATEWAY, VERSION2));
 
-        versions.appendChild(generateDeploymentVersion(doc, RESOURCEGATEWAY, VERSION1, new
String[] {BUNDLE1.getUrl().toString(), BundleHelper.KEY_SYMBOLICNAME, BUNDLE1.getSymbolicName(),
BundleHelper.KEY_VERSION, BUNDLE1.getVersion()}, new String[] {RESOURCEPROCESSOR1.getUrl().toString(),
DeploymentArtifact.DIRECTIVE_ISCUSTOMIZER, "true", BundleHelper.KEY_SYMBOLICNAME, RESOURCEPROCESSOR1.getSymbolicName(),
BundleHelper.KEY_VERSION, RESOURCEPROCESSOR1.getVersion()}, new String[] {ARTIFACT1.getUrl().toString(),
DeploymentArtifact.DIRECTIVE_KEY_PROCESSORID, "my.processor.pid"}));
+        versions.appendChild(generateDeploymentVersion(doc, RESOURCEGATEWAY, VERSION1, new
String[] {BUNDLE1.getUrl().toString(), BundleHelper.KEY_SYMBOLICNAME, BUNDLE1.getSymbolicName(),
BundleHelper.KEY_VERSION, BUNDLE1.getVersion()}, new String[] {RESOURCEPROCESSOR1.getUrl().toString(),
DeploymentArtifact.DIRECTIVE_ISCUSTOMIZER, "true", BundleHelper.KEY_SYMBOLICNAME, RESOURCEPROCESSOR1.getSymbolicName(),
BundleHelper.KEY_VERSION, RESOURCEPROCESSOR1.getVersion()}, new String[] {ARTIFACT1.getUrl().toString(),
DeploymentArtifact.DIRECTIVE_KEY_PROCESSORID, "my.processor.pid"}, new String[] {ARTIFACT2.getUrl().toString(),
DeploymentArtifact.DIRECTIVE_KEY_RESOURCE_ID, "Artifact2", DeploymentArtifact.DIRECTIVE_KEY_PROCESSORID,
"my.processor.pid" }));
 
         // transform the document to string
         TransformerFactory tFactory = TransformerFactory.newInstance();
@@ -528,7 +535,7 @@ public class RepositoryBasedProviderTest
 
         Collection<ArtifactData> bundleData = m_backend.getBundleData(RESOURCEGATEWAY,
versions.get(0));
 
-        assert bundleData.size() == 3 : "Expected three bundle to be found, but found " +
bundleData.size();
+        assert bundleData.size() == 4 : "Expected four bundle to be found, but found " +
bundleData.size();
         Iterator<ArtifactData> it = bundleData.iterator();
         while(it.hasNext()) {
             ArtifactData data = it.next();
@@ -538,6 +545,10 @@ public class RepositoryBasedProviderTest
                 // fine
             } else if (data.equals(ARTIFACT1)) {
                 // fine
+            } else if (data.equals(ARTIFACT2)) {
+                // check the filename
+                assert data.getFilename().equals("Artifact2");
+                assert data.getProcessorPid().equals("my.processor.pid");
             } else {
                 assert false : "Unknown bundle found";
             }

Modified: ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/repositoryadmin/RepositoryAdminTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/repositoryadmin/RepositoryAdminTest.java?rev=1244465&r1=1244464&r2=1244465&view=diff
==============================================================================
--- ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/repositoryadmin/RepositoryAdminTest.java
(original)
+++ ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/repositoryadmin/RepositoryAdminTest.java
Wed Feb 15 12:41:24 2012
@@ -1066,7 +1066,7 @@ public class RepositoryAdminTest extends
         // Empty tag map to be reused througout test
         final Map<String, String> tags = new HashMap<String, String>();
 
-        // First, create a bundle and an artifact, but do not provide a processor for the
artifact.
+        // First, create a bundle and two artifacts, but do not provide a processor for the
artifacts.
         ArtifactObject b1 = createBasicBundleObject("bundle1");
         Map<String, String> attr = new HashMap<String, String>();
         attr.put(ArtifactObject.KEY_URL, "http://myobject");
@@ -1075,6 +1075,14 @@ public class RepositoryAdminTest extends
 
         ArtifactObject a1 = m_artifactRepository.create(attr, tags);
 
+        attr = new HashMap<String, String>();
+        attr.put(ArtifactObject.KEY_URL, "http://myotherobject");
+        attr.put(ArtifactObject.KEY_PROCESSOR_PID, "my.processor.pid");
+        attr.put(ArtifactObject.KEY_RESOURCE_ID, "mymime");
+        attr.put(ArtifactHelper.KEY_MIMETYPE, "mymime");
+
+        ArtifactObject a2 = m_artifactRepository.create(attr, tags);
+
         GroupObject g = createBasicGroupObject("group");
         LicenseObject l = createBasicLicenseObject("license");
 
@@ -1085,6 +1093,7 @@ public class RepositoryAdminTest extends
 
         m_artifact2groupRepository.create(b1, g);
         m_artifact2groupRepository.create(a1, g);
+        m_artifact2groupRepository.create(a2, g);
 
         m_group2licenseRepository.create(g, l);
 
@@ -1113,7 +1122,7 @@ public class RepositoryAdminTest extends
 
         DeploymentArtifact[] toDeploy = dep.getDeploymentArtifacts();
 
-        assert toDeploy.length == 3 : "We expect to find three artifacts to deploy, but we
find: " + toDeploy.length;
+        assert toDeploy.length == 4 : "We expect to find four artifacts to deploy, but we
find: " + toDeploy.length;
         DeploymentArtifact bundle1 = toDeploy[0];
         Assert.assertEquals(b1.getURL(), bundle1.getUrl());
         DeploymentArtifact bundle2 = toDeploy[1];
@@ -1122,6 +1131,10 @@ public class RepositoryAdminTest extends
         DeploymentArtifact artifact1 = toDeploy[2];
         Assert.assertEquals(a1.getURL(), artifact1.getUrl());
         Assert.assertEquals("my.processor.pid", artifact1.getDirective(DeploymentArtifact.DIRECTIVE_KEY_PROCESSORID));
+        DeploymentArtifact artifact2 = toDeploy[3];
+        Assert.assertEquals(a2.getURL(), artifact2.getUrl());
+        Assert.assertEquals("my.processor.pid", artifact2.getDirective(DeploymentArtifact.DIRECTIVE_KEY_PROCESSORID));
+        Assert.assertEquals(a2.getResourceId(), artifact2.getDirective(DeploymentArtifact.DIRECTIVE_KEY_RESOURCE_ID));
 
         cleanUp();
 



Mime
View raw message