diff options
Diffstat (limited to 'das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema')
44 files changed, 4361 insertions, 0 deletions
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 |