I'm a new bee to Hippo CMS. I'm working on version 10 and I'm using angularJS service to consume the rest url for "banners" I created through HippoCms.
This is my Rest URL for Banners created via Hippo's Rest Api Manager:
http://localhost:8080/site/stbetrest/Banner?_type=json
and the reponse I'm getting when consumed the link is:
{
"pageSize": 10,
"total": 3,
"items": [
{
"content": "<![CDATA[\r\n\r\n <p>Banner description</p>\r\n\r\n \r\n]]>",
"title": "Sample banner"
},
{
"content": "<![CDATA[<p>10 Simple Steps to Green Your Office:</p>\n\n<p> </p>\n\n<p>
<img src=\"/site/pagenotfound\" /></p>]]>",
"title": "10 Simple Steps to Green Your Office"
},
{
"content": "<![CDATA[<p>How to Green Your Dorm Room</p>]]>",
"title": "How to Green Your Dorm Room"
}
],
"currentPage": 1,
"totalPages": 1
}
The Problem here is I can't see the Images I used inside the banner documents in Hippo. I want to get those Images/links to load them into a carousel created in AngularJs. Please guide me how to generate the images also into the above banner response.
UPDATE:
All though via the 'localhost:8080/cms' it shows uploaded images, but can not access the image via response:
@XmlRootElement(name = "banner")
@XmlAccessorType(XmlAccessType.NONE)
@HippoEssentialsGenerated(internalName = "gogreen:bannerdocument")
@Node(jcrType = "gogreen:bannerdocument")
public class Banner extends BaseDocument {
@XmlElement
@HippoEssentialsGenerated(internalName = "gogreen:title")
public String getTitle() {
return getProperty("gogreen:title");
}
@XmlJavaTypeAdapter(HippoHtmlAdapter.class)
@XmlElement
@HippoEssentialsGenerated(internalName = "gogreen:content")
public HippoHtml getContent() {
return getHippoHtml("gogreen:content");
}
@HippoEssentialsGenerated(internalName = "gogreen:link")
public HippoBean getLink() {
return getLinkedBean("gogreen:link", HippoBean.class);
}
@XmlJavaTypeAdapter(KerkRestAdapter.class)
@XmlElement
@HippoEssentialsGenerated(internalName = "gogreen:image")
public Kerk getImage() {
return getLinkedBean("gogreen:image", Kerk.class);
}
}
and my Content rewriter is :
public class RestContentRewriter extends SimpleContentRewriter {
@Override
protected String rewriteBinaryLink(String binaryLinkSrc, Node node, HstRequestContext requestContext, Mount targetMount) {
return super.rewriteBinaryLink(binaryLinkSrc, node, requestContext, requestContext.getMount("site"));
}
And My Adapter is:
public class KerkRestAdapter extends XmlAdapter<String, HippoHtml> {
@Override
public HippoHtml unmarshal(String representation) throws Exception {
throw new UnsupportedOperationException("Unmarshalling not implemented.");
}
@Override
public String marshal(HippoHtml html) throws Exception {
if (html == null) {
return null;
}
final HstRequestContext context = RequestContextProvider.get();
//final RestContentRewriter contentRewriter = new RestContentRewriter();
final ContentReWriter<String> contentRewriter = new RestContentRewriter();
final String rewrite = contentRewriter.rewrite(html.getContent(), html.getNode(), context, context.getMount("api"));
return "<![CDATA[" + rewrite + "]]>";
}
}
additional Question: what is the mount point to be used in rewriter? ( Rest mount name or gogreen??)
Please help !