summaryrefslogtreecommitdiffstats
path: root/das-java/contrib/ldap/das.ldap/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'das-java/contrib/ldap/das.ldap/src/main/java/org')
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplate.java129
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplateTest.java59
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplate.java157
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplateTest.java50
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplate.java103
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplateTest.java66
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplate.java117
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplateTest.java73
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/connect/ADSEmbeddedConnection.java175
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/connect/JNDIConnection.java96
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/InitialContextCreator.java75
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/InitialContextCreatorHelper.java143
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/MetaContextCreator.java65
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/destroy/InitialContextDestroyer.java74
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/destroy/MetaContextDestroyer.java53
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/Context.java81
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/LdapDAS.java379
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/LdapDASHelper.java295
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataGraphCreator.java62
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataGraphCreatorHelper.java97
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataObjectCreator.java137
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataObjectCreatorHelper.java284
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReader.java131
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReaderHelper.java365
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReader.java100
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReaderHelper.java161
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdater.java63
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdaterHelper.java228
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/constants/EncryptionConstants.java26
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/util/ChecksumUtils.java38
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/ComplexTypeOIDCreator.java69
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/OIDCreatorHelper.java73
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/SimpleTypeOIDCreator.java66
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/Prototype.java74
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/PrototypeUtilities.java243
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/CommonSetupTest.java264
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataGraphSetupTest.java138
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataObjectSetupTest.java49
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/LdapDASSetupTest.java218
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/AbstractAttributeTypeCreator.java40
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/AbstractTypeCreator.java59
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/ComplexTypeRDNCreator.java60
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SimpleTypeRDNCreator.java63
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SyntaxCheckerEntryCreator.java94
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SyntaxEntryCreator.java155
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetup.java87
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetupTest.java46
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetup.java47
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetupTest.java54
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetup.java191
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetupTest.java59
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetup.java74
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetupTest.java56
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetup.java201
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetupTest.java64
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetup.java116
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetupTest.java49
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/DataTypeToADSSyntaxMapProvider.java54
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EAttributeTypeCreator.java113
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreator.java202
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreatorHelper.java378
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EReferenceTypeCreator.java95
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EcoreTypeSystemHelper.java388
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/ModelTypeSystemCreator.java56
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/ECascadingObjectClassDestroyer.java145
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EObjectClassDestroyer.java90
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EStructuralFeatureTypeDestroyer.java61
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/provide/SyntaxOIDProvider.java62
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/AbstractTestSetup.java50
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASContextSetup.java56
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASContextSetupTest.java34
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASSchemaContextsSetup.java191
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASSchemaContextsSetupTest.java48
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaAndDASContextsSetup.java131
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaAndDASContextsSetupTest.java56
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaContextsSetup.java132
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaContextsSetupTest.java45
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextSetup.java21
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextSetupTest.java25
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextsSetup.java231
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextsSetupTest.java71
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/XSDSchemaContextsSetup.java76
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/XSDSchemaContextsSetupTest.java35
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/testing/constants/DASTestingConstants.java9
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/ComplexTypeNamespaceQualifier.java39
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/IDGenerator.java10
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/JNDIUtil.java168
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/LDAPNormalizer.java38
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/QualifiedNameNormalizer.java36
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/SimpleTypeNamespaceQualifier.java39
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceToInitialContextTransformer.java49
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceURITokenizer.java26
92 files changed, 9851 insertions, 0 deletions
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplate.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplate.java
new file mode 100644
index 0000000000..7977f60545
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplate.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.apacheds.testing.setup;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
+import org.apache.directory.server.core.configuration.ShutdownConfiguration;
+import org.apache.log4j.PropertyConfigurator;
+
+/**
+ * The Class JNDIEmbeddedConnectionTemplate.
+ */
+public abstract class ADSEmbeddedConnectionTemplate
+extends JNDIConnectionTemplate
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ Hashtable<String,Object> env =
+ new Hashtable<String,Object>();
+
+ env = createEnvironment(env);
+
+ env.put(
+ Context.PROVIDER_URL,
+ SYSTEM_PROVIDER_PATH);
+ env.put(
+ Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.directory.server.core.jndi.CoreContextFactory" );
+ env.putAll(
+ new ShutdownConfiguration().toJndiEnvironment() );
+
+ new InitialContext( env );
+ Runtime.getRuntime().gc();
+ super.tearDown();
+ }
+
+
+
+ public void setUp() throws Exception
+ {
+ PropertyConfigurator.
+ configure(NLOG4J_CONFIGURATION_FILEPATH);
+ super.setUp();
+ }
+
+ /**
+ * Connect to an embedded ApacheDS server.
+ *
+ * @param providerPath the provider path ("ou=schema", ou="system", etc.)
+ *
+ * @return the ldap context
+ *
+ * @throws NamingException the naming exception
+ */
+ public LdapContext connect( String providerPath ) throws NamingException
+ {
+ MutableStartupConfiguration mutableStartupConfiguration =
+ new MutableStartupConfiguration();
+
+ Hashtable<String,Object> adminEnv =
+ new Hashtable<String,Object>( );
+
+ adminEnv.putAll(
+ mutableStartupConfiguration.
+ toJndiEnvironment());
+
+ adminEnv.put(
+ Context.PROVIDER_URL,
+ SYSTEM_PROVIDER_PATH);
+ adminEnv.put(
+ Context.SECURITY_PRINCIPAL,
+ DEFAULT_SECURITY_PRINCIPAL_VALUE);
+ adminEnv.put(
+ Context.SECURITY_CREDENTIALS,
+ DEFAULT_SECURITY_CREDENTIALS_VALUE);
+ adminEnv.put(
+ Context.SECURITY_AUTHENTICATION,
+ SIMPLE_SECURITY_AUTHENTICATION_VALUE );
+ new InitialLdapContext( adminEnv, null );
+
+
+
+ Hashtable<String,Object> env =
+ new Hashtable<String,Object>();
+
+ env.put(
+ Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.directory.server.core.jndi.CoreContextFactory" );
+ env.put(
+ Context.SECURITY_PRINCIPAL,
+ DEFAULT_SECURITY_PRINCIPAL_VALUE);
+ env.put(
+ Context.SECURITY_CREDENTIALS,
+ DEFAULT_SECURITY_CREDENTIALS_VALUE);
+ env.put(
+ Context.SECURITY_AUTHENTICATION,
+ SIMPLE_SECURITY_AUTHENTICATION_VALUE );
+ env.put( Context.PROVIDER_URL, providerPath );
+
+ env.put( Context.PROVIDER_URL, providerPath );
+
+ return new InitialLdapContext( env, null );
+
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplateTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplateTest.java
new file mode 100644
index 0000000000..f5426b3424
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplateTest.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.apacheds.testing.setup;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+public class ADSEmbeddedConnectionTemplateTest
+extends ADSEmbeddedConnectionTemplate
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ public void testSchemaConnect() throws NamingException
+ {
+ LdapContext ldapContext =null;
+
+ ldapContext =connect("ou=schema");
+
+ assertEquals(
+ "ou=schema",
+ ldapContext.getNameInNamespace());
+ }
+
+ public void testRootDSEConnect() throws NamingException
+ {
+ LdapContext ldapContext =null;
+
+ ldapContext =connect("");
+
+ assertEquals(
+ "",
+ ldapContext.getNameInNamespace());
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplate.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplate.java
new file mode 100644
index 0000000000..fae915a0a2
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplate.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.apacheds.testing.setup;
+
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.server.core.configuration.Configuration;
+import org.apache.directory.server.core.configuration.MutablePartitionConfiguration;
+import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
+import org.apache.directory.server.core.configuration.ShutdownConfiguration;
+import org.apache.log4j.PropertyConfigurator;
+
+/**
+ * The Class JNDIEmbeddedConnectionTemplate.
+ */
+public abstract class ADSEmbeddedHotPartitionTemplate
+extends JNDIConnectionTemplate
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ Hashtable<String,Object> env =
+ new Hashtable<String,Object>();
+
+ env = createEnvironment(env);
+
+ env.put(
+ Context.PROVIDER_URL,
+ SYSTEM_PROVIDER_PATH);
+ env.put(
+ Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.directory.server.core.jndi.CoreContextFactory" );
+ env.putAll(
+ new ShutdownConfiguration().toJndiEnvironment() );
+
+ new InitialContext( env );
+ Runtime.getRuntime().gc();
+ super.tearDown();
+ }
+
+
+
+ public void setUp() throws Exception
+ {
+ PropertyConfigurator.
+ configure(NLOG4J_CONFIGURATION_FILEPATH);
+ super.setUp();
+ }
+
+ /**
+ * Connect to an embedded ApacheDS server.
+ *
+ * @param partitionName the provider path ("ou=schema", ou="system", etc.)
+ *
+ * @return the ldap context
+ *
+ * @throws NamingException the naming exception
+ */
+ public LdapContext connect( String partitionName ) throws NamingException
+ {
+ MutableStartupConfiguration mutableStartupConfiguration =
+ new MutableStartupConfiguration();
+
+ Hashtable<String,Object> adminEnv =
+ new Hashtable<String,Object>( );
+
+ adminEnv.putAll(
+ mutableStartupConfiguration.
+ toJndiEnvironment());
+
+ adminEnv.put(
+ Context.PROVIDER_URL,
+ SYSTEM_PROVIDER_PATH);
+ adminEnv.put(
+ Context.SECURITY_PRINCIPAL,
+ DEFAULT_SECURITY_PRINCIPAL_VALUE);
+ adminEnv.put(
+ Context.SECURITY_CREDENTIALS,
+ DEFAULT_SECURITY_CREDENTIALS_VALUE);
+ adminEnv.put(
+ Context.SECURITY_AUTHENTICATION,
+ SIMPLE_SECURITY_AUTHENTICATION_VALUE );
+ new InitialLdapContext( adminEnv, null );
+
+
+ MutablePartitionConfiguration dasPartition =
+ new MutablePartitionConfiguration();
+
+ Attributes suffixAttributes = new BasicAttributes();
+ suffixAttributes.put( "objectClass", "top");
+ suffixAttributes.get( "objectClass" ).add( "organizationalUnit" );
+ suffixAttributes.put( "ou", partitionName );
+
+ dasPartition.setId( partitionName);
+ dasPartition.setSuffix( "ou=" +partitionName );
+ dasPartition.setContextEntry( suffixAttributes );
+
+ Set<MutablePartitionConfiguration> partitions =
+ new HashSet<MutablePartitionConfiguration> ();
+
+ partitions.add( dasPartition );
+
+ mutableStartupConfiguration.
+ setPartitionConfigurations( partitions );
+
+ Hashtable<String,Object> env =
+ new Hashtable<String,Object>();
+
+ env.put(
+ Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.directory.server.core.jndi.CoreContextFactory" );
+ env.put(
+ Context.SECURITY_PRINCIPAL,
+ DEFAULT_SECURITY_PRINCIPAL_VALUE);
+ env.put(
+ Context.SECURITY_CREDENTIALS,
+ DEFAULT_SECURITY_CREDENTIALS_VALUE);
+ env.put(
+ Context.SECURITY_AUTHENTICATION,
+ SIMPLE_SECURITY_AUTHENTICATION_VALUE );
+ env.put(
+ Context.PROVIDER_URL,
+ "ou=" + partitionName );
+
+ env.put(
+ Configuration.JNDI_KEY,
+ mutableStartupConfiguration );
+
+ return new InitialLdapContext( env, null );
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplateTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplateTest.java
new file mode 100644
index 0000000000..aba1ff7940
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplateTest.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.apacheds.testing.setup;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+public class ADSEmbeddedHotPartitionTemplateTest
+extends ADSEmbeddedHotPartitionTemplate
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ public void testCreateHotPartition() throws NamingException
+ {
+ LdapContext ldapContext =
+ null;
+
+ ldapContext =
+ connect("test");
+
+ assertEquals(
+ "ou=test",
+ ldapContext.getNameInNamespace());
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplate.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplate.java
new file mode 100644
index 0000000000..ae267144eb
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplate.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.apacheds.testing.setup;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.constants.ApacheDSConnectionConstants;
+
+import junit.framework.TestCase;
+
+/*
+ * Just a class template class
+ */
+public abstract class JNDIConnectionTemplate
+extends TestCase
+implements ApacheDSConnectionConstants
+{
+ protected String providerHost =
+ "ldap://localhost:10389/";
+
+ protected String providerPath =
+ SYSTEM_PROVIDER_PATH;
+
+ private String providerURL =
+ providerHost + providerPath;
+
+ protected String initialContextFactory =
+ SUN_CONTEXT_FACTORY;
+
+ protected String securityAuthentication =
+ SIMPLE_SECURITY_AUTHENTICATION_VALUE;
+
+ protected String securityPrincipal =
+ DEFAULT_SECURITY_PRINCIPAL_VALUE;
+
+ protected String credentials =
+ DEFAULT_SECURITY_CREDENTIALS_VALUE;
+
+ public Hashtable<String,Object> createEnvironment(
+ Hashtable<String, Object> env)
+ {
+ providerURL =
+ providerHost + providerPath;
+
+ env.put(
+ Context.PROVIDER_URL,
+ providerURL);
+
+ env.put(
+ Context.INITIAL_CONTEXT_FACTORY,
+ initialContextFactory );
+
+ env.put(
+ Context.SECURITY_AUTHENTICATION,
+ securityAuthentication);
+
+ env.put(
+ Context.SECURITY_PRINCIPAL,
+ securityPrincipal );
+
+ env.put(
+ Context.SECURITY_CREDENTIALS,
+ credentials );
+
+ return env;
+ }
+
+ public LdapContext connect() throws NamingException
+ {
+ Hashtable<String, Object> env =
+ new Hashtable<String, Object>();
+
+ return new InitialLdapContext(
+ createEnvironment(env), null);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplateTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplateTest.java
new file mode 100644
index 0000000000..883a556167
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplateTest.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.apacheds.testing.setup;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+/*
+ * These tests require a running server.
+ */
+public class JNDIConnectionTemplateTest extends JNDIConnectionTemplate
+{
+ private static LdapContext systemContext = null;
+ private static LdapContext schemaContext = null;
+
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ }
+
+ public void testSystemContextConnection()
+ throws NamingException
+ {
+ systemContext = connect();
+ assertNotNull( systemContext );
+ assertNotNull( connect() );
+ assertEquals(
+ systemContext.
+ getNameInNamespace(),
+ "ou=system");
+ }
+
+ public void testSchemaContextConnection()
+ throws NamingException
+ {
+ providerPath = SCHEMA_PROVIDER_PATH;
+ schemaContext = connect();
+ assertNotNull (schemaContext);
+ assertNotNull(connect());
+ assertEquals(
+ schemaContext.getNameInNamespace(),
+ "ou=schema");
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplate.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplate.java
new file mode 100644
index 0000000000..546ccea0d5
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplate.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.apacheds.testing.setup;
+
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.server.core.configuration.Configuration;
+import org.apache.directory.server.core.configuration.MutablePartitionConfiguration;
+import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
+import org.apache.tuscany.das.ldap.constants.ApacheDSConnectionConstants;
+import org.apache.tuscany.das.ldap.schema.embedded.setup.test.AbstractTestSetup;
+
+import junit.framework.TestCase;
+
+/*
+ * Just a class template class
+ */
+public abstract class JNDIHotPartitionConnectionTemplate
+extends AbstractTestSetup
+implements ApacheDSConnectionConstants
+{
+
+ public Hashtable<String,Object> createEnvironment(
+ Hashtable<String, Object> env,
+ String partitionName) throws NamingException
+ {
+ MutableStartupConfiguration mutableStartupConfiguration =
+ new MutableStartupConfiguration();
+
+ MutablePartitionConfiguration dasPartition =
+ new MutablePartitionConfiguration();
+
+ Attributes suffixAttributes = new BasicAttributes();
+ suffixAttributes.put( "objectClass", "top");
+ suffixAttributes.get( "objectClass" ).add( "organizationalUnit" );
+ suffixAttributes.put( "ou", partitionName );
+
+ dasPartition.setId( partitionName);
+ dasPartition.setSuffix( "ou=" +partitionName );
+ dasPartition.setContextEntry( suffixAttributes );
+
+ Set<MutablePartitionConfiguration> partitions =
+ new HashSet<MutablePartitionConfiguration> ();
+
+ partitions.add( dasPartition );
+
+ mutableStartupConfiguration.
+ setPartitionConfigurations( partitions );
+
+ env.put(
+ Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.directory.server.core.jndi.CoreContextFactory" );
+
+ env.put(
+ Context.SECURITY_PRINCIPAL,
+ DEFAULT_SECURITY_PRINCIPAL_VALUE);
+
+ env.put(
+ Context.SECURITY_CREDENTIALS,
+ DEFAULT_SECURITY_CREDENTIALS_VALUE);
+
+ env.put(
+ Context.SECURITY_AUTHENTICATION,
+ SIMPLE_SECURITY_AUTHENTICATION_VALUE );
+
+ env.put(
+ Context.PROVIDER_URL,
+ "ou=" + partitionName );
+
+ env.put(
+ Configuration.JNDI_KEY,
+ mutableStartupConfiguration );
+
+ return env;
+ }
+
+ public LdapContext connect( String partitionName )
+ throws NamingException
+ {
+ Hashtable<String, Object> env =
+ new Hashtable<String, Object>();
+
+ return new InitialLdapContext(
+ createEnvironment(env, partitionName), null);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplateTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplateTest.java
new file mode 100644
index 0000000000..85b9f5eb10
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplateTest.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.apacheds.testing.setup;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+/*
+ * These tests require a running server.
+ */
+public class JNDIHotPartitionConnectionTemplateTest
+extends JNDIHotPartitionConnectionTemplate
+{
+ private static LdapContext testContext = null;
+ private static LdapContext systemContext = null;
+ private static LdapContext schemaContext = null;
+
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ }
+
+ public void testTestContextConnection()
+ throws NamingException
+ {
+ testContext = connect("test");
+ assertNotNull(testContext );
+ assertEquals(
+ testContext.getNameInNamespace(), "ou=test");
+ }
+
+
+ public void testSystemContextConnection()
+ throws NamingException
+ {
+ systemContext = connect("system");
+ assertNotNull( systemContext );
+ assertEquals(
+ systemContext.getNameInNamespace(), "ou=system");
+ }
+
+ public void testSchemaContextConnection()
+ throws NamingException
+ {
+ schemaContext = connect("schema");
+ assertNotNull( schemaContext );
+ assertEquals(
+ schemaContext.getNameInNamespace(),
+ "ou=schema");
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/connect/ADSEmbeddedConnection.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/connect/ADSEmbeddedConnection.java
new file mode 100644
index 0000000000..b547f1447b
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/connect/ADSEmbeddedConnection.java
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.connect;
+
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.server.core.configuration.MutablePartitionConfiguration;
+import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
+import org.apache.directory.server.core.configuration.ShutdownConfiguration;
+import org.apache.log4j.PropertyConfigurator;
+import org.apache.tuscany.model.Configuration;
+
+/**
+ * The Class JNDIEmbeddedConnectionTemplate.
+ */
+public class ADSEmbeddedConnection extends JNDIConnection {
+ private Configuration configuration = null;
+
+ public ADSEmbeddedConnection(Configuration configuration) {
+ super(configuration);
+ this.configuration = configuration;
+ }
+
+ /**
+ * Shutdown.
+ *
+ * Shuts down an embedded instance of ADS.
+ *
+ * @throws NamingException
+ * the naming exception
+ * @throws Exception
+ * the exception
+ */
+ public void shutdown() throws NamingException, Exception {
+ Hashtable<String, Object> env = new Hashtable<String, Object>();
+
+ env = createEnvironment(env);
+
+ env.put(
+ Context.PROVIDER_URL,
+ SYSTEM_PROVIDER_PATH);
+ env.put(
+ Context.INITIAL_CONTEXT_FACTORY,
+ APACHE_CONTEXT_FACTORY);
+ env.putAll(
+ new ShutdownConfiguration().toJndiEnvironment());
+
+ new InitialContext(env);
+ Runtime.getRuntime().gc();
+ }
+
+ /**
+ * Startup.
+ *
+ * Starts an embedded instance of ADS and creates the the DAS partition, if
+ * it does not already exist.
+ *
+ * @throws NamingException
+ * the naming exception
+ */
+ public LdapContext startup(String partitionName)
+ throws NamingException {
+ PropertyConfigurator.
+ configure(
+ configuration.
+ getNlog4jConfigurationFilePath());
+
+ MutableStartupConfiguration mutableStartupConfiguration =
+ new MutableStartupConfiguration();
+
+ Hashtable<String, Object> adminEnv =
+ new Hashtable<String, Object>();
+
+ adminEnv.putAll(mutableStartupConfiguration.toJndiEnvironment());
+
+ adminEnv.put(
+ Context.PROVIDER_URL,
+ SYSTEM_PROVIDER_PATH);
+ adminEnv.put(
+ Context.SECURITY_PRINCIPAL,
+ configuration.getSecurityPrincipal());
+ adminEnv.put(
+ Context.SECURITY_CREDENTIALS,
+ configuration.getSecurityCredentials());
+ adminEnv.put(
+ Context.SECURITY_AUTHENTICATION,
+ configuration.getSecurityAuthenticationType());
+ new InitialLdapContext(adminEnv, null);
+
+ MutablePartitionConfiguration dasPartition =
+ new MutablePartitionConfiguration();
+
+ Attributes suffixAttributes =
+ new BasicAttributes();
+ suffixAttributes.put(OBJECT_CLASS, TOP);
+ suffixAttributes.get(OBJECT_CLASS).add(ORGANIZATIONAL_UNIT);
+ suffixAttributes.put(OU, partitionName);
+
+ dasPartition.setId(partitionName);
+ dasPartition.setSuffix(getProviderPath(partitionName));
+ dasPartition.setContextEntry(suffixAttributes);
+
+ Set<MutablePartitionConfiguration> partitions =
+ new HashSet<MutablePartitionConfiguration>();
+
+ partitions.add(dasPartition);
+
+ mutableStartupConfiguration.setPartitionConfigurations(partitions);
+
+ Hashtable<String, Object> env =
+ new Hashtable<String, Object>();
+
+ env.put(
+ Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.directory.server.core.jndi.CoreContextFactory");
+ env.put(
+ Context.SECURITY_PRINCIPAL,
+ DEFAULT_SECURITY_PRINCIPAL_VALUE);
+ env.put(
+ Context.SECURITY_CREDENTIALS,
+ DEFAULT_SECURITY_CREDENTIALS_VALUE);
+ env.put(
+ Context.SECURITY_AUTHENTICATION,
+ SIMPLE_SECURITY_AUTHENTICATION_VALUE);
+ env.put(
+ Context.PROVIDER_URL, getProviderPath(partitionName));
+
+ env.put(
+ org.apache.directory.server.core.configuration.Configuration.JNDI_KEY,
+ mutableStartupConfiguration);
+
+ return new InitialLdapContext(env, null);
+ }
+
+ public LdapContext connect(String partitionName) throws NamingException
+ {
+ return startup(partitionName);
+ }
+
+ /**
+ * Gets the provider path. TODO Move to helper
+ *
+ * @return the provider path
+ */
+ public String getProviderPath(String partitionName) {
+ return OU + "=" + partitionName;
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/connect/JNDIConnection.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/connect/JNDIConnection.java
new file mode 100644
index 0000000000..d36dacc952
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/connect/JNDIConnection.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.connect;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+import org.apache.tuscany.model.Configuration;
+
+import org.apache.tuscany.das.ldap.constants.ApacheDSConnectionConstants;
+import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants;
+import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants;
+/*
+ * Just a class template class
+ */
+public class JNDIConnection
+implements
+ApacheDSConnectionConstants,
+AttributeTypeConstants,
+ObjectClassConstants
+{
+ private Configuration configuration = null;
+
+ public JNDIConnection(Configuration configuration)
+ {
+ this.configuration=configuration;
+ }
+
+ public Hashtable<String,Object> createEnvironment(
+ Hashtable<String, Object> env)
+ {
+ env.put(
+ Context.INITIAL_CONTEXT_FACTORY,
+ configuration.getInitialContextFactory() );
+
+ env.put(
+ Context.SECURITY_AUTHENTICATION,
+ configuration.getSecurityAuthenticationType());
+
+ env.put(
+ Context.SECURITY_PRINCIPAL,
+ configuration.getSecurityPrincipal() );
+
+ env.put(
+ Context.SECURITY_CREDENTIALS,
+ configuration.getSecurityCredentials() );
+
+ return env;
+ }
+
+ public LdapContext connect(String partitionName) throws NamingException
+ {
+ Hashtable<String, Object> env =
+ new Hashtable<String, Object>();
+
+ env = createEnvironment(env);
+
+ env.put(
+ Context.PROVIDER_URL,
+ getProviderURL(partitionName));
+
+ return new InitialLdapContext(env, null);
+ }
+
+ public String getProviderURL(String partitionName)
+ {
+ return "ldap://" +
+ configuration.getHost() +
+ ":" +
+ configuration.getPort() +
+ "/" +
+ OU +
+ "=" +
+ partitionName;
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/InitialContextCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/InitialContextCreator.java
new file mode 100644
index 0000000000..8e50e72178
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/InitialContextCreator.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.create;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.util.XSDNamespaceURITokenizer;
+import org.eclipse.emf.common.util.URI;
+
+/**
+ * The InitialContextCreator for a model's directory namespace
+ */
+public class InitialContextCreator
+{
+ /**
+ * Creates the parent context for the root DataObject instance
+ *
+ * @param dasContext the dir context
+ * @param xsdNamespace the xml namespace of the DataObjects
+ *
+ * @return the directory context
+ *
+ * @throws NamingException the naming exception
+ */
+ public static LdapContext create(
+ String xsdNamespace,
+ LdapContext dasContext) throws NamingException
+ {
+ URI xsdNamespaceURI =
+ URI.createURI(
+ xsdNamespace );
+
+ String[] pathTokens =
+ XSDNamespaceURITokenizer.
+ createPathTokens(
+ xsdNamespaceURI );
+
+ String[] authorityTokens =
+ XSDNamespaceURITokenizer.
+ createAuthorityTokens(
+ xsdNamespaceURI );
+
+ dasContext =
+ InitialContextCreatorHelper.
+ createAuthorityContext(
+ dasContext,
+ authorityTokens );
+
+ dasContext =
+ InitialContextCreatorHelper.
+ createPathContext(
+ dasContext,
+ pathTokens );
+
+ return dasContext;
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/InitialContextCreatorHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/InitialContextCreatorHelper.java
new file mode 100644
index 0000000000..0be0975082
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/InitialContextCreatorHelper.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.create;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants;
+import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants;
+import org.apache.tuscany.das.ldap.schema.constants.SchemaObjectClassConstants;
+
+/**
+ * The Class InitialContextCreatorHelper.
+ */
+public class InitialContextCreatorHelper
+implements
+ObjectClassConstants,
+SchemaObjectClassConstants,
+AttributeTypeConstants
+{
+
+ /**
+ * Creates the sub context if it does not already exist.
+ *
+ * @param ldapContext the ldap context
+ * @param subContextRDN the sub context
+ * @param attributes the attributes
+ *
+ * @return the ldap context
+ *
+ * @throws NamingException the naming exception
+ */
+ public static LdapContext createSubContext(
+ LdapContext ldapContext,
+ String subContextRDN,
+ Attributes attributes)
+ throws NamingException
+ {
+ try
+ {
+ ldapContext =
+ ( LdapContext )
+ ldapContext.
+ lookup( subContextRDN );
+ }
+ catch ( NamingException e )
+ {
+ if (attributes == null)
+ {
+ ldapContext =
+ ( LdapContext )
+ ldapContext.
+ createSubcontext( subContextRDN );
+ }
+ else
+ {
+ ldapContext =
+ ( LdapContext )
+ ldapContext.
+ createSubcontext(
+ subContextRDN,
+ attributes );
+ }
+ }
+ return ldapContext;
+ }
+
+ /**
+ * Creates the authority context. Authority
+ * means the Authority component of a URL.
+ * For example if the authority is "example.com",
+ * then the authority context will be "cn=example, cn=com".
+ *
+ * @param ldapContext the ldap context
+ * @param authorityTokens the authority tokens
+ *
+ * @return the ldap context
+ *
+ * @throws NamingException the naming exception
+ *
+ */
+ public static LdapContext createAuthorityContext(
+ LdapContext ldapContext,
+ String[] authorityTokens)
+ throws NamingException
+ {
+ for (int i = authorityTokens.length-1; i >= (0); i--)
+ {
+ String subContext = CN+ "=" + authorityTokens[i];
+ ldapContext = (LdapContext) createSubContext(
+ ldapContext,
+ subContext, null );
+ }
+ return ldapContext;
+ }
+
+ /**
+ * Creates the path context.
+ * Path means the path component of a URL.
+ * For example if the authority is "example.com/users/accounts",
+ * then the path context will be "cn=accounts, cn=users". The full
+ * model namespaced context will be "cn=accounts, cn=users, cn=example, cn=com"
+ *
+ * @param authorityContext the ldap context
+ * @param pathTokens the path tokens
+ *
+ * @return the ldap context
+ *
+ * @throws NamingException the naming exception
+ */
+ public static LdapContext createPathContext(
+ LdapContext authorityContext,
+ String[] pathTokens)
+ throws NamingException
+ {
+ for (int i = 1; i < (pathTokens.length); i++)
+ {
+ String subContext = CN + "=" + pathTokens[i];
+ authorityContext = (LdapContext) createSubContext(
+ authorityContext,
+ subContext, null );
+ }
+ return authorityContext;
+ }
+}
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/MetaContextCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/MetaContextCreator.java
new file mode 100644
index 0000000000..4caa380258
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/MetaContextCreator.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.create;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants;
+
+/**
+ * The Class MetaContextCreator.
+ */
+public class MetaContextCreator
+implements
+DASConstants,
+AttributeTypeConstants
+{
+ /**
+ * Create a meta context below the provided parent context.
+ *
+ * @param metaParentContext the context
+ *
+ * @return the ldap context
+ *
+ * @throws NamingException the naming exception
+ */
+ public static LdapContext create(
+ LdapContext metaParentContext) throws NamingException
+ {
+ String rdn =
+ CN + "=" + META_CONTEXT_NAME;
+
+ try
+ {
+ return
+ ( LdapContext )
+ metaParentContext.lookup( rdn );
+ }
+ catch(Exception e)
+ {
+ return
+ ( LdapContext )
+ metaParentContext.
+ createSubcontext( rdn );
+ }
+ }
+}
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/destroy/InitialContextDestroyer.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/destroy/InitialContextDestroyer.java
new file mode 100644
index 0000000000..2cc3fc7d36
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/destroy/InitialContextDestroyer.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.destroy;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+import org.apache.tuscany.das.ldap.util.JNDIUtil;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class InitialContextDestroyer.
+ */
+public class InitialContextDestroyer
+{
+
+ /**
+ * Destroys the initial naming context
+ * when the parent entries do not contain
+ * other child entries. If the initial
+ * naming context also supports other
+ * entries, then a NamingException will
+ * be thrown.
+ *
+ * @param partitionContext the partition context
+ * @param initialContext the initial context
+ *
+ * @throws NamingException the naming exception
+ */
+ public static void destroy(
+ DirContext initialContext,
+ DirContext partitionContext)
+ throws NamingException
+ {
+ String[] initialContextComponents =
+ JNDIUtil.
+ calculateDNComponents( initialContext );
+
+ String[] partitionContextComponents =
+ JNDIUtil.calculateDNComponents( partitionContext );
+
+ int numberOfPossibleSubcontexts =
+ initialContextComponents.length
+ - partitionContextComponents.length;
+
+ for (int i = 0; i < numberOfPossibleSubcontexts; i++)
+ {
+ String rdn = initialContextComponents[i];
+
+ initialContext = JNDIUtil.getParentContext(
+ initialContext,
+ partitionContext );
+
+ initialContext.destroySubcontext( rdn );
+ }
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/destroy/MetaContextDestroyer.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/destroy/MetaContextDestroyer.java
new file mode 100644
index 0000000000..7849b33edb
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/destroy/MetaContextDestroyer.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.destroy;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants;
+
+/**
+ * The Class MetaContextDestroyer.
+ */
+public class MetaContextDestroyer
+implements
+DASConstants,
+AttributeTypeConstants
+{
+ /**
+ * Destroys an empty meta context
+ *
+ * @param initialContext the initial context
+ *
+ * @throws NamingException the naming exception thrown when the meta context has child entries
+ */
+ public static void destroy(
+ DirContext initialContext)
+ throws NamingException
+ {
+ String rdn =
+ CN + "=" + META_CONTEXT_NAME;
+
+ initialContext.
+ destroySubcontext( rdn );
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/Context.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/Context.java
new file mode 100644
index 0000000000..31d6d8d11e
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/Context.java
@@ -0,0 +1,81 @@
+
+package org.apache.tuscany.das.ldap.emf;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.naming.ldap.LdapContext;
+
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+public class Context
+{
+ private Map<String, LdapContext> xsdNamespaceToLdapContextMap = null;
+ private Map<EDataObject, String> dataObjectToRelativeDNCache = null;
+
+
+ private LdapContext dasContext = null;
+ private LdapContext schemaContext = null;
+ private LdapContext dasMetaContext = null;
+ private LdapContext ecoreObjectClassesContext = null;
+ private LdapContext ecoreAttributeTypesContext = null;
+
+ public Context()
+ {
+ xsdNamespaceToLdapContextMap =
+ new Hashtable<String, LdapContext>();
+
+ dataObjectToRelativeDNCache =
+ new Hashtable<EDataObject, String>();
+ }
+
+ public LdapContext getDasContext()
+ {
+ return dasContext;
+ }
+ public void setDasContext( LdapContext dasContext )
+ {
+ this.dasContext = dasContext;
+ }
+ public LdapContext getSchemaContext()
+ {
+ return schemaContext;
+ }
+ public void setSchemaContext( LdapContext schemaContext )
+ {
+ this.schemaContext = schemaContext;
+ }
+ public LdapContext getDasMetaContext()
+ {
+ return dasMetaContext;
+ }
+ public void setDasMetaContext( LdapContext dasMetaContext )
+ {
+ this.dasMetaContext = dasMetaContext;
+ }
+ public LdapContext getEcoreObjectClassesContext()
+ {
+ return ecoreObjectClassesContext;
+ }
+ public void setEcoreObjectClassesContext( LdapContext ecoreObjectClassesContext )
+ {
+ this.ecoreObjectClassesContext = ecoreObjectClassesContext;
+ }
+ public LdapContext getEcoreAttributeTypesContext()
+ {
+ return ecoreAttributeTypesContext;
+ }
+ public void setEcoreAttributeTypesContext( LdapContext ecoreAttributeTypesContext )
+ {
+ this.ecoreAttributeTypesContext = ecoreAttributeTypesContext;
+ }
+ public Map<String, LdapContext> getXsdNamespaceToLdapContextMap()
+ {
+ return xsdNamespaceToLdapContextMap;
+ }
+
+ public Map<EDataObject, String> getDataObjectToRelativeDNCache()
+ {
+ return dataObjectToRelativeDNCache;
+ }
+}
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/LdapDAS.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/LdapDAS.java
new file mode 100644
index 0000000000..43e556714f
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/LdapDAS.java
@@ -0,0 +1,379 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.emf;
+
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
+import org.apache.tuscany.das.ldap.connect.ADSEmbeddedConnection;
+import org.apache.tuscany.das.ldap.connect.JNDIConnection;
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.create.InitialContextCreator;
+import org.apache.tuscany.das.ldap.create.MetaContextCreator;
+import org.apache.tuscany.das.ldap.emf.create.EDataGraphCreator;
+import org.apache.tuscany.das.ldap.emf.read.EDataGraphReader;
+import org.apache.tuscany.das.ldap.emf.update.EDataGraphUpdater;
+import org.apache.tuscany.das.ldap.schema.emf.create.EcoreTypeSystemHelper;
+import org.apache.tuscany.das.ldap.schema.emf.create.ModelTypeSystemCreator;
+import org.apache.tuscany.model.Configuration;
+import org.apache.tuscany.model.DASMeta;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.sdo.EDataGraph;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+public class LdapDAS
+implements DASConstants
+{
+ private Map<EDataObject, String> metaDataObjectToRelativeDNCache = null;
+
+ private Configuration configuration = null;
+ private DASMeta dasMeta = null;
+ private EDataGraph dasMetaDataGraph = null;
+ private Context context = null;
+ private ADSEmbeddedConnection adsEmbeddedConnection = null;
+
+
+ public LdapDAS(Configuration configuration)
+ throws NamingException
+ {
+ metaDataObjectToRelativeDNCache =
+ new Hashtable<EDataObject, String>();
+
+
+ this.configuration =
+ configuration;
+
+ context =
+ new Context();
+
+ JNDIConnection jndiConnection = null;
+
+ if (configuration.isEmbedded())
+ {
+ adsEmbeddedConnection =
+ new ADSEmbeddedConnection(configuration);
+ context.
+ setDasContext(
+ adsEmbeddedConnection.
+ connect(
+ configuration.
+ getDasPartitionName() ));
+
+ context.
+ setSchemaContext(
+ adsEmbeddedConnection.
+ connect(
+ configuration.
+ getSchemaPartitionName() ));
+ }
+ else
+ {
+ jndiConnection =
+ new JNDIConnection(configuration);
+
+ context.
+ setDasContext(
+ jndiConnection.connect(
+ configuration.
+ getDasPartitionName() ));
+
+ context.
+ setSchemaContext(
+ jndiConnection.connect(
+ configuration.
+ getSchemaPartitionName() ));
+ }
+
+ context.
+ setDasMetaContext(
+ MetaContextCreator.
+ create(
+ context.
+ getDasContext() ));
+
+ context.setEcoreObjectClassesContext(
+ LdapDASHelper.
+ createEcoreObjectClassesContext(
+ context.
+ getSchemaContext() ));
+
+ context.setEcoreAttributeTypesContext(
+ LdapDASHelper.
+ createEcoreAttributeTypesContext(
+ context.
+ getSchemaContext() ));
+ }
+
+ /**
+ * Write.
+ *
+ * @param eDataGraph the e data graph
+ * @param dasContext the das context
+ *
+ * @return the map< E data object, string>
+ *
+ * @throws NamingException the naming exception
+ *
+ * First tries to find a LdapContext that matches the xsdNamespace
+ * of the DataGraph that is about to be written. If it finds one, then
+ * it know that the type system has been written, thus it can skip this
+ * step.
+ *
+ * If the LdapContext lookup fails, the type system may still exist
+ * the check:
+ *
+ * configuration.getSupportedSchemas().contains(xsdNamespace)
+ *
+ * is performed.
+ *
+ * If the supported schema list contains the xsdNamespace, the
+ * corresponding the LdapContext parent context of the root DataObject
+ * instance is created and the DataGraph written.
+ *
+ * If the xsdNamespace is not contained by the supported schemas list,
+ * a final check is performed to see whether the type system exists. If this
+ * check succeeds and exception is thrown, because it should not. This could happen
+ * if the configuration write that occurs as the supported schema list is updated failed,
+ * or the the read of the supported schemas from the DIT failed.
+ *
+ */
+ public void create(
+ EDataGraph eDataGraph)
+ throws NamingException, Exception
+ {
+
+ EObject rootEObject =
+ eDataGraph.
+ getERootObject();
+
+ EPackage ePackage =
+ rootEObject.
+ eClass().
+ getEPackage();
+
+ String xsdNamespace =
+ ePackage.
+ getNsURI();
+
+ LdapContext rootContext =
+ context.
+ getXsdNamespaceToLdapContextMap().
+ get(xsdNamespace);
+
+ if (rootContext != null)
+ {
+ EDataGraphCreator.create(
+ eDataGraph,
+ rootContext,
+ context.
+ getDataObjectToRelativeDNCache());
+ }
+
+ /*
+ * The root context was not yet created so we check if the
+ * schema is written for the model instance, and if it is
+ * we create the root context and add it to the context map.
+ */
+ metaDataObjectToRelativeDNCache =
+ new Hashtable<EDataObject, String>();
+
+ dasMetaDataGraph =
+ LdapDASHelper.readDasMeta(
+ context,
+ metaDataObjectToRelativeDNCache );
+
+ dasMeta = ( DASMeta ) dasMetaDataGraph.getRootObject();
+
+ if (LdapDASHelper.isSchemaReady(xsdNamespace, dasMeta))
+ {
+ rootContext =
+ InitialContextCreator.
+ create(
+ xsdNamespace,
+ context.
+ getDasContext() );
+
+ context.getXsdNamespaceToLdapContextMap().
+ put(xsdNamespace, rootContext);
+
+ EDataGraphCreator.create(
+ eDataGraph,
+ rootContext,
+ context.getDataObjectToRelativeDNCache());
+ }
+
+ /*
+ * The model's schema is not yet written (We also do a validation
+ * check to make sure the server is not in an inconsistent state)
+ * so we need to write the schema and then write the model instance.
+ */
+
+ if (LdapDASHelper.isSchemaWritten(
+ rootEObject.eClass(),
+ context.
+ getEcoreObjectClassesContext() ))
+ {
+ throw new RuntimeException("This should not happen");//TODO better message + constant
+ }
+
+ List<EClass> eClassifiers =
+ EcoreTypeSystemHelper.
+ createEClassifiersList(ePackage);
+
+ rootContext =
+ InitialContextCreator.
+ create(
+ xsdNamespace,
+ context.getDasContext() );
+
+ context.getXsdNamespaceToLdapContextMap().
+ put(xsdNamespace, rootContext);
+
+ LdapContext dasModelMetaContext =
+ MetaContextCreator.
+ create(rootContext);
+
+ ModelTypeSystemCreator.create(
+ dasModelMetaContext,
+ context.getEcoreAttributeTypesContext(),
+ context.getEcoreObjectClassesContext(),
+ eClassifiers,
+ TUSCANY_OID_PREFIX_VALUE);
+
+ dasMetaDataGraph.
+ getChangeSummary().
+ beginLogging();
+
+ dasMeta.
+ getSupportedSchemas().
+ add(xsdNamespace);
+
+ dasMetaDataGraph.
+ getChangeSummary().
+ endLogging();
+
+ EDataGraphUpdater.update(
+ dasMetaDataGraph,
+ context.getDasMetaContext(),
+ metaDataObjectToRelativeDNCache);
+
+ EDataGraphCreator.create(
+ eDataGraph,
+ rootContext,
+ context.
+ getDataObjectToRelativeDNCache());
+
+ }
+
+
+ public EDataGraph read(
+ EClass rootDataObjectEClass,
+ String id)
+ throws LdapNameNotFoundException, NamingException
+ {
+ String xsdNamespace =
+ rootDataObjectEClass.
+ getEPackage().
+ getNsURI();
+
+ LdapContext rootContext =
+ context.
+ getXsdNamespaceToLdapContextMap().
+ get(xsdNamespace);
+
+ if (rootContext == null)
+ {
+ rootContext =
+ InitialContextCreator.
+ create(
+ xsdNamespace,
+ context.
+ getDasContext() );
+
+ context.
+ getXsdNamespaceToLdapContextMap().
+ put(xsdNamespace, rootContext);
+ }
+
+ return EDataGraphReader.read(
+ rootDataObjectEClass,
+ id,
+ rootContext,
+ context.
+ getDataObjectToRelativeDNCache());
+ }
+
+ public void update(EDataGraph eDataGraph)
+ throws NamingException
+ {
+ EDataObject rootDataObject =
+ ( EDataObject ) eDataGraph.getRootObject();
+
+ EClass rootDataObjectEClass =
+ rootDataObject.eClass();
+
+ String xsdNamespace =
+ rootDataObjectEClass.
+ getEPackage().
+ getNsURI();
+
+ LdapContext rootContext =
+ context.
+ getXsdNamespaceToLdapContextMap().
+ get(xsdNamespace);
+
+ if (rootContext == null)
+ {
+ rootContext =
+ InitialContextCreator.
+ create(
+ xsdNamespace,
+ context.
+ getDasContext() );
+
+ context.
+ getXsdNamespaceToLdapContextMap().
+ put(xsdNamespace, rootContext);
+ }
+
+ EDataGraphUpdater.update(
+ eDataGraph,
+ rootContext,
+ context.
+ getDataObjectToRelativeDNCache());
+ }
+
+ public Context getContext()
+ {
+ return context;
+ }
+
+ public ADSEmbeddedConnection getAdsEmbeddedConnection()
+ {
+ return adsEmbeddedConnection;
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/LdapDASHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/LdapDASHelper.java
new file mode 100644
index 0000000000..d9d2f9a0bd
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/LdapDASHelper.java
@@ -0,0 +1,295 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.emf;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.emf.create.EDataGraphCreator;
+import org.apache.tuscany.das.ldap.emf.read.EDataGraphReader;
+import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants;
+import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants;
+import org.apache.tuscany.das.ldap.schema.constants.SchemaObjectClassConstants;
+import org.apache.tuscany.das.ldap.schema.create.ComplexTypeRDNCreator;
+import org.apache.tuscany.das.ldap.schema.emf.create.EcoreTypeSystemHelper;
+import org.apache.tuscany.das.ldap.schema.emf.create.ModelTypeSystemCreator;
+import org.apache.tuscany.model.ConfigurationFactory;
+import org.apache.tuscany.model.DASMeta;
+import org.apache.tuscany.model.impl.ConfigurationPackageImpl;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.sdo.EDataGraph;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+import org.eclipse.emf.ecore.sdo.SDOFactory;
+
+public class LdapDASHelper
+implements
+DASConstants,
+ObjectClassConstants,
+AttributeTypeConstants,
+SchemaObjectClassConstants
+{
+ public static EDataGraph readDasMeta(
+ Context context,
+ Map<EDataObject, String> metaDataObjectToRelativeDNCache)
+ throws Exception
+ {
+ EDataGraph dasMetaDataGraph = null;
+
+ try
+ {
+ dasMetaDataGraph =
+ EDataGraphReader.read(
+ ConfigurationPackageImpl.
+ eINSTANCE.getDASMeta(),
+ DAS_META_ID_DEFAULT,
+ context.
+ getDasMetaContext(),
+ metaDataObjectToRelativeDNCache);
+ }
+ catch(NamingException e)
+ {
+ List<EClass> eClassifiers =
+ EcoreTypeSystemHelper.
+ createEClassifiersList(
+ ConfigurationPackageImpl.
+ eINSTANCE);
+
+ ModelTypeSystemCreator.
+ create(
+ context.getDasMetaContext(),
+ context.getEcoreAttributeTypesContext(),
+ context.getEcoreObjectClassesContext(),
+ eClassifiers,
+ TUSCANY_OID_PREFIX_VALUE );
+
+ DASMeta dasMeta =
+ ConfigurationFactory.
+ INSTANCE.
+ createDASMeta();
+
+ dasMetaDataGraph =
+ SDOFactory.
+ eINSTANCE.
+ createEDataGraph();
+
+ dasMetaDataGraph.
+ setERootObject(
+ ( EObject ) dasMeta );
+
+ EDataGraphCreator.create(
+ dasMetaDataGraph,
+ context.
+ getDasMetaContext(),
+ metaDataObjectToRelativeDNCache);
+ }
+ return dasMetaDataGraph;
+ }
+
+ public static boolean isSchemaReady(
+ String xsdNamespace,
+ DASMeta dasMeta)
+ {
+ return
+ dasMeta.
+ getSupportedSchemas().
+ contains(xsdNamespace);
+ }
+
+ public static boolean isSchemaWritten(
+ EClass eClass,
+ LdapContext ecoreObjectClassesContext)
+ throws Exception
+ {
+ String xsdNamespace =
+ eClass.getEPackage().getNsURI();
+
+ String eObjectClassRDN =
+ ComplexTypeRDNCreator.
+ create(
+ TUSCANY_OID_PREFIX_VALUE,
+ xsdNamespace,
+ eClass.getName());
+ try {
+ ecoreObjectClassesContext.
+ lookup( eObjectClassRDN );
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ return true;
+ }
+
+
+ public static boolean isSchemaSupported(
+ String xsdNamespaceURI,
+ DASMeta dasMeta)
+ {
+ return
+ dasMeta.
+ getSupportedSchemas().
+ contains(xsdNamespaceURI);
+ }
+
+ public static void initializeSchemaContexts(
+ LdapContext schemaContext,
+ LdapContext ecoreObjectClassesContext,
+ LdapContext ecoreAttributeTypesContext)
+ throws NamingException
+ {
+ LdapContext ecoreContext =
+ createEcoreContext(schemaContext);
+
+ ecoreObjectClassesContext =
+ createEcoreObjectClassesContext(ecoreContext);
+
+ ecoreAttributeTypesContext =
+ createEcoreAttributeTypesContext( ecoreContext );
+ }
+
+
+ public static LdapContext createEcoreContext(
+ LdapContext schemaContext)
+ throws NamingException
+ {
+ String ecoreContextRDN =
+ CN + "=" + ECORE_CONTEXT_NAME;
+
+ try
+ {
+ return ( LdapContext ) schemaContext.lookup( ecoreContextRDN );
+ }
+ catch (Exception e)
+ {
+ //Create the context
+ }
+
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(META_SCHEMA);
+
+ contextAttributes.put( objectClassAttribute );
+ contextAttributes.put( CN, ECORE_CONTEXT_NAME );
+
+ return
+ ( LdapContext )
+ schemaContext.
+ createSubcontext(
+ ecoreContextRDN,
+ contextAttributes );
+ }
+
+ public static LdapContext createEcoreObjectClassesContext(
+ LdapContext schemaContext)
+ throws NamingException
+ {
+ LdapContext ecoreContext =
+ createEcoreContext(schemaContext);
+
+ String ecoreObjectClassesContextRDN =
+ OU + "=" + OBJECT_CLASSES_CONTEXT_NAME;
+
+ try
+ {
+ return
+ ( LdapContext )
+ ecoreContext.
+ lookup(
+ ecoreObjectClassesContextRDN );
+ }
+ catch (Exception e)
+ {
+ //Create the context
+ }
+
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ OU,
+ OBJECT_CLASSES_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return
+ ( LdapContext )
+ ecoreContext.
+ createSubcontext(
+ ecoreObjectClassesContextRDN,
+ contextAttributes );
+ }
+
+ public static LdapContext createEcoreAttributeTypesContext(
+ LdapContext schemaContext)
+ throws NamingException
+ {
+ LdapContext ecoreContext =
+ createEcoreContext(schemaContext);
+
+ String ecoreAttributeTypesContextRDN =
+ OU + "=" + ATTRIBUTE_TYPES_CONTEXT_NAME;
+
+ try
+ {
+ return
+ ( LdapContext )
+ ecoreContext.
+ lookup(
+ ecoreAttributeTypesContextRDN );
+ }
+ catch (Exception e)
+ {
+ //Create the context
+ }
+
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ contextAttributes.put( OU, ATTRIBUTE_TYPES_CONTEXT_NAME );
+ contextAttributes.put( objectClassAttribute );
+
+ return
+ ( LdapContext )
+ ecoreContext.createSubcontext(
+ ecoreAttributeTypesContextRDN,
+ contextAttributes );
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataGraphCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataGraphCreator.java
new file mode 100644
index 0000000000..bfba12d3b5
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataGraphCreator.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.emf.create;
+
+import java.util.Map;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.sdo.EDataGraph;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+public class EDataGraphCreator
+implements AttributeTypeConstants
+{
+ public static void create(
+ EDataGraph eDataGraph,
+ LdapContext rootContext,
+ Map<EDataObject, String> dataObjectToRelativeDNCache)
+ throws NamingException
+ {
+ EDataObject rootDataObject =
+ (EDataObject)
+ eDataGraph.getRootObject();
+
+ EDataObjectCreator.create(
+ rootDataObject,
+ rootContext,
+ dataObjectToRelativeDNCache);
+
+ EList<EObject> children =
+ rootDataObject.eContents();
+
+ if (children.size() > 0)
+ {
+ EDataGraphCreatorHelper.createChildren(
+ children,
+ rootContext,
+ dataObjectToRelativeDNCache);
+ }
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataGraphCreatorHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataGraphCreatorHelper.java
new file mode 100644
index 0000000000..ab1209224a
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataGraphCreatorHelper.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.emf.create;
+
+import java.util.Map;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+public class EDataGraphCreatorHelper
+implements AttributeTypeConstants
+{
+ /*
+ * TODO Make mutlithreaded
+ */
+ public static void createChildren(
+ EList<EObject> children,
+ LdapContext rootContext,
+ Map<EDataObject, String> dataObjectToRelativeDNCache)
+ throws NamingException
+ {
+ LdapContext eContainmentFeatureContext =
+ null;
+
+ for (EObject eObject : children)
+ {
+ String parentContextRDN =
+ dataObjectToRelativeDNCache.get(eObject.eContainer());
+
+ LdapContext parentContext =
+ (LdapContext)
+ rootContext.
+ lookup(parentContextRDN);
+
+ EStructuralFeature eContainmentFeature =
+ eObject.eContainingFeature();
+
+ String eContainingFeatureContextName =
+ CN + "="+ eContainmentFeature.getName();
+
+ try
+ {
+ eContainmentFeatureContext =
+ (LdapContext)
+ parentContext.lookup(
+ eContainingFeatureContextName);
+ }
+ catch (Exception e)
+ {
+ eContainmentFeatureContext =
+ (LdapContext)
+ parentContext.
+ createSubcontext(
+ eContainingFeatureContextName);
+ }
+
+ EDataObjectCreator.create((
+ EDataObject) eObject,
+ eContainmentFeatureContext,
+ dataObjectToRelativeDNCache);
+
+ children =
+ eObject.eContents();
+
+ if ( children.size()> 0)
+ {
+ createChildren(
+ children,
+ rootContext,
+ dataObjectToRelativeDNCache);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataObjectCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataObjectCreator.java
new file mode 100644
index 0000000000..5d79d40fb5
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataObjectCreator.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.emf.create;
+
+import java.util.Map;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.util.ComplexTypeNamespaceQualifier;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+public class EDataObjectCreator
+implements DASConstants
+{
+ /**
+ * Create the LDAP entry for the EDataObject argument
+ *
+ * @param eDataObject the e data object
+ * @param containerContext the container context
+ *
+ * @throws NamingException the naming exception
+ */
+ public static void create(
+ EDataObject eDataObject,
+ LdapContext containerContext,
+ Map<EDataObject, String> dataObjectToRelativeDNCache)
+ throws NamingException
+ {
+ String rdn =
+ null;
+ Object dataObjectID =
+ null;
+
+ EClass eClass =
+ eDataObject.eClass();
+
+ EAttribute idEAttribute =
+ eClass.getEIDAttribute();
+
+ String namespaceURI =
+ eClass.getEPackage().getNsURI();
+
+ String qualifiedEAttributeName =
+ null;
+ String normalizedEAttributeName =
+ null;
+
+ Attributes attributes =
+ new BasicAttributes();
+
+ attributes =
+ EDataObjectCreatorHelper.processEAttributes(
+ attributes,
+ eDataObject,
+ eClass,
+ namespaceURI);
+
+ attributes =
+ EDataObjectCreatorHelper.processEReferences(
+ attributes,
+ eDataObject,
+ eClass,
+ namespaceURI);
+
+ String qualifiedEClassName =
+ ComplexTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eClass.getName() );
+
+ String normalizedEClassName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEClassName);
+
+ Attribute objectClassAttribute =
+ new BasicAttribute("objectClass");
+
+ objectClassAttribute.
+ add(normalizedEClassName);
+
+ attributes.put(objectClassAttribute);
+
+ dataObjectID =
+ eDataObject.eGet(idEAttribute );
+
+ qualifiedEAttributeName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eClass.getName(),
+ idEAttribute.getName() );
+
+ normalizedEAttributeName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEAttributeName);
+
+ rdn =
+ normalizedEAttributeName + "=" + dataObjectID;
+
+ containerContext.createSubcontext(
+ rdn,
+ attributes );
+
+ EDataObjectCreatorHelper.
+ updateDataObjectToRelativeDNCache(
+ eDataObject,
+ dataObjectToRelativeDNCache,
+ rdn);
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataObjectCreatorHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataObjectCreatorHelper.java
new file mode 100644
index 0000000000..90ec5701ad
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataObjectCreatorHelper.java
@@ -0,0 +1,284 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.emf.create;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+public class EDataObjectCreatorHelper
+implements DASConstants
+{
+
+ public static void updateDataObjectToRelativeDNCache(
+ EDataObject eDataObject,
+ Map<EDataObject, String> dataObjectToRelativeDNCache,
+ String rdn)
+ {
+ EDataObject parentDataObject =
+ (EDataObject) eDataObject.eContainer();
+
+ if (parentDataObject !=null)
+ {
+ String parentRDN =
+ dataObjectToRelativeDNCache.
+ get(parentDataObject);
+ rdn =
+ rdn +
+ "," +
+ "cn=" +
+ eDataObject.eContainingFeature().getName() +
+ "," +
+ parentRDN;
+ dataObjectToRelativeDNCache.put(eDataObject, rdn);
+ }
+ else
+ {
+ dataObjectToRelativeDNCache.put(eDataObject, rdn);
+ }
+ }
+
+
+ /**
+ * Process EAttributes adding the normalized EAttribute instance's
+ * name and corresponding values to the attributes argument.
+ *
+ * @param attributes the attributes
+ * @param eDataObject the e data object
+ * @param eClass the e class
+ * @param namespaceURI the namespace URI
+ *
+ * @return the attributes
+ *
+ * @throws NamingException the naming exception
+ *
+ * Note that ApacheDS supports the Syntaxes (DataTypes)
+ * Boolean, Integer, String. This means that all values that
+ * are not Boolean or Integer are stored as Strings.
+ */
+ public static Attributes processEAttributes(
+ Attributes attributes,
+ EDataObject eDataObject,
+ EClass eClass,
+ String namespaceURI)
+ throws NamingException
+ {
+ EcorePackage ecorePackage =
+ EcorePackage.eINSTANCE;
+
+ EAttribute idEAttribute =
+ eClass.getEIDAttribute();
+
+ List<EAttribute> eAttributes =
+ eClass.getEAllAttributes();
+
+ String qualifiedEAttributeName =
+ null;
+ String normalizedEAttributeName =
+ null;
+
+ for (EAttribute eAttribute : eAttributes)
+ {
+ Attribute attribute =
+ processEAttribute(
+ eAttribute,
+ namespaceURI,
+ eClass, eDataObject);
+ attributes.put(attribute);
+ }
+ return attributes;
+ }
+
+ /*
+ * TODO This is also used in updates so consider moving to a utility
+ */
+ public static Attribute processEAttribute(
+ EAttribute eAttribute,
+ String namespaceURI,
+ EClass eClass,
+ EDataObject eDataObject)
+ {
+ String qualifiedEAttributeName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eClass.getName(),
+ eAttribute.getName() );
+
+ String normalizedEAttributeName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEAttributeName);
+
+ Attribute attribute =
+ new BasicAttribute(normalizedEAttributeName);
+
+ if (eAttribute.isMany())
+ {
+ if ( !(eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ||
+ eAttribute.getEType() == EcorePackage.eINSTANCE.getEBooleanObject() ) )
+ {
+ EList<Object> eAttributeValues =
+ ( EList<Object> ) eDataObject.eGet( eAttribute );
+
+ for (Object eAttributeValue : eAttributeValues)
+ {
+ attribute.add(eAttributeValue.toString() );
+ }
+ }
+ else
+ {
+ EList<Boolean> eAttributeValues =
+ ( EList<Boolean> ) eDataObject.eGet( eAttribute );
+
+ for (Boolean eAttributeValue : eAttributeValues)
+ {
+ if (eAttributeValue == false)
+ {
+ attribute.add(Boolean.FALSE.toString().toUpperCase() );
+ }
+ else
+ {
+ attribute.add(Boolean.TRUE.toString().toUpperCase() );
+ }
+ }
+ }
+ return attribute;
+ }
+
+ if ( !(eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ||
+ eAttribute.getEType() == EcorePackage.eINSTANCE.getEBooleanObject() ) )
+ {
+ Object eAttributeValue =
+ eDataObject.eGet( eAttribute );
+
+ attribute.add(eAttributeValue.toString() );
+ }
+ else
+ {
+ Boolean eAttributeValue =
+ (Boolean) eDataObject.eGet( eAttribute );
+
+ if (eAttributeValue == false)
+ {
+ attribute.add(Boolean.FALSE.toString().toUpperCase() );
+ }
+ else
+ {
+ attribute.add(Boolean.TRUE.toString().toUpperCase() );
+ }
+ }
+ return attribute;
+ }
+
+ /**
+ * Process references adding the normalized EReference instance's
+ * name and corresponding id (IDs for multiplicity many references)
+ * to the attributes argument.
+ *
+ * @param attributes the attributes
+ * @param eDataObject the e data object
+ * @param eClass the e class
+ * @param namespaceURI the namespace URI
+ *
+ * @return the attributes
+ */
+ public static Attributes processEReferences(
+ Attributes attributes,
+ EDataObject eDataObject,
+ EClass eClass,
+ String namespaceURI)
+ {
+ List<EReference> eReferences =
+ eClass.getEAllReferences();
+
+ for (EReference eReference : eReferences)
+ {
+ String qualifiedEReferenceName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eClass.getName(),
+ eReference.getName() );
+
+ String normalizedEReferenceName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEReferenceName);
+
+ if (eReference.isMany())
+ {
+ List<EDataObject> referencedEDataObjects =
+ (List<EDataObject>) eDataObject.eGet(eReference);
+
+ Attribute idAttribute =
+ new BasicAttribute(normalizedEReferenceName);
+
+ for (EDataObject containedEDataObject : referencedEDataObjects)
+ {
+ EClass containedEDataObjectEClass =
+ containedEDataObject.eClass();
+
+ String containedEDataObjectID =
+ (String) containedEDataObject.eGet(
+ containedEDataObjectEClass.
+ getEIDAttribute());
+
+ idAttribute.add(containedEDataObjectID);
+ }
+ attributes.put(idAttribute);
+ }
+ else
+ {
+ EDataObject containedEDataObject =
+ (EDataObject)
+ eDataObject.eGet(eReference);
+
+ if (containedEDataObject != null)
+ {
+ EClass containedEDataObjectEClass =
+ containedEDataObject.eClass();
+
+ String containedEDataObjectID =
+ (String) containedEDataObject.eGet(
+ containedEDataObjectEClass.
+ getEIDAttribute());
+
+ attributes.put(
+ normalizedEReferenceName,
+ containedEDataObjectID);
+ }
+ }
+ }
+ return attributes;
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReader.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReader.java
new file mode 100644
index 0000000000..9add9b7677
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReader.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.emf.read;
+
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.sdo.EDataGraph;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+import org.eclipse.emf.ecore.sdo.SDOFactory;
+
+public class EDataGraphReader
+implements DASConstants
+{
+ public static EDataGraph read(
+ EClass rootDataObjectEClass,
+ String id,
+ LdapContext rootContext,
+ Map<EDataObject, String> dataObjectToRelativeDNCache)
+ throws NamingException, LdapNameNotFoundException
+ {
+ EDataGraph eDataGraph =
+ SDOFactory.eINSTANCE.createEDataGraph();
+
+ String namespaceURI =
+ rootDataObjectEClass.getEPackage().
+ getNsURI();
+
+ EAttribute idEAttribute =
+ rootDataObjectEClass.getEIDAttribute();
+
+ String qualifiedIDEAttributeName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ rootDataObjectEClass.getName(),
+ idEAttribute.getName() );
+
+ String normalizedIDEAttributeName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedIDEAttributeName);
+
+ String eDataObjectRDN =
+ normalizedIDEAttributeName + "=" + id;
+
+ LdapContext eDataObjectContext =
+ (LdapContext)
+ rootContext.
+ lookup(eDataObjectRDN);
+
+ Attributes attributes =
+ rootContext.
+ getAttributes(eDataObjectRDN);
+
+ Map<EDataObject, Map<EStructuralFeature, List<String>>> crossReferenceIDCache =
+ new Hashtable<EDataObject, Map<EStructuralFeature, List<String>>>();
+
+ EDataObject rootDataObject =
+ EDataGraphReaderHelper.
+ restoreEDataObject(
+ crossReferenceIDCache,
+ rootDataObjectEClass,
+ namespaceURI,
+ attributes);
+
+ String relativeDN =
+ EDataGraphReaderHelper.calculateRelativeDN(
+ rootContext,
+ eDataObjectContext);
+
+ dataObjectToRelativeDNCache.
+ put(rootDataObject, relativeDN);
+
+ List<EReference> eReferences =
+ rootDataObjectEClass.getEAllContainments();
+
+ if (rootDataObjectEClass.getEAllContainments().size() > 0)
+ {
+ EDataGraphReaderHelper.
+ addContainmentDataObjects(
+ crossReferenceIDCache,
+ dataObjectToRelativeDNCache,
+ rootDataObject,
+ attributes,
+ namespaceURI,
+ eDataObjectContext,
+ rootContext);
+ }
+
+ eDataGraph.setERootObject(rootDataObject);
+
+ Resource resource = eDataGraph.getRootResource();
+
+ EDataGraphReaderHelper.restoreCrossReferences(
+ crossReferenceIDCache,
+ resource);
+
+ return eDataGraph;
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReaderHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReaderHelper.java
new file mode 100644
index 0000000000..1496d91dab
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReaderHelper.java
@@ -0,0 +1,365 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.emf.read;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.impl.EClassImpl;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+public class EDataGraphReaderHelper
+implements DASConstants
+{
+ public static String calculateRelativeDN(
+ LdapContext containerContext,
+ LdapContext dataObjectContext) throws NamingException
+ {
+ String containerDN = containerContext.getNameInNamespace();
+ String dataObjectDN = dataObjectContext.getNameInNamespace();
+
+ int beginIndex = 0;
+ int endIndex =
+ dataObjectDN.length() - containerDN.length() - 1;
+
+ String result =
+ dataObjectDN.substring(
+ beginIndex,
+ endIndex);
+
+ return result;
+ }
+
+
+ public static EDataObject restoreEDataObject(
+ Map<EDataObject, Map<EStructuralFeature, List<String>>> crossReferenceIDCache,
+ EClass eClass,
+ String namespaceURI,
+ Attributes attributes)
+ throws NamingException
+ {
+ EDataObject eDataObject =
+ (EDataObject)
+ eClass.getEPackage().
+ getEFactoryInstance().
+ create(eClass);
+
+ EDataObjectReaderHelper.
+ restoreEAttributes(
+ eClass,
+ eDataObject,
+ namespaceURI,
+ attributes );
+
+ EStructuralFeature[] eCrossReferences =
+ ((EClassImpl.FeatureSubsetSupplier)
+ eDataObject.
+ eClass().
+ getEAllStructuralFeatures()).
+ crossReferences();
+
+ if (eCrossReferences != null)
+ {
+ Map<EStructuralFeature, List<String>> eReferenceToEObjectIDs =
+ new Hashtable<EStructuralFeature, List<String>>();
+
+ for (EStructuralFeature eReference : eCrossReferences)
+ {
+ String qualifiedEReferenceName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eClass.getName(),
+ eReference.getName() );
+
+ String normalizedEReferenceName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEReferenceName);
+
+ if (eReference.isMany())
+ {
+ List<String> idList =
+ new ArrayList<String>();
+
+ Attribute eReferenceAttribute =
+ attributes.get(normalizedEReferenceName);
+
+ NamingEnumeration namingEnumeration =
+ eReferenceAttribute.getAll();
+
+ while (namingEnumeration.hasMore())
+ {
+ String id = (String) namingEnumeration.next();
+ idList.add(id);
+ eReferenceToEObjectIDs.put(eReference, idList);
+ }
+ }
+ else
+ {
+ List<String> idList =
+ new ArrayList<String>();
+
+ String value =
+ (String)
+ attributes.
+ get(normalizedEReferenceName).
+ get();
+
+ idList.add(value);
+ eReferenceToEObjectIDs.put(eReference, idList);
+ }
+ crossReferenceIDCache.put(
+ eDataObject,
+ eReferenceToEObjectIDs);
+ }
+ }
+ return eDataObject;
+ }
+
+ public static void restoreCrossReferences(
+ Map<EDataObject, Map<EStructuralFeature, List<String>>> crossReferenceIDCache,
+ Resource resource)
+ {
+ for (EDataObject eDataObject : crossReferenceIDCache.keySet())
+ {
+ Map<EStructuralFeature, List<String>> eReferenceToIDListMap =
+ crossReferenceIDCache.get(eDataObject);
+
+ for (EStructuralFeature eStructuralFeature : eReferenceToIDListMap.keySet())
+ {
+ if (eStructuralFeature.isMany())
+ {
+ List<String> eReferenceIDs =
+ eReferenceToIDListMap.
+ get(eStructuralFeature);
+
+ EList<EDataObject> multiplicityManyList = null;
+ if (eReferenceIDs.size() > 0)
+ {
+ multiplicityManyList =
+ new BasicEList<EDataObject>();
+ }
+ for (String eReferenceID : eReferenceIDs)
+ {
+ Object referencedDataObject = resource.getEObject(eReferenceID);
+ multiplicityManyList.add((EDataObject) referencedDataObject);
+ eDataObject.eSet(
+ eStructuralFeature,
+ multiplicityManyList);
+ }
+ }
+ else
+ {
+ String eReferenceID =
+ eReferenceToIDListMap.
+ get(eStructuralFeature).
+ get(0);
+
+ Object referencedDataObject = resource.getEObject(eReferenceID);
+ eDataObject.eSet(
+ eStructuralFeature,
+ referencedDataObject);
+ }
+ }
+ }
+ }
+
+ public static void addContainmentDataObjects(
+ Map crossReferenceIDCache,
+ Map<EDataObject, String> dataObjectToRelativeDNCache,
+ EDataObject containerDataObject,
+ Attributes attributes,
+ String namespaceURI,
+ LdapContext eDataObjectContext,
+ LdapContext rootContext) throws NamingException
+ {
+ EClass eClass =
+ containerDataObject.eClass();
+
+ List<EReference> eReferences =
+ eClass.getEAllContainments();
+
+ for (EReference eReference : eReferences)
+ {
+ String qualifiedEReferenceName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eClass.getName(),
+ eReference.getName() );
+
+ String normalizedReferenceName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEReferenceName);
+
+ Attribute attribute =
+ attributes.
+ get(normalizedReferenceName);
+
+ if (attribute.size() > 0)
+ {
+ LdapContext eReferenceContainmentContext =
+ (LdapContext)
+ eDataObjectContext.
+ lookup("cn=" + eReference.getName());
+
+ EClass eReferenceType =
+ (EClass) eReference.getEType();
+
+ EAttribute eReferenceTypeEIDAttribute =
+ eReferenceType.getEIDAttribute();
+
+ String qualifiedEReferenceTypeIDEAttributeName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eReferenceType.getName(),
+ eReferenceTypeEIDAttribute.getName() );
+
+ String normalizedReferenceTypeEIDAttributeName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEReferenceTypeIDEAttributeName);
+
+ if (eReference.isMany())
+ {
+ EList<EDataObject> containmentList =
+ new BasicEList<EDataObject>();
+
+ NamingEnumeration idNamingEnumeration =
+ attribute.getAll();
+
+ while(idNamingEnumeration.hasMore())
+ {
+ String containedDataObjectID =
+ (String) idNamingEnumeration.next();
+
+ String containedDataObjectEntryRDN =
+ normalizedReferenceTypeEIDAttributeName
+ + "=" + containedDataObjectID;
+
+ Attributes eReferenceAttributes =
+ eReferenceContainmentContext.
+ getAttributes(containedDataObjectEntryRDN);
+
+
+ EDataObject eReferenceDataObject =
+ EDataGraphReaderHelper.
+ restoreEDataObject(
+ crossReferenceIDCache,
+ eReferenceType,
+ namespaceURI,
+ eReferenceAttributes);
+
+ //TODO Consider using aspects
+ String relativeDN =
+ calculateRelativeDN(
+ rootContext,
+ (LdapContext)
+ eReferenceContainmentContext.
+ lookup(containedDataObjectEntryRDN));
+ dataObjectToRelativeDNCache.put(eReferenceDataObject, relativeDN);
+ //End of Aspect
+
+ containmentList.add(eReferenceDataObject);
+
+ if (eReferenceDataObject.eClass().getEAllContainments().size() > 0)
+ {
+ addContainmentDataObjects(
+ crossReferenceIDCache,
+ dataObjectToRelativeDNCache,
+ eReferenceDataObject,
+ eReferenceAttributes,
+ namespaceURI,
+ (LdapContext) eReferenceContainmentContext.
+ lookup(containedDataObjectEntryRDN),
+ rootContext);
+ }
+ }
+ containerDataObject.eSet(eReference, containmentList);
+ }
+ else
+ {
+ String containedDataObjectID =
+ (String) attribute.get();
+
+ String containedDataObjectEntryRDN =
+ normalizedReferenceTypeEIDAttributeName
+ + "=" + containedDataObjectID;
+
+ Attributes eReferenceAttributes =
+ eReferenceContainmentContext.
+ getAttributes(containedDataObjectEntryRDN);
+
+ EDataObject eReferenceDataObject =
+ EDataGraphReaderHelper.
+ restoreEDataObject(
+ crossReferenceIDCache,
+ eReferenceType,
+ namespaceURI,
+ eReferenceAttributes);
+
+ //TODO Consider using aspects
+ String relativeDN =
+ calculateRelativeDN(
+ rootContext,
+ (LdapContext)
+ eReferenceContainmentContext.
+ lookup(containedDataObjectEntryRDN));
+
+ dataObjectToRelativeDNCache.put(eReferenceDataObject, relativeDN);
+ //End of Aspect
+
+ containerDataObject.eSet(eReference, eReferenceDataObject);
+
+ if (eReferenceDataObject.eClass().getEAllContainments().size() > 0)
+ {
+ addContainmentDataObjects(
+ crossReferenceIDCache,
+ dataObjectToRelativeDNCache,
+ eReferenceDataObject,
+ eReferenceAttributes,
+ namespaceURI,
+ (LdapContext) eReferenceContainmentContext.
+ lookup(containedDataObjectEntryRDN),
+ rootContext);
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReader.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReader.java
new file mode 100644
index 0000000000..0c812f4bfc
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReader.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.emf.read;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+public class EDataObjectReader
+implements DASConstants
+{
+ /**
+ * Read.
+ *
+ * @param eClass the e class
+ * @param id the id
+ * @param containerContext the container context
+ *
+ * @return the e data object
+ *
+ * @throws NamingException the naming exception
+ *
+ * Note that this is more of a utility, as only this class's
+ * helper is used in restoring the EDataGraph.
+ */
+ public static EDataObject read(
+ EClass eClass,
+ String id,
+ LdapContext containerContext)
+ throws NamingException
+ {
+ String namespaceURI =
+ eClass.getEPackage().
+ getNsURI();
+
+ EAttribute idEAttribute =
+ eClass.getEIDAttribute();
+
+ String qualifiedIDEAttributeName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eClass.getName(),
+ idEAttribute.getName() );
+
+ String normalizedIDEAttributeName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedIDEAttributeName);
+
+ String eDataObjectRDN =
+ normalizedIDEAttributeName + "=" + id;
+
+ LdapContext eDataObjectContext =
+ (LdapContext)
+ containerContext.
+ lookup(eDataObjectRDN);
+
+ Attributes attributes =
+ eDataObjectContext.getAttributes("");
+
+ EDataObject eDataObject =
+ (EDataObject)
+ eClass.getEPackage().
+ getEFactoryInstance().
+ create(eClass);
+
+ EDataObjectReaderHelper.
+ restoreEAttributes(
+ eClass,
+ eDataObject,
+ namespaceURI,
+ attributes );
+
+ return eDataObject;
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReaderHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReaderHelper.java
new file mode 100644
index 0000000000..2fa6321a65
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReaderHelper.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.emf.read;
+
+import java.util.List;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+public class EDataObjectReaderHelper
+implements DASConstants
+{
+ public static void restoreEAttributes(
+ EClass eClass,
+ EDataObject eDataObject,
+ String namespaceURI,
+ Attributes attributes)
+ throws NamingException
+ {
+ List<EAttribute> eAttributes =
+ eClass.getEAllAttributes();
+
+ for (EAttribute eAttribute : eAttributes)
+ {
+ String qualifiedEAttributeName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eClass.getName(),
+ eAttribute.getName() );
+
+ String normalizedEAttributeName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEAttributeName);
+
+ if (eAttribute.isMany())
+ {
+ EList<Object> values =
+ new BasicEList<Object>();
+
+ Attribute attribute =
+ attributes.
+ get(normalizedEAttributeName);
+
+ for (int i = 0; i < attribute.size(); i++)
+ {
+ String value = (String) attribute.get(i);
+
+ values.add(EcoreUtil.createFromString(
+ eAttribute.getEAttributeType(),
+ value));
+ }
+
+ eDataObject.eSet(
+ eAttribute, values);
+ }
+ else
+ {
+ String value =
+ (String)
+ attributes.
+ get(normalizedEAttributeName).
+ get();
+
+ eDataObject.eSet(
+ eAttribute,
+ EcoreUtil.createFromString(
+ eAttribute.getEAttributeType(),
+ value));
+ }
+ }
+ }
+
+
+ //TODO Test all of these verifying that we get out what we put in
+ //TODO Move to helper
+ //TODO Note that we are using eDataObject.eSet(eAttribute, EcoreUtil.createFromString(eAttribute.getEAttributeType(), value)); instead
+ /*
+ public static void setEDataObjectFeature(
+ EDataObject eDataObject,
+ String value,
+ EAttribute eAttribute)
+ {
+ if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEString())
+ {
+ eDataObject.eSet(eAttribute, value);
+ }
+ else if (
+ eAttribute.getEType() == EcorePackage.eINSTANCE.getEInt() ||
+ eAttribute.getEType() == EcorePackage.eINSTANCE.getEIntegerObject())
+ {
+ eDataObject.eSet(eAttribute, new Integer(value));
+ }
+ else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ||
+ eAttribute.getEType() == EcorePackage.eINSTANCE.getEBooleanObject())
+ {
+ eDataObject.eSet(eAttribute, new Boolean(value));
+ }
+ else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEFloat() ||
+ eAttribute.getEType() == EcorePackage.eINSTANCE.getEFloatObject())
+ {
+ eDataObject.eSet(eAttribute, new Float(value));
+ }
+ else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEDouble() ||
+ eAttribute.getEType() == EcorePackage.eINSTANCE.getEDoubleObject())
+ {
+ eDataObject.eSet(eAttribute, new Double(value));
+ }
+ else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEBigDecimal())
+ {
+ eDataObject.eSet(eAttribute, new BigDecimal(value));
+ }
+ else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEBigInteger() )
+ {
+ eDataObject.eSet(eAttribute, new BigInteger(value));
+ }
+ else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEByte() ||
+ eAttribute.getEType() == EcorePackage.eINSTANCE.getEByteObject())
+ {
+ eDataObject.eSet(eAttribute, new Byte(value));
+ }
+ else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEByte() ||
+ eAttribute.getEType() == EcorePackage.eINSTANCE.getEByteObject())
+ {
+ eDataObject.eSet(eAttribute, new Byte(value));
+ }
+ else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEByteArray())
+ {
+ throw new RuntimeException("Sorry - ByteArrays are not supported.");
+ }
+ }
+ */
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdater.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdater.java
new file mode 100644
index 0000000000..4c22faf1ce
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdater.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.emf.update;
+
+import java.util.Map;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.eclipse.emf.ecore.sdo.EChangeSummary;
+import org.eclipse.emf.ecore.sdo.EDataGraph;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+public class EDataGraphUpdater
+implements DASConstants
+{
+ public static void update(
+ EDataGraph eDataGraph,
+ LdapContext rootContext,
+ Map<EDataObject, String> dataObjectToRelativeDNCache )
+ throws NamingException
+ {
+ EChangeSummary eChangeSummary =
+ (EChangeSummary)
+ eDataGraph.getChangeSummary();
+
+ EDataGraphUpdaterHelper.
+ processChangedDataObjects(
+ eChangeSummary,
+ rootContext,
+ dataObjectToRelativeDNCache);
+
+ EDataGraphUpdaterHelper.
+ processCreatedDataObjects(
+ eChangeSummary,
+ rootContext,
+ dataObjectToRelativeDNCache);
+
+ EDataGraphUpdaterHelper.
+ processDestroyedDataObjects(
+ eChangeSummary,
+ rootContext,
+ dataObjectToRelativeDNCache);
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdaterHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdaterHelper.java
new file mode 100644
index 0000000000..a53b5547fb
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdaterHelper.java
@@ -0,0 +1,228 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.emf.update;
+
+import java.util.Map;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.emf.create.EDataGraphCreatorHelper;
+import org.apache.tuscany.das.ldap.emf.create.EDataObjectCreatorHelper;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.EMap;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.change.FeatureChange;
+import org.eclipse.emf.ecore.sdo.EChangeSummary;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+
+public class EDataGraphUpdaterHelper
+{
+ public static void processDestroyedDataObjects(
+ EChangeSummary eChangeSummary,
+ LdapContext containerContext,
+ Map<EDataObject, String> dataObjectToRelativeDNCache)
+ throws NamingException
+ {
+ EList<EObject> destroyedObjects =
+ eChangeSummary.
+ getObjectsToAttach();
+
+ for (EObject destroyedObject : destroyedObjects)
+ {
+ String destroyedObjectRelativeDN = dataObjectToRelativeDNCache.get(destroyedObject);
+ containerContext.destroySubcontext(destroyedObjectRelativeDN);
+ dataObjectToRelativeDNCache.remove(destroyedObject);
+ }
+ }
+
+ public static void processCreatedDataObjects(
+ EChangeSummary eChangeSummary,
+ LdapContext rootContext,
+ Map<EDataObject, String> dataObjectToRelativeDNCache )
+ throws NamingException
+ {
+ EList<EObject> createdObjects =
+ eChangeSummary.
+ getObjectsToDetach();
+
+ EDataGraphCreatorHelper.createChildren(
+ createdObjects,
+ rootContext,
+ dataObjectToRelativeDNCache);
+ }
+
+ public static void processChangedDataObjects(
+ EChangeSummary eChangeSummary,
+ LdapContext containerContext,
+ Map<EDataObject, String> dataObjectToRelativeDNCache )
+ throws NamingException
+ {
+ EMap<EObject, EList<FeatureChange>> objectChanges =
+ eChangeSummary.getObjectChanges();
+
+ for (EObject changedDataObject : objectChanges.keySet())
+ {
+ EList<FeatureChange> featureChanges =
+ objectChanges.get(changedDataObject);
+
+ ModificationItem[] modificationItems =
+ new ModificationItem[featureChanges.size()];
+
+ EClass changedDataObjectEClass =
+ changedDataObject.eClass();
+
+ String namespaceURI =
+ changedDataObjectEClass.
+ getEPackage().
+ getNsURI();
+
+ for (int i = 0; i < featureChanges.size(); i++)
+ {
+ FeatureChange featureChange =
+ featureChanges.get(i);
+
+ EStructuralFeature eStructuralFeature =
+ featureChange.getFeature();
+
+ if (eStructuralFeature instanceof EAttribute)
+ {
+ //TODO Note that we are not checking multiplicity many on EAttributes
+ String qualifiedEAttributeName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ changedDataObjectEClass.getName(),
+ eStructuralFeature.getName() );
+
+ String normalizedEAttributeName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEAttributeName);
+
+ //TODO PUt processEAttribute in a more generic class
+ Attribute attribute =
+ EDataObjectCreatorHelper.processEAttribute(
+ (EAttribute)eStructuralFeature,
+ namespaceURI,
+ changedDataObjectEClass,
+ (EDataObject) changedDataObject);
+
+ modificationItems[i] =
+ new ModificationItem(
+ DirContext.REPLACE_ATTRIBUTE,
+ attribute);
+ }
+ else
+ {
+ String qualifiedEReferenceName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ changedDataObjectEClass.getName(),
+ eStructuralFeature.getName() );
+
+ String normalizedEReferenceName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEReferenceName);
+
+ Attribute attribute =
+ new BasicAttribute(normalizedEReferenceName);
+
+ if (eStructuralFeature.isMany())
+ {
+ EList<EDataObject> referenceList =
+ (EList<EDataObject>) changedDataObject.eGet(eStructuralFeature);
+
+ if (referenceList.size() > 0 && referenceList!=null)
+ {
+ for (EDataObject eDataObject : referenceList)
+ {
+ attribute.add(
+ eDataObject.
+ eGet(
+ eDataObject.
+ eClass().
+ getEIDAttribute()));
+
+ modificationItems[i] =
+ new ModificationItem(
+ DirContext.REPLACE_ATTRIBUTE,
+ attribute);
+ }
+ }
+ else
+ {
+ modificationItems[i] =
+ new ModificationItem(
+ DirContext.REMOVE_ATTRIBUTE,
+ attribute);
+ }
+ }
+ else
+ {
+ EDataObject eDataObject =
+ (EDataObject)
+ changedDataObject.
+ eGet(eStructuralFeature);
+
+ if (eDataObject != null)
+ {
+ attribute.add(
+ eDataObject.
+ eGet(
+ eDataObject.
+ eClass().
+ getEIDAttribute()));
+
+ modificationItems[i] =
+ new ModificationItem(
+ DirContext.REPLACE_ATTRIBUTE,
+ attribute);
+ }
+ else
+ {
+ modificationItems[i] =
+ new ModificationItem(
+ DirContext.REMOVE_ATTRIBUTE,
+ attribute);
+ }
+ }
+ }
+ }
+ String relativeDN =
+ dataObjectToRelativeDNCache.
+ get(changedDataObject);
+
+ containerContext.modifyAttributes(
+ relativeDN,
+ modificationItems);
+ }
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/constants/EncryptionConstants.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/constants/EncryptionConstants.java
new file mode 100644
index 0000000000..59b726b4f3
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/constants/EncryptionConstants.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.encryption.constants;
+
+public interface EncryptionConstants
+{
+ String MD5 = "MD5";
+ String SHA1 = "SHA-1";//Produces longer hashes than MD5
+}
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/util/ChecksumUtils.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/util/ChecksumUtils.java
new file mode 100644
index 0000000000..7c77ddf510
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/util/ChecksumUtils.java
@@ -0,0 +1,38 @@
+
+package org.apache.tuscany.das.ldap.encryption.util;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+import org.apache.tuscany.das.ldap.encryption.constants.EncryptionConstants;
+
+public class ChecksumUtils
+implements EncryptionConstants
+{
+ public static String computeMD5Hash(String string)
+ throws NoSuchAlgorithmException
+ {
+ MessageDigest messageDigest = MessageDigest.getInstance(MD5);
+
+ byte[] digest =
+ messageDigest.digest(string.getBytes());
+
+ StringBuffer hexString = new StringBuffer();
+ for (int i=0;i<digest.length;i++) {
+ hexString.append (
+ Integer.toHexString(0xFF & digest[i]));
+ }
+
+ char[] hexStringCharacters = hexString.toString().toCharArray();
+ String checksum = "";
+
+ for( char i : hexStringCharacters)
+ {
+ int ascii = (int) i;
+ checksum = checksum + Integer.toString(ascii);
+ }
+
+ return checksum;
+ }
+
+}
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/ComplexTypeOIDCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/ComplexTypeOIDCreator.java
new file mode 100644
index 0000000000..c0bb3e9137
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/ComplexTypeOIDCreator.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.oid.create;
+
+import org.apache.tuscany.das.ldap.encryption.constants.EncryptionConstants;
+import org.apache.tuscany.das.ldap.encryption.util.ChecksumUtils;
+import org.apache.tuscany.das.ldap.util.ComplexTypeNamespaceQualifier;
+
+/**
+ * The Class UniqueOIDCreator.
+ * Creates unique OIDs for namespaced
+ * metadata such as the XSD DataType
+ * with (Class specific term) qualifiedNameURI
+ * http://www.w3.org/2001/XMLSchema/string
+ *
+ */
+public class ComplexTypeOIDCreator implements EncryptionConstants
+{
+ /**
+ * Creates a unique OID.
+ *
+ * @param instanceClassName the instance class name
+ * @param oidPrefix the OID Branch
+ * @param simpleTypeName the name
+ * @param namespaceURI the metadata namespace URI
+ *
+ * @return the string
+ *
+ * @throws Exception the exception
+ */
+ public static String create(
+ String oidPrefix,
+ String namespaceURI,
+ String complexTypeName)
+ throws Exception
+ {
+ String qualifiedNameURI =
+ ComplexTypeNamespaceQualifier.qualify(
+ namespaceURI,
+ complexTypeName);
+
+ String postfixOID =
+ ChecksumUtils.computeMD5Hash(
+ qualifiedNameURI);
+
+ postfixOID =
+ OIDCreatorHelper.
+ calculateSegmentedOID(postfixOID);
+
+ return oidPrefix + "." + postfixOID;
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/OIDCreatorHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/OIDCreatorHelper.java
new file mode 100644
index 0000000000..ad82a61514
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/OIDCreatorHelper.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.oid.create;
+
+public class OIDCreatorHelper
+{
+ private static int MAX_OID_SEGMENT_LENGTH = 8;
+ /**
+ * Calculate segmented OID.
+ *
+ * @param oid the oid
+ *
+ * @return the string
+ *
+ * @throws Exception the exception
+ *
+ * Note that the OID must be divided
+ * into segments less than 9 characters
+ * long. This is an ApacheDS restriction
+ * on OID segment length.
+ */
+ public static String calculateSegmentedOID(String oid) throws Exception
+ {
+ if (oid.length() < 10)
+ {
+ throw new Exception("The length of the oid must be greater than 9 in order to ensure uniqueness.");
+ }
+ int oidLength = oid.length();
+ int numberOfPeriods = oidLength / MAX_OID_SEGMENT_LENGTH;
+
+ int beginIndex = 0;
+ int endIndex = MAX_OID_SEGMENT_LENGTH;
+
+ String segmentedOID =
+ oid.substring(beginIndex, endIndex ) + ".";
+
+ for (int i = 2; i < numberOfPeriods; i++)
+ {
+ beginIndex = (i-1) * MAX_OID_SEGMENT_LENGTH + 1;
+ endIndex = i * MAX_OID_SEGMENT_LENGTH;
+ segmentedOID += oid.substring( beginIndex, endIndex ) + ".";
+ }
+ int finalSegmentLength = oid.length() - (endIndex + 2);
+
+ if ( finalSegmentLength > MAX_OID_SEGMENT_LENGTH )
+ {
+ segmentedOID += oid.substring( endIndex + 1,endIndex + 9 ) + ".";
+ segmentedOID += oid.substring( endIndex + 10, oid.length() );
+ }
+ else
+ {
+ segmentedOID += oid.substring( endIndex + 1, oid.length() );
+ }
+ return segmentedOID;
+ }
+}
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/SimpleTypeOIDCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/SimpleTypeOIDCreator.java
new file mode 100644
index 0000000000..3c083fc42f
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/SimpleTypeOIDCreator.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.oid.create;
+
+import org.apache.tuscany.das.ldap.encryption.constants.EncryptionConstants;
+import org.apache.tuscany.das.ldap.encryption.util.ChecksumUtils;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+
+/**
+ * The Class SimpleTypeOIDCreator.
+ * Creates unique OIDs for namespaced
+ * metadata such as the XSD DataType
+ * with (Class specific term) qualifiedNameURI
+ * http://www.w3.org/2001/XMLSchema/string
+ *
+ */
+public class SimpleTypeOIDCreator implements EncryptionConstants
+{
+ /**
+ * Creates a unique OID.
+ *
+ * @param instanceClassName the instance class name
+ * @param oidPrefix the OID Branch
+ * @param complexTypeName the name
+ * @param namespaceURI the metadata namespace URI
+ *
+ * @return the string
+ *
+ * @throws Exception the exception
+ */
+ public static String create(
+ String oidPrefix,
+ String namespaceURI,
+ String complexTypeName,
+ String simpleTypeName)
+ throws Exception
+ {
+ String qualifiedNameURI =
+ SimpleTypeNamespaceQualifier.qualify(
+ namespaceURI,
+ complexTypeName,
+ simpleTypeName);
+
+ String postfixOID = ChecksumUtils.computeMD5Hash(qualifiedNameURI);
+
+ postfixOID = OIDCreatorHelper.calculateSegmentedOID(postfixOID);
+ return oidPrefix + "." + postfixOID;
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/Prototype.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/Prototype.java
new file mode 100644
index 0000000000..17f011e971
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/Prototype.java
@@ -0,0 +1,74 @@
+package org.apache.tuscany.das.ldap.prototype.setup;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+
+public interface Prototype {
+ EClass userEClass =
+ PrototypeUtilities.createUserEClass();
+ EClass authorizationEClass =
+ PrototypeUtilities.createAuthorizationEClass();
+ EClass configurationEClass =
+ PrototypeUtilities.createConfigurationEClass();
+
+ EAttribute userNameEAttribute =
+ PrototypeUtilities.createUserNameEAttribute();
+ EAttribute userAliasesEAttribute =
+ PrototypeUtilities.createUserAliasesEAttribute();
+
+ EAttribute userPasswordEAttribute =
+ PrototypeUtilities.createUserPasswordEAttribute();
+ EAttribute userIDEAttribute =
+ PrototypeUtilities.createUserIDEAttribute();
+ EAttribute userAgeEAttribute =
+ PrototypeUtilities.createUserAgeEAttribute();
+ EAttribute userHeightEAttribute =
+ PrototypeUtilities.createUserHeightEAttribute();
+ EAttribute userIsMaleEAttribute =
+ PrototypeUtilities.createUserIsMaleEAttribute();
+ EReference userAuthorizationEReference =
+ PrototypeUtilities.createUserAuthorizationEReference();
+
+ EReference userConfigurationEReference =
+ PrototypeUtilities.createUserConfigurationEReference();
+
+
+
+
+ EAttribute authorizationFileEAttribute =
+ PrototypeUtilities.createFileEAttribute();
+ EAttribute authorizationReadEAttribute =
+ PrototypeUtilities.createReadAuthorizationEAttribute();
+ EAttribute authorizationWriteEAttribute=
+ PrototypeUtilities.createWriteAuthorizationEAttribute();
+ EAttribute authorizationExecuteEAttribute =
+ PrototypeUtilities.createExecuteAuthorizationEAttribute();
+ EAttribute authorizationIDEAttribute =
+ PrototypeUtilities.createAuthorizationIDEAttribute();
+
+ EAttribute configurationIDEAttribute =
+ PrototypeUtilities.createConfigurationIDEAttribute();
+
+ EReference configurationAuthorizationEReference =
+ PrototypeUtilities.createConfigurationAuthorizationEReference();
+
+ EReference configurationAuthorizationsEReference =
+ PrototypeUtilities.createConfigurationAuthorizationsEReference();
+
+
+ EPackage userEPackage =
+ PrototypeUtilities.createUserEPackage();
+
+ EFactory userEFactory =
+ userEPackage.getEFactoryInstance();
+
+ EcoreFactory ecoreFactory =
+ EcoreFactory.eINSTANCE;
+ EcorePackage ecorePackage =
+ EcorePackage.eINSTANCE;
+}
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/PrototypeUtilities.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/PrototypeUtilities.java
new file mode 100644
index 0000000000..11af604dfa
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/PrototypeUtilities.java
@@ -0,0 +1,243 @@
+package org.apache.tuscany.das.ldap.prototype.setup;
+
+import org.apache.tuscany.das.ldap.testing.constants.DASTestingConstants;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;
+
+public class PrototypeUtilities
+implements DASTestingConstants {
+
+ /*
+ * The User EClass is intended to be the root of the DataGraph
+ * It should have a multiplicity many containment reference of type
+ * Authorization and a containment reference of type Configuration
+ * The Configuration should have a single non-containment reference
+ * of type Authorization.
+ */
+
+ public static EClass createUserEClass()
+ {
+ EClass userEClass =
+ EcoreFactory.eINSTANCE.createEClass();
+
+ userEClass.setName("User");
+
+ return userEClass;
+ }
+
+ public static EAttribute createUserIDEAttribute()
+ {
+ EAttribute id =
+ EcoreFactory.eINSTANCE.createEAttribute();
+ id.setName( "id" );
+ id.setEType( EcorePackage.eINSTANCE.getEString() );
+ id.setID(true);
+ return id;
+ }
+
+ public static EAttribute createUserNameEAttribute()
+ {
+ EAttribute userName =
+ EcoreFactory.eINSTANCE.createEAttribute();
+ userName.setName( "userName" );
+ userName.setEType( EcorePackage.eINSTANCE.getEString() );
+ return userName;
+ }
+
+ public static EAttribute createUserAliasesEAttribute()
+ {
+ EAttribute userAliases =
+ EcoreFactory.eINSTANCE.createEAttribute();
+ userAliases.setName( "userAliases" );
+ userAliases.setLowerBound( 0 );
+ userAliases.setUpperBound( -1 );
+ userAliases.setEType( EcorePackage.eINSTANCE.getEString() );
+ return userAliases;
+ }
+
+ public static EAttribute createUserPasswordEAttribute()
+ {
+ EAttribute userPassword =
+ EcoreFactory.eINSTANCE.createEAttribute();
+ userPassword.setName( "userPassword" );
+ userPassword.setEType( EcorePackage.eINSTANCE.getEString() );
+ return userPassword;
+ }
+
+ public static EAttribute createUserAgeEAttribute()
+ {
+ EAttribute userAge =
+ EcoreFactory.eINSTANCE.createEAttribute();
+ userAge.setName( "userAge" );
+ userAge.setEType( EcorePackage.eINSTANCE.getEInt() );
+ return userAge;
+ }
+
+ public static EAttribute createUserHeightEAttribute()
+ {
+ EAttribute userHeight =
+ EcoreFactory.eINSTANCE.createEAttribute();
+ userHeight.setName( "userHeight" );
+ userHeight.setEType( EcorePackage.eINSTANCE.getEDouble() );
+ return userHeight;
+ }
+
+ public static EAttribute createUserIsMaleEAttribute()
+ {
+ EAttribute isMale =
+ EcoreFactory.eINSTANCE.createEAttribute();
+ isMale.setName( "isMale" );
+ isMale.setEType( EcorePackage.eINSTANCE.getEBoolean() );
+ return isMale;
+ }
+
+ public static EReference createUserAuthorizationEReference()
+ {
+ EReference userAuthorizationEReference =
+ EcoreFactory.eINSTANCE.createEReference();
+ userAuthorizationEReference.setLowerBound(0);
+ userAuthorizationEReference.setUpperBound(ETypedElement.UNBOUNDED_MULTIPLICITY);
+ userAuthorizationEReference.setContainment(true);
+ userAuthorizationEReference.setName("authorizationList");
+
+ return userAuthorizationEReference;
+ }
+
+ public static EReference createUserConfigurationEReference()
+ {
+ EReference userConfigurationEReference =
+ EcoreFactory.eINSTANCE.createEReference();
+ userConfigurationEReference.setLowerBound(0);
+ userConfigurationEReference.setUpperBound(1);
+ userConfigurationEReference.setContainment(true);
+ userConfigurationEReference.setName("configuration");
+
+ return userConfigurationEReference;
+ }
+
+
+ public static EPackage createUserEPackage()
+ {
+ EPackage userEPackage =
+ EcoreFactory.eINSTANCE.createEPackage();
+ userEPackage.setName( "userPackage" );
+ userEPackage.setNsPrefix( "user" );
+ userEPackage.setNsURI( xsdNamespace );
+
+ userEPackage.setEFactoryInstance(
+ new DynamicEDataObjectImpl.FactoryImpl());
+
+ return userEPackage;
+ }
+
+ public static EClass createAuthorizationEClass()
+ {
+ EClass authorizationEClass =
+ EcoreFactory.eINSTANCE.createEClass();
+
+ authorizationEClass.setName("Authorization");
+
+ return authorizationEClass;
+ }
+
+ public static EAttribute createAuthorizationIDEAttribute()
+ {
+ EAttribute id =
+ EcoreFactory.eINSTANCE.createEAttribute();
+ id.setName( "id" );
+ id.setEType( EcorePackage.eINSTANCE.getEString() );
+ id.setID(true);
+ return id;
+ }
+
+ public static EAttribute createFileEAttribute()
+ {
+ EAttribute fileNameEAttribute =
+ EcoreFactory.eINSTANCE.createEAttribute();
+ fileNameEAttribute.setName( "fileName" );
+ fileNameEAttribute.setEType( EcorePackage.eINSTANCE.getEString() );
+ return fileNameEAttribute;
+
+ }
+
+ public static EAttribute createWriteAuthorizationEAttribute()
+ {
+ EAttribute writeAuthorizationEAttribute =
+ EcoreFactory.eINSTANCE.createEAttribute();
+ writeAuthorizationEAttribute.setName( "writeAuthorization" );
+ writeAuthorizationEAttribute.setEType( EcorePackage.eINSTANCE.getEBoolean() );
+ return writeAuthorizationEAttribute;
+ }
+
+ public static EAttribute createReadAuthorizationEAttribute()
+ {
+ EAttribute readAuthorizationEAttribute =
+ EcoreFactory.eINSTANCE.createEAttribute();
+ readAuthorizationEAttribute.setName( "readAuthorization" );
+ readAuthorizationEAttribute.setEType( EcorePackage.eINSTANCE.getEBoolean() );
+ return readAuthorizationEAttribute;
+ }
+
+ public static EAttribute createExecuteAuthorizationEAttribute()
+ {
+ EAttribute readExecuteEAttribute =
+ EcoreFactory.eINSTANCE.createEAttribute();
+ readExecuteEAttribute.setName( "executeAuthorization" );
+ readExecuteEAttribute.setEType( EcorePackage.eINSTANCE.getEBoolean() );
+ return readExecuteEAttribute;
+ }
+
+
+ public static EClass createConfigurationEClass()
+ {
+ EClass configurationEClass =
+ EcoreFactory.eINSTANCE.createEClass();
+
+ configurationEClass.setName("Configuration");
+
+ return configurationEClass;
+ }
+
+ public static EAttribute createConfigurationIDEAttribute()
+ {
+ EAttribute id =
+ EcoreFactory.eINSTANCE.createEAttribute();
+ id.setName( "id" );
+ id.setEType( EcorePackage.eINSTANCE.getEString() );
+ id.setID(true);
+ return id;
+ }
+
+ public static EReference createConfigurationAuthorizationEReference()
+ {
+ EReference authorizationEReference =
+ EcoreFactory.eINSTANCE.createEReference();
+ authorizationEReference.setLowerBound(0);
+ authorizationEReference.setUpperBound(1);
+ authorizationEReference.setContainment(false);
+ //authorizationEReference.setEType(createAuthorizationEClass()); Do this in the testing code.
+ authorizationEReference.setName("authorization");
+
+ return authorizationEReference;
+ }
+
+ public static EReference createConfigurationAuthorizationsEReference()
+ {
+ EReference authorizationsEReference =
+ EcoreFactory.eINSTANCE.createEReference();
+ authorizationsEReference.setLowerBound(0);
+ authorizationsEReference.setUpperBound(ETypedElement.UNBOUNDED_MULTIPLICITY);
+ authorizationsEReference.setContainment(false);
+ //authorizationEReference.setEType(createAuthorizationEClass()); Do this in the testing code.
+ authorizationsEReference.setName("authorizations");
+
+ return authorizationsEReference;
+ }
+
+}
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/CommonSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/CommonSetupTest.java
new file mode 100644
index 0000000000..9b7673efe6
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/CommonSetupTest.java
@@ -0,0 +1,264 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.prototype.setup.test;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.tuscany.das.ldap.prototype.setup.Prototype;
+import org.apache.tuscany.das.ldap.schema.embedded.setup.test.EcoreSchemaAndDASContextsSetup;
+import org.apache.tuscany.das.ldap.schema.emf.create.EObjectClassCreator;
+import org.apache.tuscany.das.ldap.schema.emf.destroy.EObjectClassDestroyer;
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+public class CommonSetupTest
+extends EcoreSchemaAndDASContextsSetup
+implements Prototype
+{
+ protected EObjectClassCreator eObjectClassCreator = null;
+
+ protected EDataObject userDataObject = null;
+ protected EDataObject authorizationDataObject0 = null;
+ protected EDataObject authorizationDataObject1 = null;
+ protected EDataObject configurationDataObject = null;
+
+ protected static List<EClass>
+ processedEClassifiers = null;
+
+ protected String userDataObjectRDN =
+ "example-com-users-accounts-User-id=1";
+ protected String authorizationDataObject1RDN =
+ "example-com-users-accounts-Authorization-id=2,cn=authorizationList,example-com-users-accounts-User-id=1";
+ protected String authorizationDataObject2RDN =
+ "example-com-users-accounts-Authorization-id=3,cn=authorizationList,example-com-users-accounts-User-id=1";
+ protected String configurationDataObjectRDN =
+ "example-com-users-accounts-Configuration-id=5,cn=configuration,example-com-users-accounts-User-id=1";
+
+ protected String configurationContainingFeatureRDN =
+ "cn=configuration";
+ protected String authorizationListContainingFeatureRDN=
+ "cn=authorizationList";
+
+ protected LdapContext authorizationContainerContext = null;
+ protected LdapContext configurationContainerContext = null;
+ protected LdapContext userContainerContext = null;
+
+ protected Map<EDataObject, String> dataObjectToRelativeDNCache = null;
+
+ public void tearDown() throws NamingException, Exception
+ {
+ rootContext.destroySubcontext(userDataObjectRDN);
+
+ EObjectClassDestroyer.
+ destroy(
+ metaContext,
+ ecoreAttributeTypesContext,
+ ecoreObjectClassesContext,
+ userEClass,
+ TUSCANY_OID_PREFIX_VALUE );
+
+ super.tearDown();
+ }
+
+ public void setUp() throws Exception
+ {
+ FileUtils.deleteDirectory(new File("server-work"));
+
+ dataObjectToRelativeDNCache =
+ new Hashtable<EDataObject, String>();
+
+ super.setUp();
+
+ userAuthorizationEReference.
+ setEType(authorizationEClass);
+
+ userConfigurationEReference.
+ setEType(configurationEClass);
+
+ configurationAuthorizationEReference.
+ setEType(authorizationEClass);
+
+ configurationAuthorizationsEReference.
+ setEType(authorizationEClass);
+
+ userEClass.
+ getEStructuralFeatures().
+ add( userNameEAttribute );
+
+ userEClass.
+ getEStructuralFeatures().
+ add( userAliasesEAttribute );
+
+ userEClass.
+ getEStructuralFeatures().
+ add( userPasswordEAttribute );
+ userEClass.
+ getEStructuralFeatures().
+ add( userAgeEAttribute );
+ userEClass.
+ getEStructuralFeatures().
+ add( userHeightEAttribute );
+ userEClass.
+ getEStructuralFeatures().
+ add( userIsMaleEAttribute );
+ userEClass.
+ getEStructuralFeatures().
+ add( userIDEAttribute );
+ userEClass.
+ getEStructuralFeatures().
+ add( userAuthorizationEReference );
+ userEClass.
+ getEStructuralFeatures().
+ add( userConfigurationEReference );
+
+ userEPackage.getEClassifiers().add(userEClass);
+
+ userDataObject =
+ (EDataObject)
+ userEFactory.create(userEClass);
+
+ userDataObject.eSet(userNameEAttribute,"ole");
+ userDataObject.eSet(userPasswordEAttribute,"secret");
+ userDataObject.eSet(userIDEAttribute, "1");
+ userDataObject.eSet(userAgeEAttribute, 33);
+ userDataObject.eSet(userHeightEAttribute, 6.11);
+ userDataObject.eSet(userIsMaleEAttribute, true);
+
+ EList<String> userAliases = new BasicEList<String>();
+ userAliases.add("neo");
+ userAliases.add("trinity");
+ userAliases.add("morpheus");
+
+ userDataObject.eSet( userAliasesEAttribute, userAliases );
+
+ authorizationEClass.
+ getEStructuralFeatures().
+ add(authorizationFileEAttribute);
+
+ authorizationEClass.
+ getEStructuralFeatures().
+ add(authorizationWriteEAttribute);
+
+ authorizationEClass.
+ getEStructuralFeatures().
+ add(authorizationReadEAttribute);
+
+ authorizationEClass.
+ getEStructuralFeatures().
+ add(authorizationExecuteEAttribute);
+
+ authorizationEClass.
+ getEStructuralFeatures().
+ add(authorizationIDEAttribute);
+
+ userEPackage.getEClassifiers().
+ add(authorizationEClass);
+
+ authorizationDataObject0 =
+ (EDataObject)
+ userEFactory.create(authorizationEClass);
+
+ authorizationDataObject1 =
+ (EDataObject)
+ userEFactory.create(authorizationEClass);
+
+ authorizationDataObject0.eSet(authorizationFileEAttribute,"somefile.text");
+ authorizationDataObject0.eSet(authorizationWriteEAttribute, true);
+ authorizationDataObject0.eSet(authorizationReadEAttribute,true);
+ authorizationDataObject0.eSet(authorizationExecuteEAttribute,true);
+ authorizationDataObject0.eSet(authorizationIDEAttribute, "2");
+
+ authorizationDataObject1.eSet(authorizationFileEAttribute,"someOtherfile.text");
+ authorizationDataObject1.eSet(authorizationWriteEAttribute,Boolean.TRUE);
+ authorizationDataObject1.eSet(authorizationReadEAttribute,true);
+ authorizationDataObject1.eSet(authorizationExecuteEAttribute,true);
+ authorizationDataObject1.eSet(authorizationIDEAttribute, "3");
+
+ EList<EDataObject> userDataObjectAuthorizationList =
+ new BasicEList<EDataObject>();
+
+ userDataObjectAuthorizationList.add(authorizationDataObject0);
+ userDataObjectAuthorizationList.add(authorizationDataObject1);
+
+ userDataObject.eSet(
+ userAuthorizationEReference,
+ userDataObjectAuthorizationList);
+
+ configurationEClass.
+ getEStructuralFeatures().
+ add(configurationIDEAttribute);
+
+ configurationEClass.
+ getEStructuralFeatures().
+ add(configurationAuthorizationEReference);
+
+ configurationEClass.
+ getEStructuralFeatures().
+ add(configurationAuthorizationsEReference);
+
+ userEPackage.getEClassifiers().
+ add(configurationEClass);
+
+ configurationDataObject =
+ (EDataObject)
+ userEFactory.create(configurationEClass);
+
+ userDataObject.eSet(
+ userConfigurationEReference,
+ configurationDataObject);
+
+ configurationDataObject.eSet(
+ configurationIDEAttribute,
+ "5");
+
+ configurationDataObject.eSet(
+ configurationAuthorizationEReference,
+ authorizationDataObject0);
+
+ configurationDataObject.eSet(
+ configurationAuthorizationsEReference,
+ userDataObjectAuthorizationList);
+
+ processedEClassifiers =
+ new ArrayList<EClass>();
+
+ eObjectClassCreator =
+ new EObjectClassCreator();
+
+ eObjectClassCreator.
+ create(
+ metaContext,
+ ecoreAttributeTypesContext,
+ ecoreObjectClassesContext,
+ userEClass,
+ processedEClassifiers,
+ TUSCANY_OID_PREFIX_VALUE );
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataGraphSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataGraphSetupTest.java
new file mode 100644
index 0000000000..c05db9f7e2
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataGraphSetupTest.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.prototype.setup.test;
+
+import javax.naming.NamingException;
+
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.emf.create.EDataGraphCreator;
+import org.apache.tuscany.das.ldap.schema.emf.destroy.EObjectClassDestroyer;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.sdo.EDataGraph;
+import org.eclipse.emf.ecore.sdo.SDOFactory;
+import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl;
+
+public class EDataGraphSetupTest
+extends CommonSetupTest
+{
+ protected EDataGraph eDataGraph = null;
+ protected boolean readException = false;
+
+ public void tearDown() throws NamingException, Exception
+ {
+ if (dataObjectToRelativeDNCache.containsValue(authorizationDataObject1RDN)
+ || readException)
+ {
+ rootContext.destroySubcontext(authorizationDataObject1RDN);
+ }
+ if (dataObjectToRelativeDNCache.containsValue(authorizationDataObject2RDN)
+ || readException)
+ {
+ rootContext.destroySubcontext(authorizationDataObject2RDN);
+ }
+ if (dataObjectToRelativeDNCache.containsValue(configurationDataObjectRDN)
+ || readException)
+ {
+ rootContext.destroySubcontext(configurationDataObjectRDN);
+ }
+ userContainerContext.destroySubcontext(configurationContainingFeatureRDN);
+
+ userContainerContext.destroySubcontext(authorizationListContainingFeatureRDN);
+
+ EObjectClassDestroyer.
+ destroy(
+ metaContext,
+ ecoreAttributeTypesContext,
+ ecoreObjectClassesContext,
+ authorizationEClass,
+ TUSCANY_OID_PREFIX_VALUE );
+
+ EObjectClassDestroyer.
+ destroy(
+ metaContext,
+ ecoreAttributeTypesContext,
+ ecoreObjectClassesContext,
+ configurationEClass,
+ TUSCANY_OID_PREFIX_VALUE );
+
+ super.tearDown();
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ eObjectClassCreator.
+ create(
+ metaContext,
+ ecoreAttributeTypesContext,
+ ecoreObjectClassesContext,
+ authorizationEClass,
+ processedEClassifiers,
+ TUSCANY_OID_PREFIX_VALUE );
+
+ eObjectClassCreator.
+ create(
+ metaContext,
+ ecoreAttributeTypesContext,
+ ecoreObjectClassesContext,
+ configurationEClass,
+ processedEClassifiers,
+ TUSCANY_OID_PREFIX_VALUE );
+
+ eDataGraph =
+ SDOFactory.
+ eINSTANCE.
+ createEDataGraph();
+
+ eDataGraph.setERootObject(userDataObject);
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().
+ getExtensionToFactoryMap().put
+ ("xml",
+ new XMLResourceFactoryImpl());
+
+ eDataGraph.setResourceSet(resourceSet);
+
+ EDataGraphCreator.create(
+ eDataGraph,
+ rootContext,
+ dataObjectToRelativeDNCache);
+
+ userContainerContext =
+ (LdapContext)
+ rootContext.
+ lookup(userDataObjectRDN);
+
+ authorizationContainerContext =
+ (LdapContext)
+ userContainerContext.
+ lookup(authorizationListContainingFeatureRDN);
+
+ configurationContainerContext =
+ (LdapContext)
+ userContainerContext.
+ lookup(configurationContainingFeatureRDN);
+
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataObjectSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataObjectSetupTest.java
new file mode 100644
index 0000000000..4c91f34e07
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataObjectSetupTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.prototype.setup.test;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.emf.create.EDataObjectCreator;
+
+public class EDataObjectSetupTest
+extends CommonSetupTest
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ EDataObjectCreator.create(
+ userDataObject,
+ rootContext,
+ dataObjectToRelativeDNCache);
+
+ userContainerContext =
+ (LdapContext)
+ rootContext.
+ lookup(userDataObjectRDN);
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/LdapDASSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/LdapDASSetupTest.java
new file mode 100644
index 0000000000..3225868ffe
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/LdapDASSetupTest.java
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.prototype.setup.test;
+
+import java.io.File;
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.naming.NamingException;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.tuscany.das.ldap.prototype.setup.Prototype;
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.sdo.EDataGraph;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+import org.eclipse.emf.ecore.sdo.SDOFactory;
+
+public class LdapDASSetupTest
+extends TestCase
+implements Prototype
+{
+ protected Map<EDataObject, String> dataObjectToRelativeDNCache = null;
+ protected EDataGraph eDataGraph = null;
+ protected EDataObject userDataObject = null;
+ protected EDataObject authorizationDataObject0 = null;
+ protected EDataObject authorizationDataObject1 = null;
+ protected EDataObject configurationDataObject = null;
+
+ public void tearDown() throws NamingException, Exception
+ {
+ FileUtils.deleteDirectory(new File("server-work"));
+ }
+
+ public void setUp() throws Exception
+ {
+ dataObjectToRelativeDNCache =
+ new Hashtable<EDataObject, String>();
+
+ userAuthorizationEReference.
+ setEType(authorizationEClass);
+
+ userConfigurationEReference.
+ setEType(configurationEClass);
+
+ configurationAuthorizationEReference.
+ setEType(authorizationEClass);
+
+ configurationAuthorizationsEReference.
+ setEType(authorizationEClass);
+
+ userEClass.
+ getEStructuralFeatures().
+ add( userNameEAttribute );
+
+ userEClass.
+ getEStructuralFeatures().
+ add( userAliasesEAttribute );
+
+ userEClass.
+ getEStructuralFeatures().
+ add( userPasswordEAttribute );
+ userEClass.
+ getEStructuralFeatures().
+ add( userAgeEAttribute );
+ userEClass.
+ getEStructuralFeatures().
+ add( userHeightEAttribute );
+ userEClass.
+ getEStructuralFeatures().
+ add( userIsMaleEAttribute );
+ userEClass.
+ getEStructuralFeatures().
+ add( userIDEAttribute );
+ userEClass.
+ getEStructuralFeatures().
+ add( userAuthorizationEReference );
+ userEClass.
+ getEStructuralFeatures().
+ add( userConfigurationEReference );
+
+ userEPackage.getEClassifiers().add(userEClass);
+
+ userDataObject =
+ (EDataObject)
+ userEFactory.create(userEClass);
+
+ userDataObject.eSet(userNameEAttribute,"ole");
+ userDataObject.eSet(userPasswordEAttribute,"secret");
+ userDataObject.eSet(userIDEAttribute, "1");
+ userDataObject.eSet(userAgeEAttribute, 33);
+ userDataObject.eSet(userHeightEAttribute, 6.11);
+ userDataObject.eSet(userIsMaleEAttribute, true);
+
+ EList<String> userAliases = new BasicEList<String>();
+ userAliases.add("neo");
+ userAliases.add("trinity");
+ userAliases.add("morpheus");
+
+ userDataObject.eSet( userAliasesEAttribute, userAliases );
+
+ authorizationEClass.
+ getEStructuralFeatures().
+ add(authorizationFileEAttribute);
+
+ authorizationEClass.
+ getEStructuralFeatures().
+ add(authorizationWriteEAttribute);
+
+ authorizationEClass.
+ getEStructuralFeatures().
+ add(authorizationReadEAttribute);
+
+ authorizationEClass.
+ getEStructuralFeatures().
+ add(authorizationExecuteEAttribute);
+
+ authorizationEClass.
+ getEStructuralFeatures().
+ add(authorizationIDEAttribute);
+
+ userEPackage.getEClassifiers().
+ add(authorizationEClass);
+
+ authorizationDataObject0 =
+ (EDataObject)
+ userEFactory.create(authorizationEClass);
+
+ authorizationDataObject1 =
+ (EDataObject)
+ userEFactory.create(authorizationEClass);
+
+ authorizationDataObject0.eSet(authorizationFileEAttribute,"somefile.text");
+ authorizationDataObject0.eSet(authorizationWriteEAttribute, true);
+ authorizationDataObject0.eSet(authorizationReadEAttribute,true);
+ authorizationDataObject0.eSet(authorizationExecuteEAttribute,true);
+ authorizationDataObject0.eSet(authorizationIDEAttribute, "2");
+
+ authorizationDataObject1.eSet(authorizationFileEAttribute,"someOtherfile.text");
+ authorizationDataObject1.eSet(authorizationWriteEAttribute,Boolean.TRUE);
+ authorizationDataObject1.eSet(authorizationReadEAttribute,true);
+ authorizationDataObject1.eSet(authorizationExecuteEAttribute,true);
+ authorizationDataObject1.eSet(authorizationIDEAttribute, "3");
+
+ EList<EDataObject> userDataObjectAuthorizationList =
+ new BasicEList<EDataObject>();
+
+ userDataObjectAuthorizationList.add(authorizationDataObject0);
+ userDataObjectAuthorizationList.add(authorizationDataObject1);
+
+ userDataObject.eSet(
+ userAuthorizationEReference,
+ userDataObjectAuthorizationList);
+
+ configurationEClass.
+ getEStructuralFeatures().
+ add(configurationIDEAttribute);
+
+ configurationEClass.
+ getEStructuralFeatures().
+ add(configurationAuthorizationEReference);
+
+ configurationEClass.
+ getEStructuralFeatures().
+ add(configurationAuthorizationsEReference);
+
+ userEPackage.getEClassifiers().
+ add(configurationEClass);
+
+ configurationDataObject =
+ (EDataObject)
+ userEFactory.create(configurationEClass);
+
+ userDataObject.eSet(
+ userConfigurationEReference,
+ configurationDataObject);
+
+ configurationDataObject.eSet(
+ configurationIDEAttribute,
+ "5");
+
+ configurationDataObject.eSet(
+ configurationAuthorizationEReference,
+ authorizationDataObject0);
+
+ configurationDataObject.eSet(
+ configurationAuthorizationsEReference,
+ userDataObjectAuthorizationList);
+
+
+ eDataGraph =
+ SDOFactory.
+ eINSTANCE.
+ createEDataGraph();
+
+ eDataGraph.setERootObject(userDataObject);
+
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/AbstractAttributeTypeCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/AbstractAttributeTypeCreator.java
new file mode 100644
index 0000000000..c021607a2c
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/AbstractAttributeTypeCreator.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.create;
+
+/**
+ * The Class AbstractAttributeTypeCreator.
+ */
+public abstract class AbstractAttributeTypeCreator
+extends AbstractTypeCreator
+{
+
+ public AbstractAttributeTypeCreator()
+ {
+ super();
+
+ objectClassAttribute.add( META_ATTRIBUTE_TYPE );
+ basicAttributes.put( M_COLLECTIVE, LDAP_FALSE );
+ basicAttributes.put( M_EQUALITY, M_EQUALITY__NAME_OR_NUMERIC_ID_MATCH );
+ basicAttributes.put( M_NO_USER_MODIFICATION, LDAP_FALSE);
+ basicAttributes.put( M_SINGLE_VALUE, LDAP_FALSE );
+ basicAttributes.put( M_USAGE, LDAP_USER_APPLICATIONS);
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/AbstractTypeCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/AbstractTypeCreator.java
new file mode 100644
index 0000000000..6fbf988646
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/AbstractTypeCreator.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.create;
+
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants;
+import org.apache.tuscany.das.ldap.schema.constants.EnumeratedSchemaAttributeTypeValues;
+import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants;
+import org.apache.tuscany.das.ldap.schema.constants.SchemaAttributeTypeConstants;
+import org.apache.tuscany.das.ldap.schema.constants.SchemaObjectClassConstants;
+
+public abstract class AbstractTypeCreator
+implements
+EnumeratedSchemaAttributeTypeValues,
+SchemaAttributeTypeConstants,
+AttributeTypeConstants,
+SchemaObjectClassConstants,
+ObjectClassConstants,
+DASConstants
+{
+ protected Attribute objectClassAttribute;
+ protected Attributes basicAttributes;
+
+ public AbstractTypeCreator()
+ {
+ objectClassAttribute =
+ new BasicAttribute(
+ OBJECT_CLASS, TOP );
+
+ objectClassAttribute.add(
+ META_TOP );
+
+ basicAttributes = new BasicAttributes();
+ basicAttributes.put(objectClassAttribute);
+ basicAttributes.put( M_OBSOLETE, LDAP_FALSE );
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/ComplexTypeRDNCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/ComplexTypeRDNCreator.java
new file mode 100644
index 0000000000..47e3e8a716
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/ComplexTypeRDNCreator.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.create;
+
+import org.apache.tuscany.das.ldap.oid.create.ComplexTypeOIDCreator;
+import org.apache.tuscany.das.ldap.schema.constants.SchemaAttributeTypeConstants;
+
+/**
+ * The Class DataTypeRDNCreator.
+ */
+public class ComplexTypeRDNCreator
+implements SchemaAttributeTypeConstants
+{
+ /**
+ * Create.
+ *
+ * @param oidPrefix the oid prefix
+ * @param namespaceURI the namespace URI
+ * @param complexTypeName the complex type name
+ *
+ * @return the string that is the rdn
+ *
+ * @throws Exception the exception
+ */
+ public static String create(
+ String oidPrefix,
+ String namespaceURI,
+ String complexTypeName
+ )
+ throws Exception
+ {
+ String oid =
+ ComplexTypeOIDCreator.create(
+ oidPrefix,
+ namespaceURI,
+ complexTypeName );
+
+ String rdn =
+ M_OID + "=" + oid;
+
+ return rdn;
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SimpleTypeRDNCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SimpleTypeRDNCreator.java
new file mode 100644
index 0000000000..6e8eaba018
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SimpleTypeRDNCreator.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.create;
+
+import org.apache.tuscany.das.ldap.oid.create.SimpleTypeOIDCreator;
+import org.apache.tuscany.das.ldap.schema.constants.SchemaAttributeTypeConstants;
+
+/**
+ * The Class DataTypeRDNCreator.
+ */
+public class SimpleTypeRDNCreator
+implements SchemaAttributeTypeConstants
+{
+
+ /**
+ * Create.
+ *
+ * @param oidPrefix the oid prefix
+ * @param namespaceURI the namespace URI
+ * @param complexTypeName the name
+ * @param simpleTypeName the simple type name
+ *
+ * @return the string
+ *
+ * @throws Exception the exception
+ */
+ public static String create(
+ String oidPrefix,
+ String namespaceURI,
+ String complexTypeName,
+ String simpleTypeName)
+ throws Exception
+ {
+ String oid =
+ SimpleTypeOIDCreator.create(
+ oidPrefix,
+ namespaceURI,
+ complexTypeName,
+ simpleTypeName);
+
+ String rdn =
+ M_OID + "=" + oid;
+
+ return rdn;
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SyntaxCheckerEntryCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SyntaxCheckerEntryCreator.java
new file mode 100644
index 0000000000..6b115fd71f
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SyntaxCheckerEntryCreator.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.create;
+
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants;
+import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants;
+import org.apache.tuscany.das.ldap.schema.constants.SchemaAttributeTypeConstants;
+import org.apache.tuscany.das.ldap.schema.constants.SchemaObjectClassConstants;
+
+/**
+ * The Class SyntaxEntryCreator.
+ */
+public class SyntaxCheckerEntryCreator
+implements
+AttributeTypeConstants,
+SchemaAttributeTypeConstants,
+ObjectClassConstants,
+SchemaObjectClassConstants
+{
+ /**
+ * Create.
+ *
+ * @param oidPrefix the oid prefix
+ * @param namespaceURI the namespace URI
+ * @param dataTypeName the name of the DataType
+ * @param syntaxesContext the directory context
+ *
+ * @throws Exception the exception
+ */
+ public static void create(
+ String rdn,
+ LdapContext syntaxCheckerContext)
+ throws Exception
+ {
+
+ Attributes attributes =
+ prepareSyntaxCheckerAttributes();
+
+ syntaxCheckerContext.createSubcontext(
+ rdn,
+ attributes);
+ }
+
+ /**
+ * TODO - Move to helper
+ * Prepare SyntaxChecker attributes.
+ *
+ * @return the attributes
+ */
+ public static Attributes prepareSyntaxCheckerAttributes()
+ {
+ Attribute objectClassAttribute =
+ new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add( META_TOP );
+ objectClassAttribute.add( META_SYNTAX_CHECKER );
+
+ Attribute fqcnAttribute =
+ new BasicAttribute(
+ M_FQCN,
+ M_FQCN_DEFAULT_VALUE);
+
+ Attributes attributes = new BasicAttributes();
+
+ attributes.put( objectClassAttribute );
+ attributes.put( fqcnAttribute );
+
+ return attributes;
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SyntaxEntryCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SyntaxEntryCreator.java
new file mode 100644
index 0000000000..024ef1e7b9
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SyntaxEntryCreator.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.create;
+
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants;
+import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants;
+import org.apache.tuscany.das.ldap.schema.constants.SchemaAttributeTypeConstants;
+import org.apache.tuscany.das.ldap.schema.constants.SchemaObjectClassConstants;
+import org.apache.tuscany.das.ldap.util.ComplexTypeNamespaceQualifier;
+
+/**
+ * The Class SyntaxEntryCreator.
+ */
+public class SyntaxEntryCreator
+implements
+AttributeTypeConstants,
+SchemaAttributeTypeConstants,
+ObjectClassConstants,
+SchemaObjectClassConstants
+{
+ /**
+ * Create.
+ *
+ * @param oidPrefix the oid prefix
+ * @param namespaceURI the namespace URI
+ * @param dataTypeName the name of the DataType
+ * @param syntaxesContext the directory context
+ *
+ * @throws Exception the exception
+ */
+ public static void create(
+ String oidPrefix,
+ String namespaceURI,
+ String dataTypeName,
+ LdapContext syntaxesContext,
+ LdapContext syntaxCheckersContext)
+ throws Exception
+ {
+ String syntaxDescription =
+ ComplexTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ dataTypeName);
+
+ String rdn =
+ ComplexTypeRDNCreator.
+ create(
+ oidPrefix,
+ namespaceURI,
+ dataTypeName);
+
+ Attributes syntaxAttributes =
+ prepareSyntaxAttributes(
+ syntaxDescription );
+
+ Attributes syntaxCheckerAttributes =
+ prepareSyntaxCheckerAttributes();
+
+ //TODO Put back in when bug gets resolved.
+ //TODO Remember to apply the namespace qualifier or we could just leave because it's in the description effectively
+ //attributes.put(M_NAME, name );
+ //attributes.put("x-humandReadible", "false");
+ //attributes.put("m-obsolete, "false");
+ syntaxesContext.createSubcontext(
+ rdn,
+ syntaxAttributes);
+
+ syntaxCheckersContext.createSubcontext(
+ rdn,
+ syntaxCheckerAttributes);
+ }
+
+ /**
+ * TODO - Move to helper
+ * TODO - Optimize - we are prepping these each time when they could be cached
+ * Prepare syntax attributes.
+ *
+ * @param syntaxDescription the syntax description
+ *
+ * @return the attributes
+ */
+ public static Attributes prepareSyntaxAttributes(
+ String syntaxDescription)
+ {
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS, TOP);
+ objectClassAttribute.add( META_TOP );
+ objectClassAttribute.add( META_SYNTAX );
+
+ Attribute descriptionAttribute = new BasicAttribute(
+ M_DESCRIPTION,
+ syntaxDescription);
+
+ Attributes attributes = new BasicAttributes();
+
+ attributes.put( objectClassAttribute );
+ attributes.put( descriptionAttribute );
+
+ return attributes;
+ }
+
+ /**
+ * TODO - Move to helper
+ * TODO - Optimize - we are prepping these each time when they could be cached
+ * Prepare SyntaxChecker attributes.
+ *
+ * @return the attributes
+ */
+ public static Attributes prepareSyntaxCheckerAttributes()
+ {
+ Attribute objectClassAttribute =
+ new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add( META_TOP );
+ objectClassAttribute.add( META_SYNTAX_CHECKER );
+
+ Attribute fqcnAttribute =
+ new BasicAttribute(
+ M_FQCN,
+ M_FQCN_DEFAULT_VALUE);
+
+ Attributes attributes = new BasicAttributes();
+
+ attributes.put( objectClassAttribute );
+ attributes.put( fqcnAttribute );
+
+ return attributes;
+ }
+
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetup.java
new file mode 100644
index 0000000000..010baa800b
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetup.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.embedded.setup.test;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.apacheds.testing.setup.ADSEmbeddedHotPartitionTemplate;
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants;
+import org.apache.tuscany.das.ldap.schema.constants.EnumeratedSchemaAttributeTypeValues;
+import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants;
+import org.apache.tuscany.das.ldap.schema.constants.SchemaAttributeTypeConstants;
+import org.apache.tuscany.das.ldap.schema.constants.SchemaObjectClassConstants;
+import org.apache.tuscany.das.ldap.testing.constants.DASTestingConstants;
+
+public abstract class AbstractTestSetup
+extends ADSEmbeddedHotPartitionTemplate
+implements
+EnumeratedSchemaAttributeTypeValues,
+SchemaAttributeTypeConstants,
+AttributeTypeConstants,
+SchemaObjectClassConstants,
+ObjectClassConstants,
+DASConstants,
+DASTestingConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ dasPartitionContext =
+ connect("das");
+
+ schemaPartitionContext =
+ connect("schema");
+ }
+
+ protected LdapContext schemaPartitionContext =
+ null;
+
+ protected LdapContext dasPartitionContext =
+ null;
+
+ protected static final String SYNTAXES_CONTEXT_RDN =
+ OU + "=" + SYNTAXES_CONTEXT_NAME;
+
+ protected static final String SYNTAX_CHECKERS_CONTEXT_RDN =
+ OU + "=" + SYNTAX_CHECKERS_CONTEXT_NAME;
+
+ protected static final String ATTRIBUTE_TYPES_CONTEXT_RDN =
+ OU + "=" + ATTRIBUTE_TYPES_CONTEXT_NAME;
+
+ protected static final String OBJECT_CLASSES_CONTEXT_RDN =
+ OU + "=" + OBJECT_CLASSES_CONTEXT_NAME;
+
+
+
+ protected static final String XSD_CONTEXT_RDN =
+ CN + "=" + XSD_CONTEXT_NAME;
+ protected static final String DAS_CONTEXT_RDN =
+ CN + "=" + DAS_CONTEXT_NAME;
+ protected static final String ECORE_CONTEXT_RDN =
+ CN + "=" + ECORE_CONTEXT_NAME;
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetupTest.java
new file mode 100644
index 0000000000..6477225e1c
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetupTest.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.embedded.setup.test;
+
+import javax.naming.NamingException;
+
+public class AbstractTestSetupTest
+extends AbstractTestSetup
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ dasPartitionContext =
+ connect("das");
+ schemaPartitionContext =
+ connect("schema");
+ }
+
+ public void testConnect() throws NamingException
+ {
+ assertNotNull(dasPartitionContext);
+ assertNotNull(schemaPartitionContext);
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetup.java
new file mode 100644
index 0000000000..fafd0144fb
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetup.java
@@ -0,0 +1,47 @@
+package org.apache.tuscany.das.ldap.schema.embedded.setup.test;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.create.InitialContextCreator;
+import org.apache.tuscany.das.ldap.create.MetaContextCreator;
+import org.apache.tuscany.das.ldap.destroy.InitialContextDestroyer;
+import org.apache.tuscany.das.ldap.destroy.MetaContextDestroyer;
+
+public class DASContextSetup
+extends AbstractTestSetup
+implements DASConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ MetaContextDestroyer.
+ destroy( modelContext );
+
+ InitialContextDestroyer.
+ destroy(
+ modelContext,
+ dasPartitionContext );
+ super.tearDown();
+
+ dasPartitionContext.close();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ modelContext =
+ InitialContextCreator.
+ create(
+ xsdNamespace,
+ dasPartitionContext);
+
+ metaContext =
+ MetaContextCreator.
+ create( modelContext);
+ }
+
+ protected LdapContext modelContext = null;
+ protected LdapContext metaContext = null;
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetupTest.java
new file mode 100644
index 0000000000..d6ecc250c6
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetupTest.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.embedded.setup.test;
+
+import javax.naming.NamingException;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+
+public class DASContextSetupTest
+extends DASContextSetup
+implements DASConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ }
+
+ public void testModelContext() throws NamingException
+ {
+ assertNotNull(modelContext);
+ assertEquals(
+ "cn=accounts,cn=users,cn=example,cn=com,ou=das",
+ modelContext.getNameInNamespace());
+ }
+
+ public void testMetaContext() throws NamingException
+ {
+ assertNotNull(metaContext);
+ assertEquals("cn=meta,cn=accounts,cn=users,cn=example,cn=com,ou=das",
+ metaContext.getNameInNamespace());
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetup.java
new file mode 100644
index 0000000000..da620aaf34
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetup.java
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.embedded.setup.test;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.schema.create.ComplexTypeRDNCreator;
+import org.apache.tuscany.das.ldap.schema.create.SimpleTypeRDNCreator;
+
+public class DASSchemaContextsSetup
+extends AbstractTestSetup
+implements DASConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ dasSyntaxesContext.close();
+
+ dasSchemaSubContext.destroySubcontext(
+ SYNTAXES_CONTEXT_RDN );
+
+ dasAttributeTypesContext.close();
+
+ dasSchemaSubContext.destroySubcontext(
+ ATTRIBUTE_TYPES_CONTEXT_RDN );
+
+ dasSchemaSubContext.destroySubcontext(
+ OBJECT_CLASSES_CONTEXT_RDN );
+
+ dasSchemaSubContext.close();
+
+ schemaPartitionContext.destroySubcontext(
+ DAS_CONTEXT_RDN );
+
+ schemaPartitionContext.close();
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ dasSchemaSubContext =
+ createDasSchemaSubContext();
+ dasSyntaxesContext =
+ createDasSyntaxesContext();
+ dasAttributeTypesContext =
+ createDasAttributeTypesContext();
+ dasObjectClassesContext =
+ createDasObjectClassesContext();
+
+ mComplexMayRDN =
+ SimpleTypeRDNCreator.create(
+ TUSCANY_OID_PREFIX_VALUE,
+ DAS_XSD_NAMESPACE,
+ M_META_TOP_SDO_OBJECT_CLASS,
+ M_COMPLEX_MAY);
+
+ mComplexMustRDN =
+ SimpleTypeRDNCreator.create(
+ TUSCANY_OID_PREFIX_VALUE,
+ DAS_XSD_NAMESPACE,
+ M_META_TOP_SDO_OBJECT_CLASS,
+ M_COMPLEX_MUST);
+
+ idRDN =
+ SimpleTypeRDNCreator.create(
+ TUSCANY_OID_PREFIX_VALUE,
+ DAS_XSD_NAMESPACE,
+ M_META_TOP_SDO_OBJECT_CLASS,
+ ID);
+
+ metaTopSDORDN =
+ ComplexTypeRDNCreator.create(
+ TUSCANY_OID_PREFIX_VALUE,
+ DAS_XSD_NAMESPACE,
+ M_META_TOP_SDO_OBJECT_CLASS);
+ }
+
+ private DirContext createDasSchemaSubContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(META_SCHEMA);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ CN,
+ DAS_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return schemaPartitionContext.createSubcontext(
+ DAS_CONTEXT_RDN, contextAttributes );
+ }
+
+ private DirContext createDasAttributeTypesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ OU,
+ ATTRIBUTE_TYPES_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return dasSchemaSubContext.createSubcontext(
+ ATTRIBUTE_TYPES_CONTEXT_RDN, contextAttributes );
+ }
+
+ private DirContext createDasSyntaxesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ OU,
+ SYNTAXES_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return dasSchemaSubContext.createSubcontext(
+ SYNTAXES_CONTEXT_RDN, contextAttributes );
+ }
+
+ private DirContext createDasObjectClassesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute attributeTypes = new BasicAttribute(
+ OU,
+ OBJECT_CLASSES_CONTEXT_NAME);
+
+ contextAttributes.put( attributeTypes );
+ contextAttributes.put( objectClassAttribute );
+
+ return dasSchemaSubContext.createSubcontext(
+ OBJECT_CLASSES_CONTEXT_RDN,
+ contextAttributes );
+ }
+
+ protected DirContext dasSchemaSubContext = null;
+ protected DirContext dasAttributeTypesContext = null;
+ protected DirContext dasSyntaxesContext = null;
+ protected DirContext dasObjectClassesContext = null;
+
+ protected String mComplexMayRDN = null;
+ protected String mComplexMustRDN = null;
+ protected String idRDN = null;
+ protected String metaTopSDORDN = null;
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetupTest.java
new file mode 100644
index 0000000000..9adbe07463
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetupTest.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.embedded.setup.test;
+
+import javax.naming.NamingException;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+
+public class DASSchemaContextsSetupTest
+extends DASSchemaContextsSetup
+implements DASConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ }
+
+ public void testCreateDASSchemaSubContext()
+ {
+ assertNotNull(dasSchemaSubContext);
+ }
+
+ public void testCreateDasAttributeTypesContext()
+ {
+ assertNotNull(dasAttributeTypesContext);
+ }
+
+ public void testCreateDasSyntaxesContext()
+ {
+ assertNotNull(dasSyntaxesContext);
+ }
+
+ public void testCreateDasObjectClassesContext()
+ {
+ assertNotNull(dasObjectClassesContext);
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetup.java
new file mode 100644
index 0000000000..4fdaaea4b2
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetup.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.embedded.setup.test;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.create.InitialContextCreator;
+import org.apache.tuscany.das.ldap.create.MetaContextCreator;
+import org.apache.tuscany.das.ldap.destroy.InitialContextDestroyer;
+import org.apache.tuscany.das.ldap.destroy.MetaContextDestroyer;
+
+/*
+ * TODO Document that the name of a root object cannot be "meta"
+ * TODO Change "meta" to meta-inf
+ */
+public class EcoreSchemaAndDASContextsSetup
+extends EcoreSchemaContextsSetup
+implements DASConstants
+{
+ public void tearDown()
+ throws NamingException, Exception
+ {
+ MetaContextDestroyer.
+ destroy( rootContext );
+
+ InitialContextDestroyer.
+ destroy(
+ rootContext,
+ dasPartitionContext );
+
+ super.tearDown();
+
+ dasPartitionContext.close();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+
+ rootContext =
+ (LdapContext)
+ InitialContextCreator.
+ create(
+ xsdNamespace,
+ dasPartitionContext);
+
+ metaContext =
+ (LdapContext)
+ MetaContextCreator.
+ create( rootContext);
+ }
+
+ protected LdapContext rootContext = null;
+ protected LdapContext metaContext = null;
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetupTest.java
new file mode 100644
index 0000000000..e272262998
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetupTest.java
@@ -0,0 +1,56 @@
+package org.apache.tuscany.das.ldap.schema.embedded.setup.test;
+
+import javax.naming.NamingException;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+
+public class EcoreSchemaAndDASContextsSetupTest
+extends EcoreSchemaAndDASContextsSetup
+implements DASConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ }
+
+ public void testConnect()
+ {
+ assertNotNull(schemaPartitionContext);
+ }
+
+ public void testCreateEcoreSchemaSubContext()
+ {
+ assertNotNull(ecoreSchemaSubContext);
+ }
+
+ public void testCreateEcoreObjectClassesContext()
+ {
+ assertNotNull(ecoreObjectClassesContext);
+ }
+
+ public void testCreateEcoreAttributeTypesContext()
+ {
+ assertNotNull(ecoreAttributeTypesContext);
+ }
+
+ public void testCreateEcoreSyntaxesContext()
+ {
+ assertNotNull(ecoreSyntaxesContext);
+ }
+
+ public void testCreateDasModelContext()
+ {
+ assertNotNull(rootContext);
+ }
+
+ public void testCreateDasMetaContext()
+ {
+ assertNotNull(metaContext);
+ }
+
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetup.java
new file mode 100644
index 0000000000..88bd21f318
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetup.java
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.embedded.setup.test;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+
+public class EcoreSchemaContextsSetup
+extends AbstractTestSetup
+implements DASConstants
+{
+ public void tearDown()
+ throws NamingException, Exception
+ {
+ ecoreSyntaxesContext.
+ close();
+
+ ecoreSchemaSubContext.
+ destroySubcontext(
+ SYNTAXES_CONTEXT_RDN );
+
+ ecoreSyntaxCheckersContext.
+ close();
+
+ ecoreSchemaSubContext.
+ destroySubcontext(
+ SYNTAX_CHECKERS_CONTEXT_RDN );
+
+ ecoreAttributeTypesContext.
+ close();
+ ecoreSchemaSubContext.
+ destroySubcontext(
+ ATTRIBUTE_TYPES_CONTEXT_RDN );
+
+ ecoreObjectClassesContext.
+ close();
+
+ ecoreSchemaSubContext.
+ destroySubcontext(
+ OBJECT_CLASSES_CONTEXT_RDN );
+
+ ecoreSchemaSubContext.
+ close();
+ schemaPartitionContext.
+ destroySubcontext(
+ ECORE_CONTEXT_RDN );
+
+ schemaPartitionContext.close();
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ ecoreSchemaSubContext = createEcoreSchemaSubContext();
+ ecoreSyntaxesContext = createEcoreSyntaxesContext();
+ ecoreSyntaxCheckersContext = createEcoreSyntaxCheckersContext();
+ ecoreObjectClassesContext = createEcoreObjectClassesContext();
+ ecoreAttributeTypesContext = createEcoreAttributeTypesContext();
+ }
+
+ private LdapContext createEcoreSchemaSubContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(META_SCHEMA);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ CN,
+ ECORE_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return (LdapContext)
+ schemaPartitionContext.createSubcontext(
+ ECORE_CONTEXT_RDN, contextAttributes );
+ }
+
+
+ private LdapContext createEcoreObjectClassesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ OU,
+ OBJECT_CLASSES_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return (LdapContext)
+ ecoreSchemaSubContext.createSubcontext(
+ OBJECT_CLASSES_CONTEXT_RDN, contextAttributes );
+ }
+
+
+
+ private LdapContext createEcoreAttributeTypesContext()
+ throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ OU,
+ ATTRIBUTE_TYPES_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return (LdapContext)
+ ecoreSchemaSubContext.createSubcontext(
+ ATTRIBUTE_TYPES_CONTEXT_RDN, contextAttributes );
+ }
+
+ private LdapContext createEcoreSyntaxesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ OU,
+ SYNTAXES_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return (LdapContext)
+ ecoreSchemaSubContext.createSubcontext(
+ SYNTAXES_CONTEXT_RDN, contextAttributes );
+ }
+
+ private LdapContext createEcoreSyntaxCheckersContext()
+ throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ OU,
+ SYNTAX_CHECKERS_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return (LdapContext)
+ ecoreSchemaSubContext.createSubcontext(
+ SYNTAX_CHECKERS_CONTEXT_RDN,
+ contextAttributes);
+ }
+
+ protected LdapContext ecoreSchemaSubContext = null;
+ protected LdapContext ecoreObjectClassesContext = null;
+ protected LdapContext ecoreAttributeTypesContext = null;
+ protected LdapContext ecoreSyntaxesContext = null;
+ protected LdapContext ecoreSyntaxCheckersContext = null;
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetupTest.java
new file mode 100644
index 0000000000..f2c746dceb
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetupTest.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.embedded.setup.test;
+
+import javax.naming.NamingException;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+
+public class EcoreSchemaContextsSetupTest
+extends EcoreSchemaContextsSetup
+implements DASConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ }
+
+ public void testCreateEcoreSchemaSubContext()
+ {
+ assertNotNull(ecoreSchemaSubContext);
+ }
+
+ public void testCreateEcoreObjectClassesContext()
+ {
+ assertNotNull(ecoreObjectClassesContext);
+ }
+
+ public void testCreateEcoreAttributeTypesContext()
+ {
+ assertNotNull(ecoreAttributeTypesContext);
+ }
+
+ public void testCreateEcoreSyntaxesContext()
+ {
+ assertNotNull(ecoreSyntaxesContext);
+ }
+
+ public void testCreateEcoreSyntaxCheckersContext()
+ {
+ assertNotNull(ecoreSyntaxCheckersContext);
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetup.java
new file mode 100644
index 0000000000..619bc7a94f
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetup.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.embedded.setup.test;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+
+public class XSDSchemaContextsSetup
+extends AbstractTestSetup
+implements DASConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ xsdSyntaxesContext.
+ close();
+
+ xsdContext.
+ destroySubcontext(
+ SYNTAXES_CONTEXT_RDN );
+
+ xsdContext.
+ close();
+
+ schemaPartitionContext.
+ destroySubcontext(
+ XSD_CONTEXT_RDN );
+
+ schemaPartitionContext.
+ close();
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ xsdContext =
+ createXsdContext();
+ xsdSyntaxesContext =
+ createXsdSyntaxesContext();
+ }
+
+ private LdapContext createXsdContext() throws NamingException
+ {
+ Attributes contextAttributes =
+ new BasicAttributes();
+
+ Attribute objectClassAttribute =
+ new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(META_SCHEMA);
+
+ Attribute ecoreAttribute =
+ new BasicAttribute(
+ CN,
+ XSD_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return (LdapContext) schemaPartitionContext.createSubcontext(
+ XSD_CONTEXT_RDN, contextAttributes );
+ }
+
+ private LdapContext createXsdSyntaxesContext() throws NamingException
+ {
+ Attributes contextAttributes =
+ new BasicAttributes();
+
+ Attribute objectClassAttribute =
+ new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute ecoreAttribute =
+ new BasicAttribute(
+ OU,
+ SYNTAXES_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return (LdapContext) xsdContext.createSubcontext(
+ SYNTAXES_CONTEXT_RDN, contextAttributes );
+ }
+ protected LdapContext xsdContext =
+ null;
+ protected LdapContext xsdSyntaxCheckersContext =
+ null;
+ protected LdapContext xsdSyntaxesContext =
+ null;
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetupTest.java
new file mode 100644
index 0000000000..24ce5e6df1
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetupTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.embedded.setup.test;
+
+import javax.naming.NamingException;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+
+public class XSDSchemaContextsSetupTest
+extends XSDSchemaContextsSetup
+implements DASConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ }
+
+ public void testCreateXsdContext()
+ {
+ assertNotNull(xsdContext);
+ }
+
+ public void testCreateXsdSyntaxesContext()
+ {
+ assertNotNull(xsdSyntaxesContext);
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/DataTypeToADSSyntaxMapProvider.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/DataTypeToADSSyntaxMapProvider.java
new file mode 100644
index 0000000000..8bd50fb4cc
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/DataTypeToADSSyntaxMapProvider.java
@@ -0,0 +1,54 @@
+package org.apache.tuscany.das.ldap.schema.emf.create;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.das.ldap.constants.SyntaxOIDValues;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EcorePackage;
+
+public class DataTypeToADSSyntaxMapProvider
+implements SyntaxOIDValues {
+
+ EcorePackage ecorePackage =
+ EcorePackage.eINSTANCE;
+
+ private static Map<EDataType, String> dataTypeToADSSyntaxOIDMap = null;
+
+ //TODO Make this a singleton
+ public DataTypeToADSSyntaxMapProvider()
+ {
+ dataTypeToADSSyntaxOIDMap = new HashMap<EDataType, String>();
+ create();
+ }
+
+ public Map<EDataType, String> getDataTypeToADSSyntaxMap()
+ {
+ return dataTypeToADSSyntaxOIDMap;
+ }
+
+ private Map<EDataType, String> create()
+ {
+ dataTypeToADSSyntaxOIDMap.put(
+ ecorePackage.getEString(),
+ SYNTAX_STRING_OID_VALUE);
+
+ dataTypeToADSSyntaxOIDMap.put(
+ ecorePackage.getEInt(),
+ SYNTAX_INTEGER_OID_VALUE);
+
+ dataTypeToADSSyntaxOIDMap.put(
+ ecorePackage.getEIntegerObject(),
+ SYNTAX_INTEGER_OID_VALUE);
+
+ dataTypeToADSSyntaxOIDMap.put(
+ ecorePackage.getEBoolean(),
+ SYNTAX_BOOLEAN_OID_VALUE);
+
+ dataTypeToADSSyntaxOIDMap.put(
+ ecorePackage.getEBooleanObject(),
+ SYNTAX_BOOLEAN_OID_VALUE);
+
+ return dataTypeToADSSyntaxOIDMap;
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EAttributeTypeCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EAttributeTypeCreator.java
new file mode 100644
index 0000000000..5b8e65c221
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EAttributeTypeCreator.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.emf.create;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+import org.apache.tuscany.das.ldap.schema.create.AbstractAttributeTypeCreator;
+import org.apache.tuscany.das.ldap.schema.create.SimpleTypeRDNCreator;
+import org.apache.tuscany.das.ldap.schema.emf.provide.SyntaxOIDProvider;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+
+public class EAttributeTypeCreator
+extends AbstractAttributeTypeCreator
+{
+ public EAttributeTypeCreator()
+ {
+ super();
+ }
+ /**
+ * Create.
+ *
+ * @param oidPrefix the oid prefix
+ * @param eAttribute the e attribute
+ * @param attributeTypesContext the attribute types context
+ *
+ * @throws Exception the exception
+ * @throws NamingException the naming exception
+ */
+ public void create(
+ DirContext attributeTypesContext,
+ EAttribute eAttribute,
+ String oidPrefix)
+ throws NamingException, Exception
+ {
+ String eAttributeName =
+ eAttribute.getName();
+
+ EClass eContainingClass =
+ eAttribute.getEContainingClass();
+
+ String eContainingClassName =
+ eContainingClass.getName();
+
+ String namespaceURI =
+ eContainingClass.
+ getEPackage().getNsURI();
+
+ String qualifiedEAttributeNameURI =
+ SimpleTypeNamespaceQualifier.qualify(
+ namespaceURI,
+ eContainingClassName,
+ eAttributeName);
+
+ String normalizedEAttributeName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEAttributeNameURI);
+
+ EClassifier eDataType =
+ eAttribute.getEType();
+
+ SyntaxOIDProvider dataTypeToADSSyntaxMapProvider =
+ new SyntaxOIDProvider();
+
+ String syntaxOID =
+ dataTypeToADSSyntaxMapProvider.
+ getSyntaxOID(eDataType);
+
+ basicAttributes.put(
+ M_DESCRIPTION,
+ eAttributeName);
+
+ basicAttributes.put(
+ M_SYNTAX,
+ syntaxOID);
+
+ basicAttributes.put(
+ M_NAME,
+ normalizedEAttributeName );
+
+ String rdn =
+ SimpleTypeRDNCreator.create(
+ oidPrefix,
+ namespaceURI,
+ eContainingClassName,
+ eAttributeName);
+
+ attributeTypesContext.createSubcontext(
+ rdn,
+ basicAttributes);
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreator.java
new file mode 100644
index 0000000000..684509e0d9
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreator.java
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.das.ldap.schema.emf.create;
+
+import java.util.List;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.DirContext;
+
+import org.apache.tuscany.das.ldap.schema.create.AbstractTypeCreator;
+import org.apache.tuscany.das.ldap.schema.create.ComplexTypeRDNCreator;
+import org.apache.tuscany.das.ldap.util.ComplexTypeNamespaceQualifier;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.eclipse.emf.ecore.EClass;
+
+public class EObjectClassCreator
+extends AbstractTypeCreator
+{
+ public EObjectClassCreator()
+ {
+ super();
+ }
+ /**
+ * Create.
+ *
+ * @param oidPrefix the oid prefix
+ * @param eAttribute the e attribute
+ * @param attributeTypesContext the attribute types context
+ *
+ * @throws Exception the exception
+ * @throws NamingException the naming exception
+ *
+ * Note that null can passed for the processedEClassifiers list
+ * only when the EClass has not parents.
+ */
+ public void create(
+ DirContext metaContext,
+ DirContext attributeTypesContext,
+ DirContext objectClassesContext,
+ EClass eClass,
+ List<EClass> processedEClassifiers,
+ String oidPrefix)
+ throws NamingException, Exception
+ {
+ if ( processedEClassifiers != null )
+ {
+ EClass eClassParent =
+ EcoreTypeSystemHelper.
+ getEClassParent( eClass );
+
+ if (eClassParent != null)
+ {
+ boolean isEClassProcessed =
+ EObjectClassCreatorHelper.
+ isEClassProcessed(
+ eClassParent,
+ processedEClassifiers);
+
+ if (!isEClassProcessed)
+ {
+ this.create(
+ metaContext,
+ attributeTypesContext,
+ objectClassesContext,
+ eClassParent,
+ processedEClassifiers,
+ oidPrefix);
+ }
+ }
+ }
+
+ objectClassAttribute.add( META_OBJECT_CLASS );
+
+ EcoreTypeSystemHelper.
+ createAttributeTypes(
+ attributeTypesContext,
+ eClass,
+ oidPrefix );
+
+ String namespaceURI =
+ eClass.getEPackage().
+ getNsURI();
+
+ String qualifiedEClassNameURI =
+ ComplexTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eClass.getName());
+
+ String normalizedEObjectName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEClassNameURI);
+
+
+ basicAttributes.put(
+ M_NAME,
+ normalizedEObjectName );
+
+ basicAttributes.put(
+ M_DESCRIPTION,
+ eClass.getName() );
+
+ basicAttributes.put(
+ M_OBSOLETE,
+ LDAP_FALSE );
+
+ //TODO Remember to test with parent combination.
+ EObjectClassCreatorHelper.
+ addParentAttribute(
+ basicAttributes,
+ namespaceURI,
+ eClass );
+
+ if (!eClass.isAbstract())
+ {
+ basicAttributes.put(
+ M_TYPE_OBJECT_CLASS,
+ STRUCTURAL );
+ }
+ else
+ {
+ basicAttributes.put(
+ M_TYPE_OBJECT_CLASS,
+ ABSTRACT );
+ }
+
+
+ /*
+ EObjectClassCreatorHelper.
+ addEAttributes(
+ basicAttributes,
+ namespaceURI,
+ eClass );
+
+ EObjectClassCreatorHelper.
+ addEReferences(
+ basicAttributes,
+ namespaceURI,
+ eClass );
+ */
+
+
+ EObjectClassCreatorHelper.
+ addEStructuralFeatures(
+ basicAttributes,
+ namespaceURI,
+ eClass );
+
+ String rdn =
+ ComplexTypeRDNCreator.
+ create(
+ oidPrefix,
+ namespaceURI,
+ eClass.getName());
+
+ EObjectClassCreatorHelper.
+ createInheritanceMetaData(
+ metaContext,
+ eClass );
+
+ /* TODO - Remove once everything is simmered down
+ NamingEnumeration namingEnumeration =
+ basicAttributes.getAll();
+
+ while (namingEnumeration.hasMore())
+ {
+ Attribute attribute = (Attribute) namingEnumeration.next();
+ System.out.println(attribute);
+ }
+ */
+
+
+ objectClassesContext.
+ createSubcontext(
+ rdn,
+ basicAttributes );
+
+
+ if ( processedEClassifiers != null )
+ {
+ processedEClassifiers.add(eClass);
+ }
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreatorHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreatorHelper.java
new file mode 100644
index 0000000000..2a99ef8fb8
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreatorHelper.java
@@ -0,0 +1,378 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.das.ldap.schema.emf.create;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.DirContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants;
+import org.apache.tuscany.das.ldap.schema.constants.EnumeratedSchemaAttributeTypeValues;
+import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants;
+import org.apache.tuscany.das.ldap.schema.constants.SchemaAttributeTypeConstants;
+import org.apache.tuscany.das.ldap.schema.constants.SchemaObjectClassConstants;
+import org.apache.tuscany.das.ldap.util.ComplexTypeNamespaceQualifier;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * The Class EObjectClassCreatorHelper.
+ */
+public class EObjectClassCreatorHelper
+implements
+EnumeratedSchemaAttributeTypeValues,
+SchemaAttributeTypeConstants,
+AttributeTypeConstants,
+SchemaObjectClassConstants,
+ObjectClassConstants,
+DASConstants
+{
+ /**
+ * Adds the parent attribute.
+ *
+ * @param namespaceURI the namespace URI
+ * @param objectClassAttributes the object class attributes
+ * @param eClass the e class
+ */
+ public static void addParentAttribute(
+ Attributes objectClassAttributes,
+ String namespaceURI,
+ EClass eClass)
+ {
+ EClass eClassParent =
+ EcoreTypeSystemHelper.getEClassParent( eClass );
+
+ if(eClassParent !=null)
+ {
+ String qualifiedEClassParentNameURI =
+ ComplexTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eClassParent.
+ getName());
+
+ String normalizedEObjectName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEClassParentNameURI);
+
+ objectClassAttributes.put(
+ M_SUP_OBJECT_CLASS,
+ normalizedEObjectName);
+ }
+ else
+ {
+ objectClassAttributes.put(
+ M_SUP_OBJECT_CLASS,
+ META_OBJECT_CLASS );
+ }
+ }
+
+ /**
+ * Adds the E attributes.
+ *
+ * @param namespaceURI the namespace URI
+ * @param objectClassAttributes the object class attributes
+ * @param eClass the e class
+ */
+ public static void addEAttributes(
+ Attributes objectClassAttributes,
+ String namespaceURI,
+ EClass eClass)
+ {
+ List<EAttribute> eAttributes =
+ eClass.getEAttributes();
+
+ Iterator<EAttribute> eAttributeIterator =
+ eAttributes.iterator();
+
+ EAttribute eAttribute =
+ null;
+
+ String qualifiedEAttributeName =
+ null;
+
+ Attribute mMayAttribute =
+ null;
+
+ Attribute mMustAttribute =
+ null;
+
+ while( eAttributeIterator.hasNext())
+ {
+ eAttribute = eAttributeIterator.next();
+
+ qualifiedEAttributeName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eClass.getName(),
+ eAttribute.getName());
+
+ String normalizedEAttributeName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEAttributeName);
+
+ if (!eAttribute.isRequired())
+ {
+ if (mMayAttribute == null)
+ {
+ mMayAttribute = new BasicAttribute(M_MAY);
+ }
+ mMayAttribute.add(normalizedEAttributeName);
+ }
+ else
+ {
+ if (mMustAttribute == null)
+ {
+ mMustAttribute = new BasicAttribute(M_MUST);
+ }
+ mMustAttribute.add(normalizedEAttributeName);
+ }
+ }
+
+ if (mMayAttribute != null)
+ {
+ objectClassAttributes.put( mMayAttribute );
+ }
+ if (mMustAttribute != null)
+ {
+ objectClassAttributes.put( mMustAttribute );
+ }
+ }
+
+ /**
+ * Adds the E references.
+ *
+ * @param namespaceURI the namespace URI
+ * @param objectClassAttributes the object class attributes
+ * @param eClass the e class
+ */
+ public static void addEReferences(
+ Attributes objectClassAttributes,
+ String namespaceURI,
+ EClass eClass)
+ {
+ List<EReference> eReferences =
+ eClass.getEReferences();
+
+ Iterator<EReference> eReferenceIterator =
+ eReferences.iterator();
+
+ EReference eReference =
+ null;
+
+ String qualifiedEReferenceName =
+ null;
+
+ Attribute mMayAttribute =
+ null;
+
+ Attribute mMustAttribute =
+ null;
+
+ while ( eReferenceIterator.hasNext())
+ {
+ eReference = eReferenceIterator.next();
+
+ qualifiedEReferenceName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eClass.getName(),
+ eReference.getName());
+
+ String normalizedEReferenceName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEReferenceName);
+
+ if (!eReference.isRequired())
+ {
+ if (mMayAttribute == null)
+ {
+ mMayAttribute = new BasicAttribute(M_MAY);
+ }
+ mMayAttribute.add( normalizedEReferenceName );
+ }
+ else
+ {
+ if (mMustAttribute == null)
+ {
+ mMustAttribute = new BasicAttribute(M_MUST);
+ }
+ mMustAttribute.add( normalizedEReferenceName );
+ }
+ }
+ if (mMayAttribute != null)
+ {
+ objectClassAttributes.put( mMayAttribute );
+ }
+ if (mMustAttribute != null)
+ {
+ objectClassAttributes.put( mMustAttribute );
+ }
+ }
+
+ /**
+ * Adds the E references.
+ *
+ * @param namespaceURI the namespace URI
+ * @param objectClassAttributes the object class attributes
+ * @param eClass the e class
+ */
+ public static void addEStructuralFeatures(
+ Attributes objectClassAttributes,
+ String namespaceURI,
+ EClass eClass)
+ {
+ List<EStructuralFeature> eStructuralFeatures =
+ eClass.getEStructuralFeatures();
+
+ Iterator<EStructuralFeature> eStructuralFeatureIterator =
+ eStructuralFeatures.iterator();
+
+ EStructuralFeature eStructuralFeature =
+ null;
+
+ String qualifiedEStructuralFeatureName =
+ null;
+
+ Attribute mMayAttribute =
+ null;
+
+ Attribute mMustAttribute =
+ null;
+
+ while ( eStructuralFeatureIterator.hasNext())
+ {
+ eStructuralFeature =
+ eStructuralFeatureIterator.next();
+
+ qualifiedEStructuralFeatureName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eClass.getName(),
+ eStructuralFeature.getName());
+
+ String normalizedEStructuralFeatureName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEStructuralFeatureName);
+
+
+ if (!eStructuralFeature.isRequired())
+ {
+ if (mMayAttribute == null)
+ {
+ mMayAttribute = new BasicAttribute(M_MAY);
+ }
+ mMayAttribute.add( normalizedEStructuralFeatureName );
+ }
+ else
+ {
+ if (mMustAttribute == null)
+ {
+ mMustAttribute = new BasicAttribute(M_MUST);
+ }
+ mMustAttribute.add( normalizedEStructuralFeatureName );
+ }
+ }
+ if (mMayAttribute != null)
+ {
+ objectClassAttributes.put( mMayAttribute );
+ }
+ if (mMustAttribute != null)
+ {
+ objectClassAttributes.put( mMustAttribute );
+ }
+
+ }
+
+
+ /**
+ * Checks if is E class processed.
+ *
+ * @param processedEClassifiers the processed E classifiers
+ * @param eClass the e class
+ *
+ * @return true, if is E class processed
+ */
+ public static boolean isEClassProcessed(
+ EClass eClass,
+ List<EClass> processedEClassifiers)
+ {
+ return processedEClassifiers.contains( eClass );
+ }
+
+ /**
+ * Creates the inheritance meta data.
+ *
+ * @param metaContext the das model meta context
+ * @param eClass the e class
+ *
+ * @throws NamingException the naming exception
+ */
+ public static void createInheritanceMetaData(
+ DirContext metaContext,
+ EClass eClass)
+ throws NamingException
+ {
+ EClass eClassParent =
+ EcoreTypeSystemHelper.getEClassParent( eClass );
+
+ String rdn = null;
+
+ if (eClassParent != null)
+ {
+ DirContext eClassParentMetaContext =
+ null;
+ try
+ {
+ eClassParentMetaContext =
+ ( DirContext )
+ metaContext.
+ lookup(eClassParent.getName());
+ }
+ catch ( NamingException e )
+ {
+ rdn =
+ CN + "=" + eClassParent.getName();
+
+ eClassParentMetaContext =
+ ( DirContext )
+ metaContext.
+ createSubcontext( rdn );
+ }
+
+ rdn = CN + "=" + eClass.getName();
+
+ eClassParentMetaContext.
+ createSubcontext( rdn );
+ }
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EReferenceTypeCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EReferenceTypeCreator.java
new file mode 100644
index 0000000000..74c7faff71
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EReferenceTypeCreator.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.das.ldap.schema.emf.create;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+import org.apache.tuscany.das.ldap.constants.SyntaxOIDValues;
+import org.apache.tuscany.das.ldap.schema.create.AbstractAttributeTypeCreator;
+import org.apache.tuscany.das.ldap.schema.create.SimpleTypeRDNCreator;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EReference;
+
+public class EReferenceTypeCreator
+extends AbstractAttributeTypeCreator
+implements SyntaxOIDValues
+{
+ public EReferenceTypeCreator()
+ {
+ super();
+ }
+
+ public void create(
+ DirContext attributeTypesContext,
+ EReference eReference,
+ String oidPrefix)
+ throws NamingException, Exception
+ {
+ String eReferenceName =
+ eReference.getName();
+
+ EClass eContainingClass =
+ eReference.getEContainingClass();
+
+ String eContainingClassName =
+ eContainingClass.getName();
+
+ String namespaceURI =
+ eContainingClass.
+ getEPackage().
+ getNsURI();
+
+ String qualifiedEReferenceNameURI =
+ SimpleTypeNamespaceQualifier.qualify(
+ namespaceURI,
+ eContainingClassName,
+ eReferenceName);
+
+
+ String normalizedEReferenceName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEReferenceNameURI);
+
+ basicAttributes.put(
+ M_DESCRIPTION,
+ eReferenceName);
+
+ basicAttributes.put(
+ M_SYNTAX,
+ SYNTAX_STRING_OID_VALUE);
+
+ basicAttributes.put(
+ M_NAME,
+ normalizedEReferenceName );
+
+ String rdn =
+ SimpleTypeRDNCreator.create(
+ oidPrefix,
+ namespaceURI,
+ eContainingClassName,
+ eReferenceName);
+
+ attributeTypesContext.createSubcontext(
+ rdn,
+ basicAttributes);
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EcoreTypeSystemHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EcoreTypeSystemHelper.java
new file mode 100644
index 0000000000..b9e8fac0fa
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EcoreTypeSystemHelper.java
@@ -0,0 +1,388 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.emf.create;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Stack;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.schema.create.SyntaxEntryCreator;
+import org.apache.tuscany.das.ldap.schema.emf.destroy.EStructuralFeatureTypeDestroyer;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * The Class EcoreTypeSystemCreatorHelper.
+ */
+public class EcoreTypeSystemHelper
+{
+
+ /**
+ * Creates the E data types list.
+ *
+ * @param ePackage the e package
+ *
+ * @return the list< E data type>
+ */
+ public static List<EDataType> createEDataTypesList(
+ EPackage ePackage)
+ {
+ List<EObject> list = ePackage.eContents();
+ List<EDataType> eDataTypes = new ArrayList<EDataType>();
+ Iterator<EObject> iterator = list.iterator();
+ while (iterator.hasNext())
+ {
+ Object object = iterator.next();
+ if (object instanceof EDataType )
+ {
+ eDataTypes.add( ( EDataType ) object );
+ }
+ }
+ return eDataTypes;
+ }
+
+ public static void createSyntaxCheckerEntries(
+ String oidPrefix,
+ LdapContext syntaxCheckersContext) throws Exception
+
+ {
+
+ }
+
+ /**
+ * Creates the syntax entries.
+ *
+ * @param oidPrefix the oid prefix
+ * @param eDataTypes the e data types
+ * @param syntaxesContext the syntaxes context
+ *
+ * @throws Exception the exception
+ */
+ public static void createSyntaxEntries(
+ List<EDataType> eDataTypes,
+ String oidPrefix,
+ LdapContext syntaxesContext,
+ LdapContext syntaxCheckersContext) throws Exception
+ {
+ Iterator<EDataType> eDataTypeIterator =
+ eDataTypes.iterator();
+
+ String eDataTypeName =
+ null;
+ String eDataTypeNamespaceURI =
+ null;
+
+ while (eDataTypeIterator.hasNext())
+ {
+ EDataType eDataType =
+ eDataTypeIterator.next();
+ eDataTypeName =
+ eDataType.getName();
+ eDataTypeNamespaceURI =
+ eDataType.getEPackage().getNsURI();
+
+ SyntaxEntryCreator.create(
+ oidPrefix,
+ eDataTypeNamespaceURI,
+ eDataTypeName,
+ syntaxesContext,
+ syntaxCheckersContext);
+ }
+ }
+
+ /**
+ * Creates the E classifiers list.
+ *
+ * @param ePackage the e package
+ *
+ * @return the list< E class>
+ */
+ public static List<EClass> createEClassifiersList(
+ EPackage ePackage)
+ {
+ List<EObject> list = ePackage.eContents();
+ List<EClass> eClassifiers = new ArrayList<EClass>();
+ Iterator<EObject> iterator = list.iterator();
+ while (iterator.hasNext())
+ {
+ Object object = iterator.next();
+ if (object instanceof EClassifier )
+ {
+ eClassifiers.add( ( EClass ) object );
+ }
+ }
+ return eClassifiers;
+ }
+
+ /**
+ * Creates the E classifier entries.
+ *
+ * @param eClassifiers the e classifiers
+ */
+ public static void createEClassifierEntries(
+ List<EClass> eClassifiers)
+ {
+
+ }
+
+ /**
+ * Load parent E classifier stack.
+ *
+ * @param parentEClassifierStack the parent E classifier stack
+ * @param eClass the e class
+ *
+ * @return the stack< E class>
+ *
+ * Note that clients should pass null for the
+ * parentEClassifierStack argument. The method
+ * creates the stack when needed, and uses
+ * it during recursion.
+ */
+ public static Stack<EClass> loadParentEClassifierStack(
+ EClass eClass,
+ Stack<EClass> parentEClassifierStack)
+ {
+ List<EClass> eClassParents =
+ eClass.getESuperTypes();
+
+ if (eClassParents.size() > 0)
+ {
+ Iterator<EClass> eClassParentIterator =
+ eClassParents.iterator();
+
+ while(eClassParentIterator.hasNext())
+ {
+ EClass parentEClass =
+ eClassParentIterator.next();
+
+ if (!parentEClass.isInterface())
+ {
+ if (parentEClassifierStack == null)
+ {
+ parentEClassifierStack = new Stack<EClass>();
+ }
+
+ parentEClassifierStack.push( parentEClass );
+
+ eClassParents = parentEClass.getESuperTypes();
+
+ if (eClassParents.size() == 0)
+ {
+ return parentEClassifierStack;
+ }
+ else
+ {
+ loadParentEClassifierStack(
+ parentEClass,
+ parentEClassifierStack );
+ }
+ }
+ }
+ }
+ return parentEClassifierStack;
+ }
+
+ /**
+ * Creates the E object class parents.
+ *
+ * @param oidPrefix the oid prefix
+ * @param objectClassesContext the object classes context
+ * @param eClass the e class
+ *
+ * @throws Exception the exception
+ * @throws NamingException the naming exception
+ */
+ public static void createEObjectClassParents(
+ DirContext dasModelMetaContext,
+ DirContext attributeTypesContext,
+ DirContext objectClassesContext,
+ EClass eClass,
+ String oidPrefix)
+ throws NamingException, Exception
+ {
+ Stack<EClass> parentEClassifierStack =
+ EcoreTypeSystemHelper.
+ loadParentEClassifierStack(
+ eClass,
+ null);
+
+ EClass parentEClass = null;
+
+ for (int i=0; i<parentEClassifierStack.size(); i++)
+ {
+ parentEClass = parentEClassifierStack.pop();
+
+ EObjectClassCreator
+ eObjectClassCreator =
+ new EObjectClassCreator();
+
+ eObjectClassCreator.create(
+ dasModelMetaContext,
+ attributeTypesContext,
+ objectClassesContext,
+ parentEClass,
+ null,
+ oidPrefix);
+ }
+ }
+
+ /**
+ * Creates the attribute types.
+ *
+ * @param oidPrefix the oid prefix
+ * @param eClass the e class
+ * @param attributeTypesContext the attribute types context
+ *
+ * @throws Exception the exception
+ * @throws NamingException the naming exception
+ */
+ public static void createAttributeTypes(
+ DirContext attributeTypesContext,
+ EClass eClass,
+ String oidPrefix)
+ throws NamingException, Exception
+ {
+ List<EAttribute> eAttributes =
+ eClass.getEAttributes();
+
+ Iterator<EAttribute> eAttributeIterator =
+ eAttributes.iterator();
+
+ while (eAttributeIterator.hasNext())
+ {
+ EAttribute eAttribute = eAttributeIterator.next();
+
+ EAttributeTypeCreator
+ eAttributeTypeCreator =
+ new EAttributeTypeCreator();
+
+ eAttributeTypeCreator.create(
+ attributeTypesContext,
+ eAttribute,
+ oidPrefix );
+ }
+
+ List<EReference> eReferences =
+ eClass.getEReferences();
+
+ Iterator<EReference> eReferenceIterator =
+ eReferences.iterator();
+
+ while(eReferenceIterator.hasNext())
+ {
+ EReference eReference =
+ eReferenceIterator.
+ next();
+
+ EReferenceTypeCreator
+ eReferenceTypeCreator =
+ new EReferenceTypeCreator();
+
+ eReferenceTypeCreator.create(
+ attributeTypesContext,
+ eReference,
+ oidPrefix);
+ }
+ }
+
+ /**
+ * Destroy attribute types.
+ *
+ * @param oidPrefix the oid prefix
+ * @param eClass the e class
+ * @param attributeTypesContext the attribute types context
+ *
+ * @throws Exception the exception
+ * @throws NamingException the naming exception
+ */
+ public static void destroyAttributeTypes(
+ DirContext attributeTypesContext,
+ EClass eClass,
+ String oidPrefix)
+ throws NamingException, Exception
+ {
+ List<EStructuralFeature>
+ eStructuralFeatures =
+ eClass.
+ getEStructuralFeatures();
+
+ Iterator<EStructuralFeature>
+ eStructuralFeatureIterator =
+ eStructuralFeatures.iterator();
+
+ while (eStructuralFeatureIterator.hasNext())
+ {
+ EStructuralFeature
+ eStructuralFeature =
+ eStructuralFeatureIterator.next();
+
+ EStructuralFeatureTypeDestroyer.destroy(
+ attributeTypesContext,
+ eStructuralFeature,
+ oidPrefix );
+ }
+ }
+
+ /**
+ * Gets the E class parent.
+ *
+ * @param eClass the e class
+ *
+ * @return the e class parent
+ */
+ public static EClass getEClassParent(EClass eClass)
+ {
+ List<EClass> eClassParents =
+ eClass.getESuperTypes();
+
+ if (eClassParents.size() > 0)
+ {
+ Iterator<EClass> eClassParentIterator =
+ eClassParents.iterator();
+
+ while(eClassParentIterator.hasNext())
+ {
+ EClass parentEClass =
+ eClassParentIterator.next();
+
+ if (!parentEClass.isInterface())
+ {
+ return parentEClass;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/ModelTypeSystemCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/ModelTypeSystemCreator.java
new file mode 100644
index 0000000000..3a92143dc5
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/ModelTypeSystemCreator.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.emf.create;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.ldap.LdapContext;
+
+import org.eclipse.emf.ecore.EClass;
+
+public class ModelTypeSystemCreator
+{
+ private static List<EClass> processedEClassifiers =
+ new ArrayList<EClass>();
+
+ public static void create(
+ LdapContext dasModelMetaContext,
+ LdapContext attributeTypesContext,
+ LdapContext objectClassesContext,
+ List<EClass> eClassifiers,
+ String oidPrefix)
+ throws Exception
+ {
+ EObjectClassCreator eObjectClassCreator =
+ new EObjectClassCreator();
+
+ for (EClass eClass : eClassifiers)
+ {
+ eObjectClassCreator.create(
+ dasModelMetaContext,
+ attributeTypesContext,
+ objectClassesContext,
+ eClass,
+ processedEClassifiers,
+ oidPrefix );
+ }
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/ECascadingObjectClassDestroyer.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/ECascadingObjectClassDestroyer.java
new file mode 100644
index 0000000000..1ad3a1eb21
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/ECascadingObjectClassDestroyer.java
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.das.ldap.schema.emf.destroy;
+
+import java.util.Map;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.SearchResult;
+
+import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants;
+import org.eclipse.emf.ecore.EClass;
+
+/**
+ * The Class ECascadingObjectClassDestroyer.
+ *
+ * The purose of this class is to destroy a ObjectClass
+ * that is the parent of other ObjectClass entries.
+ *
+ * It first checks to see whether the EClass instance
+ * is a parent of other EClassifiers by examining
+ * whether the metaContext contains the EClass
+ * instance's name.
+ *
+ * If the EClass instance has an an metaContext child entry,
+ * then this instance is a parent of other EClassifiers.
+ * Therefore we check to see whether there are EClass
+ * instances left to delete that inherit from this EClass.
+ *
+ * If none are left we delete the parentMetaContext entry.
+ * If there are more children left, we leave the parentMetaContext
+ * entry in place and delete the children.
+ *
+ * If there is no parentMetaEntryContext, it means that this
+ * EClass instance does not have any children. Therefore it's
+ * safe to delete the corresponding ObjectClass.
+ */
+public class ECascadingObjectClassDestroyer
+implements AttributeTypeConstants
+{
+
+
+ public static void destroy(
+ Map<String, EClass> eClassNameToEClassMap,
+ DirContext metaContext,
+ DirContext attributeTypesContext,
+ DirContext objectClassesContext,
+ EClass eClass,
+ String oidPrefix)
+ throws NamingException, Exception
+ {
+ String rdn =
+ null;
+ DirContext eClassParentMetaContext =
+ null;
+ try
+ {
+ eClassParentMetaContext =
+ ( DirContext )
+ metaContext.
+ lookup( CN + "=" + eClass.getName() );
+ }
+ catch (Exception e)
+ {
+ //This eClass can be deleted, because it is not used a super class.
+ }
+
+ if (eClassParentMetaContext == null)
+ {
+ EObjectClassDestroyer.destroy(
+ metaContext,
+ attributeTypesContext,
+ objectClassesContext,
+ eClass,
+ oidPrefix );
+ }
+ else
+ {
+ Attributes searchAttributes =
+ new BasicAttributes(true);
+
+ searchAttributes.put(new BasicAttribute(CN));
+
+ NamingEnumeration<SearchResult> childEntries =
+ eClassParentMetaContext.search("", searchAttributes);
+
+ if (childEntries.hasMore())
+ {
+ while (childEntries.hasMore())
+ {
+ SearchResult childEntry =
+ childEntries.next();
+
+ Attributes childEntryAttributes =
+ childEntry.getAttributes();
+
+ String eClassName =
+ ( String )
+ childEntryAttributes.get( CN ).get();
+
+ EClass childEClass =
+ eClassNameToEClassMap.get( eClassName );
+
+ destroy(
+ eClassNameToEClassMap,
+ metaContext,
+ attributeTypesContext,
+ objectClassesContext,
+ childEClass,
+ oidPrefix );
+
+ EObjectClassDestroyer.destroy(
+ metaContext,
+ attributeTypesContext,
+ objectClassesContext,
+ eClass,
+ oidPrefix );
+
+ rdn = CN + "=" + eClass.getName();
+ metaContext.destroySubcontext( rdn );
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EObjectClassDestroyer.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EObjectClassDestroyer.java
new file mode 100644
index 0000000000..16c7f893d6
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EObjectClassDestroyer.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.das.ldap.schema.emf.destroy;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants;
+import org.apache.tuscany.das.ldap.schema.create.ComplexTypeRDNCreator;
+import org.apache.tuscany.das.ldap.schema.emf.create.EcoreTypeSystemHelper;
+import org.eclipse.emf.ecore.EClass;
+
+/**
+ * The Class EObjectClassDestroyer.
+ */
+public class EObjectClassDestroyer
+implements AttributeTypeConstants
+{
+ public static void destroy(
+ DirContext metaContext,
+ DirContext attributeTypesContext,
+ DirContext objectClassesContext,
+ EClass eClass,
+ String oidPrefix)
+ throws NamingException, Exception
+ {
+ String namespaceURI =
+ eClass.getEPackage().
+ getNsURI();
+
+ String rdn =
+ ComplexTypeRDNCreator.
+ create(
+ oidPrefix,
+ namespaceURI,
+ eClass.getName());
+
+ objectClassesContext.
+ destroySubcontext(
+ rdn);
+
+ EcoreTypeSystemHelper.
+ destroyAttributeTypes(
+ attributeTypesContext,
+ eClass,
+ oidPrefix );
+
+ LdapContext parentMetaContext =
+ null;
+
+ EClass eClassParent =
+ EcoreTypeSystemHelper.
+ getEClassParent( eClass );
+
+ /*
+ * After destroying the ObjecClass and its attributes
+ * we must also clean up the meta context.
+ */
+
+ if (eClassParent != null)
+ {
+ rdn = CN + "=" + eClassParent.getName();
+
+ parentMetaContext =
+ ( LdapContext )
+ metaContext.lookup( rdn );
+
+ rdn = CN + "=" + eClass.getName();
+
+ parentMetaContext.destroySubcontext( rdn );
+ }
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EStructuralFeatureTypeDestroyer.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EStructuralFeatureTypeDestroyer.java
new file mode 100644
index 0000000000..2d88bc8803
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EStructuralFeatureTypeDestroyer.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.das.ldap.schema.emf.destroy;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+import org.apache.tuscany.das.ldap.schema.create.AbstractAttributeTypeCreator;
+import org.apache.tuscany.das.ldap.schema.create.SimpleTypeRDNCreator;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+public class EStructuralFeatureTypeDestroyer
+extends AbstractAttributeTypeCreator
+{
+ public static void destroy(
+ DirContext attributeTypesContext,
+ EStructuralFeature eStructuralFeature,
+ String oidPrefix)
+ throws NamingException, Exception
+ {
+ EClass eContainingClass =
+ eStructuralFeature.
+ getEContainingClass();
+
+ String eContainingClassName =
+ eContainingClass.
+ getName();
+
+ String namespaceURI =
+ eContainingClass.
+ getEPackage().
+ getNsURI();
+
+ String rdn =
+ SimpleTypeRDNCreator.create(
+ oidPrefix,
+ namespaceURI,
+ eContainingClassName,
+ eStructuralFeature.getName());
+
+ attributeTypesContext.destroySubcontext(
+ rdn);
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/provide/SyntaxOIDProvider.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/provide/SyntaxOIDProvider.java
new file mode 100644
index 0000000000..be0da66292
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/provide/SyntaxOIDProvider.java
@@ -0,0 +1,62 @@
+package org.apache.tuscany.das.ldap.schema.emf.provide;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.das.ldap.constants.SyntaxOIDValues;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EcorePackage;
+
+public class SyntaxOIDProvider
+implements SyntaxOIDValues {
+
+ private static Map<EClassifier, String> dataTypeToADSSyntaxOIDMap = null;
+
+ private EcorePackage ecorePackage = EcorePackage.eINSTANCE;
+
+ //TODO Make this a singleton
+ public SyntaxOIDProvider()
+ {
+ dataTypeToADSSyntaxOIDMap =
+ new HashMap<EClassifier, String>();
+
+ this.create();
+ ecorePackage =
+ EcorePackage.eINSTANCE;
+ }
+
+ public String getSyntaxOID(EClassifier eClassifier)
+ {
+ String syntaxOID = dataTypeToADSSyntaxOIDMap.get(eClassifier);
+ if (syntaxOID == null)
+ {
+ return SYNTAX_STRING_OID_VALUE;
+ }
+ return syntaxOID;
+ }
+
+ private Map<EClassifier, String> create()
+ {
+ dataTypeToADSSyntaxOIDMap.put(
+ EcorePackage.eINSTANCE.getEString(),
+ SYNTAX_STRING_OID_VALUE);
+
+ dataTypeToADSSyntaxOIDMap.put(
+ EcorePackage.eINSTANCE.getEInt(),
+ SYNTAX_INTEGER_OID_VALUE);
+
+ dataTypeToADSSyntaxOIDMap.put(
+ EcorePackage.eINSTANCE.getEIntegerObject(),
+ SYNTAX_INTEGER_OID_VALUE);
+
+ dataTypeToADSSyntaxOIDMap.put(
+ EcorePackage.eINSTANCE.getEBoolean(),
+ SYNTAX_BOOLEAN_OID_VALUE);
+
+ dataTypeToADSSyntaxOIDMap.put(
+ EcorePackage.eINSTANCE.getEBooleanObject(),
+ SYNTAX_BOOLEAN_OID_VALUE);
+
+ return dataTypeToADSSyntaxOIDMap;
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/AbstractTestSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/AbstractTestSetup.java
new file mode 100644
index 0000000000..95bbd23f8b
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/AbstractTestSetup.java
@@ -0,0 +1,50 @@
+
+package org.apache.tuscany.das.ldap.schema.setup.test;
+
+import javax.naming.directory.DirContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.apacheds.testing.setup.JNDIConnectionTemplate;
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants;
+import org.apache.tuscany.das.ldap.schema.constants.EnumeratedSchemaAttributeTypeValues;
+import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants;
+import org.apache.tuscany.das.ldap.schema.constants.SchemaAttributeTypeConstants;
+import org.apache.tuscany.das.ldap.schema.constants.SchemaObjectClassConstants;
+
+public abstract class AbstractTestSetup
+extends JNDIConnectionTemplate
+implements
+EnumeratedSchemaAttributeTypeValues,
+SchemaAttributeTypeConstants,
+AttributeTypeConstants,
+SchemaObjectClassConstants,
+ObjectClassConstants,
+DASConstants
+{
+ protected LdapContext schemaContext =
+ null;
+
+ protected static String PROVIDER_URL_VALUE =
+ "ldap://localhost:10389/ou=schema";
+
+ protected static final String SYNTAXES_CONTEXT_RDN =
+ OU + "=" + SYNTAXES_CONTEXT_NAME;
+
+ protected static final String ATTRIBUTE_TYPES_CONTEXT_RDN =
+ OU + "=" + ATTRIBUTE_TYPES_CONTEXT_NAME;
+
+ protected static final String OBJECT_CLASSES_CONTEXT_RDN =
+ OU + "=" + OBJECT_CLASSES_CONTEXT_NAME;
+
+ protected static final String XSD_CONTEXT_RDN =
+ CN + "=" + XSD_CONTEXT_NAME;
+ protected static final String DAS_CONTEXT_RDN =
+ CN + "=" + DAS_CONTEXT_NAME;
+ protected static final String ECORE_CONTEXT_RDN =
+ CN + "=" + ECORE_CONTEXT_NAME;
+
+ protected String xsdNamespace =
+ "http://example.com/users/accounts";
+
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASContextSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASContextSetup.java
new file mode 100644
index 0000000000..7eef04e56d
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASContextSetup.java
@@ -0,0 +1,56 @@
+package org.apache.tuscany.das.ldap.schema.setup.test;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.apacheds.testing.setup.JNDIHotPartitionConnectionTemplate;
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.create.InitialContextCreator;
+import org.apache.tuscany.das.ldap.create.MetaContextCreator;
+import org.apache.tuscany.das.ldap.destroy.InitialContextDestroyer;
+import org.apache.tuscany.das.ldap.destroy.MetaContextDestroyer;
+
+public class DASContextSetup
+extends JNDIHotPartitionConnectionTemplate
+implements DASConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ MetaContextDestroyer.
+ destroy( modelContext );
+
+ InitialContextDestroyer.
+ destroy(
+ modelContext,
+ dasPartitionContext );
+ super.tearDown();
+
+ dasPartitionContext.close();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ dasPartitionContext =
+ connect("das");
+
+ modelContext =
+ (LdapContext)
+ InitialContextCreator.
+ create(
+ xsdNamespace,
+ dasPartitionContext);
+
+ //Meta Context
+ //----------------------------------------------
+ metaContext =
+ (LdapContext) MetaContextCreator.
+ create(
+ modelContext);
+ }
+ protected LdapContext dasPartitionContext = null;
+ protected LdapContext modelContext = null;
+ protected LdapContext metaContext = null;
+ protected LdapContext schemaContext = null;
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASContextSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASContextSetupTest.java
new file mode 100644
index 0000000000..8e0d4674dc
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASContextSetupTest.java
@@ -0,0 +1,34 @@
+package org.apache.tuscany.das.ldap.schema.setup.test;
+
+import javax.naming.NamingException;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+
+public class DASContextSetupTest
+extends DASContextSetup
+implements DASConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ }
+
+ public void testCreateDASPartitionContext()
+ {
+ assertNotNull(dasPartitionContext);
+ }
+
+ public void testModelContext()
+ {
+ assertNotNull(modelContext);
+ }
+ public void testMetaContext()
+ {
+ assertNotNull(metaContext);
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASSchemaContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASSchemaContextsSetup.java
new file mode 100644
index 0000000000..9f4d2bb330
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASSchemaContextsSetup.java
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.schema.setup.test;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.schema.create.ComplexTypeRDNCreator;
+import org.apache.tuscany.das.ldap.schema.create.SimpleTypeRDNCreator;
+
+public class DASSchemaContextsSetup
+extends AbstractTestSetup
+implements DASConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ dasSyntaxesContext.close();
+
+ dasContext.destroySubcontext(
+ SYNTAXES_CONTEXT_RDN );
+
+ dasAttributeTypesContext.close();
+
+ dasContext.destroySubcontext(
+ ATTRIBUTE_TYPES_CONTEXT_RDN );
+
+ dasContext.destroySubcontext(
+ OBJECT_CLASSES_CONTEXT_RDN );
+
+ dasContext.close();
+
+ schemaContext.destroySubcontext(
+ DAS_CONTEXT_RDN );
+
+ schemaContext.close();
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ schemaContext = connect();
+ dasContext = (LdapContext) createDasContext();
+ dasSyntaxesContext = (LdapContext) createDasSyntaxesContext();
+ dasAttributeTypesContext = (LdapContext) createDasAttributeTypesContext();
+ dasObjectClassesContext = (LdapContext) createDasObjectClassesContext();
+
+ mComplexMayRDN =
+ SimpleTypeRDNCreator.create(
+ TUSCANY_OID_PREFIX_VALUE,
+ DAS_XSD_NAMESPACE,
+ M_META_TOP_SDO_OBJECT_CLASS,
+ M_COMPLEX_MAY);
+
+ mComplexMustRDN =
+ SimpleTypeRDNCreator.create(
+ TUSCANY_OID_PREFIX_VALUE,
+ DAS_XSD_NAMESPACE,
+ M_META_TOP_SDO_OBJECT_CLASS,
+ M_COMPLEX_MUST);
+
+ idRDN =
+ SimpleTypeRDNCreator.create(
+ TUSCANY_OID_PREFIX_VALUE,
+ DAS_XSD_NAMESPACE,
+ M_META_TOP_SDO_OBJECT_CLASS,
+ ID);
+
+
+ metaTopSDORDN =
+ ComplexTypeRDNCreator.create(
+ TUSCANY_OID_PREFIX_VALUE,
+ DAS_XSD_NAMESPACE,
+ M_META_TOP_SDO_OBJECT_CLASS);
+ }
+
+ private DirContext createDasContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(META_SCHEMA);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ CN,
+ DAS_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return schemaContext.createSubcontext(
+ DAS_CONTEXT_RDN, contextAttributes );
+ }
+
+ private DirContext createDasAttributeTypesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ OU,
+ ATTRIBUTE_TYPES_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return dasContext.createSubcontext(
+ ATTRIBUTE_TYPES_CONTEXT_RDN, contextAttributes );
+ }
+
+ private DirContext createDasSyntaxesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ OU,
+ SYNTAXES_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return dasContext.createSubcontext(
+ SYNTAXES_CONTEXT_RDN, contextAttributes );
+ }
+
+ private DirContext createDasObjectClassesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute attributeTypes = new BasicAttribute(
+ OU,
+ OBJECT_CLASSES_CONTEXT_NAME);
+
+ contextAttributes.put( attributeTypes );
+ contextAttributes.put( objectClassAttribute );
+
+ return dasContext.createSubcontext(
+ OBJECT_CLASSES_CONTEXT_RDN,
+ contextAttributes );
+ }
+
+ protected LdapContext dasContext = null;
+ protected LdapContext dasAttributeTypesContext = null;
+ protected LdapContext dasSyntaxesContext = null;
+ protected LdapContext dasObjectClassesContext = null;
+
+ protected String mComplexMayRDN = null;
+ protected String mComplexMustRDN = null;
+ protected String idRDN = null;
+ protected String metaTopSDORDN = null;
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASSchemaContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASSchemaContextsSetupTest.java
new file mode 100644
index 0000000000..35c1f79524
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASSchemaContextsSetupTest.java
@@ -0,0 +1,48 @@
+package org.apache.tuscany.das.ldap.schema.setup.test;
+
+import javax.naming.NamingException;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+
+public class DASSchemaContextsSetupTest
+extends DASSchemaContextsSetup
+implements DASConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ }
+
+
+ public void testConnect()
+ {
+ assertNotNull(schemaContext);
+ }
+
+ public void testCreateEcoreContext()
+ {
+ assertNotNull(dasContext);
+ }
+
+
+ public void testCreateDasAttributeTypesContext()
+ {
+ assertNotNull(dasAttributeTypesContext);
+ }
+
+ public void testCreateDasSyntaxesContext()
+ {
+ assertNotNull(dasSyntaxesContext);
+ }
+
+ public void testCreateDasObjectClassesContext()
+ {
+ assertNotNull(dasObjectClassesContext);
+ }
+
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaAndDASContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaAndDASContextsSetup.java
new file mode 100644
index 0000000000..6d9164c755
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaAndDASContextsSetup.java
@@ -0,0 +1,131 @@
+package org.apache.tuscany.das.ldap.schema.setup.test;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+
+public class EcoreSchemaAndDASContextsSetup
+extends DASContextSetup
+implements DASConstants
+{
+ public void tearDown()
+ throws NamingException, Exception
+ {
+ ecoreSyntaxesContext.close();
+ ecoreContext.destroySubcontext( SYNTAXES_CONTEXT_RDN );
+
+ ecoreAttributeTypesContext.close();
+ ecoreContext.destroySubcontext( ATTRIBUTE_TYPES_CONTEXT_RDN );
+
+ ecoreObjectClassesContext.close();
+ ecoreContext.destroySubcontext( OBJECT_CLASSES_CONTEXT_RDN );
+
+ ecoreContext.close();
+ schemaContext.destroySubcontext( ECORE_CONTEXT_RDN );
+
+ schemaContext.close();
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ schemaContext = connect("schema");
+ ecoreContext = createEcoreContext();
+ ecoreSyntaxesContext = createEcoreSyntaxesContext();
+ ecoreObjectClassesContext = createEcoreObjectClassesContext();
+ ecoreAttributeTypesContext = createEcoreAttributeTypesContext();
+ }
+
+ private DirContext createEcoreContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(META_SCHEMA);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ CN,
+ ECORE_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return schemaContext.createSubcontext(
+ ECORE_CONTEXT_RDN, contextAttributes );
+ }
+
+ private DirContext createEcoreObjectClassesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ OU,
+ OBJECT_CLASSES_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return ecoreContext.createSubcontext(
+ OBJECT_CLASSES_CONTEXT_RDN, contextAttributes );
+ }
+
+
+
+ private DirContext createEcoreAttributeTypesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ OU,
+ ATTRIBUTE_TYPES_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return ecoreContext.createSubcontext(
+ ATTRIBUTE_TYPES_CONTEXT_RDN, contextAttributes );
+ }
+
+
+ private DirContext createEcoreSyntaxesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ OU,
+ SYNTAXES_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return ecoreContext.createSubcontext(
+ SYNTAXES_CONTEXT_RDN, contextAttributes );
+ }
+
+ protected DirContext ecoreContext = null;
+ protected DirContext ecoreObjectClassesContext = null;
+ protected DirContext ecoreAttributeTypesContext = null;
+ protected DirContext ecoreSyntaxesContext = null;
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaAndDASContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaAndDASContextsSetupTest.java
new file mode 100644
index 0000000000..b7a7a7834b
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaAndDASContextsSetupTest.java
@@ -0,0 +1,56 @@
+package org.apache.tuscany.das.ldap.schema.setup.test;
+
+import javax.naming.NamingException;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+
+public class EcoreSchemaAndDASContextsSetupTest
+extends EcoreSchemaAndDASContextsSetup
+implements DASConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ }
+
+ public void testConnect()
+ {
+ assertNotNull(schemaContext);
+ }
+
+ public void testCreateEcoreContext()
+ {
+ assertNotNull(ecoreContext);
+ }
+
+ public void testCreateEcoreObjectClassesContext()
+ {
+ assertNotNull(ecoreObjectClassesContext);
+ }
+
+ public void testCreateEcoreAttributeTypesContext()
+ {
+ assertNotNull(ecoreAttributeTypesContext);
+ }
+
+ public void testCreateEcoreSyntaxesContext()
+ {
+ assertNotNull(ecoreSyntaxesContext);
+ }
+
+ public void testCreateDasModelContext()
+ {
+ assertNotNull(modelContext);
+ }
+
+ public void testCreateDasMetaContext()
+ {
+ assertNotNull(metaContext);
+ }
+
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaContextsSetup.java
new file mode 100644
index 0000000000..fb8ca08b5f
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaContextsSetup.java
@@ -0,0 +1,132 @@
+package org.apache.tuscany.das.ldap.schema.setup.test;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+
+public class EcoreSchemaContextsSetup
+extends AbstractTestSetup
+implements DASConstants
+{
+ public void tearDown()
+ throws NamingException, Exception
+ {
+ ecoreSyntaxesContext.close();
+ ecoreContext.destroySubcontext( SYNTAXES_CONTEXT_RDN );
+
+ ecoreAttributeTypesContext.close();
+ ecoreContext.destroySubcontext( ATTRIBUTE_TYPES_CONTEXT_RDN );
+
+ ecoreObjectClassesContext.close();
+ ecoreContext.destroySubcontext( OBJECT_CLASSES_CONTEXT_RDN );
+
+ ecoreContext.close();
+ schemaContext.destroySubcontext( ECORE_CONTEXT_RDN );
+
+ schemaContext.close();
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ schemaContext = connect();
+ ecoreContext = createEcoreContext();
+ ecoreSyntaxesContext = createEcoreSyntaxesContext();
+ ecoreObjectClassesContext = createEcoreObjectClassesContext();
+ ecoreAttributeTypesContext = createEcoreAttributeTypesContext();
+ }
+
+ private DirContext createEcoreContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(META_SCHEMA);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ CN,
+ ECORE_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return schemaContext.createSubcontext(
+ ECORE_CONTEXT_RDN, contextAttributes );
+ }
+
+
+ private DirContext createEcoreObjectClassesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ OU,
+ OBJECT_CLASSES_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return ecoreContext.createSubcontext(
+ OBJECT_CLASSES_CONTEXT_RDN, contextAttributes );
+ }
+
+
+
+ private DirContext createEcoreAttributeTypesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ OU,
+ ATTRIBUTE_TYPES_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return ecoreContext.createSubcontext(
+ ATTRIBUTE_TYPES_CONTEXT_RDN, contextAttributes );
+ }
+
+
+ private DirContext createEcoreSyntaxesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ OU,
+ SYNTAXES_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return ecoreContext.createSubcontext(
+ SYNTAXES_CONTEXT_RDN, contextAttributes );
+ }
+
+ protected DirContext ecoreContext = null;
+ protected DirContext ecoreObjectClassesContext = null;
+ protected DirContext ecoreAttributeTypesContext = null;
+ protected DirContext ecoreSyntaxesContext = null;
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaContextsSetupTest.java
new file mode 100644
index 0000000000..060f017e35
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaContextsSetupTest.java
@@ -0,0 +1,45 @@
+package org.apache.tuscany.das.ldap.schema.setup.test;
+
+import javax.naming.NamingException;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+
+public class EcoreSchemaContextsSetupTest
+extends EcoreSchemaContextsSetup
+implements DASConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ }
+
+ public void testConnect()
+ {
+ assertNotNull(schemaContext);
+ }
+
+ public void testCreateEcoreContext()
+ {
+ assertNotNull(ecoreContext);
+ }
+
+ public void testCreateEcoreObjectClassesContext()
+ {
+ assertNotNull(ecoreObjectClassesContext);
+ }
+
+ public void testCreateEcoreAttributeTypesContext()
+ {
+ assertNotNull(ecoreAttributeTypesContext);
+ }
+
+ public void testCreateEcoreSyntaxesContext()
+ {
+ assertNotNull(ecoreSyntaxesContext);
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextSetup.java
new file mode 100644
index 0000000000..11fb2a3af9
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextSetup.java
@@ -0,0 +1,21 @@
+package org.apache.tuscany.das.ldap.schema.setup.test;
+
+import javax.naming.NamingException;
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+
+public class SchemaContextSetup
+extends AbstractTestSetup
+implements DASConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ schemaContext.close();
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ schemaContext = connect();
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextSetupTest.java
new file mode 100644
index 0000000000..dacbf2b2ec
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextSetupTest.java
@@ -0,0 +1,25 @@
+package org.apache.tuscany.das.ldap.schema.setup.test;
+
+import javax.naming.NamingException;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+
+public class SchemaContextSetupTest
+extends SchemaContextSetup
+implements DASConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ }
+
+ public void testConnect()
+ {
+ assertNotNull(schemaContext);
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextsSetup.java
new file mode 100644
index 0000000000..92f86bc402
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextsSetup.java
@@ -0,0 +1,231 @@
+package org.apache.tuscany.das.ldap.schema.setup.test;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+
+public class SchemaContextsSetup
+extends AbstractTestSetup
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ dasSyntaxesContext.close();
+ dasContext.destroySubcontext( SYNTAXES_CONTEXT_RDN );
+
+ dasAttributeTypesContext.close();
+ dasContext.destroySubcontext( ATTRIBUTE_TYPES_CONTEXT_RDN );
+
+ dasObjectClassesContext.close();
+ dasContext.destroySubcontext( OBJECT_CLASSES_CONTEXT_RDN );
+ dasContext.close();
+
+ xsdSyntaxesContext.close();
+ xsdContext.destroySubcontext( SYNTAXES_CONTEXT_RDN );
+
+ xsdContext.close();
+ schemaContext.destroySubcontext( XSD_CONTEXT_RDN );
+
+ ecoreSyntaxesContext.close();
+ ecoreContext.destroySubcontext( SYNTAXES_CONTEXT_RDN );
+
+ ecoreContext.close();
+ schemaContext.destroySubcontext( ECORE_CONTEXT_RDN );
+
+ schemaContext.destroySubcontext( DAS_CONTEXT_RDN );
+ schemaContext.close();
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ schemaContext = connect();
+ dasContext = createDASContext();
+ dasSyntaxesContext = createSyntaxesContext();
+ dasAttributeTypesContext = createAttributeTypesContext();
+ dasObjectClassesContext = createObjectClassesContext();
+ xsdContext = createXSDContext();
+ xsdSyntaxesContext = createXSDSyntaxesContext();
+ ecoreContext = createEcoreContext();
+ ecoreSyntaxesContext = createEcoreSyntaxesContext();
+ }
+
+ private DirContext createDASContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(META_SCHEMA);
+
+ Attribute dasAttribute = new BasicAttribute(
+ CN,
+ DAS_CONTEXT_NAME);
+
+ contextAttributes.put( dasAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return schemaContext.createSubcontext(
+ DAS_CONTEXT_RDN, contextAttributes );
+ }
+
+
+ private DirContext createXSDContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(META_SCHEMA);
+
+ Attribute xsdAttribute = new BasicAttribute(
+ CN,
+ XSD_CONTEXT_NAME);
+
+ contextAttributes.put( xsdAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return schemaContext.createSubcontext(
+ XSD_CONTEXT_RDN, contextAttributes );
+ }
+
+ private DirContext createXSDSyntaxesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute xsdAttribute = new BasicAttribute(
+ OU,
+ SYNTAXES_CONTEXT_NAME);
+
+ contextAttributes.put( xsdAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return xsdContext.createSubcontext(
+ SYNTAXES_CONTEXT_RDN, contextAttributes );
+ }
+
+
+ private DirContext createEcoreContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(META_SCHEMA);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ CN,
+ ECORE_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return schemaContext.createSubcontext(
+ ECORE_CONTEXT_RDN, contextAttributes );
+ }
+
+
+ private DirContext createEcoreSyntaxesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ OU,
+ SYNTAXES_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return ecoreContext.createSubcontext(
+ SYNTAXES_CONTEXT_RDN, contextAttributes );
+ }
+
+ private DirContext createSyntaxesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute syntaxesRDNAttribute = new BasicAttribute(
+ OU,
+ SYNTAXES_CONTEXT_NAME);
+
+ contextAttributes.put( objectClassAttribute );
+ contextAttributes.put( syntaxesRDNAttribute );
+
+ return dasContext.createSubcontext(
+ SYNTAXES_CONTEXT_RDN, contextAttributes );
+ }
+
+
+ private DirContext createAttributeTypesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute attributeTypes = new BasicAttribute(
+ OU,
+ ATTRIBUTE_TYPES_CONTEXT_NAME);
+
+ contextAttributes.put( attributeTypes );
+ contextAttributes.put( objectClassAttribute );
+
+ return dasContext.createSubcontext(
+ ATTRIBUTE_TYPES_CONTEXT_RDN, contextAttributes );
+ }
+
+ private DirContext createObjectClassesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute attributeTypes = new BasicAttribute(
+ OU,
+ OBJECT_CLASSES_CONTEXT_NAME);
+
+ contextAttributes.put( attributeTypes );
+ contextAttributes.put( objectClassAttribute );
+
+ return dasContext.createSubcontext(
+ OBJECT_CLASSES_CONTEXT_RDN,
+ contextAttributes );
+ }
+
+ protected DirContext dasContext = null;
+ protected DirContext xsdContext = null;
+ protected DirContext xsdSyntaxesContext = null;
+ protected DirContext ecoreContext = null;
+ protected DirContext ecoreSyntaxesContext = null;
+ protected DirContext dasSyntaxesContext = null;
+ protected DirContext dasAttributeTypesContext = null;
+ protected DirContext dasObjectClassesContext = null;
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextsSetupTest.java
new file mode 100644
index 0000000000..dfea532518
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextsSetupTest.java
@@ -0,0 +1,71 @@
+package org.apache.tuscany.das.ldap.schema.setup.test;
+
+import javax.naming.NamingException;
+
+public class SchemaContextsSetupTest
+extends SchemaContextsSetup
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ }
+
+ public void testConnect()
+ {
+ assertNotNull(schemaContext);
+ }
+
+
+ public void testCreateDASContext()
+ {
+ assertNotNull(dasContext);
+ }
+
+
+ public void testCreateXSDContext()
+ {
+ assertNotNull(xsdContext);
+ }
+
+
+
+ public void testCreateXSDSyntaxesContext()
+ {
+ assertNotNull(xsdSyntaxesContext);
+ }
+
+
+ public void testCreateEcoreContext()
+ {
+ assertNotNull(ecoreContext);
+ }
+
+
+
+ public void testCreateEcoreSyntaxesContext()
+ {
+ assertNotNull(ecoreSyntaxesContext);
+ }
+
+ public void testCreateSyntaxesContext()
+ {
+ assertNotNull(dasSyntaxesContext);
+ }
+
+ public void testCreateAttributeTypesContext()
+ {
+ assertNotNull(dasAttributeTypesContext);
+ }
+
+
+ public void testCreateObjectClassesContext()
+ {
+ assertNotNull(dasObjectClassesContext);
+ }
+
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/XSDSchemaContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/XSDSchemaContextsSetup.java
new file mode 100644
index 0000000000..4b9cd22e44
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/XSDSchemaContextsSetup.java
@@ -0,0 +1,76 @@
+package org.apache.tuscany.das.ldap.schema.setup.test;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+
+public class XSDSchemaContextsSetup
+extends AbstractTestSetup
+implements DASConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ xsdSyntaxesContext.close();
+ xsdContext.destroySubcontext( SYNTAXES_CONTEXT_RDN );
+ xsdContext.close();
+ schemaContext.destroySubcontext( XSD_CONTEXT_RDN );
+ schemaContext.close();
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ schemaContext = connect();
+ xsdContext = createXsdContext();
+ xsdSyntaxesContext = createXsdSyntaxesContext();
+ }
+
+ private DirContext createXsdContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(META_SCHEMA);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ CN,
+ XSD_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return schemaContext.createSubcontext(
+ XSD_CONTEXT_RDN, contextAttributes );
+ }
+
+ private DirContext createXsdSyntaxesContext() throws NamingException
+ {
+ Attributes contextAttributes = new BasicAttributes();
+
+ Attribute objectClassAttribute = new BasicAttribute(
+ OBJECT_CLASS,
+ TOP);
+ objectClassAttribute.add(ORGANIZATIONAL_UNIT);
+
+ Attribute ecoreAttribute = new BasicAttribute(
+ OU,
+ SYNTAXES_CONTEXT_NAME);
+
+ contextAttributes.put( ecoreAttribute );
+ contextAttributes.put( objectClassAttribute );
+
+ return xsdContext.createSubcontext(
+ SYNTAXES_CONTEXT_RDN, contextAttributes );
+ }
+
+ protected DirContext xsdContext = null;
+ protected DirContext xsdSyntaxesContext = null;
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/XSDSchemaContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/XSDSchemaContextsSetupTest.java
new file mode 100644
index 0000000000..a0bb8fb69d
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/XSDSchemaContextsSetupTest.java
@@ -0,0 +1,35 @@
+package org.apache.tuscany.das.ldap.schema.setup.test;
+
+import javax.naming.NamingException;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+
+public class XSDSchemaContextsSetupTest
+extends XSDSchemaContextsSetup
+implements DASConstants
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ super.tearDown();
+ }
+
+ public void setUp() throws NamingException, Exception
+ {
+ super.setUp();
+ }
+
+ public void testConnect()
+ {
+ assertNotNull(schemaContext);
+ }
+
+ public void testCreateEcoreContext()
+ {
+ assertNotNull(xsdContext);
+ }
+
+ public void testCreateEcoreSyntaxesContext()
+ {
+ assertNotNull(xsdSyntaxesContext);
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/testing/constants/DASTestingConstants.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/testing/constants/DASTestingConstants.java
new file mode 100644
index 0000000000..2ee1d37650
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/testing/constants/DASTestingConstants.java
@@ -0,0 +1,9 @@
+package org.apache.tuscany.das.ldap.testing.constants;
+
+public interface DASTestingConstants {
+
+ String xsdNamespace =
+ "http://example.com/users/accounts";
+
+
+}
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/ComplexTypeNamespaceQualifier.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/ComplexTypeNamespaceQualifier.java
new file mode 100644
index 0000000000..1185d968d3
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/ComplexTypeNamespaceQualifier.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.das.ldap.util;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class DataTypeNamespaceQualifier.
+ */
+public class ComplexTypeNamespaceQualifier
+{
+ /**
+ * Qualify.
+ *
+ * @param namespaceURI the namespace URI
+ * @param complexTypeName the name
+ *
+ * @return the string
+ */
+ public static String qualify(String namespaceURI, String complexTypeName )
+ {
+ return namespaceURI + "/" + complexTypeName;
+ }
+}
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/IDGenerator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/IDGenerator.java
new file mode 100644
index 0000000000..f41d192bd0
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/IDGenerator.java
@@ -0,0 +1,10 @@
+package org.apache.tuscany.das.ldap.util;
+
+public class IDGenerator {
+
+ static long currentID= System.currentTimeMillis();
+
+ static public synchronized long generate(){
+ return currentID++;
+ }
+}
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/JNDIUtil.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/JNDIUtil.java
new file mode 100644
index 0000000000..be19f0b6c4
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/JNDIUtil.java
@@ -0,0 +1,168 @@
+
+package org.apache.tuscany.das.ldap.util;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+/**
+ * The Class JNDIUtil.
+ */
+public class JNDIUtil
+{
+ /**
+ * Calculate DN components.
+ *
+ * @param context the context
+ *
+ * @return the string[] containing the components of the DN
+ *
+ * @throws NamingException the naming exception
+ */
+ public static String[] calculateDNComponents(
+ DirContext context)
+ throws NamingException
+ {
+ String contextDN =
+ context.getNameInNamespace();
+
+ String[] initialContextComponents =
+ contextDN.split( "[,]" );
+
+ return initialContextComponents;
+ }
+
+
+ /**
+ * Calculate DN components.
+ *
+ * @param contextDN the context DN
+ *
+ * @return the string[] containing the components of the DN
+ *
+ * @throws NamingException the naming exception
+ */
+ public static String[] calculateDNComponents(
+ String contextDN)
+ throws NamingException
+ {
+ String[] initialContextComponents =
+ contextDN.split( "[,]" );
+
+ return initialContextComponents;
+ }
+
+ /**
+ * Gets the parent context.
+ *
+ * @param partitionContext the partition context
+ * @param childContext the child context
+ *
+ * @return the parent context (Null if the child context is the root)
+ *
+ * @throws NamingException the naming exception
+ */
+ public static DirContext getParentContext(
+ DirContext childContext,
+ DirContext partitionContext)
+ throws NamingException
+ {
+ String[] childContextDNComponents =
+ calculateDNComponents( childContext );
+
+ String[] partitionDNComponents =
+ calculateDNComponents( partitionContext );
+
+ DirContext parentContext = null;
+
+ if (childContextDNComponents.length == partitionDNComponents.length)
+ {
+ return null;
+ }
+ else if ( (childContextDNComponents.length - 1) == partitionDNComponents.length)
+ {
+ return partitionContext;
+ }
+ else
+ {
+ String parentLookupDN =
+ calculateParentRelativeDN(
+ childContext, partitionContext.getNameInNamespace() );
+
+
+
+ parentContext =
+ ( DirContext ) partitionContext.lookup( parentLookupDN );
+ }
+ return parentContext;
+ }
+
+
+ /**
+ * Calculate parent relative DN.
+ * The parent relative DN is the
+ * DN of the parent context, relative
+ * to the partition context.
+ *
+ * So if the partition context is
+ * <i>ou=system</i> and
+ * the child context has DN
+ * <i>cn=accounts, cn=users, cn=example, ou=system</i>
+ *
+ * then the parent relative DN is
+ * <i>cn=users, cn=example</i>
+ *
+ * @param childContext the child context
+ * @param partitionDN the partition DN
+ *
+ * @return the string
+ *
+ * @throws NamingException the naming exception
+ */
+ public static String calculateParentRelativeDN(
+ DirContext childContext,
+ String partitionDN)
+ throws NamingException
+ {
+ String parentRelativeDN = null;
+
+ String[] childContextDNComponents =
+ calculateDNComponents( childContext );
+
+ String[] partitionDNComponents =
+ calculateDNComponents( partitionDN );
+
+ if (childContextDNComponents.length ==
+ partitionDNComponents.length)
+ {
+ return null;
+ }
+ else if (childContextDNComponents.length ==
+ partitionDNComponents.length + 1)
+ {
+ String childRDN = childContextDNComponents[0];
+ String childContextDN = childContext.getNameInNamespace();
+
+ int beginIndex = childRDN.length() + 1;
+ int endIndex = childContextDN.length();
+
+ parentRelativeDN = childContextDN.substring(
+ beginIndex, endIndex );
+
+ return parentRelativeDN;
+ }
+ else
+ {
+ String childRDN = childContextDNComponents[0];
+ String childContextDN = childContext.getNameInNamespace();
+
+ int beginIndex = childRDN.length() + 1;
+ int endIndex =
+ childContextDN.length() -
+ ( partitionDN.length() +1);
+
+ parentRelativeDN = childContextDN.substring(
+ beginIndex, endIndex );
+ }
+ return parentRelativeDN;
+ }
+}
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/LDAPNormalizer.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/LDAPNormalizer.java
new file mode 100644
index 0000000000..2d0be469bc
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/LDAPNormalizer.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.util;
+
+public class LDAPNormalizer
+{
+
+ /**
+ * Normalize a qualified string for LDAP
+ * by replacing periods with dashes.
+ *
+ * @param qualifiedName the qualified name
+ */
+ public static void normalize(String qualifiedName)
+ {
+ qualifiedName = qualifiedName.replace( ".", "-" );
+ }
+
+
+
+}
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/QualifiedNameNormalizer.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/QualifiedNameNormalizer.java
new file mode 100644
index 0000000000..51b34f5d0f
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/QualifiedNameNormalizer.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.util;
+
+public class QualifiedNameNormalizer
+{
+ /**
+ * Normalize a qualified string for LDAP
+ * by replacing periods with dashes.
+ *
+ * @param qualifiedName the qualified name
+ */
+ public static String normalize(String qualifiedName)
+ {
+ qualifiedName = qualifiedName.replace("http://", "");
+ qualifiedName = qualifiedName.replace("/", "-");
+ return qualifiedName.replace(".", "-");
+ }
+}
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/SimpleTypeNamespaceQualifier.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/SimpleTypeNamespaceQualifier.java
new file mode 100644
index 0000000000..40dc6e0b09
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/SimpleTypeNamespaceQualifier.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.das.ldap.util;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class DataTypeNamespaceQualifier.
+ */
+public class SimpleTypeNamespaceQualifier
+{
+ /**
+ * Qualify.
+ *
+ * @param namespaceURI the namespace URI
+ * @param complexTypeName the name
+ *
+ * @return the string
+ */
+ public static String qualify(String namespaceURI, String complexTypeName, String simpleTypeName )
+ {
+ return namespaceURI + "/" + complexTypeName + "/" + simpleTypeName;
+ }
+}
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceToInitialContextTransformer.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceToInitialContextTransformer.java
new file mode 100644
index 0000000000..87ff89071a
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceToInitialContextTransformer.java
@@ -0,0 +1,49 @@
+
+package org.apache.tuscany.das.ldap.util;
+
+import org.eclipse.emf.common.util.URI;
+
+/**
+ * The Class XSDNamespaceToInitialContextTransformer.
+ *
+ * Takes the XSD Namespace used by the DataObjects
+ * and transforms it into the DN of the initial context
+ * used for the root DataObject entry.
+ */
+public class XSDNamespaceToInitialContextTransformer
+{
+ /**
+ * Transform.
+ *
+ * @param namespaceURIString the namespace URI string
+ *
+ * @return the DN of the initial context
+ *
+ * @throws Exception the exception
+ */
+ public static String transform(String namespaceURIString) throws Exception
+ {
+ URI namespaceURI = URI.createURI(namespaceURIString);
+ String authority = namespaceURI.authority();
+
+ String path = namespaceURI.path();
+
+ String[] authorityTokens = authority.split( "[.]" );
+ String[] pathTokens = path.split("[/]");
+
+ String DN = new String("");
+
+ for (int i = (pathTokens.length-1); i > 0; i--)
+ {
+ DN = DN + "cn=" + pathTokens[i] + ", ";
+ }
+
+ for (int i = 0; i <= (authorityTokens.length-2); i++)
+ {
+ DN = DN + "cn=" + authorityTokens[i] + ", ";
+ }
+
+ DN = DN + "ou=" + authorityTokens[authorityTokens.length-1];
+ return DN;
+ }
+}
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceURITokenizer.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceURITokenizer.java
new file mode 100644
index 0000000000..833cf0e7ae
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceURITokenizer.java
@@ -0,0 +1,26 @@
+
+package org.apache.tuscany.das.ldap.util;
+
+import org.eclipse.emf.common.util.URI;
+
+public class XSDNamespaceURITokenizer
+{
+
+ public static String[] createAuthorityTokens( URI xsdNamespaceURI )
+ {
+ String authority = xsdNamespaceURI.authority();
+ String[] authorityTokens = authority.split( "[.]" );
+ return authorityTokens;
+ }
+
+ public static String[] createPathTokens(URI xsdNamespace)
+ {
+ String path = xsdNamespace.path();
+ if (path != null)
+ {
+ return path.split("[/]");
+ }
+ else
+ return null;
+ }
+}