Consider a scenario where a company uploads thousands of documents related to its policies or some other stuff in AEM. It would be an overhead for AEM to manage those documents resulting in the degradation of performance since AEM is already managing a lot of tasks.
Solution
One way of managing documents and avoid overhead in AEM is to use document management systems like Dropbox and Google Drive. On the AEM side, we would have some way to make those documents available for view/download purposes.
One way of managing documents and avoid overhead in AEM is to use document management systems like Dropbox and Google Drive. On the AEM side, we would have some way to make those documents available for view/download purposes.
Following customization needs to be done:
Customization of Touch UI content Finder: Adding one more option in the Asset category and to showcase dropbox documents in the content finder on the selection of this option.
Integration with Dropbox: Fetching the metadata of the documents using Importer
Creation of droppable component: Enabling users to drop assets from asset categories onto the page.
Metadata management of Dropbox documents
Steps to Integrate Dropbox with AEM:
Now open the above js file and then change the “name” property to “Dropbox Docs” and “itemResourceType” to the path “cq/gui/components/authoring/assetfinder/dropbox”
Create js.txt in the same hierarchy and add the path to the file created in the above step and save all the above changes. Now open any page in TOUCH UI mode, you will find an extra option being added in the dropdown.
Note: It can be any path. But according to you need to change the itemResourceType property.
(c) We need to create the component in which dropbox documents can be dropped. So you can create a copy of the OTB download component and modify the script accordingly.
That’s it……….
This is how the directory structure will look like:
Customization of Touch UI content Finder: Adding one more option in the Asset category and to showcase dropbox documents in the content finder on the selection of this option.
Integration with Dropbox: Fetching the metadata of the documents using Importer
Creation of droppable component: Enabling users to drop assets from asset categories onto the page.
Metadata management of Dropbox documents
Steps to Integrate Dropbox with AEM:
Pre-requisites:
Java 1.8 (Only in case if you install the source code attached below as the source contains some Java 8 specific code snippet.)
You also need to install Jackson-core bundle as dropbox-SDK has a dependency on it
Java 1.8 (Only in case if you install the source code attached below as the source contains some Java 8 specific code snippet.)
You also need to install Jackson-core bundle as dropbox-SDK has a dependency on it
Step1:
Sign up in dropbox and create a developer app in dropbox using the following link:
https://www.dropbox.com/developers/apps/create
For our integration Dropbox with AEM, we would be requiring the Access Token ( You need Click on the “Generate Token” button to get the Access token. The reason we are generating the token from the dropbox portal only so that we can skip the manual flow of OAuth2. For OAuth2 flow you can access OAuth2.0 )
Sign up in dropbox and create a developer app in dropbox using the following link:
https://www.dropbox.com/developers/apps/create
For our integration Dropbox with AEM, we would be requiring the Access Token ( You need Click on the “Generate Token” button to get the Access token. The reason we are generating the token from the dropbox portal only so that we can skip the manual flow of OAuth2. For OAuth2 flow you can access OAuth2.0 )
Step2:
Create the cloud services config page for Dropbox that has authoring dialog for parameters like Access Token, Target URL, Client-Identifier, Interval (The last three parameters we would be needed for creating the custom importer)
For creating the custom cloud service, please refer Create Custom Cloud service
Step3: Adding dependencies related to dropbox. I have used the maven build tool. Add the following dependency to the project’s pom.xml
<dependency>
<groupId>com.dropbox.core</groupId>
<artifactId>dropbox-core-sdk</artifactId>
<version>1.7.7</version>
</dependency>
Also, Embed transitive dependencies used by dropbox SDK using the following code:
<Embed-Dependency>dropbox-core-sdk;scope=compile|runtime</Embed-Dependency>
Step4:
Create the dropbox config page using the template that was created in Step2. You can go to “http://<domain>:<port-no>/miscadmin#/etc/cloudservices” and create the page. The page would be created under the directory in CRXDE:
“/etc/cloudservices/”
Add configure the page accordingly. Please see the below snapshot for reference.
Create the cloud services config page for Dropbox that has authoring dialog for parameters like Access Token, Target URL, Client-Identifier, Interval (The last three parameters we would be needed for creating the custom importer)
For creating the custom cloud service, please refer Create Custom Cloud service
Step3: Adding dependencies related to dropbox. I have used the maven build tool. Add the following dependency to the project’s pom.xml
<dependency>
<groupId>com.dropbox.core</groupId>
<artifactId>dropbox-core-sdk</artifactId>
<version>1.7.7</version>
</dependency>
Also, Embed transitive dependencies used by dropbox SDK using the following code:
<Embed-Dependency>dropbox-core-sdk;scope=compile|runtime</Embed-Dependency>
Step4:
Create the dropbox config page using the template that was created in Step2. You can go to “http://<domain>:<port-no>/miscadmin#/etc/cloudservices” and create the page. The page would be created under the directory in CRXDE:
“/etc/cloudservices/”
Add configure the page accordingly. Please see the below snapshot for reference.
Step 5:
Till now we are done with the basic setup required for integration. It’s time to code NOW.
Create a custom importer that will poll the dropbox and fetch the metadata of the documents. The importer will also create a node (of type dam: Asset) under the path specified in the cloud-config dialog of Dropbox Cloud Configuration Page created in Step4.
For reference, you can download DropboxImporter.java
Till now we are done with the basic setup required for integration. It’s time to code NOW.
Create a custom importer that will poll the dropbox and fetch the metadata of the documents. The importer will also create a node (of type dam: Asset) under the path specified in the cloud-config dialog of Dropbox Cloud Configuration Page created in Step4.
For reference, you can download DropboxImporter.java
Step6: Once the importer will be created, the only part left is to display the imported content in DAM’s content finder.
Note: The solution provided for displaying the content would only work in TOUCH UI because of the overlying structure of the component.
(a) To add the option in dropdown for the category under Asset tab in Content finder, we need to do the following:
Note: The solution provided for displaying the content would only work in TOUCH UI because of the overlying structure of the component.
(a) To add the option in dropdown for the category under Asset tab in Content finder, we need to do the following:
Overlay the following structure: /libs/cq/gui/components/authoring/clientlibs/assetfinder/js in apps. Delete all the child folders under js.
Create a folder “dropboxdocument” and place the .js file under it. You can copy the .js file from /libs/cq/gui/components/authoring/clientlibs/assetfinder/js/document/documentController.js. Rename the file as per your wish and save.
Create a folder “dropboxdocument” and place the .js file under it. You can copy the .js file from /libs/cq/gui/components/authoring/clientlibs/assetfinder/js/document/documentController.js. Rename the file as per your wish and save.
Now open the above js file and then change the “name” property to “Dropbox Docs” and “itemResourceType” to the path “cq/gui/components/authoring/assetfinder/dropbox”
Create js.txt in the same hierarchy and add the path to the file created in the above step and save all the above changes. Now open any page in TOUCH UI mode, you will find an extra option being added in the dropdown.
Key Properties:
name: The label that will be shown in the dropdown
itemResourceType: is the component that will be rendered in content finder for each asset
imageServlet: the service that will list of assets that match the mime types given in param and in response it will give the HTML code
(b) Now we need to customize the code the component mentioned in itemResourceType property so that it can show the desired properties of the asset in the content finder. Copy dropbox.jsp to the path “/apps/cq/gui/components/authoring/assetfinder/dropbox/”
name: The label that will be shown in the dropdown
itemResourceType: is the component that will be rendered in content finder for each asset
imageServlet: the service that will list of assets that match the mime types given in param and in response it will give the HTML code
(b) Now we need to customize the code the component mentioned in itemResourceType property so that it can show the desired properties of the asset in the content finder. Copy dropbox.jsp to the path “/apps/cq/gui/components/authoring/assetfinder/dropbox/”
Note: It can be any path. But according to you need to change the itemResourceType property.
(c) We need to create the component in which dropbox documents can be dropped. So you can create a copy of the OTB download component and modify the script accordingly.
That’s it……….
This is how the directory structure will look like:
Download Source Code: dropbox-integration
Source: https://www.tothenew.com/blog/making-dropbox-documents-available-in-aem/
Source: https://www.tothenew.com/blog/making-dropbox-documents-available-in-aem/
No comments:
Post a Comment
If you have any doubts or questions, please let us know.