View Javadoc

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