Giter Site home page Giter Site logo

adobe-consulting-services / acs-aem-samples Goto Github PK

View Code? Open in Web Editor NEW
206.0 65.0 196.0 557 KB

AEM Code Samples repository

Home Page: http://adobe-consulting-services.github.io/acs-aem-samples/

License: Apache License 2.0

Java 98.18% HTML 1.03% JavaScript 0.76% Less 0.03%
aem java code-samples osgi sling jcr cq oak adobe-experience-manager

acs-aem-samples's Introduction

ACS AEM Samples

This project is a collection of sample implementation of the various, common building blocks for AEM-based applications.

The samples in this project are not intended and should never be installed on AEM instance directly and only used for reference purposes.

These samples have not been tested for functionality; please report and bugs/incorrectness to the ACS AEM Samples GitHub Issues project.

acs-aem-samples's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

acs-aem-samples's Issues

Migrate Sample code to the acs-aem-samples repository

Fork: https://github.com/davidjgonzalez/acs-aem-samples (master)

Then copy/paste Samples from: https://github.com/activecq/com.activecq.samples/tree/master/core/src/main/java/com/activecq/samples into the acs-aem-samples project.

Migration activities:

  • Changing package naming to be “com.adobe.acs.samples”
  • Update any @component labels to be “ACS AEM Samples - ”
  • Code review/cleanup — worth sanity checking them; I wrote these years ago
  • Clarify any code w comments
  • Break up samples that are tackle too many “topics”
  • Generally the samples should do almost no “business” work; any “work” done should be very simple and straight foward. These samples are currently less about how to execute business functionality, but rather how/when/why to leverage the various building blocks in AEM..

Before "migrating" a sample, add it to this comment (and ensure someone else hasn't already claimed the sample for migration)

Migrated Samples

  • SampleAdapterFactory.java
  • SampleSlingIncludeFilter.java
  • SampleSlingRequestFilter.java
  • SampleThreadLocalFilter.java
  • SampleServiceImpl.java
  • SampleJsonHitWriter.java
  • SampleMultiReferenceServiceImpl.java
  • SampleMutableStateServiceImpl.java
  • SampleServiceImpl.java
  • SampleAllMethodsServlet.java
  • SampleSafeMethodsServlet.java
  • SampleMBeanImpl.java
  • SampleScheduledService.java
  • SampleSlingResourceProvider.java
  • workflow/* (@kalyanar - in process)
  • clientcontext/* (@kalyanar - in process)

Create Jaas Sling Authentication Handler (for Oak)

Per @asanso

If you running AEM on Oak is better you leverage the new native Jaas Osgi native integration support [0] rather than TokenUtil.createCredentials (this create always a token cookie that is not necessary in some situations).

A good example might be the SlingFormAuthenticationHandler [1]

[0] http://felix.apache.org/documentation/subprojects/apache-felix-jaas.html
[1] http://svn.apache.org/repos/asf/sling/trunk/bundles/auth/form/src/main/java/org/apache/sling/auth/form/impl/FormAuthenticationHandler.java

SampleResourceWrapper behaves differently than a JCR resource

Today we encountered the problem, that the application behaved differently when called on a JCR resource than on wrapped resource (which is built according to the SampleResourceWrapper).

The application code looked like this:

ValueMap map = resource.adaptTo(ValueMap.class);
Date lastModified = map.get("cq:lastModified", Date.class);

When the resource is a JCR resource, a correct Date object is returned, if the Resource is a SampleResourceWrapper, null is returned (even if the property comes from the wrapped resource and is not injected by the wrapper).

It took us some time to track that back to SLING-6420 (which is likely to be part of AEM 6.3); and our solution was to change the ValueMapDecorator [1] to a CompositeValueMap, which provided the proper semantics.

So can you please adjust the sample?

[1] https://github.com/Adobe-Consulting-Services/acs-aem-samples/blob/master/bundle/src/main/java/com/adobe/acs/samples/resources/SampleResourceWrapper.java#L46

Angular2 integration

Dear all,

We have completed an Angular2 project with the AoT and rollup tree-shaking. Now we would like to integrate this app into AEM, but we haven't found any example anywhere.

Do you guys have any ideas how to approach it - any examples we can look into?

Thanks, your help is much appreciated!

Best, Irman

Build does not embed bundle in content package

The {{content/pom.xml}} has an embed directive for the content-package plugin to embed the sample bundle. However, the bundle is not embedded, because there isn't a corresponding dependency definition. To further complicate matters, an old SNAPSHOT of the bundle is committed with the project sources at https://github.com/Adobe-Consulting-Services/acs-aem-samples/tree/master/content/src/main/content/jcr_root/apps/acs-samples/install.

This can be very confusing and is certainly nothing like the best-practices that a sample project should be demonstrating.

After fixing this locally, I still had to jump through some hoops to get the bundle to resolve on AEM 6.5. Maybe that's due to issues that have gone unnoticed in smoke tests due to this issue? Or maybe 6.5 is just not supported yet.

Decorator and ThreadLocal doesn't work

In SampleResourceDecorator, it mentioned that an HttpServletRequest is no longer called, so a ThreadLocal Sling Filter may be used. However, in my own testing, the Resource Decorator is always called before the Filtering happens, therefore it always receives the default value of the ThreadLocal and not the value from the actual request.

Null pointer exception in SlingRequestFilter when working with launches in AEM 6.2

Hello,

I have implemented SlingRequestFilter for restricted DAM access. However, launches functionality in AEM has stopped working because of null pointer exception thrown at below line in bold. Could you please advise how I can resolve this or what possible scenario is throwing this exception.

_// Forcing false in this sample so else this will break AEM when installed
if (false && response.getContentType().contains("html")) {
    // In this example, checking for html response type since the comments are HTML format and would break
    // binary, json, etc. responses

    // Write some more content to the response before this chain has executed
    //response.getWriter().write("<!-- Written from the Sample Sling Filter BEFORE the next include -->");

    // Proceed with the rest of the Filter chain
    chain.doFilter(request, response);

    // Write some more content to the response after this chain has executed
    //response.getWriter().write("<!-- Written from the Sample Sling Filter AFTER the next include -->");
}  else {
    **chain.doFilter(request, response);**
}

}_

Log file attached.

error.txt

Thank you,

Cannot build and deploy with Maven 3.3.3

Running the Maven command with Maven Version 3.3.3
mvn clean install -PautoInstallBundle

results into the following error:
[ERROR] Failed to execute goal com.day.jcr.vault:content-package-maven-plugin:0.
0.23:package (default-package) on project acs-aem-samples-content: Execution def
ault-package of goal com.day.jcr.vault:content-package-maven-plugin:0.0.23:packa
ge failed: A required class was missing while executing com.day.jcr.vault:conten
t-package-maven-plugin:0.0.23:package: org/slf4j/helpers/MarkerIgnoringBase

When switching to Maven 3.0.5 everything is fine and the package is being deployed.
Is this a Maven issue or an issue here?

SampleJsonHitWriter should use hit.getProperties()

SampleJsonHitWriter.java currently does

final Resource resource = hit.getResource();
final ValueMap properties = resource.adaptTo(ValueMap.class);

but it could use hit.getProperties() right away, see the javadocs.

This also handles the common jcr:content nodes and will return a ValueMap based on the jcr:content node, if present.

Hence line 84/85 can be changed from:

jsonWriter.key("key-to-use-in-json").value(properties.get("jcr:content/jcr:title",
                "") + "(pulled from jcr:content node)");

to

jsonWriter.key("key-to-use-in-json").value(hit.getProperties().get("jcr:title", "") + "(pulled from jcr:content node)");

Angular2 RuntimeCompiler issue with Adobe AEM

Hi I have the AEM integration issue with our angular2 code. We want to use templates from Adobe AEM and those templates need to be binded with Angular2 component. So there is a need for RuntimeCompiler. With AOT it is not working but without AOT we are able to use Adobe AEM template in our Angular2 Components and compile it dynamically. please let us know how we can do that ?

Possible to extend the side bar?

Is it possible to add a new customized section to the side panel when authoring a page? We'd love to integrate our enterprise asset management into the workflow of our editors.

image

com.adobe.acs.samples.events.impl.SampleJcrEventListener should not be a @Service

AFAICT, there's no reason for com.adobe.acs.samples.events.impl.SampleJcrEventListener to be an @Service. JCR EventListeners are not registered through the OSGi service registry and this class doesn't implement any other service interfaces.

Should probably remove this annotation and also the immediate=true attribute from the @Component annotation (since components which aren't services are automatically immediate).

Build Failure - generate-scr-description fails

I just pulled down the latest for this project and am trying to build with Java 8 and Maven 3.1.1, and I get the following error on build. Any thoughts?

[ERROR] /Users/brett/Documents/clients/hs2/projects/acs-aem-samples/bundle/src/main/java/com/adobe/acs/samples/migration/impl/SampleContentReplicationHarnessImpl.java [1:1]: @Component : Class must have public default constructor: com.adobe.acs.samples.migration.impl.SampleContentReplicationHarnessImpl
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] ACS AEM Samples - Reactor Project ................. SUCCESS [0.176s]
[INFO] ACS AEM Samples Bundle ............................ FAILURE [3.299s]
[INFO] ACS AEM Samples Content Package ................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.231s
[INFO] Finished at: Thu Oct 06 08:48:37 CDT 2016
[INFO] Final Memory: 23M/324M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.felix:maven-scr-plugin:1.20.0:scr (generate-scr-descriptor) on project acs-aem-samples-bundle: SCR Descriptor parsing had failures (see log) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.felix:maven-scr-plugin:1.20.0:scr (generate-scr-descriptor) on project acs-aem-samples-bundle: SCR Descriptor parsing had failures (see log)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: SCR Descriptor parsing had failures (see log)
        at org.apache.felix.scrplugin.mojo.SCRDescriptorMojo.execute(SCRDescriptorMojo.java:251)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 19 more
Caused by: org.apache.felix.scrplugin.SCRDescriptorFailureException: SCR Descriptor parsing had failures (see log)
        at org.apache.felix.scrplugin.SCRDescriptorGenerator.execute(SCRDescriptorGenerator.java:223)
        at org.apache.felix.scrplugin.mojo.SCRDescriptorMojo.execute(SCRDescriptorMojo.java:237)
        ... 21 more

Felix filter execution order issue in AEM 6.2

We have a felix filter handling the custom authentication in 6.1 similar to this acs aem sample filter. As per specification, Felix filter should get executed before Sling Engine. Thats happening in AEM 6.1 but NOT in AEM 6.2.

Steps to reproduce

  1. Deploy OSGi bundle with Sample Filter to AEM 6.1, 6.2
  2. Hit URL in new browser session
  3. Observe execution order in 6.1 (Filter -> Sling Authentication)
04.01.2018 11:31:44.131 *INFO* [qtp1030969174-68] com.sample.project.core.filters.SampleServletFilter Calling Sample Servlet Filter
04.01.2018 11:31:44.132 *INFO* [qtp1030969174-68] org.apache.sling.auth.core.impl.SlingAuthenticator getAnonymousResolver: Anonymous access not allowed by configuration - requesting credentials
  1. Observe execution order in 6.2 (Sling Authentication -> Filter)
04.01.2018 11:26:33.364 *INFO* [qtp774039123-271] org.apache.sling.auth.core.impl.SlingAuthenticator getAnonymousResolver: Anonymous access not allowed by configuration - requesting credentials
04.01.2018 11:26:33.378 *INFO* [0:0:0:0:0:0:0:1 [1515083193376] GET /libs/granite/core/content/login.html HTTP/1.1] com.sample.project.core.filters.SampleServletFilter Calling Sample Servlet Filter

Tried with service.ranking property also, but it doesn't seems to be making a difference in AEM 6.2.

Additional Information - We are not yet on AEM 6.3, but tried the filter with modifications . Seems like the behavior is same as AEM 6.2.

Any pointers for this would help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.