- How to get an API access token?
- How to work with Refresh Token and Access Token?
- How to Create and Deploy a Custom Publishing Activity?
- How to Create, Run, and Deploy a Custom Service?
- How to set or get the value of an attribute?
- How to create and manage a publishing channel?
- How to migrate configurations from one server to another?
- How to migrate REST Endpoints from v1.x to v3.x of QPPNG?
- How to retrieve audit events?
- How to generate custom audit events?
- How to check-in an asset to the repository?
- How to verify the status of a checked-in asset?
- How to create a collection on the repository?
- How to publish a document?
How to Create and Deploy a Custom Publishing Activity?
Pre-requisites
You must have the following installed on your machine:
- Java 8
- Maven
You must have access to download quark maven artifacts to update the file settings.xml in the folder .m2 to register quark maven repository through the following code:
<server>
<id>qrk-visualstudio-com-qrk-contentplatform</id>
<username>contentplatform</username>
<password>[PERSONAL_ACCESS_TOKEN]</password>
</server>
- Eclipse
Process
To create and deploy custom publishing activity:
Open Eclipse and create a new maven project.
Add the dependencies that your custom activity requires along with the following dependencies in pom.xml.
<dependency> <groupId>com.quark.qcep.contentservices</groupId> <artifactId>qcep-contentservices-remoting-stubs</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.quark.qcep.automation</groupId> <artifactId>qcep-automation-activities</artifactId> <version>1.0-SNAPSHOT</version> </dependency>
Add <repositories> and <distributionManagement> sections to your pom.xml
<repositories> <repository> <id>qrk-visualstudio-com-qrk-contentplatform</id> <url>https://qrk.pkgs.visualstudio.com/_packaging/contentplatform/maven/v1</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <distributionManagement> <repository> <id>qrk-visualstudio-com-qrk-contentplatform</id> <url>https://qrk.pkgs.visualstudio.com/_packaging/contentplatform/maven/v1</url> </repository> </distributionManagement>
You must also add any third-party dependencies that your custom activity requires.
Create a package com.quark.qcp.cas.publishing.activity.ext and add the file activity.java to the package.
Add your channel definition in the file ChannelConfig-ext.xml, which is available in folder ext in the s3 bucket of already running automation services.
See the following example of the channel ChannleConfig-ext.xml, sends an asset content to a particular folder in S3 bucket:<channel id="sendToS3" name="Send to S3" publishingProcess="sendToS3" type="deliver"> <description>Sends the content to S3</description> <param name="BUCKET_NAME" ask="true"/> <param name="FOLDER_NAME" ask="true"/> <param name="REGION_NAME" ask="true"/> <param name="ACCESS_KEY" ask="true"/> <param name="SECRET_KEY" ask="true"/> <!-- <param name="PASSWORD" ask="true"/><param name="OVERWRITE_EXISTING" ask="true">TRUE</param><param name="NAME" ask="true"/> --> <!-- Name with which the desired resource would be copied to the given S3 folder location--> </channel>
Create a file that has the process definition. For example, see the following file named SendToS3ProcessConfig.xml:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" xmlns:pub="http://www.quark.com/qpp/publishing/schema" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.quark.com/qpp/publishing/schema http://www.quark.com/qpp/publishing/schema/publishingprocess.xsd"> <!-- PROCESS DEFINITIONS --> <pub:process id="sendToS3"> <!-- A process to send file(s)/folder(s) to S3 location. --> <pub:activity class="com.quark.qcp.cas.publishing.activity.SendToS3"> <description>An activity that sends (i.e. adds / updates) content to S3 at the specified location</description> <property name="activityName"> <value>SendToS3</value> </property> <property name="bucketName"> <value>PARAM:BUCKET_NAME</value> </property> <property name="folderName"> <value>PARAM:FOLDER_NAME</value> </property> <property name="regionName"> <value>PARAM:REGION_NAME</value> </property> <property name="accessKey"> <value>PARAM:ACCESS_KEY</value> </property> <property name="secretKey"> <value>PARAM:SECRET_KEY</value> </property> </pub:activity> <pub:activity-stream-mapper> <property name="activityName"> <value>SendToS3</value> </property> <property name="inputStreamNames"> <map> <entry key="SourceContent" value="RequestContent"/> </map> </property> </pub:activity-stream-mapper> </pub:process> </beans>
Add ProcessDefinition to classpath by through import for the process definition file in ProcessConfig-ext.xml. This is also available in the folder ext in the s3 bucket of already running automation services.
For example:Package this project using the following maven package command.
D:\.....\qcp-cas-custom-activity> mvn package
This creates a jar file in the target directory inside the source directory of the project.
Copy the files creates/updated in the steps from 4 through to 7 in the folder ext in the s3 bucket of already running automation service.
Add all the third-party dependencies such as aws-java-sdk-core-1.11.795.jar and joda-time-2.8.1.jar (including transitive dependencies) inside the folder ext in the S3 bucket of already running automation service as shown in step 8.
Restart the automation services container using the following command:
docker restart qcpautomationservice
Verify whether the new channel has been deployed by executing following GET REST request:
{{PROTOCOL}}://{{MACHINE_NAME}}:{{PORT}}/api/v1/publishingService/getChannel?channelId=sendToS3
Debug custom activity remotely:
- Connect to the updated automation services remotely to debug by attaching to it at port 61411.
- Import the debug configurations and update the project to be debugged.
When there are issues while executing an activity/process/channel that you have created, fix the code and update the files associated to the folder ext in the s3 bucket.