KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mvnforum > admin > importexport > jive > JiveGroupXML


1 /*
2  * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/admin/importexport/jive/JiveGroupXML.java,v 1.6 2006/04/14 17:36:29 minhnn Exp $
3  * $Author: minhnn $
4  * $Revision: 1.6 $
5  * $Date: 2006/04/14 17:36:29 $
6  *
7  * ====================================================================
8  *
9  * Copyright (C) 2002-2006 by MyVietnam.net
10  *
11  * All copyright notices regarding mvnForum MUST remain
12  * intact in the scripts and in the outputted HTML.
13  * The "powered by" text/logo with a link back to
14  * http://www.mvnForum.com and http://www.MyVietnam.net in
15  * the footer of the pages MUST remain visible when the pages
16  * are viewed on the internet or intranet.
17  *
18  * This program is free software; you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation; either version 2 of the License, or
21  * any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program; if not, write to the Free Software
30  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31  *
32  * Support can be obtained from support forums at:
33  * http://www.mvnForum.com/mvnforum/index
34  *
35  * Correspondence and Marketing Questions can be sent to:
36  * info at MyVietnam net
37  *
38  * @author: Igor Manic
39  */

40 package com.mvnforum.admin.importexport.jive;
41
42 import com.mvnforum.admin.GroupXML;
43 import net.myvietnam.mvncore.exception.*;
44
45 /**
46  * @author Igor Manic
47  * @version $Revision: 1.6 $, $Date: 2006/04/14 17:36:29 $
48  * <br/>
49  * <code>JiveGroupXML</code> class encapsulates processing of
50  * groups' definitions found in the Jive XML file. It implements
51  * methods to be called from XML parsing routine, adds some additional
52  * processing and checking, and calls corresponding methods of
53  * <code>GroupXML</code> and other neccessary classes in order to perform
54  * the actual creation of a group, as well as assigning members to the group.
55  */

56 public class JiveGroupXML {
57
58     private GroupXML groupXML=null;
59     private boolean groupCreated=false;
60
61     public JiveGroupXML() {
62         super();
63         groupXML=new GroupXML();
64         groupCreated=false;
65     }
66
67     public void setGroupID(String JavaDoc id) {
68         groupXML.setGroupID(id);
69     }
70
71     /**
72      * This method simply calls <code>setGroupID()</code>.
73      * It's defined only to avoid property-setter problems with digester
74      * (since it doesn't seem to recognize <code>setGroupID()</code> as a setter
75      * method for <code>groupID</code> property).
76      */

77     public void setGroupId(String JavaDoc id) {
78         setGroupID(id);
79     }
80
81
82     private String JavaDoc groupName=null;
83     public void setGroupName(String JavaDoc value) throws CreateException {
84         if ( (value==null) || (value.equals("")) ) {
85             throw new CreateException("Cannot create a group with an empty GroupName.");
86         } else this.groupName=value;
87     }
88
89     private String JavaDoc groupDesc=null;
90     public void setGroupDescription(String JavaDoc value) throws CreateException {
91         this.groupDesc=value;
92     }
93
94     private String JavaDoc groupCreationDate=null;
95     public void setGroupCreationDate(String JavaDoc value) throws CreateException {
96         this.groupCreationDate=value;
97     }
98
99     private String JavaDoc groupModifiedDate=null;
100     public void setGroupModifiedDate(String JavaDoc value) throws CreateException {
101         this.groupModifiedDate=value;
102     }
103
104     private String JavaDoc groupOwnerName=null;
105     public void setGroupOwnerName(String JavaDoc value) throws CreateException {
106         this.groupOwnerName=value;
107     }
108
109     public void addJiveGroup() throws CreateException, DuplicateKeyException,
110     ObjectNotFoundException, DatabaseException, ForeignKeyNotFoundException {
111         /* First check if the digester already called this method.
112          * It will happen even under normal circumstances, if this group has
113          * subelements that need it already be defined, so they first call
114          * this method to create group before creating data that refer him.
115          */

116         if (groupCreated) return;
117         if ( (groupName==null) || (groupName.equals("")) ) {
118             throw new CreateException("Cannot create a group with an empty GroupName.");
119         } else {
120             ImportJive.addMessage("Adding Jive group \""+groupName+"\".");
121             groupXML.addGroup(groupOwnerName, groupName, groupDesc,
122                               null/*groupOption*/, groupCreationDate, groupModifiedDate);
123             groupCreated=true;
124         }
125     }
126
127     public void addJiveGroupMember(String JavaDoc username)
128     throws CreateException, DuplicateKeyException, ObjectNotFoundException,
129     DatabaseException, ForeignKeyNotFoundException {
130         if ( (!groupCreated) || (groupXML.getGroupID()<0) ) {
131             addJiveGroup();
132         }
133         if ( (username==null) || (username.equals("")) ) {
134             throw new CreateException("Cannot create a group member with an empty MemberName.");
135         } else {
136             ImportJive.addMessage("Adding group member \""+username+"\".");
137             groupXML.addMemberGroup(username, null/*privilege*/,
138                                     null/*creationDate*/, null/*modifiedDate*/);
139         }
140     }
141
142
143 }
144
145
146
Popular Tags