KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > dictionary > TestModel


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.dictionary;
18
19 import java.util.ArrayList JavaDoc;
20 import java.util.List JavaDoc;
21
22
23 /**
24  * Test Model Definitions
25  */

26 public class TestModel
27 {
28
29     public static void main(String JavaDoc[] args)
30     {
31         if (args != null && args.length > 0 && args[0].equals("-h"))
32         {
33             System.out.println("TestModel [model filename]*");
34             System.exit(0);
35         }
36         
37         System.out.println("Testing dictionary model definitions...");
38
39         // construct list of models to test
40
// include alfresco defaults
41
List JavaDoc<String JavaDoc> bootstrapModels = new ArrayList JavaDoc<String JavaDoc>();
42         bootstrapModels.add("alfresco/model/dictionaryModel.xml");
43         bootstrapModels.add("alfresco/model/systemModel.xml");
44         bootstrapModels.add("alfresco/model/contentModel.xml");
45         bootstrapModels.add("alfresco/model/applicationModel.xml");
46
47         // include models specified on command line
48
for (String JavaDoc arg: args)
49         {
50             bootstrapModels.add(arg);
51         }
52         
53         for (String JavaDoc model : bootstrapModels)
54         {
55             System.out.println(" " + model);
56         }
57         
58         // construct dictionary dao
59
NamespaceDAO namespaceDAO = new NamespaceDAOImpl();
60         DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(namespaceDAO);
61
62         // bootstrap dao
63
try
64         {
65             DictionaryBootstrap bootstrap = new DictionaryBootstrap();
66             bootstrap.setModels(bootstrapModels);
67             bootstrap.setDictionaryDAO(dictionaryDAO);
68             bootstrap.bootstrap();
69             System.out.println("Models are valid.");
70         }
71         catch(Exception JavaDoc e)
72         {
73             System.out.println("Found an invalid model...");
74             Throwable JavaDoc t = e;
75             while (t != null)
76             {
77                 System.out.println(t.getMessage());
78                 t = t.getCause();
79             }
80         }
81     }
82 }
Popular Tags