ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1152231 - in /incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest: RESTClientServlet.java Workspace.java
Date Fri, 29 Jul 2011 14:12:40 GMT
Author: marrs
Date: Fri Jul 29 14:12:40 2011
New Revision: 1152231

URL: http://svn.apache.org/viewvc?rev=1152231&view=rev
Log:
ACE-151 added proper support for (stateful) targets

Modified:
    incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/RESTClientServlet.java
    incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/Workspace.java

Modified: incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/RESTClientServlet.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/RESTClientServlet.java?rev=1152231&r1=1152230&r2=1152231&view=diff
==============================================================================
--- incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/RESTClientServlet.java
(original)
+++ incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/RESTClientServlet.java
Fri Jul 29 14:12:40 2011
@@ -117,7 +117,8 @@ public class RESTClientServlet extends H
                         List<RepositoryObject> objects = workspace.getRepositoryObjects(pathElements[2]);
                         JsonArray result = new JsonArray();
                         for (RepositoryObject ro : objects) {
-                            result.add(new JsonPrimitive(URLEncoder.encode(ro.getAssociationFilter(null),
"UTF-8")));
+                            String identity = workspace.getRepositoryObjectIdentity(ro);
+                            result.add(new JsonPrimitive(URLEncoder.encode(identity, "UTF-8")));
                         }
                         resp.getWriter().println(m_gson.toJson(result));
                         return;
@@ -200,7 +201,8 @@ public class RESTClientServlet extends H
                         try {
                             RepositoryValueObject data = m_gson.fromJson(req.getReader(),
RepositoryValueObject.class);
                             RepositoryObject object = workspace.addRepositoryObject(pathElements[2],
data.attributes, data.tags);
-                            resp.sendRedirect(buildPathFromElements(WORK_FOLDER, pathElements[1],
pathElements[2], object.getAssociationFilter(null)));
+                            String identity = workspace.getRepositoryObjectIdentity(object);
+                            resp.sendRedirect(buildPathFromElements(WORK_FOLDER, pathElements[1],
pathElements[2], identity));
                             return;
                         }
                         catch (IllegalArgumentException e) {

Modified: incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/Workspace.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/Workspace.java?rev=1152231&r1=1152230&r2=1152231&view=diff
==============================================================================
--- incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/Workspace.java
(original)
+++ incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/Workspace.java
Fri Jul 29 14:12:40 2011
@@ -36,6 +36,7 @@ import org.apache.ace.client.repository.
 import org.apache.ace.client.repository.repository.GroupRepository;
 import org.apache.ace.client.repository.repository.License2GatewayAssociationRepository;
 import org.apache.ace.client.repository.repository.LicenseRepository;
+import org.apache.ace.client.repository.stateful.StatefulGatewayObject;
 import org.apache.ace.client.repository.stateful.StatefulGatewayRepository;
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
@@ -156,6 +157,15 @@ public class Workspace {
         }
         return result;
     }
+    
+    public String getRepositoryObjectIdentity(RepositoryObject object) {
+        if (object instanceof StatefulGatewayObject) {
+            return ((StatefulGatewayObject) object).getGatewayObject().getAssociationFilter(null);
+        }
+        else {
+            return object.getAssociationFilter(null);
+        }
+    }
 
     public List<RepositoryObject> getRepositoryObjects(String entityType) {
         List list = getObjectRepository(entityType).get();
@@ -168,7 +178,12 @@ public class Workspace {
     }
 
     public RepositoryObject addRepositoryObject(String entityType, Map<String, String>
attributes, Map<String, String> tags) throws IllegalArgumentException{
-        return getObjectRepository(entityType).create(attributes, tags);
+        if (TARGET.equals(entityType)) {
+            return ((StatefulGatewayRepository) getObjectRepository(TARGET)).preregister(attributes,
tags);
+        }
+        else {
+            return getObjectRepository(entityType).create(attributes, tags);
+        }
     }
     
     public void deleteRepositoryObject(String entityType, String entityId) {
@@ -207,7 +222,7 @@ public class Workspace {
             return m_distribution2TargetAssociationRepository;
         }
         if (TARGET.equals(entityType)) {
-            return m_targetRepository;
+            return m_statefulTargetRepository;
         }
         throw new IllegalArgumentException("Unknown entity type: " + entityType);
     }



Mime
View raw message