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