Index: src/test/java/org/modeshape/connector/CmisConnectorIT.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>/*\n * ModeShape (http://www.modeshape.org)\n * See the COPYRIGHT.txt file distributed with this work for information\n * regarding copyright ownership.  Some portions may be licensed\n * to Red Hat, Inc. under one or more contributor license agreements.\n * See the AUTHORS.txt file in the distribution for a full listing of\n * individual contributors.\n *\n * Unless otherwise indicated, all code in ModeShape is licensed\n * to you under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * ModeShape is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\npackage org.modeshape.connector;\n\nimport org.apache.chemistry.opencmis.client.api.ObjectType;\nimport org.apache.chemistry.opencmis.client.api.Session;\nimport org.apache.chemistry.opencmis.client.api.SessionFactory;\nimport org.apache.chemistry.opencmis.client.api.Tree;\nimport org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;\nimport org.apache.chemistry.opencmis.commons.SessionParameter;\nimport org.apache.chemistry.opencmis.commons.enums.BindingType;\nimport org.junit.AfterClass;\nimport org.junit.BeforeClass;\nimport org.junit.Test;\nimport org.modeshape.jcr.MultiUseAbstractTest;\nimport org.modeshape.jcr.RepositoryConfiguration;\n\nimport javax.jcr.Binary;\nimport javax.jcr.Node;\nimport javax.jcr.Property;\nimport javax.jcr.ValueFactory;\nimport java.io.ByteArrayInputStream;\nimport java.io.ByteArrayOutputStream;\nimport java.io.InputStream;\nimport java.util.Calendar;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nimport static org.junit.Assert.*;\n\n/**\n * Provide integration testing of the CMIS connector with OpenCMIS InMemory\n * Repository.\n *\n * @author Alexander Voloshyn\n * @version 1.0 2/20/2013\n */\npublic class CmisConnectorIT extends MultiUseAbstractTest {\n    /**\n     * Test OpenCMIS InMemory Server URL.\n     * <p/>\n     * This OpenCMIS InMemory server instance should be started by maven cargo\n     * plugin at pre integration stage.\n     */\n    private static final String CMIS_URL = \"http://localhost:8090/\";\n\n    @BeforeClass\n    public static void beforeAll() throws Exception {\n        RepositoryConfiguration config = RepositoryConfiguration.read(\"config/repository-1.json\");\n        startRepository(config);\n    }\n\n    @AfterClass\n    public static void afterAll() throws Exception {\n        MultiUseAbstractTest.afterAll();\n    }\n\n    @Test\n    public void testDirectChemistryConnect() {\n        // default factory implementation\n        SessionFactory factory = SessionFactoryImpl.newInstance();\n        Map<String, String> parameter = new HashMap<String, String>();\n\n        // connection settings\n        parameter.put(SessionParameter.BINDING_TYPE, BindingType.WEBSERVICES.value());\n        parameter.put(SessionParameter.WEBSERVICES_ACL_SERVICE, CMIS_URL + \"services/ACLService?wsdl\");\n        parameter.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, CMIS_URL + \"services/DiscoveryService?wsdl\");\n        parameter.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, CMIS_URL + \"services/MultiFilingService?wsdl\");\n        parameter.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, CMIS_URL + \"services/NavigationService?wsdl\");\n        parameter.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, CMIS_URL + \"services/ObjectService?wsdl\");\n        parameter.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, CMIS_URL + \"services/PolicyService?wsdl\");\n        parameter.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, CMIS_URL + \"services/RelationshipService?wsdl\");\n        parameter.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, CMIS_URL + \"services/RepositoryService?wsdl\");\n        parameter.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, CMIS_URL + \"services/VersioningService?wsdl\");\n        // Default repository id for in memory server is A1\n        parameter.put(SessionParameter.REPOSITORY_ID, \"A1\");\n\n        // create session\n        final Session session = factory.createSession(parameter);\n        assertTrue(\"Chemistry session should exists.\", session != null);\n    }\n\n    private void print(List<Tree<ObjectType>> tree) {\n        for (int i = 0; i < tree.size(); i++) {\n            Tree t = tree.get(i);\n            System.out.println(\"item: \" + t.getItem());\n            print(t.getChildren());\n        }\n    }\n\n    @Test\n    public void shouldAccessRootFolder() throws Exception {\n        Node root = getSession().getNode(\"/cmis\");\n        assertTrue(root != null);\n    }\n\n    @Test\n    public void testRootFolderName() throws Exception {\n        Node root = getSession().getNode(\"/cmis\");\n        assertEquals(\"cmis\", root.getName());\n    }\n\n    @Test\n    public void shouldAccessRepositoryInfo() throws Exception {\n        Node repoInfo = getSession().getNode(\"/cmis/repository\");\n        assertEquals(\"OpenCMIS InMemory-Server\", repoInfo.getProperty(\"cmis:productName\").getString());\n        assertEquals(\"Apache Chemistry\", repoInfo.getProperty(\"cmis:vendorName\").getString());\n        assertTrue(repoInfo.getProperty(\"cmis:productVersion\").getString() != null);\n    }\n\n    @Test\n    public void shouldAccessFolderByPath() throws Exception {\n        Node root = getSession().getNode(\"/cmis\");\n        assertTrue(root != null);\n\n        Node node1 = getSession().getNode(\"/cmis/My_Folder-0-0\");\n        assertTrue(node1 != null);\n\n        Node node2 = getSession().getNode(\"/cmis/My_Folder-0-0/My_Folder-1-0\");\n        assertTrue(node2 != null);\n\n        Node node3 = getSession().getNode(\n                \"/cmis/My_Folder-0-0/My_Folder-1-0/My_Folder-2-0\");\n        assertTrue(node3 != null);\n    }\n\n    @Test\n    public void shouldAccessDocumentPath() throws Exception {\n        Node file = getSession().getNode(\"/cmis/My_Folder-0-0/My_Document-1-0\");\n        assertTrue(file != null);\n    }\n\n    // @Test\n    public void shouldAccessBinaryContent() throws Exception {\n        Node file = getSession().getNode(\"/cmis/My_Folder-0-0/My_Document-1-0\");\n        Node cnt = file.getNode(\"jcr:content\");\n\n        Property value = cnt.getProperty(\"jcr:data\");\n\n        Binary bv = value.getValue().getBinary();\n        InputStream is = bv.getStream();\n\n        ByteArrayOutputStream bout = new ByteArrayOutputStream();\n        int b = 0;\n        while (b != -1) {\n            b = is.read();\n            if (b != -1) {\n                bout.write(b);\n            }\n        }\n\n        byte[] content = bout.toByteArray();\n        String s = new String(content, 0, content.length);\n\n        assertFalse(\"Content shouldn't be empty.\", s.trim().isEmpty());\n    }\n\n    //-----------------------------------------------------------------------/\n    // Folder cmis build-in properties\n    //-----------------------------------------------------------------------/\n    @Test\n    public void shouldAccessObjectIdPropertyForFolder() throws Exception {\n        Node node = getSession().getNode(\"/cmis/My_Folder-0-0\");\n        String objectId = node.getProperty(\"jcr:uuid\").getString();\n        assertTrue(objectId != null);\n    }\n\n    @Test\n    public void shouldAccessNamePropertyForFolder() throws Exception {\n        Node node = getSession().getNode(\"/cmis/My_Folder-0-0\");\n        String name = node.getName();\n        assertEquals(\"My_Folder-0-0\", name);\n    }\n\n    @Test\n    public void shouldAccessCreatedByPropertyForFolder() throws Exception {\n        Node node = getSession().getNode(\"/cmis/My_Folder-0-0\");\n        String name = node.getProperty(\"jcr:createdBy\").getString();\n        assertEquals(\"unknown\", name);\n    }\n\n    @Test\n    public void shouldAccessCreationDatePropertyForFolder() throws Exception {\n        Node node = getSession().getNode(\"/cmis/My_Folder-0-0\");\n        Calendar date = node.getProperty(\"jcr:created\").getDate();\n        assertTrue(date != null);\n    }\n\n    @Test\n    public void shouldAccessModificationDatePropertyForFolder() throws Exception {\n        Node node = getSession().getNode(\"/cmis/My_Folder-0-0\");\n        Calendar date = node.getProperty(\"jcr:lastModified\").getDate();\n        assertTrue(date != null);\n    }\n\n\n    //-----------------------------------------------------------------------/\n    // Document cmis build-in properties\n    //-----------------------------------------------------------------------/\n    @Test\n    public void shouldAccessObjectIdPropertyForDocument() throws Exception {\n        Node node = getSession().getNode(\"/cmis/My_Folder-0-0/My_Document-1-0\");\n        String objectId = node.getProperty(\"jcr:uuid\").getString();\n        assertTrue(objectId != null);\n    }\n\n\n    @Test\n    public void shouldAccessCreatedByPropertyForDocument() throws Exception {\n        Node node = getSession().getNode(\"/cmis/My_Folder-0-0/My_Document-1-0\");\n        String name = node.getProperty(\"jcr:createdBy\").getString();\n        assertEquals(\"unknown\", name);\n    }\n\n    @Test\n    public void shouldAccessLastModifiedByPropertyForDocument()\n            throws Exception {\n        Node node = getSession().getNode(\"/cmis/My_Folder-0-0/My_Document-1-0\");\n        String name = node.getProperty(\"jcr:lastModifiedBy\").getString();\n        assertEquals(\"unknown\", name);\n    }\n\n    @Test\n    public void shouldAccessCreationDatePropertyForDocument() throws Exception {\n        Node node = getSession().getNode(\"/cmis/My_Folder-0-0/My_Document-1-0\");\n        Calendar date = node.getProperty(\"jcr:created\").getDate();\n        assertTrue(date != null);\n    }\n\n    @Test\n    public void shouldAccessModificationDatePropertyForDocument()\n            throws Exception {\n        Node node = getSession().getNode(\"/cmis/My_Folder-0-0/My_Document-1-0\");\n        Calendar date = node.getProperty(\"jcr:lastModified\").getDate();\n        assertTrue(date != null);\n    }\n\n    //    //@Test\n    public void shouldCreateFolder() throws Exception {\n        Node root = getSession().getNode(\"/cmis/src\");\n\n        Node node = root.addNode(\"test\", \"cmis:folder\");\n        node.setProperty(\"cmis:name\", \"test-name\");\n\n        root = getSession().getNode(\"/cmis/src\");\n        Node node1 = root.addNode(\"test-1\", \"cmis:document\");\n\n        byte[] content = \"Hello World\".getBytes();\n        ByteArrayInputStream bin = new ByteArrayInputStream(content);\n        bin.reset();\n\n        ValueFactory valueFactory = getSession().getValueFactory();\n        node1.setProperty(\"cmis:data\", valueFactory.createBinary(bin));\n        node1.setProperty(\"cmis:mimeType\", \"text/plain\");\n\n//        Node node2 = node.addNode(\"org\", \"cmis:folder\");\n        getSession().save();\n        assertTrue(node != null);\n\n    }\n\n    //    //@Test\n    public void shouldCreateDocument() throws Exception {\n        System.out.println(\"Creating document test case:\");\n        Node root = getSession().getNode(\"/cmis/src\");\n        Node node = root.addNode(\"readme\", \"cmis:document\");\n        System.out.println(\"Got node\");\n        node.setProperty(\"cmis:name\", \"test-name\");\n        getSession().save();\n        assertTrue(node != null);\n    }\n\n    //@Test\n    public void shouldModifyDocument() throws Exception {\n        Node pom = getSession().getNode(\"/cmis/My_Folder-0-1\");\n        pom.setProperty(\"cmis:name\", \"My_Folder-0-1_NEW_NAME\");\n\n        getSession().save();\n    }\n}\n
===================================================================
--- src/test/java/org/modeshape/connector/CmisConnectorIT.java	(revision 490e64d6bbbf051f719db708c55b0224aa275a33)
+++ src/test/java/org/modeshape/connector/CmisConnectorIT.java	(revision )
@@ -257,25 +257,27 @@
         assertTrue(date != null);
     }
 
-    //    //@Test
+    @Test
     public void shouldCreateFolder() throws Exception {
-        Node root = getSession().getNode("/cmis/src");
+        Node root = getSession().getNode("/cmis");
 
-        Node node = root.addNode("test", "cmis:folder");
-        node.setProperty("cmis:name", "test-name");
+        String name = "test"+System.currentTimeMillis();
+        Node node = root.addNode(name, "nt:folder");
+        assertTrue(name.equals(node.getName()));
+        //node.setProperty("name", "test-name");
 
-        root = getSession().getNode("/cmis/src");
-        Node node1 = root.addNode("test-1", "cmis:document");
+        root = getSession().getNode("/cmis/"+name);
+        Node node1 = root.addNode("test-1", "nt:file");
 
         byte[] content = "Hello World".getBytes();
         ByteArrayInputStream bin = new ByteArrayInputStream(content);
         bin.reset();
 
-        ValueFactory valueFactory = getSession().getValueFactory();
-        node1.setProperty("cmis:data", valueFactory.createBinary(bin));
-        node1.setProperty("cmis:mimeType", "text/plain");
+        Node contentNode = node1.addNode("jcr:content", "nt:resource");
+        Binary binary = session.getValueFactory().createBinary(bin);
+        contentNode.setProperty("jcr:data", binary);
+        contentNode.setProperty("jcr:lastModified",Calendar.getInstance());
 
-//        Node node2 = node.addNode("org", "cmis:folder");
         getSession().save();
         assertTrue(node != null);
 
Index: src/main/java/org/modeshape/connector/CmisConnector.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>/*\n * ModeShape (http://www.modeshape.org)\n * See the COPYRIGHT.txt file distributed with this work for information\n * regarding copyright ownership.  Some portions may be licensed\n * to Red Hat, Inc. under one or more contributor license agreements.\n * See the AUTHORS.txt file in the distribution for a full listing of\n * individual contributors.\n *\n * ModeShape is free software. Unless otherwise indicated, all code in ModeShape\n * is licensed to you under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * ModeShape is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\npackage org.modeshape.connector;\n\nimport java.io.ByteArrayInputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.math.BigInteger;\nimport java.util.*;\nimport javax.jcr.*;\nimport javax.jcr.NamespaceRegistry;\nimport javax.jcr.nodetype.*;\nimport org.apache.chemistry.opencmis.client.api.*;\nimport org.apache.chemistry.opencmis.client.api.Property;\nimport org.apache.chemistry.opencmis.client.api.Session;\nimport org.apache.chemistry.opencmis.client.bindings.spi.StandardAuthenticationProvider;\nimport org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;\nimport org.apache.chemistry.opencmis.commons.PropertyIds;\nimport org.apache.chemistry.opencmis.commons.SessionParameter;\nimport org.apache.chemistry.opencmis.commons.data.ContentStream;\nimport org.apache.chemistry.opencmis.commons.data.RepositoryInfo;\nimport org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;\nimport org.apache.chemistry.opencmis.commons.enums.BaseTypeId;\nimport org.apache.chemistry.opencmis.commons.enums.BindingType;\nimport org.apache.chemistry.opencmis.commons.enums.PropertyType;\nimport org.apache.chemistry.opencmis.commons.enums.VersioningState;\nimport org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;\nimport org.infinispan.schematic.document.Binary;\nimport org.infinispan.schematic.document.Document;\nimport org.infinispan.schematic.document.Document.Field;\nimport org.modeshape.jcr.JcrLexicon;\nimport org.modeshape.jcr.api.JcrConstants;\nimport org.modeshape.jcr.api.nodetype.NodeTypeManager;\nimport org.modeshape.jcr.federation.spi.Connector;\nimport org.modeshape.jcr.federation.spi.DocumentChanges;\nimport org.modeshape.jcr.federation.spi.DocumentChanges.PropertyChanges;\nimport org.modeshape.jcr.federation.spi.DocumentWriter;\nimport org.modeshape.jcr.value.*;\nimport org.w3c.dom.Element;\n\n/**\n *\n * @author kulikov\n * @author Ivan Vasyliev\n */\npublic class CmisConnector extends Connector {\n\n    //path and id for the repository node\n    private static final String REPOSITORY_ID = \"repository\";\n    private static final String REPOSITORY_NODE_NAME = \"repository\";\n\n    private Session session;\n    private ValueFactories factories;\n\n    //binding parameters\n    private String aclService;\n    private String discoveryService;\n    private String multifilingService;\n    private String navigationService;\n    private String objectService;\n    private String policyService;\n    private String relationshipService;\n    private String repositoryService;\n    private String versioningService;\n\n    //repository id\n    private String repositoryId;\n    private Properties properties;\n\n    public CmisConnector() {\n        super();\n    }\n\n    @Override\n    public void initialize(NamespaceRegistry registry,\n            NodeTypeManager nodeTypeManager) throws RepositoryException, IOException {\n        super.initialize(registry, nodeTypeManager);\n        this.factories = getContext().getValueFactories();\n        properties = new Properties(getContext().getValueFactories());\n        \n        // default factory implementation\n        Map<String, String> parameter = new HashMap<String, String>();\n\n        // user credentials\n        //parameter.put(SessionParameter.USER, user);\n        //parameter.put(SessionParameter.PASSWORD, passw);\n\n        // connection settings\n        parameter.put(SessionParameter.BINDING_TYPE, BindingType.WEBSERVICES.value());\n        parameter.put(SessionParameter.WEBSERVICES_ACL_SERVICE, aclService);\n        parameter.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, discoveryService);\n        parameter.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, multifilingService);\n        parameter.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, navigationService);\n        parameter.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, objectService);\n        parameter.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, policyService);\n        parameter.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, relationshipService);\n        parameter.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, repositoryService);\n        parameter.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, versioningService);\n        parameter.put(SessionParameter.REPOSITORY_ID, repositoryId);\n\n        SessionFactoryImpl factory = SessionFactoryImpl.newInstance();\n        session = factory.createSession(parameter, null,\n                new StandardAuthenticationProvider() {\n                    @Override\n                    public Element getSOAPHeaders(Object portObject) {\n                        //Place headers here\n                        return super.getSOAPHeaders(portObject);\n                    }\n                }, null);\n        \n        registry.registerNamespace(CmisLexicon.Namespace.PREFIX, CmisLexicon.Namespace.URI);\n        importTypes(session.getTypeDescendants(null, Integer.MAX_VALUE, true), nodeTypeManager);\n        registerRepositoryInfoType(nodeTypeManager);\n    }\n\n    @Override\n    public Document getDocumentById(String id) {\n        ObjectId objectId = ObjectId.valueOf(id);\n        switch (objectId.getType()) {\n            case REPOSITORY :\n                return cmisRepository();\n            case CONTENT :\n                return cmisContent(objectId.getIdentifier());\n            case OBJECT:\n                return cmisObject(objectId.getIdentifier());\n            default :\n                return null;\n        }\n    }\n\n    @Override\n    public String getDocumentId(String path) {\n        return session.getObjectByPath(path).getId();\n    }\n\n    @Override\n    public boolean removeDocument(String id) {\n        ObjectId objectId = ObjectId.valueOf(id);\n        switch (objectId.getType()) {\n            case REPOSITORY :\n                return false;\n            case CONTENT :\n                org.apache.chemistry.opencmis.client.api.Document doc =\n                (org.apache.chemistry.opencmis.client.api.Document) session.getObject(objectId.getIdentifier());\n                doc.deleteContentStream();\n                return true;\n            case OBJECT:\n                CmisObject object = session.getObject(objectId.getIdentifier());\n                if (object == null) {\n                    return false;\n                }\n                object.delete(true);\n                return true;\n            default:\n                return false;\n        }\n    }\n\n    @Override\n    public boolean hasDocument(String id) {\n        ObjectId objectId = ObjectId.valueOf(id);\n        switch (objectId.getType()) {\n            case REPOSITORY :\n                return true;\n            case CONTENT :\n                return session.getObject(objectId.getIdentifier()) != null;\n            default :\n                return session.getObject(id) != null;\n        }\n    }\n\n    @Override\n    public void storeDocument(Document document) {\n        ObjectId objectId = ObjectId.valueOf(document.getString(\"key\"));\n        switch (objectId.getType()) {\n            case REPOSITORY :\n                return;\n            case CONTENT :\n                ContentStream stream = jcrBinaryContent(document);\n                CmisObject cmisObject = session.getObject(objectId.getIdentifier());\n                if (stream != null && cmisObject != null) {\n                    ((org.apache.chemistry.opencmis.client.api.Document)cmisObject).setContentStream(stream, true);\n                }\n                break;\n            case OBJECT :\n                break;\n        }\n\n        //find object\n        String key = document.getString(\"key\");\n        CmisObject cmisObject = session.getObject(key);\n\n        //no such object? just exit\n        if (cmisObject == null) {\n            return;\n        }\n\n        //pickup node properties\n        Document props = document.getDocument(\"properties\").getDocument(JcrLexicon.Namespace.URI);\n\n        Iterator<Field> list = document.fields().iterator();\n\n        switch (cmisObject.getBaseTypeId()) {\n            case CMIS_FOLDER :\n                break;\n            case CMIS_DOCUMENT:\n                //store binary content\n                ContentStream stream = jcrBinaryContent(document);\n                if (stream != null) {\n                    ((org.apache.chemistry.opencmis.client.api.Document)cmisObject).setContentStream(stream, true);\n                }\n                break;\n        }\n        //set binary value and properties\n    }\n\n    @Override\n    public void updateDocument(DocumentChanges delta) {\n\n        Document node = delta.getDocument();\n        String id = delta.getDocumentId();\n\n        CmisObject cmisObject = session.getObject(id);\n        if (cmisObject == null) {\n            //unknown object\n            return;\n        }\n\n        Document props = delta.getDocument().getDocument(\"properties\");\n        HashMap<String, Object> updateProperties = new HashMap();\n\n        PropertyChanges changes = delta.getPropertyChanges();\n\n        Set<Name> changed = changes.getChanged();\n        for (Name n : changed) {\n            String jcrName = n.getLocalName();\n            Document jcrValues = props.getDocument(n.getNamespaceUri());\n\n            String cmisPropertyName = n.toString();\n            Property cmisProperty = cmisObject.getProperty(cmisPropertyName);\n\n            Object value = properties.cmisValue(cmisProperty, jcrName, jcrValues);\n            updateProperties.put(cmisPropertyName, value);\n\n            cmisObject.updateProperties(updateProperties);\n        }\n    }\n\n    @Override\n    public boolean isReadonly() {\n        return false;\n    }\n\n    @Override\n    public String newDocumentId(String parentId, Name name, Name primaryType) {\n        HashMap<String, Object> params = new HashMap();\n\n        if (primaryType.getLocalName().equals(NodeType.NT_FOLDER)) {\n            Folder parent = (Folder) session.getObject(parentId);\n            String path = parent.getPath() + \"/\" + name.getLocalName();\n            //minimal set of parameters\n            params.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_FOLDER.value());\n            params.put(PropertyIds.NAME, name.getLocalName());\n            params.put(PropertyIds.PATH, path);\n\n            Folder folder = parent.createFolder(params);\n            return folder.getId();\n        }\n\n        if (primaryType.getLocalName().equals(NodeType.NT_FILE)) {\n            Folder parent = (Folder) session.getObject(parentId);\n            String path = parent.getPath() + \"/\" + name.getLocalName();\n            //minimal set of parameters\n            params.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_DOCUMENT.value());\n            params.put(PropertyIds.NAME, name.getLocalName());\n            params.put(PropertyIds.PATH, path);\n\n            String id = parent.createDocument(params, null, VersioningState.NONE).getId();\n            return id;\n        }\n\n        return null;\n    }\n\n    /**\n     * Converts CMIS object to JCR node.\n     *\n     * @param id the identifier of the CMIS object\n     * @return JCR node document.\n     */\n    private Document cmisObject(String id) {\n        CmisObject cmisObject = session.getObject(id);\n\n        //object does not exist? return null\n        if (cmisObject == null) {\n            return null;\n        }\n\n        //converting CMIS object to JCR node\n        switch (cmisObject.getBaseTypeId()) {\n            case CMIS_FOLDER:\n                return cmisFolder(cmisObject);\n            case CMIS_DOCUMENT:\n                return cmisDocument(cmisObject);\n        }\n\n        //unexpected object type\n        return null;\n    }\n\n    /**\n     * Translates CMIS folder object to JCR node\n     * \n     * @param cmisObject CMIS folder object\n     * @return JCR node document.\n     */\n    private Document cmisFolder(CmisObject cmisObject) {\n        Folder folder = (Folder) cmisObject;\n        DocumentWriter writer = newDocument(ObjectId.toString(ObjectId.Type.OBJECT, folder.getId()));\n\n        ObjectType objectType = cmisObject.getType();\n        if (objectType.isBaseType()) {\n            writer.setPrimaryType(NodeType.NT_FOLDER);\n        } else {\n            writer.setPrimaryType(objectType.getId());\n        }\n\n        writer.setParent(folder.getParentId());\n        writer.addMixinType(NodeType.MIX_CREATED);\n        writer.addMixinType(NodeType.MIX_LAST_MODIFIED);\n        writer.addMixinType(NodeType.MIX_REFERENCEABLE);\n\n        cmisProperties(folder, writer);\n        cmisChildren((Folder)folder, writer);\n\n        //append repository information to the root node\n        if (folder.isRootFolder()) {\n            writer.addChild(ObjectId.toString(ObjectId.Type.REPOSITORY, \"\"), REPOSITORY_NODE_NAME);\n        }\n\n        return writer.document();\n    }\n\n    /**\n     * Translates cmis document object to JCR node.\n     * \n     * @param cmisObject cmis document node\n     * @return JCR node document.\n     */\n    public Document cmisDocument(CmisObject cmisObject) {\n        org.apache.chemistry.opencmis.client.api.Document doc =\n                (org.apache.chemistry.opencmis.client.api.Document) cmisObject;\n        DocumentWriter writer = newDocument(ObjectId.toString(ObjectId.Type.OBJECT, doc.getId()));\n\n        ObjectType objectType = cmisObject.getType();\n        if (objectType.isBaseType()) {\n            writer.setPrimaryType(NodeType.NT_FILE);\n        } else {\n            writer.setPrimaryType(objectType.getId());\n        }\n\n        writer.addMixinType(NodeType.MIX_CREATED);\n        writer.addMixinType(NodeType.MIX_LAST_MODIFIED);\n        writer.addMixinType(NodeType.MIX_REFERENCEABLE);\n\n        cmisProperties(doc, writer);\n        writer.addChild(ObjectId.toString(ObjectId.Type.CONTENT, doc.getId()), JcrConstants.JCR_CONTENT);\n        \n        return writer.document();\n    }\n\n    /**\n     * Converts binary content into JCR node.\n     *\n     * @param id the id of the CMIS document.\n     * @return JCR node representation.\n     */\n    private Document cmisContent(String id) {\n        DocumentWriter writer = newDocument(ObjectId.toString(ObjectId.Type.CONTENT, id));\n\n        org.apache.chemistry.opencmis.client.api.Document doc =\n                (org.apache.chemistry.opencmis.client.api.Document)session.getObject(id);\n        writer.setPrimaryType(NodeType.NT_RESOURCE);\n        \n        if (doc.getContentStream() != null) {\n            InputStream is = doc.getContentStream().getStream();\n            BinaryValue content = factories.getBinaryFactory().create(is);\n            writer.addProperty(JcrConstants.JCR_DATA, content);\n            writer.addProperty(JcrConstants.JCR_MIME_TYPE, doc.getContentStream().getMimeType());\n        }\n\n        return writer.document();\n    }\n\n    /**\n     * Converts CMIS object's properties to JCR node properties.\n     *\n     * @param object CMIS object\n     * @param writer JCR node representation.\n     */\n    private void cmisProperties(CmisObject object, DocumentWriter writer) {\n        //convert properties\n        List<Property<?>> list = object.getProperties();\n        for (Property property : list) {\n            String pname = properties.findJcrName(property.getId());\n            writer.addProperty(pname, properties.jcrValues(property));\n        }\n    }\n\n\n    /**\n     * Converts CMIS folder children to JCR node children\n     * \n     * @param folder CMIS folder\n     * @param writer JCR node representation\n     */\n    private void cmisChildren(Folder folder, DocumentWriter writer) {\n        ItemIterable<CmisObject> it = folder.getChildren();\n        for (CmisObject obj : it) {\n            writer.addChild(obj.getId(), obj.getName());\n        }\n    }\n\n    /**\n     * Translates CMIS repository information into Node.\n     * \n     * @return node document.\n     */\n    private Document cmisRepository() {\n        RepositoryInfo info = session.getRepositoryInfo();\n        DocumentWriter writer = newDocument(ObjectId.toString(ObjectId.Type.REPOSITORY, \"\"));\n\n        writer.setPrimaryType(CmisLexicon.REPOSITORY);\n        writer.setId(REPOSITORY_ID);\n\n        //product name/vendor/version\n        writer.addProperty(CmisLexicon.VENDOR_NAME, info.getVendorName());\n        writer.addProperty(CmisLexicon.PRODUCT_NAME, info.getProductName());\n        writer.addProperty(CmisLexicon.PRODUCT_VERSION, info.getProductVersion());\n        \n        return writer.document();\n    }\n\n    /**\n     * Creates content stream using JCR node.\n     *\n     * @param document JCR node representation\n     * @return CMIS content stream object\n     */\n    private ContentStream jcrBinaryContent(Document document) {\n        //pickup node properties\n        Document props = document.getDocument(\"properties\").getDocument(CmisLexicon.Namespace.URI);\n\n        Iterator<Field> list = props.fields().iterator();\n\n        //extract binary value and content\n        Binary value = props.getBinary(\"data\");\n\n        if (value == null) {\n            return null;\n        }\n\n        byte[] content = value.getBytes();\n        String fileName = props.getString(\"fileName\");\n        String mimeType = props.getString(\"mimeType\");\n\n        //wrap with input stream\n        ByteArrayInputStream bin = new ByteArrayInputStream(content);\n        bin.reset();\n\n        //create content stream\n        ContentStreamImpl contentStream = new ContentStreamImpl(fileName, BigInteger.valueOf(content.length), mimeType, bin);\n\n        return contentStream;\n    }\n\n    /**\n     * Import CMIS types to JCR repository.\n     *\n     * @param types CMIS types\n     * @param typeManager JCR type manager\n     */\n    private void importTypes(List<Tree<ObjectType>> types, NodeTypeManager typeManager) throws RepositoryException {\n        for (int i = 0; i < types.size(); i++) {\n            Tree<ObjectType> tree = types.get(i);\n            importType(tree.getItem(), typeManager);\n            importTypes(tree.getChildren(), typeManager);\n        }\n    }\n\n    /**\n     * Import given CMIS type to the JCR repository.\n     *\n     * @param cmisType cmis object type\n     * @param typeManager JCR type manager/\n     */\n    public void importType(ObjectType cmisType, NodeTypeManager typeManager) throws RepositoryException {\n        //skip base types because we are going to\n        //map base types directly\n        if (cmisType.isBaseType()) {\n            return;\n        }\n\n        //create node type template\n        NodeTypeTemplate type = typeManager.createNodeTypeTemplate();\n\n        //convert CMIS type's attributes to node type template we have just created\n        type.setName(cmisType.getId());\n        type.setAbstract(false);\n        type.setMixin(true);\n        type.setOrderableChildNodes(true);\n        type.setQueryable(true);\n        type.setDeclaredSuperTypeNames(superTypes(cmisType));\n\n        Map<String, PropertyDefinition<?>> props = cmisType.getPropertyDefinitions();\n        Set<String> names = props.keySet();\n\n        //properties\n        for (String name : names) {\n            PropertyDefinition pd = props.get(name);\n            PropertyDefinitionTemplate pt = typeManager.createPropertyDefinitionTemplate();\n\n\n            //Do we need to map types?\n            pt.setRequiredType(properties.getJcrType(pd.getPropertyType()));\n\n            pt.setAutoCreated(false);\n            pt.setAvailableQueryOperators(new String[]{});\n            pt.setName(name);\n            pt.setMandatory(pd.isRequired());\n\n            type.getPropertyDefinitionTemplates().add(pt);\n        }\n\n        //register type\n        NodeTypeDefinition[] nodeDefs = new NodeTypeDefinition[] {type};\n        typeManager.registerNodeTypes(nodeDefs, true);\n    }\n\n    /**\n     * Determines supertypes for the given CMIS type in terms of JCR.\n     *\n     * @param cmisType given CMIS type\n     * @return supertypes in JCR lexicon.\n     */\n    private String[] superTypes(ObjectType cmisType) {\n        if (cmisType.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) {\n            return new String[] {JcrConstants.NT_FOLDER};\n        }\n\n        if (cmisType.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) {\n            return new String[] {JcrConstants.NT_FILE};\n        }\n\n        return new String[]{cmisType.getParentType().getLocalName()};\n    }\n\n    /**\n     * Defines node type for the repository info.\n     *\n     * @param typeManager JCR node type manager.\n     * @throws RepositoryException\n     */\n    private void registerRepositoryInfoType(NodeTypeManager typeManager) throws RepositoryException {\n        //create node type template\n        NodeTypeTemplate type = typeManager.createNodeTypeTemplate();\n\n        //convert CMIS type's attributes to node type template we have just created\n        type.setName(\"cmis:repository\");\n        type.setAbstract(false);\n        type.setMixin(true);\n        type.setOrderableChildNodes(true);\n        type.setQueryable(true);\n        type.setDeclaredSuperTypeNames(new String[]{JcrConstants.NT_FOLDER});\n\n        PropertyDefinitionTemplate vendorName = typeManager.createPropertyDefinitionTemplate();\n        vendorName.setAutoCreated(false);\n        vendorName.setName(\"cmis:vendorName\");\n        vendorName.setMandatory(false);\n\n        type.getPropertyDefinitionTemplates().add(vendorName);\n\n        PropertyDefinitionTemplate productName = typeManager.createPropertyDefinitionTemplate();\n        productName.setAutoCreated(false);\n        productName.setName(\"cmis:productName\");\n        productName.setMandatory(false);\n\n        type.getPropertyDefinitionTemplates().add(productName);\n\n        PropertyDefinitionTemplate productVersion = typeManager.createPropertyDefinitionTemplate();\n        productVersion.setAutoCreated(false);\n        productVersion.setName(\"cmis:productVersion\");\n        productVersion.setMandatory(false);\n\n        type.getPropertyDefinitionTemplates().add(productVersion);\n\n        //register type\n        NodeTypeDefinition[] nodeDefs = new NodeTypeDefinition[] {type};\n        typeManager.registerNodeTypes(nodeDefs, true);\n    }\n}\n
===================================================================
--- src/main/java/org/modeshape/connector/CmisConnector.java	(revision 490e64d6bbbf051f719db708c55b0224aa275a33)
+++ src/main/java/org/modeshape/connector/CmisConnector.java	(revision )
@@ -23,17 +23,7 @@
  */
 package org.modeshape.connector;
 
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigInteger;
-import java.util.*;
-import javax.jcr.*;
-import javax.jcr.NamespaceRegistry;
-import javax.jcr.nodetype.*;
 import org.apache.chemistry.opencmis.client.api.*;
-import org.apache.chemistry.opencmis.client.api.Property;
-import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.client.bindings.spi.StandardAuthenticationProvider;
 import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
 import org.apache.chemistry.opencmis.commons.PropertyIds;
@@ -43,7 +33,6 @@
 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.enums.BindingType;
-import org.apache.chemistry.opencmis.commons.enums.PropertyType;
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
 import org.infinispan.schematic.document.Binary;
@@ -56,11 +45,21 @@
 import org.modeshape.jcr.federation.spi.DocumentChanges;
 import org.modeshape.jcr.federation.spi.DocumentChanges.PropertyChanges;
 import org.modeshape.jcr.federation.spi.DocumentWriter;
-import org.modeshape.jcr.value.*;
+import org.modeshape.jcr.value.BinaryValue;
+import org.modeshape.jcr.value.Name;
+import org.modeshape.jcr.value.ValueFactories;
 import org.w3c.dom.Element;
 
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.*;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.util.*;
+
 /**
- *
  * @author kulikov
  * @author Ivan Vasyliev
  */
@@ -69,10 +68,8 @@
     //path and id for the repository node
     private static final String REPOSITORY_ID = "repository";
     private static final String REPOSITORY_NODE_NAME = "repository";
-
     private Session session;
     private ValueFactories factories;
-
     //binding parameters
     private String aclService;
     private String discoveryService;
@@ -83,10 +80,11 @@
     private String relationshipService;
     private String repositoryService;
     private String versioningService;
-
     //repository id
     private String repositoryId;
     private Properties properties;
+    private Map<String, NodeType> folderTypes;
+    private Map<String, NodeType> fileTypes;
 
     public CmisConnector() {
         super();
@@ -94,11 +92,12 @@
 
     @Override
     public void initialize(NamespaceRegistry registry,
-            NodeTypeManager nodeTypeManager) throws RepositoryException, IOException {
+                           NodeTypeManager nodeTypeManager) throws RepositoryException, IOException {
         super.initialize(registry, nodeTypeManager);
+
         this.factories = getContext().getValueFactories();
         properties = new Properties(getContext().getValueFactories());
-        
+
         // default factory implementation
         Map<String, String> parameter = new HashMap<String, String>();
 
@@ -128,23 +127,36 @@
                         return super.getSOAPHeaders(portObject);
                     }
                 }, null);
-        
+
         registry.registerNamespace(CmisLexicon.Namespace.PREFIX, CmisLexicon.Namespace.URI);
-        importTypes(session.getTypeDescendants(null, Integer.MAX_VALUE, true), nodeTypeManager);
+        importTypes(session.getTypeDescendants(null, Integer.MAX_VALUE, true), nodeTypeManager, registry);
         registerRepositoryInfoType(nodeTypeManager);
+
+        folderTypes = new HashMap<String, NodeType>();
+        NodeTypeIterator folders = nodeTypeManager.getNodeType(NodeType.NT_FOLDER).getSubtypes();
+        while (folders.hasNext()) {
+            NodeType type = (NodeType) folders.next();
+            folderTypes.put(type.getName(), type);
-    }
+        }
+        NodeTypeIterator files = nodeTypeManager.getNodeType(NodeType.NT_FILE).getSubtypes();
+        fileTypes = new HashMap<String, NodeType>();
+        while (files.hasNext()) {
+            NodeType type = (NodeType) files.next();
+            fileTypes.put(type.getName(), type);
+        }
+    }
 
     @Override
     public Document getDocumentById(String id) {
         ObjectId objectId = ObjectId.valueOf(id);
         switch (objectId.getType()) {
-            case REPOSITORY :
+            case REPOSITORY:
                 return cmisRepository();
-            case CONTENT :
+            case CONTENT:
                 return cmisContent(objectId.getIdentifier());
             case OBJECT:
                 return cmisObject(objectId.getIdentifier());
-            default :
+            default:
                 return null;
         }
     }
@@ -181,11 +193,11 @@
     public boolean hasDocument(String id) {
         ObjectId objectId = ObjectId.valueOf(id);
         switch (objectId.getType()) {
-            case REPOSITORY :
+            case REPOSITORY:
                 return true;
-            case CONTENT :
+            case CONTENT:
                 return session.getObject(objectId.getIdentifier()) != null;
-            default :
+            default:
                 return session.getObject(id) != null;
         }
     }
@@ -222,13 +234,13 @@
         Iterator<Field> list = document.fields().iterator();
 
         switch (cmisObject.getBaseTypeId()) {
-            case CMIS_FOLDER :
+            case CMIS_FOLDER:
                 break;
             case CMIS_DOCUMENT:
                 //store binary content
                 ContentStream stream = jcrBinaryContent(document);
                 if (stream != null) {
-                    ((org.apache.chemistry.opencmis.client.api.Document)cmisObject).setContentStream(stream, true);
+                    ((org.apache.chemistry.opencmis.client.api.Document) cmisObject).setContentStream(stream, true);
                 }
                 break;
         }
@@ -276,7 +288,7 @@
     public String newDocumentId(String parentId, Name name, Name primaryType) {
         HashMap<String, Object> params = new HashMap();
 
-        if (primaryType.getLocalName().equals(NodeType.NT_FOLDER)) {
+        if (primaryType.toString().equals(NodeType.NT_FOLDER) || folderTypes.containsKey(primaryType.toString())) {
             Folder parent = (Folder) session.getObject(parentId);
             String path = parent.getPath() + "/" + name.getLocalName();
             //minimal set of parameters
@@ -284,22 +296,39 @@
             params.put(PropertyIds.NAME, name.getLocalName());
             params.put(PropertyIds.PATH, path);
 
+            if (folderTypes.containsKey(primaryType.toString())) {
+                for (javax.jcr.nodetype.PropertyDefinition prop : folderTypes.get(primaryType.toString()).getPropertyDefinitions()) {
+                    if (prop.isMandatory()) {
+                        //TODO: Fill proper random value per each possible type
+                        params.put(prop.getName(), new Object());
+                    }
+                }
+            }
+
             Folder folder = parent.createFolder(params);
             return folder.getId();
         }
 
-        if (primaryType.getLocalName().equals(NodeType.NT_FILE)) {
+        if (primaryType.toString().equals(NodeType.NT_FILE) || fileTypes.containsKey(primaryType.toString())) {
             Folder parent = (Folder) session.getObject(parentId);
             String path = parent.getPath() + "/" + name.getLocalName();
             //minimal set of parameters
             params.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_DOCUMENT.value());
             params.put(PropertyIds.NAME, name.getLocalName());
-            params.put(PropertyIds.PATH, path);
+            //params.put(PropertyIds.PARENT_ID, path);
 
-            String id = parent.createDocument(params, null, VersioningState.NONE).getId();
-            return id;
+            if (fileTypes.containsKey(primaryType.toString())) {
+                for (javax.jcr.nodetype.PropertyDefinition prop : fileTypes.get(primaryType.toString()).getPropertyDefinitions()) {
+                    if (prop.isMandatory()) {
+                        //TODO: Fill proper random value per each possible type
+                        params.put(prop.getName(), new Object());
-        }
+                    }
-
+                }
+            }
+            //TODO: check capabilities, in case of versioning supported - create new version
+            //session.getRepositoryInfo().getCapabilities().getChangesCapability().
+            return parent.createDocument(params, null, VersioningState.NONE).getId();
+        }
         return null;
     }
 
@@ -331,7 +360,7 @@
 
     /**
      * Translates CMIS folder object to JCR node
-     * 
+     *
      * @param cmisObject CMIS folder object
      * @return JCR node document.
      */
@@ -352,7 +381,7 @@
         writer.addMixinType(NodeType.MIX_REFERENCEABLE);
 
         cmisProperties(folder, writer);
-        cmisChildren((Folder)folder, writer);
+        cmisChildren((Folder) folder, writer);
 
         //append repository information to the root node
         if (folder.isRootFolder()) {
@@ -364,7 +393,7 @@
 
     /**
      * Translates cmis document object to JCR node.
-     * 
+     *
      * @param cmisObject cmis document node
      * @return JCR node document.
      */
@@ -386,7 +415,7 @@
 
         cmisProperties(doc, writer);
         writer.addChild(ObjectId.toString(ObjectId.Type.CONTENT, doc.getId()), JcrConstants.JCR_CONTENT);
-        
+
         return writer.document();
     }
 
@@ -400,9 +429,9 @@
         DocumentWriter writer = newDocument(ObjectId.toString(ObjectId.Type.CONTENT, id));
 
         org.apache.chemistry.opencmis.client.api.Document doc =
-                (org.apache.chemistry.opencmis.client.api.Document)session.getObject(id);
+                (org.apache.chemistry.opencmis.client.api.Document) session.getObject(id);
         writer.setPrimaryType(NodeType.NT_RESOURCE);
-        
+
         if (doc.getContentStream() != null) {
             InputStream is = doc.getContentStream().getStream();
             BinaryValue content = factories.getBinaryFactory().create(is);
@@ -428,10 +457,9 @@
         }
     }
 
-
     /**
      * Converts CMIS folder children to JCR node children
-     * 
+     *
      * @param folder CMIS folder
      * @param writer JCR node representation
      */
@@ -444,7 +472,7 @@
 
     /**
      * Translates CMIS repository information into Node.
-     * 
+     *
      * @return node document.
      */
     private Document cmisRepository() {
@@ -458,7 +486,7 @@
         writer.addProperty(CmisLexicon.VENDOR_NAME, info.getVendorName());
         writer.addProperty(CmisLexicon.PRODUCT_NAME, info.getProductName());
         writer.addProperty(CmisLexicon.PRODUCT_VERSION, info.getProductVersion());
-        
+
         return writer.document();
     }
 
@@ -498,30 +526,35 @@
     /**
      * Import CMIS types to JCR repository.
      *
-     * @param types CMIS types
+     * @param types       CMIS types
      * @param typeManager JCR type manager
+     * @param registry
      */
-    private void importTypes(List<Tree<ObjectType>> types, NodeTypeManager typeManager) throws RepositoryException {
+    private void importTypes(List<Tree<ObjectType>> types, NodeTypeManager typeManager, NamespaceRegistry registry) throws RepositoryException {
         for (int i = 0; i < types.size(); i++) {
             Tree<ObjectType> tree = types.get(i);
-            importType(tree.getItem(), typeManager);
-            importTypes(tree.getChildren(), typeManager);
+            importType(tree.getItem(), typeManager, registry);
+            importTypes(tree.getChildren(), typeManager, registry);
         }
     }
 
     /**
      * Import given CMIS type to the JCR repository.
      *
-     * @param cmisType cmis object type
+     * @param cmisType    cmis object type
      * @param typeManager JCR type manager/
+     * @param registry
      */
-    public void importType(ObjectType cmisType, NodeTypeManager typeManager) throws RepositoryException {
+    public void importType(ObjectType cmisType, NodeTypeManager typeManager, NamespaceRegistry registry) throws RepositoryException {
         //skip base types because we are going to
         //map base types directly
         if (cmisType.isBaseType()) {
             return;
         }
 
+        //TODO: get namespace information and register
+        //registry.registerNamespace(cmisType.getLocalNamespace(), cmisType.getLocalNamespace());
+
         //create node type template
         NodeTypeTemplate type = typeManager.createNodeTypeTemplate();
 
@@ -540,21 +573,16 @@
         for (String name : names) {
             PropertyDefinition pd = props.get(name);
             PropertyDefinitionTemplate pt = typeManager.createPropertyDefinitionTemplate();
-
-
-            //Do we need to map types?
             pt.setRequiredType(properties.getJcrType(pd.getPropertyType()));
-
             pt.setAutoCreated(false);
             pt.setAvailableQueryOperators(new String[]{});
             pt.setName(name);
             pt.setMandatory(pd.isRequired());
-
             type.getPropertyDefinitionTemplates().add(pt);
         }
 
         //register type
-        NodeTypeDefinition[] nodeDefs = new NodeTypeDefinition[] {type};
+        NodeTypeDefinition[] nodeDefs = new NodeTypeDefinition[]{type};
         typeManager.registerNodeTypes(nodeDefs, true);
     }
 
@@ -573,7 +601,7 @@
             return new String[] {JcrConstants.NT_FILE};
         }
 
-        return new String[]{cmisType.getParentType().getLocalName()};
+        return new String[]{cmisType.getParentType().getId()};
     }
 
     /**
@@ -616,7 +644,7 @@
         type.getPropertyDefinitionTemplates().add(productVersion);
 
         //register type
-        NodeTypeDefinition[] nodeDefs = new NodeTypeDefinition[] {type};
+        NodeTypeDefinition[] nodeDefs = new NodeTypeDefinition[]{type};
         typeManager.registerNodeTypes(nodeDefs, true);
     }
 }
Index: src/main/resources/infinispan-federation-persistent.xml
===================================================================
--- src/main/resources/infinispan-federation-persistent.xml	(revision 490e64d6bbbf051f719db708c55b0224aa275a33)
+++ src/main/resources/infinispan-federation-persistent.xml	(revision 490e64d6bbbf051f719db708c55b0224aa275a33)
@@ -1,1 +0,0 @@
-
\ No newline at end of file
Index: src/main/resources/infinispan-configuration.xml
===================================================================
--- src/main/resources/infinispan-configuration.xml	(revision 490e64d6bbbf051f719db708c55b0224aa275a33)
+++ src/main/resources/infinispan-configuration.xml	(revision 490e64d6bbbf051f719db708c55b0224aa275a33)
@@ -1,1 +0,0 @@
-
\ No newline at end of file
