Get bean by name of the document

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Get bean by name of the document

chaga
Hello,
I am using spring Rest template to extract the data from hippo using plain JAX-RS Services and displaying this data in the frontend using the rest client.

I am passing the name of the document as the parameter and would like to get the corresponding bean for this document.

Could you tell me how can I get the bean by name of the document added in the repository.

Thanks

Cdt,
Chandan AGARWAL
IED
Smile Benelux
Brussels
Mb - (+32) 0492101358


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Get bean by name of the document

Jeroen Reijn
Administrator
Could you perhaps explain what you have tried?
What bean are you trying to get? A document of a child node?

Jeroen

On Tue, Sep 25, 2012 at 8:01 PM, Chandan AGARWAL
<[hidden email]> wrote:

> Hello,
> I am using spring Rest template to extract the data from hippo using plain
> JAX-RS Services and displaying this data in the frontend using the rest
> client.
>
> I am passing the name of the document as the parameter and would like to get
> the corresponding bean for this document.
>
> Could you tell me how can I get the bean by name of the document added in
> the repository.
>
> Thanks
>
> Cdt,
> Chandan AGARWAL
> IED
> Smile Benelux
> Brussels
> Mb - (+32) 0492101358
>
>
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--
Jeroen Reijn
Solution Architect
Hippo

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

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

http://about.me/jeroenreijn
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Get bean by name of the document

chaga
Hi Jeroen,
Here is the code snippet of my code :

@Path("/contentBlocks/")
public class ContentBlockResource extends AbstractContentResource {

@GET
    @Path("/{documentName}")
    @Produces("text/xml")
    public ContentBlockRepresentation getContentBlockByName(@Context HttpServletRequest servletRequest,
            @Context HttpServletResponse servletResponse, @PathParam("documentName") String documentName) {

        ContentBlockRepresentation contentBlockRepresentation = new ContentBlockRepresentation();

        HstRequestContext requestContext = getRequestContext(servletRequest);


// I need to get the bean by the document name passed in the pathParam variable here and then map it as a contentBlockRepresentation object and return it back to the client
      

        return contentBlockRepresentation;
    }
 
  }

@XmlRootElement(name = "contentBlock")
public class ContentBlockRepresentation {

    private String title;
    private String description;
    private ImageRepresentation image;

    public ContentBlockRepresentation() {
    }

    public ContentBlockRepresentation(String title, String description, ImageRepresentation image) {
        this.title = title;
        this.description = description;
        this.image = image;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @XmlElement(name = "image")
    public ImageRepresentation getImage() {
        return image;
    }

    public void setImage(ImageRepresentation image) {
        this.image = image;
    }

}

As you see I am passing the name of the document that i want as a pathParam . For eg I have created a file called "quickaccess" of document type ContentBlock in the cms inside the folder cullen.
When i call my class from the rest client with the url contentBlocks/quickaccess , I want to get the corresponding bean of quickaccess, which I would convert to my object ContentBlockRepresentation and send it back.

So, my question is how can i get the bean by the name of the document ?


Cdt,
Chandan AGARWAL
IED
Smile Benelux
Brussels
Mb - (+32) 0492101358


From: "Jeroen Reijn" <[hidden email]>
To: "Hippo CMS 7 implementation list" <[hidden email]>
Sent: Wednesday, September 26, 2012 9:59:38 AM
Subject: Re: [Hippo-cms7-user] Get bean by name of the document

Could you perhaps explain what you have tried?
What bean are you trying to get? A document of a child node?

Jeroen

On Tue, Sep 25, 2012 at 8:01 PM, Chandan AGARWAL
<[hidden email]> wrote:

> Hello,
> I am using spring Rest template to extract the data from hippo using plain
> JAX-RS Services and displaying this data in the frontend using the rest
> client.
>
> I am passing the name of the document as the parameter and would like to get
> the corresponding bean for this document.
>
> Could you tell me how can I get the bean by name of the document added in
> the repository.
>
> Thanks
>
> Cdt,
> Chandan AGARWAL
> IED
> Smile Benelux
> Brussels
> Mb - (+32) 0492101358
>
>
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--
Jeroen Reijn
Solution Architect
Hippo

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

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

http://about.me/jeroenreijn
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Get bean by name of the document

chaga
I guess no one saw my reply... can anyone help me with my problem stated my previous reply...I am blocked because of this problem.

Thanks in advance

Cdt,
Chandan AGARWAL
IED
Smile Benelux
Brussels
Mb - (+32) 0492101358


From: "Chandan AGARWAL" <[hidden email]>
To: "Hippo CMS 7 implementation list" <[hidden email]>
Sent: Wednesday, September 26, 2012 10:27:22 AM
Subject: Re: [Hippo-cms7-user] Get bean by name of the document

Hi Jeroen,
Here is the code snippet of my code :

@Path("/contentBlocks/")
public class ContentBlockResource extends AbstractContentResource {

@GET
    @Path("/{documentName}")
    @Produces("text/xml")
    public ContentBlockRepresentation getContentBlockByName(@Context HttpServletRequest servletRequest,
            @Context HttpServletResponse servletResponse, @PathParam("documentName") String documentName) {

        ContentBlockRepresentation contentBlockRepresentation = new ContentBlockRepresentation();

        HstRequestContext requestContext = getRequestContext(servletRequest);


// I need to get the bean by the document name passed in the pathParam variable here and then map it as a contentBlockRepresentation object and return it back to the client
      

        return contentBlockRepresentation;
    }
 
  }

@XmlRootElement(name = "contentBlock")
public class ContentBlockRepresentation {

    private String title;
    private String description;
    private ImageRepresentation image;

    public ContentBlockRepresentation() {
    }

    public ContentBlockRepresentation(String title, String description, ImageRepresentation image) {
        this.title = title;
        this.description = description;
        this.image = image;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @XmlElement(name = "image")
    public ImageRepresentation getImage() {
        return image;
    }

    public void setImage(ImageRepresentation image) {
        this.image = image;
    }

}

As you see I am passing the name of the document that i want as a pathParam . For eg I have created a file called "quickaccess" of document type ContentBlock in the cms inside the folder cullen.
When i call my class from the rest client with the url contentBlocks/quickaccess , I want to get the corresponding bean of quickaccess, which I would convert to my object ContentBlockRepresentation and send it back.

So, my question is how can i get the bean by the name of the document ?


Cdt,
Chandan AGARWAL
IED
Smile Benelux
Brussels
Mb - (+32) 0492101358


From: "Jeroen Reijn" <[hidden email]>
To: "Hippo CMS 7 implementation list" <[hidden email]>
Sent: Wednesday, September 26, 2012 9:59:38 AM
Subject: Re: [Hippo-cms7-user] Get bean by name of the document

Could you perhaps explain what you have tried?
What bean are you trying to get? A document of a child node?

Jeroen

On Tue, Sep 25, 2012 at 8:01 PM, Chandan AGARWAL
<[hidden email]> wrote:

> Hello,
> I am using spring Rest template to extract the data from hippo using plain
> JAX-RS Services and displaying this data in the frontend using the rest
> client.
>
> I am passing the name of the document as the parameter and would like to get
> the corresponding bean for this document.
>
> Could you tell me how can I get the bean by name of the document added in
> the repository.
>
> Thanks
>
> Cdt,
> Chandan AGARWAL
> IED
> Smile Benelux
> Brussels
> Mb - (+32) 0492101358
>
>
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--
Jeroen Reijn
Solution Architect
Hippo

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

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

http://about.me/jeroenreijn
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html



_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Get bean by name of the document

Jasper Floor
HI,

My colleague Ujwall and I thought this might give you some hints

if you know the path:

requestContext.getSession().getNode(absPath);
 
where absPath of course has to have the documentName


if documentName is an attribute of the node you need to create a query

HstRequestContext requestContext = RequestContextProvider.get();
bean = getMountContentBaseBean(requestContext).getBean(relPath) //bean is scope or go for the root


HstQueryManager manager = getHstQueryManager(requestContext.getSession(), requestContext);
HstQuery hstQuery = manager.createQuery(bean, Bean.class, true);

Filter docNameFilter= hstQuery.createFilter();
itemCodeFilter.addEqualTo(attributeName, documentName);

hstQuery.setFilter(docNameFilter);

HstQueryResult result = hstQuery.execute();

something like that I think will work.

node name may not be unique.  It is important to know if you are searching for a something unique. a document name is is not qutie unique even if you mean node name. the node name of the published, unpublished and drafts nodes are identical. 

you can add a jcrExpression to the HSTquery or you can do a jcr query directly on the repository (...().getSession().getQueryManager()....).


hope this helps a bit.


On Thu, Sep 27, 2012 at 9:08 AM, Chandan AGARWAL <[hidden email]> wrote:
I guess no one saw my reply... can anyone help me with my problem stated my previous reply...I am blocked because of this problem.

Thanks in advance


Cdt,
Chandan AGARWAL
IED
Smile Benelux
Brussels
Mb - <a href="tel:%28%2B32%29%200492101358" value="+32492101358" target="_blank">(+32) 0492101358


From: "Chandan AGARWAL" <[hidden email]>

To: "Hippo CMS 7 implementation list" <[hidden email]>
Sent: Wednesday, September 26, 2012 10:27:22 AM

Subject: Re: [Hippo-cms7-user] Get bean by name of the document

Hi Jeroen,
Here is the code snippet of my code :

@Path("/contentBlocks/")
public class ContentBlockResource extends AbstractContentResource {

@GET
    @Path("/{documentName}")
    @Produces("text/xml")
    public ContentBlockRepresentation getContentBlockByName(@Context HttpServletRequest servletRequest,
            @Context HttpServletResponse servletResponse, @PathParam("documentName") String documentName) {

        ContentBlockRepresentation contentBlockRepresentation = new ContentBlockRepresentation();

        HstRequestContext requestContext = getRequestContext(servletRequest);


// I need to get the bean by the document name passed in the pathParam variable here and then map it as a contentBlockRepresentation object and return it back to the client
      

        return contentBlockRepresentation;
    }
 
  }

@XmlRootElement(name = "contentBlock")
public class ContentBlockRepresentation {

    private String title;
    private String description;
    private ImageRepresentation image;

    public ContentBlockRepresentation() {
    }

    public ContentBlockRepresentation(String title, String description, ImageRepresentation image) {
        this.title = title;
        this.description = description;
        this.image = image;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @XmlElement(name = "image")
    public ImageRepresentation getImage() {
        return image;
    }

    public void setImage(ImageRepresentation image) {
        this.image = image;
    }

}

As you see I am passing the name of the document that i want as a pathParam . For eg I have created a file called "quickaccess" of document type ContentBlock in the cms inside the folder cullen.
When i call my class from the rest client with the url contentBlocks/quickaccess , I want to get the corresponding bean of quickaccess, which I would convert to my object ContentBlockRepresentation and send it back.

So, my question is how can i get the bean by the name of the document ?


Cdt,
Chandan AGARWAL
IED
Smile Benelux
Brussels
Mb - <a href="tel:%28%2B32%29%200492101358" value="+32492101358" target="_blank">(+32) 0492101358


From: "Jeroen Reijn" <[hidden email]>
To: "Hippo CMS 7 implementation list" <[hidden email]>
Sent: Wednesday, September 26, 2012 9:59:38 AM
Subject: Re: [Hippo-cms7-user] Get bean by name of the document

Could you perhaps explain what you have tried?
What bean are you trying to get? A document of a child node?

Jeroen

On Tue, Sep 25, 2012 at 8:01 PM, Chandan AGARWAL
<[hidden email]> wrote:
> Hello,
> I am using spring Rest template to extract the data from hippo using plain
> JAX-RS Services and displaying this data in the frontend using the rest
> client.
>
> I am passing the name of the document as the parameter and would like to get
> the corresponding bean for this document.
>

> Could you tell me how can I get the bean by name of the document added in
> the repository.
>
> Thanks
>
> Cdt,
> Chandan AGARWAL
> IED
> Smile Benelux
> Brussels
> Mb - <a href="tel:%28%2B32%29%200492101358" value="+32492101358" target="_blank">(+32) 0492101358
>
>
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--
Jeroen Reijn
Solution Architect
Hippo

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US <a href="tel:%2B1%20877%20414%204776" value="+18774144776" target="_blank">+1 877 414 4776 (toll free)
Europe <a href="tel:%2B31%280%2920%20522%204466" value="+31205224466" target="_blank">+31(0)20 522 4466
www.onehippo.com

http://about.me/jeroenreijn
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html



_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html