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?

  • Obtain UUID and content text from JCR repository
    2013/02/05 09:47

    asertic <p> Hi, I&#39;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?</p>

  • Number of messages  9
    Registration date Feb 5, 2013
    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

     

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

    namitgupta <p> Hi,</p> <p> 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:</p> <p> select * from [jnt:article]</p> <p> &nbsp;</p> <p> Yoy can run this query using the Jahia tools. The Tools can be accessed by following URL:</p> <p> http://localhost:8080/tools</p> <p> &nbsp;</p> <p> 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:</p> <p> &nbsp;</p> <p> &nbsp;</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> Regards,</p> <p> Namit</p> <p> &nbsp;</p>

  • Number of messages  36
    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 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?

     

  • Re: Re: Obtain UUID and content text from JCR repository
    2013/02/05 11:10

    asertic <p> Thanks for your answer. I created a test site and I added a node (folder) &quot;rich-text&quot; that contains a simple html page. What is the query in Json format to get the html code (<span class="hps">the written text</span> <span class="hps">on the page</span>) of this content to?</p> <p> &nbsp;</p>

  • Number of messages  9
    Registration date Feb 5, 2013
    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?

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

    asertic <p> no one can help me?</p>

  • Number of messages  9
    Registration date Feb 5, 2013
    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: 

  • Re: Re: Obtain UUID and content text from JCR repository
    2013/02/05 16:07

    asertic <p> <span id="result_box" lang="en">In &quot;sito_prova&quot;&nbsp;<span class="hps">I created</span> <span class="hps">some content</span> <span class="hps">in</span>&nbsp;&quot;C<span class="hps">ontents&quot; directory.</span></span></p> <p> <span lang="en"><span class="hps">One of these is &quot;TEST_CONTENT&quot; (rich-text).</span></span></p> <p> <img alt="" src="http://img22.imageshack.us/img22/1962/image2kv.png" /></p> <p> <span class="short_text" id="result_box" lang="en">&quot;TEST_CONTENT&quot;&nbsp;<span class="hps">contains the following </span>&nbsp;<span class="hps">html text.</span></span></p> <p> <img alt="" src="http://img703.imageshack.us/img703/690/image3yk.png" /></p> <p> The &quot;TEST_CONTEN&quot; &nbsp;ID in default repository is&nbsp;<strong style="color: rgb(54, 57, 61); font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 20px;">ID:&nbsp;</strong><span style="color: rgb(54, 57, 61); font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 20px;">70c8f783-d7c5-4096-b9ac-d0c64eddcdce</span></p> <p> Can I obtain the html-text in green circle using a HTTP Get Request or Jahia REST API?</p> <p> I&#39;ve seen the link: http://www.jahia.com/community/documentation/jahiapedia/jahia-modules/rest.html &nbsp;&nbsp;<span class="hps">but</span> <span class="hps">I did not understand</span> <span class="hps">how to use the</span> <span class="hps">API&#39;s.</span></p> <p> &nbsp;</p> <p> Browsin defaul repository I have the following path:&nbsp;</p> <p> <img alt="" src="http://img826.imageshack.us/img826/5874/image4wc.png" /></p>

  • Number of messages  9
    Registration date Feb 5, 2013
    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?

  • Re: Re: Re: Re: Obtain UUID and content text from JCR repository
    2013/02/06 09:28

    asertic <p> 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?</p>

  • Number of messages  9
    Registration date Feb 6, 2013
    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.

     

  • Re: Re: Re: Re: Re: Re: Obtain UUID and content text from JCR repository
    2013/02/07 12:24

    asertic <p> Hi,</p> <p> thanks for your answer.</p> <p> The correct query in my case is:</p> <p> localhost:8080/cms/find/live/en?&amp;limit=0&amp;query=SELECT * FROM [jnt:bigText] WHERE [jcr:uuid] = &#39;70c8f783-d7c5-4096-b9ac-d0c64eddcdce&#39;</p> <p> When I execute it with Google Crome browser, I get the following result:</p> <pre style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; white-space: pre-wrap;"> [ &nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;node&quot;: { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;index&quot;: 1, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;text&quot;: &quot;&lt;p&gt;\n\t&lt;span style=\&quot;color:#8b4513;\&quot;&gt;&lt;strong&gt;TEST_CONTENT&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;\n&lt;p&gt;\n\t&lt;font color=\&quot;#8b4513\&quot;&gt;&lt;b&gt;Corpo del contenuto di test&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;\n&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;jcr:created&quot;: &quot;2013-02-05T15:40:08.634+01:00&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;j:originWS&quot;: &quot;default&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;j:published&quot;: &quot;true&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;jcr:lastModified&quot;: &quot;2013-02-05T18:16:21.979+01:00&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;j:lastPublishedBy&quot;: &quot;root&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;jcr:createdBy&quot;: &quot;root&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;j:nodename&quot;: &quot;contenuto_di_prova&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;jcr:versionHistory&quot;: &quot;/cms/render/default/it/jcr%3asystem/jcr%3aversionStorage/70/c8/f7/70c8f783-d7c5-4096-b9ac-d0c64eddcdce.html&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;depth&quot;: 4, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;jcr:uuid&quot;: &quot;70c8f783-d7c5-4096-b9ac-d0c64eddcdce&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;jcr:mixinTypes&quot;: [ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;jmix:accessControlled&quot; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ], &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;jcr:lastModifiedBy&quot;: &quot;root&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;jcr:baseVersion&quot;: &quot;/cms/render/default/it/jcr%3asystem/jcr%3aversionStorage/70/c8/f7/70c8f783-d7c5-4096-b9ac-d0c64eddcdce/1.0.html&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;jcr:isCheckedOut&quot;: &quot;true&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;path&quot;: &quot;/sites/ilmiosito/contents/contenuto_di_prova&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;nodename&quot;: &quot;contenuto_di_prova&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;primaryNodeType&quot;: &quot;jnt:bigText&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;j:lastPublished&quot;: &quot;2013-02-05T17:57:05.710+01:00&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;identifier&quot;: &quot;70c8f783-d7c5-4096-b9ac-d0c64eddcdce&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;jcr:primaryType&quot;: &quot;jnt:bigText&quot; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;jcr:text&quot;: &quot;&quot; &nbsp;&nbsp;&nbsp; } ]</pre> <div class="gt-baf-cell gt-baf-word"> 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:</div> <div class="gt-baf-cell gt-baf-word"> <pre> [{&quot;jcr:text&quot;:&quot;&quot;}]</pre> <p> &nbsp;</p> <p> <span id="result_box" lang="en"><span class="hps">My</span> <span class="hps">tomcat</span> <span class="hps">server (and Jahia Repository)</span> <span class="hps">is</span> <span class="hps alt-edited">correctly</span> <span class="hps">accessible from</span> <span class="hps">other computers</span> <span class="hps">in the</span> <span class="hps">LAN.</span></span></p> </div> <p> &nbsp;</p>

  • Number of messages  9
    Registration date Feb 7, 2013
    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