Testing Alfresco from command line with CURL and CMIS Browser

Recently, I’ve been working to automate ALF_NODE_PROPERTIES table partition process in PostgreSQL for Alfresco. This process creates several partitions for the table, including older contents in the first partition and new contents in the last one. Once the table has been partitioned is required to test CRUD for properties belonging to nodes in every segment to ensure that every partition has been properly set up.

Using CMIS Browser protocol to access Alfresco, simple CURL sentences can perform such operations.

Modifying a property for an existing content

Alfresco provides the same sample files on every installation, so a property of one of this sample files can be created or modified to test CRUD in the first partition.

Following command will modify cmis:description property value to “test” at Data Dictionary > scripts > alfresco docs.js.sample file.


$ curl -X POST \
'http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/Data%20Dictionary/scripts/alfresco%20docs.js.sample?cmisSelector=object' \
-H 'authorization: Basic YWRtaW46dGVtcG9yYWw= \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'cmisaction=update&propertyId%5B0%5D=cmis%3Adescription&propertyValue%5B0%5D=testok&succinct=true'

Content for every intermediate partition can be selected to perform the same command.

Creating a new content

Every new content will be created in the last partition, so to test CRUD in this partition an upload command can be used.

Following command will create a file named “test.txt” at Shared repository folder.

$ curl -X POST \
  http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/Shared \
  -H 'authorization: Basic YWRtaW46dGVtcG9yYWw=' \
  -H 'content-type: multipart/form-data' \
  -F cmisaction=createDocument \
  -F 'propertyId[0]=cmis:objectTypeId' \
  -F 'propertyValue[0]=cmis:document' \
  -F 'propertyId[1]=cmis:name' \
  -F 'propertyValue[1]=test.txt' \
  -F file=@/tmp/test.txt \
  -F succinct=true

Removing a content

Partition testing does not require this additional command, but it has been included to clear our operations in the server.

Following command will remove the file “test.txt” we’ve just created at Shared repository folder.

curl -X POST\
  http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/Shared/test.txt \
  -H 'authorization: Basic YWRtaW46dGVtcG9yYWw=' \
  -H 'content-type: multipart/form-data' \
  -F cmisaction=delete \
  -F succinct=true 

Alfresco makes it so simple to automate our operations!

Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s