1 Flashcards
A quickstart jar file needs to allow an AEM author instance to be installed on the localhost on port 6302.
What should this file be renamed before launching?
( ) cq-author-p4502.jar
( ) cq-author-x6302.jar
( ) cq-author-p6302.jar
( ) aem-p6302-author.jar
(+) cq-author-p6302.jar
AEM is installed in $AEM_HOME.
In which subfolder is the command line startup and shutdown scripts located?
( ) $AEM_HOME/crx-quickstart/bin/
( ) $AEM_HOME/crx-quickstart/opt/
( ) $AEM_HOME/crx-quickstart/scripts/
( ) $AEM_HOME/
(+) $AEM_HOME/crx-quickstart/bin/
For each CRX node in the hierarchy, which actions can be configured using the user admin interface?
( ) Read, Write, Delete, Edit ACL, Replicate
( ) Read, Modify, Create, Delete, Read ACL, Edit ACL, Replicate
( ) Read, Write, Read ACL, Edit ACL, Replicate
( ) Read, Modify, Create, Delete, Read ACL, Edit ACL
(+) Read, Modify, Create, Delete, Read ACL, Edit ACL, Replicate
See https://experienceleague.adobe.com/docs/experience-manager-64/administering/security/security.html?lang=en#permissions-in-aem
In which two ways can a developer keep simple and maintainable CRX Access Control Lists? (Choose two.)
( ) Assign access rights user by user
( ) Use Deny statements extensively
( ) Assign access rights to user groups rather than users
( ) Use Deny statements sparingly
( ) Delete the everyone group
(+) Assign access rights to user groups rather than users
(+) Use Deny statements sparingly
See https://experienceleague.adobe.com/docs/experience-manager-64/administering/security/security.html?lang=en#permission-states
An online insurance company website has user-generated content that must be replicated in all publish instances.
What action should the developer take to achieve this?
( ) Configure reverse replication agents for the author
( ) Disable static agent in the author instance
( ) Configure the replication agent in the publish instances
( ) Configure the dispatcher flush agent in publish instance
(+) Configure reverse replication agents for the author
Reverse replication is used to get user content generated on a publish instance back to an author instance. This is commonly used for features such as surveys and registration forms.
As the publish environment is usually in the DMZ, to get content back to the author environment THE CONNECTION MUST BE INITIATED FROM THE AUTHOR INSTANCE. This is done with:
- an outbox in the publish environment where the content is placed.
- an agent (publish) in the author environment which periodically polls the outbox for new content.
To do this you need:
- A reverse replication agent in the AUTHOR environment. This acts as the active component to collect information from the outbox in the publish environment:
- A reverse replication agent in the publish environment (an outbox) This is the passive element as it acts as an “outbox”. User input is placed here, from where it is collected by the agent in the author environment.
https://experienceleague.adobe.com/docs/experience-manager-64/deploying/configuring/replication.html?lang=en#configuring-reverse-replication
How should a developer configure the replication agent to flush the dispatcher cache for a newly activated page?
( ) Create a reverse replication agent on the author instance
( ) Set the serialization type property of the default agent to dispatcher flush
( ) Create a new replication agent and set transport URI to point to the dispatcher
( ) Create a dispatcher flush agent in publish instance
(+) Create a dispatcher flush agent in publish instance
Under certain circumstances, performance gains can be made by transferring cache management from the authoring environment to a publishing instance. It will then be the PUBLISHING environment (not the AEM authoring environment) that sends a cache invalidation request to Dispatcher when a published page is received.
Such circumstances include:
- Preventing possible timing conflicts between Dispatcher and the publish instance (see Invalidating Dispatcher cache from the Authoring Environment).
- The system includes several publishing instances that reside on high performance servers, and only one authoring instance.
The dispatcher flush is controlled by a replication AGENT operating on the PUBLISH instance. However, the configuration is made on the authoring environment and then transferred by activating the agent
After configuring, when you ACTIVATE a page FROM author TO publish, this agent (PUBLISH) initiates a standard replication. The log includes messages indicating requests coming from your publish server, similar to the following example:
13:29:47 127.0.0.1 POST /dispatcher/invalidate.cache 200
https://experienceleague.adobe.com/docs/experience-manager-64/deploying/configuring/replication.html?lang=en#configuring-a-dispatcher-flush-agent
https://experienceleague.adobe.com/docs/experience-manager-dispatcher/using/configuring/page-invalidate.html?lang=en#invalidating-dispatcher-cache-from-a-publishing-instance
A developer is monitoring the default replication agent on the author instance. The replication queue is blocked with a single item in it. The developer tests the connection, and the replication test is successful.
What is causing this issue?
( ) The replication agent has NOT been configured on the publish instance.
( ) The publish instance is offline.
( ) The replication user does NOT have permission to replicate the blocking item.
( ) The replication URI is incorrect.
(+) The replication user does NOT have permission to replicate the blocking item.
Two AEM publish instances feed a single Dispatcher.
Which part of the Dispatcher configuration should a developer review to ensure both AEM publish instances are used?
( ) cache
( ) filter
( ) farms
( ) virtualhosts
(+) farms
https://experienceleague.adobe.com/docs/experience-manager-dispatcher/using/configuring/dispatcher-configuration.html?lang=en#defining-farms-farms
Too many pages are invalidated in the dispatcher cache when a page is published.
What is most likely causing this issue in the dispatcher configuration?
( ) The level of cache invalidation is NOT appropriate for the published content model.
( ) The OS file system permissions are NOT properly configured.
( ) Sticky sessions are NOT configured properly, resulting in requests being delivered to the wrong server.
( ) File globbing in the dispatcher configuration is NOT correct.
(+) The level of cache invalidation is NOT appropriate for the published content model.
https://experienceleague.adobe.com/docs/experience-manager-dispatcher/using/configuring/dispatcher-configuration.html?lang=en#invalidating-files-by-folder-level
There are performance, stability, and security issues with an installed AEM instance
What should a developer do to fix these issues?
( ) Delete and reinstall the AEM instance
( ) Install Adobe-provided Apache configuration file
( ) Install service pack updates from package share
( ) Stop, clear cache files, and restart the AEM instance
(+) Install service pack updates from package share
A developer installs the latest Service pack to a local AEM author instance.
How should the developer install this package on the publish instance?
( ) Use upload/install from OSGI console of publish instance
( ) Replicate from package manager of author instance
( ) Use upload/install from OSGI console of author instance
( ) Replicate from package manager of publish instance
(+) Replicate from package manager of author instance
A developer needs to create a new component called “Component A”. Component A must show a list of other components that all have a resource type of existing “Component B”. Component A must render this list of tiles for each Component B where the tile rendering is different from the default one. The list of rendered tiles must be reusable by future new components.
How should the developer implement this functionality?
( ) Create a script for tile rendering in Component B and use data-sly-resource attribute with a Sling selector in Component A to render the tile.
( ) Component A overlays Component B and overwrites the base renderer to facilitate the tiles.
( ) Component A inherits from Component B and overwrites the base renderer to facilitate the tiles.
( ) Component A calls the HTL of Component B directly using a data-sly-include attribute.
(+) Create a script for tile rendering in Component B and use data-sly-resource attribute with a Sling selector in Component A to render the tile.
See -> https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#229-resource
The resourceType-option comes handy if you want to point to a different ‘component’ to render your node, other than the one specified via sling:resourceType on the node level.
<div></div>
renders the ‘foo’ node via the component specified at sling:resourceType
<div></div>
renders the ‘foo’ node via the component a/b/c/d
See -> https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/data-sly-resource-attributes/m-p/210945
A developer is working on a custom component with a configurable image. Authors configure this image through the component dialog by editing a field with the following attributes:
+ image
- autoStart=”{Boolean}false”
- class=”cq-droptarget”
- jcr:primaryType=”nt:unstructured”
- sling:resourceType=”cq/gui/components/authoring/dialog/fileupload”
- fileNameParameter=”./fileName”
- fileReferenceParameter=”./fileReference”
- mimeTypes=”[image/gif,image/jpeg,image/png,image/svg+xml,image/tiff,image/webp]”
- multiple=”{Boolean}false”
- name=”./file”
- title=”Image”
- uploadUrl=”${suffix.path}”
- useHTML5=”{Boolean}true”
Authors must be able to drag an image directly from the sidekick into the component to configure the image. The developer needs to add a drop target configuration to the component to meet this requirement.
Which drop target configuration should be used?
( ) + cq:dropTargets
+ image
- jcr:primaryType=”nt:unstructured”
- accept=”[image/gif,image/jpeg,image/png,image/svg+xml,image/tiff,image/webp]”
- groups=”[media]”
- propertyName=”./fileReference”
( ) + cq:dropTargets
+ image
- jcr:primaryType=”nt:unstructured”
- accept=”[image/gif,image/jpeg,image/png,image/svg+xml,image/tiff,image/webp]”
- groups=”[media]”
- propertyName=”./file”
( ) + cq:dropTargets
+ image
- jcr:primaryType=”nt:unstructured”
- accept=”[image/gif,image/jpeg,image/png,image/svg+xml,image/tiff,image/webp]”
- group=”media”
- propertyName=”./file”
( ) + cq:dropTargets
+ image
- jcr:primaryType=”nt:unstructured”
- accept=”[image/gif,image/jpeg,image/png,image/svg+xml,image/tiff,image/webp]”
- group=”media”
- propertyName=”./fileReference”
(+) + cq:dropTargets
+ image
- jcr:primaryType=”nt:unstructured”
- accept=”[image/gif,image/jpeg,image/png,image/svg+xml,image/tiff,image/webp]”
- groups=”[media]”
- propertyName=”./fileReference”
http://www.sgaemsolutions.com/2019/01/cqdroptagets-in-cqeditconfig-node-in-aem.html
A developer needs to create a component with the following requirements:
The component must be configurable
The component should be editable, NOT removable
An author should be unable to add the component to a page through design mode
Which node structure should the developer use to meet these requirements?
( ) + component
- jcr:primaryType=”cq:Component”
- jcr:title=”Component”
- cq:actions = “[edit]”
+ cq:dialog
…
( ) + component
- jcr:primaryType=”cq:Component”
- jcr:title=”Component”
- componentGroup=”.hidden”
+ cq:dialog
…
+ cq:editConfig
- cq:actions = “[edit]”
( ) + component
- jcr:primaryType=”cq:Component”
- jcr:title=”Component”
- componentGroup=”.hidden”
- cq:actions = “[edit]”
+ cq:dialog
…
( ) + component
- jcr:primaryType=”cq:Component”
- jcr:title=”Component”
- hidden=”true”
+ cq:dialog
…
+ cq:editConfig
- cq:actions = “[edit]”
(+) + component
- jcr:primaryType=”cq:Component”
- jcr:title=”Component”
- componentGroup=”.hidden”
+ cq:dialog
…
+ cq:editConfig
- cq:actions = “[edit]”
A developer creates a custom component. The component dialog includes the following two fields:
+ text
- jcr:primaryType=”nt:unstructured”
- sling:resourceType=”granite/ui/components/coral/foundation/form/textarea”
- fieldLabel=”Text”
- name=”./text”
+ charLimit
- jcr:primaryType=”nt:unstructured”
- sling:resourceType=”granite/ui/components/coral/foundation/form/numberfield”
- defaultValue=”0”
- fieldLabel=”Character Limit”
- name=”./charLimit”
The component should display the first ‘X’ characters of the text entered in the ‘text’ input, where ‘X’ is the number entered in the ‘charLimit’ input. If zero, or no value, is entered in the ‘charLimit’ input, then the text should be unaltered. The developer creates the following Sling Model to perform the truncation:
@Model(adaptables = SlingHttpServletRequest.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public class Truncation {
@ValueMapValue private String text; @ValueMapValue private Integer charLimit; @PostConstruct private void init() { if (text != null && 0 < charLimit && charLimit < text.length()) { text = text.substring(0, charLimit); } } public String getText() { return text; } }
A Null Pointer Exception occurs if NO charLimit value is set in the component dialog.
What should the developer do to resolve this issue?
( ) Replace the defaultValue=”0” attribute of the charLimit field in the dialog with defaultValue=”{Long}0”
( ) Add the @Default annotation to the charLimit variable in the Sling Model
( ) Replace the defaultValue=”0” attribute of the charLimit field in the dialog with min=”0”
( ) Change the defaultInjectionStrategy of the Truncation Sling Model to DefaultInjectionStrategy.REQUIRED
(+) Add the @Default annotation to the charLimit variable in the Sling Model
https://sling.apache.org/documentation/bundles/models.html#annotation-reference-1
A developer has a component foobar that consists of the files listed below:
script-a.js
“use strict”;
use(function () {
return “foo”;
});
script-b.js
“use strict”;
use(function () {
return “”;
});
foobar.html
<div>
<div></div>
<div></div>
<div></div>
<div></div></div>
What is the output when this component is rendered?
( ) <div>
<div class="bar"></div>
<div class="foo"></div>
<div></div>
<div class=""></div>
</div>
( ) <div>
<div class="foo"></div>
<div class="foo"></div>
<div class=""></div>
<div class="foo"></div>
</div>
( ) <div>
<div class="bar"></div>
<div class="bar"></div>
<div class="foo"></div>
<div class=""></div>
</div>
( ) <div>
<div class="bar"></div>
<div class="foo"></div>
<div></div>
<div></div>
</div>
(+) <div>
<div class="bar"></div>
<div class="foo"></div>
<div></div>
<div class=""></div>
</div>
https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#223-attribute
## Attributes are processed left-to-right:
foobar = {‘id’: ‘foo’, ‘class’: ‘bar’, ‘lang’: ‘’}
<div></div>
<div></div>
<div></div>
<div></div>
## Boolean values allow to control the display of boolean attributes:
## Arrays are cast to strings:
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
——————————————————————##Numbers are cast to strings (i.e. zero doesn’t remove the attribute):
<div></div>
<div></div>
## Note: Event handler attributes (on*) and the style attribute cannot be generated with data-sly-attribute due to the fact that none of the available display contexts can fully protect against XSS attacks given the range of values that these attributes can contain.
A developer is creating a custom component that shows a list of pages. For each page, the following items must be shown:
- Title of the page
- Description of the page
- A button with fixed text “Read more” that must be translatable
All of the above fields must be wrapped in a <div> tag.
The logic for obtaining the list of pages must be reusable for future components.
Which snippet should the developer use to meet these requirements?
( )
<div>
<p>${item.title}</p>
<p>${item.description}</p>
<a> ${“Read more” @ .translate} </a><a>
</a></div>
( )
<div>
<p>${page.title}</p>
<p>${page.description}</p>
<a>${“Read more” @ i18n} </a><a>
</a></div>
( )
<div>
<p>${model.title}</p>
<p>${model.description}</p>
<a>${“Read more” @ .translate} </a><a>
</a></div>
( )
<div>
<p>${item.title}</p>
<p>${item.description}</p>
<a>${“Read more” @ i18n} </a><a>
</a></div></div>
(+)
<div>
<p>${item.title}</p>
<p>${item.description}</p>
<a>${“Read more” @ i18n} </a><a>
</a></div>
https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#227-repeat
https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#123-i18n
##Repeats the content of the element for each item of the provided object (which can be an array, or any iterable object).
<p>${item.text}</p>
<p>${childResource.text}</p>
<div>${article.excerpt}</div>
<div>${article.excerpt}</div>
## An additional itemList (respectively List in case a custom identifier/variable was defined using data-sly-repeat.) identifier is also available within the scope, with the following members:
- index: zero-based counter (0..length-1);
- count: one-based counter (1..length);
- first: true for the first element being iterated;
- middle: true if element being iterated is neither the first nor the last;
- last: true for the last element being iterated;
- odd: true if count is odd;
- even: true if count is even.
##When iterating over Map objects, the item variable contains the key of each map item:
<p>
<span>key: ${item}</span>
<span>value: ${myMap[item]}</span>
</p>
A developer has a component named ‘foobar’ with the following file:
foobar.html
<div></div>
<div></div>
What is the output when the component is rendered?
( ) <div></div>
<div></div>
( ) <div></div>
<div></div>
( ) <div></div>
<div></div>
( ) <div></div>
<div></div>
Follows the same data-sly-attribute rules( https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#223-attribute)
(+) <div></div>
<div></div>
## Attributes are processed left-to-right:
foobar = {‘id’: ‘foo’, ‘class’: ‘bar’, ‘lang’: ‘’}
<div></div>
<div></div>
<div></div>
<div></div>
## Boolean values allow to control the display of boolean attributes:
## Arrays are cast to strings:
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
##Numbers are cast to strings (i.e. zero doesn’t remove the attribute):
<div></div>
<div></div>
## Note: Event handler attributes (on*) and the style attribute cannot be generated with data-sly-attribute due to the fact that none of the available display contexts can fully protect against XSS attacks given the range of values that these attributes can contain.p>
A developer needs to implement a header component for a website. The component has the following requirements:
- The component should be configured once on the page highest in the hierarchy.
- The header component on pages lower in the hierarchy should look the same and show the same data.
- If necessary, the configuration can be overwritten on a child page.
- The component should show a list of links that are configured in the header component.
Which code snippet for returning the list of pages should the developer use?
( ) public String[] getHeaderLinks(Page page) {
final Resource pageContent = page.getContentResource();
final ComponentInheritanceValueMap properties = new ComponentInheritanceValueMap(pageContent);
return properties.get(HEADER_PAGE_LIST, String[].class);
}
( ) public String[] getHeaderLinks(Resource componentResource) {
final HierarchyNodeInheritanceValueMap properties = componentResource.adaptTo(HierarchyNodeInheritanceValueMap.class);
return properties.get(HEADER_PAGE_LIST, String[].class);
}
( ) public String[] getHeaderLinks(Resource componentResource) {
final ComponentInheritanceValueMap properties = componentResource.adaptTo(ComponentInheritanceValueMap.class);
return properties.getInherited(HEADER_PAGE_LIST, String[].class);
}
( ) public String[] getHeaderLinks(Resource componentResource) {
final HierarchyNodeInheritanceValueMap properties = new HierarchyNodeInheritanceValueMap(componentResource);
return properties.getInherited(HEADER_PAGE_LIST, String[].class);
}
(+) public String[] getHeaderLinks(Resource componentResource) {
final HierarchyNodeInheritanceValueMap properties = new HierarchyNodeInheritanceValueMap(componentResource);
return properties.getInherited(HEADER_PAGE_LIST, String[].class);
}
https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/commons/inherit/HierarchyNodeInheritanceValueMap.html
https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/commons/inherit/ComponentInheritanceValueMap.html
## HierarchyNodeInheritanceValueMap
Note that HierarchyNodeInheritanceValueMap searches ONLY the PAGE hierarchy. It will NOT (for instance), look in:
/content/parent/page/jcr:content/footer/@width
See ComponentInheritanceValueMap for that functionality.
For example, given: /content/parent/page/jcr:content/footer/image/@width, the HierarchyNodeInheritanceValueMap will search for a footer/image/@width property in:
- /content/parent/page/jcr:content/footer/image/@width
- /content/parent/jcr:content/footer/image/@width
- /content/jcr:content/footer/image/@width
Having not found it in any of those locations, it will then return null.
## ComponentInheritanceValueMap
An InheritanceValueMap for a given Resource that will inherit values from ancestors up to its ancestral component, but no higher.
For example, given: /content/parent/page/jcr:content/footer/image/@width, the ComponentInheritanceValueMap will search for a width property in:
/content/parent/page/jcr:content/footer/image/@width
/content/parent/page/jcr:content/footer/@width
/content/parent/page/jcr:content/@width
Having not found it in any of those locations, it will then return null.
Note that ComponentInheritanceValueMap searches ONLY the COMPONENT hierarchy. It will NOT (for instance), look in:
/content/parent/jcr:content/footer/image/@width
See HierarchyNodeInheritanceValueMap for that functionality.
A developer is working on an HTL script for a custom component. The script has the following requirements:
- This script must list the title of every child page of the current page.
- If a child page does NOT have any children, then its title should link directly to that page.
- If a child page has children, then the title of every one of its children should be listed beneath its title.
- The title of every grandchild page should link directly to that page.
Which HTL script should the developer use to meet these requirements?
( ) <ul>
<li>
<b>${child.title}</b> <ul> <li> <a href="%24%7Bgrandchild.path%20@%20extension%20=%20'html'%7D">${grandchild.title}</a> </li> </ul> <a href="%24%7Bchild.path%20@%20extension%20=%20'html'%7D">${child.title}</a> </li> </ul>
( ) <ul>
<li>
<b>${child.title}</b> <ul> <li> <a href="%24%7Bgrandchild.path%20@%20extension%20=%20'html'%7D">${grandchild.title}</a> </li> </ul> <a href="%24%7Bchild.path%20@%20extension%20=%20'html'%7D">${child.title}</a> </li> </ul>
( ) <ul>
<li>
<b>${child.title}</b> <ul> <li> <a href="%24%7Bgrandchild.path%7D">${grandchild.title}</a> </li> </ul> <a href="%24%7Bchild.path%7D">${child.title}</a> </li> </ul>
( ) <ul>
<li>
<b>${child.title}</b> <ul> <li> <a href="%24%7Bgrandchild.path%7D">${grandchild.title}</a> </li> </ul> <a href="%24%7Bchild.path%7D">${child.title}</a> </li> </ul>
(+) <ul>
<li>
<b>${child.title}</b> <ul> <li> <a href="%24%7Bgrandchild.path%20@%20extension%20=%20'html'%7D">${grandchild.title}</a> </li> </ul> <a href="%24%7Bchild.path%20@%20extension%20=%20'html'%7D">${child.title}</a> </li> </ul>
–> See https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#225-test
–> See https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#125-uri-manipulation
–> See https://experienceleague.adobe.com/docs/experience-manager-htl/content/global-objects.html?lang=en
A developer has a component named ‘foobar’ with the following file:
FooBar.java
import com.adobe.cq.sightly.WCMUsePojo;
public class FooBar extends WCMUsePojo {
@Override public void activate() throws Exception {} public String getLink() { return "https://www.foo'bar.com"; } public String getText() { return "foo'bar"; } }
foobar.html
<div>
<a>
${fooBar.text}
</a>
</div>
What is the output when the component is rendered?
( ) <div>
<a>
foo’bar
</a>
</div>
( ) <div>
<a>
foo’bar
</a>
</div>
( ) <div>
<a>
foo’bar
</a>
</div>
( ) <div>
<a>
foo’bar
</a>
</div>
(+) <div>
<a>
foo’bar
</a>
</div>
https://experienceleague.adobe.com/docs/experience-manager-htl/content/getting-started.html?lang=en#automatic-context-aware-escaping
A developer is working with the following HTL expression in a component rendering script:
${‘path/page.infinity.json’ @ extension = ‘html’,
removeSelectors = [‘foo’],
selectors = [‘foo’, ‘bar’],
prependSuffix = ‘hello’,
suffix = ‘world’}
What is the expected output of this expression?
( ) path/page.bar.html/hello/world
( ) path/page.infinity.json.bar.html/world
( ) path/page.foo.bar.html/hello/world
( ) path/page.bar.html/world
(+) path/page.bar.html/hello/world
https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#125-uri-manipulation
## Note: It seems URI manipulation DOESN’T work like attributes (data-sly-attribute) which are processed from left to right. URI manipulation seems to apply all at once, concurrently
- selectors - MODIFIES OR REMOVES the selectors from a URI; the selectors are the URI segments between the part that identifies a resource (the resource’s path) and the extension used for representing the resource
- addSelectors - adds the provided selectors (selectors string or selectors array) to the URI
- removeSelectors - removes the provided selectors (selectors string or selectors array) from the URI
The developer is presented with a component “Component A” which inherits from a component “Component B”.
The dialog of Component A on path ../cq:dialog/../../items looks like:
+ align
- jcr:primaryType=”nt:unstructured”
- sling:resourceType=”granite/ui/components/coral/foundation/form/select”
- fieldLabel=”Align Text”
- name=”./align”
The dialog of Component B on path ../cq:dialog/../../items looks like:
+ title
- jcr:primaryType=”nt:unstructured”
- sling:resourceType=”granite/ui/components/coral/foundation/form/textarea”
- fieldLabel=”Title”
- name=”./title”
+ description
- jcr:primaryType=”nt:unstructured”
- sling:resourceType=”granite/ui/components/coral/foundation/form/textarea”
- fieldLabel=”Description”
- name=”./description”
The requirement for the dialog is that the Align text field is shown after the Title field.
What should the developer do without changing Component B?
( ) Move all the nodes under the item node from Component B to Component A and order them according the requirements.
( ) Extend Component B with the functionality of Component A
( ) Add the property sling:orderBefore=”description” to the align node.
( ) Move the align node from Component A to Component B and order them according the requirements.
(+) Add the property sling:orderBefore=”description” to the align node.
https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-with-aem-headless/spa-editor/react/extend-component.html?lang=en#extend-dialog
https://sling.apache.org/documentation/bundles/resource-merger.html#child-resource-order-1
Our Banner component requires an extra text field in the dialog to capture the bannerText.
Since we are using Sling inheritance, we can use features of the Sling Resource Merger to override or extend portions of the dialog. In this sample a new tab has been added to the dialog to capture additional data from an author to populate the Card Component.
A developer is working on a dialog for a contact list component. The dialog has the following requirements:
- The list of contacts must include one or more entries
- Contact details must include a full name
- Contact details must include an email address
- Contact details can optionally include a short bio
- Authors need to be able to rearrange the contacts in the list
Which dialog configuration should the developer use to meet all of these requirements?
( ) + multi
- sling:resourceType=”granite/ui/components/coral/foundation/form/multifield”
- composite=”{Boolean}true”
- fieldLabel=”Contact List”
- required=”{Boolean}true”
+ field
- sling:resourceType=”granite/ui/components/coral/foundation/container”
- name=”./contacts”
+ items
+ name
- sling:resourceType=”granite/ui/components/coral/foundation/form/textfield”
- fieldLabel=”Full Name”
- name=”./name”
- required=”{Boolean}true”
+ email
- sling:resourceType=”granite/ui/components/coral/foundation/form/textfield”
- fieldLabel=”Email Address”
- name=”./email”
- required=”{Boolean}true”
+ bio
- sling:resourceType=”granite/ui/components/coral/foundation/form/textarea”
- fieldLabel=”Short Bio”
- name=”./bio”
( ) + multi
- sling:resourceType=”granite/ui/components/coral/foundation/form/multifield”
- fieldLabel=”Contact List”
+ field
- sling:resourceType=”granite/ui/components/coral/foundation/container”
- composite=”{Boolean}true”
- name=”./contacts”
+ items
+ name
- sling:resourceType=”granite/ui/components/coral/foundation/form/textfield”
- fieldLabel=”Full Name”
- name=”./name”
+ email
- sling:resourceType=”granite/ui/components/coral/foundation/form/textfield”
- fieldLabel=”Email Address”
- name=”./email”
+ bio
- sling:resourceType=”granite/ui/components/coral/foundation/form/textarea”
- fieldLabel=”Short Bio”
- name=”./bio”
- required=”{Boolean}false”
( ) + multi
- sling:resourceType=”granite/ui/components/coral/foundation/form/multifield”
- composite=”{Boolean}true”
- fieldLabel=”Contact List”
+ field
- sling:resourceType=”granite/ui/components/coral/foundation/container”
- name=”./contacts”
+ items
+ name
- sling:resourceType=”granite/ui/components/coral/foundation/form/textfield”
- fieldLabel=”Full Name”
- name=”./name”
+ email
- sling:resourceType=”granite/ui/components/coral/foundation/form/textfield”
- fieldLabel=”Email Address”
- name=”./email”
+ bio
- sling:resourceType=”granite/ui/components/coral/foundation/form/textarea”
- fieldLabel=”Short Bio”
- name=”./bio”
- required=”{Boolean}false”
( ) + multi
- sling:resourceType=”granite/ui/components/coral/foundation/form/multifield”
- fieldLabel=”Contact List”
- required=”{Boolean}true”
+ field
- sling:resourceType=”granite/ui/components/coral/foundation/container”
- composite=”{Boolean}true”
- name=”./contacts”
+ items
+ name
- sling:resourceType=”granite/ui/components/coral/foundation/form/textfield”
- fieldLabel=”Full Name”
- name=”./name”
- required=”{Boolean}true”
+ email
- sling:resourceType=”granite/ui/components/coral/foundation/form/textfield”
- fieldLabel=”Email Address”
- name=”./email”
- required=”{Boolean}true”
+ bio
- sling:resourceType=”granite/ui/components/coral/foundation/form/textarea”
- fieldLabel=”Short Bio”
- name=”./bio”
(+) + multi
- sling:resourceType=”granite/ui/components/coral/foundation/form/multifield”
- composite=”{Boolean}true”
- fieldLabel=”Contact List”
- required=”{Boolean}true”
+ field
- sling:resourceType=”granite/ui/components/coral/foundation/container”
- name=”./contacts”
+ items
+ name
- sling:resourceType=”granite/ui/components/coral/foundation/form/textfield”
- fieldLabel=”Full Name”
- name=”./name”
- required=”{Boolean}true”
+ email
- sling:resourceType=”granite/ui/components/coral/foundation/form/textfield”
- fieldLabel=”Email Address”
- name=”./email”
- required=”{Boolean}true”
+ bio
- sling:resourceType=”granite/ui/components/coral/foundation/form/textarea”
- fieldLabel=”Short Bio”
- name=”./bio”
https://developer.adobe.com/experience-manager/reference-materials/6-5/granite-ui/api/jcr_root/libs/granite/ui/components/coral/foundation/form/multifield/index.html
Multifield component allows to add/reorder/remove multiple instances of a field.
( ) include
( ) categories
( ) embed
( ) dependencies
(+) embed
https://experienceleague.adobe.com/docs/experience-manager-65/developing/introduction/clientlibs.html?lang=en#embedding-code-from-other-libraries
## How Client-Side Libraries Work in AEM
By default, cq:ClientLibraryFolder nodes can be placed anywhere within the /apps, /libs and /etc subtrees of the repository (these defaults, and other settings can be controlled through the Adobe Granite HTML Library Manager panel of the System Console).
Each cq:ClientLibraryFolder is populated with a set of JS and/or CSS files, along with a few supporting files (see below). The properties of the cq:ClientLibraryFolder are configured as follows:
- categories: Identifies the categories into which the set of JS and/or CSS files within this cq:ClientLibraryFolder fall. The categories property, being multi-valued, allows a library folder to be part of more than one category (see below for how this may be useful).
- dependencies: This is a list of other client library categories on which this library folder depends. For example, given two cq:ClientLibraryFolder nodes F and G, if a file in F requires another file in G in order to function properly, then at least one of the categories of G should be among the dependencies of F.
- embed: Used to embed code from other libraries. If node F embeds nodes G and H, the resulting HTML will be a concentration of content from nodes G and H.
- allowProxy: If a client library is located under /apps, this property allows access to it via proxy servlet. See Locating a Client Library Folder and Using the Proxy Client Libraries Servlet below.
A Client-Side Library has the category “library.example”.
Which HTL statement should a developer use to reference only the CSS files of this Client-Side Library?
( )
( )
( )
( )
(+)
A developer wants to create a Client Library that will only be included on touch enabled devices.
What action should the developer take to achieve this?
( ) Set the channels property on the Client Library Folder to “touch”
( ) Pass the parameter user-agent=’touch’ when referencing the Client Library
( ) Create a resource folder called “touch” under the Client Library Folder
( ) Add the line “#base=touch” to the js.txt and css.txt files in the Client Library Folder
(+) Set the channels property on the Client Library Folder to “touch”
https://experienceleague.adobe.com/docs/experience-manager-65/developing/introduction/clientlibs.html?lang=en#using-a-library-for-specific-mobile-groups
## Using a Library for Specific Mobile Groups
Use the channels property of a client library folder to identify the mobile group that uses the library. The channels property is useful when libraries of the same category are designed for different device capabilities.
To associate a client library folder with a device group, add a property to your cq:ClientLibraryFolder node with the following attributes:
Name: channels
Type: String[]
Values: The name of the mobile group.
To exclude the library folder from a group, prefix the name with an exclamation mark (“!”).
For example, the following table lists the value of the channels property for each client library folder of the cq.widgets category:
Client library folder Value of channels property
/libs/cq/analytics/widgets !touch
/libs/cq/analytics/widgets/themes/default !touch
/libs/cq/cloudserviceconfigs/widgets !touch
/libs/cq/searchpromote/widgets !touch
/libs/cq/searchpromote/widgets/themes/default [no value]
/libs/cq/touch/widgets touch
/libs/cq/touch/widgets/themes/default touch
/libs/cq/ui/widgets !touch
/libs/cq/ui/widgets/themes/default !touch
A developer is creating a new component. When rendering the component in a browser, the developer is presented with errors in the browser console. The JavaScript code is compressed.
What is the first step the developer should take to resolve this issue?
( ) Check in the browser on which line the error occurs and check all the JavaScript files of the loaded Client Library files to find the error.
( ) Set “Minify” option to false and the “Debug” option to true in the HTML Library Manager service.
( ) Look in the browser if the Client Library is loaded already.
( ) Remove loaded Client Libraries one by one from the page to determine which Client Library contains the errors.
(+) Set “Minify” option to false and the “Debug” option to true in the HTML Library Manager service.
https://experienceleague.adobe.com/docs/experience-manager-65/developing/introduction/clientlibs.html?lang=en#configuring-library-handling-for-development-and-production
## The HTML Library Manager service processes cq:ClientLibraryFolder tags and generates the libraries at runtime. The type of environment, development or production, determines how you should configure the service:
Increase security: Disable debugging
Improve performance: Remove whitespace and compress libraries.
Improve readability: Include whitespace and do not compress.
Refer to the following four Client Library Folders.
+ One
- categories=”[library.one]”
- dependencies=”[library.three, library.four]”
- embed=”[library.two]”
+ Two
- categories=”[library.two]”
+ Three
- categories=”[library.three]”
- dependencies=”[library.four]”
+ Four
- categories=”[library.four]”
A developer uses the following
What is the resulting HTML?
( )
( )
( )
( )
(+)
## Note:
- The dependencies are loaded before so that they are available for the library which relies on them
- The embedded libraries are embedded under the name of the embedding library. In this case, the library.two was embedded with the library.one under that name.
A developer has a component located under the path /apps. This component has a Client Library which is directly loaded onto a page. The publish instance loads the page correctly. The dispatcher also loads the page, but the Client Library is missing.
How should the developer resolve this issue, while taking security into consideration?
( ) Allow the path to the clientlibs on the dispatcher.
( ) Add the property allowProxy with a boolean value true.
( ) Change the ACLs for the Client Library.
( ) Move the Client Library under /apps//library.
(+) Add the property allowProxy with a boolean value true.
https://experienceleague.adobe.com/docs/experience-manager-65/developing/introduction/clientlibs.html?lang=en#locating-a-client-library-folder-and-using-the-proxy-client-libraries-servlet
## In order for the client libraries under /apps to be accessible, a proxy servelt is used. The ACLs are still enforced on the client library folder, but the servlet allows for the content to be read via /etc.clientlibs/ if the allowProxy property is set to true.
Adobe recommends locating client libraries under /apps and making them available using the proxy servlet. However keep in mind that best practice still requires that public sites never include anything that is served directly over an /apps or /libs path.
Refer to the following Client Library node structure.
+ clientlibs
- jcr:primaryType=”cq:ClientLibraryFolder”
- categories=”[clientlibs.example]”
+ js.txt
- jcr:primaryType=”nt:file”
+ css.txt
- jcr:primaryType=”nt:file”
+ js
- jcr:primaryType=”nt:folder”
+ javascript1.js
+ javascript2.js
The js.txt looks like
javascript1.js
javascript2.js
The javascript is NOT present in the Client Library when it is loaded.
What should a developer do to resolve this issue?
( ) Change the js folder to a Client Library node and embed it on the clientlibs node
( ) Change the js folder to a Client Library node and add the property categories=”[clientlibs.example]”
( ) Add #base=js as the first line in the js.txt file
( ) Split the js and css into 2 Client Libraries since they can’t be in the same Client Library
base=js
(+) Add #base=js as the first line in the js.txt file
https://experienceleague.adobe.com/docs/experience-manager-65/developing/components/classic-ui-components/widgets.html?lang=en#including-the-client-sided-code-in-a-page
## Client sided javascript and stylesheet code should be placed in a client library.
To create a client library:
- Create a node below /apps/ with the following properties:
- name=“clientlib”
- jcr:mixinTypes=“[mix:lockable]”
- jcr:primaryType=“cq:ClientLibraryFolder”
- sling:resourceType=“widgets/clientlib”
- categories=“[category-name]”
- dependencies=“[cq.widgets]”
Note: category-name is the name of the custom library (e.g. “cq.extjstraining”) and is used to include the library on the page.
- Below clientlib create the css and js folders (nt:folder).
- Below clientlib create the css.txt and js.txt files (nt:files). Those .txt files list the files that are included in the library.
- Edit js.txt: it needs to start with ’ #base=js’ followed by the list of the files that will be aggregated by the CQ client library service, eg:
components.js
exercises.js
CustomWidget.js
CustomBrowseField.js
InsertTextPlugin.js
- Edit css.txt: it needs to start with ’ #base=css’ followed by the list of the files that will be aggregated by the CQ client library service, eg:
components.css
- Below the js folder, place the javascript files that belong to the library.
- Below the css folder, place the .css files and the resources used by the css files (e.g. my_icon.png).
A developer creates a custom Client Library named foobar.
This Client Library embeds 5 other Client Libraries and contains 10 JavaScript source files. One of these files, called foo.js, has a bug on line 8 which causes an exception. The Client Library is throwing this exception on line 1350 when it is included on a webpage.
How should a developer find the exact line in foo.js where the exception has been thrown?
( ) 1. Add the query parameter debugClientLibs=true to the request
2. Use the browser JavaScript debugging tools
( ) 1. Add the selector debugClientLibs to the page request
2. Check the JavaScript exception log in the OSGi web console
( ) 1. Temporarily remove the embedded Client Libraries of the foobar Client Library
2. Use the browser JavaScript debugging tools
( ) 1. Enable JS/CSS minification in OSGi configuration console for HTML Library Manager
2. Check the JavaScript exception log in the OSGi web console
(+) 1. Add the query parameter debugClientLibs=true to the request
2. Use the browser JavaScript debugging tools
https://experienceleague.adobe.com/docs/experience-manager-65/developing/introduction/clientlibs.html?lang=en#see-embedded-files
## To trace the origin of embedded code, or to ensure that embedded client libraries are producing the expected results, you can see the names of the files that are being embedded at runtime. To see the file names, append the debugClientLibs=true parameter to the URL of your web page. The library that is generated contains @import statements instead of the embedded code.
A developer created a Client Library called foobar containing a folder scripts with two JavaScript files.
script-a.js
“use strict”;
var v = “Foo”;
script-b.js
“use strict”;
v = “Bar”;
When the Client Library is included on a page, only the code from script-a.js is available.
What should the developer do to fix this issue?
( ) Add or correct the entry for script-b.js in the file js.txt and redeploy
( ) Add or correct the entry for script-b.js in the file javascript.txt and redeploy
( ) Correct any syntax violations in the file script-b.js and redeploy
( ) Correct violations against strict mode in the file script-b.js and redeploy
(+) Add or correct the entry for script-b.js in the file js.txt and redeploy
A developer wants to extend AEM Core Components to create a custom Carousel Component.
( ) Copy the Core Carousel component to /apps/ folder
( ) Use the sling:resourceSuperType property to point to the core component
( ) Use the sling:resourceType property to point to the core component
( ) Make changes to the original component and assign a component group
(+) Use the sling:resourceSuperType property to point to the core component
https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-with-aem-headless/spa-editor/react/extend-component.html?lang=en#sling-resource-super-type
## Inheritance with Sling Resource Super Type
To extend an existing component set a property named sling:resourceSuperType on your component’s definition. sling:resourceSuperTypeis a property that can be set on an AEM component’s definition that points to another component. This explicitly sets the component to inherit all functionality of the component identified as the sling:resourceSuperType.
If we want to extend the Image component at wknd-spa-react/components/image we need to update the code in the ui.apps module.
A developer needs to upgrade existing components (Proxy Components) based on Core Components Version 1(v1) to Core Components Version 2(v2).
How should the developer upgrade to V2 Core Components?
( ) Modify the sling:resourceSuperType property on the V1 core components to point to V2 Component
( ) Modify the sling:resourceSuperType property on the proxy component to point to V2 Component
( ) Proxy Components will be automatically upgraded to the V2 Core Component on AEM Restart
( ) Create a new Proxy Component and set sling:resourceType property to V2 Core Component
(+) Modify the sling:resourceSuperType property on the proxy component to point to V2 Component
https://experienceleague.adobe.com/docs/experience-manager-core-components/using/get-started/using.html?lang=en#create-proxy-components
## Create Proxy Components
For reasons explained in the Proxy Component Pattern section, Core Components must not be directly referenced from the content. To avoid that, they all belong to a hidden component group ( .core-wcm or .core-wcm-form), which will prevent them from showing up directly in the editor.
Instead, site-specific components must be created, which define the desired component name and group to display to page authors, and refer each to a Core Component as their super-type. These site-specific components are sometimes called “proxy components”, because they don’t need to contain anything and serve mostly to define the version of a component to use for the site. However, when customizing the Core Components, these proxy components play an essential role for markup and logic customization.
So for each Core Component that is desired to be used for a site, you must:
Create a corresponding proxy component in the site’s components folder.
Example
Under /apps/my-site/components create a title node of type cq:Component
Point to the corresponding Core Component version with the super-type.
Example
Add following property:
sling:resourceSuperType=”core/wcm/components/title/v1/title”
Define the component’s group, title, and optionally description. These values are project specific and dictate how the component is exposed to authors.
## Proxy Component Pattern
As each content resource has a sling:resourceType property that references the component to render it, it is usually good practice to have these properties pointing to site-specific components, instead of pointing to components that are shared by multiple sites. This will offer more flexibility and avoid content refactoring if one site needs a different behavior for a component, because this customization can then be achieved on the site-specific component and won’t affect the other sites.
However, for the project-specific components not to duplicate any code, they should each refer to the shared parent component with the sling:resourceSuperType property. These project-specific components that mostly just refer to parent components are called “proxy components”. Proxy components can be entirely empty if they fully inherit the functionality, or they can redefine some aspects of the component.
A developer wants to consume AEM Page Data in a Single Page Application. The Single Page Application is coded to understand JSON format. Only page content should be exposed through JSON. All the existing components are based on foundation components.
Which change should the developer make in the existing components to support this requirement?
( ) Create a custom sling event handler to handle JSON requests
( ) Implement a Sling Model Exporter for the components
( ) Invoke the page URL with the extension .json to get the values to construct the required output
( ) Add JSON as the default extension in Apache Sling Servlet/Script Resolver and Error Handler Configuration
(+) Implement a Sling Model Exporter for the components
https://experienceleague.adobe.com/docs/experience-manager-learn/foundation/development/develop-sling-model-exporter.html?lang=en
https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/implementing/developing/full-stack/components-templates/enabling-json-exporter.html?lang=en
Note:
- The out-of-the-box Sling JSON content representation only outputs the JCR content structure. For instance, when applied to a Page component it will output all page properties in a JSON format excluding any business logic eventually in place during the component rendering.
- The Sling Model Exporter allows the output of all business logic (getters returned by the model during rendering) plus it is possible to add custom JSON content redemption
A developer creates Editable Templates based on a custom Page component. The developer wants to leverage the Style System within the Editable Templates to allow authors to switch between the Dark and Light Theme. The Style System dialog is NOT enabled for the site.
What should the developer do to resolve this issue?
( ) Create a new dialog for the custom Page component
( ) Set the sling:resourceSuperType property to core/wcm/components/page/v2/page on the Page component
( ) Define Style definitions using Page Policy dialog on Editable Template
( ) Create two new client libraries with a dark and light theme and map them to the Page component
(+) Set the sling:resourceSuperType property to core/wcm/components/page/v2/page on the Page component
A developer needs to change the label “Sites” in the navigation of AEM author to “Websites”.
Which action should the developer take to achieve this?
( ) Modify the node /libs/cq/core/content/nav/sites by updating the jcr:title property value
( ) Create a new node /apps/cq/core/content/nav/sites and update the property jcr:title
( ) Modify the code of /libs/granite/ui/components/shell/globalnav/overlay/overlay.jsp to display the new value
( ) Change the code of /libs/granite/ui/components/shell/clientlibs/shell/js/globalnav.js to display the new value
(+) Create a new node /apps/cq/core/content/nav/sites and update the property jcr:title
https://experienceleague.adobe.com/docs/experience-manager-65/developing/platform/overlays.html?lang=en
## In this context (extending AEM) an overlay means taking the predefined functionality and imposing your own definitions over that (to customize the standard functionality).
In a standard instance the predefined functionality is held under /libs and it is recommended practice to define your overlay (customizations) under the /apps branch. AEM uses a search path to find a resource, searching first the /apps branch and then the /libs branch (the search path can be configured). This mechanism means that your overlay (and the customizations defined there) will have priority.
A developer needs to create a banner component. This component shows an image across the full width of the page. A title is shown on top of the image. This text can be aligned to the left, middle, or right. The core components feature a teaser component which matches almost all requirements, but not all.
What is the most maintainable way for the developer to implement these requirements?
( ) Create a new custom component from scratch.
( ) Overlay the teaser core component.
( ) Inherit from the teaser core component.
( ) Use and configure the teaser core component.
(+) Inherit from the teaser core component.
A developer is creating a custom method. This method must return a String property y from child x. The method must use only Sling APIs.
How should the developer retrieve property y of node x, and node x may or may NOT exist?
( ) String y = null;
Node x = node.getNode(“x”);
if (null!=x) {
Properties properties = x.getProperties();
if (null!=properties) {
y = properties.get(“y”,””);
}
}
( ) String y = null;
Node x = node.getChild(“x”);
if (null!=x) {
ValueMap map = x.getValueMap();
if (null!=map) {
y = map.get(“y”,””);
}
}
( ) String y = ((ValueMap) resource.getChild(“x”).getValueMap()).get(“y”,””);
( ) String y = null;
Resource x = resource.getChild(“x”);
if (null!=x) {
ValueMap map = x.getValueMap();
if (null!=map) {
y = map.get(“y”,””);
}
}
(+) String y = null;
Resource x = resource.getChild(“x”);
if (null!=x) {
ValueMap map = x.getValueMap();
if (null!=map) {
y = map.get(“y”,””);
}
}
https://experienceleague.adobe.com/docs/experience-manager-learn/foundation/development/understand-java-api-best-practices.html?lang=en#sling-apis
https://sling.apache.org/apidocs/sling10/org/apache/sling/api/resource/ValueMap.html#get-java.lang.String-java.lang.Class-
A developer is writing Java code using the Sling API that needs to work with the JCR directly. The code needs to obtain a Session object.
A service user named “reposervice” may be mapped outside the code.
Which two methods could a developer use to obtain a Session without using a deprecated API? (Choose two.)
( ) SlingRepository repository;
if (null != repository) {
Session session = repository.loginAdministrative(“crx.default”);
}
( ) ResourceResolverFactory resolverFactory;
if (null != resolverFactory) {
ResourceResolver resolver = resolverFactory.getServiceResourceResolver(null);
Session session = resolver.adaptTo(Session.class);
}
( ) ResourceResolverFactory resolverFactory;
if (null!=resolverFactory) {
Map authenticationInfo = new HashMap();
authenticationInfo.put(“username”,”admin”);
authenticationInfo.put(“password”,”admin”);
Session session = resolverFactory.getAdministrativeResourceResolver(authenticationInfo).adaptTo(Session.class);
}
( ) ResourceResolverFactory resolverFactory;
if (null!=resolverFactory) {
Map authenticationInfo = new HashMap();
authenticationInfo.put(“username”,”reposervice”);
Session session = resolverFactory.getAdministrativeResourceResolver(authenticationInfo, resolverFactory.getPassword(“reposervice”)).adaptTo(Session.class);
}
( ) SlingRepository repo;
if (null != repo) {
Session session = repo.loginService(null, repo.getDefaultWorkspace());
}
(+) ResourceResolverFactory resolverFactory;
if (null != resolverFactory) {
ResourceResolver resolver = resolverFactory.getServiceResourceResolver(null);
Session session = resolver.adaptTo(Session.class);
}
(+) SlingRepository repo;
if (null != repo) {
Session session = repo.loginService(null, repo.getDefaultWorkspace());
}
https://sling.apache.org/apidocs/sling11/org/apache/sling/api/resource/ResourceResolverFactory.html#getServiceResourceResolver-java.util.Map-
https://sling.apache.org/apidocs/sling8/org/apache/sling/jcr/api/SlingRepository.html#loginService-java.lang.String-java.lang.String-
https://sling.apache.org/apidocs/sling8/org/apache/sling/jcr/api/SlingRepository.html#getDefaultWorkspace–
A developer needs to write Java code using the JCR API that unlocks a node.
Which code should the developer use?
( ) public void unlock(String path) throws PathNotFoundException, AccessDeniedException, InvalidItemStateException, LockException, RepositoryException {
Resource thisResource = this.getCurrentResource();
Node thisNode = thisResource.getNode();
thisNode.unlock();
}
( ) public void unlock(String path) throws PathNotFoundException, AccessDeniedException, InvalidItemStateException, LockException, RepositoryException {
Resource thisResource = this.getCurrentResource();
ResourceResolver resolver = thisResource.getResourceResolver();
Node thisNode = resolver.adaptTo(Node.class);
LockManager lockMgr = thisNode.getLockManager();
if (lockMgr.isLocked(path)) {
lockMgr.unlock(path);
}
}
( ) public void unlock(String path) throws PathNotFoundException, AccessDeniedException, InvalidItemStateException, LockException, RepositoryException {
Resource thisResource = this.getCurrentResource();
ResourceResolver resolver = thisResource.getResourceResolver();
Session session = resolver.adaptTo(Session.class);
LockManager lockMgr = session.getWorkspace().getLockManager();
if (lockMgr.isLocked(path)) {
lockMgr.unlock(path);
}
}
( ) public void unlock(String path) throws PathNotFoundException, AccessDeniedException, InvalidItemStateException, LockException, RepositoryException {
Resource thisResource = this.getCurrentResource();
ResourceResolver resolver = thisResource.getResourceResolver();
LockManager lockMgr = resolver.adaptTo(LockManager.class);
if (lockMgr.isLocked(path)) {
lockMgr.unlock(path);
}
}
(+) public void unlock(String path) throws PathNotFoundException, AccessDeniedException, InvalidItemStateException, LockException, RepositoryException {
Resource thisResource = this.getCurrentResource();
ResourceResolver resolver = thisResource.getResourceResolver();
Session session = resolver.adaptTo(Session.class);
LockManager lockMgr = session.getWorkspace().getLockManager();
if (lockMgr.isLocked(path)) {
lockMgr.unlock(path);
}
}
https://developer.adobe.com/experience-manager/reference-materials/spec/jsr170/javadocs/jcr-2.0/javax/jcr/lock/LockManager.html#unlock(java.lang.String)