cq5,aem , JCR Node imported as nt:file when using content-package-maven-plugin

JCR Node imported as nt:file when using content-package-maven-plugin


Tag: cq5,aem

I created an OSGI config JCR node in XML within my Adobe CQ project under /apps/myproject/config/org.apache.sling.commons.log.LogManager.factory.config-MYPROJECT.xml

<?xml version="1.0" encoding="UTF-8"?>
    org.apache.sling.commons.log.pattern="\{0,date,HH:mm:ss.SSS} *{4}* {3} {5}"
    org.apache.sling.commons.log.names="[com.mycompany.myproject]" />

Problem is that when it gets imported into the JCR, it is showing up as an nt:file instead of what it should be according to its jcr:primaryType so that it look like this in CRXDE

incorrect import as nt:file

when it should look like this

expected import as sling:OsgiConfig


So my XML markup starts EXACTLY as follows:

<?xml version="1.0" encoding="UTF-8"?>

What I had done originally was to create a new xml file and put in my config. There are 2 other ways I know to create nodes

  1. By doing it in CRXDE and then using vault to export
  2. By doing it in Eclipse using the AEM developer tools (Eclipse plugin for Apache Sling)

In the case of a vault export, the XML starts like this:

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" ...

and in the case of the plugin, it starts like this

<?xml version="1.0" encoding="UTF-8"?>

but wait, you can't see it here, the plugin actually adds a friggin blank space right after jcr:root.

So whatever XML parser is acting on these XML files to create nodes in the JRC, it behaves oddly if there is no space right after the root node name. I'm on Windows, using Maven 3.2.3, using version 0.0.20 of content-package-maven-plugin, and AEM 5.6.1.


How to get SlingRequest from saxon TransformerFactory

I want to get a current SlingRequest.getRequestURI() and pass it to new LinkTransformer(links, repository, <<requestedUrl>>). So I tried to add an annotation @Reference SlingRequest slingRequest and it throws me exception. Here is my code: package com.my.transformer; import com.my.transformer.impl.LinkTransformer; import org.apache.felix.scr.annotations.*; import org.apache.sling.jcr.api.SlingRepository; import org.apache.sling.rewriter.Transformer; import org.apache.sling.rewriter.TransformerFactory; import...

CQ5 aka AEM - Finding the source of a copied page programmatically

I'm currently exploring AEM and was wondering if it's possible to identify the "source" of a page. To clarify what I mean exactly: If you copy a page by using the "Copy" and "Paste" options in CQ5 WCM (not a live copy, just a normal copy of a page) is...

How to get url of all child,grand child pages using root path?

I have a path of a root page and I want to retrieve all the child pages of root page and grandchild and grand grand child of root page. My structure is like this rootPage | | |---------childPage | | |---------grandChildPage | | | |----------------------grandGrandChildPages So I want the path...

Is it possible to switch to Sling Selector Script based on page property

In an AEM Sightly component, which has two modes; gallery and directory. The directory view is implemented with a selector (/apps/mi-proj/people_list/directory.html). By default the component renders in a gallery mode (using people_list/people_list.html). Users would like the ability to choose which view is shown by default. In either cases, users can...

AEM pathfield appending values without changing

I have a path field widget in AEM for error page handling. I have added it at the base page implementation and when I try and select the path, I see that there is a "," appended to the path. If I clear the field and save, I see that...

Java AEM Query Builder ||

I am building a simple meta-data table that gets the data from a query. I want to be able to query on two options for the 'type' variable. the || is not working however; when I use this the page crashes. Map<String, String> predicates = new HashMap<String, String>(); predicates.put("path", searchPath);...

Unable to select the components on a page

I want to perform a rollout only for the selected components in the page. I noticed that I am not able to select any of the components presented in the pages using the small checkbox in the component's edit bar. I am not sure why this is happening. All of...

How would you implement Adobe CQ client side validation for form fields?

I have implemented custom server side validation for form fields, so when the user specifies a constraint, the field will be validated on form submit. I would like to have client side validation as well, if possible at constraint level so that all that it needs to be configured on...

cq:editConfig not applying outside of parsys

Cross-post from Adobe Community Forums: http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.html/forum__qugo-we_have_an_imagecom.html We have an image component, its _cq_editConfig.xml is: <?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" cq:disableTargeting="{Boolean}true"...

Rewrite Adobe CQ Image src attribute

In AEM, content such as pages and images contains the '/content/' prefix in them. We are able to rewrite these url via Link Checker Transformer configuration and resourceResolver.map() method. URLs are being rewritten for HTML elements <a> and <form>. But I want it to work for <img> elements as well....

How to do a search by date query on cq pages

I am trying to create a blog in cq5. The OOTB search component in blog is not supporting search by date feature. I tried to override it, but could not find the correct query to fetch the blogs created on a particular date. Seems the only functions supported are >,>=,<,<=....

Restricting javax.servlet.Filter to specific URL pattern

I'm trying to implement a Filter for a project in Adobe CQ 5.6.1. Seems nifty to be used for doing some, say, authentication stuff for each page that gets displayed. I've read up on the documentation on Filters and I've coded my annotations this way: @SlingFilter( label = "Filter implementation",...

How to instantiate a Sling Model with multiple adaptables

The @Model annotation in Sling Models allows for multiple adaptables, for example @Model(adaptables = { SlingHttpServletRequest.class, Resource.class }) However, I am not sure how to instantiate a Model with multiple adaptables from a JSP. The options shown in the Sling documentation always specify a single adaptable only: https://sling.apache.org/documentation/bundles/models.html#adaptto

How to wrap 2 components in a div from the template content.xml file?

I have two components that should be configured in a cq template, in the content.xml file (in the jcr:content node). I don't have a page component for my template, so I cannot do something like this: <div class="wrapper_div"> <cq:include resourceType="/my/first/component"/> <cq:include resourceType="/my/second/component"/> </div> Is there a way to define a...

CQ5 SlingServlet and resourceTypes not working for specific resource paths

If I define a Sling Servlet as follows: @SlingServlet( label="TestResourceTypeServlet", name = "com.company.project.servlets.TestResourceType", extensions = {"bob"}, resourceTypes= {"cq:Page"}, methods= {"GET"}, metatype=true) @Properties({ @Property(name = "service.description", value = "A test servlet"), @Property(name = "service.vendor", value = "Company") }) The servlet picks up any get request to every page with an extension...

How to create a directory on the basis of path in cq5?

I have a String which is the path of the page for example /content/xperia/public/events/eventeditor. I am gererating the XML of this page and saving it to DAM, but I want to save it in the similar tree structure under /content. I tried the following code String page = "/content/xperia/public/events/eventeditor"; page...

Jcr query multiple nodes having their abs paths

I am trying to query multiple nodes having their abs paths I know I can do session.getNode(absPath) But I have to iterate through it, and, probably it is not the fastest solution .Is there a way to do it all together(so to say, by batch)?...

How to total up first few elements in a for each loop of Sightly?

How to add the first three elements of a for loop in sightly and show the value as Total. I have code as below {{each(i, provision) provisionTypes}} <label class="day-provision-label"> <input type="checkbox" class="day-provision" data-provision-type="${provision}" {{if day[provision]}}checked{{/if}} {{if !day.working}}disabled{{/if}}> ${provision.charAt(0).toUpperCase() + provision.slice(1)} <span class="provision-rate ui-supporting-text"> $${rates[provision].toFixed(5)} </span> </label> {{/each}} What I want...

CQ5 debug bundles using eclipse won't halt

I created a bundle that I already uploaded, but I would like to debug it. I started the server with debug mode: java -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n -XX:MaxPermSize=256m -Xmx1024M -jar AEM_6.0_Quickstart.jar, and then I set to the project that packaged into the bundle its remote debugging configuration, but when I set the breakpoints...

AEM TouchUI Components dialog

I have multiple components that use another component as a child, not to generate all the content but it is a child component we recognized needed to be used multiple times so we created a child component that is being included: The problem that I have run into is that...

On/Off time(datetime field) doesn't cleared after cancel button is pressed

I open page properties and fill some fields After I pressed cancel button, and reopened properties dialog, all field cleared, but datetime fields didn't. What is the rigth way to clear datetime fields?...

AEM 6.0 Image crop tools (using Free Crop / Ratio Crop) not functioning properly but working in CQ 5

I'm having a concern on the Image Crop Tool in AEM 6.0. I had an existing code working in CQ5 (with regards to Image Crop Tool), but when I tried to use AEM6.0, this certain tool won't work properly anymore. When I try to crop the image, it doesn't really...

Which performs better for search in in Adobe AEM, SQL2 or the QueryBuilder?

I have to make some queries in AEM and I'm not sure if I should go for the QueryBuilder or SQL2. The queries are not particularly complex. I need to find pages using a date range,tags and resourceType. Which is the preferred method to make queries in AEM? which one...

Impose component restriction to a series of parsys-CQ

I have a series of parsys present in my page's footer. At the same time, I want to impose component restriction to all these via etc/designs/projectname/content.xml. This goes like this: JSP: <c:forEach var="i" begin="0" end="${properties.numberOfFooterLinks-1}"> <div class="small-6 medium-4 large-2 columns"> <cq:include path="./footerPar${i}" resourceType="foundation/components/parsys" /> </div> </c:forEach> XML: <footer jcr:primaryType="nt:unstructured"> <footerPar0...

Get JSP output within Servlet in AEM

In CQ, we need to process jsp within servlet then combine the result with other results we get from server before writing back to browser. The following code is almost what we need, except that it writes the result back to browser after processing jsp. RequestDispatcher dispatcher = request.getRequestDispatcher(resource); dispatcher.forward(request,...

How to use and configure logback in Adobe CQ5 projects?

I newbie in CQ5. I started my first project in CQ and I want to write any exceptions and debug info of project's components, services and servlets (in bundles) to log files in crx-repo (...\crx-quickstart\logs). I want to use slf4j with logback implementation in my project. I tried below steps:...

Page activation(using siteadmin) is too long

I have page with a lot amoun of content. After activation button is pressed ,loading bar is shown for a 2-3 mins, activation response is pending for a 2-3 mins. If i use curl command : curl -u admin:admin -F cmd=activate -F ignoredeactivated=false -F onlymodified=false -F path=/path/topage http://server:port//etc/replication/treeactivation.html Or http://server:port/etc/replication/treeactivation.html...

In CQ/AEM, can I prevent Sidekick from showing?

Under certain circumstances, I want to prevent the Sidekick from being displayed on a page. I tried some things: Removing the init.jsp include. This works, but it also prevents certain CQ javascript libraries from being loaded, and I need these libraries. Adding a jquery onload event to hide the sidekick....

Adobe AEM 6.0 component default control

When building components in AEM, by default new components are created with an associated JSP file for rendering. For builds using Sightly, each time a component is created the developer must delete the JSP file and create the required HTML file. This leads to wasted time and effort, not to...

Setting regular expression to validate URL format in Adobe CQ5

I want to validate a URL inside a textfield using Adobe CQ5, so I set up the properties regex and regexText as usual, but for some reason is not working: <facebook jcr:primaryType="cq:Widget" emptyText="http://www.facebook.com/account-name" fieldDescription="Set the Facebook URL" fieldLabel="Facebook" name="./facebookUrl" regex="/^(http://www.|https://www.|http://|https://)[a-z0-9]+([-.]{1}[a-z0-9]+)*.[a-z]{2,5}(:[0-9]{1,5})?(/.*)?$/" regexText="Invalid URL format" xtype="textfield"/> So when I type inside the...

Output of jStack

We are using Adobe AEM on a windows machine. Our Author instances get very slow and to investigate the same we try to take thread dumps by using the command jstack.exe pid > output file The problem is that the output of this command is not same always. Below are...

can port of a cq instance be set in terminal

their is an option for setting run mode of a CQ Instance directly in terminal viz -Dsling.run.modes=${CQ_RUNMODE} is their a similar option for changing the port as well. I'm basically looking for a solution to keep changing name of CQ jar for a new instance. Thanks