incubator-ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1152257 - in /incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest: RESTClientServlet.java RepositoryObjectSerializer.java Workspace.java
Date Fri, 29 Jul 2011 15:11:02 GMT
Author: marrs
Date: Fri Jul 29 15:11:01 2011
New Revision: 1152257

URL: http://svn.apache.org/viewvc?rev=1152257&view=rev
Log:
ACE-151 now also starts to expose the state of targets, read-only and not 100% complete yet

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/RepositoryObjectSerializer.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=1152257&r1=1152256&r2=1152257&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 15:11:01 2011
@@ -36,6 +36,7 @@ import javax.servlet.http.HttpServletRes
 
 import org.apache.ace.client.repository.RepositoryObject;
 import org.apache.ace.client.repository.SessionFactory;
+import org.apache.ace.client.repository.stateful.StatefulGatewayObject;
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
 import org.osgi.service.cm.ConfigurationException;

Modified: incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/RepositoryObjectSerializer.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/RepositoryObjectSerializer.java?rev=1152257&r1=1152256&r2=1152257&view=diff
==============================================================================
--- incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/RepositoryObjectSerializer.java
(original)
+++ incubator/ace/trunk/ace-client-rest/src/main/java/org/apache/ace/client/rest/RepositoryObjectSerializer.java
Fri Jul 29 15:11:01 2011
@@ -22,9 +22,14 @@ import java.lang.reflect.Type;
 import java.util.Enumeration;
 
 import org.apache.ace.client.repository.RepositoryObject;
+import org.apache.ace.client.repository.object.ArtifactObject;
+import org.apache.ace.client.repository.object.DeploymentArtifact;
+import org.apache.ace.client.repository.stateful.StatefulGatewayObject;
 
+import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
 import com.google.gson.JsonSerializationContext;
 import com.google.gson.JsonSerializer;
 
@@ -50,6 +55,35 @@ public class RepositoryObjectSerializer 
             tags.addProperty(key, repositoryObject.getTag(key));
         }
         result.add("tags", tags);
+        // finally, if it's a target with state, add that as well
+        if (repositoryObject instanceof StatefulGatewayObject) {
+            StatefulGatewayObject stateful = (StatefulGatewayObject) repositoryObject;
+            JsonObject state = new JsonObject();
+            state.addProperty("registrationState", stateful.getRegistrationState().name());
+            state.addProperty("provisioningState", stateful.getProvisioningState().name());
+            state.addProperty("storeState", stateful.getStoreState().name());
+            state.addProperty("currentVersion", stateful.getCurrentVersion());
+            state.addProperty("isRegistered", Boolean.toString(stateful.isRegistered()));
+            state.addProperty("needsApproval", Boolean.toString(stateful.needsApprove()));
+            state.addProperty("autoApprove", Boolean.toString(stateful.getAutoApprove()));
+            JsonArray artifactsFromShop = new JsonArray();
+            for (ArtifactObject a : stateful.getArtifactsFromShop()) {
+                artifactsFromShop.add(new JsonPrimitive(Workspace.getRepositoryObjectIdentity(a)));
+            }
+            state.add("artifactsFromShop", artifactsFromShop);
+            JsonArray artifactsFromDeployment = new JsonArray();
+            for (DeploymentArtifact a : stateful.getArtifactsFromDeployment()) {
+                artifactsFromDeployment.add(new JsonPrimitive(a.getUrl()));
+            }
+            state.add("artifactsFromDeployment", artifactsFromDeployment);
+            state.addProperty("lastInstallVersion", stateful.getLastInstallVersion());
+            state.addProperty("lastInstallSuccess", stateful.getLastInstallSuccess());
+            /* TODO auditEvents probably also needs paging and maybe filtering / searching
*/
+            /* TODO getLicenses/AssocationsWith might not be that helpful since the data
is also available in a different way */
+            /* TODO some of this tends to show up as attributes as well, so we will need
to do some filtering there */
+            /* TODO some aspects of the state can be manipulated as well, we need to supply
methods for that */
+            result.add("state", state);
+        }
         return result;
     }
 }
\ No newline at end of file

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=1152257&r1=1152256&r2=1152257&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 15:11:01 2011
@@ -48,13 +48,13 @@ import org.osgi.service.useradmin.User;
 import org.osgi.service.useradmin.UserAdmin;
 
 public class Workspace {
-    private static final String ARTIFACT = "artifact";
-    private static final String ARTIFACT2FEATURE = "artifact2feature";
-    private static final String FEATURE = "feature";
-    private static final String FEATURE2DISTRIBUTION = "feature2distribution";
-    private static final String DISTRIBUTION = "distribution";
-    private static final String DISTRIBUTION2TARGET = "distribution2target";
-    private static final String TARGET = "target";
+    static final String ARTIFACT = "artifact";
+    static final String ARTIFACT2FEATURE = "artifact2feature";
+    static final String FEATURE = "feature";
+    static final String FEATURE2DISTRIBUTION = "feature2distribution";
+    static final String DISTRIBUTION = "distribution";
+    static final String DISTRIBUTION2TARGET = "distribution2target";
+    static final String TARGET = "target";
     private final String m_sessionID;
     private final String m_repositoryURL;
     private final String m_obrURL;
@@ -158,7 +158,7 @@ public class Workspace {
         return result;
     }
     
-    public String getRepositoryObjectIdentity(RepositoryObject object) {
+    public static String getRepositoryObjectIdentity(RepositoryObject object) {
         if (object instanceof StatefulGatewayObject) {
             return ((StatefulGatewayObject) object).getGatewayObject().getAssociationFilter(null);
         }



Mime
View raw message