Hi Readers,
Here you may comment all the questions/ doubts which you encountered during your journey for AEM. I will try my best to help you out and might connect with you to solve them too.
Also you may post interesting questions which you went through during your respective interviews , and I will try to answer them and thereby increase the Question Bank for masses.
So go ahead and post the questions !!
Thanks a lot .
Hashim
Hi Hashim,
what is a difference between sevice and a component in osgi ?
LikeLike
Hi Karan,
As far as Spring Annotations are concerned, it is specified in Spring Documentation very clearly that: Spring 2.5 introduces further stereotype annotations: @Component, @Service, and @Controller. @Component is a generic stereotype for any Spring-managed component. @Repository, @Service, and @Controller are specializations of @Component for more specific use cases, for example, in the persistence, service, and presentation layers, respectively.
Therefore, you can annotate your component classes with @Component, but by annotating them with @Repository, @Service, or @Controller instead, your classes are more properly suited for processing by tools or associating with aspects. For example, these stereotype annotations make ideal targets for pointcuts.
Thus, if you are choosing between using @Component or @Service for your service layer, @Service is clearly the better choice. Similarly, as stated above, @Repository is already supported as a marker for automatic exception translation in your persistence layer.
In terms of Aspect Oriented Programming:
@Component – Indicates a auto scan component.
@Repository – Indicates DAO component in the persistence layer.
@Service – Indicates a Service component in the business layer.
@Controller – Indicates a controller component in the presentation layer.
Now the question comes what will happen if I write my Business logic , just using @Component. It will work definitely , but not a good practice and would lead to bad code . Moreover it will behave the same , but one aspect is that they wont be able to catch some specific exception related to DAO instead of Repository if we use @component or @ service.
Moreover you might not be able to inject your Class component if @Service is not present as an annotation. (Note- Dependency Injection- usage of @Reference could be done only in classes defined as @Component and not simply Classes. )
So its always advisable to respect the convention and use them in line with layers.
I hope that answers the question.
LikeLike
Hi Hasim,
When we remove all annotations from a class then it will behave as normal java class???
LikeLiked by 1 person
Yes Purnima,
It will behave as a normal Java class. Infact with the annotations too all the properties of a Java class would be there.
LikeLike
Hi Karansheel,
Thanks for your questions.
1. Why questions is existing: In practical we need to identify them when design and implement.
2. Answer:
– All objects managed by OSGi container are components. You qualify components as services. This means that all services are components but not vice-versa.
– Components can refer/call (using container injection – @Reference) other services but not components.
– In other words, a component cannot be injected into another component / service. Only services can be injected into another component. Remember that a component can refer other services.
Regards,
Hung Vu
LikeLiked by 1 person
hi Hasim,
Me preparing for AEM 6.0 Certification.
Can you please tell which areas to concentrate on.
LikeLike
Hi Aman,
I would suggest you to go the blog entry https://hashimkhan.in/certification-question-bank/cq-6-0/ and give a read of ALL the questions that I had posted. This would give you an idea of the type of questions which could be asked. And if you would closely notice, while stating the answers , I have posted links for the topics been discussed there. You MUST be reading those topics thoroughly , because that is the target area where your exam will be concentrated.
Moreover, after your are done with CQ-6.0 question bank, make sure you practice CQ5.6 question bank too, as there will be a lot of questions which would be similar.
If you are well equipped with the questions and related topics I have mentioned in my blog. You will be definitely through the exam.
All the best.
LikeLiked by 1 person
Hi Hashim,
I 6.0 Question Bank Question 15,you gave answer as1)NoSample Content
But OOB is provided is provided with Sample Content Like Geometrixx Sites.
Can you guide me on this.
LikeLiked by 1 person
Hi Aman,
Yes Aman, you are right, but if you will closely look on the options you will not find the correct ones present there. Nosamplecontent would be the case when you will install your publish environment on an actual CQ project, where you might not need any of the Geometrixx pages. I would suggest to be clear with the concept and just verify the options once before making a choice. The options might somewhat differ.
Regards
Hashim
LikeLiked by 1 person
hi Hashim,
Working on Reading RSS Feed Xml with a Schedular and displaying it on a Tab Panel periodically.
Can you please let me know the design approach for this.
Will this Schedular be a part of my OSGI bundle or it wil be a Stand alone jar.
LikeLike
Hi Aman,
As far as I understood from the description of your problem, you have to consume an RSS feed XML data and read/store that data in nodes in JCR, so that you may use it for displaying in Tab Panel. I assume the RSS feed changes in some defined period only (if its dynamic and changes frequently dont choose schedular. )
So the first step would be to pick an appropriate XML parser ( Use this link : http://www.javacodegeeks.com/2013/05/parsing-xml-using-dom-sax-and-stax-parser-in-java.html ) and create node structures in your JCR (or fill the properties of your component ). So everytime that specific node should have data. There should not be a lag in that. Then use that node properties to read and display as per need.
One important thing to note is that once you are updating the nodes via schedular, none of the property should be blank. So to overcome this use something like–
Before schedular : node1 (this node has updated RSS feed data).
Schedular is ON : node1 ; tempnode1 (tempnode should be used to update RSS feed data)
Schedular completed : delete node1 and rename tempnode1 to node1.
Follow this approach to minimize the effect of updating RSS feed data dynamically.
You may use it in your OSGi bundle itself, no need for a standalone jar.
I hope this answer the question.
Regards
Hashim
LikeLiked by 1 person
Hi Hashim,
How will search for a configuration in repository?
a. PID
b. Component.id
c. component.name
d. none
The answer to this question according to me should be PID as it is the unique Id.
Can you please confirm what would be the right answer and why.
Thanks
Anish
LikeLike
Yes thats correct way to do so. eg.
select * from nt:base where jcr:path like ‘/apps/%’ and contains(*, ‘org.apache.felix.webconsole.internal.servlet.OsgiManager’) .
Here PID is org.apache.felix.webconsole.internal.servlet.OsgiManager .
Regards
Hashim
LikeLike
Hi Hashim,
when i open the question bank for AEM 6.0 certification Exam its asking the password could u pls tell me how to get the password .
LikeLike
Hi,
Please read https://hashimkhan.in/aem-adobecq5-certification-question-bank/cq-6-0/ to get the access code. I will mail them to you if you post your mail id there.
Regards
Hashim
LikeLike
Hi Hashim,
I have some questions as below: (CQ6 exam)
1/Choose 3 jar files which install publish instance successfully
a- cq5-publish-p4502.jar
b- cq5-publish-4502.jar
c- crxquickstart-publish-4502.jar
d- another one
2/What is valid mode out-of-box used in CQ?
+ production
+ activate
+ nosamplecontent
+ other option
What is your answer for these questions?
LikeLike
Hi,
1. There are a few rules which define naming convention for a jar. You may refer http://docs.adobe.com/docs/en/cq/5-5/deploying/installing_cq.html
+When you rename the file, it must start with cq; as in cq5-publish-p4503.jar.
+It is recommended that you always prefix the port number with -p; as in cq5-publish-p4503.jar or cq5-author-p6754.jar.
+the port number must be 4 or 5 digits
+these digits must come after a dash
+if there are any other digits in the filename, then the port number must be prefixed with -p
the “cq5” prefix at the beginning of the filename is ignored
So according to them only option a is correct.
2. Answer is nosamplecontent.
Regards
Hashim
LikeLike
Could you please update these questions to your question bank for CQ6.
Because this is real question that I got from CQ6 exam.
Thanks
LikeLike
Yes sure…right away (Q15 and Q45)..Thanks :)
LikeLike
Hi Hashim,
I installed publish instance using “cq5‑publish‑4502.jar” file name and it started properly as publish instance. I guess even “b” option is correct for 1st question. Can you please check once and confirm? Also, can you please share your personal email id?
Thanks and Regards
LikeLike
Hi Mohan,
Actually these naming conventions were strictly followed with versions (less than) <6.0 . They have changed them recently and hence the confusion.
You may test the priority and answer accordingly.
Regards
Hashim
LikeLike
Hi Hashim,
Which two following URLs show logs?
a- http://localhost:4502/system/console/status-slinglogs
b- http://localhost:4502/system/console/logs
c- others
This is a multiple choice question.
Thanks
LikeLike
Hi Hashim,
Which two following URLs show logs?
a- http://localhost:4502/system/console/status-slinglogs
b- http://localhost:4502/system/console/logs
c- others
I have confuse about options a and b. May be this is a multiple choice question.
Thanks
LikeLike
Hi ,
Something similar is mentioned in Q19 https://hashimkhan.in/aem-adobecq5-certification-question-bank/cq-6-0-question-set/ . For checking logs you may use
+ /bin/crxde/logs
+ http://localhost:4502/system/console/slinglog
Please read http://dev.day.com/docs/en/cq/current/deploying/configure_logging.html for details.
Regards
Hashim
LikeLike
Hi Hashim,
Could you please take a look on my answer for question below?
4. In junit dependency xyz I want to use version greater than or equal to 3.8 –
a. (3.8)
b. (3.8]
c. [3.8]
d. [3.8,)</version
My Answer id: d
LikeLike
Hi,
Yes thats correct . You may read the syntax from this link. Read More
Regards
Hashim
LikeLike
Hi Hashim,
5. What is vault merge/resolve command will do? –
a. Will resolve conflict semantically
b. Will remove resolve conflict
c. Will keep resolve conflict
d. Will resolve conflict related artifact files
I have concerned about these options a and d. Could you please tell me what is the final answer?
LikeLike
Hi, The answer to this question is D, as mentioned in the link http://docs.adobe.com/docs/en/crx/2-3/how_to/how_to_use_the_vlttool.html . Its wriiten there that “This command does not semantically resolve conflicts or remove conflict markers; it merely removes the conflict-related artifact files and allows PATH to be committed again.”
Regards
Hashim
LikeLike
Hi Hashim,
Could you please review my answer for question below?
12. Felix config is modified at three locations, which one is applied at runtime
a. Apps
b. Libs
c. Felix
d. None
My Answer: a
LikeLike
Hi,
The answer for this is (c)Felix. They were asking about the precedence order for changing the configurations at runtime. Please read the Link thoroughly .
Going forward please read the links I have mentioned along with each and every question . This would help you to clarify the answers yourself and would prepare you for the situation when a twisted question is asked .
Regards
Hashim
LikeLike
Hi Hashim,
Could you please confirm my answer for question below?
13. After making changes in OGSi config how to make changes effective
a. Restart the server
b. Restart the bundle
c. Nothing is required
d. Start stop the bundle
My Answer : C
Thanks
LikeLike
Hi,
Yes thats correct. I have already shared a link for this http://docs.adobe.com/docs/en/cq/5-5/deploying/configuring_cq.html Please read it completely.
Regards
Hashim
LikeLike
Hi Hashim,
37. How do you specify the osgi config of a java class in Publish runmode?
a. (Node Location) /apps/system/config/org.apache.felix.webconsole.internal.servlet.OsgiManager jcr:primary type= sling:osgiConfig
b. /apps/system/config/org.apache.felix.webconsole.internal.servlet.OsgiManager.config
jcr:primary type= sling:osgiConfig
c./apps/system/config/org.apache.felix.webconsole.internal.servlet.OsgiManager.config
jcr:primary type= nt:file
d./apps/system/config/org.apache.felix.webconsole.internal.servlet.OsgiManager.properties
jcr:primary type= nt:file
–> The answer is C.
Could you please review my answer for question below?
Thanks,
Thao
LikeLike
Hi,
The Answer should be A. /apps/system/config/org.apache.felix.webconsole.internal.servlet.OsgiManager jcr:primary type= sling:OsgiConfig
Please read Link for better understanding.
Thanks
Hashim
LikeLike
Answer should be both A & C.
Refer https://docs.adobe.com/docs/en/aem/6-1/deploy/configuring/configuring-osgi.html#Resolution Order at Startup
LikeLike
I think tthe answer is actually A,B,C as all these options are working fine.
LikeLike
Hi Hashim,
I can not access to CQ6 question bank page. It shows me that “The page not found”.
Could you please help me to double check it?
Thanks
LikeLike
Hi, Yes the pages are down now .
Regards
Hashim
LikeLike
HI thao , The answer has to be between A and B , because the question mentions that it is a OSGI config . OSGI config can have as their jcr:primarytype ONLY sling:OsgiConfig . That effectively rules out C and D. Not really sure in A and B. Please remember these questions are not exact and are memory based. So , they can have some ambiguities.
LikeLiked by 1 person
Also , in the paper you have questions in which you have to select multiple answers. This can be one of those questions . Because here both A and B appear to be correct.
LikeLike
Thanks for your support :)!
LikeLiked by 1 person
Hi
according to the question 72 of the cq5.6 exams
QUESTION 72
Which statement about the docroot paramter in the cache section of the CQ Dispatcher configuration file is true?
A. It should be the same path where the CQ server is installed.
B. It is required to be the same as the document root of the Web server.
C. It can be any path inside the filesystem that can be modified by the Web server.
D. It should be the same as the one configured in the repository as docroot property.
you wrote that the right answer is C
The question is that on the Adobe documentation is written that
“The value must be the exact same path as the document root of the web server so that Dispatcher and the web server handle the same files.”
What do you think?
thanks
LikeLike
Hi , Yes you are correct. Option B should be the answer.
Regards
Hashim
LikeLike
Hi Hashim,
Please help me review the answer of the below question.
6. When installing dispatcher on IIS server Which Application D Feature is required to configure AEM dispatcher? –
a. ISAPI Filter
b. ISAPI Extension
c. CGI
–> The answer is A
Thanks,
Thao Nguyen
LikeLike
Hi,
The Answer for this question should be B. Please lookfor “required” in the link https://docs.adobe.com/docs/en/dispatcher/disp-install.html
Regards
Hashim
LikeLike
Thank Hashim!
LikeLike
Hi Hashim,
I saw that in the question lists with question 17, you provide the answer is A. You can explain more details for me. Because I think that with this question, A and D are correct.
17. Which log contains startup related info? –
a. Stdout
b. Error
c. Audit log
d. Stderr log
Answer- a
Thanks,
Thao Nguyen
LikeLike
Hi,
They are only seeking logs which are used in startup .Option A is correct. Please refer to the link: http://docs.adobe.com/docs/en/cq/5-6-1/deploying/monitoring_and_maintaining.html#Working%20with%20Audit%20Records%20and%20Log%20Files
Regards
Hashim
LikeLike
Hi Hashim,
Could you please add question 28, 29, and 38 into the question list?
Thanks,
Thao Nguyen
LikeLike
Hi Hashim,
44.) How will you apply the new configuration while creating it from crxde ?
a. Restart CQ instance
b. Do nothing, changes applied automatically.
c. Restart the service once.
d. Save ALL and changes will apply.
–> The answer is D
After I read the link:
http://docs.adobe.com/docs/en/cq/current/deploying/configuring_osgi.html#Adding a New Configuration to the Repository. I think D is correct answer. Could you please confirm and give me your feedback?
Thanks,
Thao Nguyen
LikeLike
Yes thats correct.
LikeLike
Hi Hashim,
The link that Thao mentioned says that the service should be restarted.
Does the service restart as soon as it is saved?
If not then the ans should be ‘c’.
Can you please provide your feedback?
LikeLike
Hey Hashim, did you take down the page for the adobe 6.0 sample question set. Could you please let me know how can I prepare for the exams alternatively. Thanks for the help.
LikeLike
Hi James,
Yes I removed the pages for now. You may refer to the links I have shared at https://hashimkhan.in/aem-adobecq5-certification-question-bank/cq-6-0/ . Also you can read a few questions at https://hashimkhan.in/ask-me/ . All the best.
Regards
Hashim
LikeLike
Hi Hashim,
Could you please add question 28, 29, and 38 into the question list? I saw that they are missing in the question list.
Please help me on the below question:
41. If we want to revert the default parsys functionality, i.e., order in which components are displayed.(choose 2 options)
a)write from scratch
b)create parsys component, give sling:resourceType as /libs/foundation/… and make changes in jsp
c) copy required jsps from foundation into /apps/myproject and make changes
d) copy entire parsys related code and make change to applicable jsps
Could you please explain more details?
Thanks,
Thao Nguyen
LikeLike
Hi,
To override the default functionality of parsys component, you may proceed as follows:
1.Create a new parsys component under /apps//components/content/parsys and apply sling:resourceType=foundation/components/parsys, modify the JSP as applicable.
2.Copy the parsys component and all its contents from /libs/foudation/components/parsys to /apps/foundation/components/parsys and modifty the applicable jsps
The options might be having different language , but the crux solution is above.
Regards
Hashim
LikeLike
Hi Hashim,
40/ If we start AEM server in debugger mode what will happen?
a. It will fork a child process for sure.
b. It will not fork any child process.
My Answer: A
2/ in the sling.property file run mode is set to publish whereas in the command line run mode is given as below Java -r author. Which run mode will apply author or publish?
a. publish
b. author
c. None
d. both
My Answer: A
Could you please review these questions?
Thanks,
Huy Do
LikeLike
Hi ,
Please read the below links :
1. http://docs.adobe.com/docs/en/cq/current/getting_started/download_and_startworking.html#Further%20options%20available%20from%20the%20Quickstart%20file
http://blogs.adobe.com/dmcmahon/2012/03/09/cq5-5-how-to-start-the-server-in-debug-mode/
In general, when you execute a process, you must first fork() and then exec(). Forking creates a child process by duplicating the current process. Then, you call exec() to change the “process image” to a new “process image”, essentially executing different code within the child process. In general, this is how you create new processes to execute other programs / scripts.
2. http://helpx.adobe.com/experience-manager/kb/RunModeSetUp.html Yes ‘publish’ is correct .
Regards
Hashim
LikeLike
Hi Hashim,
35. IIS dispatcher is installed in C:/inetpub. Site root is /content/www/mysite. A page/content/www/mysite/mypage and the dispatcher flush agent is not configured? What should be done to get the latest my page?
a. Go and delete the physical path of cache
b. Do nothing
My Answer is : A
Could you please review my answer?
Thank,
Huy Do
LikeLike
Hi DOQUANG HUY ,
In the exam , the options won’t be as simple as ” Go and delete the physical path of cache ” since that is not how this exam works. There will be 4 options , and 3 of them were suggesting the path of the cached file. SO the correct answer would be and then the path of the page . This siteroot will be given in the question . So all in all , this question is testing , your knowledge about the correct path of cache , that where will the cache be saved .
LikeLiked by 1 person
Also , please go through this link
https://docs.adobe.com/docs/en/dispatcher/disp-install.html
LikeLike
Hi Hashim,
About question 35:
IIS dispatcher is installed in c:/inetpub. Site root is /content/www/mysite. A page /content/www/mysite/mypage and the dispatcher flush agent is not configured? What should be done to get the latest mypage?
a.Go and delete the physical path of cache.
b. Do nothing
–> I think that we will delete /content/www/mysite/mypage . Could you please give me your feedback?
Thanks,
Thao Nguyen
LikeLiked by 1 person
Hi Thao ,
Since dispatcher agent is NOT configured , therefore cache will not automatically get updated and therefore you will HAVE to delete the relevant cached page at the location in which it is cached. . 3 of the 4 options were suggesting to delete the cached files at a particular location . So , the right answer will be the ,
“C:\inetpub\wwwroot. ” OR the DOCUMENTROOT mentioned , and then the path of the relevant page .
The Dispatcher places the cached documents in the document root of the web server.
“C:\inetpub\wwwroot.” – this path is typically used as the path where cache is saved . So be careful while selecting the options .
P.S- Here your answer is right .
LikeLike
Also , please go through this link
https://docs.adobe.com/docs/en/dispatcher/disp-install.html
LikeLike
ratna1.kumar@gmail.com..Please send me the complete list.. Thanks, Ratna Kumar.
LikeLike
Hi ,
You may refer to the links I have shared at https://hashimkhan.in/aem-adobecq5-certification-question-bank/cq-6-0/ and https://hashimkhan.in/aem-adobecq5-certification-question-bank/cq-5-6/. Also you can read a few questions at https://hashimkhan.in/ask-me/ .
This is the complete list.
All the best.
Regards
Hashim
LikeLike
Hi Hashim,
I want to create a listener which could hide and show a multifield on clicking a checkbox.
I have got till getting the value of checkbox but not able to hide the multifield.
Can you help on that?
LikeLike
Hi Sanjana , Please elaborate more on this query . As, to what is the error ?
The ideal way to write a dialog listener is
1 : First identify the event , in which you want your listener to be called .
In this case , I believe you would want one on ‘selectionchanged ‘ since your use case suggests that on the change of this value(checked/not checked) , you want multifield to
be shown/hidden
2 : Now , since you have identified your event , you can go ahead and write the simplest code possible , just to check if its working fine or not .
Here is the code that will work for you :
function(comp, val, isChecked) {alert("hi world");
var panel = comp.findParentByType("panel"); //find the parent panel container
var multifield= panel.getComponent("multifield"); //find the component with itemId rdg
/*hide or show component based on checked value */
isChecked ? multifield.hide() : multifield.show();
}
LikeLiked by 1 person
Also , you can use this link . It works perfectly
http://stackoverflow.com/questions/22868253/in-cq5-widget-hide-and-show-based-on-checkbox-in-dialog
LikeLike
hi Hasim,
when i deploy the bundle i am getting these errors 1. org.apache.http Cannot be resolved 2. org.apache.http.client.methods Cannot be resolved 3. org.apache.http.impl.client Cannot be resolved how to resolve this error can please suggest how to fix this.
Manually i deployed the bundle in felix console. i hv also added httpclient-4.0.2 & httpcore-4.3.2 to the buildpath but still its not working
LikeLike
Hi Dillip ,
I am assuming that you uploaded a bundle in CQ and when you opened it in (http://localhost:4502/system/console/bundles) , in the ‘import packages ‘
you could see this error .
This error normally occurs when you don’t have a specific dependency added in your pom.xml which will download the respective JAR.
Most probably you will have to add the dependancy in your pom.xml
( in the folder in which these are being used ) .
This is done so that the related jars can be downloaded by maven .
In this case as we have 3 unresolved packages
1 : org.apache.http
2 : org.apache.http.client.methods
3 : org.apache.http.impl.client
Now , The dependancy that corresponds to them is
org.apache.httpcomponents
httpclient
4.4.1
Please add this in your pom.xml of the module where you are getting an error
But even after adding them , and including these package definitions in our ‘Import package’ , (when I tried on my local system) , I could still see the error
Error : org.apache.http – not resolved .
But , I could see the downloaded JARs in my repository ( c:> users > m2 > repository ) !
So , what we need to change is the ‘import package ‘ definition . Since these 3 imports have one thing in common ‘org.apache.http’
we can directly include all three with one statement ‘org.apache.http.*’
and VOLA ! It should work then.(it worked on my local machine )
This is my import package statement .
org.apache.http.*,
*;resolution:=optional
Also , I referred to this link , which says that ‘org.apache.http.client.methods’ is a part of a particular jar file which we downloaded through the dependancy.
http://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient/4.4.1
LikeLiked by 1 person
the dependency tag and the import package tag are not visible here(wordpress) ..please check out the link for the exact dependency
.http://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient/4.4.1
LikeLike
Hi Hashim,
Suppose there are multiple pages[in millions] and each one of them have four custom properties[repeating] in it.
The values present in those properties have to be replaced with corresponding new values.
Can you please let us know, if this can be done via Groovy script.
Your thoughts/inputs will be very much helpful.
LikeLike
Hi ,
I tried replicating your problem statement , in my local machine . Turns out , you can modify the value of any number of pages that you want . Properties can be iterated as well . Hashim has also addressed , sort of this situation in his Groovy Script Blog page . Please go through it also .
My content hierarchy is as follows
/content/groovy
/content/groovy/rahipagetest
/content/groovy/rahipagetest/grrovypage1
/content/groovy/rahipagetest/groovypage2
Each of the pages (groovypag1 and groovypage2 have two properties based on which , they have to be searched.The two properties are ‘property1’ and ‘property2 ‘ . All , the pages , who have both these properties will be displayed.
Step 1 : Run a query for retrieving the results that you want
query > select * from nt:base where property1 IS NOT null AND property2 IS NOT NULL
# you can of course modify the query as you want , I am just giving you a prototype.
Step 2 : you will get the results in the form of query results ( as we get , when we write the same code in java ) , So extract the results in NODES form . You have to extract in node form , so that it is easier for you to set a property in it using JCR API
Step 3 : Set the desired property . (Since, my query said that the page should have both ‘property1’ and ‘property2 ‘ as their properties , therefore I am not including a
JCR check of ‘hasproperty’
Step 4 : Save the session ! This is highly important , because you may bedoing everything right , but if you dont save your session , you will never see the results.
Done !
This is the sample code that I used in my machine to set the properties to something else. Here property is set to TEST and property2 is set to GROOVY .
Check the results on your page ‘/content/groovy/rahipagetest/grrovypage1/jcr:content’ .
———————————————————————————————————–
import javax.jcr.query.*
import com.day.cq.dam.api.*
import javax.jcr.*
import org.apache.sling.api.resource.*
/** Define the content hierarchy*/
final def page = getPage(‘/content/groovy’)
//Step 1
/*This method is used to Query the JCR and find results as per the Query.*/
def buildQuery() {
def queryManager = session.workspace.queryManager;
def statement = ‘select * from nt:base where property1 IS NOT null AND property2 IS NOT NULL’;
queryManager.createQuery(statement, ‘sql’);
}
//Step 2
/* Property which is searched in the content hierarchy */
final def query = buildQuery();
final def result = query.execute()
/* Get the rows in the form of nodes*/
def rows = result.nodes
rows.each { row ->
println row.path
row.set(‘property1′,’TEST’); //setting the property
row.set(‘property2′,’GROOVY’); //setting the property
/**just tocheck in your local instance if it is set or not**/
println row.get(‘property1’);
println row.get(‘property2’);
session.save() //Step 4
}
————————————————————————————————————
LikeLike
Hi,
Thanks a ton for your reply.
Will try it out with the same page structure on my local instance.
LikeLike
Hi,
It seems to be working absolutely fine. Thanks a lot.
I had mentioned the below in my earlier post :
“Each one of them have four custom properties[repeating] in it.
The values present in those properties have to be replaced with corresponding new values”
Sorry for not being very clear.
Explaining the situation in detail as below :
– Multiple pages are present with four custom properties[(custom1,custom2,custom3,custom4) single valued or repeating].
– We have a well defined mapping[old values to be replaced with new values] mentioned as below. For example :
Oldpropertyvalue Newpropertyvalue
oldvalue1 newvalue1
oldvalue2 newvalue2
oldvalue3 newvalue3
oldvalue4 newvalue4
oldvalue5 newvalue5
oldvalue6 newvalue6
and so on……
– The “Oldpropertyvalue” values may or may not be present in all the four custom property in the pages.Probably they might appear in one or two or three or all the four.
– Where ever it is present, it has to be replaced with the new values.
I am not getting as to how is this to be done. Your inputs/code snippet would be very much required.
LikeLike
Hi ,
I gave you a prototype of the code. Now , you can improvise it as per your will .
1 : If my understanding is correct , you are referring to the jcr properties of the page ie . which are displayed in the console when we click on the jcr:content node of the page . If this is the case , then in the same page , properties can not be repeated. They are unique .
If it is the JCR properties , then the code that I have provided will work fine , as I have listed for two properties , you can do the same for four and improvise as per you requirement .
LikeLike
Hi,
Thanks a lot for your reply. Sorry, the length of the post got bit big[tried to minimize it as much as possible]
– Yes, I am referring to jcr properties of the page i.e, if I go to the page in crx explorer and then click on jcr:content of the page I see those custom properties[custom1,custom2,custom3,custom4].
– The custom properties are of type String[].
– These custom properties[may be all or some of them] have some values assigned to them, may be something like
custom1:oldvalue1,oldvalue2,someothervalue
custom2:oldvalue3,oldvalue4
custom3:oldvalue5,oldvalue6,someothervalue
custom4:someothervalue
There is a corresponding mapping[for values to be replaced] as below :
oldvalues newvalues
oldvalue1 newvalue1
oldvalue2 newvalue2
oldvalue3 newvalue3
oldvalue4 newvalue4
and so on….
The OUTPUT should be something like
custom1:newvalue1,newvalue2,someothervalue
custom2:newvalue3,newvalue4
custom3:newvalue5,newvalue6,someothervalue
custom4:someothervalue
From what I understand is
– When you mentioned “then in the same page , properties can not be repeated”, it means oldvalue1 can appear only in custom1 and not in custom1 & custom2 & custom3 & custom4, correct?
– Also, based on the basic code you have provided I should be able to make necessary changes and the code should be able to achieve this objective,correct?
– Will definitely try my best possible and post back my results.
LikeLike
Oh , you meant multi-valued properties. Again , for that its a simple code, I have modified the existing code to set the multivalued properties. Please be carefull and improvise it as per your business requirement.
Now , I added an extra property3 which is of type String Array and enetered some test values in it (1,2,3). . So to set it in groovy with your new properties , I first included the new values in arrStr (like an object) and then , these new values were set into property3.
Hope this helps :)
I took help from this document .
http://code.citytechinc.com/aem-groovy-extension/groovydocs/com/citytechinc/aem/groovy/extension/services/impl/DefaultMetaClassExtensionProvider.html
——————————————————————————————————————
import javax.jcr.query.*
import com.day.cq.dam.api.*
import javax.jcr.*
import org.apache.sling.api.resource.*
/** Define the content hierarchy*/
final def page = getPage(‘/content/groovy’)
//Step 1
/*This method is used to Query the JCR and find results as per the Query.*/
def buildQuery() {
def queryManager = session.workspace.queryManager;
def statement = ‘select * from nt:base where test IS NOT null AND groovy IS NOT NULL’;
queryManager.createQuery(statement, ‘sql’);
}
//Step 2
/* Property which is searched in the content hierarchy */
final def query = buildQuery();
final def result = query.execute()
/* Get the rows in the form of nodes*/
def rows = result.nodes
Object[] arrStr = [‘Ananas’, ‘Banana’, ‘Kiwi’] //new array for property 3
rows.each { row ->
row.set(‘property3’,arrStr); //setting a multivalued property
row.set(‘property2′,’GROOVY’); //setting the property
/**just tocheck in your local instance if it is set or not**/
println row.get(‘property1’);
println row.get(‘property2’);
session.save() //Step 4
}
——————————————————————————————————–
LikeLike
Hi Hasim: On the following question:
1. I have created two nodes nt:unstructured inside the root folder and nt:folder inside the apps.Which node type would you be able to save ?
a. Exception is thrown and nothing is saved
b. Both
c. None
d. One, nt:folder
Answer- a
The doc says “a”, but actually both work fine when I test.
If I create a node nt:unstructured inside the root folder and also create a nt:folder inside the apps, then try to save, it works just fine.
There are cases where I understand an exception would be thrown but not in these two. Could you please let me know what am I seeing wrong?
Thanks.
LikeLike
Hi ,
The question , really at the most basic level , tests your knowledge about the different node types that are allowed within a specific node type . The point to remember is that
1- A nt:unstructured node CANNOT be created under the type ‘nt:folder’.Go ahead , try it, it’s not gonna happen ! But it can be created under folder .
2- If something cannot be saved , then any subsequent node created willalso not be saved , irrespective of the fact , that it’s allowed or not allowed.
Here
Actually , this question was seen in other forms also , and in this form .
For e.g. – > A node was created of the type ‘nt:unstructured’ inside the ‘apps’ folder . Another folder was created , under apps folder. After saving what will happen ?
So here , nothing will be saved and exception will be thrown. So remember that question can change its form . You have to grasp the knowledge hidden behind it .
Here , of course you are right . It will be saved , without any problems .
LikeLike
Thanks Fruitygirl06 :)
LikeLiked by 1 person
Apologies ,
the first point is actually
1- A nt:unstructured node CANNOT be created under the type ‘nt:folder’.Go ahead , try it, it’s not gonna happen ! But it can be created under ROOT FOLDER . ( ie. directly under ‘/’ ).
LikeLike
So, the answer is both (b) when we are creating nt:unstructured inside the root folder and nt:folder inside the apps?
LikeLike
Hi Hashim,
I have an issue with uploading images in CQ5.6. After I upload an image in damadmin, the status shows it triggered the workflow “DAM update asset” and stuck at step “continue updating?”. The image is finally available after a couple of hours… which is not ideal.
When I opened the workflow console, I could see quite a lot STALE instances (all related to DAM update asset) and a few RUNNING instances.
I wonder how I could improve this workflow process. Thanks in advance for any assistance you can provide.
Regards,
G
LikeLike
Hi Gary,
There is a workflow which gets triggered as soon as you upload an asset in AEM DAM. If you don’t want that workflow to be triggered automatically you can visit the workflow launcher console and disable the launcher for sometime. Then upload the images in DAM and trigger workflow manually for renditions when the server load is less.
Alternatively you can explore Webdav to upload your images into the CRX. You may follow this if the number of images is too huge. http://docs.adobe.com/docs/en/crx/2-3/how_to/webdav_access.html
Another approach could be to explore Workflow Purge, which will purge your instances after an interval of time periodically and would decrease the load on your server. https://helpx.adobe.com/experience-manager/kb/howtopurgewf.html
I hope these would help you sort of this problem. You may choose any of the approach as per your business need.
Kind Regards
Hashim
LikeLike
Hi Hasim: On the following question about AEM 6:
How do you specify the email config in Pusblish run mode, in aem?
Thanks.
LikeLike
Reformulating the question:
How do you specify the email config of a java class in Pusblish run mode, in aem?
Would be: /apps/system/config/org.apache.felix.webconsole.internal.servlet.EmailUpadate …
Thank a lot.
LikeLike
Hi Salamao ,
This question has multiple answers associated with it .
The key to answering this question is that
1 – For publish mode we can specify config.publish ( to make sure that this runs ONLY in publish
So , the option would contain config.publish in it’s path
2- The configuration should have a primary type of sling:OsgiConfig .
This question has two right answers . It has already been answered in this page . Foor further clarity please refer to the above questions .
LikeLike
Hi Hassim:
I have written a groovy script similar to yours; I got 4 pages and iterated down their trees looking for specific properties. I chose to recurse vs. iterate query result sets as the result sets were too large for memory. I am running this script OUTSIDE of the groovyconsole and it works but it is slow. Will there be a significant difference running from within the groovyconsole? I dont know why it is slow. Here is the process… I get 4 root nodes, loop down their trees and if the nodepath matches a regexp, I get modify a property in that node, modify it, then save in a batch based on batchcount…
def rootMap = [:]
rootMap.put(“SWATCHES”, getRootNode(queryManager, ‘swatches’).execute().nodes.nextNode())
rootMap.put(“SHOP”, getRootNode(queryManager, ‘shop’).execute().nodes.nextNode())
rootMap.put(“GROUPS”, getRootNode(queryManager, ‘groups’).execute().nodes.nextNode())
rootMap.put(“SKUS”, getRootNode(queryManager, ‘skus’).execute().nodes.nextNode())
//recursively process the root nodes, relinking images as you go
def results = []
rootMap.each{k, rootNode->
relinkImages(rootNode, file, session, saveCount, k)
}
Closure relinkImages
relinkImages = { node, file, session, saveCount, mode->
def nodePath = node.path
if (nodePath =~ /.*image.*/)
{
if (node.hasProperty(‘fileReference’))
{
node.setProperty(‘fileReference’, “${IMGREPLACEMENT}”)
….
//recurse through the children of the current node
node.nodes.each {childnode->
relinkImages(childnode, file, session, saveCount, mode)
}
…
Any ideas how to speed this up?
LikeLike
Hi Shelli,
I dont think there will be much difference within the groovy console too. The query seems quite heavy as it has 4 Queries along with recursive execution of each rootnode . If you may use direct queries for searching the imageNodes within the rootNodes instead of a recursive operation, it might reduce the time.
Moreover there should be a possibility to reduce the complete operation into a single Query Search instead of a 2 step operation. Let me know the actual business requirement , I would try it here myself.
Regards
Hashim
LikeLike
Hi Hashim,
I would like to do Certification on the CQ5, Currently am working as Publisher in CQ5.
Please suggest on which one will be the best for me to go ahead.
Thank you !
LikeLike
Hi Hashim,
Thanks for such a nice website on AEM. I like your blog structure and content.
I have one question on workflow.
1. I want to capture input(“Reason for request”) in textbox from the initiator when he starts the workflow. How can I do that?
2. I will be using that input in the later stage where I will send email to Approver along with “Reason for request”.
I am clear with 2(how to send email). can you please help with 1(User input capturing)
LikeLike
Hi,
There can be a few ways to implement the use case you are stating.
1. You may add an extra workflow step (first step on the workflow) , which might go directly to initiator. Use Dialog participant Step in this step and seek all the input you need from initiator. Further you may add the input in metadata and use them in subsequent steps.
2. In the Page itself, take the inputs from the initiator and add the data into the page jcr node. You can pick that data in any of the steps from the payload node. You may also give a button to the Initiator on the page and then on the click of a button, initiate the workflow via JAVA code.
3. You can ask initiators to add the input data directly into the arguments/comments of the workflow too. That can be retrieved in the further steps.
Regards
Hashim
LikeLike
Hi Hashim,
Can you please confirm the answer of below question
You want to prompt a workflow user for information during the processing of a workflow step. Where is the content that the workflow user entered stored?
A. As part of the page.
B. As part of the workflow model.
C. As part of the workflow instance.
D. As part of the design.
LikeLike
Hi Lalit,
I believe the answer for this should be A. You may refer to the article https://forums.adobe.com/thread/952372 for details.
More to add on this, there are two ways where data could be stored : at the jcr:content or in the metadata of a workflow.
LINK
Regards
Hashim
LikeLike
Hashim this is where I am confused a little bit. Maybe I am doing something wrong. So they mentioned that when you run a workflow with a participant step the data entered by user is stored at the payload location which would be a page if we choose to run a workflow on page. But when I created a dummy workflow with such config. Its data was stored in workflow instance. Not on the page which I choose as payload. Can you hep me to setup that you used to test this
LikeLike
Hi,
So the trick here is how to name the property in your dialog for which you seek a value. Follow the steps mentioned in this adobe docs link
Read This
Regards
Hashim
LikeLike
Thanks Hashim, Got what you meant now
LikeLike
Hi Hashim,
Can you please let me know the correct answer for the below question.
You have changed the CRX admin password. Which console or tool do you also need to update? A. CRXDE Lite B. CQSE Admin Console C. Apache Felix Web Console D. CQ User Administration Console
LikeLike
There are two places where you need to update
1-directly in the CRX crx.system workspace using the CRX Content Explorer
2-CRX Sling Client Repository via the Felix Management Console
So the answer is C
https://helpx.adobe.com/experience-manager/kb/ChangeAdminPwd.html
LikeLike
Hi Hashim,
May i know that how i get certification exams.. who will conduct them? How to register for that exam? and is there any institutes or books to learn CQ5?
LikeLike
Hi,
You may google about these things . Refer to the official link : http://training.adobe.com/certification/exams.html#p=1&solution=adobeExperienceManager
https://docs.adobe.com/docs/en/aem/6-0.html
https://docs.adobe.com/docs/en/cq/5-6-1.html
Regards
Hashim
LikeLike
Hi,
Can you please let me know the answer for the below.
Which property is deprecated while resolving a template (T) that can be used for page (P)
1] cq:allowedTemplates property of jcr:content subnode of P or an ancestor of P
2] allowedPaths property of T
3] allowedParents property of T
4] allowedChildren property of template of P
LikeLike
Answer is 2 allowedPaths
LikeLike
Hi,
Can you please let me know the answer for the below :
When installing IIS, which application development feature needs to be enabled to work with AEM dispatcher?
– ISAPI filters
– ISAPI extensions
– Server side includes
– CGI
LikeLike
Hi,
Can you please let me know the answer for the below :
You want to restrict the size of a custom log file and enable log file rotation. Which Apache sling configuration has to be changed in AEM web console?
– Apache sling composite health check
– Apache sling Job manager
– Apache sling logging logger configuration
– Apache sling logging writer configuration
LikeLike
Answer is -> Apache sling logging writer configuration
LikeLike
Hi,
Can you please let me know the answer for the below :
You are creating a new OSGI configuration in the repository. When are the configuration changes applied
– Changes are applied as soon as the node is updated by restarting the service.
– Immediately
– After restarting CQ instance
– By stopping and starting the bundle that refer the service.
LikeLike
the Allowed Path property has been deprecated
http://versatileankur.blogspot.in/2014/07/page-without-template-in-cq5.html
LikeLike
Hi there,
I would like to request help with AEM and chef automation, I am new to this chef automation. Any insights with respect to chef automation and AEM will be greatly appreciated.
And AEM deployment on EC2 if possible will be absolutely great.
Thanks in advance.
LikeLike
Hi,
I am not sure of Chef automation. Is it used for Build and Deploy? We generally use Jenkins as a Build and Deploy tool. The b elow links might be helpful for you
https://github.com/tacitknowledge/aem-cookbook
http://www.techinsight.io/review/adobe-experience-manager/aem-development-environment-on-windows/
http://blogs.adobe.com/experiencedelivers/experience-management/master-chef-class-learn-quickly-cook-delightful-cqaem-infrastructures/
Regards
Hashim
LikeLike
Hi Hashim,
True amoung client library?
1.Client library has primarytype value nt:folder
2.Client library should be defined under /etc/clientlibs/projectname
3.to incude css use
4.Day CQ HTML library manager service in felix is used to minify the generated css for better performance.
is it option 4?
Will system throws null poiner exception when using page.getTemplate.getPath() in publish mode?
which command is recommended to get template path in author and publish mode
1. page.getTemplate.getPath()
2. property.get(“cq:template”,””)
Thanks,
mani
LikeLike
Yes, the 4th is correct answer.
2nd option will give you the template.
These are basic questions, which you should be knowing if you are working on the tool. I dont find any use of memorizing the answers if you are not sure of the basics.
Please read the basics thoroughly before taking the test .
Regards
Hashim
LikeLike
Hi i have a problem can you tell me how fix it?
The pages are not getting open because org.apache.commons.lang3.StringUtils is not getting initialized. When i click on link it says server not found.
See the below logs for this. We are not importing this class also.
Caused by: org.apache.sling.api.SlingException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class org.apache.commons.lang3.StringUtils
LikeLike
Hi,
Its actually difficult to debug your problem without seeing a proper project structure. You should check whether this particular class has been included in your maven pom.xml . Also verify if there are specific dependencies regarding to this class.
You can also check whether the specific jar is getting downloaded in your .m2 folder.
This can be your starting points to debug it further.
Regards
Hashim
LikeLike
In staging publish when i click on a page it throws Server not found. when i check logs Caused by: org.apache.sling.api.SlingException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class org.apache.commons.lang3.StringUtils is showing. how to resolve it ..
LikeLike
I have given some pointers above. Please google more for why NoClassDef exception occurs.
Regards
Hashim
LikeLike
Hi Hashim,
I have written an EventListener to listen the events raised upon any property change for a DAM asset. The Listener is working fine but only the first time. When again event is raised, EventListener is not listening it. I need to restart the bundle everytime for it to work for me.
Can you suggest what am I missing here?
LikeLike
Hi ,
This shouldn’t be the case , if the code is correctly implemented. I cant comment exactly what is the issue here without seeing the code snippet. You can try to implement an existing Event Listener (from google) and then customize it according to your use case. Or else try to add Loggers in each of your methods and then debug the issue.
Regards
Hashim
LikeLike
Hi Hashim,
I am developing an aem 6.1 based application. I have an requirement for url map like currently my url for all the pages are like domainname.com/content/project/en_US/home.html, instead of such a big url i would like to trim this as domaniname.com/home.html .
Means i want to replace /content/project/en_US/ with / which is common across all the pages, is there a way to achieve this.
Thanks for help in advance.
LikeLike
Hi,
Thats a very common use case . You can use either etc/mapping for that based on your environment configurations Or you can do so using Apache Sling Resource Resolver Factory URL mappings. Read more below :
https://docs.adobe.com/docs/en/cq/5-6-1/deploying/resource_mapping.html
https://cwiki.apache.org/confluence/display/SLING/Flexible+Resource+Resolution
Regards
Hashim
LikeLike