06-01-2011 08:23 AM
/*
 * Copyright (C) 2005-2010 Alfresco Software Limited.
 *
 * This file is part of Alfresco
 *
 * Alfresco is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Alfresco is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
 */
package org.alfresco.sample.jcr;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
 * Simple Example that demonstrate login and retrieval of top-level Spaces
 * under Company Home.
 * 
 * @author David Caruana
 */
public class SimpleExample
{
    public static void main(String[] args)
        throws Exception
    {
        // Setup Spring and Transaction Service
        ApplicationContext context = new ClassPathXmlApplicationContext("classpath:alfresco/application-context.xml");
        
        // Retrieve Repository
        Repository repository = (Repository)context.getBean("JCR.Repository");
        // Login to workspace
        // Note: Default workspace is the one used by Alfresco Web Client which contains all the Spaces
        //       and their documents
        Session session = repository.login(new SimpleCredentials("admin", "alfrescoadmin".toCharArray()));
        try
        {
            // Retrieve Company Home
            Node root = session.getRootNode();
            Node companyHome = root.getNode("app:company_home");
            
            // Iterator through children of Company Home
            NodeIterator iterator = companyHome.getNodes();
            while(iterator.hasNext())
            {
                Node child = iterator.nextNode();
                System.out.println(child.getName());
                PropertyIterator propIterator = child.getProperties();
                while(propIterator.hasNext())
                {
                    Property prop = propIterator.nextProperty();
                    if (!prop.getDefinition().isMultiple())
                    {
                        System.out.println(" " + prop.getName() + " = " + prop.getString());
                    }
                }
            }System.out.println("pas de noeud");
        }
        finally
        {
            session.logout();
            System.exit(0);
        }
        
    }
    
}
#
# Sample custom content and index data location
#
dir.root=C:/Alfresco/alf_data
db.name=alfresco
db.username=root
db.password=alfresco
db.port=3306
db.host=10.67.27.12
#
# MySQL connection (This is default and requires mysql-connector-java-3.1.12-bin.jar, which ships with the Alfresco server)
#
db.driver=org.gjt.mm.mysql.Driver
db.url=jdbc:mysql://10.67.27.12:3306/alfresco
#
# Oracle connection (requires ojdbc14_g.jar or equivalent jar in shared libraries location)
#
#db.driver=oracle.jdbc.OracleDriver
#db.url=jdbc:oracle:thin:@localhost:1521:alfresco
#
# Sybase connection (requires jconn2d.jar or equivalent jar in shared libraries location)
#
#db.driver=com.sybase.jdbc2.jdbc.SybDriver
#db.url=jdbc:sybase:Tds:localhost:2638/alfresco
# 
# Properties shared between the Alfresco server 
# and its remote clients (e.g.: the virtualization server).
#
# Ports used by Alfresco
#
# Note:  These ports are also used by the virtualization server
#        (hence, they're in a seperate file that can be copied easily).
avm.rmi.service.port=50501
avmsync.rmi.service.port=50502
attribute.rmi.service.port=50503
authentication.rmi.service.port=50504
repo.rmi.service.port=50505
action.rmi.service.port=50806
wcm-deployment-receiver.rmi.service.port=50507
# Remote RMI services
alfresco.rmi.services.port=50500
alfresco.rmi.services.host=10.67.27.12
Exception in thread "main" org.alfresco.error.AlfrescoRuntimeException: 05010001 Ensure that the 'dir.root' property is pointing to the correct data location.
   at org.alfresco.repo.admin.ConfigurationChecker.check(ConfigurationChecker.java:332)
   at org.alfresco.repo.admin.ConfigurationChecker.access$000(ConfigurationChecker.java:68)
   at org.alfresco.repo.admin.ConfigurationChecker$1.execute(ConfigurationChecker.java:180)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:377)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:270)
   at org.alfresco.repo.admin.ConfigurationChecker.onBootstrap(ConfigurationChecker.java:184)
   at org.springframework.extensions.surf.util.AbstractLifecycleBean.onApplicationEvent(AbstractLifecycleBean.java:56)
   at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
   at org.alfresco.repo.management.SafeApplicationEventMulticaster.multicastEvent(SafeApplicationEventMulticaster.java:78)
   at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:294)
   at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:858)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:419)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
   at org.alfresco.sample.jcr.SimpleExample.main(SimpleExample.java:47)
dir.root=C:/Alfresco/alf_data06-01-2011 08:40 AM
06-01-2011 09:30 AM
06-01-2011 10:09 AM
 
					
				
				
			
		
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.