Expand my Community achievements bar.

SOLVED

How to export a node ignore child with using JCR API

Avatar

Former Community Member

JCR Session interface have 2 method for developer to export and import operation.

Now i am going to export this node not contains it's child: /content/geometrixx/en/products/square

protected void test() { try { String nodePath = "/content/geometrixx/en/products/square"; Node exportNode = session.getNodeByIdentifier(nodePath ); this.exportSystemView(session, exportNode); } catch (Exception ex){ ex.printStackTrace(); } closeSession(); System.out.println("Export Ok"); } private void exportSystemView(Session session, Node page) throws RepositoryException, IOException { File outputFile = new File(page.getName() + ".xml"); FileOutputStream out = new FileOutputStream(outputFile); session.exportSystemView(page.getPath(), out, false, true); }

Then begin to import this node to this destination: /content/geometrixx/fr/products

protected void test() { try { String path = "square.xml"; String absPath = "/content/geometrixx/fr/products"; File file = new File(path); InputStream is = new FileInputStream(file); this.session.importXML(absPath, is, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW); } catch (Exception ex) {} closeSession(); System.out.println("Import Ok"); }

Import done, i see a new node "square" already created under "/content/geometrixx/fr/products". But the problem with if to double click the node happen error following:

no content Cannot serve request to /content/geometrixx/fr/products/square.html in /libs/foundation/components/primary/cq/Page/Page.jsp Request Progress: 0 (2014-12-09 15:40:18) TIMER_START{Request Processing} 0 (2014-12-09 15:40:18) COMMENT timer_end format is {<elapsed msec>,<timer name>} <optional message> 0 (2014-12-09 15:40:18) LOG Method=GET, PathInfo=/content/geometrixx/fr/products/square.html 0 (2014-12-09 15:40:18) TIMER_START{ResourceResolution} 1 (2014-12-09 15:40:18) TIMER_END{1,ResourceResolution} URI=/content/geometrixx/fr/products/square.html resolves to Resource=JcrNodeResource, type=cq:Page, superType=null, path=/content/geometrixx/fr/products/square 1 (2014-12-09 15:40:18) LOG Resource Path Info: SlingRequestPathInfo: path='/content/geometrixx/fr/products/square', selectorString='null', extension='html', suffix='null' 1 (2014-12-09 15:40:18) TIMER_START{ServletResolution} 1 (2014-12-09 15:40:18) TIMER_START{resolveServlet(JcrNodeResource, type=cq:Page, superType=null, path=/content/geometrixx/fr/products/square)} 1 (2014-12-09 15:40:18) TIMER_END{0,resolveServlet(JcrNodeResource, type=cq:Page, superType=null, path=/content/geometrixx/fr/products/square)} Using servlet /libs/foundation/components/primary/cq/Page/Page.jsp 1 (2014-12-09 15:40:18) TIMER_END{0,ServletResolution} URI=/content/geometrixx/fr/products/square.html handled by Servlet=/libs/foundation/components/primary/cq/Page/Page.jsp 1 (2014-12-09 15:40:18) LOG Applying Requestfilters 1 (2014-12-09 15:40:18) LOG Calling filter: com.adobe.granite.resourceresolverhelper.impl.ResourceResolverHelperImpl 1 (2014-12-09 15:40:18) LOG Calling filter: org.apache.sling.bgservlets.impl.BackgroundServletStarterFilter 1 (2014-12-09 15:40:18) LOG Calling filter: com.adobe.cq.dam.s7imaging.impl.auth.MemoryTokenAuthHandler 1 (2014-12-09 15:40:18) LOG Calling filter: org.apache.sling.i18n.impl.I18NFilter 1 (2014-12-09 15:40:18) LOG Calling filter: com.adobe.granite.httpcache.impl.InnerCacheFilter 1 (2014-12-09 15:40:18) LOG Calling filter: org.apache.sling.rewriter.impl.RewriterFilter 1 (2014-12-09 15:40:18) LOG Calling filter: com.day.cq.wcm.designimporter.CanvasPageDeleteRequestFilter 1 (2014-12-09 15:40:18) LOG Calling filter: com.adobe.cq.history.impl.HistoryRequestFilter 1 (2014-12-09 15:40:18) LOG Calling filter: com.day.cq.wcm.core.impl.WCMRequestFilter 1 (2014-12-09 15:40:18) LOG Calling filter: com.adobe.granite.optout.impl.OptOutFilter 1 (2014-12-09 15:40:18) LOG Calling filter: com.day.cq.theme.impl.ThemeResolverFilter 1 (2014-12-09 15:40:18) LOG Calling filter: com.day.cq.wcm.foundation.forms.impl.FormsHandlingServlet 1 (2014-12-09 15:40:18) LOG Calling filter: com.adobe.cq.social.commons.cors.CORSAuthenticationFilter 1 (2014-12-09 15:40:18) LOG Calling filter: org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter 1 (2014-12-09 15:40:18) LOG Calling filter: com.day.cq.wcm.mobile.core.impl.redirect.RedirectFilter 2 (2014-12-09 15:40:18) LOG RedirectFilter did not redirect (MobileUtil.isMobileResource() returns false) 2 (2014-12-09 15:40:18) LOG Calling filter: com.day.cq.wcm.core.impl.warp.TimeWarpFilter 2 (2014-12-09 15:40:18) LOG Calling filter: com.day.cq.wcm.core.impl.AuthoringUIModeServiceImpl 2 (2014-12-09 15:40:18) LOG Calling filter: com.adobe.cq.social.commons.security.SaferSlingPostServlet 2 (2014-12-09 15:40:18) LOG Calling filter: com.adobe.granite.requests.logging.impl.RequestLoggerImpl 2 (2014-12-09 15:40:18) LOG Applying Componentfilters 2 (2014-12-09 15:40:18) LOG Calling filter: com.day.cq.personalization.impl.TargetComponentFilter 2 (2014-12-09 15:40:18) LOG Calling filter: com.day.cq.wcm.core.impl.WCMComponentFilter 2 (2014-12-09 15:40:18) LOG Calling filter: com.day.cq.wcm.core.impl.WCMDebugFilter 2 (2014-12-09 15:40:18) TIMER_START{/libs/foundation/components/primary/cq/Page/Page.jsp#0} 3 (2014-12-09 15:40:18) LOG Applying Error filters 3 (2014-12-09 15:40:18) LOG Calling filter: org.apache.sling.rewriter.impl.RewriterFilter 3 (2014-12-09 15:40:18) TIMER_START{handleError:status=404} 4 (2014-12-09 15:40:18) TIMER_END{1,handleError:status=404} Using handler /libs/sling/servlet/errorhandler/404.jsp 6 (2014-12-09 15:40:18) LOG Found processor for post processing ProcessorConfiguration: {contentTypes=[text/html],order=-1, active=true, valid=true, processErrorResponse=true, pipeline=(generator=Config(type=htmlparser, config={}), transformers=(Config(type=linkchecker, config={}), Config(type=mobile, config=JcrPropertyMap [node=Node[NodeDelegate{tree=/libs/cq/config/rewriter/default/transformer-mobile: { jcr:primaryType = nt:unstructured, component-optional = true}}], values={jcr:primaryType=nt:unstructured, component-optional=true}]), Config(type=mobiledebug, config=JcrPropertyMap [node=Node[NodeDelegate{tree=/libs/cq/config/rewriter/default/transformer-mobiledebug: { jcr:primaryType = nt:unstructured, component-optional = true}}], values={jcr:primaryType=nt:unstructured, component-optional=true}]), Config(type=contentsync, config=JcrPropertyMap [node=Node[NodeDelegate{tree=/libs/cq/config/rewriter/default/transformer-contentsync: { jcr:primaryType = nt:unstructured, component-optional = true}}], values={jcr:primaryType=nt:unstructured, component-optional=true}]), serializer=Config(type=htmlwriter, config={}))} 6 (2014-12-09 15:40:18) TIMER_END{6,Request Processing} Dumping SlingRequestProgressTracker Entries

 

Why happened that? The requirment is just export a node(not contains child) then to import to other destination.

And i find out that under destination there is not node "jcr:content" at all, i suspect lack something when export.

(BTW, if export a node contained it's child, then import to an destination, result is no any problem )

Any expert could help see it? Thanks a lot.

1 Accepted Solution

Avatar

Correct answer by
Level 10

It is expected because you are missing to include jcr:content. You can use package manager or its api [1]   Or use tool [2]. 

[1]  http://www.aemstuff.com/#article1000

[2]  http://helpx.adobe.com/experience-manager/kb/contentcompareimport.html

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

It is expected because you are missing to include jcr:content. You can use package manager or its api [1]   Or use tool [2]. 

[1]  http://www.aemstuff.com/#article1000

[2]  http://helpx.adobe.com/experience-manager/kb/contentcompareimport.html