Thursday, July 21, 2016

Home Folders for Recreated Alfresco Users

When you create an Alfresco user (e.g., John Doe with “johndoe” as the user name), a home folder (e.g., johndoe) is also created for that user under the RepositoryàUser Homes folder and has permissions similar to the following:
 

The Alfresco documentation defines the internal ROLE_OWNER role as follows:

ROLE_OWNER is assigned to the owner of a node. If there is no explicit owner, this role is assigned to the creator. This role has all the rights on the owned node.

So, in the example above, John Doe is the owner of the folder, and thus, granted all permissions through both the explicit user-based assignment and internal ROLE_OWNER assignment.

When you delete an Alfresco user, the user’s home folder is not deleted. However, because the user object (i.e., cm:person) is deleted, the explicit user-based assignment is removed from the permissions on the deleted user’s home folder, leaving only the ROLE_OWNER set of permissions:
 
 
Examination of this folder in the Alfresco Share Node Browser shows that the deleted user is still the owner of the folder.

If you later recreate the deleted user, don’t be surprised to see a new home folder (e.g., johndoe-1) assigned to the resurrected user—even though the original home folder (e.g., johndoe) still exists and is accessible to the recreated user. As a result, any content stored in the original home folder is no longer accessible via the user’s My Files link in the Alfresco Share toolbar.
 
You can correct this by moving the contents of the original home folder to the new home folder. If the user has access to the Repository link in the Share toolbar, he’ll be able to move the folder contents without administrator assistance because he has ROLE_OWNER access to both the original and new home folders.

The question remains, however—why doesn’t Alfresco reuse the preserved home folder when a previously deleted user is recreated?

Tuesday, July 12, 2016

Reducing Log File Size in Alfresco

Newer versions of Alfresco will create certain log files by default, including a daily log file that is regularly larger than 100+ MB:  the <CATALINA_HOME>/logs/localhost_access_logYYYY-MM-DD.txt log file.


You can prevent this log file from being created by editing the <CATALINA_HOME>/conf/server.xml file and commenting out the following section:

<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t &quot;%r&quot; %s %b" />

Once this section is commented out, restart Alfresco, and the localhost_access_log files will no longer be created.

Thursday, July 7, 2016

Alfresco Notification Rules - Alerting Users of New File Uploads



Did you ever want to be alerted when new content is uploaded to a specific folder in Alfresco?  

The Activities Feed is one method that Alfresco uses to notify users about actions that have occurred in Share like file uploads.  These notifications are usually sent out nightly (They are also called Site Activity Notification emails). 

But if you want to know immediately when a specific kind of upload has occurred, a better option might be to create a rule that will automatically send out a notification email when an upload or change has happened to content within the folder that you would like to track.

For example, a folder rule can be created that would alert you on the upload of a document to an Alfresco folder by sending out a notification email to a specified list of people, as shown in the following:


The email informs you of the time of the upload and has a direct link to the document's details page in Alfresco Share.  It's easy to set up a rule that does this.

Before we start, you'll need to have configured Alfresco to be able to send outbound emails.  A description for how to configure that is described here in the Alfresco documentation.

Now, let's look at how to send email notifications.  Within Share, first navigate to the folder that you would like to monitor and for that folder select the action Manage Rules.  This action is visible from either the document library list view or the folder's detailed page view.



From the Manage Rules page, select the New Rule button along the right and the details for a new rule can then be entered in a form as shown here:


It's necessary to give a name to the rule and also to specify what folder action will trigger the rule, any additional criteria for which types of items that will cause the rule to run, and the action that will be performed.  

In the definition shown above, any Microsoft Word document that has a filename that starts with "Status Report" that gets uploaded to this folder will cause the rule to run.  Send email is the action we've selected to perform.  Note that there are some additional options across the bottom.  In this case we've selected that the rule should apply not only to uploads to this folder but to all its subfolders too.

Next to Send email is a button called Message...  Clicking on that button pops up a dialog that has additional information about the recipients and the content of the email that will be sent.
The Select button lets us choose who should receive the email.  Below that, the Subject of the message can be defined.

In this case, the template file called notify_user_email.html.ftl is selected to define the content body of the email that is sent out.  The contents of that file is displayed in the Message area. It works much like how a mail merge document does.  Embedded within this Freemarker file are references to dynamic data that can be inserted into the email body.

This sample email template file selected here comes along with the base install of Alfresco.  To find this template file, navigate through the repository file structure to this folder:
You have the option of just using the sample file, editing it, or creating a totally new template file in this directory.  The syntax used in the file is HTML and Freemarker.  

For example, here is a portion of the sample email template file:

   <div style="font-size: 22px; padding-bottom: 4px;">
      ${person.properties.firstName} 
     <#if person.properties.lastName?exists> ${person.properties.lastName}</#if> 
has added a new content item, ${document.name}, in the ${document.siteShortName!""} site
   </div>
   <div style="font-size: 13px;">
      ${date?datetime?string.full}
   </div>

Here we see some objects that are available to us to that are dynamically evaluated when the rule is run.  These include person, document and date.  But note that the subject line for the email isn't part of the Freemarker template so you can't embed dynamic properties in it.

Some information available for person that can be referenced when creating the template includes the firstName, lastName, and email.  Similarly, there are many properties available for the document.  Also note that an alternative way to reference document properties is like: ${document.properties["cm:name"]}.

That's all that's needed.  After the template is created and the rule is defined, email notifications will begin to be sent as new Word status reports are filed into this folder.