tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lrese...@apache.org
Subject svn commit: r562520 [5/10] - in /incubator/tuscany/java/das/ldap: ./ das.ldap.configuration.model.ecore.v100/ das.ldap.configuration.model.ecore.v100/model/ das.ldap.configuration.model.ecore.v100/src/ das.ldap.configuration.model.v100/ das.ldap.config...
Date Fri, 03 Aug 2007 16:40:19 GMT
Added: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReaderHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReaderHelper.java?view=auto&rev=562520
==============================================================================
--- incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReaderHelper.java (added)
+++ incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReaderHelper.java Fri Aug  3 09:40:00 2007
@@ -0,0 +1,365 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.emf.read;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.impl.EClassImpl;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+public class EDataGraphReaderHelper
+implements DASConstants
+{
+	public static String calculateRelativeDN(
+			LdapContext containerContext, 
+			LdapContext dataObjectContext) throws NamingException
+	{
+    	String containerDN    = containerContext.getNameInNamespace();
+    	String dataObjectDN = dataObjectContext.getNameInNamespace();
+    	
+    	int beginIndex = 0;
+    	int endIndex    = 
+    		dataObjectDN.length() - containerDN.length() - 1;
+
+    	String result    = 
+    		dataObjectDN.substring(
+    				beginIndex, 
+    				endIndex);
+    	
+    	return result;
+	}
+	
+
+    public static EDataObject restoreEDataObject(
+    		Map<EDataObject, Map<EStructuralFeature, List<String>>> crossReferenceIDCache,
+    		EClass eClass,
+    		String namespaceURI,
+    		Attributes attributes) 
+    throws NamingException
+    {
+        EDataObject eDataObject =
+        	(EDataObject)
+        	eClass.getEPackage().
+        	getEFactoryInstance().
+        	create(eClass);
+        
+        EDataObjectReaderHelper.
+        restoreEAttributes( 
+            eClass, 
+            eDataObject, 
+            namespaceURI, 
+            attributes );
+
+        EStructuralFeature[] eCrossReferences = 
+        	((EClassImpl.FeatureSubsetSupplier)
+        			eDataObject.
+        			eClass().
+        			getEAllStructuralFeatures()).
+        			crossReferences();
+        
+        if (eCrossReferences != null)
+        {
+        	Map<EStructuralFeature, List<String>> eReferenceToEObjectIDs = 
+        		new Hashtable<EStructuralFeature, List<String>>();
+        	
+            for (EStructuralFeature eReference : eCrossReferences)
+            {
+                String qualifiedEReferenceName             =
+                    SimpleTypeNamespaceQualifier.
+                    qualify( 
+                        namespaceURI, 
+                        eClass.getName(), 
+                        eReference.getName() );
+                
+            	String normalizedEReferenceName         =
+                	QualifiedNameNormalizer.
+                	normalize(qualifiedEReferenceName);
+
+            	if (eReference.isMany())
+            	{
+                	List<String> idList                                =
+                		new ArrayList<String>();
+
+            		Attribute eReferenceAttribute             = 
+            			attributes.get(normalizedEReferenceName);
+            		
+            		NamingEnumeration namingEnumeration = 
+            			eReferenceAttribute.getAll();
+            		
+            		while (namingEnumeration.hasMore())
+            		{
+            			String id = (String) namingEnumeration.next();
+            			idList.add(id);
+                    	eReferenceToEObjectIDs.put(eReference, idList);
+            		}
+            	}
+            	else
+            	{
+                	List<String> idList                                   =
+                		new ArrayList<String>();
+
+                	String value                                               = 
+                		(String) 
+                		attributes.
+                		get(normalizedEReferenceName).
+                		get();
+                	
+                	idList.add(value);
+                	eReferenceToEObjectIDs.put(eReference, idList);
+            	}
+            	crossReferenceIDCache.put(
+            			eDataObject, 
+            			eReferenceToEObjectIDs);
+            }
+        }
+        return eDataObject;
+    }
+    
+    public static void restoreCrossReferences(
+    		Map<EDataObject, Map<EStructuralFeature, List<String>>> crossReferenceIDCache,
+    		Resource resource)
+    {
+    	for (EDataObject eDataObject : crossReferenceIDCache.keySet())
+    	{
+    		Map<EStructuralFeature, List<String>> eReferenceToIDListMap = 
+    			crossReferenceIDCache.get(eDataObject);
+    		
+    		for (EStructuralFeature eStructuralFeature : eReferenceToIDListMap.keySet())
+    		{
+    			if (eStructuralFeature.isMany())
+    			{
+    				List<String> eReferenceIDs = 
+    					eReferenceToIDListMap.
+    					get(eStructuralFeature);
+    				
+    				EList<EDataObject> multiplicityManyList = null;
+    				if (eReferenceIDs.size() > 0)
+    				{
+    			    	multiplicityManyList =
+    			    		new BasicEList<EDataObject>();
+    				}
+    				for (String eReferenceID : eReferenceIDs)
+    				{
+        				Object referencedDataObject = resource.getEObject(eReferenceID);
+        				multiplicityManyList.add((EDataObject) referencedDataObject);
+        				eDataObject.eSet(
+        						eStructuralFeature, 
+        						multiplicityManyList);
+    				}
+    			}
+    			else
+    			{
+    				String eReferenceID = 
+    					eReferenceToIDListMap.
+    					get(eStructuralFeature).
+    					get(0);
+    				
+    				Object referencedDataObject = resource.getEObject(eReferenceID);
+    				eDataObject.eSet(
+    						eStructuralFeature, 
+    						referencedDataObject);
+    			}
+    		}
+    	}
+    }
+    
+    public static void addContainmentDataObjects(
+    		Map crossReferenceIDCache,
+    		Map<EDataObject, String> dataObjectToRelativeDNCache,
+    		EDataObject containerDataObject,
+    		Attributes attributes,
+    		String namespaceURI,
+    		LdapContext eDataObjectContext,
+    		LdapContext rootContext) throws NamingException
+    {
+    	EClass eClass                                            =
+    		containerDataObject.eClass();
+    	
+    	List<EReference> eReferences               =
+    		eClass.getEAllContainments();
+    	
+    	for (EReference eReference : eReferences)
+    	{
+            String qualifiedEReferenceName          =
+                SimpleTypeNamespaceQualifier.
+                qualify( 
+                    namespaceURI, 
+                    eClass.getName(), 
+                    eReference.getName() );
+            
+        	String normalizedReferenceName         =
+            	QualifiedNameNormalizer.
+            	normalize(qualifiedEReferenceName);
+        	
+        	Attribute attribute                                  =
+        		attributes.
+        		get(normalizedReferenceName);
+        	
+        	if (attribute.size() > 0)
+        	{
+        		LdapContext eReferenceContainmentContext = 
+        			(LdapContext) 
+        			eDataObjectContext.
+        			lookup("cn=" + eReference.getName());
+        		
+        		EClass eReferenceType                                 =
+        			(EClass) eReference.getEType();
+        		
+        		EAttribute eReferenceTypeEIDAttribute     =
+        			eReferenceType.getEIDAttribute();
+        
+        		String qualifiedEReferenceTypeIDEAttributeName  =
+                    SimpleTypeNamespaceQualifier.
+                    qualify( 
+                        namespaceURI, 
+                        eReferenceType.getName(), 
+                        eReferenceTypeEIDAttribute.getName() );
+                
+            	String normalizedReferenceTypeEIDAttributeName         =
+                	QualifiedNameNormalizer.
+                	normalize(qualifiedEReferenceTypeIDEAttributeName);
+            	
+        		if (eReference.isMany())
+        		{
+        	    	EList<EDataObject> containmentList =
+        	    		new BasicEList<EDataObject>();
+        	    	
+                	NamingEnumeration idNamingEnumeration =
+                		attribute.getAll();
+                	
+                	while(idNamingEnumeration.hasMore())
+                	{
+                		String containedDataObjectID                    = 
+                			(String) idNamingEnumeration.next();
+                		
+                		String containedDataObjectEntryRDN       =
+                			normalizedReferenceTypeEIDAttributeName
+                			+ "=" + containedDataObjectID;
+                		
+                		Attributes eReferenceAttributes                =
+                			eReferenceContainmentContext.
+                			getAttributes(containedDataObjectEntryRDN);
+                		
+                		
+                		EDataObject eReferenceDataObject             = 
+                			EDataGraphReaderHelper.
+                			restoreEDataObject(
+                					crossReferenceIDCache, 
+                					eReferenceType,
+                					namespaceURI,
+                					eReferenceAttributes);
+
+                		//TODO Consider using aspects
+                		String relativeDN = 
+                			calculateRelativeDN(
+                					rootContext, 
+                					(LdapContext) 
+                					eReferenceContainmentContext.
+                					lookup(containedDataObjectEntryRDN));
+                		dataObjectToRelativeDNCache.put(eReferenceDataObject, relativeDN);
+                		//End of Aspect
+
+                		containmentList.add(eReferenceDataObject);
+                		
+                		if (eReferenceDataObject.eClass().getEAllContainments().size() > 0)
+                		{
+                			addContainmentDataObjects(
+                		    		crossReferenceIDCache,
+                		    		dataObjectToRelativeDNCache,
+                		    		eReferenceDataObject,
+                		    		eReferenceAttributes,
+                		    		namespaceURI,
+                		    		(LdapContext) eReferenceContainmentContext.
+                		    		lookup(containedDataObjectEntryRDN),
+                		    		rootContext);
+                		}
+                	}
+                	containerDataObject.eSet(eReference, containmentList);
+        		}
+        		else
+        		{
+        			String containedDataObjectID                    = 
+            			(String) attribute.get();
+
+            		String containedDataObjectEntryRDN       =
+            			normalizedReferenceTypeEIDAttributeName
+            			+ "=" + containedDataObjectID;
+            		
+            		Attributes eReferenceAttributes                =
+            			eReferenceContainmentContext.
+            			getAttributes(containedDataObjectEntryRDN);
+            		
+            		EDataObject eReferenceDataObject          = 
+            			EDataGraphReaderHelper.
+            			restoreEDataObject(
+            					crossReferenceIDCache, 
+            					eReferenceType,
+            					namespaceURI,
+            					eReferenceAttributes);
+
+            		//TODO Consider using aspects
+            		String relativeDN = 
+            			calculateRelativeDN(
+            					rootContext, 
+            					(LdapContext) 
+            					eReferenceContainmentContext.
+            					lookup(containedDataObjectEntryRDN));
+            		
+            		dataObjectToRelativeDNCache.put(eReferenceDataObject, relativeDN);
+            		//End of Aspect
+
+                	containerDataObject.eSet(eReference, eReferenceDataObject);
+
+                	if (eReferenceDataObject.eClass().getEAllContainments().size() > 0)
+            		{
+            			addContainmentDataObjects(
+            		    		crossReferenceIDCache, 
+            		    		dataObjectToRelativeDNCache,
+            		    		eReferenceDataObject,
+            		    		eReferenceAttributes,
+            		    		namespaceURI,
+            		    		(LdapContext) eReferenceContainmentContext.
+            		    		lookup(containedDataObjectEntryRDN),
+            		    		rootContext);
+            		}
+            	}
+       		}
+       	}
+    }
+}
\ No newline at end of file

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReaderHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReaderHelper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReader.java?view=auto&rev=562520
==============================================================================
--- incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReader.java (added)
+++ incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReader.java Fri Aug  3 09:40:00 2007
@@ -0,0 +1,100 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.emf.read;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+public class EDataObjectReader
+implements DASConstants
+{
+    /**
+     * Read.
+     * 
+     * @param eClass the e class
+     * @param id the id
+     * @param containerContext the container context
+     * 
+     * @return the e data object
+     * 
+     * @throws NamingException the naming exception
+     * 
+     * Note that this is more of a utility, as only this class's
+     * helper is used in restoring the EDataGraph. 
+     */
+    public static EDataObject read(
+    		EClass eClass,
+    		String id,
+    		LdapContext containerContext) 
+    throws NamingException
+    {
+        String namespaceURI                 =
+            eClass.getEPackage().
+            getNsURI();
+
+        EAttribute idEAttribute             =
+    		eClass.getEIDAttribute();
+
+        String qualifiedIDEAttributeName    =
+            SimpleTypeNamespaceQualifier.
+            qualify( 
+                namespaceURI, 
+                eClass.getName(), 
+                idEAttribute.getName() );
+        
+    	String normalizedIDEAttributeName   =
+        	QualifiedNameNormalizer.
+        	normalize(qualifiedIDEAttributeName);
+        
+    	String eDataObjectRDN               = 
+        	normalizedIDEAttributeName + "=" + id;
+        
+        LdapContext eDataObjectContext      =
+        	(LdapContext) 
+        	containerContext.
+        	lookup(eDataObjectRDN);
+        
+        Attributes attributes               = 
+        	eDataObjectContext.getAttributes("");
+        
+        EDataObject eDataObject =
+        	(EDataObject)
+        	eClass.getEPackage().
+        	getEFactoryInstance().
+        	create(eClass);
+
+        EDataObjectReaderHelper.
+        restoreEAttributes( 
+            eClass, 
+            eDataObject, 
+            namespaceURI, 
+            attributes );
+        
+        return eDataObject;
+    }
+}
\ No newline at end of file

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReader.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReaderHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReaderHelper.java?view=auto&rev=562520
==============================================================================
--- incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReaderHelper.java (added)
+++ incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReaderHelper.java Fri Aug  3 09:40:00 2007
@@ -0,0 +1,161 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.emf.read;
+
+import java.util.List;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+public class EDataObjectReaderHelper
+implements DASConstants
+{
+    public static void restoreEAttributes(
+        EClass eClass,
+        EDataObject eDataObject,
+        String namespaceURI,
+        Attributes attributes) 
+    throws NamingException
+    {
+    	List<EAttribute> eAttributes        = 
+            eClass.getEAllAttributes();
+
+    	for (EAttribute eAttribute : eAttributes)
+    	{
+            String qualifiedEAttributeName  =
+                SimpleTypeNamespaceQualifier.
+                qualify( 
+                    namespaceURI, 
+                    eClass.getName(), 
+                    eAttribute.getName() );
+            
+        	String normalizedEAttributeName =
+            	QualifiedNameNormalizer.
+            	normalize(qualifiedEAttributeName);
+        	
+        	if (eAttribute.isMany())
+        	{
+        	    EList<Object> values = 
+        	        new BasicEList<Object>();
+        	    
+        	    Attribute attribute  = 
+        	        attributes.
+        	        get(normalizedEAttributeName);
+
+        	    for (int i = 0; i < attribute.size(); i++)
+        	    {
+        	        String value = (String) attribute.get(i);
+        	        
+        	        values.add(EcoreUtil.createFromString(
+                        eAttribute.getEAttributeType(), 
+                        value));
+        	    }
+        	    
+                eDataObject.eSet(
+                    eAttribute, values);
+        	}
+        	else
+        	{
+                String value          = 
+                    (String) 
+                    attributes.
+                    get(normalizedEAttributeName).
+                    get();
+                
+                eDataObject.eSet(
+                        eAttribute, 
+                        EcoreUtil.createFromString(
+                                eAttribute.getEAttributeType(), 
+                                value));
+        	}
+    	}
+    }
+
+    
+    //TODO Test all of these verifying that we get out what we put in
+    //TODO Move to helper
+    //TODO Note that we are using         	eDataObject.eSet(eAttribute, EcoreUtil.createFromString(eAttribute.getEAttributeType(), value)); instead
+    /*
+    public static void setEDataObjectFeature(
+    		EDataObject eDataObject,
+    		String value,
+    		EAttribute eAttribute)
+    {
+    	if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEString())
+    	{
+    		eDataObject.eSet(eAttribute, value);
+    	}
+    	else if (
+    			eAttribute.getEType() == EcorePackage.eINSTANCE.getEInt() ||
+    			eAttribute.getEType() == EcorePackage.eINSTANCE.getEIntegerObject())
+    	{
+    		eDataObject.eSet(eAttribute, new Integer(value));
+    	}
+    	else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ||
+    			eAttribute.getEType() == EcorePackage.eINSTANCE.getEBooleanObject())
+    	{
+    		eDataObject.eSet(eAttribute, new Boolean(value));
+    	}
+    	else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEFloat() ||
+    			eAttribute.getEType() == EcorePackage.eINSTANCE.getEFloatObject())
+    	{
+    		eDataObject.eSet(eAttribute, new Float(value));
+    	}
+    	else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEDouble() ||
+    			eAttribute.getEType() == EcorePackage.eINSTANCE.getEDoubleObject())
+    	{
+    		eDataObject.eSet(eAttribute, new Double(value));
+    	}
+    	else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEBigDecimal()) 
+    	{
+    		eDataObject.eSet(eAttribute, new BigDecimal(value));
+    	}
+    	else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEBigInteger() )
+    	{
+    		eDataObject.eSet(eAttribute, new BigInteger(value));
+    	}
+    	else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEByte() ||
+    			eAttribute.getEType() == EcorePackage.eINSTANCE.getEByteObject())
+    	{
+    		eDataObject.eSet(eAttribute, new Byte(value));
+    	}
+    	else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEByte() ||
+    			eAttribute.getEType() == EcorePackage.eINSTANCE.getEByteObject())
+    	{
+    		eDataObject.eSet(eAttribute, new Byte(value));
+    	}
+      	else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEByteArray())
+    	{
+      		throw new RuntimeException("Sorry - ByteArrays are not supported.");
+    	}
+    }
+    */
+}
\ No newline at end of file

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReaderHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReaderHelper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdater.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdater.java?view=auto&rev=562520
==============================================================================
--- incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdater.java (added)
+++ incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdater.java Fri Aug  3 09:40:00 2007
@@ -0,0 +1,63 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.emf.update;
+
+import java.util.Map;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.eclipse.emf.ecore.sdo.EChangeSummary;
+import org.eclipse.emf.ecore.sdo.EDataGraph;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+public class EDataGraphUpdater
+implements DASConstants
+{
+    public static void update(
+    		EDataGraph eDataGraph,
+    		LdapContext rootContext,
+    		Map<EDataObject, String> dataObjectToRelativeDNCache ) 
+    throws NamingException
+    {
+     	EChangeSummary eChangeSummary =
+    		(EChangeSummary) 
+    		eDataGraph.getChangeSummary();
+
+    	EDataGraphUpdaterHelper.
+    	processChangedDataObjects(
+    			eChangeSummary, 
+    			rootContext, 
+    			dataObjectToRelativeDNCache);
+    	
+    	EDataGraphUpdaterHelper.
+    	processCreatedDataObjects(
+    			eChangeSummary, 
+    			rootContext, 
+    			dataObjectToRelativeDNCache);
+    	
+    	EDataGraphUpdaterHelper.
+    	processDestroyedDataObjects(
+    			eChangeSummary, 
+    			rootContext, 
+    			dataObjectToRelativeDNCache);
+    }
+}
\ No newline at end of file

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdater.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdater.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdaterHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdaterHelper.java?view=auto&rev=562520
==============================================================================
--- incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdaterHelper.java (added)
+++ incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdaterHelper.java Fri Aug  3 09:40:00 2007
@@ -0,0 +1,228 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.emf.update;
+
+import java.util.Map;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.emf.create.EDataGraphCreatorHelper;
+import org.apache.tuscany.das.ldap.emf.create.EDataObjectCreatorHelper;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.EMap;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.change.FeatureChange;
+import org.eclipse.emf.ecore.sdo.EChangeSummary;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+
+public class EDataGraphUpdaterHelper
+{
+	public static void processDestroyedDataObjects(
+			EChangeSummary eChangeSummary,
+    		LdapContext containerContext,
+    		Map<EDataObject, String> dataObjectToRelativeDNCache) 
+	throws NamingException
+	{
+		EList<EObject> destroyedObjects                                           = 
+			eChangeSummary.
+			getObjectsToAttach();
+    	
+    	for (EObject destroyedObject : destroyedObjects)
+    	{
+    		String destroyedObjectRelativeDN = dataObjectToRelativeDNCache.get(destroyedObject);
+    		containerContext.destroySubcontext(destroyedObjectRelativeDN);
+    		dataObjectToRelativeDNCache.remove(destroyedObject);
+    	}
+	}
+	
+	public static void processCreatedDataObjects(
+			EChangeSummary eChangeSummary,
+    		LdapContext rootContext,
+    		Map<EDataObject, String> dataObjectToRelativeDNCache ) 
+	throws NamingException 
+	{
+		EList<EObject> createdObjects                                           = 
+			eChangeSummary.
+			getObjectsToDetach();
+    		
+            EDataGraphCreatorHelper.createChildren(
+            		createdObjects,
+            		rootContext,
+            		dataObjectToRelativeDNCache);
+	}
+	
+    public static void processChangedDataObjects(
+    		EChangeSummary eChangeSummary,
+    		LdapContext containerContext,
+    		Map<EDataObject, String> dataObjectToRelativeDNCache ) 
+    throws NamingException
+    {
+		EMap<EObject, EList<FeatureChange>> objectChanges      = 
+			eChangeSummary.getObjectChanges();
+    	
+    	for (EObject changedDataObject : objectChanges.keySet())
+    	{
+    		EList<FeatureChange> featureChanges                              =
+    			objectChanges.get(changedDataObject);
+    		
+    			ModificationItem[] modificationItems   =
+    				new ModificationItem[featureChanges.size()];
+    			
+    	        EClass changedDataObjectEClass                                         = 
+    	        	changedDataObject.eClass();
+    	        
+    	        String namespaceURI                                                              =
+    	            changedDataObjectEClass.
+    	            getEPackage().
+    	            getNsURI();
+
+        		for (int i = 0; i < featureChanges.size(); i++)
+        		{
+        			FeatureChange featureChange              = 
+        				featureChanges.get(i);
+        			
+        			EStructuralFeature eStructuralFeature = 
+        				featureChange.getFeature();
+        			
+        			if (eStructuralFeature instanceof EAttribute)
+        			{
+        				//TODO Note that we are not checking multiplicity many on EAttributes
+        		        String qualifiedEAttributeName                            =
+        		            SimpleTypeNamespaceQualifier.
+        		            qualify( 
+        		                namespaceURI, 
+        		                changedDataObjectEClass.getName(), 
+        		                eStructuralFeature.getName() );
+        		        
+        		        String normalizedEAttributeName                        =
+        		        	QualifiedNameNormalizer.
+        		        	normalize(qualifiedEAttributeName);
+        		        
+        		        //TODO PUt processEAttribute in  a more generic class
+        		        Attribute attribute = 
+        		        	EDataObjectCreatorHelper.processEAttribute(
+        		        		(EAttribute)eStructuralFeature,
+        		        		namespaceURI,
+        		        		changedDataObjectEClass,
+        		        		(EDataObject) changedDataObject);
+
+        				modificationItems[i] = 
+        					new ModificationItem(
+        							DirContext.REPLACE_ATTRIBUTE,
+        							attribute);
+        			}
+        			else
+        			{
+        				String qualifiedEReferenceName                            =
+        		            SimpleTypeNamespaceQualifier.
+        		            qualify( 
+        		                namespaceURI, 
+        		                changedDataObjectEClass.getName(), 
+        		                eStructuralFeature.getName() );
+        		        
+        		        String normalizedEReferenceName                        =
+        		        	QualifiedNameNormalizer.
+        		        	normalize(qualifiedEReferenceName);
+
+        		        Attribute attribute = 
+        		        	new BasicAttribute(normalizedEReferenceName);
+
+        		        if (eStructuralFeature.isMany())
+        		        {
+        		        	EList<EDataObject> referenceList = 
+        		        		(EList<EDataObject>) changedDataObject.eGet(eStructuralFeature);
+        		        	
+        		        	if (referenceList.size() > 0 && referenceList!=null)
+        		        	{
+                		        for (EDataObject eDataObject : referenceList)
+                		        {
+                		        	attribute.add(
+                		        			eDataObject.
+                		        			eGet(
+                		        					eDataObject.
+                		        					eClass().
+                		        					getEIDAttribute()));
+                		        	
+                    				modificationItems[i] = 
+                    					new ModificationItem(
+                    							DirContext.REPLACE_ATTRIBUTE,
+                    							attribute);
+                		        }
+        		        	}
+        		        	else 
+        		        	{
+        		        		modificationItems[i] = 
+                					new ModificationItem(
+                							DirContext.REMOVE_ATTRIBUTE,
+                							attribute);
+        		        	}
+        		        }
+        		        else
+        		        {
+        		        	EDataObject eDataObject = 
+        		        		(EDataObject) 
+        		        		changedDataObject.
+        		        		eGet(eStructuralFeature);
+        		        	
+        		        	if (eDataObject != null)
+        		        	{
+            		        	attribute.add(
+            		        			eDataObject.
+            		        			eGet(
+            		        					eDataObject.
+            		        					eClass().
+            		        					getEIDAttribute()));
+            		        	
+                				modificationItems[i] = 
+                					new ModificationItem(
+                							DirContext.REPLACE_ATTRIBUTE,
+                							attribute);
+        		        	}
+        		        	else
+        		        	{
+                				modificationItems[i] = 
+                					new ModificationItem(
+                							DirContext.REMOVE_ATTRIBUTE,
+                							attribute);
+        		        	}
+        		        }
+        			}
+    		}
+    		String relativeDN = 
+				dataObjectToRelativeDNCache.
+				get(changedDataObject);
+
+    		containerContext.modifyAttributes(
+					relativeDN, 
+					modificationItems);
+    	}
+    }
+}
\ No newline at end of file

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdaterHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdaterHelper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/constants/EncryptionConstants.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/constants/EncryptionConstants.java?view=auto&rev=562520
==============================================================================
--- incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/constants/EncryptionConstants.java (added)
+++ incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/constants/EncryptionConstants.java Fri Aug  3 09:40:00 2007
@@ -0,0 +1,26 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.encryption.constants;
+
+public interface EncryptionConstants
+{
+    String MD5 = "MD5";
+    String SHA1 = "SHA-1";//Produces longer hashes than MD5
+}

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/constants/EncryptionConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/constants/EncryptionConstants.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/util/ChecksumUtils.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/util/ChecksumUtils.java?view=auto&rev=562520
==============================================================================
--- incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/util/ChecksumUtils.java (added)
+++ incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/util/ChecksumUtils.java Fri Aug  3 09:40:00 2007
@@ -0,0 +1,38 @@
+
+package org.apache.tuscany.das.ldap.encryption.util;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+import org.apache.tuscany.das.ldap.encryption.constants.EncryptionConstants;
+
+public class ChecksumUtils
+implements EncryptionConstants
+{
+    public static String computeMD5Hash(String string) 
+    throws NoSuchAlgorithmException
+    {
+        MessageDigest messageDigest = MessageDigest.getInstance(MD5);
+        
+        byte[] digest               = 
+            messageDigest.digest(string.getBytes());
+    
+        StringBuffer hexString = new StringBuffer();
+        for (int i=0;i<digest.length;i++) {
+          hexString.append (
+            Integer.toHexString(0xFF & digest[i]));
+        }
+    
+        char[] hexStringCharacters = hexString.toString().toCharArray();
+        String checksum = "";
+        
+        for( char i : hexStringCharacters)
+        {
+            int ascii = (int) i;
+            checksum = checksum + Integer.toString(ascii);
+        }
+ 
+        return checksum;
+    }
+
+}

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/util/ChecksumUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/util/ChecksumUtils.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/ComplexTypeOIDCreator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/ComplexTypeOIDCreator.java?view=auto&rev=562520
==============================================================================
--- incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/ComplexTypeOIDCreator.java (added)
+++ incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/ComplexTypeOIDCreator.java Fri Aug  3 09:40:00 2007
@@ -0,0 +1,69 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.oid.create;
+
+import org.apache.tuscany.das.ldap.encryption.constants.EncryptionConstants;
+import org.apache.tuscany.das.ldap.encryption.util.ChecksumUtils;
+import org.apache.tuscany.das.ldap.util.ComplexTypeNamespaceQualifier;
+
+/**
+ * The Class UniqueOIDCreator.
+ * Creates unique OIDs for namespaced
+ * metadata such as the XSD DataType
+ * with (Class specific term) qualifiedNameURI 
+ * http://www.w3.org/2001/XMLSchema/string
+ * 
+ */
+public class ComplexTypeOIDCreator implements EncryptionConstants
+{
+    /**
+     * Creates a unique OID.
+     * 
+     * @param instanceClassName the instance class name
+     * @param oidPrefix the OID Branch
+     * @param simpleTypeName the name
+     * @param namespaceURI the metadata namespace URI
+     * 
+     * @return the string
+     * 
+     * @throws Exception the exception
+     */
+    public static String create(
+        String oidPrefix,
+        String namespaceURI,
+        String complexTypeName) 
+    throws Exception
+    {
+        String qualifiedNameURI = 
+            ComplexTypeNamespaceQualifier.qualify(
+                namespaceURI, 
+                complexTypeName);
+
+        String postfixOID = 
+            ChecksumUtils.computeMD5Hash(
+                qualifiedNameURI);
+        
+        postfixOID = 
+            OIDCreatorHelper.
+            calculateSegmentedOID(postfixOID);
+
+        return oidPrefix + "." + postfixOID;
+    }
+}
\ No newline at end of file

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/ComplexTypeOIDCreator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/ComplexTypeOIDCreator.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/OIDCreatorHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/OIDCreatorHelper.java?view=auto&rev=562520
==============================================================================
--- incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/OIDCreatorHelper.java (added)
+++ incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/OIDCreatorHelper.java Fri Aug  3 09:40:00 2007
@@ -0,0 +1,73 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.oid.create;
+
+public class OIDCreatorHelper
+{
+    private static int MAX_OID_SEGMENT_LENGTH = 8;
+    /**
+     * Calculate segmented OID.
+     * 
+     * @param oid the oid
+     * 
+     * @return the string
+     * 
+     * @throws Exception the exception
+     * 
+     * Note that the OID must be divided
+     * into segments less than 9 characters
+     * long.  This is an ApacheDS restriction
+     * on OID segment length.
+     */
+    public static String calculateSegmentedOID(String oid) throws Exception
+    {
+        if (oid.length() < 10)
+        {
+            throw new Exception("The length of the oid must be greater than 9 in order to ensure uniqueness.");
+        }
+        int oidLength = oid.length();
+        int numberOfPeriods  = oidLength / MAX_OID_SEGMENT_LENGTH;
+        
+        int beginIndex = 0;
+        int endIndex = MAX_OID_SEGMENT_LENGTH;
+        
+        String segmentedOID = 
+            oid.substring(beginIndex, endIndex ) + ".";
+
+        for (int i = 2; i < numberOfPeriods; i++)
+        {
+            beginIndex = (i-1) * MAX_OID_SEGMENT_LENGTH + 1;
+            endIndex = i * MAX_OID_SEGMENT_LENGTH;
+            segmentedOID +=  oid.substring( beginIndex, endIndex ) + ".";
+        }
+        int finalSegmentLength = oid.length() - (endIndex + 2);
+        
+        if ( finalSegmentLength > MAX_OID_SEGMENT_LENGTH )
+        {
+            segmentedOID += oid.substring( endIndex + 1,endIndex + 9  ) + ".";
+            segmentedOID += oid.substring( endIndex + 10, oid.length()  );
+        }
+        else
+        {
+            segmentedOID += oid.substring( endIndex + 1, oid.length()  );            
+        }
+        return segmentedOID;
+    }
+}

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/OIDCreatorHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/OIDCreatorHelper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/SimpleTypeOIDCreator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/SimpleTypeOIDCreator.java?view=auto&rev=562520
==============================================================================
--- incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/SimpleTypeOIDCreator.java (added)
+++ incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/SimpleTypeOIDCreator.java Fri Aug  3 09:40:00 2007
@@ -0,0 +1,66 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.oid.create;
+
+import org.apache.tuscany.das.ldap.encryption.constants.EncryptionConstants;
+import org.apache.tuscany.das.ldap.encryption.util.ChecksumUtils;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+
+/**
+ * The Class SimpleTypeOIDCreator.
+ * Creates unique OIDs for namespaced
+ * metadata such as the XSD DataType
+ * with (Class specific term) qualifiedNameURI 
+ * http://www.w3.org/2001/XMLSchema/string
+ * 
+ */
+public class SimpleTypeOIDCreator implements EncryptionConstants
+{
+    /**
+     * Creates a unique OID.
+     * 
+     * @param instanceClassName the instance class name
+     * @param oidPrefix the OID Branch
+     * @param complexTypeName the name
+     * @param namespaceURI the metadata namespace URI 
+     * 
+     * @return the string
+     * 
+     * @throws Exception the exception
+     */
+    public static String create(
+        String oidPrefix,
+        String namespaceURI,
+        String complexTypeName,
+        String simpleTypeName) 
+    throws Exception
+    {
+        String qualifiedNameURI = 
+            SimpleTypeNamespaceQualifier.qualify(
+                namespaceURI, 
+                complexTypeName, 
+                simpleTypeName);
+
+        String postfixOID = ChecksumUtils.computeMD5Hash(qualifiedNameURI);
+        
+        postfixOID = OIDCreatorHelper.calculateSegmentedOID(postfixOID);
+        return oidPrefix + "." + postfixOID;
+    }
+}
\ No newline at end of file

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/SimpleTypeOIDCreator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/SimpleTypeOIDCreator.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/Prototype.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/Prototype.java?view=auto&rev=562520
==============================================================================
--- incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/Prototype.java (added)
+++ incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/Prototype.java Fri Aug  3 09:40:00 2007
@@ -0,0 +1,74 @@
+package org.apache.tuscany.das.ldap.prototype.setup;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+
+public interface Prototype {
+	EClass userEClass                      = 
+		PrototypeUtilities.createUserEClass();
+	EClass authorizationEClass             = 
+		PrototypeUtilities.createAuthorizationEClass();
+	EClass configurationEClass             =
+		PrototypeUtilities.createConfigurationEClass();
+	
+	EAttribute userNameEAttribute          = 
+		PrototypeUtilities.createUserNameEAttribute();
+	EAttribute userAliasesEAttribute       = 
+        PrototypeUtilities.createUserAliasesEAttribute();
+    
+	EAttribute userPasswordEAttribute      = 
+		PrototypeUtilities.createUserPasswordEAttribute();
+	EAttribute userIDEAttribute            =
+		PrototypeUtilities.createUserIDEAttribute();
+	EAttribute userAgeEAttribute           =
+		PrototypeUtilities.createUserAgeEAttribute();
+	EAttribute userHeightEAttribute        =
+		PrototypeUtilities.createUserHeightEAttribute();
+	EAttribute userIsMaleEAttribute        =
+		PrototypeUtilities.createUserIsMaleEAttribute();
+	EReference userAuthorizationEReference = 
+		PrototypeUtilities.createUserAuthorizationEReference();
+	
+	EReference userConfigurationEReference = 
+		PrototypeUtilities.createUserConfigurationEReference();
+	
+
+	
+	
+	EAttribute authorizationFileEAttribute = 
+		PrototypeUtilities.createFileEAttribute();
+	EAttribute authorizationReadEAttribute = 
+		PrototypeUtilities.createReadAuthorizationEAttribute();
+	EAttribute authorizationWriteEAttribute= 
+		PrototypeUtilities.createWriteAuthorizationEAttribute();
+	EAttribute authorizationExecuteEAttribute              = 
+		PrototypeUtilities.createExecuteAuthorizationEAttribute();
+	EAttribute authorizationIDEAttribute                        = 
+		PrototypeUtilities.createAuthorizationIDEAttribute();
+	
+	EAttribute configurationIDEAttribute                        =
+		PrototypeUtilities.createConfigurationIDEAttribute();
+	
+	EReference configurationAuthorizationEReference =
+		PrototypeUtilities.createConfigurationAuthorizationEReference();
+	
+	EReference configurationAuthorizationsEReference =
+		PrototypeUtilities.createConfigurationAuthorizationsEReference();
+	
+	
+	EPackage  userEPackage                     = 
+		PrototypeUtilities.createUserEPackage();
+	
+	EFactory userEFactory                        =
+		userEPackage.getEFactoryInstance();
+	
+    EcoreFactory ecoreFactory                 = 
+    	EcoreFactory.eINSTANCE;
+    EcorePackage ecorePackage               = 
+    	EcorePackage.eINSTANCE;
+}

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/Prototype.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/Prototype.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/PrototypeUtilities.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/PrototypeUtilities.java?view=auto&rev=562520
==============================================================================
--- incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/PrototypeUtilities.java (added)
+++ incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/PrototypeUtilities.java Fri Aug  3 09:40:00 2007
@@ -0,0 +1,243 @@
+package org.apache.tuscany.das.ldap.prototype.setup;
+
+import org.apache.tuscany.das.ldap.testing.constants.DASTestingConstants;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl;
+
+public class PrototypeUtilities 
+implements DASTestingConstants {
+
+	/*
+	 * The User EClass is intended to be the root of the DataGraph
+	 * It should have a multiplicity many containment reference of type 
+	 * Authorization and a containment reference of type Configuration
+	 * The Configuration should have a single non-containment reference
+	 * of type Authorization.  
+	 */
+
+    public static EClass createUserEClass()
+    {
+        EClass userEClass                                     = 
+        	EcoreFactory.eINSTANCE.createEClass();
+        
+        userEClass.setName("User");
+        
+        return userEClass;
+    }
+    
+    public static EAttribute createUserIDEAttribute()
+    {
+        EAttribute id                         = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        id.setName( "id" );
+        id.setEType( EcorePackage.eINSTANCE.getEString() );
+        id.setID(true);
+        return id;
+    }
+
+    public static EAttribute createUserNameEAttribute()
+    {
+        EAttribute userName                         = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        userName.setName( "userName" );
+        userName.setEType( EcorePackage.eINSTANCE.getEString() );
+        return userName;
+    }
+
+    public static EAttribute createUserAliasesEAttribute()
+    {
+        EAttribute userAliases                         = 
+            EcoreFactory.eINSTANCE.createEAttribute();
+        userAliases.setName( "userAliases" );
+        userAliases.setLowerBound( 0 );
+        userAliases.setUpperBound( -1 );
+        userAliases.setEType( EcorePackage.eINSTANCE.getEString() );
+        return userAliases;
+    }
+
+    public static EAttribute createUserPasswordEAttribute()
+    {
+        EAttribute userPassword                    = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        userPassword.setName( "userPassword" );
+        userPassword.setEType( EcorePackage.eINSTANCE.getEString() );
+        return userPassword;
+    }
+    
+    public static EAttribute createUserAgeEAttribute()
+    {
+        EAttribute userAge                         = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        userAge.setName( "userAge" );
+        userAge.setEType( EcorePackage.eINSTANCE.getEInt() );
+        return userAge;
+    }
+
+    public static EAttribute createUserHeightEAttribute()
+    {
+        EAttribute userHeight                         = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        userHeight.setName( "userHeight" );
+        userHeight.setEType( EcorePackage.eINSTANCE.getEDouble() );
+        return userHeight;
+    }
+
+    public static EAttribute createUserIsMaleEAttribute()
+    {
+        EAttribute isMale                         = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        isMale.setName( "isMale" );
+        isMale.setEType( EcorePackage.eINSTANCE.getEBoolean() );
+        return isMale;
+    }
+    
+    public static EReference createUserAuthorizationEReference()
+    {
+    	EReference userAuthorizationEReference =
+    		EcoreFactory.eINSTANCE.createEReference();
+    	userAuthorizationEReference.setLowerBound(0);
+    	userAuthorizationEReference.setUpperBound(ETypedElement.UNBOUNDED_MULTIPLICITY);
+    	userAuthorizationEReference.setContainment(true);
+    	userAuthorizationEReference.setName("authorizationList");
+    	
+    	return userAuthorizationEReference;
+    }
+
+    public static EReference createUserConfigurationEReference()
+    {
+    	EReference userConfigurationEReference =
+    		EcoreFactory.eINSTANCE.createEReference();
+    	userConfigurationEReference.setLowerBound(0);
+    	userConfigurationEReference.setUpperBound(1);
+    	userConfigurationEReference.setContainment(true);
+    	userConfigurationEReference.setName("configuration");
+    	
+    	return userConfigurationEReference;
+    }
+
+    
+    public static EPackage createUserEPackage()
+    {
+        EPackage userEPackage                     = 
+        	EcoreFactory.eINSTANCE.createEPackage();
+        userEPackage.setName( "userPackage" );
+        userEPackage.setNsPrefix( "user" );
+        userEPackage.setNsURI( xsdNamespace );
+        
+        userEPackage.setEFactoryInstance(
+            new DynamicEDataObjectImpl.FactoryImpl());
+        
+        return userEPackage;
+    }
+    
+    public static EClass createAuthorizationEClass()
+    {
+        EClass authorizationEClass         = 
+        	EcoreFactory.eINSTANCE.createEClass();
+        
+        authorizationEClass.setName("Authorization");
+
+        return authorizationEClass;
+    }
+    
+    public static EAttribute createAuthorizationIDEAttribute()
+    {
+        EAttribute id                         = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        id.setName( "id" );
+        id.setEType( EcorePackage.eINSTANCE.getEString() );
+        id.setID(true);
+        return id;
+    }
+    
+    public static EAttribute createFileEAttribute()
+    {
+        EAttribute fileNameEAttribute     = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        fileNameEAttribute.setName( "fileName" );
+        fileNameEAttribute.setEType( EcorePackage.eINSTANCE.getEString() );
+        return fileNameEAttribute;
+        
+    }
+    
+    public static EAttribute createWriteAuthorizationEAttribute()
+    {
+        EAttribute writeAuthorizationEAttribute  = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        writeAuthorizationEAttribute.setName( "writeAuthorization" );
+        writeAuthorizationEAttribute.setEType( EcorePackage.eINSTANCE.getEBoolean() );
+        return writeAuthorizationEAttribute;
+    }
+
+    public static EAttribute createReadAuthorizationEAttribute()
+    {
+        EAttribute readAuthorizationEAttribute  = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        readAuthorizationEAttribute.setName( "readAuthorization" );
+        readAuthorizationEAttribute.setEType( EcorePackage.eINSTANCE.getEBoolean() );
+        return readAuthorizationEAttribute;
+    }
+
+    public static EAttribute createExecuteAuthorizationEAttribute()
+    {
+        EAttribute readExecuteEAttribute  = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        readExecuteEAttribute.setName( "executeAuthorization" );
+        readExecuteEAttribute.setEType( EcorePackage.eINSTANCE.getEBoolean() );
+        return readExecuteEAttribute;
+    }
+
+    
+    public static EClass createConfigurationEClass()
+    {
+        EClass configurationEClass                                     = 
+        	EcoreFactory.eINSTANCE.createEClass();
+        
+        configurationEClass.setName("Configuration");
+        
+        return configurationEClass;
+    }
+    
+    public static EAttribute createConfigurationIDEAttribute()
+    {
+        EAttribute id                         = 
+        	EcoreFactory.eINSTANCE.createEAttribute();
+        id.setName( "id" );
+        id.setEType( EcorePackage.eINSTANCE.getEString() );
+        id.setID(true);
+        return id;
+    }
+    
+    public static EReference createConfigurationAuthorizationEReference()
+    {
+    	EReference authorizationEReference =
+    		EcoreFactory.eINSTANCE.createEReference();
+    	authorizationEReference.setLowerBound(0);
+    	authorizationEReference.setUpperBound(1);
+    	authorizationEReference.setContainment(false);
+    	//authorizationEReference.setEType(createAuthorizationEClass()); Do this in the testing code.
+    	authorizationEReference.setName("authorization");
+    	
+    	return authorizationEReference;
+    }
+    
+    public static EReference createConfigurationAuthorizationsEReference()
+    {
+    	EReference authorizationsEReference =
+    		EcoreFactory.eINSTANCE.createEReference();
+    	authorizationsEReference.setLowerBound(0);
+    	authorizationsEReference.setUpperBound(ETypedElement.UNBOUNDED_MULTIPLICITY);
+    	authorizationsEReference.setContainment(false);
+    	//authorizationEReference.setEType(createAuthorizationEClass()); Do this in the testing code.
+    	authorizationsEReference.setName("authorizations");
+    	
+    	return authorizationsEReference;
+    }
+
+}

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/PrototypeUtilities.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/PrototypeUtilities.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/CommonSetupTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/CommonSetupTest.java?view=auto&rev=562520
==============================================================================
--- incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/CommonSetupTest.java (added)
+++ incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/CommonSetupTest.java Fri Aug  3 09:40:00 2007
@@ -0,0 +1,264 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.prototype.setup.test;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.tuscany.das.ldap.prototype.setup.Prototype;
+import org.apache.tuscany.das.ldap.schema.embedded.setup.test.EcoreSchemaAndDASContextsSetup;
+import org.apache.tuscany.das.ldap.schema.emf.create.EObjectClassCreator;
+import org.apache.tuscany.das.ldap.schema.emf.destroy.EObjectClassDestroyer;
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+public class CommonSetupTest 
+extends EcoreSchemaAndDASContextsSetup
+implements Prototype
+{
+    protected EObjectClassCreator eObjectClassCreator     = null;
+
+	protected EDataObject userDataObject                  = null;
+	protected EDataObject authorizationDataObject0        = null;
+	protected EDataObject authorizationDataObject1        = null;
+	protected EDataObject configurationDataObject         = null;
+	
+	protected static List<EClass> 
+    processedEClassifiers                                 = null;
+
+	protected String userDataObjectRDN                    = 
+		"example-com-users-accounts-User-id=1";
+	protected String authorizationDataObject1RDN          = 
+		"example-com-users-accounts-Authorization-id=2,cn=authorizationList,example-com-users-accounts-User-id=1";
+	protected String authorizationDataObject2RDN          = 
+		"example-com-users-accounts-Authorization-id=3,cn=authorizationList,example-com-users-accounts-User-id=1";
+	protected String configurationDataObjectRDN           = 
+		"example-com-users-accounts-Configuration-id=5,cn=configuration,example-com-users-accounts-User-id=1";
+
+	protected String configurationContainingFeatureRDN    = 
+		"cn=configuration";
+	protected String authorizationListContainingFeatureRDN= 
+		"cn=authorizationList";
+	
+	protected LdapContext authorizationContainerContext   = null;
+	protected LdapContext configurationContainerContext   = null;
+	protected LdapContext userContainerContext            = null;
+
+	protected Map<EDataObject, String> dataObjectToRelativeDNCache   = null;
+	
+	public void tearDown() throws NamingException, Exception
+	{
+		rootContext.destroySubcontext(userDataObjectRDN);
+
+        EObjectClassDestroyer.
+            destroy(
+                metaContext,
+                ecoreAttributeTypesContext,
+                ecoreObjectClassesContext, 
+                userEClass, 
+                TUSCANY_OID_PREFIX_VALUE );
+           
+        super.tearDown();
+	}
+	
+	public void setUp() throws Exception
+	{
+        FileUtils.deleteDirectory(new File("server-work"));
+        
+		dataObjectToRelativeDNCache          =
+    		new Hashtable<EDataObject, String>();
+
+		super.setUp();
+		
+        userAuthorizationEReference.
+        setEType(authorizationEClass);
+        
+        userConfigurationEReference.
+        setEType(configurationEClass);
+        
+        configurationAuthorizationEReference.
+        setEType(authorizationEClass);
+
+        configurationAuthorizationsEReference.
+        setEType(authorizationEClass);
+
+        userEClass.
+        getEStructuralFeatures().
+        add( userNameEAttribute );
+        
+        userEClass.
+        getEStructuralFeatures().
+        add( userAliasesEAttribute );
+        
+        userEClass.
+        getEStructuralFeatures().
+        add( userPasswordEAttribute );
+        userEClass.
+        getEStructuralFeatures().
+        add( userAgeEAttribute );
+        userEClass.
+        getEStructuralFeatures().
+        add( userHeightEAttribute );
+        userEClass.
+        getEStructuralFeatures().
+        add( userIsMaleEAttribute );
+        userEClass.
+        getEStructuralFeatures().
+        add( userIDEAttribute );
+        userEClass.
+        getEStructuralFeatures().
+        add( userAuthorizationEReference );
+        userEClass.
+        getEStructuralFeatures().
+        add( userConfigurationEReference );
+
+		userEPackage.getEClassifiers().add(userEClass);
+		
+    	userDataObject =
+    		(EDataObject) 
+    		userEFactory.create(userEClass);
+    	
+    	userDataObject.eSet(userNameEAttribute,"ole");
+    	userDataObject.eSet(userPasswordEAttribute,"secret");
+    	userDataObject.eSet(userIDEAttribute, "1");
+    	userDataObject.eSet(userAgeEAttribute, 33);
+    	userDataObject.eSet(userHeightEAttribute, 6.11);
+    	userDataObject.eSet(userIsMaleEAttribute, true);
+    	
+    	EList<String> userAliases = new BasicEList<String>();
+    	userAliases.add("neo");
+    	userAliases.add("trinity");
+    	userAliases.add("morpheus");
+    	
+    	userDataObject.eSet( userAliasesEAttribute, userAliases );
+
+    	authorizationEClass.
+		getEStructuralFeatures().
+		add(authorizationFileEAttribute);
+
+		authorizationEClass.
+		getEStructuralFeatures().
+		add(authorizationWriteEAttribute);
+
+		authorizationEClass.
+		getEStructuralFeatures().
+		add(authorizationReadEAttribute);
+		
+		authorizationEClass.
+		getEStructuralFeatures().
+		add(authorizationExecuteEAttribute);
+
+		authorizationEClass.
+		getEStructuralFeatures().
+		add(authorizationIDEAttribute);
+		
+		userEPackage.getEClassifiers().
+		add(authorizationEClass);
+				
+    	authorizationDataObject0  =
+    		(EDataObject) 
+    		userEFactory.create(authorizationEClass);
+    	
+    	authorizationDataObject1  =
+    		(EDataObject) 
+    		userEFactory.create(authorizationEClass);
+    	
+    	authorizationDataObject0.eSet(authorizationFileEAttribute,"somefile.text");
+    	authorizationDataObject0.eSet(authorizationWriteEAttribute, true);
+    	authorizationDataObject0.eSet(authorizationReadEAttribute,true);
+    	authorizationDataObject0.eSet(authorizationExecuteEAttribute,true);
+    	authorizationDataObject0.eSet(authorizationIDEAttribute, "2");
+
+    	authorizationDataObject1.eSet(authorizationFileEAttribute,"someOtherfile.text");
+    	authorizationDataObject1.eSet(authorizationWriteEAttribute,Boolean.TRUE);
+    	authorizationDataObject1.eSet(authorizationReadEAttribute,true);
+    	authorizationDataObject1.eSet(authorizationExecuteEAttribute,true);
+    	authorizationDataObject1.eSet(authorizationIDEAttribute, "3");
+    	
+    	EList<EDataObject> userDataObjectAuthorizationList =
+    		new BasicEList<EDataObject>();
+    	
+    	userDataObjectAuthorizationList.add(authorizationDataObject0);
+    	userDataObjectAuthorizationList.add(authorizationDataObject1);
+    	
+		userDataObject.eSet(
+				userAuthorizationEReference, 
+				userDataObjectAuthorizationList);
+		
+		configurationEClass.
+		getEStructuralFeatures().
+		add(configurationIDEAttribute);
+		
+		configurationEClass.
+		getEStructuralFeatures().
+		add(configurationAuthorizationEReference);
+		
+		configurationEClass.
+		getEStructuralFeatures().
+		add(configurationAuthorizationsEReference);
+		
+		userEPackage.getEClassifiers().
+		add(configurationEClass);
+		
+		configurationDataObject  =
+    		(EDataObject) 
+    		userEFactory.create(configurationEClass);
+		
+		userDataObject.eSet(
+				userConfigurationEReference, 
+				configurationDataObject);
+		
+		configurationDataObject.eSet(
+				configurationIDEAttribute, 
+				"5");
+
+		configurationDataObject.eSet(
+				configurationAuthorizationEReference, 
+				authorizationDataObject0);
+		
+		configurationDataObject.eSet(
+				configurationAuthorizationsEReference, 
+				userDataObjectAuthorizationList);
+            
+        processedEClassifiers                   = 
+            new ArrayList<EClass>();
+        
+        eObjectClassCreator      =
+            new EObjectClassCreator();
+        
+        eObjectClassCreator.
+        create(
+            metaContext,
+            ecoreAttributeTypesContext,
+            ecoreObjectClassesContext,
+            userEClass, 
+            processedEClassifiers,
+            TUSCANY_OID_PREFIX_VALUE );
+	}
+}
\ No newline at end of file

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/CommonSetupTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/CommonSetupTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataGraphSetupTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataGraphSetupTest.java?view=auto&rev=562520
==============================================================================
--- incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataGraphSetupTest.java (added)
+++ incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataGraphSetupTest.java Fri Aug  3 09:40:00 2007
@@ -0,0 +1,138 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.prototype.setup.test;
+
+import javax.naming.NamingException;
+
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.emf.create.EDataGraphCreator;
+import org.apache.tuscany.das.ldap.schema.emf.destroy.EObjectClassDestroyer;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.sdo.EDataGraph;
+import org.eclipse.emf.ecore.sdo.SDOFactory;
+import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl;
+
+public class EDataGraphSetupTest 
+extends CommonSetupTest
+{
+	protected EDataGraph eDataGraph                   = null;
+	protected boolean readException                   = false;
+	
+	public void tearDown() throws NamingException, Exception
+	{
+        if (dataObjectToRelativeDNCache.containsValue(authorizationDataObject1RDN)
+            || readException)
+		{
+			rootContext.destroySubcontext(authorizationDataObject1RDN);			
+		}
+		if (dataObjectToRelativeDNCache.containsValue(authorizationDataObject2RDN)
+		    || readException)
+		{
+			rootContext.destroySubcontext(authorizationDataObject2RDN);			
+		}
+		if (dataObjectToRelativeDNCache.containsValue(configurationDataObjectRDN)
+		    || readException)
+		{
+			rootContext.destroySubcontext(configurationDataObjectRDN);			
+		}
+		userContainerContext.destroySubcontext(configurationContainingFeatureRDN);
+		
+		userContainerContext.destroySubcontext(authorizationListContainingFeatureRDN);
+
+        EObjectClassDestroyer.
+        destroy(
+            metaContext,
+            ecoreAttributeTypesContext,
+            ecoreObjectClassesContext, 
+            authorizationEClass, 
+            TUSCANY_OID_PREFIX_VALUE );
+
+        EObjectClassDestroyer.
+        destroy(
+            metaContext,
+            ecoreAttributeTypesContext,
+            ecoreObjectClassesContext, 
+            configurationEClass, 
+            TUSCANY_OID_PREFIX_VALUE );
+           
+        super.tearDown();
+	}
+	
+	public void setUp() throws Exception
+	{
+		super.setUp();
+		
+        eObjectClassCreator.
+        create(
+            metaContext,
+            ecoreAttributeTypesContext,
+            ecoreObjectClassesContext,
+            authorizationEClass, 
+            processedEClassifiers,
+            TUSCANY_OID_PREFIX_VALUE );
+
+        eObjectClassCreator.
+        create(
+            metaContext,
+            ecoreAttributeTypesContext,
+            ecoreObjectClassesContext,
+            configurationEClass, 
+            processedEClassifiers,
+            TUSCANY_OID_PREFIX_VALUE );
+
+    	eDataGraph             =
+    		SDOFactory.
+    		eINSTANCE.
+    		createEDataGraph();
+    	   		
+    	eDataGraph.setERootObject(userDataObject);
+    	
+    	ResourceSet resourceSet = new ResourceSetImpl();
+        resourceSet.getResourceFactoryRegistry().
+        getExtensionToFactoryMap().put
+        ("xml",
+        new XMLResourceFactoryImpl());
+    	
+    	eDataGraph.setResourceSet(resourceSet);
+    	
+    	EDataGraphCreator.create(
+				eDataGraph,
+				rootContext,
+				dataObjectToRelativeDNCache);
+    	
+    	userContainerContext = 
+    		(LdapContext) 
+    		rootContext.
+    		lookup(userDataObjectRDN);
+    	
+    	authorizationContainerContext =
+    		(LdapContext) 
+    		userContainerContext.
+    		lookup(authorizationListContainingFeatureRDN);
+    	
+    	configurationContainerContext                             =
+    		(LdapContext) 
+    		userContainerContext.
+    		lookup(configurationContainingFeatureRDN);
+
+	}
+}
\ No newline at end of file

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataGraphSetupTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataGraphSetupTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataObjectSetupTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataObjectSetupTest.java?view=auto&rev=562520
==============================================================================
--- incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataObjectSetupTest.java (added)
+++ incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataObjectSetupTest.java Fri Aug  3 09:40:00 2007
@@ -0,0 +1,49 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.tuscany.das.ldap.prototype.setup.test;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.emf.create.EDataObjectCreator;
+
+public class EDataObjectSetupTest 
+extends CommonSetupTest
+{
+	public void tearDown() throws NamingException, Exception
+	{
+        super.tearDown();
+	}
+	
+	public void setUp() throws Exception
+	{
+		super.setUp();
+		
+   		EDataObjectCreator.create(
+   				userDataObject,
+   				rootContext,
+   				dataObjectToRelativeDNCache);
+   		
+    	userContainerContext = 
+    		(LdapContext) 
+    		rootContext.
+    		lookup(userDataObjectRDN);
+	}
+}
\ No newline at end of file

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataObjectSetupTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataObjectSetupTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message