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
18          extends BaseTestCase {
19      private static final Logger LOG = LoggerFactory.getLogger(DocumentStoreModelInitiallizer_UT.class);
20  
21      @Test
22      public void initDocStoreModel() throws Exception {
23          DocumentStoreModelInitiallizer documentStoreModelInitiallizer = 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      private static void dump(Node node) throws RepositoryException {
32          LOG.info(node.getPath());
33          if (node.getName().equals("jcr:system")) {
34              return;
35          }
36  
37          PropertyIterator properties = node.getProperties();
38          while (properties.hasNext()) {
39              Property property = properties.nextProperty();
40              if (property.getDefinition().isMultiple()) {
41                  Value[] values = property.getValues();
42                  for (int i = 0; i < values.length; i++) {
43                      LOG.info(property.getPath() + " = " + values[i].getString());
44                  }
45              }
46              else {
47                  LOG.info(property.getPath() + " = " + property.getString());
48              }
49          }
50  
51          NodeIterator nodes = node.getNodes();
52          while (nodes.hasNext()) {
53              dump(nodes.nextNode());
54          }
55      }
56  }