incubator-ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject svn commit: r1138494 - in /incubator/ace/trunk: ace-client-repository-api/src/main/java/org/apache/ace/client/repository/helper/ ace-client-repository-helper-bundle/src/main/java/org/apache/ace/client/repository/helper/bundle/impl/ ace-client-repositor...
Date Wed, 22 Jun 2011 14:55:30 GMT
Author: pauls
Date: Wed Jun 22 14:55:30 2011
New Revision: 1138494

URL: http://svn.apache.org/viewvc?rev=1138494&view=rev
Log:
Change the way we handle identity across the board. We now do it based on the definintion
of an repository object (ACE-149).

Modified:
    incubator/ace/trunk/ace-client-repository-api/src/main/java/org/apache/ace/client/repository/helper/ArtifactRecognizer.java
    incubator/ace/trunk/ace-client-repository-helper-bundle/src/main/java/org/apache/ace/client/repository/helper/bundle/impl/BundleHelperImpl.java
    incubator/ace/trunk/ace-client-repository-helper-configuration/src/main/java/org/apache/ace/client/repository/helper/configuration/impl/ConfigurationHelperImpl.java
    incubator/ace/trunk/ace-client-repository-helper-user/src/main/java/org/apache/ace/client/repository/helper/user/impl/UserHelperImpl.java
    incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactObjectImpl.java
    incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactRepositoryImpl.java
    incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/stateful/impl/StatefulGatewayObjectImpl.java
    incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/stateful/impl/StatefulGatewayRepositoryImpl.java
    incubator/ace/trunk/ace-client-repository-impl/src/test/java/org/apache/ace/client/repository/impl/ArtifactTest.java
    incubator/ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/repositoryadmin/RepositoryAdminTest.java
    incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/NamedObject.java
    incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Associations.java
    incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedArtifactObject.java
    incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedDistributionObject.java
    incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedFeatureObject.java
    incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedTargetObject.java
    incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java

Modified: incubator/ace/trunk/ace-client-repository-api/src/main/java/org/apache/ace/client/repository/helper/ArtifactRecognizer.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-repository-api/src/main/java/org/apache/ace/client/repository/helper/ArtifactRecognizer.java?rev=1138494&r1=1138493&r2=1138494&view=diff
==============================================================================
--- incubator/ace/trunk/ace-client-repository-api/src/main/java/org/apache/ace/client/repository/helper/ArtifactRecognizer.java
(original)
+++ incubator/ace/trunk/ace-client-repository-api/src/main/java/org/apache/ace/client/repository/helper/ArtifactRecognizer.java
Wed Jun 22 14:55:30 2011
@@ -55,4 +55,13 @@ public interface ArtifactRecognizer
      * <code>false</code> otherwise.
      */
     public boolean canHandle(String mimetype);
+    
+    /**
+     * Returns a preferred extension for the file name if a new one is created.
+     * 
+     * @param artifact The url to the artifact.
+     * 
+     * @return The extension that is preferred or an empty string if there is none.
+     */
+    public String getExtension(URL artifact);
 }
\ No newline at end of file

Modified: incubator/ace/trunk/ace-client-repository-helper-bundle/src/main/java/org/apache/ace/client/repository/helper/bundle/impl/BundleHelperImpl.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-repository-helper-bundle/src/main/java/org/apache/ace/client/repository/helper/bundle/impl/BundleHelperImpl.java?rev=1138494&r1=1138493&r2=1138494&view=diff
==============================================================================
--- incubator/ace/trunk/ace-client-repository-helper-bundle/src/main/java/org/apache/ace/client/repository/helper/bundle/impl/BundleHelperImpl.java
(original)
+++ incubator/ace/trunk/ace-client-repository-helper-bundle/src/main/java/org/apache/ace/client/repository/helper/bundle/impl/BundleHelperImpl.java
Wed Jun 22 14:55:30 2011
@@ -275,4 +275,8 @@ public class BundleHelperImpl implements
     public ArtifactPreprocessor getPreprocessor() {
         return null;
     }
+    
+    public String getExtension(URL artifact) {
+        return ".jar";
+    }
 }
\ No newline at end of file

Modified: incubator/ace/trunk/ace-client-repository-helper-configuration/src/main/java/org/apache/ace/client/repository/helper/configuration/impl/ConfigurationHelperImpl.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-repository-helper-configuration/src/main/java/org/apache/ace/client/repository/helper/configuration/impl/ConfigurationHelperImpl.java?rev=1138494&r1=1138493&r2=1138494&view=diff
==============================================================================
--- incubator/ace/trunk/ace-client-repository-helper-configuration/src/main/java/org/apache/ace/client/repository/helper/configuration/impl/ConfigurationHelperImpl.java
(original)
+++ incubator/ace/trunk/ace-client-repository-helper-configuration/src/main/java/org/apache/ace/client/repository/helper/configuration/impl/ConfigurationHelperImpl.java
Wed Jun 22 14:55:30 2011
@@ -42,10 +42,17 @@ public class ConfigurationHelperImpl imp
 
     public Map<String, String> extractMetaData(URL artifact) throws IllegalArgumentException
{
         Map<String, String> result = new HashMap<String, String>();
-        result.put(KEY_FILENAME, new File(artifact.getFile()).getName());
         result.put(ArtifactObject.KEY_PROCESSOR_PID, PROCESSOR);
         result.put(ArtifactObject.KEY_MIMETYPE, MIMETYPE);
-        result.put(ArtifactObject.KEY_ARTIFACT_NAME, result.get(KEY_FILENAME));
+        String name = new File(artifact.getFile()).getName();
+        String key = KEY_FILENAME + "-";
+        int idx = name.indexOf(key);
+        if (idx > -1) {
+            int endIdx = name.indexOf("-", idx + key.length());
+            name = name.substring(idx + key.length(), (endIdx > -1) ? endIdx : (name.length()
- getExtension(artifact).length()));
+        }
+        result.put(ArtifactObject.KEY_ARTIFACT_NAME, name);
+        result.put(KEY_FILENAME, name);
         return result;
     }
 
@@ -100,4 +107,9 @@ public class ConfigurationHelperImpl imp
     public ArtifactPreprocessor getPreprocessor() {
         return VELOCITY_ARTIFACT_PREPROCESSOR;
     }
+    
+    public String getExtension(URL artifact) {
+        return ".xml";
+    }
+    
 }
\ No newline at end of file

Modified: incubator/ace/trunk/ace-client-repository-helper-user/src/main/java/org/apache/ace/client/repository/helper/user/impl/UserHelperImpl.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-repository-helper-user/src/main/java/org/apache/ace/client/repository/helper/user/impl/UserHelperImpl.java?rev=1138494&r1=1138493&r2=1138494&view=diff
==============================================================================
--- incubator/ace/trunk/ace-client-repository-helper-user/src/main/java/org/apache/ace/client/repository/helper/user/impl/UserHelperImpl.java
(original)
+++ incubator/ace/trunk/ace-client-repository-helper-user/src/main/java/org/apache/ace/client/repository/helper/user/impl/UserHelperImpl.java
Wed Jun 22 14:55:30 2011
@@ -45,7 +45,14 @@ public class UserHelperImpl implements A
         Map<String, String> result = new HashMap<String, String>();
         result.put(ArtifactObject.KEY_PROCESSOR_PID, PROCESSOR);
         result.put(ArtifactObject.KEY_MIMETYPE, MIMETYPE);
-        result.put(ArtifactObject.KEY_ARTIFACT_NAME, new File(artifact.getFile()).getName());
+        String name = new File(artifact.getFile()).getName();
+        String key = ArtifactObject.KEY_ARTIFACT_NAME + "-";
+        int idx = name.indexOf(key);
+        if (idx > -1) {
+            int endIdx = name.indexOf("-", idx + key.length());
+            name = name.substring(idx + key.length(), (endIdx > -1) ? endIdx : (name.length()
- getExtension(artifact).length()));
+        }
+        result.put(ArtifactObject.KEY_ARTIFACT_NAME, name);
         return result;
     }
 
@@ -104,4 +111,8 @@ public class UserHelperImpl implements A
     public ArtifactPreprocessor getPreprocessor() {
         return VELOCITY_ARTIFACT_PREPROCESSOR;
     }
+    
+    public String getExtension(URL artifact) {
+        return ".xml";
+    }
 }
\ No newline at end of file

Modified: incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactObjectImpl.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactObjectImpl.java?rev=1138494&r1=1138493&r2=1138494&view=diff
==============================================================================
--- incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactObjectImpl.java
(original)
+++ incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactObjectImpl.java
Wed Jun 22 14:55:30 2011
@@ -55,12 +55,11 @@ public class ArtifactObjectImpl extends 
     }
 
     private static String[] completeMandatoryAttributes(String[] mandatory) {
-        String[] result = new String[mandatory.length + 2];
+        String[] result = new String[mandatory.length + 1];
         for (int i = 0; i < mandatory.length; i++) {
             result[i] = mandatory[i];
         }
         result[mandatory.length] = KEY_MIMETYPE;
-        result[mandatory.length + 1 ] = KEY_URL;
         return result;
     }
 
@@ -94,15 +93,7 @@ public class ArtifactObjectImpl extends 
 
     @Override
     String[] getDefiningKeys() {
-        String[] fromHelper = getHelper().getDefiningKeys();
-
-        String[] result = new String[fromHelper.length + 1];
-        for (int i = 0; i < fromHelper.length; i++) {
-            result[i] = fromHelper[i];
-        }
-        result[fromHelper.length] = KEY_URL;
-
-        return result;
+        return getHelper().getDefiningKeys().clone();
     }
 
     public String getURL() {

Modified: incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactRepositoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactRepositoryImpl.java?rev=1138494&r1=1138493&r2=1138494&view=diff
==============================================================================
--- incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactRepositoryImpl.java
(original)
+++ incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactRepositoryImpl.java
Wed Jun 22 14:55:30 2011
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.ArrayList;
@@ -141,7 +142,15 @@ public class ArtifactRepositoryImpl exte
     @Override
     ArtifactObjectImpl createNewInhabitant(Map<String, String> attributes, Map<String,
String> tags) {
         ArtifactHelper helper = getHelper(attributes.get(ArtifactObject.KEY_MIMETYPE));
-        return new ArtifactObjectImpl(helper.checkAttributes(attributes), helper.getMandatoryAttributes(),
tags, this, this);
+        ArtifactObjectImpl ao = new ArtifactObjectImpl(helper.checkAttributes(attributes),
helper.getMandatoryAttributes(), tags, this, this);
+        if ((ao.getAttribute("upload") != null) && (m_obrBase != null)){
+            try {
+                ao.addAttribute(ArtifactObject.KEY_URL, new URL(m_obrBase, ao.getDefinition()
+ ao.getAttribute("upload")).toString());
+            } catch (MalformedURLException e) {
+                throw new IllegalStateException(e);
+            }
+        }
+        return ao;
     }
 
     @Override
@@ -346,22 +355,38 @@ public class ArtifactRepositoryImpl exte
         Map<String, String> tags = new HashMap<String, String>();
 
         helper.checkAttributes(attributes);
-
-        URL location;
-        if (upload) {
-            location = upload(artifact, mimetype);
-        }
-        else {
-            location = artifact;
-        }
-
-        attributes.put(ArtifactObject.KEY_URL, location.toString());
         attributes.put(ArtifactObject.KEY_ARTIFACT_DESCRIPTION, "");
         if (overwrite) {
             attributes.put(ArtifactObject.KEY_MIMETYPE, mimetype);
         }
 
-        return create(attributes, tags);
+        String artifactURL = artifact.toString();
+        
+        attributes.put(ArtifactObject.KEY_URL, artifactURL);
+        
+        if (upload) {
+            attributes.put("upload", recognizer.getExtension(artifact));
+        }
+
+        ArtifactObject result = create(attributes, tags);
+        
+        if (upload) {
+            try {
+                upload(artifact, result.getDefinition() + attributes.get("upload"), mimetype);
+            } catch (IOException ex) {
+                remove(result);
+                throw ex;
+            }
+            finally {
+                try {
+                    attributes.remove("upload");
+                } catch (Exception ex) {
+                    // Not much we can do
+                }
+            }
+        }
+        return result;
+        
     }
 
     /**
@@ -407,7 +432,7 @@ public class ArtifactRepositoryImpl exte
      * @return The persistent URL of this artifact.
      * @throws IOException for any problem uploading the artifact.
      */
-    private URL upload(URL artifact, String mimetype) throws IOException {
+    private URL upload(URL artifact, String definition, String mimetype) throws IOException
{
         if (m_obrBase == null) {
             throw new IOException("There is no storage available for this artifact.");
         }
@@ -417,7 +442,7 @@ public class ArtifactRepositoryImpl exte
         URL url = null;
         try {
             input = artifact.openStream();
-            url = new URL(m_obrBase, new File(artifact.getFile()).getName());
+            url = new URL(m_obrBase, definition);
             URLConnection connection = url.openConnection();
             connection.setDoOutput(true);
             connection.setDoInput(true);

Modified: incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/stateful/impl/StatefulGatewayObjectImpl.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/stateful/impl/StatefulGatewayObjectImpl.java?rev=1138494&r1=1138493&r2=1138494&view=diff
==============================================================================
--- incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/stateful/impl/StatefulGatewayObjectImpl.java
(original)
+++ incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/stateful/impl/StatefulGatewayObjectImpl.java
Wed Jun 22 14:55:30 2011
@@ -571,10 +571,7 @@ public class StatefulGatewayObjectImpl i
     }
 
     public String getDefinition() {
-        synchronized(m_lock) {
-            ensureGatewayPresent();
-            return m_gatewayObject.getDefinition();
-        }
+        return "gateway-" + KEY_ID + "-" + getID();
     }
 
     private class ExtendedEnumeration<T> implements Enumeration<T> {

Modified: incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/stateful/impl/StatefulGatewayRepositoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/stateful/impl/StatefulGatewayRepositoryImpl.java?rev=1138494&r1=1138493&r2=1138494&view=diff
==============================================================================
--- incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/stateful/impl/StatefulGatewayRepositoryImpl.java
(original)
+++ incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/stateful/impl/StatefulGatewayRepositoryImpl.java
Wed Jun 22 14:55:30 2011
@@ -511,6 +511,7 @@ public class StatefulGatewayRepositoryIm
             if (bundleVersion != null) {
                 directives.put(BundleHelper.KEY_VERSION, bundleVersion);
             }
+            
             directives.put(DeploymentArtifact.DIRECTIVE_KEY_BASEURL, bundle.getURL());
             result.add(m_deploymentRepository.createDeploymentArtifact(bundle.getURL(), directives));
         }

Modified: incubator/ace/trunk/ace-client-repository-impl/src/test/java/org/apache/ace/client/repository/impl/ArtifactTest.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-repository-impl/src/test/java/org/apache/ace/client/repository/impl/ArtifactTest.java?rev=1138494&r1=1138493&r2=1138494&view=diff
==============================================================================
--- incubator/ace/trunk/ace-client-repository-impl/src/test/java/org/apache/ace/client/repository/impl/ArtifactTest.java
(original)
+++ incubator/ace/trunk/ace-client-repository-impl/src/test/java/org/apache/ace/client/repository/impl/ArtifactTest.java
Wed Jun 22 14:55:30 2011
@@ -153,11 +153,11 @@ class MockHelper implements ArtifactHelp
     }
 
     public String[] getDefiningKeys() {
-        return new String[0];
+        return new String[]{ArtifactObject.KEY_URL};
     }
 
     public String[] getMandatoryAttributes() {
-        return new String[0];
+        return new String[]{ArtifactObject.KEY_URL};
     }
 
     public boolean canUse(ArtifactObject object) {

Modified: incubator/ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/repositoryadmin/RepositoryAdminTest.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/repositoryadmin/RepositoryAdminTest.java?rev=1138494&r1=1138493&r2=1138494&view=diff
==============================================================================
--- incubator/ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/repositoryadmin/RepositoryAdminTest.java
(original)
+++ incubator/ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/repositoryadmin/RepositoryAdminTest.java
Wed Jun 22 14:55:30 2011
@@ -1935,11 +1935,11 @@ class MockArtifactHelper implements Arti
         return null;
     }
     public String[] getDefiningKeys() {
-        return new String[0];
+        return new String[] {ArtifactObject.KEY_URL};
     }
 
     public String[] getMandatoryAttributes() {
-        return new String[0];
+        return new String[] {ArtifactObject.KEY_URL};
     }
 
     public <TYPE extends ArtifactObject> String getAssociationFilter(TYPE obj, Map<String,
String> properties) {

Modified: incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/NamedObject.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/NamedObject.java?rev=1138494&r1=1138493&r2=1138494&view=diff
==============================================================================
--- incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/NamedObject.java
(original)
+++ incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/NamedObject.java
Wed Jun 22 14:55:30 2011
@@ -7,4 +7,5 @@ public interface NamedObject {
     String getDescription();
     void setDescription(String description);
     RepositoryObject getObject();
+    public String getDefinition();
 }
\ No newline at end of file

Modified: incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Associations.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Associations.java?rev=1138494&r1=1138493&r2=1138494&view=diff
==============================================================================
--- incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Associations.java
(original)
+++ incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Associations.java
Wed Jun 22 14:55:30 2011
@@ -72,7 +72,7 @@ public class Associations {
                 return null;
             }
             public boolean equals(Object itemId, RepositoryObject object) {
-                return (getNamedObject(object).getName().equals(itemId));
+                return (getNamedObject(object).getDefinition().equals(itemId));
             }
     	};
     }
@@ -203,7 +203,7 @@ public class Associations {
                 if (object != null) {
                     NamedObject namedObject = getNamedObject(object);
                     if (namedObject != null) {
-                        if (namedObject.getName().equals(value)) {
+                        if (namedObject.getDefinition().equals(value)) {
                             return object;
                         }
                     }

Modified: incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedArtifactObject.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedArtifactObject.java?rev=1138494&r1=1138493&r2=1138494&view=diff
==============================================================================
--- incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedArtifactObject.java
(original)
+++ incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedArtifactObject.java
Wed Jun 22 14:55:30 2011
@@ -26,4 +26,8 @@ public class NamedArtifactObject impleme
     public RepositoryObject getObject() {
         return m_target;
     }
+    
+    public String getDefinition() {
+        return m_target.getDefinition();
+    }
 }
\ No newline at end of file

Modified: incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedDistributionObject.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedDistributionObject.java?rev=1138494&r1=1138493&r2=1138494&view=diff
==============================================================================
--- incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedDistributionObject.java
(original)
+++ incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedDistributionObject.java
Wed Jun 22 14:55:30 2011
@@ -26,4 +26,8 @@ public class NamedDistributionObject imp
     public RepositoryObject getObject() {
         return m_target;
     }
+    
+    public String getDefinition() {
+        return m_target.getDefinition();
+    }
 }
\ No newline at end of file

Modified: incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedFeatureObject.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedFeatureObject.java?rev=1138494&r1=1138493&r2=1138494&view=diff
==============================================================================
--- incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedFeatureObject.java
(original)
+++ incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedFeatureObject.java
Wed Jun 22 14:55:30 2011
@@ -26,4 +26,8 @@ public class NamedFeatureObject implemen
     public RepositoryObject getObject() {
         return m_target;
     }
+    
+    public String getDefinition() {
+        return m_target.getDefinition();
+    }
 }
\ No newline at end of file

Modified: incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedTargetObject.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedTargetObject.java?rev=1138494&r1=1138493&r2=1138494&view=diff
==============================================================================
--- incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedTargetObject.java
(original)
+++ incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/NamedTargetObject.java
Wed Jun 22 14:55:30 2011
@@ -37,4 +37,8 @@ class NamedTargetObject implements Named
     public RepositoryObject getObject() {
         return m_target;
     }
+    
+    public String getDefinition() {
+        return m_target.getDefinition();
+    }
 }
\ No newline at end of file

Modified: incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java?rev=1138494&r1=1138493&r2=1138494&view=diff
==============================================================================
--- incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
(original)
+++ incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
Wed Jun 22 14:55:30 2011
@@ -618,35 +618,38 @@ public class VaadinClient extends com.va
 
                 	return;
                 }
-                Item item = addItem(artifact.getName());
-                item.getItemProperty(OBJECT_NAME).setValue(artifact.getName());
-                item.getItemProperty(OBJECT_DESCRIPTION).setValue(artifact.getDescription());
-                HorizontalLayout buttons = new HorizontalLayout();
-                Button removeLinkButton = new RemoveLinkButton<ArtifactObject>(artifact,
null, m_featuresPanel) {
-                    @Override
-                    protected void removeLinkFromLeft(ArtifactObject object, RepositoryObject
other) {}
-                    
-                    @Override
-                    protected void removeLinkFromRight(ArtifactObject object, RepositoryObject
other) {
-                        List<Artifact2GroupAssociation> associations = object.getAssociationsWith((GroupObject)
other);
-                        for (Artifact2GroupAssociation association : associations) {
-                            m_artifact2GroupAssociationRepository.remove(association);
+                Item item = addItem(artifact.getDefinition());
+                if (item != null) {
+                    item.getItemProperty(OBJECT_NAME).setValue(artifact.getName());
+                    item.getItemProperty(OBJECT_DESCRIPTION).setValue(artifact.getDescription());
+                    HorizontalLayout buttons = new HorizontalLayout();
+                    Button removeLinkButton = new RemoveLinkButton<ArtifactObject>(artifact,
null, m_featuresPanel) {
+                        @Override
+                        protected void removeLinkFromLeft(ArtifactObject object, RepositoryObject
other) {}
+                        
+                        @Override
+                        protected void removeLinkFromRight(ArtifactObject object, RepositoryObject
other) {
+                            List<Artifact2GroupAssociation> associations = object.getAssociationsWith((GroupObject)
other);
+                            for (Artifact2GroupAssociation association : associations) {
+                                m_artifact2GroupAssociationRepository.remove(association);
+                            }
+                            m_associations.removeAssociatedItem(object);
+                            m_table.requestRepaint();
                         }
-                        m_associations.removeAssociatedItem(object);
-                        m_table.requestRepaint();
-                    }
-                };
-                buttons.addComponent(removeLinkButton);
-                buttons.addComponent(new RemoveItemButton<ArtifactObject, ArtifactRepository>(artifact,
m_artifactRepository));
-                item.getItemProperty(ACTIONS).setValue(buttons);
-
+                    };
+                    buttons.addComponent(removeLinkButton);
+                    buttons.addComponent(new RemoveItemButton<ArtifactObject, ArtifactRepository>(artifact,
m_artifactRepository));
+                    item.getItemProperty(ACTIONS).setValue(buttons);
+                }
             }
             private void change(ArtifactObject artifact) {
-                Item item = getItem(artifact.getName());
-                item.getItemProperty(OBJECT_DESCRIPTION).setValue(artifact.getDescription());
+                Item item = getItem(artifact.getDefinition());
+                if (item != null) {
+                    item.getItemProperty(OBJECT_DESCRIPTION).setValue(artifact.getDescription());
+                }
             }
             private void remove(ArtifactObject artifact) {
-                removeItem(artifact.getName());
+                removeItem(artifact.getDefinition());
             }
         };
     }
@@ -678,41 +681,45 @@ public class VaadinClient extends com.va
                 }
             }
             private void add(GroupObject feature) {
-                Item item = addItem(feature.getName());
-                item.getItemProperty(OBJECT_NAME).setValue(feature.getName());
-                item.getItemProperty(OBJECT_DESCRIPTION).setValue(feature.getDescription());
-                Button removeLinkButton = new RemoveLinkButton<GroupObject>(feature,
m_artifactsPanel, m_distributionsPanel) {
-                    @Override
-                    protected void removeLinkFromLeft(GroupObject object, RepositoryObject
other) {
-                        List<Artifact2GroupAssociation> associations = object.getAssociationsWith((ArtifactObject)
other);
-                        for (Artifact2GroupAssociation association : associations) {
-                            m_artifact2GroupAssociationRepository.remove(association);
+                Item item = addItem(feature.getDefinition());
+                if (item != null) {
+                    item.getItemProperty(OBJECT_NAME).setValue(feature.getName());
+                    item.getItemProperty(OBJECT_DESCRIPTION).setValue(feature.getDescription());
+                    Button removeLinkButton = new RemoveLinkButton<GroupObject>(feature,
m_artifactsPanel, m_distributionsPanel) {
+                        @Override
+                        protected void removeLinkFromLeft(GroupObject object, RepositoryObject
other) {
+                            List<Artifact2GroupAssociation> associations = object.getAssociationsWith((ArtifactObject)
other);
+                            for (Artifact2GroupAssociation association : associations) {
+                                m_artifact2GroupAssociationRepository.remove(association);
+                            }
+                            m_associations.removeAssociatedItem(object);
+                            m_table.requestRepaint();
                         }
-                        m_associations.removeAssociatedItem(object);
-                        m_table.requestRepaint();
-                    }
-
-                    @Override
-                    protected void removeLinkFromRight(GroupObject object, RepositoryObject
other) {
-                        List<Group2LicenseAssociation> associations = object.getAssociationsWith((LicenseObject)
other);
-                        for (Group2LicenseAssociation association : associations) {
-                            m_group2LicenseAssociationRepository.remove(association);
+    
+                        @Override
+                        protected void removeLinkFromRight(GroupObject object, RepositoryObject
other) {
+                            List<Group2LicenseAssociation> associations = object.getAssociationsWith((LicenseObject)
other);
+                            for (Group2LicenseAssociation association : associations) {
+                                m_group2LicenseAssociationRepository.remove(association);
+                            }
+                            m_associations.removeAssociatedItem(object);
+                            m_table.requestRepaint();
                         }
-                        m_associations.removeAssociatedItem(object);
-                        m_table.requestRepaint();
-                    }
-                };
-                HorizontalLayout buttons = new HorizontalLayout();
-                buttons.addComponent(removeLinkButton);
-                buttons.addComponent(new RemoveItemButton<GroupObject, GroupRepository>(feature,
m_featureRepository));
-                item.getItemProperty(ACTIONS).setValue(buttons);
+                    };
+                    HorizontalLayout buttons = new HorizontalLayout();
+                    buttons.addComponent(removeLinkButton);
+                    buttons.addComponent(new RemoveItemButton<GroupObject, GroupRepository>(feature,
m_featureRepository));
+                    item.getItemProperty(ACTIONS).setValue(buttons);
+                }
             }
             private void change(GroupObject go) {
-                Item item = getItem(go.getName());
-                item.getItemProperty(OBJECT_DESCRIPTION).setValue(go.getDescription());
+                Item item = getItem(go.getDefinition());
+                if (item != null) {
+                    item.getItemProperty(OBJECT_DESCRIPTION).setValue(go.getDescription());
+                }
             }
             private void remove(GroupObject go) {
-                removeItem(go.getName());
+                removeItem(go.getDefinition());
             }
          };
     }
@@ -788,41 +795,45 @@ public class VaadinClient extends com.va
                 }
             }
             private void add(LicenseObject distribution) {
-                Item item = addItem(distribution.getName());
-                item.getItemProperty(OBJECT_NAME).setValue(distribution.getName());
-                item.getItemProperty(OBJECT_DESCRIPTION).setValue(distribution.getDescription());
-                Button removeLinkButton = new RemoveLinkButton<LicenseObject>(distribution,
m_featuresPanel, m_targetsPanel) {
-                    @Override
-                    protected void removeLinkFromLeft(LicenseObject object, RepositoryObject
other) {
-                        List<Group2LicenseAssociation> associations = object.getAssociationsWith((GroupObject)
other);
-                        for (Group2LicenseAssociation association : associations) {
-                            m_group2LicenseAssociationRepository.remove(association);
+                Item item = addItem(distribution.getDefinition());
+                if (item != null) {
+                    item.getItemProperty(OBJECT_NAME).setValue(distribution.getName());
+                    item.getItemProperty(OBJECT_DESCRIPTION).setValue(distribution.getDescription());
+                    Button removeLinkButton = new RemoveLinkButton<LicenseObject>(distribution,
m_featuresPanel, m_targetsPanel) {
+                        @Override
+                        protected void removeLinkFromLeft(LicenseObject object, RepositoryObject
other) {
+                            List<Group2LicenseAssociation> associations = object.getAssociationsWith((GroupObject)
other);
+                            for (Group2LicenseAssociation association : associations) {
+                                m_group2LicenseAssociationRepository.remove(association);
+                            }
+                            m_associations.removeAssociatedItem(object);
+                            m_table.requestRepaint();
                         }
-                        m_associations.removeAssociatedItem(object);
-                        m_table.requestRepaint();
-                    }
-
-                    @Override
-                    protected void removeLinkFromRight(LicenseObject object, RepositoryObject
other) {
-                        List<License2GatewayAssociation> associations = object.getAssociationsWith((GatewayObject)
other);
-                        for (License2GatewayAssociation association : associations) {
-                            m_license2GatewayAssociationRepository.remove(association);
+    
+                        @Override
+                        protected void removeLinkFromRight(LicenseObject object, RepositoryObject
other) {
+                            List<License2GatewayAssociation> associations = object.getAssociationsWith((GatewayObject)
other);
+                            for (License2GatewayAssociation association : associations) {
+                                m_license2GatewayAssociationRepository.remove(association);
+                            }
+                            m_associations.removeAssociatedItem(object);
+                            m_table.requestRepaint();
                         }
-                        m_associations.removeAssociatedItem(object);
-                        m_table.requestRepaint();
-                    }
-                };
-                HorizontalLayout buttons = new HorizontalLayout();
-                buttons.addComponent(removeLinkButton);
-                buttons.addComponent(new RemoveItemButton<LicenseObject, LicenseRepository>(distribution,
m_distributionRepository));
-                item.getItemProperty(ACTIONS).setValue(buttons);
+                    };
+                    HorizontalLayout buttons = new HorizontalLayout();
+                    buttons.addComponent(removeLinkButton);
+                    buttons.addComponent(new RemoveItemButton<LicenseObject, LicenseRepository>(distribution,
m_distributionRepository));
+                    item.getItemProperty(ACTIONS).setValue(buttons);
+                }
             }
             private void change(LicenseObject distribution) {
-                Item item = getItem(distribution.getName());
-                item.getItemProperty(OBJECT_DESCRIPTION).setValue(distribution.getDescription());
+                Item item = getItem(distribution.getDefinition());
+                if (item != null) {
+                    item.getItemProperty(OBJECT_DESCRIPTION).setValue(distribution.getDescription());
+                }
             }
             private void remove(LicenseObject distribution) {
-                removeItem(distribution.getName());
+                removeItem(distribution.getDefinition());
             }
         };
     }
@@ -855,36 +866,40 @@ public class VaadinClient extends com.va
                 }
             }
             private void add(StatefulGatewayObject statefulTarget) {
-                Item item = addItem(statefulTarget.getID());
-                item.getItemProperty(OBJECT_NAME).setValue(statefulTarget.getID());
-                item.getItemProperty(OBJECT_DESCRIPTION).setValue("");
-                Button removeLinkButton = new RemoveLinkButton<StatefulGatewayObject>(statefulTarget,
m_distributionsPanel, null) {
-                    @Override
-                    protected void removeLinkFromLeft(StatefulGatewayObject object, RepositoryObject
other) {
-                        List<License2GatewayAssociation> associations = object.getAssociationsWith((LicenseObject)
other);
-                        for (License2GatewayAssociation association : associations) {
-                            m_license2GatewayAssociationRepository.remove(association);
+                Item item = addItem(statefulTarget.getDefinition());
+                if (item != null) {
+                    item.getItemProperty(OBJECT_NAME).setValue(statefulTarget.getID());
+                    item.getItemProperty(OBJECT_DESCRIPTION).setValue("");
+                    Button removeLinkButton = new RemoveLinkButton<StatefulGatewayObject>(statefulTarget,
m_distributionsPanel, null) {
+                        @Override
+                        protected void removeLinkFromLeft(StatefulGatewayObject object, RepositoryObject
other) {
+                            List<License2GatewayAssociation> associations = object.getAssociationsWith((LicenseObject)
other);
+                            for (License2GatewayAssociation association : associations) {
+                                m_license2GatewayAssociationRepository.remove(association);
+                            }
+                            m_associations.removeAssociatedItem(object);
+                            m_table.requestRepaint();
                         }
-                        m_associations.removeAssociatedItem(object);
-                        m_table.requestRepaint();
-                    }
-
-                    @Override
-                    protected void removeLinkFromRight(StatefulGatewayObject object, RepositoryObject
other) {
-                    }
-                };
-                HorizontalLayout buttons = new HorizontalLayout();
-                buttons.addComponent(removeLinkButton);
-                // next line commented out because removing stateful targets currently is
not possible
-                //buttons.addComponent(new RemoveItemButton<StatefulGatewayObject, StatefulGatewayRepository>(statefulTarget,
m_statefulTargetRepository));
-                item.getItemProperty(ACTIONS).setValue(buttons);
+    
+                        @Override
+                        protected void removeLinkFromRight(StatefulGatewayObject object,
RepositoryObject other) {
+                        }
+                    };
+                    HorizontalLayout buttons = new HorizontalLayout();
+                    buttons.addComponent(removeLinkButton);
+                    // next line commented out because removing stateful targets currently
is not possible
+                    //buttons.addComponent(new RemoveItemButton<StatefulGatewayObject,
StatefulGatewayRepository>(statefulTarget, m_statefulTargetRepository));
+                    item.getItemProperty(ACTIONS).setValue(buttons);
+                }
             }
             private void change(StatefulGatewayObject statefulTarget) {
-                Item item = getItem(statefulTarget.getID());
-                item.getItemProperty(OBJECT_DESCRIPTION).setValue("");
+                Item item = getItem(statefulTarget.getDefinition());
+                if (item != null) {
+                    item.getItemProperty(OBJECT_DESCRIPTION).setValue("");
+                } 
             }
             private void remove(StatefulGatewayObject statefulTarget) {
-                removeItem(statefulTarget.getID());
+                removeItem(statefulTarget.getDefinition());
             }
         };
     }
@@ -1014,51 +1029,43 @@ public class VaadinClient extends com.va
         m_statefulTargetRepository.preregister(attributes, tags);
     }
 
-    private ArtifactObject getArtifact(String name) {
-        try {
-            List<ArtifactObject> list = m_artifactRepository.get(m_context.createFilter("("
+ ArtifactObject.KEY_ARTIFACT_NAME + "=" + name + ")"));
-            if (list.size() == 1) {
-                return list.get(0);
+    private ArtifactObject getArtifact(String definition) {
+        List<ArtifactObject> list = m_artifactRepository.get();
+        for (ArtifactObject ao : list) {
+            if (ao.getDefinition().equals(definition)) {
+                return ao;
             }
         }
-        catch (InvalidSyntaxException e) {
-        }
         return null;
     }
 
     private GroupObject getFeature(String name) {
-        try {
-            List<GroupObject> list = m_featureRepository.get(m_context.createFilter("("
+ GroupObject.KEY_NAME + "=" + name + ")"));
-            if (list.size() == 1) {
-                return list.get(0);
+        List<GroupObject> list = m_featureRepository.get();
+        for (GroupObject go : list) {
+            if (go.getDefinition().equals(name)) {
+                return go;
             }
         }
-        catch (InvalidSyntaxException e) {
-        }
         return null;
     }
     
     private LicenseObject getDistribution(String name) {
-        try {
-            List<LicenseObject> list = m_distributionRepository.get(m_context.createFilter("("
+ LicenseObject.KEY_NAME + "=" + name + ")"));
-            if (list.size() == 1) {
-                return list.get(0);
+        List<LicenseObject> list = m_distributionRepository.get();
+        for (LicenseObject lo : list) {
+            if (lo.getDefinition().equals(name)) {
+                return lo;
             }
         }
-        catch (InvalidSyntaxException e) {
-        }
         return null;
     }
     
     private StatefulGatewayObject getTarget(String name) {
-        try {
-            List<StatefulGatewayObject> list = m_statefulTargetRepository.get(m_context.createFilter("("
+ StatefulGatewayObject.KEY_ID + "=" + name + ")"));
-            if (list.size() == 1) {
-                return list.get(0);
+        List<StatefulGatewayObject> list = m_statefulTargetRepository.get();
+        for (StatefulGatewayObject sgo : list) {
+            if (sgo.getDefinition().equals(name)) {
+                return sgo;
             }
         }
-        catch (InvalidSyntaxException e) {
-        }
         return null;
     }
 
@@ -1373,7 +1380,7 @@ public class VaadinClient extends com.va
             String version = getNamedItemText(attr, "version");
             m_obrList.add(new OBREntry(symbolicname, version, uri));
         }
-
+        
         // Create a list of filenames from the ArtifactRepository
         List<OBREntry> fromRepository = new ArrayList<OBREntry>();
         List<ArtifactObject> artifactObjects = m_artifactRepository.get();
@@ -1398,14 +1405,18 @@ public class VaadinClient extends com.va
             String uri = s.getUri();
             String symbolicName = s.getSymbolicName();
             String version = s.getVersion();
-            Item item = table.addItem(uri);
-            if (symbolicName == null || symbolicName.length() == 0) {
-                item.getItemProperty("symbolic name").setValue(uri);
-            }
-            else {
-                item.getItemProperty("symbolic name").setValue(symbolicName);
+            try {
+                Item item = table.addItem(uri);
+                if (symbolicName == null || symbolicName.length() == 0) {
+                    item.getItemProperty("symbolic name").setValue(uri);
+                }
+                else {
+                    item.getItemProperty("symbolic name").setValue(symbolicName);
+                }
+                item.getItemProperty("version").setValue(version);
+            } catch (Exception ex) {
+                ex.printStackTrace();
             }
-            item.getItemProperty("version").setValue(version);
         }
     }
     



Mime
View raw message