AnsweredAssumed Answered

Mail Notification (Rule Outbound) : Two emails on delete?

Question asked by sylvain78 on Sep 19, 2007
Latest reply on Sep 20, 2007 by sylvain78
Hi,

I created a rule which sends an email on "Outbound" event.
I am using the Web Service API.

When I delete content in the target space, I get two emails.
I made sure I only have one rule on the target space.

Is this the correct behaviour?  Why should I get two emails for a single delete?

Basically the code is the following (Put it in a method and change the emails!):

String PARAM_TO = "to";
String PARAM_TO_MANY = "to_many";
String PARAM_SUBJECT = "subject";
String PARAM_TEXT = "text";
String PARAM_FROM = "from";
String PARAM_TEMPLATE = "template";

Store STORE =
    new Store(Constants.WORKSPACE_STORE, "SpacesStore");
String xPath = "/app:company_home";
Reference reference = new Reference(STORE, null, xPath);
String[] ruleTypeNames = new String[]{"outbound"};

String subject = "Test Alfresco";
String from = "someEmail";
String to = "someEmail";
String text = "Changed occured.";

// Create action parameters
NamedValue[] parameters = null;
NamedValue valueTo =
    new NamedValue(PARAM_TO, new Boolean(false), to, null);
NamedValue valueFrom =
    new NamedValue(PARAM_FROM, new Boolean(false), from, null);
NamedValue valueSubject =
    new NamedValue(PARAM_SUBJECT, new Boolean(false), subject, null);
NamedValue valueText =
    new NamedValue(PARAM_TEXT, new Boolean(false), text, null);
NamedValue valueTemplate =
    new NamedValue(PARAM_TEMPLATE, new Boolean(false), null, null);      
parameters =
    new NamedValue[]{valueTo, valueFrom, valueSubject, valueTemplate, valueText};

// Create the action
Action action = new Action();
action.setActionName("mail");
action.setTitle("Send an email to specified users.");
action.setDescription("");
action.setParameters(parameters);
action.setActionReference(reference);
         
// Create the rule
Rule rule = new Rule();
rule.setRuleTypes(ruleTypeNames);
rule.setTitle("Notify User");
rule.setDescription("");
rule.setAction(action);

try {
    // Authentication
    WebServiceClient.startSession("admin", "admin");
   
    // Save the rule
    WebServiceClient.getActionService().saveRules(
        reference, new Rule[]{rule});

} catch (Exception e) {
    e.printStackTrace();
} finally {
    WebServiceClient.endSession();
}

If anyone can help me, I will appreciate it!

Thanks,

Sylvain

Outcomes