Thursday, December 22, 2016

Alfresco: API to Delete a Specific Document Version

Version 2.3 of the Formtek Version Browser for Alfresco 5.1 was released this week.  A new feature in this release is a delete action that allows users to delete specific versions of a document.

The Delete Version action is shown highlighted by the red box in the screenshot shown here:

This same functionality can be accessed programmatically.

Installation of the Version Browser also activates two different APIs for deleting a version: either as a REST webscript service call or by using an Alfresco server-side Javascript.  I'll describe briefly here how that functionality can be accessed.

GET REST Service Call

Versions can be deleted with the following GET REST webscript.

Here the parameters are:
    {item_store_type}/{item_store_id}/{item_id} - The nodeRef of the document (not the specific version)
    {delversion} - The version label of the version being deleted.  Note that a hyphen is used here and not a period to separate the major from the minor part of the version label.

Here is an example that deletes version 1.0 of a document:


Running this in a browser will return with the following result:

Javascript API call

You can also use a Formtek-defined Javascript method in your server-side Javascript programming for webscripts and rules to delete a version.

The method can be called as follows:

        ftkver.delete(nodeRef, verlabel);

    nodeRef = String with the nodeRef id of the main document
    verlabel = String with the version label

This method returns a boolean that is true when the version is successfully deleted.

Note again that this functionality is not a standard Alfresco capability and available only with the Formtek Version Browser.

Wednesday, December 14, 2016

After an Alfresco upgrade or content refresh some users are unable to login.

How can it be that after an Alfresco upgrade or content refresh most users can log in but a few users are unable to log into Alfresco? It's possible that some of the data is corrupted. This could be the case if Tomcat was left running while the database backup copy was created. Whatever the reason there is a common cause that is easily verified and corrected.  

Before moving on to the verification and solution section below make sure you are in a situation where only a few selected users are unable to login. Here you go:

1. Under the Admin Tools, via the node browser, find one of users that is unable to login: Search in the node browser for “/sys:system/sys:people/ cm:UserName” using XPATH where ‘Username’ is the user’s login.

Example:  /sys:system/sys:people/cm:jsmith

2. Expand the workspace preference and locate the content url from the “cm:preferenceValues”. It should look similar to: contentUrl=store://2016/11/19/13/43/da13c437-488b-48b5-9a30-9edc85677020.bin|mimetype=text/plain|size=1974|encoding=UTF-8|locale=en_US_|id=1922

3. Now go to your contentstore folder location and make sure the listed ‘bin’ file exist in that path in the contentstore.

4. If it does not exists the user will not be able to login. So, if the file is not there create a file with the exact name as shown in the “cm:preferenceValues”bin in the corresponding directory. NOTE: If the folders don’t exist you will have to create these directories. Create a plain text file and simply put in empty json brackets; ‘{}’.

5. If it exists open it via text editor and fix the existing file by adding simple ‘{}’ json brackets.

6. Look through the rest of the values and identify any with a ‘bin’ file in the contentstore. If you find any you should verify that the file is there and contains the ‘{}’ json brackets.

NOTE: You should not have to restart Alfresco for this change to take effect. Simply have the user retest their login.