Jahia Dev Forum > Obtain UUID and...

0 (0 Good)
0 (0 Bad)

Obtain UUID and content text from JCR repository

by  asertic »  2013/02/05 09:47

Hi, I'm new to Jahia and I have the following problem. Using a java application written by me, I would get the UUID and the content (such as text) of an article published in a Jahia site. Is it possible? What tools do I need to do this?

  (asertic)

Number of messages  9
Registration date
0 (0 Good)
0 (0 Bad)

Re: Obtain UUID and content text from JCR repository

by  namitgupta »  2013/02/05 10:22

Hi,

It is difficult to understand the exact requirement from your post. However, If you want a list of published articles, then you can simply run the following query on the live workspace. The query should be something like:

select * from [jnt:article]

 

Yoy can run this query using the Jahia tools. The Tools can be accessed by following URL:

http://localhost:8080/tools

 

You can also obtain the result set from the aforesaid query in a JSON format using the Jahia REST api. The http request should be:

 

 

http://localhost:8080/cms/find/live/en?&limit=0&query=select * from [jnt:article]

 

Regards,

Namit

 

  (namitgupta)

Number of messages  36
Registration date
0 (0 Good)
0 (0 Bad)

Re: Re: Obtain UUID and content text from JCR repository

by  asertic »  2013/02/05 10:53

Thanks for your answer. I created a test site and I added a node (folder) "rich-text" that contains a simple html page. What is the query in Json format to get the html code (the written text on the page) of this content to?

 

  (asertic)

Number of messages  9
Registration date
0 (0 Good)
0 (0 Bad)

Obtain UUID and content text from JCR repository

by  asertic »  2013/02/05 14:49

no one can help me?

  (asertic)

Number of messages  9
Registration date
0 (0 Good)
0 (0 Bad)

Re: Obtain UUID and content text from JCR repository

by  shyrkov »  2013/02/05 14:56

Hello Antonio,

could you, please, be more specific? Perhaps illustrate your use case with a screenshot?

It is hard to guess what is your content structure and type.

In the example of Namit, he was obtaining all content nodes of type jnt:article using the HTTP request:

http://localhost:8080/cms/find/live/en?&limit=0&query=select * from [jnt:article]

 

In your case I even not sure what type of content you have created in the page and would like to get via HTTP call in JSON format.

Thank you in advance for providing more details.

 

Kind regards

Sergiy

  • Re: Obtain UUID and content text from JCR repository
    2013/02/05 14:56

    shyrkov <p> Hello Antonio,</p> <p> could you, please, be more specific? Perhaps illustrate your use case with a screenshot?</p> <p> It is hard to guess what is your content structure and type.</p> <p> In the example of Namit, he was obtaining all content nodes of type jnt:article using the HTTP request:</p> <pre style="margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(51, 51, 51); font-size: 13px;"> http://localhost:8080/cms/find/live/en?&amp;limit=0&amp;query=select * from [jnt:article]</pre> <p> &nbsp;</p> <p> In your case I even not sure what type of content you have created in the page and would like to get via HTTP call in JSON format.</p> <p> Thank you in advance for providing more details.</p> <p> &nbsp;</p> <p> Kind regards</p> <p> Sergiy</p>

  • Number of messages  407
    Registration date Feb 5, 2013
    0 (0 Good)
    0 (0 Bad)

    Re: Re: Obtain UUID and content text from JCR repository

    by  asertic »  2013/02/05 15:54

    In "sito_prova" I created some content in "Contents" directory.

    One of these is "TEST_CONTENT" (rich-text).

    "TEST_CONTENT" contains the following  html text.

    The "TEST_CONTEN"  ID in default repository is ID: 70c8f783-d7c5-4096-b9ac-d0c64eddcdce

    Can I obtain the html-text in green circle using a HTTP Get Request or Jahia REST API?

    I've seen the link: http://www.jahia.com/community/documentation/jahiapedia/jahia-modules/rest.html   but I did not understand how to use the API's.

     

    Browsin defaul repository I have the following path: 

      (asertic)

    Number of messages  9
    Registration date
    0 (0 Good)
    0 (0 Bad)

    Re: Re: Re: Obtain UUID and content text from JCR repository

    by  rvt »  2013/02/05 22:35

    You can do a ajax request like this:

     

    http://localhost:8080/cms/sites/<MYSITE>/contents/<SYSTEM NAME OF YOUR CONTENT ITEM>.html.ajax

    In your case (I hope I typed it over correctly):

    http://localhost:8080/cms/sites/ilmiosito/contents/contenuto_di_prova.html.ajax

    Ries
    ##jahia @ freenode.org

     

  • Re: Re: Re: Obtain UUID and content text from JCR repository
    2013/02/05 22:35

    rvt <p> You can do a ajax request like this:</p> <p> &nbsp;</p> <p> http://localhost:8080/cms/sites/&lt;MYSITE&gt;/contents/&lt;SYSTEM NAME OF YOUR CONTENT ITEM&gt;.html.ajax</p> <div> <p> In your case (I hope I typed it over correctly):</p> <p> http://localhost:8080/cms/sites/ilmiosito/contents/contenuto_di_prova.html.ajax</p> <div> Ries</div> <div> ##jahia @ freenode.org</div> </div> <p> &nbsp;</p>

  • Number of messages  185
    Registration date Feb 5, 2013
    0 (0 Good)
    0 (0 Bad)

    Re: Re: Re: Re: Obtain UUID and content text from JCR repository

    by  asertic »  2013/02/06 09:28

    rvt, thanks for yur answer! Can I have the same result using the content UUID in the URL (or in a query) as identifier instead of system name of content? Then, what is the URL?

      (asertic)

    Number of messages  9
    Registration date
    0 (0 Good)
    0 (0 Bad)

    Re: Re: Re: Re: Re: Obtain UUID and content text from JCR repository

    by  pap@commaro.com »  2013/02/06 15:35

    Hi,

    the query using uuid, could look like this:

    localhost:8080/jahia/cms/find/live/en?&limit=0&query=SELECT * FROM [jnt:bigText] WHERE [jcr:uuid] = '70c8f783-d7c5-4096-b9ac-d0c64eddcdce'

    This is however searching in the live workspace for already published content. Using .../find/default/en... would search in default workspace.

    Here is more documentation about the REST API: http://www.jahia.com/community/documentation/jahiapedia/jahia-modules/rest.html

    Regards,
    Benjamin

    Benjamin Papez (pap@commaro.com)

    Number of messages  220
    Registration date
    0 (0 Good)
    0 (0 Bad)

    Re: Re: Re: Re: Re: Re: Obtain UUID and content text from JCR repository

    by  asertic »  2013/02/07 12:18

    Hi,

    thanks for your answer.

    The correct query in my case is:

    localhost:8080/cms/find/live/en?&limit=0&query=SELECT * FROM [jnt:bigText] WHERE [jcr:uuid] = '70c8f783-d7c5-4096-b9ac-d0c64eddcdce'

    When I execute it with Google Crome browser, I get the following result:

    [
        {
            "node": {
                "index": 1,
                "text": "<p>\n\t<span style=\"color:#8b4513;\"><strong>TEST_CONTENT</strong></span></p>\n<p>\n\t<font color=\"#8b4513\"><b>Corpo del contenuto di test</b></font></p>\n",
                "jcr:created": "2013-02-05T15:40:08.634+01:00",
                "j:originWS": "default",
                "j:published": "true",
                "jcr:lastModified": "2013-02-05T18:16:21.979+01:00",
                "j:lastPublishedBy": "root",
                "jcr:createdBy": "root",
                "j:nodename": "contenuto_di_prova",
                "jcr:versionHistory": "/cms/render/default/it/jcr%3asystem/jcr%3aversionStorage/70/c8/f7/70c8f783-d7c5-4096-b9ac-d0c64eddcdce.html",
                "depth": 4,
                "jcr:uuid": "70c8f783-d7c5-4096-b9ac-d0c64eddcdce",
                "jcr:mixinTypes": [
                    "jmix:accessControlled"
                ],
                "jcr:lastModifiedBy": "root",
                "jcr:baseVersion": "/cms/render/default/it/jcr%3asystem/jcr%3aversionStorage/70/c8/f7/70c8f783-d7c5-4096-b9ac-d0c64eddcdce/1.0.html",
                "jcr:isCheckedOut": "true",
                "path": "/sites/ilmiosito/contents/contenuto_di_prova",
                "nodename": "contenuto_di_prova",
                "primaryNodeType": "jnt:bigText",
                "j:lastPublished": "2013-02-05T17:57:05.710+01:00",
                "identifier": "70c8f783-d7c5-4096-b9ac-d0c64eddcdce",
                "jcr:primaryType": "jnt:bigText"
            },
            "jcr:text": ""
        }
    ]
    Besides, when I try to execut the query from another PC on my LAN (using my IP address in the URL) after login to repository I get:
    [{"jcr:text":""}]

     

    My tomcat server (and Jahia Repository) is correctly accessible from other computers in the LAN.

     

      (asertic)

    Number of messages  9
    Registration date
    Contact
    Share
    Feedback

    Get in touch

    Whether you are a current user or if you are just evaluating Jahia, we are here to help.

    Contact us

    Share this page