Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/lucane/server/store/Store.java


1   /*
2    * Lucane - a collaborative platform
3    * Copyright (C) 2003  Vincent Fiack <vincent@lucane.org>
4    *
5    * This library is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU Lesser General Public
7    * License as published by the Free Software Foundation; either
8    * version 2.1 of the License, or (at your option) any later version.
9    *
10   * This library is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   * Lesser General Public License for more details.
14   *
15   * You should have received a copy of the GNU Lesser General Public
16   * License along with this library; if not, write to the Free Software
17   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  package org.lucane.server.store;
21  
22  import org.lucane.server.Server;
23  import org.lucane.common.concepts.*;
24  import org.lucane.server.store.sql.*;
25  import org.lucane.common.MD5;
26  
27  /**
28   * The unique way to get Stores for the different concepts.
29   */
30  public class Store
31  {    
32      private GroupStore group;
33      private PluginStore plugin;
34      private ServiceStore service;
35      private UserStore user;
36      
37      /**
38       * Constructor.
39       * 
40       * Instantiate the managers and set some initial data if necessary
41       */
42      public Store()
43      throws Exception
44      {
45          boolean inited = Server.getInstance().getDBLayer().hasTable("groups");
46      
47          this.group = new SqlGroupStore(this);         
48          this.plugin = new SqlPluginStore();
49          this.service = new SqlServiceStore();
50          this.user = new SqlUserStore();
51          
52          if(! inited)
53              setInitialData();
54      }
55      
56      /**
57       * Get the GroupStore
58       * 
59       * @return the GroupStore instance
60       */
61    public GroupStore getGroupStore()
62    {
63      return group;
64    }
65    
66    /**
67     * Get the PluginStore
68     * 
69     * @return the PluginStore instance
70     */
71    public PluginStore getPluginStore()
72    {
73      return plugin;
74    }
75    
76    /**
77     * Get the ServiceStore
78     * 
79     * @return the ServiceStore instance
80     */
81    public ServiceStore getServiceStore()
82    {
83      return service;
84    }
85    
86    /**
87     * Get the UserStore
88     * 
89     * @return the UserStore instance
90     */
91    public UserStore getUserStore()
92    {
93      return user;
94    }
95      
96      /**
97       * Set some default initial data.
98       * Called by the constructor.
99       */
100     private void setInitialData()
101     throws Exception
102     {
103         //groups
104         GroupConcept allUsers = new GroupConcept("AllUsers");
105         GroupConcept grantedUsers = new GroupConcept("GrantedUsers");
106         GroupConcept admins = new GroupConcept("Admins");
107         admins.addParent(allUsers);
108         grantedUsers.addParent(allUsers);
109         
110         //admin user
111         UserConcept admin = new UserConcept("admin", MD5.encode("admin"), false, "org.lucane.plugins.maininterface");
112         admin.generateKeys("admin");
113         admins.addUser(admin);
114         getUserStore().storeUser(admin);
115 
116         //guest user
117         UserConcept guest = new UserConcept("guest", MD5.encode("guest"), false, "org.lucane.plugins.maininterface");
118         guest.generateKeys("guest");
119         allUsers.addUser(guest);
120         getUserStore().storeUser(guest);
121         
122         //granted user
123         UserConcept granted = new UserConcept("granted", MD5.encode("granted"), false, "org.lucane.plugins.maininterface");
124         granted.generateKeys("granted");
125         grantedUsers.addUser(granted);
126         getUserStore().storeUser(granted);
127         
128         //administrator application
129         PluginConcept administratorPlugin = new PluginConcept("org.lucane.plugins.administrator", "0.6");
130         ServiceConcept administratorService = new ServiceConcept("org.lucane.plugins.administrator", false);
131         admins.addPlugin(administratorPlugin);
132         admins.addService(administratorService);
133         getPluginStore().storePlugin(administratorPlugin);
134         getServiceStore().storeService(administratorService);
135         
136         //filemanager application
137         PluginConcept filemanagerPlugin = new PluginConcept("org.lucane.plugins.filemanager", "0.6");
138         ServiceConcept filemanagerService = new ServiceConcept("org.lucane.plugins.filemanager", false);
139         grantedUsers.addPlugin(filemanagerPlugin);
140         allUsers.addService(filemanagerService);
141         getPluginStore().storePlugin(filemanagerPlugin);
142         getServiceStore().storeService(filemanagerService);
143           
144         //forum application
145         PluginConcept forumPlugin = new PluginConcept("org.lucane.plugins.forum", "0.6");
146         ServiceConcept forumService = new ServiceConcept("org.lucane.plugins.forum", false);
147         allUsers.addPlugin(forumPlugin);
148         allUsers.addService(forumService);
149         getPluginStore().storePlugin(forumPlugin);
150         getServiceStore().storeService(forumService);
151         
152         //forumadmin application
153         PluginConcept forumadminPlugin = new PluginConcept("org.lucane.plugins.forumadmin", "0.6");
154         ServiceConcept forumadminService = new ServiceConcept("org.lucane.plugins.forumadmin", false);
155         admins.addPlugin(forumadminPlugin);
156         admins.addService(forumadminService);
157         getPluginStore().storePlugin(forumadminPlugin);
158         getServiceStore().storeService(forumadminService);
159         
160         //helpbrowser application
161         PluginConcept helpbrowserPlugin = new PluginConcept("org.lucane.plugins.helpbrowser", "0.6");
162         allUsers.addPlugin(helpbrowserPlugin);
163         getPluginStore().storePlugin(helpbrowserPlugin);
164                 
165         //maininterface application
166         PluginConcept maininterfacePlugin = new PluginConcept("org.lucane.plugins.maininterface", "0.6");
167         ServiceConcept maininterfaceService = new ServiceConcept("org.lucane.plugins.maininterface", false);
168         allUsers.addPlugin(maininterfacePlugin);
169         allUsers.addService(maininterfaceService);
170         getPluginStore().storePlugin(maininterfacePlugin);
171         getServiceStore().storeService(maininterfaceService);
172         
173         //notes application
174         PluginConcept notesPlugin = new PluginConcept("org.lucane.plugins.notes", "0.6");
175         ServiceConcept notesService = new ServiceConcept("org.lucane.plugins.notes", false);
176         allUsers.addPlugin(notesPlugin);
177         allUsers.addService(notesService);
178         getPluginStore().storePlugin(notesPlugin);
179         getServiceStore().storeService(notesService);
180                 
181         //passwdchanger application
182         PluginConcept passwdchangerPlugin = new PluginConcept("org.lucane.plugins.passwdchanger", "0.6");
183         ServiceConcept passwdchangerService = new ServiceConcept("org.lucane.plugins.passwdchanger", false);
184         grantedUsers.addPlugin(passwdchangerPlugin);
185         admins.addPlugin(passwdchangerPlugin);
186         grantedUsers.addService(passwdchangerService);
187         admins.addService(passwdchangerService);
188         getPluginStore().storePlugin(passwdchangerPlugin);
189         getServiceStore().storeService(passwdchangerService);
190 
191         //pluginsinfos application
192         PluginConcept pluginsinfosPlugin = new PluginConcept("org.lucane.plugins.pluginsinfos", "0.6");
193         allUsers.addPlugin(pluginsinfosPlugin);
194         getPluginStore().storePlugin(pluginsinfosPlugin);
195        
196         //quickmessage application
197         PluginConcept quickmessagePlugin = new PluginConcept("org.lucane.plugins.quickmessage", "0.6");
198         allUsers.addPlugin(quickmessagePlugin);
199         getPluginStore().storePlugin(quickmessagePlugin);
200               
201         //reunion application
202         PluginConcept reunionPlugin = new PluginConcept("org.lucane.plugins.reunion", "0.6");
203         allUsers.addPlugin(reunionPlugin);
204         getPluginStore().storePlugin(reunionPlugin);
205         
206         //sendfile application
207         PluginConcept sendfilePlugin = new PluginConcept("org.lucane.plugins.sendfile", "0.6");
208         allUsers.addPlugin(sendfilePlugin);
209         getPluginStore().storePlugin(sendfilePlugin);
210                 
211         //sendmail application
212         ServiceConcept sendmailService = new ServiceConcept("org.lucane.plugins.sendmail", false);
213         allUsers.addService(sendmailService);
214         getServiceStore().storeService(sendmailService);
215 
216     //sqlnavigator application
217     PluginConcept sqlnavigatorPlugin = new PluginConcept("org.lucane.plugins.sqlnavigator", "0.6");
218     ServiceConcept sqlnavigatorService = new ServiceConcept("org.lucane.plugins.sqlnavigator", false);
219     admins.addPlugin(sqlnavigatorPlugin);
220     admins.addService(sqlnavigatorService);
221     getPluginStore().storePlugin(sqlnavigatorPlugin);
222     getServiceStore().storeService(sqlnavigatorService);
223     
224         getGroupStore().storeGroup(allUsers);
225         getGroupStore().storeGroup(grantedUsers);
226         getGroupStore().storeGroup(admins);
227     }
228 }