View Javadoc

1   import org.junit.Test;
2   import org.kuali.ole.DocumentStoreModelInitiallizer;
3   import org.kuali.ole.RepositoryManager;
4   import org.kuali.ole.BaseTestCase;
5   
6   import javax.jcr.*;
7   
8   /**
9    * Created by IntelliJ IDEA.
10   * User: pvsubrah
11   * Date: 1/10/12
12   * Time: 11:03 AM
13   * To change this template use File | Settings | File Templates.
14   */
15  public class DocumentStoreModelInitiallizer_UT extends BaseTestCase{
16      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocumentStoreModelInitiallizer_UT.class);
17  
18      @Test
19      public void initDocStoreModel() throws Exception {
20          DocumentStoreModelInitiallizer documentStoreModelInitiallizer
21                  = new DocumentStoreModelInitiallizer();
22          documentStoreModelInitiallizer.init();
23          RepositoryManager repositoryManager = RepositoryManager.getRepositoryManager();
24          Session session = repositoryManager.getSession();
25          dump(session.getRootNode());
26  
27  
28      }
29  
30      private static void dump(Node node) throws RepositoryException {
31        LOG.info(node.getPath());
32          if (node.getName().equals("jcr:system")) {
33              return;
34          }
35  
36          PropertyIterator properties = node.getProperties();
37          while (properties.hasNext()) {
38              Property property = properties.nextProperty();
39              if (property.getDefinition().isMultiple()) {
40                  Value[] values = property.getValues();
41                  for (int i = 0; i < values.length; i++) {
42                     LOG.info(
43                              property.getPath() + " = " + values[i].getString());
44                  }
45              } else {
46                 LOG.info(
47                          property.getPath() + " = " + property.getString());
48              }
49          }
50  
51          NodeIterator nodes = node.getNodes();
52          while (nodes.hasNext()) {
53              dump(nodes.nextNode());
54          }
55      }
56  }