Developing Take Ownership Extension for ACA 2.8.0

cancel
Showing results for 
Search instead for 
Did you mean: 

Developing Take Ownership Extension for ACA 2.8.0

angelborroy
Alfresco Employee
1 0 2,310

This blog post describes how to develop an Action Extension for the Alfresco Content App. Take Ownership action, coming from legacy Alfresco UI, has been published as a new Node module ready to be applied to an ACA deployment.

https://www.npmjs.com/package/take-ownership

Source code for the module is available in:

https://github.com/aborroy/aca-take-ownershiptake-ownership-screen.png

 

Take Ownership action is available from context menus, toolbars and viewer.

This module has been developed with ACA 2.8.0, ACS 7.1.1 and NodeJS 12.22.10

Let's review below the process followed to create this new extension.

 

Setting up development environment

A regular development environment should include a running Alfresco repository and an Angular working folder.

There are different alternatives to run Alfresco Repository locally, like using the Alfresco Docker Installer tool.

$ mkdir docker
$ cd docker
$ yo alfresco-docker-installer
? Which ACS version do you want to use? 7.1
? How may GB RAM are available for Alfresco (16 is minimum required)? 16
? Do you want to use HTTPs for Web Proxy? No
? What is the name of your server? localhost
? Choose the password for your admin user admin
? What HTTP port do you want to use (all the services are using the same port)? 8080
? Do you want to use FTP (port 2121)? No
? Do you want to use MariaDB instead of PostgreSQL? No
? Are you using different languages (this is the most common scenario)? Yes
? Would you like to use HTTP, HTTPs or Shared Secret for Alfresco-SOLR communication? http
? Do you want to use credentials for Events service (ActiveMQ)? No
? Do you want to create an internal SMTP server? No
? Do you want to create an internal LDAP server? No

$ docker-compose up --build --force-recreate

Once the Repository is up and running, ACA application folder can be configured.

$ git clone git@github.com:Alfresco/alfresco-content-app.git
$ cd alfresco-content-app
$ vi .env
# App config settings
APP_CONFIG_BPM_HOST="<url>"
APP_CONFIG_ECM_HOST="http://127.0.0.1:8080"
APP_CONFIG_OAUTH2_HOST="<url>"
APP_CONFIG_IDENTITY_HOST="<url>"
APP_CONFIG_PROVIDER="ALL"
APP_CONFIG_AUTH_TYPE="OAUTH"
APP_CONFIG_OAUTH2_CLIENTID="alfresco"
APP_CONFIG_OAUTH2_IMPLICIT_FLOW=true
APP_CONFIG_OAUTH2_SILENT_LOGIN=true
APP_CONFIG_OAUTH2_REDIRECT_SILENT_IFRAME_URI="{protocol}//{hostname}{:port}/assets/silent-refresh.html"
APP_CONFIG_OAUTH2_REDIRECT_LOGIN=/
APP_CONFIG_OAUTH2_REDIRECT_LOGOUT=/
# CONTENT - ALFRESCO OFFICE SERVICES PLUGIN RELATED
APP_CONFIG_PLUGIN_AOS=true

$ npm install

At this point, the environment is ready to create the take-ownership module (empty by now).

$ ng generate library take-ownership
$ ng build take-ownership

Verifying that evertything is in place, can be achieved by running the ACA app.

$ npm start

Developing the extension

This extension requires using some ADF / ACA components, that are mainly described in the ACA Docs Extending section.

 

take-ownership-diagram.png

The module uses the ExtensionService to integrate with the ACA app and the TranslationService to provide i18n resources. An evaluator, defining when the action is enabled, is examining current user permissions and role. The effects for the action are invoking the service when the user confirms the action in the dialog component. And the service is invoking Alfresco REST API to perform the change in the cmSmiley Surprisedwner property.

More details on this implementation are available in

https://github.com/aborroy/aca-take-ownership/tree/main/projects/take-ownership

 

Creating an independent module

Once the code is running as expected, isolating this feature in a different project can be done by following these steps.

Create a new library as described in Angular Creating Libraries documentation.

$ ng new aca-take-ownership --no-create-application
$ cd aca-take-ownership
$ ng generate library take-ownership

Copy the source code and main dependencies for package.json into your new project to create something like https://github.com/aborroy/aca-take-ownership

Build and pack the library.

$ npm run build:take-ownership
$ cd dist/take-ownership
$ npm pack

From this point, the take-ownership-0.0.1.tgz package is ready to be installed. You may also use npm publish to upload this package to npm.js, but we're staying with local deployment in this blog post.

 

Installing the extension

The project living in https://github.com/aborroy/aca-take-ownership includes a simple shell script to install and uninstall the package on a clean ACA application.

Follow next steps to start an ACA application with the take-ownership application installed

$ ./aca-apply-extension.sh -aca -install

$ cd alfresco-content-app

$ vi .env
# App config settings
APP_CONFIG_BPM_HOST="<url>"
APP_CONFIG_ECM_HOST="http://127.0.0.1:8080"
APP_CONFIG_OAUTH2_HOST="<url>"
APP_CONFIG_IDENTITY_HOST="<url>"
APP_CONFIG_PROVIDER="ALL"
APP_CONFIG_AUTH_TYPE="OAUTH"
APP_CONFIG_OAUTH2_CLIENTID="alfresco"
APP_CONFIG_OAUTH2_IMPLICIT_FLOW=true
APP_CONFIG_OAUTH2_SILENT_LOGIN=true
APP_CONFIG_OAUTH2_REDIRECT_SILENT_IFRAME_URI="{protocol}//{hostname}{:port}/assets/silent-refresh.html"
APP_CONFIG_OAUTH2_REDIRECT_LOGIN=/
APP_CONFIG_OAUTH2_REDIRECT_LOGOUT=/
# CONTENT - ALFRESCO OFFICE SERVICES PLUGIN RELATED
APP_CONFIG_PLUGIN_AOS=true

$ npm start

If you want to uninstall the package and remove extension config modifications in ACA, just type the following:

$ ./aca-apply-extension.sh -uninstall
$ npm start

Video recording

Find additional material in this video.

 

Additional resources

About the Author
Angel Borroy is Hyland Developer Evangelist. Over the last 15 years, he has been working as a software architect on Java, BPM, document management and electronic signatures. He has been working with Alfresco during the last years to customize several implementations in large organizations and to provide add-ons to the Community based on Record Management and Electronic Signature. He writes (sometimes) on his personal blog http://angelborroy.wordpress.com. He is (proud) member of the Order of the Bee.