cancel
Showing results for 
Search instead for 
Did you mean: 

Adding nightly 'cron' job to email users?

thomas_hood
Champ in-the-making
Champ in-the-making
Hello,

I'm new to Alfresco and Im trying to do two things:

Firstly add a content type with extended meta-data (namely a 'owner email address' and an a 'document expiry date') which I have done successfully by reading the documentation on the wiki. I can see my new tags in the node_properties tabe.

The second thing I'm trying to do is to run nightly a process that finds all my new content type documents with which expire on that day, and email the owner of the document.

I'm really struggling to see the wood for the trees here: can anyone suggest a plan of attack?

Thanks,

Tom
3 REPLIES 3

jbaton
Champ in-the-making
Champ in-the-making
Thomas,

I have had a similar feature to implement. The approach I took was to add the expiry date (I called it obsolescence) to the advanced search and leave the users search for documents, using a date range.


For your approach, I will not discuss how to cron in java (quartz, homegrown threads) but would advice you to use JCR access to the repository (see the wiki).

Iterate the nodes, check date, add it to list  (user + email + document name + path  +url)


Then sort your list by user, iterate your list to send 1 email by user

May be should you warn about documents that will be expired in N days ?

Please contribute your code, as I am also interested


Jerome

soeursourire
Champ in-the-making
Champ in-the-making
Seeing your discussion I guess you know how to use crons. I get into troubles with cron in my code and do not find any answer. Please would you mind telling me what I am doing wrong: this morning at 9.30am I was launching a cron that should execute a job at 9.45am. This cron is writing "Execution Job" in my log file.

However nothing is written in my log file while doing this:

SchedulerFactory sf = new StdSchedulerFactory();
Scheduler sched = sf.getScheduler();
// define the job and tie it to our EthicFlow_CreatePersonJob class
JobDetail job = new JobDetail("EthicFlow_CreatePersonJob", "group1", EthicFlow_CreatePersonJob.class);

Date runTime = TriggerUtils.getDateOf(0,45,9,22,8,2006);

SimpleTrigger trigger = new SimpleTrigger("trigger1", "group1", runTime);
sched.scheduleJob(job, trigger);
sched.start();
Thread.sleep(90L * 1000L);
sched.shutdown(true);

With the execution job:

protected void executeInternal(JobExecutionContext ctx)

throws JobExecutionException {

// do the actual work
logger.info("Execution Job");

}

If I launch the cron almost at the same time as the set runtime that is working but if the cron has to be executed 10min later that does not seem to work. What do I do wrong here?

Thanks in advance for your help.

soeursourire
Champ in-the-making
Champ in-the-making
The problem was these lines:

Thread.sleep(90L * 1000L);
sched.shutdown(true);

To remove