ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1476933 - in /ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui: domain/OBREntry.java vaadin/AddArtifactWindow.java
Date Mon, 29 Apr 2013 09:19:52 GMT
Author: bramk
Date: Mon Apr 29 09:19:52 2013
New Revision: 1476933

URL: http://svn.apache.org/r1476933
Log:
ACE-345 Improved OBR resource handling

Modified:
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/domain/OBREntry.java
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/AddArtifactWindow.java

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/domain/OBREntry.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/domain/OBREntry.java?rev=1476933&r1=1476932&r2=1476933&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/domain/OBREntry.java (original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/domain/OBREntry.java Mon
Apr 29 09:19:52 2013
@@ -19,16 +19,23 @@
 package org.apache.ace.webui.domain;
 
 public class OBREntry {
+	
+    private final String m_name;
     private final String m_symbolicName;
     private final String m_version;
     private final String m_uri;
 
-    public OBREntry(String symbolicName, String version, String uri) {
+    public OBREntry(String name, String symbolicName, String version, String uri) {
+    	m_name = name;
         m_symbolicName = symbolicName;
         m_version = version;
         m_uri = uri;
     }
 
+    public String getName() {
+        return m_name;
+    }
+
     public String getVersion() {
         return m_version;
     }

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/AddArtifactWindow.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/AddArtifactWindow.java?rev=1476933&r1=1476932&r2=1476933&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/AddArtifactWindow.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/AddArtifactWindow.java
Mon Apr 29 09:19:52 2013
@@ -579,11 +579,15 @@ abstract class AddArtifactWindow extends
      * Converts a given artifact object to an OBR entry.
      * 
      * @param artifactObject the artifact object to convert;
-     * @param artifactURL the artifact url.
+     * @param obrBase the obr base url.
      * @return an OBR entry instance, never <code>null</code>.
      */
-    private OBREntry convertToOBREntry(ArtifactObject artifactObject, String artifactURL)
{
-        return new OBREntry(artifactObject.getName(), artifactObject.getAttribute(BundleHelper.KEY_VERSION),
new File(artifactURL).getName());
+    private OBREntry convertToOBREntry(ArtifactObject artifactObject, String obrBase) {
+        String name = artifactObject.getName();
+        String symbolicName = artifactObject.getAttribute(BundleHelper.KEY_SYMBOLICNAME);
+        String version = artifactObject.getAttribute(BundleHelper.KEY_VERSION);
+        String relativeURL = artifactObject.getURL().substring(obrBase.length());
+        return new OBREntry(name, symbolicName, version, relativeURL);
     }
 
     /**
@@ -621,14 +625,11 @@ abstract class AddArtifactWindow extends
         // Create a list of all bundle names
         for (OBREntry s : obrList) {
             String uri = s.getUri();
-            String symbolicName = s.getSymbolicName();
-            if (symbolicName == null || symbolicName.length() == 0) {
-                symbolicName = uri;
-            }
+            String name = s.getName();
             String version = s.getVersion();
 
             Item item = dataSource.addItem(uri);
-            item.getItemProperty(ArtifactTable.PROPERTY_SYMBOLIC_NAME).setValue(symbolicName);
+            item.getItemProperty(ArtifactTable.PROPERTY_SYMBOLIC_NAME).setValue(name);
             item.getItemProperty(ArtifactTable.PROPERTY_VERSION).setValue(version);
         }
     }
@@ -658,7 +659,7 @@ abstract class AddArtifactWindow extends
             if (artifactURL != null && artifactURL.startsWith(baseURL)) {
                 // we now know this artifact comes from the OBR we are querying,
                 // so we are interested.
-                fromRepository.add(convertToOBREntry(ao, artifactURL));
+                fromRepository.add(convertToOBREntry(ao, baseURL));
             }
         }
         return fromRepository;
@@ -753,10 +754,25 @@ abstract class AddArtifactWindow extends
             NamedNodeMap attr = resource.getAttributes();
 
             String uri = getNamedItemText(attr, "uri");
+            if (uri == null || uri.equals("")) {
+                logError("Skipping resource without uri from repository " + obrBaseUrl);
+                continue;
+            }
+
+            String name = getNamedItemText(attr, "presentationname");
             String symbolicname = getNamedItemText(attr, "symbolicname");
             String version = getNamedItemText(attr, "version");
 
-            obrList.add(new OBREntry(symbolicname, version, uri));
+            if (name == null || name.equals("")) {
+                if (symbolicname != null && !symbolicname.equals("")) {
+                    name = symbolicname;
+                }
+                else {
+                    name = new File(uri).getName();
+                }
+            }
+
+            obrList.add(new OBREntry(name, symbolicname, version, uri));
         }
 
         return obrList;



Mime
View raw message