--Thanks
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 http://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.
Here is how we do it with faster jaxon
@Controller(value = "globalTemplateController")
@Path("/v1/globalTemplate")
@Produces({ MimeTypes.JSON })
public class GlobalTemplatesControllerV1Implextends AbstractRestController implementsGlobalTemplatesController {
private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory.getLogger(GlobalTemplatesControllerV1Impl.class);
@Autowired
private GlobalTemplateServiceglobalTemplateService;
private static String generateJSON(finalGlobalNavDocument globalNavDocument) {
final JsonFactory factory = new JsonFactory();
try(final StringWriter stringWriter = new StringWriter()) {
try (final JsonGenerator generator =factory.createGenerator(stringWriter)) {
generator.writeStartObject();
generator.writeArrayFieldStart("content");
generator.writeRaw(globalNavDocument.toJSON());
generator.writeEndArray();
generator.writeEndObject();
} catch (final IOException e) {
LOG.error(JSONHelper.CAUGHT_IO_EXCEPTION, e);
return StringUtils.EMPTY;
}
return stringWriter.toString();
} catch (final IOException e) {
LOG.error(JSONHelper.CAUGHT_IO_EXCEPTION, e);
return StringUtils.EMPTY;
}
}
@Override
@GET
@Path("/")
public @ResponseBody String getGlobalTemplate() {
final HstRequestContext hstContext = RequestContextProvider.get();
final GlobalNavDocument result =this.globalTemplateService.getGlobalTemplate(hstContext);
assert result != null : "did not get a result";
return generateJSON(result);
}
@XmlRootElement(name = "login")
@JsonRootName("login")
public class LoginRepresentation {
@XmlElement(name = "username-label")
@JsonProperty("username-label")
private String usernameLabel;
@XmlElement(name = "password-label")
@JsonProperty("password-label")
private String passwordLabel;
> <mailto:hippo-community+unsub...@googlegroups.com>.
> > <mailto:hippo-community+unsub...@googlegroups.com <javascript:>>.
> > Visit this group at http://groups.google.com/group/hippo-community
> <http://groups.google.com/group/hippo-community>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
> --
> w....@onehippo.com <javascript:> www.onehippo.com
> <http://www.onehippo.com>
> Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
> 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
> <mailto:hippo-community+unsub...@googlegroups.com>.
> <mailto:hippo-community+unsub...@googlegroups.com>.