qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1581526 - in /qpid/branches/0.28/qpid: ./ java/ java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java
Date Tue, 25 Mar 2014 21:18:47 GMT
Author: rgodfrey
Date: Tue Mar 25 21:18:47 2014
New Revision: 1581526

URL: http://svn.apache.org/r1581526
Log:
merged bugfix r1580560 from trunk

Modified:
    qpid/branches/0.28/qpid/   (props changed)
    qpid/branches/0.28/qpid/java/   (props changed)
    qpid/branches/0.28/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java

Propchange: qpid/branches/0.28/qpid/
------------------------------------------------------------------------------
  Merged /qpid/trunk/qpid:r1580560

Propchange: qpid/branches/0.28/qpid/java/
------------------------------------------------------------------------------
  Merged /qpid/trunk/qpid/java:r1580560

Modified: qpid/branches/0.28/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.28/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java?rev=1581526&r1=1581525&r2=1581526&view=diff
==============================================================================
--- qpid/branches/0.28/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java
(original)
+++ qpid/branches/0.28/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java
Tue Mar 25 21:18:47 2014
@@ -38,10 +38,17 @@ import java.util.UUID;
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.Model;
 import org.apache.qpid.server.model.VirtualHost;
+import org.codehaus.jackson.JsonGenerator;
 import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.Version;
 import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.Module;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.SerializerProvider;
+import org.codehaus.jackson.map.module.SimpleModule;
 
 public class JsonFileConfigStore implements DurableConfigurationStore
 {
@@ -61,8 +68,30 @@ public class JsonFileConfigStore impleme
     private String _backupFileName;
     private int _configVersion;
 
+    private static final Module _module;
+    static
+    {
+        SimpleModule module= new SimpleModule("ConfiguredObjectSerializer", new Version(1,0,0,null));
+
+        final JsonSerializer<ConfiguredObject> serializer = new JsonSerializer<ConfiguredObject>()
+        {
+            @Override
+            public void serialize(final ConfiguredObject value,
+                                  final JsonGenerator jgen,
+                                  final SerializerProvider provider)
+                    throws IOException, JsonProcessingException
+            {
+                jgen.writeString(value.getId().toString());
+            }
+        };
+        module.addSerializer(ConfiguredObject.class, serializer);
+
+        _module = module;
+    }
+
     public JsonFileConfigStore()
     {
+        _objectMapper.registerModule(_module);
         _objectMapper.enable(SerializationConfig.Feature.INDENT_OUTPUT);
     }
 
@@ -414,7 +443,17 @@ public class JsonFileConfigStore impleme
                     {
                         ConfiguredObjectRecord childRecord = _objectsById.get(childId);
                         final String parentArg = type.getSimpleName().toLowerCase();
-                        if(id.toString().equals(String.valueOf(childRecord.getAttributes().get(parentArg))))
+                        final Object parent = childRecord.getAttributes().get(parentArg);
+                        String parentId;
+                        if(parent instanceof ConfiguredObject)
+                        {
+                            parentId = ((ConfiguredObject)parent).getId().toString();
+                        }
+                        else
+                        {
+                            parentId = String.valueOf(parent);
+                        }
+                        if(id.toString().equals(parentId))
                         {
                             entities.add(build(childClass,childId));
                         }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message