<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Create page/site from a simple java project? in Adobe Experience Manager Questions</title>
    <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/create-page-site-from-a-simple-java-project/m-p/456391#M131363</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;LI-USER uid="17543975"&gt;&lt;/LI-USER&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;For #1 -&amp;gt; you are right, you can get resourceResolver when using osgi&lt;BR /&gt;I think you can establish a javax.jcr.Session using basic auth and perform CRUD operarions on repository :&lt;/P&gt;&lt;PRE&gt;public Session getAemSession() {
		Session session = null;
		try {
			Repository aemrepository = JcrUtils.getRepository(this.getRepositoryname());
			session = aemrepository.login(
					new SimpleCredentials(this.getRepositoryusername(), this.getRepositorypassword().toCharArray()));
		} catch (RepositoryException e) {
			LOGGER.debug("RepositoryException::Exception::{}", e.getMessage());
		}
		return session;
	}&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;This we you can access the AEM JCR from external application.&lt;BR /&gt;&lt;BR /&gt;Here's the reference link :&lt;BR /&gt;&lt;A href="https://experienceleague.adobe.com/docs/experience-manager-64/developing/platform/access-jcr.html?lang=en" target="_blank"&gt;https://experienceleague.adobe.com/docs/experience-manager-64/developing/platform/access-jcr.html?lang=en&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Milind&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jun 2022 10:21:54 GMT</pubDate>
    <dc:creator>milind_bachani</dc:creator>
    <dc:date>2022-06-15T10:21:54Z</dc:date>
    <item>
      <title>Create page/site from a simple java project?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/create-page-site-from-a-simple-java-project/m-p/456381#M131361</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My usecase is to create page/site in AEM in a simple java project. However I am unable to find a optimal way to do so.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Purpose: Creating testdata for my project as a part of Automation Testing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Solutions tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1)Page Manager APIs to create pages, the issue faced in this is unable to get ResourceResolver instance.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;java.lang.NullPointerException&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;at com.aem.create_page.createPage(create_page.java:53)&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;at com.aem.create_page.main(create_page.java:116)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Below is the code screenshot, where this error is occurring:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vishakha_sonawale_1-1655285692621.png" style="width: 400px;"&gt;&lt;img src="https://experienceleaguecommunities.adobe.com/t5/image/serverpage/image-id/41881iA83DCE23522BB044/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="vishakha_sonawale_1-1655285692621.png" alt="vishakha_sonawale_1-1655285692621.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As per my understanding to get the resource resolver instance we need to create OSGi or Sling project, which I am trying to avoid since I am not sure how it will fit in our existing framework.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Tried to identify REST API for pages/sites, however couldn't find any similar to Assets in aem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any pointers on the above usecase would be helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vishakha&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 09:35:39 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/create-page-site-from-a-simple-java-project/m-p/456381#M131361</guid>
      <dc:creator>vishakha_sonawale</dc:creator>
      <dc:date>2022-06-15T09:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create page/site from a simple java project?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/create-page-site-from-a-simple-java-project/m-p/456391#M131363</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;LI-USER uid="17543975"&gt;&lt;/LI-USER&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;For #1 -&amp;gt; you are right, you can get resourceResolver when using osgi&lt;BR /&gt;I think you can establish a javax.jcr.Session using basic auth and perform CRUD operarions on repository :&lt;/P&gt;&lt;PRE&gt;public Session getAemSession() {
		Session session = null;
		try {
			Repository aemrepository = JcrUtils.getRepository(this.getRepositoryname());
			session = aemrepository.login(
					new SimpleCredentials(this.getRepositoryusername(), this.getRepositorypassword().toCharArray()));
		} catch (RepositoryException e) {
			LOGGER.debug("RepositoryException::Exception::{}", e.getMessage());
		}
		return session;
	}&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;This we you can access the AEM JCR from external application.&lt;BR /&gt;&lt;BR /&gt;Here's the reference link :&lt;BR /&gt;&lt;A href="https://experienceleague.adobe.com/docs/experience-manager-64/developing/platform/access-jcr.html?lang=en" target="_blank"&gt;https://experienceleague.adobe.com/docs/experience-manager-64/developing/platform/access-jcr.html?lang=en&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Milind&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 10:21:54 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/create-page-site-from-a-simple-java-project/m-p/456391#M131363</guid>
      <dc:creator>milind_bachani</dc:creator>
      <dc:date>2022-06-15T10:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: Create page/site from a simple java project?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/create-page-site-from-a-simple-java-project/m-p/456393#M131364</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Over here first you need to get the service resource resolver in your java class using the below code snipped:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Map&amp;lt;String, Object&amp;gt; param = &lt;/SPAN&gt;&lt;SPAN class=""&gt;new&lt;/SPAN&gt;&lt;SPAN&gt; HashMap&amp;lt;String, Object&amp;gt;(); param.put(ResourceResolverFactory.SUBSERVICE, &lt;/SPAN&gt;&lt;SPAN class=""&gt;"writeService"&lt;/SPAN&gt;&lt;SPAN&gt;); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ResourceResolver resolver = &lt;/SPAN&gt;&lt;SPAN class=""&gt;null&lt;/SPAN&gt;&lt;SPAN&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;try&lt;/SPAN&gt;&lt;SPAN&gt; { resolver = resolverFactory.getServiceResourceResolver(param);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;}&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;catch&lt;/SPAN&gt; (Exception e) { log.error(&lt;SPAN class=""&gt;"Exception"&lt;/SPAN&gt;,e); } &lt;SPAN class=""&gt;finally&lt;/SPAN&gt;{ &lt;SPAN class=""&gt;if&lt;/SPAN&gt;(resolver != &lt;SPAN class=""&gt;null&lt;/SPAN&gt; &amp;amp;&amp;amp; resolver.isLive()){ resolver.close(); } }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And for the steps to create the system user, and the user mapping service, you can refer to the document&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://one-inside.com/aem6-resourceresolver-access-in-services/" target="_blank" rel="noopener"&gt;https://one-inside.com/aem6-resourceresolver-access-in-services&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 10:34:33 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/create-page-site-from-a-simple-java-project/m-p/456393#M131364</guid>
      <dc:creator>shaileshbassi</dc:creator>
      <dc:date>2022-06-15T10:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create page/site from a simple java project?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/create-page-site-from-a-simple-java-project/m-p/456467#M131390</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;LI-USER uid="17543975"&gt;&lt;/LI-USER&gt;&amp;nbsp;,&lt;BR /&gt;Let me talk to your solutions first.&amp;nbsp;&lt;BR /&gt;1. You will get null as per your screenshoot because you are passing null to get resource resolver. You should pass map which contains a service user. That service user should have proper permission to perform any action.&amp;nbsp;&lt;BR /&gt;2. Yes, you can make a call from java project(outside aem) to create page. Still not sure why do you need this. But my further answer having way to make rest call.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you are writing automation, you must be having some framework to get AEM related objects. You should be able to get resource resolver. Can't add much information as I am not sure about what frameworks you are using.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Adding two solution as per what I understood.&amp;nbsp;&lt;BR /&gt;1. You should get resource resolver using service/system user. This is recommended way. If you are having existing project. you must be having service user and a way to get resource resolver.&amp;nbsp;&lt;BR /&gt;Here is one link&amp;nbsp;&lt;A href="https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-initialize-resourceresolver-reference-variable/m-p/455538#M131047" target="_blank" rel="noopener"&gt;https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-initialize-resourceresolver-reference-variable/m-p/455538#M131047&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Creating page from outside AEM (Rest call). I am explaining using postman. you can easily convert this into rest call using any Java API. You can get java code from postman itself.&lt;BR /&gt;1. Create a post call for URL -&amp;nbsp;&lt;SPAN&gt;&lt;A href="http://localhost:4502/libs/wcm/core/content/sites/createpagewizard/_jcr_content" target="_blank" rel="noopener"&gt;http://localhost:4502/libs/wcm/core/content/sites/createpagewizard/_jcr_content&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2. In Authentication &amp;nbsp;tab -&amp;gt; Choose Basic Auth -&amp;gt; your credential&lt;/P&gt;&lt;P&gt;3. in Body Tab -&amp;gt; Add parameters use to create page. I added only which needed. You can add others as well.&lt;BR /&gt;Adding a screenshoot.&amp;nbsp;&lt;BR /&gt;Again, this is basic way to authenticate. There are other ways too. Use as per your need.&amp;nbsp;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Postman_Page.png" style="width: 999px;"&gt;&lt;img src="https://experienceleaguecommunities.adobe.com/t5/image/serverpage/image-id/41898iDDD225913478C5B8/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="Postman_Page.png" alt="Postman_Page.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 20:24:52 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/create-page-site-from-a-simple-java-project/m-p/456467#M131390</guid>
      <dc:creator>sunil_kumar_</dc:creator>
      <dc:date>2022-06-15T20:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: Create page/site from a simple java project?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/create-page-site-from-a-simple-java-project/m-p/456570#M131432</link>
      <description>&lt;P&gt;From what I read, you are trying to run a Java application (standalone, that means not deployed into AEM) which connects to AEM to create test cntent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would use the AEM Testing Clients, which can be used to do that. See [1] for the github project. The README of the underlying Sling Testing Client library [2] has some examples how you can make it run.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the main purpose of these libraries is to create Integration Tests for AEM; so creating test content is just a small part of its functionality.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[1] &lt;A href="https://github.com/adobe/aem-testing-clients" target="_blank"&gt;https://github.com/adobe/aem-testing-clients&lt;/A&gt;&lt;/P&gt;&lt;P&gt;[2] &lt;A href="https://github.com/apache/sling-org-apache-sling-testing-clients" target="_blank"&gt;https://github.com/apache/sling-org-apache-sling-testing-clients&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 11:47:38 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/create-page-site-from-a-simple-java-project/m-p/456570#M131432</guid>
      <dc:creator>Jörg_Hoh</dc:creator>
      <dc:date>2022-06-16T11:47:38Z</dc:date>
    </item>
  </channel>
</rss>

