KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > db > DotCMSInitDb


1 package com.dotmarketing.db;
2
3 import java.util.List JavaDoc;
4
5 import com.dotmarketing.cms.factories.PublicCompanyFactory;
6 import com.dotmarketing.factories.GroupFactory;
7 import com.dotmarketing.factories.HostFactory;
8 import com.dotmarketing.factories.LayoutFactory;
9 import com.dotmarketing.portlets.languagesmanager.factories.LanguageFactory;
10 import com.dotmarketing.portlets.structure.factories.StructureFactory;
11 import com.dotmarketing.util.Logger;
12
13 public class DotCMSInitDb {
14
15     public static void InitializeDb() {
16
17         /*
18          * check a liferay property to see if we've inited the db.
19          */

20
21         DotConnect db = new DotConnect();
22         db.setSQL("select count(*) as test from inode");
23         
24         int test = db.getInt("test");
25         boolean configured = (test > 0);
26
27         if (!configured) {
28             Logger.info(DotCMSInitDb.class,
29                     "There are no inodes - initializing db for first time use");
30
31             PublicCompanyFactory.createDefaultCompany();
32
33             // Ensures that default groups are set up
34
GroupFactory.createDefaultGroups();
35             LayoutFactory.createDefaultLayouts();
36
37             // Creating the default host
38
List JavaDoc hosts = HostFactory.getAllHosts();
39
40             if (hosts.size() == 0) {
41                 Logger.debug(DotCMSInitDb.class, "Creating Default Host");
42                 HostFactory.createDefaultHost();
43             }
44
45             //Create Default Language
46
LanguageFactory.createDefaultLanguage();
47             
48             // Creating the default content structures if it not exists.
49
StructureFactory.createDefaultStructure();
50
51         } else {
52             Logger
53                     .info(DotCMSInitDb.class,
54                             "inodes exist, skipping initialization of db");
55
56         }
57     }
58
59 }
60
Popular Tags