REST URL for standard image and REST Resource

146 views
Skip to first unread message

Amal Saha

unread,
Feb 12, 2016, 7:33:34 AM2/12/16
to Hippo Community
Hello,

I am trying to get and also upload images thru REST API and the gallery is standard location, i.e., /content/gallery/myhippoproject. 
The REST mount point is 'restapi' and the servlet context is 'site'. 

I can get an image stored there as abc.jpg as 
http://localhost:9080/site/binaries/content/gallery/myhippoproject/abc.jpg using a browser and there is no problem with the interactive
retrieval of image thru browser.

Now I want to get the same image using REST API. I have configured Java class org.hippoecm.hst.jaxrs.services.content.ImageSetContentResource in file spring-plain-rest-api.xml and the path in that class is "/hippogallery:imageset/". Therefore I constructed the REST URL http://localhost:9080/site/restapi/hippogallery:imageset/original and trying to get representation of original image from the imageset node, but I get the error:

[BaseImageSetContentResource.getImageResource:128] Failed to retrieve content bean. org.hippoecm.hst.content.beans.ObjectBeanManagerException: Cannot return bean of type 'interface org.hippoecm.hst.content.beans.standard.HippoGalleryImageSetBean'



The web service is hit and but the error seems to be due to incorrect URL - it appears that it cannot find the standard gallery folder location. 



Question1: 

Given my REST mount point 'restapi' and servlet context 'site', what is the correct REST URL for retrieving original image in an imageset content in standard location, /content/gallery/myhippoproject ? 




Question2: 

I also want to upload image from a file using REST API. Given my REST mount point 'restapi' and servlet context 'site', what is the correct REST URL for uploading the original image from a file abc.jpg, to an imageset content in standard location, /content/gallery/myhippoproject ? 





Thanking you in advance. 


Thanks and Regards,

Amal



Amal Saha

unread,
Feb 15, 2016, 3:21:51 AM2/15/16
to hippo-c...@googlegroups.com

siteContentBasePath of HstRequestContext is automatically set "content/documents/myhippoproject" rather than "content/gallery/myhippoproject". That seems to the root cause. 


How do we override this? 








Thanks and Regards,
Amal     

Amal Saha
CTO, Cratuz Technology,
Plot # 475, Udyog Vihar, Phase-V,
Gurgaon, Haryana, INDIA 
Mobile: +91-9818004327, Office Phone: +91-124-4003508 
Email: amal...@cratuz.com , Web Site: cratuz.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 a topic in the Google Groups "Hippo Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hippo-community/ygjeEmCEsUI/unsubscribe.
To unsubscribe from this group and all its topics, 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.

Oscar Scholten

unread,
Feb 16, 2016, 7:02:39 AM2/16/16
to hippo-c...@googlegroups.com
Hi Amal,

You can configure the content root of a site as part of the HST configuration model. See [1]. You can edit this configuration in a running system using the Hippo CMS Console [2].

Let me know if this solves your problem!

Cheers, Oscar


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.



--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 745 Atlantic Ave, 8th Floor, MA 02111

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

Amal Saha

unread,
Feb 16, 2016, 9:07:47 AM2/16/16
to hippo-c...@googlegroups.com
Hi Oscar,

Thanks for your suggestion. Based on your suggestion, I edited 
value of hst:content of /hst:hst/hst:sites/myhippoproject to /content/gallery/myhippoproject. With this, I get requestContext.getSiteContentBasePath()=content/gallery/myhippoproject and this is a step forward for me.

This also means that the content root folder is NOT the root case of the original problem, although initially I thought it was.

Now I get the following error message 

Failed to retrieve content bean. org.hippoecm.hst.content.beans.ObjectBeanManagerException: Cannot return bean of type 'interface org.hippoecm.hst.content.beans.standard.HippoGalleryImageSetBean'


and  my code in REST web service method is quite simple: 


@GET

@Path("/getImageset")  

public HippoGalleryImageSetRepresentation getImageSetResource2(@Context HttpServletRequest servletRequest,   @Context HttpServletResponse servletResponse, @Context UriInfo uriInfo

{

        return super.getImageSetResource(servletRequest, servletResponse, uriInfo); 

 }






The problems that I face:

1.  I am unable to retrieve the imageset data in standard imageset folder, content/gallery/myhippoproject,  thru this web service.  

2. My second objective is to upload image, into standard imageset folder content/gallery/myhippoproject, using standard REST web service method BaseImageSetContentResource.updateImageResourceContent(), but I get stuck because of mapping issues mentioned above.  


​I would appreciate any clue from you. ​



Thanks and Regards,
Amal     

Amal Saha
CTO, Cratuz Technology,
Plot # 475, Udyog Vihar, Phase-V,
Gurgaon, Haryana, INDIA 
Mobile: +91-9818004327, Office Phone: +91-124-4003508 
Email: amal...@cratuz.com , Web Site: cratuz.com  

Amal Saha

unread,
Feb 16, 2016, 9:15:46 AM2/16/16
to hippo-c...@googlegroups.com

​It may be noted that my web service class extends ​
org.hippoecm.hst.jaxrs.services.content
​.​
BaseImageSetContentResource
​. 


------



On Tue, Feb 16, 2016 at 7:37 PM, Amal Saha <amal...@cratuz.com> wrote:
BaseImageSetContentResource


Oscar Scholten

unread,
Feb 17, 2016, 6:31:56 AM2/17/16
to hippo-c...@googlegroups.com
Hi Amal,

Let's first focus on retrieving the image set. As part of our test suite there is a running example of a REST API exposing both documents and imagesets. Have a look at [1], which is the tag of the test suite which was set when we released 10.2.0.

After you export, build (with -DskipTests or a lot of tests will fire) and run this, you will find near the bottom of the home page a few example links to specific variants of an imageset. Look for "Dummy example REST links". An example link:


A few notes:
  • You should not have to compose these links yourself if you are using the HST, these links are rendered in following file: resources/src/main/webapp/WEB-INF/jsp/components/main/home.jsp:40
  • The hst:link tag specifies the mount that should be used to render the link
  • In the console there are a few sub mounts under the /restapi mount

Hope this helps, Oscar


--
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.

Amal Saha

unread,
Feb 17, 2016, 6:50:21 AM2/17/16
to hippo-c...@googlegroups.com
Hi Oscar,

Thank you very much. The issue has been resolved. 

The mistake that I had made was that I treated the REST Web Service as "plain". When I treated them as "content-aware", the issue was resolved.  I had to change the REST URL accordingly. 



Thanks and Regards,
Amal     



You received this message because you are subscribed to a topic in the Google Groups "Hippo Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hippo-community/ygjeEmCEsUI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hippo-communi...@googlegroups.com.

oussaief...@gmail.com

unread,
Dec 27, 2017, 11:40:24 AM12/27/17
to Hippo Community
Hi,


Can you help me please,

When I try to show an image in browser via the URL 


, the following error is displayed.

Page not found!!!

The page you requested was not found in this site.

Reply all
Reply to author
Forward
0 new messages