RESTFUL JAX-RS JSON DATE SERIALIZATION FORMAT

915 views
Skip to first unread message

danie...@gmail.com

unread,
Nov 14, 2017, 11:14:08 AM11/14/17
to Hippo Community
Hello,

I am trying to change how documents serialize the JSON output for dates. Right now the dates are being serialized automatically to yyyy-MM-dd'T'HH:mm:ssZZ format, but I would like the dates to be serialized using epoch. I tried following this https://www.onehippo.org/library/concepts/rest/restful-jax-rs-json-date-serialization-format.html article as a guide, but adding in this code throws an error.

my error:
"Invocation of init method failed; nested exception is java.lang.NoSuchMethodException: com.fasterxml.jackson.databind.SerializationConfig.setDateFormat(java.text.SimpleDateFormat)"

Is there another way to change the date to epoch for documents in Hippo?


Thanks,
Daniel

Marijan Milicevic

unread,
Nov 14, 2017, 12:32:05 PM11/14/17
to hippo-c...@googlegroups.com
that method is removed indeed, you could try:
  <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <property name="targetObject" ref="jaxrsRestJacksonObjectMapper" />
    <property name="targetMethod" value="setDateFormat"/>
    <property name="arguments">
      <list>
        <bean class="java.text.SimpleDateFormat">
          <constructor-arg value="yyyy-MM-dd'T'HH:mm:ssZZ"/>
        </bean>
      </list>
    </property>
  </bean>
I'll create a documentation issue for it.

cheers
marijan


 


Thanks,
Daniel

--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-community@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.

danie...@gmail.com

unread,
Nov 14, 2017, 4:01:28 PM11/14/17
to Hippo Community
Hello Marijan,

That code update did seem to get rid of the error, but the addition of the code doesnt seem to have any impact on the date format of my documents when i view their JSON representation. Right now they are still using the same format no matter what format I set in the <constructor-arg value="yyyy-MM-dd"/> . Secondly, would you also be using this constructor-arg to pass in a request for epoch formatting?

On Tuesday, November 14, 2017 at 12:32:05 PM UTC-5, marijan milicevic wrote:



Thanks,
Daniel
To post to this group, send email to hippo-c...@googlegroups.com

RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.

danie...@gmail.com

unread,
Nov 22, 2017, 3:31:00 AM11/22/17
to Hippo Community
And just to provide more context around my question, my goal is to serialize using the automatic api Hippo provides for documents. That way all documents would be serialized automatically using the Date format I specify (epoch in this case).

I tried your recommended method but that didnt have any impact on the Dates returned in the json. I also tried overriding the "jaxrsRestJacksonObjectMapper" bean another way, but my changes to the setDateFormat seemed to also get ignored. Any thoughts on why the bean isnt being overridden properly?

myspringconfig.xml
<bean id="jaxrsRestJacksonObjectMapper" class="com.myclass.Tester">
    </bean>



overriding class (any value i pass into SimpleDateFormat has no impact on the output JSON serialization of my documents)
public class Tester extends ObjectMapper {

  public Tester() {
    this.setDateFormat(new SimpleDateFormat("MM-DD-YYYY"));
  }

  @Override
  public ObjectMapper setDateFormat(DateFormat dateFormat) {
    return super.setDateFormat(dateFormat);
  }
}


On Tuesday, November 14, 2017 at 12:32:05 PM UTC-5, marijan milicevic wrote:


Thanks,
Daniel
To post to this group, send email to hippo-c...@googlegroups.com

RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
Message has been deleted

Yaron Benjamin

unread,
Dec 10, 2017, 1:46:12 AM12/10/17
to Hippo Community
Hello Marijan,

Is there any way to configure the Date Format (Milliseconds since the EPOCH) for the default Content Rest API - the default date format seems to be  yyyy-MM-dd'T'HH:mm:ssZZ -- is there any way to modify this?  


Thank you,

Yaron

Bert Leunis

unread,
Dec 11, 2017, 3:11:07 AM12/11/17
to Hippo Community
On Sun, Dec 10, 2017 at 7:46 AM, Yaron Benjamin <yben...@gmail.com> wrote:
Hello Marijan,

Is there any way to configure the Date Format (Milliseconds since the EPOCH) for the default Content Rest API - the default date format seems to be  yyyy-MM-dd'T'HH:mm:ssZZ -- is there any way to modify this? 
Not at the moment. The string value of JCR Date fields is returned as is, from the nodes. I don't expect the output to be read by humans in sites or applications. An application can read the output and transform or format it for display or other purposes.
 
 


Thank you,

Yaron

--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-community@googlegroups.com

RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

Ard Schrijvers

unread,
Dec 11, 2017, 3:58:08 AM12/11/17
to hippo-c...@googlegroups.com
Hey Yaron,

On Mon, Dec 11, 2017 at 9:10 AM, Bert Leunis <bert....@bloomreach.com> wrote:
> On Sun, Dec 10, 2017 at 7:46 AM, Yaron Benjamin <yben...@gmail.com> wrote:
>>>>
>>>> Hello Marijan,
>>
>>
>> Is there any way to configure the Date Format (Milliseconds since the
>> EPOCH) for the default Content Rest API - the default date format seems to
>> be yyyy-MM-dd'T'HH:mm:ssZZ -- is there any way to modify this?

Although undocumented, this is possible.

The 'representation' of your content via the content rest api is done
via visitors, they can be found in the package
org.hippoecm.hst.restapi.content.visitors.

However, you can add in your end project your more specific visitors
(for example in the HST this is done with the ResourceBundleVisitor).

You can then for example add 'NewsDocumentVisitor' and annotate it
with PrimaryNodeTypeNodeVisitor, for example:

@PrimaryNodeTypeNodeVisitor
public class ResourceBundleVisitor extends HippoDocumentVisitor {

@Override
public String getNodeType() {
return myproject:newsdocument;
}

// custom visitNode code
}

Note the matching is done on primary type, not on a #isNodeType logic.

I am not really sure any more if this is all. Perhaps you need to add
the classpath for which your PrimaryNodeTypeNodeVisitor annotated
classes are scanned. If your PrimaryNodeTypeNodeVisitor annotated
visitor doesn't get picked up, this might be needed (I should test it
again, I can't recall and from scanning the code I am not sure any
more)

In your case, most likely you need to add a class something like:

@PrimaryNodeTypeNodeVisitor
public class MyHippoPublicationWorkflowDocumentVisitor extends
org.hippoecm.hst.restapi.content.visitors.HippoPublicationWorkflowDocumentVisitor
{

@Override
protected void addPropertyConditionally(final ResourceContext
context, final String name, final String value, final Map<String,
Object> response ) {
super.addPropertyConditionally(.....)
// DO you specific date stuff
}
}

Also see https://issues.onehippo.com/browse/HSTTWO-3565

HTH,

Regards Ard

>
> Not at the moment. The string value of JCR Date fields is returned as is,
> from the nodes. I don't expect the output to be read by humans in sites or
> applications. An application can read the output and transform or format it
> for display or other purposes.
>
>>
>>
>>
>>
>> https://www.onehippo.org/library/concepts/rest/restful-jax-rs-json-date-serialization-format.html
>> this link seems to reference the custom JAX-RS
>>
>> Thank you,
>>
>> Yaron
>>
>> --
>> Hippo Community Group: The place for all discussions and announcements
>> about Hippo CMS (and HST, repository etc. etc.)
>>
>> To post to this group, send email to hippo-c...@googlegroups.com
>> RSS:
>> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Hippo Community" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to hippo-communi...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/hippo-community.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> Hippo Community Group: The place for all discussions and announcements about
> Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-c...@googlegroups.com
> RSS:
> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups
> "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to hippo-communi...@googlegroups.com.
--
Hippo Netherlands, Oosteinde 11, 1017 WT Amsterdam, Netherlands
Hippo USA, Inc. 71 Summer Street, 2nd Floor Boston, MA 02110, United
states of America.

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

Woonsan Ko

unread,
Dec 15, 2017, 12:24:37 PM12/15/17
to hippo-c...@googlegroups.com
I think org.hippoecm.hst.restapi.content.visitors.AbstractNodeVisitor#getValueRepresentation(Value) should have handled date property in a better way.
At the moment, the method simply converts JCR date property value to string and pushes the value to the response object.
If it pushes a Calendar object instead (which should be an obvious choice since JCR returns Calendar object anyway), the ObjectMapper of Jackson2 could have serialized it to epoch number by default, with an option to change it by spring bean configuration to something like ISO8601 string.
Anyway, as it's hard-coded to convert Calendar to string by default, it's almost impossible or too hard to change it at the moment.
I would rather fix the logic of AbstractNodeVisitor#getValueRepresentation(Value) to put Calendar object, and let Jackson2 handle it in serialization.

Just my two cents,

Woonsan


>> To post to this group, send email to hippo-community@googlegroups.com

>> RSS:
>> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Hippo Community" group.
>> To unsubscribe from this group and stop receiving emails from it, send an

>> Visit this group at https://groups.google.com/group/hippo-community.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> Hippo Community Group: The place for all discussions and announcements about
> Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-community@googlegroups.com

> RSS:
> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups
> "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an
--
Hippo Netherlands, Oosteinde 11, 1017 WT Amsterdam, Netherlands
Hippo USA, Inc. 71 Summer Street, 2nd Floor Boston, MA 02110, United
states of America.

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com
--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)

To post to this group, send email to hippo-community@googlegroups.com

RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

Ard Schrijvers

unread,
Dec 18, 2017, 3:46:13 AM12/18/17
to hippo-c...@googlegroups.com
Hey Woonsan,

On Fri, Dec 15, 2017 at 6:24 PM, Woonsan Ko <woons...@bloomreach.com> wrote:
> I think
> org.hippoecm.hst.restapi.content.visitors.AbstractNodeVisitor#getValueRepresentation(Value)
> should have handled date property in a better way.
> At the moment, the method simply converts JCR date property value to string
> and pushes the value to the response object.
> If it pushes a Calendar object instead (which should be an obvious choice
> since JCR returns Calendar object anyway), the ObjectMapper of Jackson2
> could have serialized it to epoch number by default, with an option to
> change it by spring bean configuration to something like ISO8601 string.
> Anyway, as it's hard-coded to convert Calendar to string by default, it's
> almost impossible or too hard to change it at the moment.
> I would rather fix the logic of
> AbstractNodeVisitor#getValueRepresentation(Value) to put Calendar object,
> and let Jackson2 handle it in serialization.

I agree!

How shall we proceed with this? Just changing it might result in
undesired BC behavior for existing customers. Should we introduce an
option to switch to your described behavior? Or change it but
introduce a new API version (from the top of my head I don't know how
versioning of the api is currently done)

Regards Ard
>> >> To post to this group, send email to hippo-c...@googlegroups.com
>> >> RSS:
>> >>
>> >> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
>> >> ---
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "Hippo Community" group.
>> >> To unsubscribe from this group and stop receiving emails from it, send
>> >> an
>> >> email to hippo-communi...@googlegroups.com.
>> >> Visit this group at https://groups.google.com/group/hippo-community.
>> >> For more options, visit https://groups.google.com/d/optout.
>> >
>> >
>> > --
>> > Hippo Community Group: The place for all discussions and announcements
>> > about
>> > Hippo CMS (and HST, repository etc. etc.)
>> >
>> > To post to this group, send email to hippo-c...@googlegroups.com
>> > RSS:
>> >
>> > https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
>> > ---
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Hippo Community" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to hippo-communi...@googlegroups.com.
>> > Visit this group at https://groups.google.com/group/hippo-community.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>> Hippo Netherlands, Oosteinde 11, 1017 WT Amsterdam, Netherlands
>> Hippo USA, Inc. 71 Summer Street, 2nd Floor Boston, MA 02110, United
>> states of America.
>>
>> US +1 877 414 4776 (toll free)
>> Europe +31(0)20 522 4466
>> www.onehippo.com
>>
>> --
>> Hippo Community Group: The place for all discussions and announcements
>> about Hippo CMS (and HST, repository etc. etc.)
>>
>> To post to this group, send email to hippo-c...@googlegroups.com
>> RSS:
>> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Hippo Community" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to hippo-communi...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/hippo-community.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> Woonsan Ko
> woons...@bloomreach.com
> US +1 877 414 4776 (toll free)
> Europe +31(0)20 522 4466
>
>
> --
> Hippo Community Group: The place for all discussions and announcements about
> Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-c...@googlegroups.com
> RSS:
> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups
> "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to hippo-communi...@googlegroups.com.

Bert Leunis

unread,
Dec 18, 2017, 3:55:19 AM12/18/17
to Hippo Community
On Mon, Dec 18, 2017 at 9:46 AM, Ard Schrijvers <ard.sch...@bloomreach.com> wrote:
Hey Woonsan,

On Fri, Dec 15, 2017 at 6:24 PM, Woonsan Ko <woons...@bloomreach.com> wrote:
> I think
> org.hippoecm.hst.restapi.content.visitors.AbstractNodeVisitor#getValueRepresentation(Value)
> should have handled date property in a better way.
> At the moment, the method simply converts JCR date property value to string
> and pushes the value to the response object.
> If it pushes a Calendar object instead (which should be an obvious choice
> since JCR returns Calendar object anyway), the ObjectMapper of Jackson2
> could have serialized it to epoch number by default, with an option to
> change it by spring bean configuration to something like ISO8601 string.
> Anyway, as it's hard-coded to convert Calendar to string by default, it's
> almost impossible or too hard to change it at the moment.
> I would rather fix the logic of
> AbstractNodeVisitor#getValueRepresentation(Value) to put Calendar object,
> and let Jackson2 handle it in serialization.

I agree!

How shall we proceed with this? Just changing it might result in
undesired BC behavior for existing customers. Should we introduce an
option to switch to your described behavior? Or change it but
introduce a new  API version (from the top of my head I don't know how
versioning of the api is currently done)
Feel free to add extra insights there too.
 

Regards Ard
>> >> To post to this group, send email to hippo-community@googlegroups.com

>> >> RSS:
>> >>
>> >> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
>> >> ---
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "Hippo Community" group.
>> >> To unsubscribe from this group and stop receiving emails from it, send
>> >> an

>> >> Visit this group at https://groups.google.com/group/hippo-community.
>> >> For more options, visit https://groups.google.com/d/optout.
>> >
>> >
>> > --
>> > Hippo Community Group: The place for all discussions and announcements
>> > about
>> > Hippo CMS (and HST, repository etc. etc.)
>> >
>> > To post to this group, send email to hippo-community@googlegroups.com

>> > RSS:
>> >
>> > https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
>> > ---
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Hippo Community" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an

>> > Visit this group at https://groups.google.com/group/hippo-community.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>> Hippo Netherlands, Oosteinde 11, 1017 WT Amsterdam, Netherlands
>> Hippo USA, Inc. 71 Summer Street, 2nd Floor Boston, MA 02110, United
>> states of America.
>>
>> US +1 877 414 4776 (toll free)
>> Europe +31(0)20 522 4466
>> www.onehippo.com
>>
>> --
>> Hippo Community Group: The place for all discussions and announcements
>> about Hippo CMS (and HST, repository etc. etc.)
>>
>> To post to this group, send email to hippo-community@googlegroups.com

>> RSS:
>> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Hippo Community" group.
>> To unsubscribe from this group and stop receiving emails from it, send an

>> Visit this group at https://groups.google.com/group/hippo-community.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> Woonsan Ko
> woons...@bloomreach.com
> US +1 877 414 4776 (toll free)
> Europe +31(0)20 522 4466
>
>
> --
> Hippo Community Group: The place for all discussions and announcements about
> Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-community@googlegroups.com

> RSS:
> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups
> "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an

> Visit this group at https://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.



--
Hippo Netherlands, Oosteinde 11, 1017 WT Amsterdam, Netherlands
Hippo USA, Inc. 71 Summer Street, 2nd Floor Boston, MA 02110, United
states of America.

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)

To post to this group, send email to hippo-community@googlegroups.com

RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

Woonsan Ko

unread,
Dec 18, 2017, 8:36:32 PM12/18/17
to hippo-c...@googlegroups.com
I think you can put Calendar object without converting to string in the class.
And afterward, you should set a feature in ObjectMapper to serialize date value to ISO8601 by default through spring config. Then people may optionally choose to remove the ISO8601 serializing option in their project.
I don’t expect any backward incompatibility issue.

Regards,

Woonsan

Sent from my iPhone
To post to this group, send email to hippo-c...@googlegroups.com

RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.

Ard Schrijvers

unread,
Dec 19, 2017, 11:12:21 AM12/19/17
to hippo-c...@googlegroups.com
On Tue, Dec 19, 2017 at 2:36 AM, Woonsan Ko <woons...@bloomreach.com> wrote:
> I think you can put Calendar object without converting to string in the
> class.
> And afterward, you should set a feature in ObjectMapper to serialize date
> value to ISO8601 by default through spring config. Then people may
> optionally choose to remove the ISO8601 serializing option in their project.
> I don’t expect any backward incompatibility issue.

Ah that is a good idea! You mean to serialize by default in the format
we already had.

Can you make an issue for this or do you want to pick this up?

Regards Ard
>> >> --
>> >> Hippo Netherlands, Oosteinde 11, 1017 WT Amsterdam, Netherlands
>> >> Hippo USA, Inc. 71 Summer Street, 2nd Floor Boston, MA 02110, United
>> >> states of America.
>> >>
>> >> US +1 877 414 4776 (toll free)
>> >> Europe +31(0)20 522 4466
>> >> www.onehippo.com
>> >>
>> >> --
>> >> Hippo Community Group: The place for all discussions and announcements
>> >> about Hippo CMS (and HST, repository etc. etc.)
>> >>
>> >> To post to this group, send email to hippo-c...@googlegroups.com
>> >> RSS:
>> >>
>> >> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
>> >> ---
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "Hippo Community" group.
>> >> To unsubscribe from this group and stop receiving emails from it, send
>> >> an
>> >> email to hippo-communi...@googlegroups.com.
>> >> Visit this group at https://groups.google.com/group/hippo-community.
>> >> For more options, visit https://groups.google.com/d/optout.
>> >
>> >
>> >
>> >
>> > --
>> > Woonsan Ko
>> > woons...@bloomreach.com
>> > US +1 877 414 4776 (toll free)
>> > Europe +31(0)20 522 4466
>> >
>> >
>> > --
>> > Hippo Community Group: The place for all discussions and announcements
>> > about
>> > Hippo CMS (and HST, repository etc. etc.)
>> >
>> > To post to this group, send email to hippo-c...@googlegroups.com
>> > RSS:
>> >
>> > https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
>> > ---
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Hippo Community" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to hippo-communi...@googlegroups.com.
>> > Visit this group at https://groups.google.com/group/hippo-community.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>> Hippo Netherlands, Oosteinde 11, 1017 WT Amsterdam, Netherlands
>> Hippo USA, Inc. 71 Summer Street, 2nd Floor Boston, MA 02110, United
>> states of America.
>>
>> US +1 877 414 4776 (toll free)
>> Europe +31(0)20 522 4466
>> www.onehippo.com
>>
>> --
>> Hippo Community Group: The place for all discussions and announcements
>> about Hippo CMS (and HST, repository etc. etc.)
>>

Yaron Benjamin

unread,
Dec 20, 2017, 9:10:31 AM12/20/17
to Hippo Community
Hey Guys,

That would be awesome if it was in the build! How long does it normally take to get these types of enhancements?  It sounds like it would not be advantages to try to extend HippoDocumentVisitor as modifying 

AbstractNodeVisitor.getValueRepresentation() could be 


 default:

                // Date is rendered by JackRabbit including timezone, no need for special handling

                return jcrValue.getDate();



instead of 

default:

                // Date is rendered by JackRabbit including timezone, no need for special handling

                return jcrValue.getString();



(I am simplifying a little here :)  )

Woonsan Ko

unread,
Dec 20, 2017, 2:40:57 PM12/20/17
to hippo-c...@googlegroups.com


> On Dec 19, 2017, at 11:12 AM, Ard Schrijvers <ard.sch...@bloomreach.com> wrote:
>
>> On Tue, Dec 19, 2017 at 2:36 AM, Woonsan Ko <woons...@bloomreach.com> wrote:
>> I think you can put Calendar object without converting to string in the
>> class.
>> And afterward, you should set a feature in ObjectMapper to serialize date
>> value to ISO8601 by default through spring config. Then people may
>> optionally choose to remove the ISO8601 serializing option in their project.
>> I don’t expect any backward incompatibility issue.
>
> Ah that is a good idea! You mean to serialize by default in the format
> we already had.
>
> Can you make an issue for this or do you want to pick this up?

I think Bert already created an issue. I hope Engineering take the issue. I haven’t used the generic content service often myself (personally in favor of content Hal api, an enterprise plugin) and I’m on holidays. :-)

Woonsan

Ard Schrijvers

unread,
Dec 21, 2017, 4:02:07 AM12/21/17
to hippo-c...@googlegroups.com
Hey Yaron,

hard to say when it gets picked up in general. If something is a bug,
in general quite fast. If it is a (minor) improvement, it is hard to
say

Regards Ard

Yaron Benjamin

unread,
Dec 26, 2017, 9:44:47 AM12/26/17
to Hippo Community
Sounds good thanks guys!  It sounds like it could potentially be a while before this is added into a build - is there a recommendation or preferred path forward in the meantime?  

could I override the HippoDocumentVisitor class; would you see any issues with this for the short term?

Thank you,

Yaron Benjamin

unread,
Dec 26, 2017, 4:03:07 PM12/26/17
to Hippo Community
For the short team - I modified the following -- Ard and Woonsan please let me know if you absolutely hate this for a quick fix until it gets put into HST2 V. 6.0.0  :) 


HippoPublicationWorkflowDocumentVisitor

 response.put("pubwfCreationDate", node.getProperty(HIPPOSTDPUBWF_CREATION_DATE).getDate().getTimeInMillis());

        response.put("pubwfLastModificationDate", node.getProperty(HIPPOSTDPUBWF_LAST_MODIFIED_DATE).getDate().getTimeInMillis());

        if (node.hasProperty(HIPPOSTDPUBWF_PUBLICATION_DATE)) {

            response.put("pubwfPublicationDate", node.getProperty(HIPPOSTDPUBWF_PUBLICATION_DATE).getDate().getTimeInMillis());

        }


Then on  AbstractNodeVisitor

protected Object getValueRepresentation(final Value jcrValue) throws RepositoryException {

        switch (jcrValue.getType()) {

            case BINARY:

                return "Retrieving the content of binary property values is not yet supported in the Content REST API. Use images and assets instead.";

            case LONG:

                return jcrValue.getLong();

            case DOUBLE:

                return jcrValue.getDouble();

            case BOOLEAN:

                return jcrValue.getBoolean();

            case DECIMAL:

                return jcrValue.getDecimal();

            case DATE:

             return jcrValue.getDate().getTimeInMillis();

            default:

                // Date is rendered by JackRabbit including timezone, no need for special handling

                return jcrValue.getString();

        }


...And finally...


protected void visitProperties(final ResourceContext context, final Node node, final Map<String, Object> response)

            throws RepositoryException {

        for (Property property : new PropertyIterable(node.getProperties())) {

            final ContentType parentContentType = context.getContentTypes().getContentTypeForNode(property.getParent());

            final ContentTypeProperty propertyType = parentContentType.getProperties().get(property.getName());


            if (propertyType != null                                  // explicit and non-residual property type

                    && !propertyType.isDerivedItem()                  // defined in a (inherited) document type

                    && !skipProperty(context, propertyType, property)

                    || property.getType() ==5 // not marked to be skipped

            ) {

                visitProperty(context, propertyType, property, response);

Ard Schrijvers

unread,
Jan 2, 2018, 3:44:56 AM1/2/18
to hippo-c...@googlegroups.com
Hey Yaron,

seems like a valid approach. Obviously forking comes with a risk. Make
sure that once we support it in the product that you get rid of your
fork

Regards Ard
Reply all
Reply to author
Forward
0 new messages