001import org.junit.Ignore;
002import org.junit.Test;
003import org.kuali.ole.DocumentStoreModelInitiallizer;
004import org.kuali.ole.RepositoryManager;
005import org.kuali.ole.BaseTestCase;
006import org.slf4j.Logger;
007import org.slf4j.LoggerFactory;
008
009import javax.jcr.*;
010
011/**
012 * Created by IntelliJ IDEA.
013 * User: pvsubrah
014 * Date: 1/10/12
015 * Time: 11:03 AM
016 * To change this template use File | Settings | File Templates.
017 */
018@Ignore
019public class DocumentStoreModelInitiallizer_UT
020        extends BaseTestCase {
021    private static final Logger LOG = LoggerFactory.getLogger(DocumentStoreModelInitiallizer_UT.class);
022
023    @Test
024    public void initDocStoreModel() throws Exception {
025        DocumentStoreModelInitiallizer documentStoreModelInitiallizer = new DocumentStoreModelInitiallizer();
026        documentStoreModelInitiallizer.init();
027        RepositoryManager repositoryManager = RepositoryManager.getRepositoryManager();
028        Session session = repositoryManager.getSession();
029        dump(session.getRootNode());
030        repositoryManager.logout(session);
031    }
032
033    private static void dump(Node node) throws RepositoryException {
034        LOG.info(node.getPath());
035        if (node.getName().equals("jcr:system")) {
036            return;
037        }
038
039        PropertyIterator properties = node.getProperties();
040        while (properties.hasNext()) {
041            Property property = properties.nextProperty();
042            if (property.getDefinition().isMultiple()) {
043                Value[] values = property.getValues();
044                for (int i = 0; i < values.length; i++) {
045                    LOG.info(property.getPath() + " = " + values[i].getString());
046                }
047            }
048            else {
049                LOG.info(property.getPath() + " = " + property.getString());
050            }
051        }
052
053        NodeIterator nodes = node.getNodes();
054        while (nodes.hasNext()) {
055            dump(nodes.nextNode());
056        }
057    }
058}