Re: SDK-CSP, API and Chat service migration to XDI2-0.7.4

7 views
Skip to first unread message

Markus Sabadello

unread,
Aug 20, 2015, 5:05:10 AM8/20/15
to xd...@googlegroups.com, Kapil Vats, Les Chasen, Ning Zhang
Hey,

I'm sorry I don't really know much about how Jackson works internally.

It looks like it's trying to call the XDIAddress.getContextNodeXDIAddress() method, which may return only the XDIAddress itself, so that's a loop (intentional).

Maybe somehow you can instruct Jackson to exclude this method call.

Why would you want to serialize the internal structure of a cloud number to JSON anyway?

Is it not enough to have this?
{ "cloud_number": "[=]!:uuid:f0b586a2-6324-469e-9f6f-9a65769284b3" }

Of course in release-0.7.4 it should be this:
{ "cloud_number": "=!:uuid:f0b586a2-6324-469e-9f6f-9a65769284b3" }

Markus


On Thu, Aug 20, 2015 at 9:26 AM, Ning Zhang <ni...@respectnetwork.net> wrote:
Markus,

With 0.7.4, it seems that the CloudNumber object can no longer be serialized as json string.

For example, the following exception will be thrown:

07:05:35.138 [http-nio-8080-exec-9] ERROR b.n.c.p.m.ProxyBaseObject - toString() failed - Direct self-reference leading to cycle (through reference chain: biz.neustar.clouds.proxy.service.DependentData["cloud_number"]->xdi2.core.syntax.CloudNumber["peer_root_xdiarc"]->xdi2.core.syntax.XDIArc["xref"]->xdi2.core.syntax.XDIXRef["xdiaddress"]->xdi2.core.syntax.XDIAddress["context_node_xdiaddress"])
com.fasterxml.jackson.databind.JsonMappingException: Direct self-reference leading to cycle (through reference chain: biz.neustar.clouds.proxy.service.DependentData["cloud_number"]->xdi2.core.syntax.CloudNumber["peer_root_xdiarc"]->xdi2.core.syntax.XDIArc["xref"]->xdi2.core.syntax.XDIXRef["xdiaddress"]->xdi2.core.syntax.XDIAddress["context_node_xdiaddress"])
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter._handleSelfReference(BeanPropertyWriter.java:740) ~[jackson-databind-2.3.4.jar!/:2.3.4]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:537) ~[jackson-databind-2.3.4.jar!/:2.3.4]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:644) ~[jackson-databi


with 0.6, it can serialized such as the following. I am wondering how to get jackson work again.

Thanks,
-Ning


  "cloud_number" : {
    "xri" : {
      "sub_segments" : [ {
        "cs" : "=",
        "class_xs" : true,
        "attribute_xs" : false,
        "literal" : null,
        "xref" : null
      }, {
        "cs" : "!",
        "class_xs" : false,
        "attribute_xs" : false,
        "literal" : ":uuid:f0b586a2-6324-469e-9f6f-9a65769284b3",
        "xref" : null
      } ],
      "num_sub_segments" : 2,
      "first_sub_segment" : {
        "cs" : "=",
        "class_xs" : true,
        "attribute_xs" : false,
        "literal" : null,
        "xref" : null
      },
      "last_sub_segment" : {
        "cs" : "!",
        "class_xs" : false,
        "attribute_xs" : false,
        "literal" : ":uuid:f0b586a2-6324-469e-9f6f-9a65769284b3",
        "xref" : null
      }
    },
    "peer_root_xri" : {
      "cs" : null,
      "class_xs" : false,
      "attribute_xs" : false,
      "literal" : null,
      "xref" : {
        "xs" : "()",
        "segment" : {
          "sub_segments" : [ {
            "cs" : "=",
            "class_xs" : true,
            "attribute_xs" : false,
            "literal" : null,
            "xref" : null
          }, {
            "cs" : "!",
            "class_xs" : false,
            "attribute_xs" : false,
            "literal" : ":uuid:f0b586a2-6324-469e-9f6f-9a65769284b3",
            "xref" : null
          } ],
          "num_sub_segments" : 2,
          "first_sub_segment" : {
            "cs" : "=",
            "class_xs" : true,
            "attribute_xs" : false,
            "literal" : null,
            "xref" : null
          },
          "last_sub_segment" : {
            "cs" : "!",
            "class_xs" : false,
            "attribute_xs" : false,
            "literal" : ":uuid:f0b586a2-6324-469e-9f6f-9a65769284b3",
            "xref" : null
          }
        },
        "partial_subject" : null,
        "partial_predicate" : null,
        "iri" : null,
        "literal" : null,
        "empty" : false,
        "value" : "[=]!:uuid:f0b586a2-6324-469e-9f6f-9a65769284b3"
      }
    },
    "cs" : "="
  },




On Wed, Aug 19, 2015 at 5:02 AM, Markus Sabadello <mar...@respectnetwork.net> wrote:
Hello Kapil,

You can use this code:

List<CloudName> cloudNames = new ArrayList<CloudName> ();

for (Relation relation : relations) {
    cloudNames.add(CloudName.fromPeerRootXDIArc(r.getTargetXDIAddress()));
}

Markus


On Tue, Aug 18, 2015 at 5:41 PM, Kapil Vats <ka...@respectnetwork.net> wrote:
Hi Les,

Yesterday I was able to Register and able to login to personal cloud using after code migrated to XDI2 version-0.7.4.
Today I updated the Chat code to support XDI2 version-0.7.4. To test Chat service I have to create Dependent clouds, but was not able to.

Provided fix for Dependent cloud registration but while fetching back dependent cloud facing issue, which blocked me to test chat service.

ERROR [2015-08-18 11:15:56,485] io.dropwizard.jersey.errors.LoggingExceptionMapper: Error handling a request: 53d82ef2854fe7c8
! xdi2.core.exceptions.Xdi2RuntimeException: Invalid cloud name: (=kapil.sirqul.chd2)
! at xdi2.core.syntax.CloudName.fromXDIAddress(CloudName.java:79) ~[personal-cloud-service-application-1.0.jar:1.0]
! at xdi2.core.util.iterators.MappingCloudNameIterator.map(MappingCloudNameIterator.java:23) ~[personal-cloud-service-application-1.0.jar:1.0]
! at xdi2.core.util.iterators.MappingCloudNameIterator.map(MappingCloudNameIterator.java:13) ~[personal-cloud-service-application-1.0.jar:1.0]
! at xdi2.core.util.iterators.MappingIterator.next(MappingIterator.java:28) ~[personal-cloud-service-application-1.0.jar:1.0]
! at xdi2.core.util.iterators.SelectingIterator.lookahead(SelectingIterator.java:28) ~[personal-cloud-service-application-1.0.jar:1.0]
! at xdi2.core.util.iterators.SelectingIterator.<init>(SelectingIterator.java:18) ~[personal-cloud-service-application-1.0.jar:1.0]
! at xdi2.core.util.iterators.NotNullIterator.<init>(NotNullIterator.java:14) ~[personal-cloud-service-application-1.0.jar:1.0]
! at net.respectnetwork.sdk.csp.BasicCSP.checkCloudNamesInCSP(BasicCSP.java:836) ~[personal-cloud-service-application-1.0.jar:1.0]

Code in red color below is where this error occurred.

ContextNode cotextNode = messageResult.getGraph().getDeepContextNode(XDIAddress.fromComponent(cloudNumber.getPeerRootXDIArc()));
  ReadOnlyIterator<Relation> relations = cotextNode == null ? null : cotextNode.getRelations(XDIDictionaryConstants.XDI_ADD_IS_REF);

  CloudName[] cloudNames = new IteratorArrayMaker<CloudName> (
    new NotNullIterator<CloudName> (
      new MappingCloudNameIterator(
        new MappingRelationTargetXDIAddressIterator(relations)
        ))).array(CloudName.class);


Would appreciate Markus help here.

Thanks,
Kapil



Reply all
Reply to author
Forward
0 new messages