KickJava   Java API By Example, From Geeks To Geeks.

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


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.GroupControllerProxy;
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 group.
34  */

35 public class GroupAddressProvider extends UsersAddressProvider
36 {
37     /**
38      * The name of the group argument.
39      */

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

45     private String JavaDoc groupName;
46     
47     /**
48      * Default constructor.
49      */

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

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

79     protected void initialize() throws WorkflowException
80     {
81         super.initialize();
82         groupName = getArgument(GROUP_ARGUMENT);
83     }
84 }
85
Popular Tags