Open IT Experts for Enterprise

Zylk empresa de desarrollo de ecommerce

How to control public shared content in Alfresco

Cesar Capillas
Cesar Capillas
Last day, I was asked for a client about how to control
"public" shared content in Alfresco Share in a simple way.
These are some of the ideas of the support conversation:
 
[me] First, just write in the Alfresco Share search box, the next
querys. You should see your shared content. 
 
ASPECT:"qshare:shared" 
ASPECT:"qshare:shared" AND @cm:creator:"ccl001"
ASPECT:"qshare:shared" AND @qshare:sharedBy:"ccl001"
ASPECT:"qshare:shared" AND @cm:modified:["2014-12-31" TO NOW]
ASPECT:"qshare:shared" AND @cm:modified:[MIN TO "2013-12-31"]
 
[client] OMG! There exists a lot of public documents… What can we
do for managing this ? Querys are right but many final users do not
understand complex queries, and they are not familiar with aspects.
 
[me] Right, we can implement a document filter query in sites
and/or in My documents dashlet, for final users.
 
[client] We are not sure about document library filters… because
filters will appear in all sites, for all users. What about for
Alfresco Admins ? May we get a list of public nodes ? How can we
unshare these public urls ? 
 
[me] Just removing qhare:shared aspect. For alfresco admins, we can
run a simple script in Javascript API for getting a brief report in
CSV, via
Alfresco Javascript Console
. This should be valid also for users
that create rules on their sites, executing the JS code. This is only
valid for 1000 items, although you can run it several times (which is
not always possible). 
 
var nodes = search.luceneSearch('ASPECT:"qshare:shared"');
var count = 0;
for each(var node in nodes) {
        count = count + 1;
        logger.log(count + ": "+node.displayPath+"/"+node.name);           
        // Uncomment these two lines for unsharing
        //logger.log("  Cleaning the aspect..");    
        //node.removeAspect("qshare:shared");
        //node.save();
        //logger.log("  Done");                        
}
 
[client] Mmm… I don’t see the full picture, yet.
 
[me] Ok, we can filter query by modified date too. You can assume
that content is shared before being modified and then to unpublish
them if the content was modified many time ago.
 
var nodes =
search.luceneSearch('ASPECT:"qshare:shared" AND
@cm\:modified:["2014-12-31" TO NOW]'); 
 
[client] This is a little tricky… but I’m not sure about it.
 
[me] Ok, you can use cm:effectivity aspect in Alfresco content, and
use cm:to property for controlling the end lifecycle on your public
nodes and urls. So, add aspect Effectivity, to the node to be shared,
and then edit effectivity properties.
 
[client] I don’t see it, this implies more work for final users.
 
[me] Well, you may also use content rules, for setting cm:to by a
default relative date, if the content is shared.
 
[client] Better. Something more ?
 
[me] Then, we can write another script that checks the expiration
date cm:to (i.e. today), and then remove the aspect or aspects.
 
var today  = new Date();
var month = today.getMonth() + 1; //months from 1-12
var day     = today.getDate();
var year    = today.getFullYear();
var mydate = year+"-"+month+"-"+day;
var nodes = search.luceneSearch('ASPECT:"qshare:shared" AND @cm\:to:"'+mydate+'"');
var count = 0;
for each(var node in nodes) {
  count = count + 1;
  logger.log(count + ": "+node.displayPath+"/"+node.name);
  logger.log(" This public url is expired --> "+node.properties["cm:to"]);
  logger.log(" Cleaning the aspect..");
  node.removeAspect("qshare:shared");
  //node.removeAspect("cm:effectivity");
  node.save();
  logger.log("Done");
}
 
[client] It sounds even better.
 
[me] And finally, we can do a daily quartz executing the javascript
code, to unshare the public urls.
 
 
[client] Ok, let’s do it. 
 
P.S: Tested in Alfresco 4.2.4 EE (although it may work in other versions).

Si te ha parecido interesante comparte este post en RRS

Facebook
LinkedIn
Telegram
Email

Leer más sobre temas relacionados

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *