Wednesday, February 22, 2017

Alfresco Share - How to remove Comments field and hide the Comment link on Document Details page

The document details page is developed using Surf, use the SurfBug tool to identify the components for the Comments field and Comment  link. The SurfBug tool can activated using the following URL: 

http://localhost:8080/share/page/surfBugStatus

After enabling the SurfBug tool click on the Comment link and Comments field to find out the region-id and source-id for the Comments field and link. We need these values to remove the Comments field and hide the Comment link on document details page.





After getting the region-id and source-id add a Spring Surf extension module that tells Share not to render the Comments field and hide the Comment link.

In the extension module override the default sub-components and add new evaluations for it. The region-id and source-id values that we got from the Surfbug tool should be used to identify the components.

In the sub-component evaluation of Comments field specify a unique id and set render to false. This evaluation will hide the Comments field on document details page.

In the sub-component evaluation of node-header specify a unique id and set showComments property to false. This evaluation will hide the Comment link on document details page.

Set the auto-deploy property of the module to true. Restarting the Alfresco server will automatically deploy this module. An example extension module is shown below:


Restart the server. Login to Alfresco Share and go to the document details page, the Comment link and the Comments field should now be removed from the page.



Tuesday, January 31, 2017

How to Change the Alfresco Share Landing Page for all Users

In Alfresco 5.1.x, it’s easy for users to change their own home page. The Use Current Page option in the user menu can be used to change the logged in user’s home page to the current page. And, the home page can also be reset back to the user’s dashboard with the selection of the Use My Dashboard option.


But, what if you want all of your Alfresco users to use the same landing page when they log in to Alfresco Share? Perhaps you’d like it to be your corporate site dashboard or a heavily-used site folder? Instead of having your users individually change their home page, an admin user can easily make a global change for all users like this:
1.      Open the TOMCAT/webapps/share/site-index.jsp file for editing.

a.       Look for the following lines at the bottom of the file:

    // redirect to site or user dashboard as appropriate
     String siteName = request.getParameter("site");
        if (siteName == null || siteName.length() == 0)
     {
        // Get and forward to user's home page
        SlingshotUserFactory slingshotUserFactory =
                (SlingshotUserFactory) FrameworkUtil.getServiceRegistry().getUserFactory();
        String userHomePage = slingshotUserFactory.getUserHomePage(context, userid);
        response.sendRedirect(request.getContextPath() + userHomePage);
     }
     else
     {
        // forward to site specific dashboard page
        response.sendRedirect(request.getContextPath() + "/page/site/" + URLEncoder.encode(siteName) +  "/dashboard");
     }

b.      Set the "siteName" variable to your preferred landing page site name, for example:

  String siteName = request.getParameter("site");
     siteName = "formtek";

      c.       If you want your site dashboard to be the new landing page, you’re done editing the file.                        However, if you want your new landing page to be a folder in your site, you’ll need to make                  one more change to replace “dashboard” in the following line with the document library                        folder of  your choice:

 response.sendRedirect(request.getContextPath() + "/page/site/" +    URLEncoder.encode(siteName) + "/dashboard");

In this example, I’m using the “Policies and Procedures” folder in the site’s document library:

 response.sendRedirect(request.getContextPath() + "/page/site/" +  URLEncoder.encode(siteName) +  "/documentlibrary#filter=path%7C%2FPolicies%2520and%2520Procedures%7C&page=1");

NOTE: To get the correct folder syntax, you can navigate to the folder in Alfresco Share and copy the folder syntax from the browser address bar.

d.      Save your changes and close the file.

2.      Restart Alfresco for the changes to take effect.

Now, when a user logs in to Alfresco Share, the user will be redirected to your newly configured landing page. Here are two different results for the above examples:

The configured site dashboard is the new landing page:

The configured site folder is the new landing page:

It is important to note that if your new landing page restricts site membership (as in the case of the “private” example site above), non-members would see the following upon login:


Clicking the “Back to My Dashboard” button redirects unprivileged users to their own home page. To eliminate this scenario, changes would need to be made to verify site membership and only redirect site members to the new landing page. (Perhaps the discussion of a future post.)

Wednesday, January 25, 2017

Restricting Availability of Alfresco Dashlets by Group

There are two kinds of dashboards in Alfresco Share: User and Site dashboards.  By default, after logging into Share, the user is presented with a customizable dashboard page.  The dashboard page is made up of dashlets that can be arranged using the Customize User Dashboard page, as shown here. Site dashboard pages can be similarly arranged and customized by the site managers.


Developers are able to create new dashlets that can be added to the list of available dashlets. A dashlet is composed of a number of files, one of which is called the descriptor file.  The descriptor file is a brief XML document that describes the name, description and availability information about the dashlet.

Alfresco documentation describes how the <family> tag can be used in the descriptor to specify which of the two dashboards the dashlet can appear: on the user, site, or both of the dashboards.

The family tag can take the following values:
  • user-dashlet - for use on the User Dashboard
  • site-dashlet - for use on the Site Dashboard
  • dashlet - for use on either User or Site Dashboards
But, there is another use for the family tag which isn't well documented.  The family tag can also be used to restrict availability of a dashlet by group. In that case, the name of the group is included in the family tag, like this:

 <family>group:GROUP_ALFRESCO_ADMINISTRATORS</family>  

Here we refer to the Alfresco administrators group called ALFRESCO_ADMINISTRATORS.  Note that the group name used within Alfresco code prefixes all names with GROUP_. We see the group is referenced here as GROUP_ALFRESCO_ADMINISTRATORS, even though it is displayed as ALFRESCO_ADMINISTRATORS in the Group Browser of the Share UI.



Now, let's consider a specific case. When developing the Formtek Peer Association Extension, we had the need for a dashlet to be available only to administrators from their user dashboards. To enforce both restrictions, we used the following dashlet descriptor file with two family tag elements:

 <webscript>  
   <shortname>Remove Peer Association</shortname>  
   <description>Removes Formtek Peer Association Metadata</description>  
   <family>user-dashlet</family>  
   <family>group:GROUP_ALFRESCO_ADMINISTRATORS</family>  
   <url>/components/ftkassociations/dashlets/remove</url>  
 </webscript>    


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:

http://<server>:<port>/alfresco/s/slingshot/doclib/action/formtek/extensions/version-browser/remove-version/node/workspace/SpacesStore/a6248c1f-b226-4bf3-a5ec-d904a3115e72/1-0

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.