KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > applications > workflowtool > function > email > RoleAddressProvider


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23 package org.infoglue.cms.applications.workflowtool.function.email;
24
25 import java.util.ArrayList JavaDoc;
26 import java.util.Collection JavaDoc;
27
28 import org.infoglue.cms.controllers.kernel.impl.simple.RoleControllerProxy;
29
30 import com.opensymphony.workflow.WorkflowException;
31
32 /**
33  * This function is used when an email should be sent to all members of a role.
34  */

35 public class RoleAddressProvider extends UsersAddressProvider {
36     /**
37      * The name of the role argument.
38      */

39     private static final String JavaDoc ROLE_ARGUMENT = "role";
40     
41     /**
42      * The name of the role whose members should recieve an email.
43      */

44     private String JavaDoc roleName;
45     
46     /**
47      * Default constructor.
48      */

49     public RoleAddressProvider()
50     {
51         super();
52     }
53     
54     /**
55      * Returns the principals that should be the recipients of the email.
56      *
57      * @return a Collection of <code>InfogluePrincipal</code>:s.
58      */

59     protected Collection JavaDoc getPrincipals() throws WorkflowException
60     {
61         try
62         {
63             return RoleControllerProxy.getController(getDatabase()).getInfoGluePrincipals(roleName);
64         }
65         catch(Exception JavaDoc e)
66         {
67             throwException(e);
68         }
69         return new ArrayList JavaDoc();
70     }
71     
72     /**
73      * Method used for initializing the function; will be called before <code>execute</code> is called.
74      * <p><strong>Note</strong>! You must call <code>super.initialize()</code> first.</p>
75      *
76      * @throws WorkflowException if an error occurs during the initialization.
77      */

78     protected void initialize() throws WorkflowException
79     {
80         super.initialize();
81         roleName = getArgument(ROLE_ARGUMENT);
82     }
83 }
84
Popular Tags