tobywang11030 / AEM-Training

AEM Learning documents/AEM学习文档
19 stars 9 forks source link
aem java jcr osgi osgi-applications sling-application sling-instance

AEM Training

AEM basic technical knowledge study

1. 什么是AEM

1.1 AEM 官方定义

mvn clean install -PautoInstallPackage,local-author,adobe-public
java -XX:MaxPermSize=1028m -Xmx2048M -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=30308,server=y,suspend=n -jar cq-author-4502.jar  -r author localdev
mvn archetype:generate \
 -DarchetypeGroupId=com.adobe.granite.archetypes \
 -DarchetypeArtifactId=aem-project-archetype \
 -DarchetypeVersion=XX

XX 是版本号,具体取值参见:https://github.com/adobe/aem-project-archetype/blob/master/VERSIONS.md

2.4.1 AEM project modules structure

在这里插入图片描述

2.5 AEM 控制台

2.5.1 http://localhost:4502/aem/start.html

Touch UI Manager是AEM的核心控制台 在这里插入图片描述 Touch UI控制台主要提供页面的管理(创建新页面,编辑页面),Asset管理(上传,删除图片,视频等素材),另外还提供了一些列工具,比如replication,workflow,template,account等,具体可直接点击Tool按钮查看: 在这里插入图片描述 Touch UI控制台是运维人员和AEM管理员的主要控制台

2.5.2 http://localhost:4502/crx/de/index.jsp

Crx/de控制台可以认为是AEM的数据库管理工具 在这里插入图片描述 Crx/de 工具的主要功能是查看JCR的底层数据,包括我们部署到AEM的代码,OOTB的代码,以及用户创建的页面,添加的组件等,可以说,整个AEM的所有数据都可以在Crx/de中查看,以及修改,修改立即生效,因此,在项目中,我们可以在Crx/de中验证我们的功能,或者直接在Crx/de中添加修改数据而不经过代码部署环节,甚至,可以在生产环境的Crx/de中快速开发一个紧急功能而绕过其他环节。 Crx/de的另一个功能是数据导入导出,将用户生产的数据(添加的页面,图片,author的组件)等导入到其他Instance中。

2.5.3 http://localhost:4502/system/console/configMgr

ConfigMgr主要用来查看Bundle级的信息,比如,项目代码的Bundle是否部署和运行成功,组件java代码的Model是否成功运行,最重要的功能是,如果我们在java代码中添加了Property field,那我们可以在这个控制台中进行配置。 在这里插入图片描述

2.5.4 http://localhost:4502/crx/explorer/index.jsp

explorer 控制台不是很常用,核心功能是配置系统级用户,系统级用户是,在AEM的权限管理中,所有操作JCR数据必须要有一个用户,我们在Java中使用API操作JCR也不例外,因此需要为我们的java代码分配一个用户,而直接在Touch UI中创建用户,安全性低并且还需要密码认证,所以我们一般在该控制台中创建一个为代码使用的系统级用户。 在这里插入图片描述

2.6 AEM 基础术语

Granite.I18n.get('upload-time');
2.9.6 命令行 CURL 安装和下载 package
2.9.6.1 curl 下载 package
curl -# -u admin:admin -O http://localhost:4503/etc/packages/my_packages/image.zip
2.9.6.2 curl 上传或安装 package
curl -u admin:admin -F file=@"content.zip" -F name=“Package” -F force=true -F install=false http://localhost:4502/crx/packmgr/service.jsp --progress-bar -o upload.txt

3. AEM 技术架构

3.1 AEM 三大分层和三大核心技术架构图

在这里插入图片描述

3.2 AEM 三大核心技术

3.2.1 Apache Sling

Apache Sling :: Servlet Resolution
https://sling.apache.org/old-stuff/servlet-resolution.html
Apache Sling :: URL decomposition
http://sling.apache.org/documentation/the-sling-engine/url-decomposition.html
Apache Sling :: HTL Scripting
https://sling.apache.org/documentation/bundles/scripting/scripting-htl.html
Apache Sling :: Sling Models
https://sling.apache.org/documentation/bundles/models.html#specifying-an-alternate-adapter-class- since-110
拓展书目:
Continuous Delivery of Apache Sling Applications
Server-side OSGi with Apache Sling

3.2.2 java JCR & Apache Jackrabbit

Java JSR-170(JCR)
JCR规范下载
http://download.oracle.com/otndocs/jcp/content_repository-1.0.1-mr-oth-JSpec/index.html
Jackrabbit: 依据JCR规范的一个JCR实现类库
http://jackrabbit.apache.org/jcr/jackrabbit-architecture.html

3.2.3 Apache Felix

一个OSGI实现 官网 http://felix.apache.org/
拓展书目: OSGi and Apache Felix 3.0 Beginner's Guide

3.3. AEM 首选渲染层模板语言:HTL

HTML Template Language (HTL)是AEM所推荐使用的服务器端动态HTML模板语言
HTL 语法详解
https://github.com/Adobe-Marketing-Cloud/htl-spec/blob/master/SPECIFICATION.md#221-use
HTL Adobe 官方教程
https://helpx.adobe.com/experience-manager/htl/using/getting-started.html

4. AEM Build命令详解

4.1 MVN build命令相关知识

参考书目Maven权威指南中文版

4.2 AEM Build命令结构解释

在这里插入图片描述 如无法显示此图片,请浏览器中打开此链接:https://img-blog.csdnimg.cn/20191108104552463.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0NvZGluZ0Jsb2c=,size_16,color_FFFFFF,t_70

5. AEM 相关学习资料

5.1 Adobe 官方教程入口

https://helpx.adobe.com/support/experience-manager/6-3.html

5.2 Adobe 官方视频教程入口

https://helpx.adobe.com/experience-manager/kt/index/aem-6-3-videos.html

5.3 Adobe 官方实例教程入口

教你一步一步的开发AEM,很实用 附带官方实例源码 https://github.com/Adobe-Marketing-Cloud/aem-guides-wknd

5.4 Adobe官方“怎么样实现XX”文章汇总

https://helpx.adobe.com/experience-manager/topics/how-to.html

6. AEM分步学习

6.1 Part 1 Project Setup

https://helpx.adobe.com/experience-manager/kt/sites/using/getting-started-wknd-tutorial-develop/part1.html

6.2 Part 2 Creating a Base Page and Template

https://helpx.adobe.com/experience-manager/kt/sites/using/getting-started-wknd-tutorial-develop/part2.html

6.3 Part 3 Client-Side Libraries and Responsive Grid

https://helpx.adobe.com/experience-manager/kt/sites/using/getting-started-wknd-tutorial-develop/part3.html

6.4 Part 4 Developing with the Style System

https://helpx.adobe.com/experience-manager/kt/sites/using/getting-started-wknd-tutorial-develop/part4.html

6.5 Part 5 Navigation and Search

https://helpx.adobe.com/experience-manager/kt/sites/using/getting-started-wknd-tutorial-develop/part5.html

6.5 Part 6 Sling Models and Card Component

https://helpx.adobe.com/experience-manager/kt/sites/using/getting-started-wknd-tutorial-develop/part6.html

7. 常用技术点

7.1 Create AEM component by using Sling Model

https://helpx.adobe.com/experience-manager/using/aem63_slingmodel.html

7.2 Create AEM component by using WCMUsePojo

https://helpx.adobe.com/experience-manager/using/first_htl_WCMUsePojo.html

7.3 Scheduling with a cron expression

https://sling.apache.org/documentation/bundles/scheduler-service-commons-scheduler.html

7.4 Query Builder API

https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/querybuilder-api.html

7.5 SSO in AEM

https://helpx.adobe.com/experience-manager/6-3/sites/deploying/using/single-sign-on.html

7.6 Content Services

https://helpx.adobe.com/experience-manager/6-4/mobile/using/content-services.html

7.7 Developing AEM Mobile Content Services

https://helpx.adobe.com/experience-manager/6-4/mobile/using/spaces-and-entities.html

7.8 Getting Started with AEM Content Services

https://helpx.adobe.com/experience-manager/kt/sites/using/content-services-tutorial-use.html

7.9 Developing Sling Model Exporters in AEM

https://helpx.adobe.com/experience-manager/kt/platform-repository/using/sling-model-exporter-tutorial-develop.html

7.10 Enabling JSON Export for a Component

https://helpx.adobe.com/experience-manager/6-3/release-notes/json-exporter-dev-fp.html

7.11 Scripting variables in JSP

https://cwiki.apache.org/confluence/display/SLING/Scripting+variables#Scriptingvariables-Commonscriptingvariables

7.12 How to Build AEM Projects using Apache Maven

https://helpx.adobe.com/experience-manager/6-4/sites/developing/using/ht-projects-maven.html

7.13 动态下拉菜单

https://www.linkedin.com/pulse/granite-datasource-inside-touch-ui-select-object-aem-gonz%C3%A1lez-ramos https://mkbansal.wordpress.com/2016/01/04/aem-acs-generic-list-dialog-configuration-touch-ui/ https://helpx.adobe.com/experience-manager/using/creating-touchui-validate11.html

7.14 Configuring the Rich Text Editor

https://helpx.adobe.com/experience-manager/6-3/sites/administering/using/rich-text-editor.html#PluginsandtheirFeatures

7.15 Components for Page Authoring

https://helpx.adobe.com/experience-manager/6-2/sites/authoring/using/editmode.html#Text

7.16 Understanding AEM Content Fragments

https://helpx.adobe.com/experience-manager/kt/sites/using/content-fragments-feature-video-understand.html

7.17 使用Multifield

https://helpx.adobe.com/experience-manager/using/multifield_aem63.html

7.18 使用SlingModel

https://helpx.adobe.com/experience-manager/using/aem63_htl_repeat_slingmodel.html

7.19 Creating an Adobe Experience Manager HTML Template Language component that uses the WCMUsePojo API

https://helpx.adobe.com/experience-manager/using/first_htl_WCMUsePojo.html

7.20 SlingModel

https://helpx.adobe.com/experience-manager/using/aem64_coral_resourcetypes.html

7.21 创建custom sling servlet

https://helpx.adobe.com/experience-manager/using/resourcetypes.html

7.22 创建render component

https://helpx.adobe.com/experience-manager/using/resourcetypes.html#h2Createarendercomponentthatusesthetemplatebrh2

7.23 创建一个Servlet service

http://www.6dglobal.com/blog/servlets-sling-case-disappearing-servlet-path-2013-01-31

7.24 Sling Servlet service 文档

https://sling.apache.org/documentation/the-sling-engine/servlets.html

7.25 SegmentNotFound Issue or AuthenticationSupport service missing issue

https://github.com/tobywang11030/mangoCMS/blob/master/SegmentNotFound%20Issue%20and%20AuthenticationSupport%20service%20missing%20issue

7.26 Mvn build 时出现类似不能下载Adobe相关依赖的依赖性错误

Maven settings
http://helpx.adobe.com/experience-manager/kb/SetUpTheAdobeMavenRepository.html
运行时加上

 -Padobe-public

7.27 Editable and Static Templates

7.27.1 Editable Templates

官方定义

7.27.2 Static Templates

By definition, the template console and template editor only allow creation and editing of editable templates. Therefore this document focuses exclusively on editable templates.

7.28 Sling Query

使用Sling query可实现类似JQuery选择器的体验来查询JCR,例如当前节点的上一个和下一个节点等实现分页效果 https://sling.apache.org/documentation/bundles/sling-query.html

8. Self-Assessment Preparation and Learning worksheet

Topics Cost(hours) Details Reference Start Date End Date Completed? Questions Comment
Basic AEM knowledge study
Installing and configuring an AEM developer environment 1. Install AEM on supported operating systems.
2. Install AEM with different run modes (Author and Publish).
3. Start AEM in debug mode for remote debugging.
4. Setup and configure replication agents.
5. Setup and configure a Web server
5. Setup and manage OSGi configurations.
6. Manage users and groups
7. Manage Access Control Level (ACL) permissions.
Building and deploying AEM projects 1. Configure a source control system to manage files in AEM
2. Build and deploy AEM projects by using Maven
Building AEM components 1. Create custom components and dialogs
2. Create templates and page components
3. Create client libraries.
4. Extend out-of-the-box AEM components.
Building OSGi services 1. Create custom OSGi services.
2. Create and manage custom OSGi configurations.
3. Configure and manage OSGi services and bundles by using the Felix web console.
4. Manage Maven dependencies.
Troubleshooting AEM projects 1. Create custom log files by using the Web console.
2. Configure and manage AEM log levels for specific AEM environments.
3. Given an option for starting AEM, I can select the correct parameter(s) for starting AEM.
4. Troubleshoot caching issues related to the Dispatcher and browsers.
5. Troubleshoot AEM configurations.

9. AEM实战项目 Mango

9.1 Mango项目介绍

Mango是一个企业门户网站,主要功能是展示企业信息,企业动态,企业大事记等。

9.2 项目需求-基础篇

AEM advanced technical knowledge study

1. 系统维护

1.1 清理磁盘空间占用

AEM使用一段时间之后,因AEM的存储机制问题,AEM的Repository的文件夹的大小会越来越大,会造成极大的系统开销甚至导致数据错误时AEM崩溃无法运行。AEM6.3以后提供两种方式清理AEM的数据仓库以节省磁盘占用。下面为具体步骤,亦可参考Adobe官网https://helpx.adobe.com/experience-manager/6-4/sites/deploying/using/revision-cleanup.html

1.1.1 Online Revision Cleanup

依次进入Tools-Operations-Maintenance 进入系统维护工具 或者直接访问 http://localhost:4502/libs/granite/operations/content/maintenance.html 在这里插入图片描述 AEM提供了两组清理工具,一组为建议Daily执行的,一组为建议Weekly执行的。 点击Daily Maintenance Window,即可发现系统默认提供了两个清理工具
在这里插入图片描述 可以直接手动运行这个Revision Clean Up,该工具运行后,可以减少repository\segmentstore文件夹的大小 点击Weekly Maintenance Window,即可发现系统默认提供了两个清理工具
在这里插入图片描述
可以直接手动运行这个Data Store Garbage Collection,该工具运行后,可以减少repository\datastore文件夹的大小
备注:如发现运行Online Revision Cleanup中的任何清理工具均无任何效果,则需要用Offline Revision Cleanup进行清理。该问题根据官网介绍,可能是因为清理机制的问题。

1.1.2 Offline Revision Cleanup

如发现Online Revision Cleanup的方式无法清理,需要使用Offline Revision Cleanup

首先访问https://repo1.maven.org/maven2/org/apache/jackrabbit/oak-run/下载合适版本的 oak-run.jar 工具

然后关掉AEM实例

依次执行如下命令:

Shut down AEM.

执行命令

java -jar oak-run.jar checkpoints install-folder/crx-quickstart/repository/segmentstore

执行命令

 java -jar oak-run.jar checkpoints install-folder/crx-quickstart/repository/segmentstore rm-unreferenced

执行命令

java -jar -Dsun.arch.data.model=32 oak-run.jar compact install-folder/crx-quickstart/repository/segmentstore

1.2 关闭AEM默认的Version生成方式进一步永久性的减小磁盘占用

AEM默认会开启Version生成,当你上传,更新,新建,发布一个页面或者asset时,均会生成一个对应的Version,而这些额外的Version默认设置下是不会被删除的,会造成磁盘占用越来越大,可以通过修改VersionManagerImpl这个类的设置开关闭Version生成,或者开启Version Purgin功能自动清理Version。 在这里插入图片描述

1.3 数据存储方式

AEM有两种形式的数据,一种为Node数据,主要存储的是JCR属性,另一个为二进制数据,主要存储的是上传的图片,视频等。安装并启动一个AEM实例后,在默认情况下,这两种形式的数据均以Tar Storage(一种文件存储系统)的形式储存在本地磁盘中。可参考https://helpx.adobe.com/experience-manager/6-4/sites/deploying/using/storage-elements-in-aem-6.html

1.3.1 File Storage

AEM的默认数据存储方式,该方式下数据已Tar文件的形式存储,该方式具有比较高的性能,也是AEM建议的存储方式,该方式的缺点是如果用户会上传大量的图片,视频,以及每天会有大量的author和修改的话,会造成repository文件夹很大,甚至几TB,这样一是比较昂贵,而是因为数据文件过多,增加了数据损坏导致系统崩溃的风险。

该模式的几种优化方案:

1.3.2 Mongo Storage

根据AEM官方介绍,如果符合以下条件,建议使用Mongo Storage存储方式,否则还是应使用默认的file storage

启用该存储方式,可以将Node数据以及二进制数据(可选,二进制数据仍可以已文件形式存在本地磁盘或者S3等第三方云),这样可以借助Mongo Storage的高性能,分布式的特点提高AEM的数据存储性能。具体可参考https://helpx.adobe.com/experience-manager/6-4/sites/deploying/using/aem-with-mongodb.html

2. Self-Assessment Preparation and Learning worksheet

Topics Cost(hours) Details Reference Start Date End Date Completed? Questions Comment
Install and Configure the AEM Environment 1. Identify the default runmode of the AEM server
2. Identify the default runmode of the AEM server
3. Apply best practices for installation of AEM 6.0 ondifferent operating systems
4. Determine the valid run modes to operate AEM
5. State the configurations required for the installation on application servers
6. Identify the supported operating system for installing AEM on an application
Build and deploy AEM projects 1. Apply version control management best practices
2. Apply standard procedures to create multi-module Maven projects
3. Apply standard procedures to develop and debug application using IDE
Build AEM Components 1. Given a scenario, I can analyze and evaluate the usage of forms, metadata and other features
2. Apply best practices to create and use client libraries
3. Apply best practices to create, customize, and configure AEM components and dialogs
4. Given a scenario, I can determine workflow steps and processes
5. Apply standard procedures to create and extend AEM components, templates, and page components
Create and configure OSGI services 1. Apply standard processes to manage OSGI bundles,services and dependencies
2. Analyze and evaluate the logs to identify discrepancies
3. Given a scenario, I can determine the OSGI configuration
4. Apply a standard process to create OSGI components and services
Setup content structure and taxonomy 1. Apply best practices to manage user-generated content
2. Given a scenario, I can analyze content structure and evaluate query efficiency
3. Apply standard procedures to manage AEM tagging framework
4. Given a scenario, I can analyze workflows to setup multilingual sites
Create AEM security policies 1. Evaluate AEM users and group permissions
2. Apply standard processes to set up CUGs
3. Evaluate ACLs and permission level for users/groups
Set-up and configure deployment infrastructure 1. Analyze and evaluate logs and other artifacts to manage garbage collection and TAR optimization
2. Apply standard procedure for backend data store configuration
3. Apply standard procedures to integrate AEM applications with Marketing Cloud tools and third-party tools
4. Apply standard procedures to integrate AEM applications with LDAP/SSO/OAUTH Providers/Third-Party login authentication mechanisms
Troubleshoot AEM projects 1. Troubleshoot issues related to performance
2. Troubleshoot functional issues
3. Identify issues related to scalability bottlenecks