Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/DataTypeToADSSyntaxMapProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/DataTypeToADSSyntaxMapProvider.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/DataTypeToADSSyntaxMapProvider.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/DataTypeToADSSyntaxMapProvider.java Fri Jun 22 09:39:30 2007
@@ -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
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EAttributeTypeCreator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EAttributeTypeCreator.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EAttributeTypeCreator.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EAttributeTypeCreator.java Fri Jun 22 09:39:30 2007
@@ -0,0 +1,133 @@
+/*
+ * 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.Map;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+import org.apache.tuscany.das.ldap.oid.create.ComplexTypeOIDCreator;
+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.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+
+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();
+
+ String eDatatypeName =
+ eDataType.getName();
+
+ String eDataTypeNamespaceURI =
+ eDataType.getEPackage().getNsURI();
+
+ /*
+ String syntaxOID =
+ ComplexTypeOIDCreator.create(
+ oidPrefix,
+ eDataTypeNamespaceURI,
+ eDatatypeName);
+ */
+
+ DataTypeToADSSyntaxMapProvider dataTypeToADSSyntaxMapProvider =
+ new DataTypeToADSSyntaxMapProvider();
+
+ Map<EDataType, String> dataTypeToADSSyntaxMap =
+ dataTypeToADSSyntaxMapProvider.
+ getDataTypeToADSSyntaxMap();
+
+ String syntaxOID =
+ dataTypeToADSSyntaxMap.get(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
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreator.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreator.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreator.java Fri Jun 22 09:39:30 2007
@@ -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
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreatorHelper.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreatorHelper.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreatorHelper.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreatorHelper.java Fri Jun 22 09:39:30 2007
@@ -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,
+ M_META_TOP_SDO_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
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EReferenceTypeCreator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EReferenceTypeCreator.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EReferenceTypeCreator.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EReferenceTypeCreator.java Fri Jun 22 09:39:30 2007
@@ -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.DASConstants;
+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 DASConstants
+{
+ 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,
+ DISTINGUISHED_NAME_SYNTAX_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
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EcoreTypeSystemCreator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EcoreTypeSystemCreator.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EcoreTypeSystemCreator.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EcoreTypeSystemCreator.java Fri Jun 22 09:39:30 2007
@@ -0,0 +1,52 @@
+/*
+ * 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.ldap.LdapContext;
+
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EcorePackage;
+
+public class EcoreTypeSystemCreator
+{
+ private static
+ EcorePackage ecorePackage =
+ EcorePackage.eINSTANCE;
+
+ public static void create(
+ LdapContext syntaxesContext,
+ LdapContext syntaxCheckersContext,
+ String oidPrefix) throws Exception
+ {
+ List<EDataType> eDataTypes =
+ EcoreTypeSystemHelper.
+ createEDataTypesList(
+ ecorePackage);
+
+ EcoreTypeSystemHelper.
+ createSyntaxEntries(
+ eDataTypes,
+ oidPrefix,
+ syntaxesContext,
+ syntaxCheckersContext);
+ }
+}
\ No newline at end of file
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EcoreTypeSystemHelper.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EcoreTypeSystemHelper.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EcoreTypeSystemHelper.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EcoreTypeSystemHelper.java Fri Jun 22 09:39:30 2007
@@ -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;
+ }
+}
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/ModelTypeSystemCreator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/ModelTypeSystemCreator.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/ModelTypeSystemCreator.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/ModelTypeSystemCreator.java Fri Jun 22 09:39:30 2007
@@ -0,0 +1,84 @@
+/*
+ * 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 javax.naming.directory.DirContext;
+import javax.naming.ldap.LdapContext;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EPackage;
+
+public class ModelTypeSystemCreator
+{
+ private static List<EClass> processedEClassifiers =
+ new ArrayList<EClass>();
+
+ public static void create(
+ LdapContext dasModelMetaContext,
+ LdapContext syntaxesContext,
+ LdapContext syntaxCheckersContext,
+ LdapContext attributeTypesContext,
+ LdapContext objectClassesContext,
+ EPackage ePackage,
+ String oidPrefix)
+ throws Exception
+ {
+ List<EDataType> eDataTypes =
+ EcoreTypeSystemHelper.
+ createEDataTypesList(ePackage);
+
+ EcoreTypeSystemHelper.
+ createSyntaxEntries(
+ eDataTypes,
+ oidPrefix,
+ syntaxesContext,
+ syntaxCheckersContext);
+
+ List<EClass> eClassifiers =
+ EcoreTypeSystemHelper.
+ createEClassifiersList( ePackage );
+
+ Iterator<EClass> eClassIterator =
+ eClassifiers.iterator();
+
+
+ EObjectClassCreator eObjectClassCreator =
+ new EObjectClassCreator();
+
+ while (eClassIterator.hasNext())
+ {
+ EClass eClass =
+ eClassIterator.next();
+
+ eObjectClassCreator.create(
+ dasModelMetaContext,
+ attributeTypesContext,
+ objectClassesContext,
+ eClass,
+ processedEClassifiers,
+ oidPrefix );
+ }
+ }
+}
\ No newline at end of file
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/ECascadingObjectClassDestroyer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/ECascadingObjectClassDestroyer.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/ECascadingObjectClassDestroyer.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/ECascadingObjectClassDestroyer.java Fri Jun 22 09:39:30 2007
@@ -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
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EObjectClassDestroyer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EObjectClassDestroyer.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EObjectClassDestroyer.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EObjectClassDestroyer.java Fri Jun 22 09:39:30 2007
@@ -0,0 +1,84 @@
+/*
+ * 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.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 );
+
+ DirContext parentMetaContext =
+ null;
+
+ EClass eClassParent =
+ EcoreTypeSystemHelper.
+ getEClassParent( eClass );
+
+ if (eClassParent != null)
+ {
+ rdn = CN + "=" + eClassParent.getName();
+
+ parentMetaContext =
+ ( DirContext )
+ metaContext.lookup( rdn );
+
+ rdn = CN + "=" + eClass.getName();
+
+ parentMetaContext.destroySubcontext( rdn );
+ }
+ }
+}
\ No newline at end of file
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EStructuralFeatureTypeDestroyer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EStructuralFeatureTypeDestroyer.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EStructuralFeatureTypeDestroyer.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EStructuralFeatureTypeDestroyer.java Fri Jun 22 09:39:30 2007
@@ -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
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EcoreTypeSystemDestroyer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EcoreTypeSystemDestroyer.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EcoreTypeSystemDestroyer.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EcoreTypeSystemDestroyer.java Fri Jun 22 09:39:30 2007
@@ -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.emf.destroy;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.schema.destroy.SyntaxCheckerEntryDestroyer;
+import org.apache.tuscany.das.ldap.schema.destroy.SyntaxEntryDestroyer;
+import org.apache.tuscany.das.ldap.schema.emf.create.EcoreTypeSystemHelper;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EcorePackage;
+
+public class EcoreTypeSystemDestroyer
+{
+
+ private static EcorePackage ecorePackage =
+ EcorePackage.eINSTANCE;
+
+ /**
+ * Destroy.
+ *
+ * @param oidPrefix the oid prefix
+ * @param syntaxesContext the syntaxes context
+ *
+ * @throws Exception the exception
+ */
+ public static void destroy(
+ LdapContext syntaxesContext,
+ LdapContext syntaxCheckersContext,
+ String oidPrefix) throws Exception
+ {
+ List<EDataType> eDataTypes =
+ EcoreTypeSystemHelper.
+ createEDataTypesList(ecorePackage);
+
+ Iterator<EDataType> eDataTypeIterator = eDataTypes.iterator();
+
+ EDataType eDataType = null;
+ String eDataTypeName = null;
+ String eDataTypeNamespaceURI = null;
+
+ while (eDataTypeIterator.hasNext())
+ {
+ eDataType =
+ eDataTypeIterator.next();
+
+ eDataTypeName =
+ eDataType.getName();
+
+ eDataTypeNamespaceURI =
+ eDataType.getEPackage().getNsURI();
+
+ SyntaxEntryDestroyer.destroy(
+ oidPrefix,
+ eDataTypeNamespaceURI,
+ eDataTypeName,
+ syntaxesContext);
+
+ SyntaxCheckerEntryDestroyer.destroy(
+ oidPrefix,
+ eDataTypeNamespaceURI,
+ eDataTypeName,
+ syntaxCheckersContext);
+ }
+
+ }
+}
\ No newline at end of file
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/ComplexTypeNamespaceQualifier.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/ComplexTypeNamespaceQualifier.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/ComplexTypeNamespaceQualifier.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/ComplexTypeNamespaceQualifier.java Fri Jun 22 09:39:30 2007
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.das.ldap.util;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class DataTypeNamespaceQualifier.
+ */
+public class ComplexTypeNamespaceQualifier
+{
+ /**
+ * Qualify.
+ *
+ * @param namespaceURI the namespace URI
+ * @param complexTypeName the name
+ *
+ * @return the string
+ */
+ public static String qualify(String namespaceURI, String complexTypeName )
+ {
+ return namespaceURI + "/" + complexTypeName;
+ }
+}
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/IDGenerator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/IDGenerator.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/IDGenerator.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/IDGenerator.java Fri Jun 22 09:39:30 2007
@@ -0,0 +1,10 @@
+package org.apache.tuscany.das.ldap.util;
+
+public class IDGenerator {
+
+ static long currentID= System.currentTimeMillis();
+
+ static public synchronized long generate(){
+ return currentID++;
+ }
+}
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/JNDIUtil.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/JNDIUtil.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/JNDIUtil.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/JNDIUtil.java Fri Jun 22 09:39:30 2007
@@ -0,0 +1,168 @@
+
+package org.apache.tuscany.das.ldap.util;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+/**
+ * The Class JNDIUtil.
+ */
+public class JNDIUtil
+{
+ /**
+ * Calculate DN components.
+ *
+ * @param context the context
+ *
+ * @return the string[] containing the components of the DN
+ *
+ * @throws NamingException the naming exception
+ */
+ public static String[] calculateDNComponents(
+ DirContext context)
+ throws NamingException
+ {
+ String contextDN =
+ context.getNameInNamespace();
+
+ String[] initialContextComponents =
+ contextDN.split( "[,]" );
+
+ return initialContextComponents;
+ }
+
+
+ /**
+ * Calculate DN components.
+ *
+ * @param contextDN the context DN
+ *
+ * @return the string[] containing the components of the DN
+ *
+ * @throws NamingException the naming exception
+ */
+ public static String[] calculateDNComponents(
+ String contextDN)
+ throws NamingException
+ {
+ String[] initialContextComponents =
+ contextDN.split( "[,]" );
+
+ return initialContextComponents;
+ }
+
+ /**
+ * Gets the parent context.
+ *
+ * @param partitionContext the partition context
+ * @param childContext the child context
+ *
+ * @return the parent context (Null if the child context is the root)
+ *
+ * @throws NamingException the naming exception
+ */
+ public static DirContext getParentContext(
+ DirContext childContext,
+ DirContext partitionContext)
+ throws NamingException
+ {
+ String[] childContextDNComponents =
+ calculateDNComponents( childContext );
+
+ String[] partitionDNComponents =
+ calculateDNComponents( partitionContext );
+
+ DirContext parentContext = null;
+
+ if (childContextDNComponents.length == partitionDNComponents.length)
+ {
+ return null;
+ }
+ else if ( (childContextDNComponents.length - 1) == partitionDNComponents.length)
+ {
+ return partitionContext;
+ }
+ else
+ {
+ String parentLookupDN =
+ calculateParentRelativeDN(
+ childContext, partitionContext.getNameInNamespace() );
+
+
+
+ parentContext =
+ ( DirContext ) partitionContext.lookup( parentLookupDN );
+ }
+ return parentContext;
+ }
+
+
+ /**
+ * Calculate parent relative DN.
+ * The parent relative DN is the
+ * DN of the parent context, relative
+ * to the partition context.
+ *
+ * So if the partition context is
+ * <i>ou=system</i> and
+ * the child context has DN
+ * <i>cn=accounts, cn=users, cn=example, ou=system</i>
+ *
+ * then the parent relative DN is
+ * <i>cn=users, cn=example</i>
+ *
+ * @param childContext the child context
+ * @param partitionDN the partition DN
+ *
+ * @return the string
+ *
+ * @throws NamingException the naming exception
+ */
+ public static String calculateParentRelativeDN(
+ DirContext childContext,
+ String partitionDN)
+ throws NamingException
+ {
+ String parentRelativeDN = null;
+
+ String[] childContextDNComponents =
+ calculateDNComponents( childContext );
+
+ String[] partitionDNComponents =
+ calculateDNComponents( partitionDN );
+
+ if (childContextDNComponents.length ==
+ partitionDNComponents.length)
+ {
+ return null;
+ }
+ else if (childContextDNComponents.length ==
+ partitionDNComponents.length + 1)
+ {
+ String childRDN = childContextDNComponents[0];
+ String childContextDN = childContext.getNameInNamespace();
+
+ int beginIndex = childRDN.length() + 1;
+ int endIndex = childContextDN.length();
+
+ parentRelativeDN = childContextDN.substring(
+ beginIndex, endIndex );
+
+ return parentRelativeDN;
+ }
+ else
+ {
+ String childRDN = childContextDNComponents[0];
+ String childContextDN = childContext.getNameInNamespace();
+
+ int beginIndex = childRDN.length() + 1;
+ int endIndex =
+ childContextDN.length() -
+ ( partitionDN.length() +1);
+
+ parentRelativeDN = childContextDN.substring(
+ beginIndex, endIndex );
+ }
+ return parentRelativeDN;
+ }
+}
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/LDAPNormalizer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/LDAPNormalizer.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/LDAPNormalizer.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/LDAPNormalizer.java Fri Jun 22 09:39:30 2007
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.util;
+
+public class LDAPNormalizer
+{
+
+ /**
+ * Normalize a qualified string for LDAP
+ * by replacing periods with dashes.
+ *
+ * @param qualifiedName the qualified name
+ */
+ public static void normalize(String qualifiedName)
+ {
+ qualifiedName = qualifiedName.replace( ".", "-" );
+ }
+
+
+
+}
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/QualifiedNameNormalizer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/QualifiedNameNormalizer.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/QualifiedNameNormalizer.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/QualifiedNameNormalizer.java Fri Jun 22 09:39:30 2007
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.util;
+
+public class QualifiedNameNormalizer
+{
+ /**
+ * Normalize a qualified string for LDAP
+ * by replacing periods with dashes.
+ *
+ * @param qualifiedName the qualified name
+ */
+ public static String normalize(String qualifiedName)
+ {
+ qualifiedName = qualifiedName.replace("http://", "");
+ qualifiedName = qualifiedName.replace("/", "-");
+ return qualifiedName.replace(".", "-");
+ }
+}
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/SimpleTypeNamespaceQualifier.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/SimpleTypeNamespaceQualifier.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/SimpleTypeNamespaceQualifier.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/SimpleTypeNamespaceQualifier.java Fri Jun 22 09:39:30 2007
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.das.ldap.util;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class DataTypeNamespaceQualifier.
+ */
+public class SimpleTypeNamespaceQualifier
+{
+ /**
+ * Qualify.
+ *
+ * @param namespaceURI the namespace URI
+ * @param complexTypeName the name
+ *
+ * @return the string
+ */
+ public static String qualify(String namespaceURI, String complexTypeName, String simpleTypeName )
+ {
+ return namespaceURI + "/" + complexTypeName + "/" + simpleTypeName;
+ }
+}
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceToInitialContextTransformer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceToInitialContextTransformer.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceToInitialContextTransformer.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceToInitialContextTransformer.java Fri Jun 22 09:39:30 2007
@@ -0,0 +1,49 @@
+
+package org.apache.tuscany.das.ldap.util;
+
+import org.eclipse.emf.common.util.URI;
+
+/**
+ * The Class XSDNamespaceToInitialContextTransformer.
+ *
+ * Takes the XSD Namespace used by the DataObjects
+ * and transforms it into the DN of the initial context
+ * used for the root DataObject entry.
+ */
+public class XSDNamespaceToInitialContextTransformer
+{
+ /**
+ * Transform.
+ *
+ * @param namespaceURIString the namespace URI string
+ *
+ * @return the DN of the initial context
+ *
+ * @throws Exception the exception
+ */
+ public static String transform(String namespaceURIString) throws Exception
+ {
+ URI namespaceURI = URI.createURI(namespaceURIString);
+ String authority = namespaceURI.authority();
+
+ String path = namespaceURI.path();
+
+ String[] authorityTokens = authority.split( "[.]" );
+ String[] pathTokens = path.split("[/]");
+
+ String DN = new String("");
+
+ for (int i = (pathTokens.length-1); i > 0; i--)
+ {
+ DN = DN + "cn=" + pathTokens[i] + ", ";
+ }
+
+ for (int i = 0; i <= (authorityTokens.length-2); i++)
+ {
+ DN = DN + "cn=" + authorityTokens[i] + ", ";
+ }
+
+ DN = DN + "ou=" + authorityTokens[authorityTokens.length-1];
+ return DN;
+ }
+}
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceURITokenizer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceURITokenizer.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceURITokenizer.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceURITokenizer.java Fri Jun 22 09:39:30 2007
@@ -0,0 +1,26 @@
+
+package org.apache.tuscany.das.ldap.util;
+
+import org.eclipse.emf.common.util.URI;
+
+public class XSDNamespaceURITokenizer
+{
+
+ public static String[] createAuthorityTokens( URI xsdNamespaceURI )
+ {
+ String authority = xsdNamespaceURI.authority();
+ String[] authorityTokens = authority.split( "[.]" );
+ return authorityTokens;
+ }
+
+ public static String[] createPathTokens(URI xsdNamespace)
+ {
+ String path = xsdNamespace.path();
+ if (path != null)
+ {
+ return path.split("[/]");
+ }
+ else
+ return null;
+ }
+}
Added: directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplate.java
URL: http://svn.apache.org/viewvc/directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplate.java?view=auto&rev=549870
==============================================================================
--- directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplate.java (added)
+++ directory/sandbox/oersoy/das.ldap.parent/das.ldap/src/test/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplate.java Fri Jun 22 09:39:30 2007
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.apacheds.testing.setup;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
+import org.apache.directory.server.core.configuration.ShutdownConfiguration;
+import org.apache.log4j.PropertyConfigurator;
+
+/**
+ * The Class JNDIEmbeddedConnectionTemplate.
+ */
+public abstract class ADSEmbeddedConnectionTemplate
+extends JNDIConnectionTemplate
+{
+ public void tearDown() throws NamingException, Exception
+ {
+ Hashtable<String,Object> env =
+ new Hashtable<String,Object>();
+
+ env = createEnvironment(env);
+
+ env.put(
+ Context.PROVIDER_URL,
+ SYSTEM_PROVIDER_PATH);
+ env.put(
+ Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.directory.server.core.jndi.CoreContextFactory" );
+ env.putAll(
+ new ShutdownConfiguration().toJndiEnvironment() );
+
+ new InitialContext( env );
+ Runtime.getRuntime().gc();
+ super.tearDown();
+ }
+
+
+
+ public void setUp() throws Exception
+ {
+ PropertyConfigurator.
+ configure(NLOG4J_CONFIGURATION_FILEPATH);
+ super.setUp();
+ }
+
+ /**
+ * Connect to an embedded ApacheDS server.
+ *
+ * @param providerPath the provider path ("ou=schema", ou="system", etc.)
+ *
+ * @return the ldap context
+ *
+ * @throws NamingException the naming exception
+ */
+ public LdapContext connect( String providerPath ) throws NamingException
+ {
+ MutableStartupConfiguration mutableStartupConfiguration =
+ new MutableStartupConfiguration();
+
+ Hashtable<String,Object> adminEnv =
+ new Hashtable<String,Object>( );
+
+ adminEnv.putAll(
+ mutableStartupConfiguration.
+ toJndiEnvironment());
+
+ adminEnv.put(
+ Context.PROVIDER_URL,
+ SYSTEM_PROVIDER_PATH);
+ adminEnv.put(
+ Context.SECURITY_PRINCIPAL,
+ DEFAULT_SECURITY_PRINCIPAL_VALUE);
+ adminEnv.put(
+ Context.SECURITY_CREDENTIALS,
+ DEFAULT_SECURITY_CREDENTIALS_VALUE);
+ adminEnv.put(
+ Context.SECURITY_AUTHENTICATION,
+ SIMPLE_SECURITY_AUTHENTICATION_VALUE );
+ new InitialLdapContext( adminEnv, null );
+
+
+
+ Hashtable<String,Object> env =
+ new Hashtable<String,Object>();
+
+ env.put(
+ Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.directory.server.core.jndi.CoreContextFactory" );
+ env.put(
+ Context.SECURITY_PRINCIPAL,
+ DEFAULT_SECURITY_PRINCIPAL_VALUE);
+ env.put(
+ Context.SECURITY_CREDENTIALS,
+ DEFAULT_SECURITY_CREDENTIALS_VALUE);
+ env.put(
+ Context.SECURITY_AUTHENTICATION,
+ SIMPLE_SECURITY_AUTHENTICATION_VALUE );
+ env.put( Context.PROVIDER_URL, providerPath );
+
+ env.put( Context.PROVIDER_URL, providerPath );
+
+ return new InitialLdapContext( env, null );
+
+ }
+}
\ No newline at end of file
|