diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-02 22:21:03 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-02 22:21:03 +0000 |
commit | f3e3191c911992ae4b55cf1619206ad7dd2b7c9f (patch) | |
tree | 59522e24f2dcb85cf55f7b4eb9e161382059fe45 /das-java/contrib | |
parent | 1a07cc91f40d1a8307189f746f6f55e3be7bb6d5 (diff) |
Moving LDAP DAS to contrib folder at new SVN structure
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@832142 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'das-java/contrib')
147 files changed, 17177 insertions, 0 deletions
diff --git a/das-java/contrib/ldap/das.ldap.configuration.model.ecore.v100/model/model.ecore b/das-java/contrib/ldap/das.ldap.configuration.model.ecore.v100/model/model.ecore new file mode 100644 index 0000000000..0ba9341bcc --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.configuration.model.ecore.v100/model/model.ecore @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage xmi:version="2.0" + xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="model" + nsURI="http://org.apache.tuscany/das.ldap.configuration.model.ecore.v100" nsPrefix="tuscany"> + <eClassifiers xsi:type="ecore:EClass" name="Configuration"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="host" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" + defaultValueLiteral="localhost"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="port" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" + defaultValueLiteral="10389"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="initialContextFactory" + eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" defaultValueLiteral="org.apache.directory.server.core.jndi.CoreContextFactory"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="dasPartitionName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" + defaultValueLiteral="das"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="schemaPartitionName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" + defaultValueLiteral="schema"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="securityPrincipal" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" + defaultValueLiteral="uid=admin,ou=system"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="securityAuthenticationType" + eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" defaultValueLiteral="simple"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="securityCredentials" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" + defaultValueLiteral="secret"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="nlog4jConfigurationFilePath" + eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" defaultValueLiteral="src/test/resources/log4j.properties"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="embedded" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean" + defaultValueLiteral="false"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="DASMeta"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="supportedSchemas" upperBound="-1" + eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" defaultValueLiteral="localhost"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" + defaultValueLiteral="0" iD="true"/> + </eClassifiers> +</ecore:EPackage> diff --git a/das-java/contrib/ldap/das.ldap.configuration.model.ecore.v100/model/model.genmodel b/das-java/contrib/ldap/das.ldap.configuration.model.ecore.v100/model/model.genmodel new file mode 100644 index 0000000000..0535a4bbcc --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.configuration.model.ecore.v100/model/model.genmodel @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<genmodel:GenModel xmi:version="2.0" + xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" + xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/das.ldap.configuration.model.v100/src/main/java" + editDirectory="/das.ldap.configuration.model.ecore.v100.edit/src" editorDirectory="/das.ldap.configuration.model.ecore.v100.editor/src" + modelPluginID="das.ldap.configuration.model.ecore.v100" modelName="Model" rootExtendsInterface="" + rootExtendsClass="org.eclipse.emf.ecore.sdo.impl.EDataObjectImpl" rootImplementsInterface="org.eclipse.emf.ecore.sdo.InternalEDataObject" + suppressEMFTypes="true" suppressEMFMetaData="true" featureMapWrapperInterface="commonj.sdo.Sequence" + featureMapWrapperInternalInterface="org.eclipse.emf.ecore.sdo.util.ESequence" + featureMapWrapperClass="org.eclipse.emf.ecore.sdo.util.BasicESequence" importerID="org.eclipse.emf.importer.ecore" + complianceLevel="5.0"> + <foreignModel>model.ecore</foreignModel> + <staticPackages>http://www.eclipse.org/emf/2003/SDO</staticPackages> + <modelPluginVariables>EMF_COMMONJ_SDO=org.eclipse.emf.commonj.sdo</modelPluginVariables> + <modelPluginVariables>EMF_ECORE_SDO=org.eclipse.emf.ecore.sdo</modelPluginVariables> + <genPackages prefix="Configuration" basePackage="org.apache.tuscany" disposableProviderFactory="true" + ecorePackage="model.ecore#/"> + <genClasses ecoreClass="model.ecore#//Configuration"> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute model.ecore#//Configuration/host"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute model.ecore#//Configuration/port"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute model.ecore#//Configuration/initialContextFactory"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute model.ecore#//Configuration/dasPartitionName"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute model.ecore#//Configuration/schemaPartitionName"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute model.ecore#//Configuration/securityPrincipal"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute model.ecore#//Configuration/securityAuthenticationType"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute model.ecore#//Configuration/securityCredentials"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute model.ecore#//Configuration/nlog4jConfigurationFilePath"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute model.ecore#//Configuration/embedded"/> + </genClasses> + <genClasses ecoreClass="model.ecore#//DASMeta"> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute model.ecore#//DASMeta/supportedSchemas"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute model.ecore#//DASMeta/id"/> + </genClasses> + </genPackages> +</genmodel:GenModel> diff --git a/das-java/contrib/ldap/das.ldap.configuration.model.ecore.v100/pom.xml b/das-java/contrib/ldap/das.ldap.configuration.model.ecore.v100/pom.xml new file mode 100644 index 0000000000..2d862f55b2 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.configuration.model.ecore.v100/pom.xml @@ -0,0 +1,11 @@ +<?xml version="1.0"?><project> + <parent> + <artifactId>tuscany-das-ldap</artifactId> + <groupId>org.apache.tuscany.das</groupId> + <version>1.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>das.ldap.configuration.model.ecore.v100</artifactId> + <name></name> + <url></url> +</project>
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap.configuration.model.v100/META-INF/MANIFEST.MF b/das-java/contrib/ldap/das.ldap.configuration.model.v100/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..e9569eefae --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.configuration.model.v100/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: das.ldap.configuration.model.ecore.v100; singleton:=true +Bundle-Version: 1.0.0 +Bundle-ClassPath: . +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Export-Package: org.apache.tuscany.model, + org.apache.tuscany.model.impl, + org.apache.tuscany.model.util +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.emf.ecore;visibility:=reexport, + org.eclipse.emf.commonj.sdo;visibility:=reexport, + org.eclipse.emf.ecore.sdo;visibility:=reexport +Eclipse-LazyStart: true diff --git a/das-java/contrib/ldap/das.ldap.configuration.model.v100/build.properties b/das-java/contrib/ldap/das.ldap.configuration.model.v100/build.properties new file mode 100644 index 0000000000..66d9c2d48b --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.configuration.model.v100/build.properties @@ -0,0 +1,14 @@ + +# <copyright> +# </copyright> +# +# $Id$ + +bin.includes = .,\ + model/,\ + META-INF/,\ + plugin.xml,\ + plugin.properties +jars.compile.order = . +source.. = src/ +output.. = bin/ diff --git a/das-java/contrib/ldap/das.ldap.configuration.model.v100/plugin.properties b/das-java/contrib/ldap/das.ldap.configuration.model.v100/plugin.properties new file mode 100644 index 0000000000..2eb18d8518 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.configuration.model.v100/plugin.properties @@ -0,0 +1,20 @@ + +# <copyright> +# </copyright> +# +# $Id$ + +# ==================================================================== +# To code developer: +# Do NOT change the properties between this line and the +# "%%% END OF TRANSLATED PROPERTIES %%%" line. +# Make a new property name, append to the end of the file and change +# the code to use the new property. +# ==================================================================== + +# ==================================================================== +# %%% END OF TRANSLATED PROPERTIES %%% +# ==================================================================== + +pluginName = Model Model +providerName = www.example.org diff --git a/das-java/contrib/ldap/das.ldap.configuration.model.v100/plugin.xml b/das-java/contrib/ldap/das.ldap.configuration.model.v100/plugin.xml new file mode 100644 index 0000000000..d840c5a51b --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.configuration.model.v100/plugin.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.0"?> + +<!-- + <copyright> + </copyright> + + $Id$ +--> + +<plugin> + + <extension point="org.eclipse.emf.ecore.generated_package"> + <package + uri = "http://org.apache.tuscany/das.ldap.configuration.model.ecore.v100" + class = "org.apache.tuscany.model.impl.ConfigurationPackageImpl" /> + </extension> + +</plugin> diff --git a/das-java/contrib/ldap/das.ldap.configuration.model.v100/pom.xml b/das-java/contrib/ldap/das.ldap.configuration.model.v100/pom.xml new file mode 100644 index 0000000000..27da7eddc6 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.configuration.model.v100/pom.xml @@ -0,0 +1,173 @@ +<?xml version="1.0"?><project> + <parent> + <artifactId>tuscany-das-ldap</artifactId> + <groupId>org.apache.tuscany.das</groupId> + <version>1.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>das.ldap.configuration.model.v100</artifactId> + <name></name> + + <url>http://pyramidetechnologies.com/model/archetype</url> + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ant</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>codegen</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>codegen-ecore</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>codegen-ecore-ui</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>codegen-ui</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>common</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>commonj-sdo</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>common-ui</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>converter</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore-change</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore-change-edit</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore-edit</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore-sdo</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore-sdo-edit</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore-xmi</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>edit</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>edit-ui</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>emf</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>exporter</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>importer</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>importer-ecore</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>importer-java</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>importer-rose</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-ecore2ecore</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-ecore2ecore-editor</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-ecore2xml</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-ecore2xml-ui</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-ui</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-xsd2ecore</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-xsd2ecore-editor</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.xsd</groupId> + <artifactId>ecore-exporter</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.xsd</groupId> + <artifactId>ecore-importer</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.xsd</groupId> + <artifactId>edit</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.xsd</groupId> + <artifactId>xsd</artifactId> + </dependency> + </dependencies> +</project>
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/Configuration.java b/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/Configuration.java new file mode 100644 index 0000000000..f885a91f68 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/Configuration.java @@ -0,0 +1,296 @@ +/** + * <copyright> + * </copyright> + * + * $Id$ + */ +package org.apache.tuscany.model; + + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Configuration</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.apache.tuscany.model.Configuration#getHost <em>Host</em>}</li> + * <li>{@link org.apache.tuscany.model.Configuration#getPort <em>Port</em>}</li> + * <li>{@link org.apache.tuscany.model.Configuration#getInitialContextFactory <em>Initial Context Factory</em>}</li> + * <li>{@link org.apache.tuscany.model.Configuration#getDasPartitionName <em>Das Partition Name</em>}</li> + * <li>{@link org.apache.tuscany.model.Configuration#getSchemaPartitionName <em>Schema Partition Name</em>}</li> + * <li>{@link org.apache.tuscany.model.Configuration#getSecurityPrincipal <em>Security Principal</em>}</li> + * <li>{@link org.apache.tuscany.model.Configuration#getSecurityAuthenticationType <em>Security Authentication Type</em>}</li> + * <li>{@link org.apache.tuscany.model.Configuration#getSecurityCredentials <em>Security Credentials</em>}</li> + * <li>{@link org.apache.tuscany.model.Configuration#getNlog4jConfigurationFilePath <em>Nlog4j Configuration File Path</em>}</li> + * <li>{@link org.apache.tuscany.model.Configuration#isEmbedded <em>Embedded</em>}</li> + * </ul> + * </p> + * + * @model + * @generated + */ +public interface Configuration +{ + /** + * Returns the value of the '<em><b>Host</b></em>' attribute. + * The default value is <code>"localhost"</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Host</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Host</em>' attribute. + * @see #setHost(String) + * @model default="localhost" + * @generated + */ + String getHost(); + + /** + * Sets the value of the '{@link org.apache.tuscany.model.Configuration#getHost <em>Host</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Host</em>' attribute. + * @see #getHost() + * @generated + */ + void setHost(String value); + + /** + * Returns the value of the '<em><b>Port</b></em>' attribute. + * The default value is <code>"10389"</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Port</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Port</em>' attribute. + * @see #setPort(String) + * @model default="10389" + * @generated + */ + String getPort(); + + /** + * Sets the value of the '{@link org.apache.tuscany.model.Configuration#getPort <em>Port</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Port</em>' attribute. + * @see #getPort() + * @generated + */ + void setPort(String value); + + /** + * Returns the value of the '<em><b>Initial Context Factory</b></em>' attribute. + * The default value is <code>"org.apache.directory.server.core.jndi.CoreContextFactory"</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Initial Context Factory</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Initial Context Factory</em>' attribute. + * @see #setInitialContextFactory(String) + * @model default="org.apache.directory.server.core.jndi.CoreContextFactory" + * @generated + */ + String getInitialContextFactory(); + + /** + * Sets the value of the '{@link org.apache.tuscany.model.Configuration#getInitialContextFactory <em>Initial Context Factory</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Initial Context Factory</em>' attribute. + * @see #getInitialContextFactory() + * @generated + */ + void setInitialContextFactory(String value); + + /** + * Returns the value of the '<em><b>Das Partition Name</b></em>' attribute. + * The default value is <code>"das"</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Das Partition Name</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Das Partition Name</em>' attribute. + * @see #setDasPartitionName(String) + * @model default="das" + * @generated + */ + String getDasPartitionName(); + + /** + * Sets the value of the '{@link org.apache.tuscany.model.Configuration#getDasPartitionName <em>Das Partition Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Das Partition Name</em>' attribute. + * @see #getDasPartitionName() + * @generated + */ + void setDasPartitionName(String value); + + /** + * Returns the value of the '<em><b>Schema Partition Name</b></em>' attribute. + * The default value is <code>"schema"</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Schema Partition Name</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Schema Partition Name</em>' attribute. + * @see #setSchemaPartitionName(String) + * @model default="schema" + * @generated + */ + String getSchemaPartitionName(); + + /** + * Sets the value of the '{@link org.apache.tuscany.model.Configuration#getSchemaPartitionName <em>Schema Partition Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Schema Partition Name</em>' attribute. + * @see #getSchemaPartitionName() + * @generated + */ + void setSchemaPartitionName(String value); + + /** + * Returns the value of the '<em><b>Security Principal</b></em>' attribute. + * The default value is <code>"uid=admin,ou=system"</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Security Principal</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Security Principal</em>' attribute. + * @see #setSecurityPrincipal(String) + * @model default="uid=admin,ou=system" + * @generated + */ + String getSecurityPrincipal(); + + /** + * Sets the value of the '{@link org.apache.tuscany.model.Configuration#getSecurityPrincipal <em>Security Principal</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Security Principal</em>' attribute. + * @see #getSecurityPrincipal() + * @generated + */ + void setSecurityPrincipal(String value); + + /** + * Returns the value of the '<em><b>Security Authentication Type</b></em>' attribute. + * The default value is <code>"simple"</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Security Authentication Type</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Security Authentication Type</em>' attribute. + * @see #setSecurityAuthenticationType(String) + * @model default="simple" + * @generated + */ + String getSecurityAuthenticationType(); + + /** + * Sets the value of the '{@link org.apache.tuscany.model.Configuration#getSecurityAuthenticationType <em>Security Authentication Type</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Security Authentication Type</em>' attribute. + * @see #getSecurityAuthenticationType() + * @generated + */ + void setSecurityAuthenticationType(String value); + + /** + * Returns the value of the '<em><b>Security Credentials</b></em>' attribute. + * The default value is <code>"secret"</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Security Credentials</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Security Credentials</em>' attribute. + * @see #setSecurityCredentials(String) + * @model default="secret" + * @generated + */ + String getSecurityCredentials(); + + /** + * Sets the value of the '{@link org.apache.tuscany.model.Configuration#getSecurityCredentials <em>Security Credentials</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Security Credentials</em>' attribute. + * @see #getSecurityCredentials() + * @generated + */ + void setSecurityCredentials(String value); + + /** + * Returns the value of the '<em><b>Nlog4j Configuration File Path</b></em>' attribute. + * The default value is <code>"src/test/resources/log4j.properties"</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Nlog4j Configuration File Path</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Nlog4j Configuration File Path</em>' attribute. + * @see #setNlog4jConfigurationFilePath(String) + * @model default="src/test/resources/log4j.properties" + * @generated + */ + String getNlog4jConfigurationFilePath(); + + /** + * Sets the value of the '{@link org.apache.tuscany.model.Configuration#getNlog4jConfigurationFilePath <em>Nlog4j Configuration File Path</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Nlog4j Configuration File Path</em>' attribute. + * @see #getNlog4jConfigurationFilePath() + * @generated + */ + void setNlog4jConfigurationFilePath(String value); + + /** + * Returns the value of the '<em><b>Embedded</b></em>' attribute. + * The default value is <code>"false"</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Embedded</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Embedded</em>' attribute. + * @see #setEmbedded(boolean) + * @model default="false" + * @generated + */ + boolean isEmbedded(); + + /** + * Sets the value of the '{@link org.apache.tuscany.model.Configuration#isEmbedded <em>Embedded</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Embedded</em>' attribute. + * @see #isEmbedded() + * @generated + */ + void setEmbedded(boolean value); + +} // Configuration diff --git a/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/ConfigurationFactory.java b/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/ConfigurationFactory.java new file mode 100644 index 0000000000..5edfd1230e --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/ConfigurationFactory.java @@ -0,0 +1,45 @@ +/** + * <copyright> + * </copyright> + * + * $Id$ + */ +package org.apache.tuscany.model; + + +/** + * <!-- begin-user-doc --> + * The <b>Factory</b> for the model. + * It provides a create method for each non-abstract class of the model. + * <!-- end-user-doc --> + * @generated + */ +public interface ConfigurationFactory +{ + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + ConfigurationFactory INSTANCE = org.apache.tuscany.model.impl.ConfigurationFactoryImpl.eINSTANCE; + + /** + * Returns a new object of class '<em>Configuration</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Configuration</em>'. + * @generated + */ + Configuration createConfiguration(); + + /** + * Returns a new object of class '<em>DAS Meta</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>DAS Meta</em>'. + * @generated + */ + DASMeta createDASMeta(); + +} //ConfigurationFactory diff --git a/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/DASMeta.java b/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/DASMeta.java new file mode 100644 index 0000000000..cd424ffa9c --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/DASMeta.java @@ -0,0 +1,70 @@ +/** + * <copyright> + * </copyright> + * + * $Id$ + */ +package org.apache.tuscany.model; + +import java.util.List; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>DAS Meta</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.apache.tuscany.model.DASMeta#getSupportedSchemas <em>Supported Schemas</em>}</li> + * <li>{@link org.apache.tuscany.model.DASMeta#getId <em>Id</em>}</li> + * </ul> + * </p> + * + * @model + * @generated + */ +public interface DASMeta +{ + /** + * Returns the value of the '<em><b>Supported Schemas</b></em>' attribute list. + * The list contents are of type {@link java.lang.String}. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Supported Schemas</em>' attribute list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Supported Schemas</em>' attribute list. + * @model default="localhost" + * @generated + */ + List<String> getSupportedSchemas(); + + /** + * Returns the value of the '<em><b>Id</b></em>' attribute. + * The default value is <code>"0"</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Id</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Id</em>' attribute. + * @see #setId(String) + * @model default="0" id="true" + * @generated + */ + String getId(); + + /** + * Sets the value of the '{@link org.apache.tuscany.model.DASMeta#getId <em>Id</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Id</em>' attribute. + * @see #getId() + * @generated + */ + void setId(String value); + +} // DASMeta diff --git a/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/impl/ConfigurationFactoryImpl.java b/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/impl/ConfigurationFactoryImpl.java new file mode 100644 index 0000000000..e22a4e1a30 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/impl/ConfigurationFactoryImpl.java @@ -0,0 +1,130 @@ +/** + * <copyright> + * </copyright> + * + * $Id$ + */ +package org.apache.tuscany.model.impl; + +import org.apache.tuscany.model.*; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Factory</b>. + * <!-- end-user-doc --> + * @generated + */ +public class ConfigurationFactoryImpl extends EFactoryImpl implements ConfigurationFactory +{ + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final ConfigurationFactoryImpl eINSTANCE = init(); + + /** + * Creates the default factory implementation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static ConfigurationFactoryImpl init() + { + try + { + ConfigurationFactoryImpl theConfigurationFactory = (ConfigurationFactoryImpl)EPackage.Registry.INSTANCE.getEFactory("http://org.apache.tuscany/das.ldap.configuration.model.ecore.v100"); + if (theConfigurationFactory != null) + { + return theConfigurationFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new ConfigurationFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ConfigurationFactoryImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case ConfigurationPackageImpl.CONFIGURATION: return (EObject)createConfiguration(); + case ConfigurationPackageImpl.DAS_META: return (EObject)createDASMeta(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Configuration createConfiguration() + { + ConfigurationImpl configuration = new ConfigurationImpl(); + return configuration; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public DASMeta createDASMeta() + { + DASMetaImpl dasMeta = new DASMetaImpl(); + return dasMeta; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ConfigurationPackageImpl getConfigurationPackageImpl() + { + return (ConfigurationPackageImpl)getEPackage(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @deprecated + * @generated + */ + @Deprecated + public static ConfigurationPackageImpl getPackage() + { + return ConfigurationPackageImpl.eINSTANCE; + } + +} //ConfigurationFactoryImpl diff --git a/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/impl/ConfigurationImpl.java b/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/impl/ConfigurationImpl.java new file mode 100644 index 0000000000..cbc280ebf5 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/impl/ConfigurationImpl.java @@ -0,0 +1,692 @@ +/** + * <copyright> + * </copyright> + * + * $Id$ + */ +package org.apache.tuscany.model.impl; + +import org.apache.tuscany.model.Configuration; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; + +import org.eclipse.emf.ecore.sdo.impl.EDataObjectImpl; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Configuration</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.model.impl.ConfigurationImpl#getHost <em>Host</em>}</li> + * <li>{@link org.apache.tuscany.model.impl.ConfigurationImpl#getPort <em>Port</em>}</li> + * <li>{@link org.apache.tuscany.model.impl.ConfigurationImpl#getInitialContextFactory <em>Initial Context Factory</em>}</li> + * <li>{@link org.apache.tuscany.model.impl.ConfigurationImpl#getDasPartitionName <em>Das Partition Name</em>}</li> + * <li>{@link org.apache.tuscany.model.impl.ConfigurationImpl#getSchemaPartitionName <em>Schema Partition Name</em>}</li> + * <li>{@link org.apache.tuscany.model.impl.ConfigurationImpl#getSecurityPrincipal <em>Security Principal</em>}</li> + * <li>{@link org.apache.tuscany.model.impl.ConfigurationImpl#getSecurityAuthenticationType <em>Security Authentication Type</em>}</li> + * <li>{@link org.apache.tuscany.model.impl.ConfigurationImpl#getSecurityCredentials <em>Security Credentials</em>}</li> + * <li>{@link org.apache.tuscany.model.impl.ConfigurationImpl#getNlog4jConfigurationFilePath <em>Nlog4j Configuration File Path</em>}</li> + * <li>{@link org.apache.tuscany.model.impl.ConfigurationImpl#isEmbedded <em>Embedded</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class ConfigurationImpl extends EDataObjectImpl implements Configuration +{ + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private static final long serialVersionUID = 1L; + + /** + * The default value of the '{@link #getHost() <em>Host</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getHost() + * @generated + * @ordered + */ + protected static final String HOST_EDEFAULT = "localhost"; + + /** + * The cached value of the '{@link #getHost() <em>Host</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getHost() + * @generated + * @ordered + */ + protected String host = HOST_EDEFAULT; + + /** + * The default value of the '{@link #getPort() <em>Port</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getPort() + * @generated + * @ordered + */ + protected static final String PORT_EDEFAULT = "10389"; + + /** + * The cached value of the '{@link #getPort() <em>Port</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getPort() + * @generated + * @ordered + */ + protected String port = PORT_EDEFAULT; + + /** + * The default value of the '{@link #getInitialContextFactory() <em>Initial Context Factory</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getInitialContextFactory() + * @generated + * @ordered + */ + protected static final String INITIAL_CONTEXT_FACTORY_EDEFAULT = "org.apache.directory.server.core.jndi.CoreContextFactory"; + + /** + * The cached value of the '{@link #getInitialContextFactory() <em>Initial Context Factory</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getInitialContextFactory() + * @generated + * @ordered + */ + protected String initialContextFactory = INITIAL_CONTEXT_FACTORY_EDEFAULT; + + /** + * The default value of the '{@link #getDasPartitionName() <em>Das Partition Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getDasPartitionName() + * @generated + * @ordered + */ + protected static final String DAS_PARTITION_NAME_EDEFAULT = "das"; + + /** + * The cached value of the '{@link #getDasPartitionName() <em>Das Partition Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getDasPartitionName() + * @generated + * @ordered + */ + protected String dasPartitionName = DAS_PARTITION_NAME_EDEFAULT; + + /** + * The default value of the '{@link #getSchemaPartitionName() <em>Schema Partition Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getSchemaPartitionName() + * @generated + * @ordered + */ + protected static final String SCHEMA_PARTITION_NAME_EDEFAULT = "schema"; + + /** + * The cached value of the '{@link #getSchemaPartitionName() <em>Schema Partition Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getSchemaPartitionName() + * @generated + * @ordered + */ + protected String schemaPartitionName = SCHEMA_PARTITION_NAME_EDEFAULT; + + /** + * The default value of the '{@link #getSecurityPrincipal() <em>Security Principal</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getSecurityPrincipal() + * @generated + * @ordered + */ + protected static final String SECURITY_PRINCIPAL_EDEFAULT = "uid=admin,ou=system"; + + /** + * The cached value of the '{@link #getSecurityPrincipal() <em>Security Principal</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getSecurityPrincipal() + * @generated + * @ordered + */ + protected String securityPrincipal = SECURITY_PRINCIPAL_EDEFAULT; + + /** + * The default value of the '{@link #getSecurityAuthenticationType() <em>Security Authentication Type</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getSecurityAuthenticationType() + * @generated + * @ordered + */ + protected static final String SECURITY_AUTHENTICATION_TYPE_EDEFAULT = "simple"; + + /** + * The cached value of the '{@link #getSecurityAuthenticationType() <em>Security Authentication Type</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getSecurityAuthenticationType() + * @generated + * @ordered + */ + protected String securityAuthenticationType = SECURITY_AUTHENTICATION_TYPE_EDEFAULT; + + /** + * The default value of the '{@link #getSecurityCredentials() <em>Security Credentials</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getSecurityCredentials() + * @generated + * @ordered + */ + protected static final String SECURITY_CREDENTIALS_EDEFAULT = "secret"; + + /** + * The cached value of the '{@link #getSecurityCredentials() <em>Security Credentials</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getSecurityCredentials() + * @generated + * @ordered + */ + protected String securityCredentials = SECURITY_CREDENTIALS_EDEFAULT; + + /** + * The default value of the '{@link #getNlog4jConfigurationFilePath() <em>Nlog4j Configuration File Path</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getNlog4jConfigurationFilePath() + * @generated + * @ordered + */ + protected static final String NLOG4J_CONFIGURATION_FILE_PATH_EDEFAULT = "src/test/resources/log4j.properties"; + + /** + * The cached value of the '{@link #getNlog4jConfigurationFilePath() <em>Nlog4j Configuration File Path</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getNlog4jConfigurationFilePath() + * @generated + * @ordered + */ + protected String nlog4jConfigurationFilePath = NLOG4J_CONFIGURATION_FILE_PATH_EDEFAULT; + + /** + * The default value of the '{@link #isEmbedded() <em>Embedded</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isEmbedded() + * @generated + * @ordered + */ + protected static final boolean EMBEDDED_EDEFAULT = false; + + /** + * The cached value of the '{@link #isEmbedded() <em>Embedded</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isEmbedded() + * @generated + * @ordered + */ + protected boolean embedded = EMBEDDED_EDEFAULT; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected ConfigurationImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + protected EClass eStaticClass() + { + return ConfigurationPackageImpl.Literals.CONFIGURATION; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getHost() + { + return host; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setHost(String newHost) + { + String oldHost = host; + host = newHost; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ConfigurationPackageImpl.CONFIGURATION__HOST, oldHost, host)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getPort() + { + return port; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setPort(String newPort) + { + String oldPort = port; + port = newPort; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ConfigurationPackageImpl.CONFIGURATION__PORT, oldPort, port)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getInitialContextFactory() + { + return initialContextFactory; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setInitialContextFactory(String newInitialContextFactory) + { + String oldInitialContextFactory = initialContextFactory; + initialContextFactory = newInitialContextFactory; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ConfigurationPackageImpl.CONFIGURATION__INITIAL_CONTEXT_FACTORY, oldInitialContextFactory, initialContextFactory)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getDasPartitionName() + { + return dasPartitionName; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setDasPartitionName(String newDasPartitionName) + { + String oldDasPartitionName = dasPartitionName; + dasPartitionName = newDasPartitionName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ConfigurationPackageImpl.CONFIGURATION__DAS_PARTITION_NAME, oldDasPartitionName, dasPartitionName)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getSchemaPartitionName() + { + return schemaPartitionName; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setSchemaPartitionName(String newSchemaPartitionName) + { + String oldSchemaPartitionName = schemaPartitionName; + schemaPartitionName = newSchemaPartitionName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ConfigurationPackageImpl.CONFIGURATION__SCHEMA_PARTITION_NAME, oldSchemaPartitionName, schemaPartitionName)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getSecurityPrincipal() + { + return securityPrincipal; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setSecurityPrincipal(String newSecurityPrincipal) + { + String oldSecurityPrincipal = securityPrincipal; + securityPrincipal = newSecurityPrincipal; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ConfigurationPackageImpl.CONFIGURATION__SECURITY_PRINCIPAL, oldSecurityPrincipal, securityPrincipal)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getSecurityAuthenticationType() + { + return securityAuthenticationType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setSecurityAuthenticationType(String newSecurityAuthenticationType) + { + String oldSecurityAuthenticationType = securityAuthenticationType; + securityAuthenticationType = newSecurityAuthenticationType; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ConfigurationPackageImpl.CONFIGURATION__SECURITY_AUTHENTICATION_TYPE, oldSecurityAuthenticationType, securityAuthenticationType)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getSecurityCredentials() + { + return securityCredentials; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setSecurityCredentials(String newSecurityCredentials) + { + String oldSecurityCredentials = securityCredentials; + securityCredentials = newSecurityCredentials; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ConfigurationPackageImpl.CONFIGURATION__SECURITY_CREDENTIALS, oldSecurityCredentials, securityCredentials)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getNlog4jConfigurationFilePath() + { + return nlog4jConfigurationFilePath; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setNlog4jConfigurationFilePath(String newNlog4jConfigurationFilePath) + { + String oldNlog4jConfigurationFilePath = nlog4jConfigurationFilePath; + nlog4jConfigurationFilePath = newNlog4jConfigurationFilePath; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ConfigurationPackageImpl.CONFIGURATION__NLOG4J_CONFIGURATION_FILE_PATH, oldNlog4jConfigurationFilePath, nlog4jConfigurationFilePath)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isEmbedded() + { + return embedded; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setEmbedded(boolean newEmbedded) + { + boolean oldEmbedded = embedded; + embedded = newEmbedded; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ConfigurationPackageImpl.CONFIGURATION__EMBEDDED, oldEmbedded, embedded)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case ConfigurationPackageImpl.CONFIGURATION__HOST: + return getHost(); + case ConfigurationPackageImpl.CONFIGURATION__PORT: + return getPort(); + case ConfigurationPackageImpl.CONFIGURATION__INITIAL_CONTEXT_FACTORY: + return getInitialContextFactory(); + case ConfigurationPackageImpl.CONFIGURATION__DAS_PARTITION_NAME: + return getDasPartitionName(); + case ConfigurationPackageImpl.CONFIGURATION__SCHEMA_PARTITION_NAME: + return getSchemaPartitionName(); + case ConfigurationPackageImpl.CONFIGURATION__SECURITY_PRINCIPAL: + return getSecurityPrincipal(); + case ConfigurationPackageImpl.CONFIGURATION__SECURITY_AUTHENTICATION_TYPE: + return getSecurityAuthenticationType(); + case ConfigurationPackageImpl.CONFIGURATION__SECURITY_CREDENTIALS: + return getSecurityCredentials(); + case ConfigurationPackageImpl.CONFIGURATION__NLOG4J_CONFIGURATION_FILE_PATH: + return getNlog4jConfigurationFilePath(); + case ConfigurationPackageImpl.CONFIGURATION__EMBEDDED: + return isEmbedded() ? Boolean.TRUE : Boolean.FALSE; + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case ConfigurationPackageImpl.CONFIGURATION__HOST: + setHost((String)newValue); + return; + case ConfigurationPackageImpl.CONFIGURATION__PORT: + setPort((String)newValue); + return; + case ConfigurationPackageImpl.CONFIGURATION__INITIAL_CONTEXT_FACTORY: + setInitialContextFactory((String)newValue); + return; + case ConfigurationPackageImpl.CONFIGURATION__DAS_PARTITION_NAME: + setDasPartitionName((String)newValue); + return; + case ConfigurationPackageImpl.CONFIGURATION__SCHEMA_PARTITION_NAME: + setSchemaPartitionName((String)newValue); + return; + case ConfigurationPackageImpl.CONFIGURATION__SECURITY_PRINCIPAL: + setSecurityPrincipal((String)newValue); + return; + case ConfigurationPackageImpl.CONFIGURATION__SECURITY_AUTHENTICATION_TYPE: + setSecurityAuthenticationType((String)newValue); + return; + case ConfigurationPackageImpl.CONFIGURATION__SECURITY_CREDENTIALS: + setSecurityCredentials((String)newValue); + return; + case ConfigurationPackageImpl.CONFIGURATION__NLOG4J_CONFIGURATION_FILE_PATH: + setNlog4jConfigurationFilePath((String)newValue); + return; + case ConfigurationPackageImpl.CONFIGURATION__EMBEDDED: + setEmbedded(((Boolean)newValue).booleanValue()); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eUnset(int featureID) + { + switch (featureID) + { + case ConfigurationPackageImpl.CONFIGURATION__HOST: + setHost(HOST_EDEFAULT); + return; + case ConfigurationPackageImpl.CONFIGURATION__PORT: + setPort(PORT_EDEFAULT); + return; + case ConfigurationPackageImpl.CONFIGURATION__INITIAL_CONTEXT_FACTORY: + setInitialContextFactory(INITIAL_CONTEXT_FACTORY_EDEFAULT); + return; + case ConfigurationPackageImpl.CONFIGURATION__DAS_PARTITION_NAME: + setDasPartitionName(DAS_PARTITION_NAME_EDEFAULT); + return; + case ConfigurationPackageImpl.CONFIGURATION__SCHEMA_PARTITION_NAME: + setSchemaPartitionName(SCHEMA_PARTITION_NAME_EDEFAULT); + return; + case ConfigurationPackageImpl.CONFIGURATION__SECURITY_PRINCIPAL: + setSecurityPrincipal(SECURITY_PRINCIPAL_EDEFAULT); + return; + case ConfigurationPackageImpl.CONFIGURATION__SECURITY_AUTHENTICATION_TYPE: + setSecurityAuthenticationType(SECURITY_AUTHENTICATION_TYPE_EDEFAULT); + return; + case ConfigurationPackageImpl.CONFIGURATION__SECURITY_CREDENTIALS: + setSecurityCredentials(SECURITY_CREDENTIALS_EDEFAULT); + return; + case ConfigurationPackageImpl.CONFIGURATION__NLOG4J_CONFIGURATION_FILE_PATH: + setNlog4jConfigurationFilePath(NLOG4J_CONFIGURATION_FILE_PATH_EDEFAULT); + return; + case ConfigurationPackageImpl.CONFIGURATION__EMBEDDED: + setEmbedded(EMBEDDED_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case ConfigurationPackageImpl.CONFIGURATION__HOST: + return HOST_EDEFAULT == null ? host != null : !HOST_EDEFAULT.equals(host); + case ConfigurationPackageImpl.CONFIGURATION__PORT: + return PORT_EDEFAULT == null ? port != null : !PORT_EDEFAULT.equals(port); + case ConfigurationPackageImpl.CONFIGURATION__INITIAL_CONTEXT_FACTORY: + return INITIAL_CONTEXT_FACTORY_EDEFAULT == null ? initialContextFactory != null : !INITIAL_CONTEXT_FACTORY_EDEFAULT.equals(initialContextFactory); + case ConfigurationPackageImpl.CONFIGURATION__DAS_PARTITION_NAME: + return DAS_PARTITION_NAME_EDEFAULT == null ? dasPartitionName != null : !DAS_PARTITION_NAME_EDEFAULT.equals(dasPartitionName); + case ConfigurationPackageImpl.CONFIGURATION__SCHEMA_PARTITION_NAME: + return SCHEMA_PARTITION_NAME_EDEFAULT == null ? schemaPartitionName != null : !SCHEMA_PARTITION_NAME_EDEFAULT.equals(schemaPartitionName); + case ConfigurationPackageImpl.CONFIGURATION__SECURITY_PRINCIPAL: + return SECURITY_PRINCIPAL_EDEFAULT == null ? securityPrincipal != null : !SECURITY_PRINCIPAL_EDEFAULT.equals(securityPrincipal); + case ConfigurationPackageImpl.CONFIGURATION__SECURITY_AUTHENTICATION_TYPE: + return SECURITY_AUTHENTICATION_TYPE_EDEFAULT == null ? securityAuthenticationType != null : !SECURITY_AUTHENTICATION_TYPE_EDEFAULT.equals(securityAuthenticationType); + case ConfigurationPackageImpl.CONFIGURATION__SECURITY_CREDENTIALS: + return SECURITY_CREDENTIALS_EDEFAULT == null ? securityCredentials != null : !SECURITY_CREDENTIALS_EDEFAULT.equals(securityCredentials); + case ConfigurationPackageImpl.CONFIGURATION__NLOG4J_CONFIGURATION_FILE_PATH: + return NLOG4J_CONFIGURATION_FILE_PATH_EDEFAULT == null ? nlog4jConfigurationFilePath != null : !NLOG4J_CONFIGURATION_FILE_PATH_EDEFAULT.equals(nlog4jConfigurationFilePath); + case ConfigurationPackageImpl.CONFIGURATION__EMBEDDED: + return embedded != EMBEDDED_EDEFAULT; + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (host: "); + result.append(host); + result.append(", port: "); + result.append(port); + result.append(", initialContextFactory: "); + result.append(initialContextFactory); + result.append(", dasPartitionName: "); + result.append(dasPartitionName); + result.append(", schemaPartitionName: "); + result.append(schemaPartitionName); + result.append(", securityPrincipal: "); + result.append(securityPrincipal); + result.append(", securityAuthenticationType: "); + result.append(securityAuthenticationType); + result.append(", securityCredentials: "); + result.append(securityCredentials); + result.append(", nlog4jConfigurationFilePath: "); + result.append(nlog4jConfigurationFilePath); + result.append(", embedded: "); + result.append(embedded); + result.append(')'); + return result.toString(); + } + +} //ConfigurationImpl diff --git a/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/impl/ConfigurationPackageImpl.java b/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/impl/ConfigurationPackageImpl.java new file mode 100644 index 0000000000..15afe8aa32 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/impl/ConfigurationPackageImpl.java @@ -0,0 +1,726 @@ +/** + * <copyright> + * </copyright> + * + * $Id$ + */ +package org.apache.tuscany.model.impl; + +import org.apache.tuscany.model.Configuration; +import org.apache.tuscany.model.ConfigurationFactory; +import org.apache.tuscany.model.DASMeta; + +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.impl.EPackageImpl; + +/** + * <!-- begin-user-doc --> + * The <b>Package</b> for the model. + * It contains accessors for the meta objects to represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @see org.apache.tuscany.model.ConfigurationFactory + * @model kind="package" + * @generated + */ +public class ConfigurationPackageImpl extends EPackageImpl +{ + /** + * The package name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final String eNAME = "model"; + + /** + * The package namespace URI. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final String eNS_URI = "http://org.apache.tuscany/das.ldap.configuration.model.ecore.v100"; + + /** + * The package namespace name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final String eNS_PREFIX = "tuscany"; + + /** + * The singleton instance of the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final ConfigurationPackageImpl eINSTANCE = org.apache.tuscany.model.impl.ConfigurationPackageImpl.init(); + + /** + * The meta object id for the '{@link org.apache.tuscany.model.impl.ConfigurationImpl <em>Configuration</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.model.impl.ConfigurationImpl + * @see org.apache.tuscany.model.impl.ConfigurationPackageImpl#getConfiguration() + * @generated + */ + public static final int CONFIGURATION = 0; + + /** + * The feature id for the '<em><b>Host</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int CONFIGURATION__HOST = 0; + + /** + * The feature id for the '<em><b>Port</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int CONFIGURATION__PORT = 1; + + /** + * The feature id for the '<em><b>Initial Context Factory</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int CONFIGURATION__INITIAL_CONTEXT_FACTORY = 2; + + /** + * The feature id for the '<em><b>Das Partition Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int CONFIGURATION__DAS_PARTITION_NAME = 3; + + /** + * The feature id for the '<em><b>Schema Partition Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int CONFIGURATION__SCHEMA_PARTITION_NAME = 4; + + /** + * The feature id for the '<em><b>Security Principal</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int CONFIGURATION__SECURITY_PRINCIPAL = 5; + + /** + * The feature id for the '<em><b>Security Authentication Type</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int CONFIGURATION__SECURITY_AUTHENTICATION_TYPE = 6; + + /** + * The feature id for the '<em><b>Security Credentials</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int CONFIGURATION__SECURITY_CREDENTIALS = 7; + + /** + * The feature id for the '<em><b>Nlog4j Configuration File Path</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int CONFIGURATION__NLOG4J_CONFIGURATION_FILE_PATH = 8; + + /** + * The feature id for the '<em><b>Embedded</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int CONFIGURATION__EMBEDDED = 9; + + /** + * The number of structural features of the '<em>Configuration</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int CONFIGURATION_FEATURE_COUNT = 10; + + /** + * The meta object id for the '{@link org.apache.tuscany.model.impl.DASMetaImpl <em>DAS Meta</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.model.impl.DASMetaImpl + * @see org.apache.tuscany.model.impl.ConfigurationPackageImpl#getDASMeta() + * @generated + */ + public static final int DAS_META = 1; + + /** + * The feature id for the '<em><b>Supported Schemas</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DAS_META__SUPPORTED_SCHEMAS = 0; + + /** + * The feature id for the '<em><b>Id</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DAS_META__ID = 1; + + /** + * The number of structural features of the '<em>DAS Meta</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DAS_META_FEATURE_COUNT = 2; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass configurationEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass dasMetaEClass = null; + + /** + * Creates an instance of the model <b>Package</b>, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + * <p>Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.apache.tuscany.model.impl.ConfigurationPackageImpl#eNS_URI + * @see #init() + * @generated + */ + private ConfigurationPackageImpl() + { + super(eNS_URI, ((EFactory)ConfigurationFactory.INSTANCE)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the <b>Package</b> for this + * model, and for any others upon which it depends. Simple + * dependencies are satisfied by calling this method on all + * dependent packages before doing anything else. This method drives + * initialization for interdependent packages directly, in parallel + * with this package, itself. + * <p>Of this package and its interdependencies, all packages which + * have not yet been registered by their URI values are first created + * and registered. The packages are then initialized in two steps: + * meta-model objects for all of the packages are created before any + * are initialized, since one package's meta-model objects may refer to + * those of another. + * <p>Invocation of this method will not affect any packages that have + * already been initialized. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static ConfigurationPackageImpl init() + { + if (isInited) return (ConfigurationPackageImpl)EPackage.Registry.INSTANCE.getEPackage(ConfigurationPackageImpl.eNS_URI); + + // Obtain or create and register package + ConfigurationPackageImpl theConfigurationPackageImpl = (ConfigurationPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof ConfigurationPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new ConfigurationPackageImpl()); + + isInited = true; + + // Create package meta-data objects + theConfigurationPackageImpl.createPackageContents(); + + // Initialize created meta-data + theConfigurationPackageImpl.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theConfigurationPackageImpl.freeze(); + + return theConfigurationPackageImpl; + } + + + /** + * Returns the meta object for class '{@link org.apache.tuscany.model.Configuration <em>Configuration</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Configuration</em>'. + * @see org.apache.tuscany.model.Configuration + * @generated + */ + public EClass getConfiguration() + { + return configurationEClass; + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.model.Configuration#getHost <em>Host</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Host</em>'. + * @see org.apache.tuscany.model.Configuration#getHost() + * @see #getConfiguration() + * @generated + */ + public EAttribute getConfiguration_Host() + { + return (EAttribute)configurationEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.model.Configuration#getPort <em>Port</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Port</em>'. + * @see org.apache.tuscany.model.Configuration#getPort() + * @see #getConfiguration() + * @generated + */ + public EAttribute getConfiguration_Port() + { + return (EAttribute)configurationEClass.getEStructuralFeatures().get(1); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.model.Configuration#getInitialContextFactory <em>Initial Context Factory</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Initial Context Factory</em>'. + * @see org.apache.tuscany.model.Configuration#getInitialContextFactory() + * @see #getConfiguration() + * @generated + */ + public EAttribute getConfiguration_InitialContextFactory() + { + return (EAttribute)configurationEClass.getEStructuralFeatures().get(2); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.model.Configuration#getDasPartitionName <em>Das Partition Name</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Das Partition Name</em>'. + * @see org.apache.tuscany.model.Configuration#getDasPartitionName() + * @see #getConfiguration() + * @generated + */ + public EAttribute getConfiguration_DasPartitionName() + { + return (EAttribute)configurationEClass.getEStructuralFeatures().get(3); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.model.Configuration#getSchemaPartitionName <em>Schema Partition Name</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Schema Partition Name</em>'. + * @see org.apache.tuscany.model.Configuration#getSchemaPartitionName() + * @see #getConfiguration() + * @generated + */ + public EAttribute getConfiguration_SchemaPartitionName() + { + return (EAttribute)configurationEClass.getEStructuralFeatures().get(4); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.model.Configuration#getSecurityPrincipal <em>Security Principal</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Security Principal</em>'. + * @see org.apache.tuscany.model.Configuration#getSecurityPrincipal() + * @see #getConfiguration() + * @generated + */ + public EAttribute getConfiguration_SecurityPrincipal() + { + return (EAttribute)configurationEClass.getEStructuralFeatures().get(5); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.model.Configuration#getSecurityAuthenticationType <em>Security Authentication Type</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Security Authentication Type</em>'. + * @see org.apache.tuscany.model.Configuration#getSecurityAuthenticationType() + * @see #getConfiguration() + * @generated + */ + public EAttribute getConfiguration_SecurityAuthenticationType() + { + return (EAttribute)configurationEClass.getEStructuralFeatures().get(6); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.model.Configuration#getSecurityCredentials <em>Security Credentials</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Security Credentials</em>'. + * @see org.apache.tuscany.model.Configuration#getSecurityCredentials() + * @see #getConfiguration() + * @generated + */ + public EAttribute getConfiguration_SecurityCredentials() + { + return (EAttribute)configurationEClass.getEStructuralFeatures().get(7); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.model.Configuration#getNlog4jConfigurationFilePath <em>Nlog4j Configuration File Path</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Nlog4j Configuration File Path</em>'. + * @see org.apache.tuscany.model.Configuration#getNlog4jConfigurationFilePath() + * @see #getConfiguration() + * @generated + */ + public EAttribute getConfiguration_Nlog4jConfigurationFilePath() + { + return (EAttribute)configurationEClass.getEStructuralFeatures().get(8); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.model.Configuration#isEmbedded <em>Embedded</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Embedded</em>'. + * @see org.apache.tuscany.model.Configuration#isEmbedded() + * @see #getConfiguration() + * @generated + */ + public EAttribute getConfiguration_Embedded() + { + return (EAttribute)configurationEClass.getEStructuralFeatures().get(9); + } + + /** + * Returns the meta object for class '{@link org.apache.tuscany.model.DASMeta <em>DAS Meta</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>DAS Meta</em>'. + * @see org.apache.tuscany.model.DASMeta + * @generated + */ + public EClass getDASMeta() + { + return dasMetaEClass; + } + + /** + * Returns the meta object for the attribute list '{@link org.apache.tuscany.model.DASMeta#getSupportedSchemas <em>Supported Schemas</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute list '<em>Supported Schemas</em>'. + * @see org.apache.tuscany.model.DASMeta#getSupportedSchemas() + * @see #getDASMeta() + * @generated + */ + public EAttribute getDASMeta_SupportedSchemas() + { + return (EAttribute)dasMetaEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.model.DASMeta#getId <em>Id</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Id</em>'. + * @see org.apache.tuscany.model.DASMeta#getId() + * @see #getDASMeta() + * @generated + */ + public EAttribute getDASMeta_Id() + { + return (EAttribute)dasMetaEClass.getEStructuralFeatures().get(1); + } + + /** + * Returns the factory that creates the instances of the model. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the factory that creates the instances of the model. + * @generated + */ + public ConfigurationFactory getConfigurationFactory() + { + return (ConfigurationFactory)getEFactoryInstance(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void createPackageContents() + { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + configurationEClass = createEClass(CONFIGURATION); + createEAttribute(configurationEClass, CONFIGURATION__HOST); + createEAttribute(configurationEClass, CONFIGURATION__PORT); + createEAttribute(configurationEClass, CONFIGURATION__INITIAL_CONTEXT_FACTORY); + createEAttribute(configurationEClass, CONFIGURATION__DAS_PARTITION_NAME); + createEAttribute(configurationEClass, CONFIGURATION__SCHEMA_PARTITION_NAME); + createEAttribute(configurationEClass, CONFIGURATION__SECURITY_PRINCIPAL); + createEAttribute(configurationEClass, CONFIGURATION__SECURITY_AUTHENTICATION_TYPE); + createEAttribute(configurationEClass, CONFIGURATION__SECURITY_CREDENTIALS); + createEAttribute(configurationEClass, CONFIGURATION__NLOG4J_CONFIGURATION_FILE_PATH); + createEAttribute(configurationEClass, CONFIGURATION__EMBEDDED); + + dasMetaEClass = createEClass(DAS_META); + createEAttribute(dasMetaEClass, DAS_META__SUPPORTED_SCHEMAS); + createEAttribute(dasMetaEClass, DAS_META__ID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void initializePackageContents() + { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + + // Initialize classes and features; add operations and parameters + initEClass(configurationEClass, Configuration.class, "Configuration", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getConfiguration_Host(), ecorePackage.getEString(), "host", "localhost", 0, 1, Configuration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getConfiguration_Port(), ecorePackage.getEString(), "port", "10389", 0, 1, Configuration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getConfiguration_InitialContextFactory(), ecorePackage.getEString(), "initialContextFactory", "org.apache.directory.server.core.jndi.CoreContextFactory", 0, 1, Configuration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getConfiguration_DasPartitionName(), ecorePackage.getEString(), "dasPartitionName", "das", 0, 1, Configuration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getConfiguration_SchemaPartitionName(), ecorePackage.getEString(), "schemaPartitionName", "schema", 0, 1, Configuration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getConfiguration_SecurityPrincipal(), ecorePackage.getEString(), "securityPrincipal", "uid=admin,ou=system", 0, 1, Configuration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getConfiguration_SecurityAuthenticationType(), ecorePackage.getEString(), "securityAuthenticationType", "simple", 0, 1, Configuration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getConfiguration_SecurityCredentials(), ecorePackage.getEString(), "securityCredentials", "secret", 0, 1, Configuration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getConfiguration_Nlog4jConfigurationFilePath(), ecorePackage.getEString(), "nlog4jConfigurationFilePath", "src/test/resources/log4j.properties", 0, 1, Configuration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getConfiguration_Embedded(), ecorePackage.getEBoolean(), "embedded", "false", 0, 1, Configuration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(dasMetaEClass, DASMeta.class, "DASMeta", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getDASMeta_SupportedSchemas(), ecorePackage.getEString(), "supportedSchemas", "localhost", 0, -1, DASMeta.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getDASMeta_Id(), ecorePackage.getEString(), "id", "0", 0, 1, DASMeta.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + } + + /** + * <!-- begin-user-doc --> + * Defines literals for the meta objects that represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @generated + */ + public interface Literals + { + /** + * The meta object literal for the '{@link org.apache.tuscany.model.impl.ConfigurationImpl <em>Configuration</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.model.impl.ConfigurationImpl + * @see org.apache.tuscany.model.impl.ConfigurationPackageImpl#getConfiguration() + * @generated + */ + public static final EClass CONFIGURATION = eINSTANCE.getConfiguration(); + + /** + * The meta object literal for the '<em><b>Host</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute CONFIGURATION__HOST = eINSTANCE.getConfiguration_Host(); + + /** + * The meta object literal for the '<em><b>Port</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute CONFIGURATION__PORT = eINSTANCE.getConfiguration_Port(); + + /** + * The meta object literal for the '<em><b>Initial Context Factory</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute CONFIGURATION__INITIAL_CONTEXT_FACTORY = eINSTANCE.getConfiguration_InitialContextFactory(); + + /** + * The meta object literal for the '<em><b>Das Partition Name</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute CONFIGURATION__DAS_PARTITION_NAME = eINSTANCE.getConfiguration_DasPartitionName(); + + /** + * The meta object literal for the '<em><b>Schema Partition Name</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute CONFIGURATION__SCHEMA_PARTITION_NAME = eINSTANCE.getConfiguration_SchemaPartitionName(); + + /** + * The meta object literal for the '<em><b>Security Principal</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute CONFIGURATION__SECURITY_PRINCIPAL = eINSTANCE.getConfiguration_SecurityPrincipal(); + + /** + * The meta object literal for the '<em><b>Security Authentication Type</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute CONFIGURATION__SECURITY_AUTHENTICATION_TYPE = eINSTANCE.getConfiguration_SecurityAuthenticationType(); + + /** + * The meta object literal for the '<em><b>Security Credentials</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute CONFIGURATION__SECURITY_CREDENTIALS = eINSTANCE.getConfiguration_SecurityCredentials(); + + /** + * The meta object literal for the '<em><b>Nlog4j Configuration File Path</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute CONFIGURATION__NLOG4J_CONFIGURATION_FILE_PATH = eINSTANCE.getConfiguration_Nlog4jConfigurationFilePath(); + + /** + * The meta object literal for the '<em><b>Embedded</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute CONFIGURATION__EMBEDDED = eINSTANCE.getConfiguration_Embedded(); + + /** + * The meta object literal for the '{@link org.apache.tuscany.model.impl.DASMetaImpl <em>DAS Meta</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.model.impl.DASMetaImpl + * @see org.apache.tuscany.model.impl.ConfigurationPackageImpl#getDASMeta() + * @generated + */ + public static final EClass DAS_META = eINSTANCE.getDASMeta(); + + /** + * The meta object literal for the '<em><b>Supported Schemas</b></em>' attribute list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute DAS_META__SUPPORTED_SCHEMAS = eINSTANCE.getDASMeta_SupportedSchemas(); + + /** + * The meta object literal for the '<em><b>Id</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute DAS_META__ID = eINSTANCE.getDASMeta_Id(); + + } + +} //ConfigurationPackageImpl diff --git a/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/impl/DASMetaImpl.java b/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/impl/DASMetaImpl.java new file mode 100644 index 0000000000..2f14d4011a --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/impl/DASMetaImpl.java @@ -0,0 +1,234 @@ +/** + * <copyright> + * </copyright> + * + * $Id$ + */ +package org.apache.tuscany.model.impl; + +import java.util.Collection; +import java.util.List; + +import org.apache.tuscany.model.DASMeta; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; + +import org.eclipse.emf.ecore.sdo.impl.EDataObjectImpl; + +import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>DAS Meta</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.model.impl.DASMetaImpl#getSupportedSchemas <em>Supported Schemas</em>}</li> + * <li>{@link org.apache.tuscany.model.impl.DASMetaImpl#getId <em>Id</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class DASMetaImpl extends EDataObjectImpl implements DASMeta +{ + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private static final long serialVersionUID = 1L; + + /** + * The cached value of the '{@link #getSupportedSchemas() <em>Supported Schemas</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getSupportedSchemas() + * @generated + * @ordered + */ + protected EList<String> supportedSchemas; + + /** + * The default value of the '{@link #getId() <em>Id</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getId() + * @generated + * @ordered + */ + protected static final String ID_EDEFAULT = "0"; + + /** + * The cached value of the '{@link #getId() <em>Id</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getId() + * @generated + * @ordered + */ + protected String id = ID_EDEFAULT; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected DASMetaImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + protected EClass eStaticClass() + { + return ConfigurationPackageImpl.Literals.DAS_META; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public List<String> getSupportedSchemas() + { + if (supportedSchemas == null) + { + supportedSchemas = new EDataTypeUniqueEList<String>(String.class, this, ConfigurationPackageImpl.DAS_META__SUPPORTED_SCHEMAS); + } + return supportedSchemas; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getId() + { + return id; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setId(String newId) + { + String oldId = id; + id = newId; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ConfigurationPackageImpl.DAS_META__ID, oldId, id)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case ConfigurationPackageImpl.DAS_META__SUPPORTED_SCHEMAS: + return getSupportedSchemas(); + case ConfigurationPackageImpl.DAS_META__ID: + return getId(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case ConfigurationPackageImpl.DAS_META__SUPPORTED_SCHEMAS: + getSupportedSchemas().clear(); + getSupportedSchemas().addAll((Collection<? extends String>)newValue); + return; + case ConfigurationPackageImpl.DAS_META__ID: + setId((String)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eUnset(int featureID) + { + switch (featureID) + { + case ConfigurationPackageImpl.DAS_META__SUPPORTED_SCHEMAS: + getSupportedSchemas().clear(); + return; + case ConfigurationPackageImpl.DAS_META__ID: + setId(ID_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case ConfigurationPackageImpl.DAS_META__SUPPORTED_SCHEMAS: + return supportedSchemas != null && !supportedSchemas.isEmpty(); + case ConfigurationPackageImpl.DAS_META__ID: + return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (supportedSchemas: "); + result.append(supportedSchemas); + result.append(", id: "); + result.append(id); + result.append(')'); + return result.toString(); + } + +} //DASMetaImpl diff --git a/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/util/ConfigurationAdapterFactory.java b/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/util/ConfigurationAdapterFactory.java new file mode 100644 index 0000000000..7d0d4e154d --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/util/ConfigurationAdapterFactory.java @@ -0,0 +1,158 @@ +/** + * <copyright> + * </copyright> + * + * $Id$ + */ +package org.apache.tuscany.model.util; + +import org.apache.tuscany.model.*; + +import org.apache.tuscany.model.impl.ConfigurationPackageImpl; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + +/** + * <!-- begin-user-doc --> + * The <b>Adapter Factory</b> for the model. + * It provides an adapter <code>createXXX</code> method for each class of the model. + * <!-- end-user-doc --> + * @see org.apache.tuscany.model.impl.ConfigurationPackageImpl + * @generated + */ +public class ConfigurationAdapterFactory extends AdapterFactoryImpl +{ + /** + * The cached model package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected static ConfigurationPackageImpl modelPackage; + + /** + * Creates an instance of the adapter factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ConfigurationAdapterFactory() + { + if (modelPackage == null) + { + modelPackage = ConfigurationPackageImpl.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * <!-- begin-user-doc --> + * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. + * <!-- end-user-doc --> + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) + { + if (object == modelPackage) + { + return true; + } + if (object instanceof EObject) + { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch the delegates to the <code>createXXX</code> methods. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected ConfigurationSwitch<Adapter> modelSwitch = + new ConfigurationSwitch<Adapter>() + { + @Override + public Adapter caseConfiguration(Configuration object) + { + return createConfigurationAdapter(); + } + @Override + public Adapter caseDASMeta(DASMeta object) + { + return createDASMetaAdapter(); + } + @Override + public Adapter defaultCase(EObject object) + { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the <code>target</code>. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param target the object to adapt. + * @return the adapter for the <code>target</code>. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) + { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link org.apache.tuscany.model.Configuration <em>Configuration</em>}'. + * <!-- begin-user-doc --> + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * <!-- end-user-doc --> + * @return the new adapter. + * @see org.apache.tuscany.model.Configuration + * @generated + */ + public Adapter createConfigurationAdapter() + { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.apache.tuscany.model.DASMeta <em>DAS Meta</em>}'. + * <!-- begin-user-doc --> + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * <!-- end-user-doc --> + * @return the new adapter. + * @see org.apache.tuscany.model.DASMeta + * @generated + */ + public Adapter createDASMetaAdapter() + { + return null; + } + + /** + * Creates a new adapter for the default case. + * <!-- begin-user-doc --> + * This default implementation returns null. + * <!-- end-user-doc --> + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() + { + return null; + } + +} //ConfigurationAdapterFactory diff --git a/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/util/ConfigurationSwitch.java b/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/util/ConfigurationSwitch.java new file mode 100644 index 0000000000..81668705b6 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.configuration.model.v100/src/main/java/org/apache/tuscany/model/util/ConfigurationSwitch.java @@ -0,0 +1,167 @@ +/** + * <copyright> + * </copyright> + * + * $Id$ + */ +package org.apache.tuscany.model.util; + +import java.util.List; + +import org.apache.tuscany.model.*; + +import org.apache.tuscany.model.impl.ConfigurationPackageImpl; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; + +/** + * <!-- begin-user-doc --> + * The <b>Switch</b> for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the <code>caseXXX</code> method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * <!-- end-user-doc --> + * @see org.apache.tuscany.model.impl.ConfigurationPackageImpl + * @generated + */ +public class ConfigurationSwitch<T> +{ + /** + * The cached model package + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected static ConfigurationPackageImpl modelPackage; + + /** + * Creates an instance of the switch. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ConfigurationSwitch() + { + if (modelPackage == null) + { + modelPackage = ConfigurationPackageImpl.eINSTANCE; + } + } + + /** + * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the first non-null result returned by a <code>caseXXX</code> call. + * @generated + */ + public T doSwitch(EObject theEObject) + { + return doSwitch(theEObject.eClass(), theEObject); + } + + /** + * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the first non-null result returned by a <code>caseXXX</code> call. + * @generated + */ + protected T doSwitch(EClass theEClass, EObject theEObject) + { + if (theEClass.eContainer() == modelPackage) + { + return doSwitch(theEClass.getClassifierID(), theEObject); + } + else + { + List<EClass> eSuperTypes = theEClass.getESuperTypes(); + return + eSuperTypes.isEmpty() ? + defaultCase(theEObject) : + doSwitch(eSuperTypes.get(0), theEObject); + } + } + + /** + * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the first non-null result returned by a <code>caseXXX</code> call. + * @generated + */ + protected T doSwitch(int classifierID, EObject theEObject) + { + switch (classifierID) + { + case ConfigurationPackageImpl.CONFIGURATION: + { + Configuration configuration = (Configuration)theEObject; + T result = caseConfiguration(configuration); + if (result == null) result = defaultCase(theEObject); + return result; + } + case ConfigurationPackageImpl.DAS_META: + { + DASMeta dasMeta = (DASMeta)theEObject; + T result = caseDASMeta(dasMeta); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of '<em>Configuration</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>Configuration</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseConfiguration(Configuration object) + { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of '<em>DAS Meta</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>DAS Meta</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseDASMeta(DASMeta object) + { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>EObject</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + public T defaultCase(EObject object) + { + return null; + } + +} //ConfigurationSwitch diff --git a/das-java/contrib/ldap/das.ldap.constants/pom.xml b/das-java/contrib/ldap/das.ldap.constants/pom.xml new file mode 100644 index 0000000000..e501f8b1e5 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.constants/pom.xml @@ -0,0 +1,20 @@ +<?xml version="1.0"?><project> + <parent> + <artifactId>tuscany-das-ldap</artifactId> + <groupId>org.apache.tuscany.das</groupId> + <version>1.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>das.ldap.constants</artifactId> + <name>das.ldap.constants</name> + + <url>http://maven.apache.org</url> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> +</project> diff --git a/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/constants/ApacheDSConnectionConstants.java b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/constants/ApacheDSConnectionConstants.java new file mode 100644 index 0000000000..01e4d63789 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/constants/ApacheDSConnectionConstants.java @@ -0,0 +1,48 @@ +/* + * 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.constants; + +public interface ApacheDSConnectionConstants +{ + String APACHE_CONTEXT_FACTORY = + "org.apache.directory.server.core.jndi.CoreContextFactory"; + + String SUN_CONTEXT_FACTORY = + "com.sun.jndi.ldap.LdapCtxFactory"; + + String SIMPLE_SECURITY_AUTHENTICATION_VALUE = + "simple"; + + String DEFAULT_SECURITY_PRINCIPAL_VALUE = + "uid=admin,ou=system"; + + String DEFAULT_SECURITY_CREDENTIALS_VALUE = + "secret"; + + String SCHEMA_PROVIDER_PATH = + "ou=schema"; + + String SYSTEM_PROVIDER_PATH = + "ou=system"; + + String NLOG4J_CONFIGURATION_FILEPATH = + "src/test/resources/log4j.properties"; + +} diff --git a/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/constants/DASConstants.java b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/constants/DASConstants.java new file mode 100644 index 0000000000..91745e0980 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/constants/DASConstants.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.constants; + +public interface DASConstants { + String DAS_META_ID_DEFAULT = + "0"; + + + String DAS_XSD_NAMESPACE = + "http://org.apache.tuscany/das/ldap"; + + String M_META_TOP_SDO_OBJECT_CLASS = + "metaTopSDO"; + + String M_COMPLEX_MAY = + "m-complexMay"; + + String M_COMPLEX_MAY_DESCRIPTION = + "SDO Type member that is a reference"; + + String M_COMPLEX_MUST = + "m-complexMust"; + + String M_COMPLEX_MUST_DESCRIPTION = + "Required SDO Type member reference."; + + String ID = + "id"; + + String ID_DESCRIPTION = + "Unique DataObject Instance Integer ID"; + + //================================================== + String XSD_CONTEXT_NAME = + "xsd"; + + String ECORE_CONTEXT_NAME = + "ecore"; + + String DAS_CONTEXT_NAME = + "das"; + + String SYNTAXES_CONTEXT_NAME = + "syntaxes"; + + String SYNTAX_CHECKERS_CONTEXT_NAME = + "syntaxCheckers"; + + String ATTRIBUTE_TYPES_CONTEXT_NAME = + "attributeTypes"; + + String OBJECT_CLASSES_CONTEXT_NAME = + "objectClasses"; + + String META_CONTEXT_NAME = + "meta"; + //================================================== + + String LDAP_USER_APPLICATIONS = + "USER_APPLICATIONS"; + + String LDAP_FALSE = + "FALSE"; + + String TUSCANY_OID_PREFIX_VALUE = + "1.3.6.1.4.1.18060.4"; + + + String OID_SYNTAX_OID_VALUE = + "1.3.6.1.4.1.1466.115.121.1.38"; + + String INTEGER_SYNTAX_OID_VALUE = + "1.3.6.1.4.1.1466.115.121.1.27"; + + String DISTINGUISHED_NAME_SYNTAX_OID_VALUE = + "1.3.6.1.4.1.1466.115.121.1.12"; +} diff --git a/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/constants/SyntaxOIDValues.java b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/constants/SyntaxOIDValues.java new file mode 100644 index 0000000000..32dece8648 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/constants/SyntaxOIDValues.java @@ -0,0 +1,8 @@ +package org.apache.tuscany.das.ldap.constants; + +public interface SyntaxOIDValues { + + String SYNTAX_STRING_OID_VALUE = "1.3.6.1.4.1.1466.115.121.1.15"; + String SYNTAX_INTEGER_OID_VALUE = "1.3.6.1.4.1.1466.115.121.1.27"; + String SYNTAX_BOOLEAN_OID_VALUE = "1.3.6.1.4.1.1466.115.121.1.7"; +} diff --git a/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/AttributeTypeConstants.java b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/AttributeTypeConstants.java new file mode 100644 index 0000000000..9a61986318 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/AttributeTypeConstants.java @@ -0,0 +1,25 @@ + +package org.apache.tuscany.das.ldap.schema.constants; + +public interface AttributeTypeConstants +{ + String CN = "cn"; + String OU = "ou"; + String OBJECT_CLASS = "objectClass"; + String CREATORS_NAME = "creatorsName"; + String CREATE_TIMESTAMP = "createTimestamp"; + String MODIFY_TIMESTAMP = "modifyTimestamp"; + String MODIFIERS_NAME = "modifiersName"; + + String LDAP_SYNTAXES = "ldapSyntaxes"; + String SYNTAXES = "syntaxes"; + String SYNTAX_CHECKERS = "syntaxCheckers"; + String MATCHING_RULES = "matchingRules"; + String ATTRIBUTE_TYPES = "attributeTypes"; + String OBJECT_CLASSES = "objectClasses"; + String MATCHING_RULE = "matchingRuleUse"; + String DIT_STRUCTURE = "ditStructureRules"; + String DIT_CONTENT = "ditContentRules"; + String NAME_FORMS = "nameForms"; + String UNIQUE_IDENTIFIER = "uniqueIdentifier"; +} diff --git a/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/EnumeratedSchemaAttributeTypeValues.java b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/EnumeratedSchemaAttributeTypeValues.java new file mode 100644 index 0000000000..6658beeafa --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/EnumeratedSchemaAttributeTypeValues.java @@ -0,0 +1,7 @@ + +package org.apache.tuscany.das.ldap.schema.constants; + +public interface EnumeratedSchemaAttributeTypeValues +{ + String M_EQUALITY__NAME_OR_NUMERIC_ID_MATCH="nameOrNumericIdMatch"; +} diff --git a/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/ObjectClassConstants.java b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/ObjectClassConstants.java new file mode 100644 index 0000000000..c722ef8631 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/ObjectClassConstants.java @@ -0,0 +1,35 @@ +/* + * 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.constants; + + +/** + * These constants are used by the DAS and DAS Clients. + * + */ +public interface ObjectClassConstants +{ + String TOP = "top"; + String ORGANIZATIONAL_UNIT = "organizationalUnit"; + + String ABSTRACT = "ABSTRACT"; + String STRUCTURAL = "STRUCTURAL"; + String AUXILIARY = "AUXILIARY"; +} diff --git a/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/PartitionConstants.java b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/PartitionConstants.java new file mode 100644 index 0000000000..c5ef1f2392 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/PartitionConstants.java @@ -0,0 +1,8 @@ + +package org.apache.tuscany.das.ldap.schema.constants; + +public interface PartitionConstants +{ + + +} diff --git a/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/SchemaAttributeTypeConstants.java b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/SchemaAttributeTypeConstants.java new file mode 100644 index 0000000000..8cf39ce172 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/SchemaAttributeTypeConstants.java @@ -0,0 +1,33 @@ + +package org.apache.tuscany.das.ldap.schema.constants; + +public interface SchemaAttributeTypeConstants +{ + String M_SUP_OBJECT_CLASS = "m-supObjectClass"; + String M_BYTECODE = "m-bytecode"; + String M_FQCN = "m-fqcn"; + String M_DEPENDENCIES = "m-dependencies"; + String M_DISABLED = "m-disabled"; + String M_DESCRIPTION = "m-description"; + String M_OBSOLETE = "m-obsolete"; + String M_NAME = "m-name"; + String M_OID = "m-oid"; + String M_OC = "m-oc"; + String M_AUX = "m-aux"; + String M_USAGE = "m-usage"; + String M_NO_USER_MODIFICATION = "m-noUserModification"; + String M_SINGLE_VALUE = "m-singleValue"; + String M_COLLECTIVE = "m-collective"; + String M_SUBSTR = "m-substr"; + String M_SUP = "m-supAttributeType"; + String M_ORDERING = "m-ordering"; + String M_EQUALITY = "m-equality"; + String M_SYNTAX = "m-syntax"; + String M_MUST = "m-must"; + String M_MAY = "m-may"; + String M_TYPE_OBJECT_CLASS = "m-typeObjectClass"; + String X_HUMAN_READIBLE = "x-humanReadible";//TODO Fix spelling once fixed in ADS + + String M_FQCN_DEFAULT_VALUE = + "org.apache.directory.shared.ldap.schema.syntax.AcceptAllSyntaxChecker"; +} diff --git a/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/SchemaObjectClassConstants.java b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/SchemaObjectClassConstants.java new file mode 100644 index 0000000000..34f04d3498 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/SchemaObjectClassConstants.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.constants; + + +/** + * These constants are used by the DAS and DAS Clients. + */ +public interface SchemaObjectClassConstants +{ + String META_TOP = "metaTop"; + String META_SCHEMA = "metaSchema"; + String META_OBJECT_CLASS = "metaObjectClass"; + String META_ATTRIBUTE_TYPE = "metaAttributeType"; + String META_MATCHING_RULE = "metaMatchingRule"; + String META_NORMALIZER = "metaNormalizer"; + String META_SYNTAX = "metaSyntax"; + String META_SYNTAX_CHECKER = "metaSyntaxChecker"; + String META_COMPARATOR = "metaComparator"; + String META_NAME_FORM = "metaNameForm"; + String META_DIT_CONTENT_RULE = "metaDITContentRule"; +} diff --git a/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/SystemSchemaConstants.java b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/SystemSchemaConstants.java new file mode 100644 index 0000000000..2e8dac3cbb --- /dev/null +++ b/das-java/contrib/ldap/das.ldap.constants/src/main/java/org/apache/tuscany/das/ldap/schema/constants/SystemSchemaConstants.java @@ -0,0 +1,34 @@ +/* + * 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.constants; + + +/** + * Constants for the System schema. + * + * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> + * @version $Rev$, $Date$ + */ +public interface SystemSchemaConstants +{ + String SCHEMA_NAME = "system"; + + +} diff --git a/das-java/contrib/ldap/das.ldap/pom.xml b/das-java/contrib/ldap/das.ldap/pom.xml new file mode 100644 index 0000000000..68524253b6 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/pom.xml @@ -0,0 +1,207 @@ +<?xml version="1.0"?><project> + <parent> + <groupId>org.apache.tuscany.das</groupId> + <artifactId>tuscany-das-ldap</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>das.ldap</artifactId> + <name></name> + + <url>http://pyramidetechnologies.com/model/archetype</url> + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.das</groupId> + <artifactId>das.ldap.configuration.model.v100</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.das</groupId> + <artifactId>das.ldap.constants</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + + + <dependency> + <groupId>org.apache.directory.server</groupId> + <artifactId>apacheds-core</artifactId> + <version>1.5.1-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>nlog4j</artifactId> + <version>1.2.25</version> + </dependency> + + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>1.3.1</version> + </dependency> + + + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ant</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>codegen</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>codegen-ecore</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>codegen-ecore-ui</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>codegen-ui</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>common</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>commonj-sdo</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>common-ui</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>converter</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore-change</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore-change-edit</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore-edit</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore-sdo</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore-sdo-edit</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore-xmi</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>edit</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>edit-ui</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>emf</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>exporter</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>importer</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>importer-ecore</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>importer-java</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>importer-rose</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-ecore2ecore</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-ecore2ecore-editor</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-ecore2xml</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-ecore2xml-ui</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-ui</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-xsd2ecore</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-xsd2ecore-editor</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.xsd</groupId> + <artifactId>ecore-exporter</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.xsd</groupId> + <artifactId>ecore-importer</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.xsd</groupId> + <artifactId>edit</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.xsd</groupId> + <artifactId>xsd</artifactId> + </dependency> + </dependencies> +</project> diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplate.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplate.java new file mode 100644 index 0000000000..7977f60545 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplate.java @@ -0,0 +1,129 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.apacheds.testing.setup; + +import java.util.Hashtable; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.naming.ldap.InitialLdapContext; +import javax.naming.ldap.LdapContext; + +import org.apache.directory.server.core.configuration.MutableStartupConfiguration; +import org.apache.directory.server.core.configuration.ShutdownConfiguration; +import org.apache.log4j.PropertyConfigurator; + +/** + * The Class JNDIEmbeddedConnectionTemplate. + */ +public abstract class ADSEmbeddedConnectionTemplate +extends JNDIConnectionTemplate +{ + public void tearDown() throws NamingException, Exception + { + Hashtable<String,Object> env = + new Hashtable<String,Object>(); + + env = createEnvironment(env); + + env.put( + Context.PROVIDER_URL, + SYSTEM_PROVIDER_PATH); + env.put( + Context.INITIAL_CONTEXT_FACTORY, + "org.apache.directory.server.core.jndi.CoreContextFactory" ); + env.putAll( + new ShutdownConfiguration().toJndiEnvironment() ); + + new InitialContext( env ); + Runtime.getRuntime().gc(); + super.tearDown(); + } + + + + public void setUp() throws Exception + { + PropertyConfigurator. + configure(NLOG4J_CONFIGURATION_FILEPATH); + super.setUp(); + } + + /** + * Connect to an embedded ApacheDS server. + * + * @param providerPath the provider path ("ou=schema", ou="system", etc.) + * + * @return the ldap context + * + * @throws NamingException the naming exception + */ + public LdapContext connect( String providerPath ) throws NamingException + { + MutableStartupConfiguration mutableStartupConfiguration = + new MutableStartupConfiguration(); + + Hashtable<String,Object> adminEnv = + new Hashtable<String,Object>( ); + + adminEnv.putAll( + mutableStartupConfiguration. + toJndiEnvironment()); + + adminEnv.put( + Context.PROVIDER_URL, + SYSTEM_PROVIDER_PATH); + adminEnv.put( + Context.SECURITY_PRINCIPAL, + DEFAULT_SECURITY_PRINCIPAL_VALUE); + adminEnv.put( + Context.SECURITY_CREDENTIALS, + DEFAULT_SECURITY_CREDENTIALS_VALUE); + adminEnv.put( + Context.SECURITY_AUTHENTICATION, + SIMPLE_SECURITY_AUTHENTICATION_VALUE ); + new InitialLdapContext( adminEnv, null ); + + + + Hashtable<String,Object> env = + new Hashtable<String,Object>(); + + env.put( + Context.INITIAL_CONTEXT_FACTORY, + "org.apache.directory.server.core.jndi.CoreContextFactory" ); + env.put( + Context.SECURITY_PRINCIPAL, + DEFAULT_SECURITY_PRINCIPAL_VALUE); + env.put( + Context.SECURITY_CREDENTIALS, + DEFAULT_SECURITY_CREDENTIALS_VALUE); + env.put( + Context.SECURITY_AUTHENTICATION, + SIMPLE_SECURITY_AUTHENTICATION_VALUE ); + env.put( Context.PROVIDER_URL, providerPath ); + + env.put( Context.PROVIDER_URL, providerPath ); + + return new InitialLdapContext( env, null ); + + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplateTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplateTest.java new file mode 100644 index 0000000000..f5426b3424 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedConnectionTemplateTest.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.apacheds.testing.setup; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +public class ADSEmbeddedConnectionTemplateTest +extends ADSEmbeddedConnectionTemplate +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws Exception + { + super.setUp(); + } + + public void testSchemaConnect() throws NamingException + { + LdapContext ldapContext =null; + + ldapContext =connect("ou=schema"); + + assertEquals( + "ou=schema", + ldapContext.getNameInNamespace()); + } + + public void testRootDSEConnect() throws NamingException + { + LdapContext ldapContext =null; + + ldapContext =connect(""); + + assertEquals( + "", + ldapContext.getNameInNamespace()); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplate.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplate.java new file mode 100644 index 0000000000..fae915a0a2 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplate.java @@ -0,0 +1,157 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.apacheds.testing.setup; + +import java.util.HashSet; +import java.util.Hashtable; +import java.util.Set; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttributes; +import javax.naming.ldap.InitialLdapContext; +import javax.naming.ldap.LdapContext; + +import org.apache.directory.server.core.configuration.Configuration; +import org.apache.directory.server.core.configuration.MutablePartitionConfiguration; +import org.apache.directory.server.core.configuration.MutableStartupConfiguration; +import org.apache.directory.server.core.configuration.ShutdownConfiguration; +import org.apache.log4j.PropertyConfigurator; + +/** + * The Class JNDIEmbeddedConnectionTemplate. + */ +public abstract class ADSEmbeddedHotPartitionTemplate +extends JNDIConnectionTemplate +{ + public void tearDown() throws NamingException, Exception + { + Hashtable<String,Object> env = + new Hashtable<String,Object>(); + + env = createEnvironment(env); + + env.put( + Context.PROVIDER_URL, + SYSTEM_PROVIDER_PATH); + env.put( + Context.INITIAL_CONTEXT_FACTORY, + "org.apache.directory.server.core.jndi.CoreContextFactory" ); + env.putAll( + new ShutdownConfiguration().toJndiEnvironment() ); + + new InitialContext( env ); + Runtime.getRuntime().gc(); + super.tearDown(); + } + + + + public void setUp() throws Exception + { + PropertyConfigurator. + configure(NLOG4J_CONFIGURATION_FILEPATH); + super.setUp(); + } + + /** + * Connect to an embedded ApacheDS server. + * + * @param partitionName the provider path ("ou=schema", ou="system", etc.) + * + * @return the ldap context + * + * @throws NamingException the naming exception + */ + public LdapContext connect( String partitionName ) throws NamingException + { + MutableStartupConfiguration mutableStartupConfiguration = + new MutableStartupConfiguration(); + + Hashtable<String,Object> adminEnv = + new Hashtable<String,Object>( ); + + adminEnv.putAll( + mutableStartupConfiguration. + toJndiEnvironment()); + + adminEnv.put( + Context.PROVIDER_URL, + SYSTEM_PROVIDER_PATH); + adminEnv.put( + Context.SECURITY_PRINCIPAL, + DEFAULT_SECURITY_PRINCIPAL_VALUE); + adminEnv.put( + Context.SECURITY_CREDENTIALS, + DEFAULT_SECURITY_CREDENTIALS_VALUE); + adminEnv.put( + Context.SECURITY_AUTHENTICATION, + SIMPLE_SECURITY_AUTHENTICATION_VALUE ); + new InitialLdapContext( adminEnv, null ); + + + MutablePartitionConfiguration dasPartition = + new MutablePartitionConfiguration(); + + Attributes suffixAttributes = new BasicAttributes(); + suffixAttributes.put( "objectClass", "top"); + suffixAttributes.get( "objectClass" ).add( "organizationalUnit" ); + suffixAttributes.put( "ou", partitionName ); + + dasPartition.setId( partitionName); + dasPartition.setSuffix( "ou=" +partitionName ); + dasPartition.setContextEntry( suffixAttributes ); + + Set<MutablePartitionConfiguration> partitions = + new HashSet<MutablePartitionConfiguration> (); + + partitions.add( dasPartition ); + + mutableStartupConfiguration. + setPartitionConfigurations( partitions ); + + Hashtable<String,Object> env = + new Hashtable<String,Object>(); + + env.put( + Context.INITIAL_CONTEXT_FACTORY, + "org.apache.directory.server.core.jndi.CoreContextFactory" ); + env.put( + Context.SECURITY_PRINCIPAL, + DEFAULT_SECURITY_PRINCIPAL_VALUE); + env.put( + Context.SECURITY_CREDENTIALS, + DEFAULT_SECURITY_CREDENTIALS_VALUE); + env.put( + Context.SECURITY_AUTHENTICATION, + SIMPLE_SECURITY_AUTHENTICATION_VALUE ); + env.put( + Context.PROVIDER_URL, + "ou=" + partitionName ); + + env.put( + Configuration.JNDI_KEY, + mutableStartupConfiguration ); + + return new InitialLdapContext( env, null ); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplateTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplateTest.java new file mode 100644 index 0000000000..aba1ff7940 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/ADSEmbeddedHotPartitionTemplateTest.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.apacheds.testing.setup; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +public class ADSEmbeddedHotPartitionTemplateTest +extends ADSEmbeddedHotPartitionTemplate +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws Exception + { + super.setUp(); + } + + public void testCreateHotPartition() throws NamingException + { + LdapContext ldapContext = + null; + + ldapContext = + connect("test"); + + assertEquals( + "ou=test", + ldapContext.getNameInNamespace()); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplate.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplate.java new file mode 100644 index 0000000000..ae267144eb --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplate.java @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.apacheds.testing.setup; + +import java.util.Hashtable; + +import javax.naming.Context; +import javax.naming.NamingException; +import javax.naming.ldap.InitialLdapContext; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.constants.ApacheDSConnectionConstants; + +import junit.framework.TestCase; + +/* + * Just a class template class + */ +public abstract class JNDIConnectionTemplate +extends TestCase +implements ApacheDSConnectionConstants +{ + protected String providerHost = + "ldap://localhost:10389/"; + + protected String providerPath = + SYSTEM_PROVIDER_PATH; + + private String providerURL = + providerHost + providerPath; + + protected String initialContextFactory = + SUN_CONTEXT_FACTORY; + + protected String securityAuthentication = + SIMPLE_SECURITY_AUTHENTICATION_VALUE; + + protected String securityPrincipal = + DEFAULT_SECURITY_PRINCIPAL_VALUE; + + protected String credentials = + DEFAULT_SECURITY_CREDENTIALS_VALUE; + + public Hashtable<String,Object> createEnvironment( + Hashtable<String, Object> env) + { + providerURL = + providerHost + providerPath; + + env.put( + Context.PROVIDER_URL, + providerURL); + + env.put( + Context.INITIAL_CONTEXT_FACTORY, + initialContextFactory ); + + env.put( + Context.SECURITY_AUTHENTICATION, + securityAuthentication); + + env.put( + Context.SECURITY_PRINCIPAL, + securityPrincipal ); + + env.put( + Context.SECURITY_CREDENTIALS, + credentials ); + + return env; + } + + public LdapContext connect() throws NamingException + { + Hashtable<String, Object> env = + new Hashtable<String, Object>(); + + return new InitialLdapContext( + createEnvironment(env), null); + } + + public void setUp() throws Exception + { + super.setUp(); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplateTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplateTest.java new file mode 100644 index 0000000000..883a556167 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIConnectionTemplateTest.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.apacheds.testing.setup; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +/* + * These tests require a running server. + */ +public class JNDIConnectionTemplateTest extends JNDIConnectionTemplate +{ + private static LdapContext systemContext = null; + private static LdapContext schemaContext = null; + + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void testSystemContextConnection() + throws NamingException + { + systemContext = connect(); + assertNotNull( systemContext ); + assertNotNull( connect() ); + assertEquals( + systemContext. + getNameInNamespace(), + "ou=system"); + } + + public void testSchemaContextConnection() + throws NamingException + { + providerPath = SCHEMA_PROVIDER_PATH; + schemaContext = connect(); + assertNotNull (schemaContext); + assertNotNull(connect()); + assertEquals( + schemaContext.getNameInNamespace(), + "ou=schema"); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplate.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplate.java new file mode 100644 index 0000000000..546ccea0d5 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplate.java @@ -0,0 +1,117 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.apacheds.testing.setup; + +import java.util.HashSet; +import java.util.Hashtable; +import java.util.Set; + +import javax.naming.Context; +import javax.naming.NamingException; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttributes; +import javax.naming.ldap.InitialLdapContext; +import javax.naming.ldap.LdapContext; + +import org.apache.directory.server.core.configuration.Configuration; +import org.apache.directory.server.core.configuration.MutablePartitionConfiguration; +import org.apache.directory.server.core.configuration.MutableStartupConfiguration; +import org.apache.tuscany.das.ldap.constants.ApacheDSConnectionConstants; +import org.apache.tuscany.das.ldap.schema.embedded.setup.test.AbstractTestSetup; + +import junit.framework.TestCase; + +/* + * Just a class template class + */ +public abstract class JNDIHotPartitionConnectionTemplate +extends AbstractTestSetup +implements ApacheDSConnectionConstants +{ + + public Hashtable<String,Object> createEnvironment( + Hashtable<String, Object> env, + String partitionName) throws NamingException + { + MutableStartupConfiguration mutableStartupConfiguration = + new MutableStartupConfiguration(); + + MutablePartitionConfiguration dasPartition = + new MutablePartitionConfiguration(); + + Attributes suffixAttributes = new BasicAttributes(); + suffixAttributes.put( "objectClass", "top"); + suffixAttributes.get( "objectClass" ).add( "organizationalUnit" ); + suffixAttributes.put( "ou", partitionName ); + + dasPartition.setId( partitionName); + dasPartition.setSuffix( "ou=" +partitionName ); + dasPartition.setContextEntry( suffixAttributes ); + + Set<MutablePartitionConfiguration> partitions = + new HashSet<MutablePartitionConfiguration> (); + + partitions.add( dasPartition ); + + mutableStartupConfiguration. + setPartitionConfigurations( partitions ); + + env.put( + Context.INITIAL_CONTEXT_FACTORY, + "org.apache.directory.server.core.jndi.CoreContextFactory" ); + + env.put( + Context.SECURITY_PRINCIPAL, + DEFAULT_SECURITY_PRINCIPAL_VALUE); + + env.put( + Context.SECURITY_CREDENTIALS, + DEFAULT_SECURITY_CREDENTIALS_VALUE); + + env.put( + Context.SECURITY_AUTHENTICATION, + SIMPLE_SECURITY_AUTHENTICATION_VALUE ); + + env.put( + Context.PROVIDER_URL, + "ou=" + partitionName ); + + env.put( + Configuration.JNDI_KEY, + mutableStartupConfiguration ); + + return env; + } + + public LdapContext connect( String partitionName ) + throws NamingException + { + Hashtable<String, Object> env = + new Hashtable<String, Object>(); + + return new InitialLdapContext( + createEnvironment(env, partitionName), null); + } + + public void setUp() throws Exception + { + super.setUp(); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplateTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplateTest.java new file mode 100644 index 0000000000..85b9f5eb10 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/directory/apacheds/testing/setup/JNDIHotPartitionConnectionTemplateTest.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.apacheds.testing.setup; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +/* + * These tests require a running server. + */ +public class JNDIHotPartitionConnectionTemplateTest +extends JNDIHotPartitionConnectionTemplate +{ + private static LdapContext testContext = null; + private static LdapContext systemContext = null; + private static LdapContext schemaContext = null; + + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void testTestContextConnection() + throws NamingException + { + testContext = connect("test"); + assertNotNull(testContext ); + assertEquals( + testContext.getNameInNamespace(), "ou=test"); + } + + + public void testSystemContextConnection() + throws NamingException + { + systemContext = connect("system"); + assertNotNull( systemContext ); + assertEquals( + systemContext.getNameInNamespace(), "ou=system"); + } + + public void testSchemaContextConnection() + throws NamingException + { + schemaContext = connect("schema"); + assertNotNull( schemaContext ); + assertEquals( + schemaContext.getNameInNamespace(), + "ou=schema"); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/connect/ADSEmbeddedConnection.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/connect/ADSEmbeddedConnection.java new file mode 100644 index 0000000000..b547f1447b --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/connect/ADSEmbeddedConnection.java @@ -0,0 +1,175 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.connect; + +import java.util.HashSet; +import java.util.Hashtable; +import java.util.Set; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttributes; +import javax.naming.ldap.InitialLdapContext; +import javax.naming.ldap.LdapContext; + +import org.apache.directory.server.core.configuration.MutablePartitionConfiguration; +import org.apache.directory.server.core.configuration.MutableStartupConfiguration; +import org.apache.directory.server.core.configuration.ShutdownConfiguration; +import org.apache.log4j.PropertyConfigurator; +import org.apache.tuscany.model.Configuration; + +/** + * The Class JNDIEmbeddedConnectionTemplate. + */ +public class ADSEmbeddedConnection extends JNDIConnection { + private Configuration configuration = null; + + public ADSEmbeddedConnection(Configuration configuration) { + super(configuration); + this.configuration = configuration; + } + + /** + * Shutdown. + * + * Shuts down an embedded instance of ADS. + * + * @throws NamingException + * the naming exception + * @throws Exception + * the exception + */ + public void shutdown() throws NamingException, Exception { + Hashtable<String, Object> env = new Hashtable<String, Object>(); + + env = createEnvironment(env); + + env.put( + Context.PROVIDER_URL, + SYSTEM_PROVIDER_PATH); + env.put( + Context.INITIAL_CONTEXT_FACTORY, + APACHE_CONTEXT_FACTORY); + env.putAll( + new ShutdownConfiguration().toJndiEnvironment()); + + new InitialContext(env); + Runtime.getRuntime().gc(); + } + + /** + * Startup. + * + * Starts an embedded instance of ADS and creates the the DAS partition, if + * it does not already exist. + * + * @throws NamingException + * the naming exception + */ + public LdapContext startup(String partitionName) + throws NamingException { + PropertyConfigurator. + configure( + configuration. + getNlog4jConfigurationFilePath()); + + MutableStartupConfiguration mutableStartupConfiguration = + new MutableStartupConfiguration(); + + Hashtable<String, Object> adminEnv = + new Hashtable<String, Object>(); + + adminEnv.putAll(mutableStartupConfiguration.toJndiEnvironment()); + + adminEnv.put( + Context.PROVIDER_URL, + SYSTEM_PROVIDER_PATH); + adminEnv.put( + Context.SECURITY_PRINCIPAL, + configuration.getSecurityPrincipal()); + adminEnv.put( + Context.SECURITY_CREDENTIALS, + configuration.getSecurityCredentials()); + adminEnv.put( + Context.SECURITY_AUTHENTICATION, + configuration.getSecurityAuthenticationType()); + new InitialLdapContext(adminEnv, null); + + MutablePartitionConfiguration dasPartition = + new MutablePartitionConfiguration(); + + Attributes suffixAttributes = + new BasicAttributes(); + suffixAttributes.put(OBJECT_CLASS, TOP); + suffixAttributes.get(OBJECT_CLASS).add(ORGANIZATIONAL_UNIT); + suffixAttributes.put(OU, partitionName); + + dasPartition.setId(partitionName); + dasPartition.setSuffix(getProviderPath(partitionName)); + dasPartition.setContextEntry(suffixAttributes); + + Set<MutablePartitionConfiguration> partitions = + new HashSet<MutablePartitionConfiguration>(); + + partitions.add(dasPartition); + + mutableStartupConfiguration.setPartitionConfigurations(partitions); + + Hashtable<String, Object> env = + new Hashtable<String, Object>(); + + env.put( + Context.INITIAL_CONTEXT_FACTORY, + "org.apache.directory.server.core.jndi.CoreContextFactory"); + env.put( + Context.SECURITY_PRINCIPAL, + DEFAULT_SECURITY_PRINCIPAL_VALUE); + env.put( + Context.SECURITY_CREDENTIALS, + DEFAULT_SECURITY_CREDENTIALS_VALUE); + env.put( + Context.SECURITY_AUTHENTICATION, + SIMPLE_SECURITY_AUTHENTICATION_VALUE); + env.put( + Context.PROVIDER_URL, getProviderPath(partitionName)); + + env.put( + org.apache.directory.server.core.configuration.Configuration.JNDI_KEY, + mutableStartupConfiguration); + + return new InitialLdapContext(env, null); + } + + public LdapContext connect(String partitionName) throws NamingException + { + return startup(partitionName); + } + + /** + * Gets the provider path. TODO Move to helper + * + * @return the provider path + */ + public String getProviderPath(String partitionName) { + return OU + "=" + partitionName; + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/connect/JNDIConnection.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/connect/JNDIConnection.java new file mode 100644 index 0000000000..d36dacc952 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/connect/JNDIConnection.java @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.connect; + +import java.util.Hashtable; + +import javax.naming.Context; +import javax.naming.NamingException; +import javax.naming.ldap.InitialLdapContext; +import javax.naming.ldap.LdapContext; +import org.apache.tuscany.model.Configuration; + +import org.apache.tuscany.das.ldap.constants.ApacheDSConnectionConstants; +import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants; +import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants; +/* + * Just a class template class + */ +public class JNDIConnection +implements +ApacheDSConnectionConstants, +AttributeTypeConstants, +ObjectClassConstants +{ + private Configuration configuration = null; + + public JNDIConnection(Configuration configuration) + { + this.configuration=configuration; + } + + public Hashtable<String,Object> createEnvironment( + Hashtable<String, Object> env) + { + env.put( + Context.INITIAL_CONTEXT_FACTORY, + configuration.getInitialContextFactory() ); + + env.put( + Context.SECURITY_AUTHENTICATION, + configuration.getSecurityAuthenticationType()); + + env.put( + Context.SECURITY_PRINCIPAL, + configuration.getSecurityPrincipal() ); + + env.put( + Context.SECURITY_CREDENTIALS, + configuration.getSecurityCredentials() ); + + return env; + } + + public LdapContext connect(String partitionName) throws NamingException + { + Hashtable<String, Object> env = + new Hashtable<String, Object>(); + + env = createEnvironment(env); + + env.put( + Context.PROVIDER_URL, + getProviderURL(partitionName)); + + return new InitialLdapContext(env, null); + } + + public String getProviderURL(String partitionName) + { + return "ldap://" + + configuration.getHost() + + ":" + + configuration.getPort() + + "/" + + OU + + "=" + + partitionName; + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/InitialContextCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/InitialContextCreator.java new file mode 100644 index 0000000000..8e50e72178 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/InitialContextCreator.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.create; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.util.XSDNamespaceURITokenizer; +import org.eclipse.emf.common.util.URI; + +/** + * The InitialContextCreator for a model's directory namespace + */ +public class InitialContextCreator +{ + /** + * Creates the parent context for the root DataObject instance + * + * @param dasContext the dir context + * @param xsdNamespace the xml namespace of the DataObjects + * + * @return the directory context + * + * @throws NamingException the naming exception + */ + public static LdapContext create( + String xsdNamespace, + LdapContext dasContext) throws NamingException + { + URI xsdNamespaceURI = + URI.createURI( + xsdNamespace ); + + String[] pathTokens = + XSDNamespaceURITokenizer. + createPathTokens( + xsdNamespaceURI ); + + String[] authorityTokens = + XSDNamespaceURITokenizer. + createAuthorityTokens( + xsdNamespaceURI ); + + dasContext = + InitialContextCreatorHelper. + createAuthorityContext( + dasContext, + authorityTokens ); + + dasContext = + InitialContextCreatorHelper. + createPathContext( + dasContext, + pathTokens ); + + return dasContext; + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/InitialContextCreatorHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/InitialContextCreatorHelper.java new file mode 100644 index 0000000000..0be0975082 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/InitialContextCreatorHelper.java @@ -0,0 +1,143 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.create; + +import javax.naming.NamingException; +import javax.naming.directory.Attributes; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants; +import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants; +import org.apache.tuscany.das.ldap.schema.constants.SchemaObjectClassConstants; + +/** + * The Class InitialContextCreatorHelper. + */ +public class InitialContextCreatorHelper +implements +ObjectClassConstants, +SchemaObjectClassConstants, +AttributeTypeConstants +{ + + /** + * Creates the sub context if it does not already exist. + * + * @param ldapContext the ldap context + * @param subContextRDN the sub context + * @param attributes the attributes + * + * @return the ldap context + * + * @throws NamingException the naming exception + */ + public static LdapContext createSubContext( + LdapContext ldapContext, + String subContextRDN, + Attributes attributes) + throws NamingException + { + try + { + ldapContext = + ( LdapContext ) + ldapContext. + lookup( subContextRDN ); + } + catch ( NamingException e ) + { + if (attributes == null) + { + ldapContext = + ( LdapContext ) + ldapContext. + createSubcontext( subContextRDN ); + } + else + { + ldapContext = + ( LdapContext ) + ldapContext. + createSubcontext( + subContextRDN, + attributes ); + } + } + return ldapContext; + } + + /** + * Creates the authority context. Authority + * means the Authority component of a URL. + * For example if the authority is "example.com", + * then the authority context will be "cn=example, cn=com". + * + * @param ldapContext the ldap context + * @param authorityTokens the authority tokens + * + * @return the ldap context + * + * @throws NamingException the naming exception + * + */ + public static LdapContext createAuthorityContext( + LdapContext ldapContext, + String[] authorityTokens) + throws NamingException + { + for (int i = authorityTokens.length-1; i >= (0); i--) + { + String subContext = CN+ "=" + authorityTokens[i]; + ldapContext = (LdapContext) createSubContext( + ldapContext, + subContext, null ); + } + return ldapContext; + } + + /** + * Creates the path context. + * Path means the path component of a URL. + * For example if the authority is "example.com/users/accounts", + * then the path context will be "cn=accounts, cn=users". The full + * model namespaced context will be "cn=accounts, cn=users, cn=example, cn=com" + * + * @param authorityContext the ldap context + * @param pathTokens the path tokens + * + * @return the ldap context + * + * @throws NamingException the naming exception + */ + public static LdapContext createPathContext( + LdapContext authorityContext, + String[] pathTokens) + throws NamingException + { + for (int i = 1; i < (pathTokens.length); i++) + { + String subContext = CN + "=" + pathTokens[i]; + authorityContext = (LdapContext) createSubContext( + authorityContext, + subContext, null ); + } + return authorityContext; + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/MetaContextCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/MetaContextCreator.java new file mode 100644 index 0000000000..4caa380258 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/create/MetaContextCreator.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.create; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants; + +/** + * The Class MetaContextCreator. + */ +public class MetaContextCreator +implements +DASConstants, +AttributeTypeConstants +{ + /** + * Create a meta context below the provided parent context. + * + * @param metaParentContext the context + * + * @return the ldap context + * + * @throws NamingException the naming exception + */ + public static LdapContext create( + LdapContext metaParentContext) throws NamingException + { + String rdn = + CN + "=" + META_CONTEXT_NAME; + + try + { + return + ( LdapContext ) + metaParentContext.lookup( rdn ); + } + catch(Exception e) + { + return + ( LdapContext ) + metaParentContext. + createSubcontext( rdn ); + } + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/destroy/InitialContextDestroyer.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/destroy/InitialContextDestroyer.java new file mode 100644 index 0000000000..2cc3fc7d36 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/destroy/InitialContextDestroyer.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.destroy; + +import javax.naming.NamingException; +import javax.naming.directory.DirContext; + +import org.apache.tuscany.das.ldap.util.JNDIUtil; + +// TODO: Auto-generated Javadoc +/** + * The Class InitialContextDestroyer. + */ +public class InitialContextDestroyer +{ + + /** + * Destroys the initial naming context + * when the parent entries do not contain + * other child entries. If the initial + * naming context also supports other + * entries, then a NamingException will + * be thrown. + * + * @param partitionContext the partition context + * @param initialContext the initial context + * + * @throws NamingException the naming exception + */ + public static void destroy( + DirContext initialContext, + DirContext partitionContext) + throws NamingException + { + String[] initialContextComponents = + JNDIUtil. + calculateDNComponents( initialContext ); + + String[] partitionContextComponents = + JNDIUtil.calculateDNComponents( partitionContext ); + + int numberOfPossibleSubcontexts = + initialContextComponents.length + - partitionContextComponents.length; + + for (int i = 0; i < numberOfPossibleSubcontexts; i++) + { + String rdn = initialContextComponents[i]; + + initialContext = JNDIUtil.getParentContext( + initialContext, + partitionContext ); + + initialContext.destroySubcontext( rdn ); + } + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/destroy/MetaContextDestroyer.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/destroy/MetaContextDestroyer.java new file mode 100644 index 0000000000..7849b33edb --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/destroy/MetaContextDestroyer.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.destroy; + +import javax.naming.NamingException; +import javax.naming.directory.DirContext; + +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants; + +/** + * The Class MetaContextDestroyer. + */ +public class MetaContextDestroyer +implements +DASConstants, +AttributeTypeConstants +{ + /** + * Destroys an empty meta context + * + * @param initialContext the initial context + * + * @throws NamingException the naming exception thrown when the meta context has child entries + */ + public static void destroy( + DirContext initialContext) + throws NamingException + { + String rdn = + CN + "=" + META_CONTEXT_NAME; + + initialContext. + destroySubcontext( rdn ); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/Context.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/Context.java new file mode 100644 index 0000000000..31d6d8d11e --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/Context.java @@ -0,0 +1,81 @@ + +package org.apache.tuscany.das.ldap.emf; + +import java.util.Hashtable; +import java.util.Map; + +import javax.naming.ldap.LdapContext; + +import org.eclipse.emf.ecore.sdo.EDataObject; + +public class Context +{ + private Map<String, LdapContext> xsdNamespaceToLdapContextMap = null; + private Map<EDataObject, String> dataObjectToRelativeDNCache = null; + + + private LdapContext dasContext = null; + private LdapContext schemaContext = null; + private LdapContext dasMetaContext = null; + private LdapContext ecoreObjectClassesContext = null; + private LdapContext ecoreAttributeTypesContext = null; + + public Context() + { + xsdNamespaceToLdapContextMap = + new Hashtable<String, LdapContext>(); + + dataObjectToRelativeDNCache = + new Hashtable<EDataObject, String>(); + } + + public LdapContext getDasContext() + { + return dasContext; + } + public void setDasContext( LdapContext dasContext ) + { + this.dasContext = dasContext; + } + public LdapContext getSchemaContext() + { + return schemaContext; + } + public void setSchemaContext( LdapContext schemaContext ) + { + this.schemaContext = schemaContext; + } + public LdapContext getDasMetaContext() + { + return dasMetaContext; + } + public void setDasMetaContext( LdapContext dasMetaContext ) + { + this.dasMetaContext = dasMetaContext; + } + public LdapContext getEcoreObjectClassesContext() + { + return ecoreObjectClassesContext; + } + public void setEcoreObjectClassesContext( LdapContext ecoreObjectClassesContext ) + { + this.ecoreObjectClassesContext = ecoreObjectClassesContext; + } + public LdapContext getEcoreAttributeTypesContext() + { + return ecoreAttributeTypesContext; + } + public void setEcoreAttributeTypesContext( LdapContext ecoreAttributeTypesContext ) + { + this.ecoreAttributeTypesContext = ecoreAttributeTypesContext; + } + public Map<String, LdapContext> getXsdNamespaceToLdapContextMap() + { + return xsdNamespaceToLdapContextMap; + } + + public Map<EDataObject, String> getDataObjectToRelativeDNCache() + { + return dataObjectToRelativeDNCache; + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/LdapDAS.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/LdapDAS.java new file mode 100644 index 0000000000..43e556714f --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/LdapDAS.java @@ -0,0 +1,379 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.emf; + +import java.util.Hashtable; +import java.util.List; +import java.util.Map; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException; +import org.apache.tuscany.das.ldap.connect.ADSEmbeddedConnection; +import org.apache.tuscany.das.ldap.connect.JNDIConnection; +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.create.InitialContextCreator; +import org.apache.tuscany.das.ldap.create.MetaContextCreator; +import org.apache.tuscany.das.ldap.emf.create.EDataGraphCreator; +import org.apache.tuscany.das.ldap.emf.read.EDataGraphReader; +import org.apache.tuscany.das.ldap.emf.update.EDataGraphUpdater; +import org.apache.tuscany.das.ldap.schema.emf.create.EcoreTypeSystemHelper; +import org.apache.tuscany.das.ldap.schema.emf.create.ModelTypeSystemCreator; +import org.apache.tuscany.model.Configuration; +import org.apache.tuscany.model.DASMeta; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.sdo.EDataGraph; +import org.eclipse.emf.ecore.sdo.EDataObject; + +public class LdapDAS +implements DASConstants +{ + private Map<EDataObject, String> metaDataObjectToRelativeDNCache = null; + + private Configuration configuration = null; + private DASMeta dasMeta = null; + private EDataGraph dasMetaDataGraph = null; + private Context context = null; + private ADSEmbeddedConnection adsEmbeddedConnection = null; + + + public LdapDAS(Configuration configuration) + throws NamingException + { + metaDataObjectToRelativeDNCache = + new Hashtable<EDataObject, String>(); + + + this.configuration = + configuration; + + context = + new Context(); + + JNDIConnection jndiConnection = null; + + if (configuration.isEmbedded()) + { + adsEmbeddedConnection = + new ADSEmbeddedConnection(configuration); + context. + setDasContext( + adsEmbeddedConnection. + connect( + configuration. + getDasPartitionName() )); + + context. + setSchemaContext( + adsEmbeddedConnection. + connect( + configuration. + getSchemaPartitionName() )); + } + else + { + jndiConnection = + new JNDIConnection(configuration); + + context. + setDasContext( + jndiConnection.connect( + configuration. + getDasPartitionName() )); + + context. + setSchemaContext( + jndiConnection.connect( + configuration. + getSchemaPartitionName() )); + } + + context. + setDasMetaContext( + MetaContextCreator. + create( + context. + getDasContext() )); + + context.setEcoreObjectClassesContext( + LdapDASHelper. + createEcoreObjectClassesContext( + context. + getSchemaContext() )); + + context.setEcoreAttributeTypesContext( + LdapDASHelper. + createEcoreAttributeTypesContext( + context. + getSchemaContext() )); + } + + /** + * Write. + * + * @param eDataGraph the e data graph + * @param dasContext the das context + * + * @return the map< E data object, string> + * + * @throws NamingException the naming exception + * + * First tries to find a LdapContext that matches the xsdNamespace + * of the DataGraph that is about to be written. If it finds one, then + * it know that the type system has been written, thus it can skip this + * step. + * + * If the LdapContext lookup fails, the type system may still exist + * the check: + * + * configuration.getSupportedSchemas().contains(xsdNamespace) + * + * is performed. + * + * If the supported schema list contains the xsdNamespace, the + * corresponding the LdapContext parent context of the root DataObject + * instance is created and the DataGraph written. + * + * If the xsdNamespace is not contained by the supported schemas list, + * a final check is performed to see whether the type system exists. If this + * check succeeds and exception is thrown, because it should not. This could happen + * if the configuration write that occurs as the supported schema list is updated failed, + * or the the read of the supported schemas from the DIT failed. + * + */ + public void create( + EDataGraph eDataGraph) + throws NamingException, Exception + { + + EObject rootEObject = + eDataGraph. + getERootObject(); + + EPackage ePackage = + rootEObject. + eClass(). + getEPackage(); + + String xsdNamespace = + ePackage. + getNsURI(); + + LdapContext rootContext = + context. + getXsdNamespaceToLdapContextMap(). + get(xsdNamespace); + + if (rootContext != null) + { + EDataGraphCreator.create( + eDataGraph, + rootContext, + context. + getDataObjectToRelativeDNCache()); + } + + /* + * The root context was not yet created so we check if the + * schema is written for the model instance, and if it is + * we create the root context and add it to the context map. + */ + metaDataObjectToRelativeDNCache = + new Hashtable<EDataObject, String>(); + + dasMetaDataGraph = + LdapDASHelper.readDasMeta( + context, + metaDataObjectToRelativeDNCache ); + + dasMeta = ( DASMeta ) dasMetaDataGraph.getRootObject(); + + if (LdapDASHelper.isSchemaReady(xsdNamespace, dasMeta)) + { + rootContext = + InitialContextCreator. + create( + xsdNamespace, + context. + getDasContext() ); + + context.getXsdNamespaceToLdapContextMap(). + put(xsdNamespace, rootContext); + + EDataGraphCreator.create( + eDataGraph, + rootContext, + context.getDataObjectToRelativeDNCache()); + } + + /* + * The model's schema is not yet written (We also do a validation + * check to make sure the server is not in an inconsistent state) + * so we need to write the schema and then write the model instance. + */ + + if (LdapDASHelper.isSchemaWritten( + rootEObject.eClass(), + context. + getEcoreObjectClassesContext() )) + { + throw new RuntimeException("This should not happen");//TODO better message + constant + } + + List<EClass> eClassifiers = + EcoreTypeSystemHelper. + createEClassifiersList(ePackage); + + rootContext = + InitialContextCreator. + create( + xsdNamespace, + context.getDasContext() ); + + context.getXsdNamespaceToLdapContextMap(). + put(xsdNamespace, rootContext); + + LdapContext dasModelMetaContext = + MetaContextCreator. + create(rootContext); + + ModelTypeSystemCreator.create( + dasModelMetaContext, + context.getEcoreAttributeTypesContext(), + context.getEcoreObjectClassesContext(), + eClassifiers, + TUSCANY_OID_PREFIX_VALUE); + + dasMetaDataGraph. + getChangeSummary(). + beginLogging(); + + dasMeta. + getSupportedSchemas(). + add(xsdNamespace); + + dasMetaDataGraph. + getChangeSummary(). + endLogging(); + + EDataGraphUpdater.update( + dasMetaDataGraph, + context.getDasMetaContext(), + metaDataObjectToRelativeDNCache); + + EDataGraphCreator.create( + eDataGraph, + rootContext, + context. + getDataObjectToRelativeDNCache()); + + } + + + public EDataGraph read( + EClass rootDataObjectEClass, + String id) + throws LdapNameNotFoundException, NamingException + { + String xsdNamespace = + rootDataObjectEClass. + getEPackage(). + getNsURI(); + + LdapContext rootContext = + context. + getXsdNamespaceToLdapContextMap(). + get(xsdNamespace); + + if (rootContext == null) + { + rootContext = + InitialContextCreator. + create( + xsdNamespace, + context. + getDasContext() ); + + context. + getXsdNamespaceToLdapContextMap(). + put(xsdNamespace, rootContext); + } + + return EDataGraphReader.read( + rootDataObjectEClass, + id, + rootContext, + context. + getDataObjectToRelativeDNCache()); + } + + public void update(EDataGraph eDataGraph) + throws NamingException + { + EDataObject rootDataObject = + ( EDataObject ) eDataGraph.getRootObject(); + + EClass rootDataObjectEClass = + rootDataObject.eClass(); + + String xsdNamespace = + rootDataObjectEClass. + getEPackage(). + getNsURI(); + + LdapContext rootContext = + context. + getXsdNamespaceToLdapContextMap(). + get(xsdNamespace); + + if (rootContext == null) + { + rootContext = + InitialContextCreator. + create( + xsdNamespace, + context. + getDasContext() ); + + context. + getXsdNamespaceToLdapContextMap(). + put(xsdNamespace, rootContext); + } + + EDataGraphUpdater.update( + eDataGraph, + rootContext, + context. + getDataObjectToRelativeDNCache()); + } + + public Context getContext() + { + return context; + } + + public ADSEmbeddedConnection getAdsEmbeddedConnection() + { + return adsEmbeddedConnection; + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/LdapDASHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/LdapDASHelper.java new file mode 100644 index 0000000000..d9d2f9a0bd --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/LdapDASHelper.java @@ -0,0 +1,295 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.emf; + +import java.util.List; +import java.util.Map; + +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.emf.create.EDataGraphCreator; +import org.apache.tuscany.das.ldap.emf.read.EDataGraphReader; +import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants; +import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants; +import org.apache.tuscany.das.ldap.schema.constants.SchemaObjectClassConstants; +import org.apache.tuscany.das.ldap.schema.create.ComplexTypeRDNCreator; +import org.apache.tuscany.das.ldap.schema.emf.create.EcoreTypeSystemHelper; +import org.apache.tuscany.das.ldap.schema.emf.create.ModelTypeSystemCreator; +import org.apache.tuscany.model.ConfigurationFactory; +import org.apache.tuscany.model.DASMeta; +import org.apache.tuscany.model.impl.ConfigurationPackageImpl; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.sdo.EDataGraph; +import org.eclipse.emf.ecore.sdo.EDataObject; +import org.eclipse.emf.ecore.sdo.SDOFactory; + +public class LdapDASHelper +implements +DASConstants, +ObjectClassConstants, +AttributeTypeConstants, +SchemaObjectClassConstants +{ + public static EDataGraph readDasMeta( + Context context, + Map<EDataObject, String> metaDataObjectToRelativeDNCache) + throws Exception + { + EDataGraph dasMetaDataGraph = null; + + try + { + dasMetaDataGraph = + EDataGraphReader.read( + ConfigurationPackageImpl. + eINSTANCE.getDASMeta(), + DAS_META_ID_DEFAULT, + context. + getDasMetaContext(), + metaDataObjectToRelativeDNCache); + } + catch(NamingException e) + { + List<EClass> eClassifiers = + EcoreTypeSystemHelper. + createEClassifiersList( + ConfigurationPackageImpl. + eINSTANCE); + + ModelTypeSystemCreator. + create( + context.getDasMetaContext(), + context.getEcoreAttributeTypesContext(), + context.getEcoreObjectClassesContext(), + eClassifiers, + TUSCANY_OID_PREFIX_VALUE ); + + DASMeta dasMeta = + ConfigurationFactory. + INSTANCE. + createDASMeta(); + + dasMetaDataGraph = + SDOFactory. + eINSTANCE. + createEDataGraph(); + + dasMetaDataGraph. + setERootObject( + ( EObject ) dasMeta ); + + EDataGraphCreator.create( + dasMetaDataGraph, + context. + getDasMetaContext(), + metaDataObjectToRelativeDNCache); + } + return dasMetaDataGraph; + } + + public static boolean isSchemaReady( + String xsdNamespace, + DASMeta dasMeta) + { + return + dasMeta. + getSupportedSchemas(). + contains(xsdNamespace); + } + + public static boolean isSchemaWritten( + EClass eClass, + LdapContext ecoreObjectClassesContext) + throws Exception + { + String xsdNamespace = + eClass.getEPackage().getNsURI(); + + String eObjectClassRDN = + ComplexTypeRDNCreator. + create( + TUSCANY_OID_PREFIX_VALUE, + xsdNamespace, + eClass.getName()); + try { + ecoreObjectClassesContext. + lookup( eObjectClassRDN ); + } + catch (Exception e) + { + return false; + } + return true; + } + + + public static boolean isSchemaSupported( + String xsdNamespaceURI, + DASMeta dasMeta) + { + return + dasMeta. + getSupportedSchemas(). + contains(xsdNamespaceURI); + } + + public static void initializeSchemaContexts( + LdapContext schemaContext, + LdapContext ecoreObjectClassesContext, + LdapContext ecoreAttributeTypesContext) + throws NamingException + { + LdapContext ecoreContext = + createEcoreContext(schemaContext); + + ecoreObjectClassesContext = + createEcoreObjectClassesContext(ecoreContext); + + ecoreAttributeTypesContext = + createEcoreAttributeTypesContext( ecoreContext ); + } + + + public static LdapContext createEcoreContext( + LdapContext schemaContext) + throws NamingException + { + String ecoreContextRDN = + CN + "=" + ECORE_CONTEXT_NAME; + + try + { + return ( LdapContext ) schemaContext.lookup( ecoreContextRDN ); + } + catch (Exception e) + { + //Create the context + } + + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(META_SCHEMA); + + contextAttributes.put( objectClassAttribute ); + contextAttributes.put( CN, ECORE_CONTEXT_NAME ); + + return + ( LdapContext ) + schemaContext. + createSubcontext( + ecoreContextRDN, + contextAttributes ); + } + + public static LdapContext createEcoreObjectClassesContext( + LdapContext schemaContext) + throws NamingException + { + LdapContext ecoreContext = + createEcoreContext(schemaContext); + + String ecoreObjectClassesContextRDN = + OU + "=" + OBJECT_CLASSES_CONTEXT_NAME; + + try + { + return + ( LdapContext ) + ecoreContext. + lookup( + ecoreObjectClassesContextRDN ); + } + catch (Exception e) + { + //Create the context + } + + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + OBJECT_CLASSES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return + ( LdapContext ) + ecoreContext. + createSubcontext( + ecoreObjectClassesContextRDN, + contextAttributes ); + } + + public static LdapContext createEcoreAttributeTypesContext( + LdapContext schemaContext) + throws NamingException + { + LdapContext ecoreContext = + createEcoreContext(schemaContext); + + String ecoreAttributeTypesContextRDN = + OU + "=" + ATTRIBUTE_TYPES_CONTEXT_NAME; + + try + { + return + ( LdapContext ) + ecoreContext. + lookup( + ecoreAttributeTypesContextRDN ); + } + catch (Exception e) + { + //Create the context + } + + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + contextAttributes.put( OU, ATTRIBUTE_TYPES_CONTEXT_NAME ); + contextAttributes.put( objectClassAttribute ); + + return + ( LdapContext ) + ecoreContext.createSubcontext( + ecoreAttributeTypesContextRDN, + contextAttributes ); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataGraphCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataGraphCreator.java new file mode 100644 index 0000000000..bfba12d3b5 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataGraphCreator.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.emf.create; + +import java.util.Map; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.sdo.EDataGraph; +import org.eclipse.emf.ecore.sdo.EDataObject; + +public class EDataGraphCreator +implements AttributeTypeConstants +{ + public static void create( + EDataGraph eDataGraph, + LdapContext rootContext, + Map<EDataObject, String> dataObjectToRelativeDNCache) + throws NamingException + { + EDataObject rootDataObject = + (EDataObject) + eDataGraph.getRootObject(); + + EDataObjectCreator.create( + rootDataObject, + rootContext, + dataObjectToRelativeDNCache); + + EList<EObject> children = + rootDataObject.eContents(); + + if (children.size() > 0) + { + EDataGraphCreatorHelper.createChildren( + children, + rootContext, + dataObjectToRelativeDNCache); + } + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataGraphCreatorHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataGraphCreatorHelper.java new file mode 100644 index 0000000000..ab1209224a --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataGraphCreatorHelper.java @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.emf.create; + +import java.util.Map; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.sdo.EDataObject; + +public class EDataGraphCreatorHelper +implements AttributeTypeConstants +{ + /* + * TODO Make mutlithreaded + */ + public static void createChildren( + EList<EObject> children, + LdapContext rootContext, + Map<EDataObject, String> dataObjectToRelativeDNCache) + throws NamingException + { + LdapContext eContainmentFeatureContext = + null; + + for (EObject eObject : children) + { + String parentContextRDN = + dataObjectToRelativeDNCache.get(eObject.eContainer()); + + LdapContext parentContext = + (LdapContext) + rootContext. + lookup(parentContextRDN); + + EStructuralFeature eContainmentFeature = + eObject.eContainingFeature(); + + String eContainingFeatureContextName = + CN + "="+ eContainmentFeature.getName(); + + try + { + eContainmentFeatureContext = + (LdapContext) + parentContext.lookup( + eContainingFeatureContextName); + } + catch (Exception e) + { + eContainmentFeatureContext = + (LdapContext) + parentContext. + createSubcontext( + eContainingFeatureContextName); + } + + EDataObjectCreator.create(( + EDataObject) eObject, + eContainmentFeatureContext, + dataObjectToRelativeDNCache); + + children = + eObject.eContents(); + + if ( children.size()> 0) + { + createChildren( + children, + rootContext, + dataObjectToRelativeDNCache); + } + } + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataObjectCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataObjectCreator.java new file mode 100644 index 0000000000..5d79d40fb5 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataObjectCreator.java @@ -0,0 +1,137 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.emf.create; + +import java.util.Map; + +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.util.ComplexTypeNamespaceQualifier; +import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer; +import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.sdo.EDataObject; + +public class EDataObjectCreator +implements DASConstants +{ + /** + * Create the LDAP entry for the EDataObject argument + * + * @param eDataObject the e data object + * @param containerContext the container context + * + * @throws NamingException the naming exception + */ + public static void create( + EDataObject eDataObject, + LdapContext containerContext, + Map<EDataObject, String> dataObjectToRelativeDNCache) + throws NamingException + { + String rdn = + null; + Object dataObjectID = + null; + + EClass eClass = + eDataObject.eClass(); + + EAttribute idEAttribute = + eClass.getEIDAttribute(); + + String namespaceURI = + eClass.getEPackage().getNsURI(); + + String qualifiedEAttributeName = + null; + String normalizedEAttributeName = + null; + + Attributes attributes = + new BasicAttributes(); + + attributes = + EDataObjectCreatorHelper.processEAttributes( + attributes, + eDataObject, + eClass, + namespaceURI); + + attributes = + EDataObjectCreatorHelper.processEReferences( + attributes, + eDataObject, + eClass, + namespaceURI); + + String qualifiedEClassName = + ComplexTypeNamespaceQualifier. + qualify( + namespaceURI, + eClass.getName() ); + + String normalizedEClassName = + QualifiedNameNormalizer. + normalize(qualifiedEClassName); + + Attribute objectClassAttribute = + new BasicAttribute("objectClass"); + + objectClassAttribute. + add(normalizedEClassName); + + attributes.put(objectClassAttribute); + + dataObjectID = + eDataObject.eGet(idEAttribute ); + + qualifiedEAttributeName = + SimpleTypeNamespaceQualifier. + qualify( + namespaceURI, + eClass.getName(), + idEAttribute.getName() ); + + normalizedEAttributeName = + QualifiedNameNormalizer. + normalize(qualifiedEAttributeName); + + rdn = + normalizedEAttributeName + "=" + dataObjectID; + + containerContext.createSubcontext( + rdn, + attributes ); + + EDataObjectCreatorHelper. + updateDataObjectToRelativeDNCache( + eDataObject, + dataObjectToRelativeDNCache, + rdn); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataObjectCreatorHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataObjectCreatorHelper.java new file mode 100644 index 0000000000..90ec5701ad --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/create/EDataObjectCreatorHelper.java @@ -0,0 +1,284 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.emf.create; + +import java.util.List; +import java.util.Map; + +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; + +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer; +import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.sdo.EDataObject; + +public class EDataObjectCreatorHelper +implements DASConstants +{ + + public static void updateDataObjectToRelativeDNCache( + EDataObject eDataObject, + Map<EDataObject, String> dataObjectToRelativeDNCache, + String rdn) + { + EDataObject parentDataObject = + (EDataObject) eDataObject.eContainer(); + + if (parentDataObject !=null) + { + String parentRDN = + dataObjectToRelativeDNCache. + get(parentDataObject); + rdn = + rdn + + "," + + "cn=" + + eDataObject.eContainingFeature().getName() + + "," + + parentRDN; + dataObjectToRelativeDNCache.put(eDataObject, rdn); + } + else + { + dataObjectToRelativeDNCache.put(eDataObject, rdn); + } + } + + + /** + * Process EAttributes adding the normalized EAttribute instance's + * name and corresponding values to the attributes argument. + * + * @param attributes the attributes + * @param eDataObject the e data object + * @param eClass the e class + * @param namespaceURI the namespace URI + * + * @return the attributes + * + * @throws NamingException the naming exception + * + * Note that ApacheDS supports the Syntaxes (DataTypes) + * Boolean, Integer, String. This means that all values that + * are not Boolean or Integer are stored as Strings. + */ + public static Attributes processEAttributes( + Attributes attributes, + EDataObject eDataObject, + EClass eClass, + String namespaceURI) + throws NamingException + { + EcorePackage ecorePackage = + EcorePackage.eINSTANCE; + + EAttribute idEAttribute = + eClass.getEIDAttribute(); + + List<EAttribute> eAttributes = + eClass.getEAllAttributes(); + + String qualifiedEAttributeName = + null; + String normalizedEAttributeName = + null; + + for (EAttribute eAttribute : eAttributes) + { + Attribute attribute = + processEAttribute( + eAttribute, + namespaceURI, + eClass, eDataObject); + attributes.put(attribute); + } + return attributes; + } + + /* + * TODO This is also used in updates so consider moving to a utility + */ + public static Attribute processEAttribute( + EAttribute eAttribute, + String namespaceURI, + EClass eClass, + EDataObject eDataObject) + { + String qualifiedEAttributeName = + SimpleTypeNamespaceQualifier. + qualify( + namespaceURI, + eClass.getName(), + eAttribute.getName() ); + + String normalizedEAttributeName = + QualifiedNameNormalizer. + normalize(qualifiedEAttributeName); + + Attribute attribute = + new BasicAttribute(normalizedEAttributeName); + + if (eAttribute.isMany()) + { + if ( !(eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() || + eAttribute.getEType() == EcorePackage.eINSTANCE.getEBooleanObject() ) ) + { + EList<Object> eAttributeValues = + ( EList<Object> ) eDataObject.eGet( eAttribute ); + + for (Object eAttributeValue : eAttributeValues) + { + attribute.add(eAttributeValue.toString() ); + } + } + else + { + EList<Boolean> eAttributeValues = + ( EList<Boolean> ) eDataObject.eGet( eAttribute ); + + for (Boolean eAttributeValue : eAttributeValues) + { + if (eAttributeValue == false) + { + attribute.add(Boolean.FALSE.toString().toUpperCase() ); + } + else + { + attribute.add(Boolean.TRUE.toString().toUpperCase() ); + } + } + } + return attribute; + } + + if ( !(eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() || + eAttribute.getEType() == EcorePackage.eINSTANCE.getEBooleanObject() ) ) + { + Object eAttributeValue = + eDataObject.eGet( eAttribute ); + + attribute.add(eAttributeValue.toString() ); + } + else + { + Boolean eAttributeValue = + (Boolean) eDataObject.eGet( eAttribute ); + + if (eAttributeValue == false) + { + attribute.add(Boolean.FALSE.toString().toUpperCase() ); + } + else + { + attribute.add(Boolean.TRUE.toString().toUpperCase() ); + } + } + return attribute; + } + + /** + * Process references adding the normalized EReference instance's + * name and corresponding id (IDs for multiplicity many references) + * to the attributes argument. + * + * @param attributes the attributes + * @param eDataObject the e data object + * @param eClass the e class + * @param namespaceURI the namespace URI + * + * @return the attributes + */ + public static Attributes processEReferences( + Attributes attributes, + EDataObject eDataObject, + EClass eClass, + String namespaceURI) + { + List<EReference> eReferences = + eClass.getEAllReferences(); + + for (EReference eReference : eReferences) + { + String qualifiedEReferenceName = + SimpleTypeNamespaceQualifier. + qualify( + namespaceURI, + eClass.getName(), + eReference.getName() ); + + String normalizedEReferenceName = + QualifiedNameNormalizer. + normalize(qualifiedEReferenceName); + + if (eReference.isMany()) + { + List<EDataObject> referencedEDataObjects = + (List<EDataObject>) eDataObject.eGet(eReference); + + Attribute idAttribute = + new BasicAttribute(normalizedEReferenceName); + + for (EDataObject containedEDataObject : referencedEDataObjects) + { + EClass containedEDataObjectEClass = + containedEDataObject.eClass(); + + String containedEDataObjectID = + (String) containedEDataObject.eGet( + containedEDataObjectEClass. + getEIDAttribute()); + + idAttribute.add(containedEDataObjectID); + } + attributes.put(idAttribute); + } + else + { + EDataObject containedEDataObject = + (EDataObject) + eDataObject.eGet(eReference); + + if (containedEDataObject != null) + { + EClass containedEDataObjectEClass = + containedEDataObject.eClass(); + + String containedEDataObjectID = + (String) containedEDataObject.eGet( + containedEDataObjectEClass. + getEIDAttribute()); + + attributes.put( + normalizedEReferenceName, + containedEDataObjectID); + } + } + } + return attributes; + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReader.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReader.java new file mode 100644 index 0000000000..9add9b7677 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReader.java @@ -0,0 +1,131 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.emf.read; + +import java.util.Hashtable; +import java.util.List; +import java.util.Map; + +import javax.naming.NamingException; +import javax.naming.directory.Attributes; +import javax.naming.ldap.LdapContext; + +import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException; +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer; +import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.sdo.EDataGraph; +import org.eclipse.emf.ecore.sdo.EDataObject; +import org.eclipse.emf.ecore.sdo.SDOFactory; + +public class EDataGraphReader +implements DASConstants +{ + public static EDataGraph read( + EClass rootDataObjectEClass, + String id, + LdapContext rootContext, + Map<EDataObject, String> dataObjectToRelativeDNCache) + throws NamingException, LdapNameNotFoundException + { + EDataGraph eDataGraph = + SDOFactory.eINSTANCE.createEDataGraph(); + + String namespaceURI = + rootDataObjectEClass.getEPackage(). + getNsURI(); + + EAttribute idEAttribute = + rootDataObjectEClass.getEIDAttribute(); + + String qualifiedIDEAttributeName = + SimpleTypeNamespaceQualifier. + qualify( + namespaceURI, + rootDataObjectEClass.getName(), + idEAttribute.getName() ); + + String normalizedIDEAttributeName = + QualifiedNameNormalizer. + normalize(qualifiedIDEAttributeName); + + String eDataObjectRDN = + normalizedIDEAttributeName + "=" + id; + + LdapContext eDataObjectContext = + (LdapContext) + rootContext. + lookup(eDataObjectRDN); + + Attributes attributes = + rootContext. + getAttributes(eDataObjectRDN); + + Map<EDataObject, Map<EStructuralFeature, List<String>>> crossReferenceIDCache = + new Hashtable<EDataObject, Map<EStructuralFeature, List<String>>>(); + + EDataObject rootDataObject = + EDataGraphReaderHelper. + restoreEDataObject( + crossReferenceIDCache, + rootDataObjectEClass, + namespaceURI, + attributes); + + String relativeDN = + EDataGraphReaderHelper.calculateRelativeDN( + rootContext, + eDataObjectContext); + + dataObjectToRelativeDNCache. + put(rootDataObject, relativeDN); + + List<EReference> eReferences = + rootDataObjectEClass.getEAllContainments(); + + if (rootDataObjectEClass.getEAllContainments().size() > 0) + { + EDataGraphReaderHelper. + addContainmentDataObjects( + crossReferenceIDCache, + dataObjectToRelativeDNCache, + rootDataObject, + attributes, + namespaceURI, + eDataObjectContext, + rootContext); + } + + eDataGraph.setERootObject(rootDataObject); + + Resource resource = eDataGraph.getRootResource(); + + EDataGraphReaderHelper.restoreCrossReferences( + crossReferenceIDCache, + resource); + + return eDataGraph; + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReaderHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReaderHelper.java new file mode 100644 index 0000000000..1496d91dab --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReaderHelper.java @@ -0,0 +1,365 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.emf.read; + +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; + +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer; +import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier; +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.impl.EClassImpl; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.sdo.EDataObject; + +public class EDataGraphReaderHelper +implements DASConstants +{ + public static String calculateRelativeDN( + LdapContext containerContext, + LdapContext dataObjectContext) throws NamingException + { + String containerDN = containerContext.getNameInNamespace(); + String dataObjectDN = dataObjectContext.getNameInNamespace(); + + int beginIndex = 0; + int endIndex = + dataObjectDN.length() - containerDN.length() - 1; + + String result = + dataObjectDN.substring( + beginIndex, + endIndex); + + return result; + } + + + public static EDataObject restoreEDataObject( + Map<EDataObject, Map<EStructuralFeature, List<String>>> crossReferenceIDCache, + EClass eClass, + String namespaceURI, + Attributes attributes) + throws NamingException + { + EDataObject eDataObject = + (EDataObject) + eClass.getEPackage(). + getEFactoryInstance(). + create(eClass); + + EDataObjectReaderHelper. + restoreEAttributes( + eClass, + eDataObject, + namespaceURI, + attributes ); + + EStructuralFeature[] eCrossReferences = + ((EClassImpl.FeatureSubsetSupplier) + eDataObject. + eClass(). + getEAllStructuralFeatures()). + crossReferences(); + + if (eCrossReferences != null) + { + Map<EStructuralFeature, List<String>> eReferenceToEObjectIDs = + new Hashtable<EStructuralFeature, List<String>>(); + + for (EStructuralFeature eReference : eCrossReferences) + { + String qualifiedEReferenceName = + SimpleTypeNamespaceQualifier. + qualify( + namespaceURI, + eClass.getName(), + eReference.getName() ); + + String normalizedEReferenceName = + QualifiedNameNormalizer. + normalize(qualifiedEReferenceName); + + if (eReference.isMany()) + { + List<String> idList = + new ArrayList<String>(); + + Attribute eReferenceAttribute = + attributes.get(normalizedEReferenceName); + + NamingEnumeration namingEnumeration = + eReferenceAttribute.getAll(); + + while (namingEnumeration.hasMore()) + { + String id = (String) namingEnumeration.next(); + idList.add(id); + eReferenceToEObjectIDs.put(eReference, idList); + } + } + else + { + List<String> idList = + new ArrayList<String>(); + + String value = + (String) + attributes. + get(normalizedEReferenceName). + get(); + + idList.add(value); + eReferenceToEObjectIDs.put(eReference, idList); + } + crossReferenceIDCache.put( + eDataObject, + eReferenceToEObjectIDs); + } + } + return eDataObject; + } + + public static void restoreCrossReferences( + Map<EDataObject, Map<EStructuralFeature, List<String>>> crossReferenceIDCache, + Resource resource) + { + for (EDataObject eDataObject : crossReferenceIDCache.keySet()) + { + Map<EStructuralFeature, List<String>> eReferenceToIDListMap = + crossReferenceIDCache.get(eDataObject); + + for (EStructuralFeature eStructuralFeature : eReferenceToIDListMap.keySet()) + { + if (eStructuralFeature.isMany()) + { + List<String> eReferenceIDs = + eReferenceToIDListMap. + get(eStructuralFeature); + + EList<EDataObject> multiplicityManyList = null; + if (eReferenceIDs.size() > 0) + { + multiplicityManyList = + new BasicEList<EDataObject>(); + } + for (String eReferenceID : eReferenceIDs) + { + Object referencedDataObject = resource.getEObject(eReferenceID); + multiplicityManyList.add((EDataObject) referencedDataObject); + eDataObject.eSet( + eStructuralFeature, + multiplicityManyList); + } + } + else + { + String eReferenceID = + eReferenceToIDListMap. + get(eStructuralFeature). + get(0); + + Object referencedDataObject = resource.getEObject(eReferenceID); + eDataObject.eSet( + eStructuralFeature, + referencedDataObject); + } + } + } + } + + public static void addContainmentDataObjects( + Map crossReferenceIDCache, + Map<EDataObject, String> dataObjectToRelativeDNCache, + EDataObject containerDataObject, + Attributes attributes, + String namespaceURI, + LdapContext eDataObjectContext, + LdapContext rootContext) throws NamingException + { + EClass eClass = + containerDataObject.eClass(); + + List<EReference> eReferences = + eClass.getEAllContainments(); + + for (EReference eReference : eReferences) + { + String qualifiedEReferenceName = + SimpleTypeNamespaceQualifier. + qualify( + namespaceURI, + eClass.getName(), + eReference.getName() ); + + String normalizedReferenceName = + QualifiedNameNormalizer. + normalize(qualifiedEReferenceName); + + Attribute attribute = + attributes. + get(normalizedReferenceName); + + if (attribute.size() > 0) + { + LdapContext eReferenceContainmentContext = + (LdapContext) + eDataObjectContext. + lookup("cn=" + eReference.getName()); + + EClass eReferenceType = + (EClass) eReference.getEType(); + + EAttribute eReferenceTypeEIDAttribute = + eReferenceType.getEIDAttribute(); + + String qualifiedEReferenceTypeIDEAttributeName = + SimpleTypeNamespaceQualifier. + qualify( + namespaceURI, + eReferenceType.getName(), + eReferenceTypeEIDAttribute.getName() ); + + String normalizedReferenceTypeEIDAttributeName = + QualifiedNameNormalizer. + normalize(qualifiedEReferenceTypeIDEAttributeName); + + if (eReference.isMany()) + { + EList<EDataObject> containmentList = + new BasicEList<EDataObject>(); + + NamingEnumeration idNamingEnumeration = + attribute.getAll(); + + while(idNamingEnumeration.hasMore()) + { + String containedDataObjectID = + (String) idNamingEnumeration.next(); + + String containedDataObjectEntryRDN = + normalizedReferenceTypeEIDAttributeName + + "=" + containedDataObjectID; + + Attributes eReferenceAttributes = + eReferenceContainmentContext. + getAttributes(containedDataObjectEntryRDN); + + + EDataObject eReferenceDataObject = + EDataGraphReaderHelper. + restoreEDataObject( + crossReferenceIDCache, + eReferenceType, + namespaceURI, + eReferenceAttributes); + + //TODO Consider using aspects + String relativeDN = + calculateRelativeDN( + rootContext, + (LdapContext) + eReferenceContainmentContext. + lookup(containedDataObjectEntryRDN)); + dataObjectToRelativeDNCache.put(eReferenceDataObject, relativeDN); + //End of Aspect + + containmentList.add(eReferenceDataObject); + + if (eReferenceDataObject.eClass().getEAllContainments().size() > 0) + { + addContainmentDataObjects( + crossReferenceIDCache, + dataObjectToRelativeDNCache, + eReferenceDataObject, + eReferenceAttributes, + namespaceURI, + (LdapContext) eReferenceContainmentContext. + lookup(containedDataObjectEntryRDN), + rootContext); + } + } + containerDataObject.eSet(eReference, containmentList); + } + else + { + String containedDataObjectID = + (String) attribute.get(); + + String containedDataObjectEntryRDN = + normalizedReferenceTypeEIDAttributeName + + "=" + containedDataObjectID; + + Attributes eReferenceAttributes = + eReferenceContainmentContext. + getAttributes(containedDataObjectEntryRDN); + + EDataObject eReferenceDataObject = + EDataGraphReaderHelper. + restoreEDataObject( + crossReferenceIDCache, + eReferenceType, + namespaceURI, + eReferenceAttributes); + + //TODO Consider using aspects + String relativeDN = + calculateRelativeDN( + rootContext, + (LdapContext) + eReferenceContainmentContext. + lookup(containedDataObjectEntryRDN)); + + dataObjectToRelativeDNCache.put(eReferenceDataObject, relativeDN); + //End of Aspect + + containerDataObject.eSet(eReference, eReferenceDataObject); + + if (eReferenceDataObject.eClass().getEAllContainments().size() > 0) + { + addContainmentDataObjects( + crossReferenceIDCache, + dataObjectToRelativeDNCache, + eReferenceDataObject, + eReferenceAttributes, + namespaceURI, + (LdapContext) eReferenceContainmentContext. + lookup(containedDataObjectEntryRDN), + rootContext); + } + } + } + } + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReader.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReader.java new file mode 100644 index 0000000000..0c812f4bfc --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReader.java @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.emf.read; + +import javax.naming.NamingException; +import javax.naming.directory.Attributes; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer; +import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.sdo.EDataObject; + +public class EDataObjectReader +implements DASConstants +{ + /** + * Read. + * + * @param eClass the e class + * @param id the id + * @param containerContext the container context + * + * @return the e data object + * + * @throws NamingException the naming exception + * + * Note that this is more of a utility, as only this class's + * helper is used in restoring the EDataGraph. + */ + public static EDataObject read( + EClass eClass, + String id, + LdapContext containerContext) + throws NamingException + { + String namespaceURI = + eClass.getEPackage(). + getNsURI(); + + EAttribute idEAttribute = + eClass.getEIDAttribute(); + + String qualifiedIDEAttributeName = + SimpleTypeNamespaceQualifier. + qualify( + namespaceURI, + eClass.getName(), + idEAttribute.getName() ); + + String normalizedIDEAttributeName = + QualifiedNameNormalizer. + normalize(qualifiedIDEAttributeName); + + String eDataObjectRDN = + normalizedIDEAttributeName + "=" + id; + + LdapContext eDataObjectContext = + (LdapContext) + containerContext. + lookup(eDataObjectRDN); + + Attributes attributes = + eDataObjectContext.getAttributes(""); + + EDataObject eDataObject = + (EDataObject) + eClass.getEPackage(). + getEFactoryInstance(). + create(eClass); + + EDataObjectReaderHelper. + restoreEAttributes( + eClass, + eDataObject, + namespaceURI, + attributes ); + + return eDataObject; + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReaderHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReaderHelper.java new file mode 100644 index 0000000000..2fa6321a65 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReaderHelper.java @@ -0,0 +1,161 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.emf.read; + +import java.util.List; + +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; + +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer; +import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier; +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.sdo.EDataObject; +import org.eclipse.emf.ecore.util.EcoreUtil; + +public class EDataObjectReaderHelper +implements DASConstants +{ + public static void restoreEAttributes( + EClass eClass, + EDataObject eDataObject, + String namespaceURI, + Attributes attributes) + throws NamingException + { + List<EAttribute> eAttributes = + eClass.getEAllAttributes(); + + for (EAttribute eAttribute : eAttributes) + { + String qualifiedEAttributeName = + SimpleTypeNamespaceQualifier. + qualify( + namespaceURI, + eClass.getName(), + eAttribute.getName() ); + + String normalizedEAttributeName = + QualifiedNameNormalizer. + normalize(qualifiedEAttributeName); + + if (eAttribute.isMany()) + { + EList<Object> values = + new BasicEList<Object>(); + + Attribute attribute = + attributes. + get(normalizedEAttributeName); + + for (int i = 0; i < attribute.size(); i++) + { + String value = (String) attribute.get(i); + + values.add(EcoreUtil.createFromString( + eAttribute.getEAttributeType(), + value)); + } + + eDataObject.eSet( + eAttribute, values); + } + else + { + String value = + (String) + attributes. + get(normalizedEAttributeName). + get(); + + eDataObject.eSet( + eAttribute, + EcoreUtil.createFromString( + eAttribute.getEAttributeType(), + value)); + } + } + } + + + //TODO Test all of these verifying that we get out what we put in + //TODO Move to helper + //TODO Note that we are using eDataObject.eSet(eAttribute, EcoreUtil.createFromString(eAttribute.getEAttributeType(), value)); instead + /* + public static void setEDataObjectFeature( + EDataObject eDataObject, + String value, + EAttribute eAttribute) + { + if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEString()) + { + eDataObject.eSet(eAttribute, value); + } + else if ( + eAttribute.getEType() == EcorePackage.eINSTANCE.getEInt() || + eAttribute.getEType() == EcorePackage.eINSTANCE.getEIntegerObject()) + { + eDataObject.eSet(eAttribute, new Integer(value)); + } + else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() || + eAttribute.getEType() == EcorePackage.eINSTANCE.getEBooleanObject()) + { + eDataObject.eSet(eAttribute, new Boolean(value)); + } + else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEFloat() || + eAttribute.getEType() == EcorePackage.eINSTANCE.getEFloatObject()) + { + eDataObject.eSet(eAttribute, new Float(value)); + } + else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEDouble() || + eAttribute.getEType() == EcorePackage.eINSTANCE.getEDoubleObject()) + { + eDataObject.eSet(eAttribute, new Double(value)); + } + else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEBigDecimal()) + { + eDataObject.eSet(eAttribute, new BigDecimal(value)); + } + else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEBigInteger() ) + { + eDataObject.eSet(eAttribute, new BigInteger(value)); + } + else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEByte() || + eAttribute.getEType() == EcorePackage.eINSTANCE.getEByteObject()) + { + eDataObject.eSet(eAttribute, new Byte(value)); + } + else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEByte() || + eAttribute.getEType() == EcorePackage.eINSTANCE.getEByteObject()) + { + eDataObject.eSet(eAttribute, new Byte(value)); + } + else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEByteArray()) + { + throw new RuntimeException("Sorry - ByteArrays are not supported."); + } + } + */ +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdater.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdater.java new file mode 100644 index 0000000000..4c22faf1ce --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdater.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.emf.update; + +import java.util.Map; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.eclipse.emf.ecore.sdo.EChangeSummary; +import org.eclipse.emf.ecore.sdo.EDataGraph; +import org.eclipse.emf.ecore.sdo.EDataObject; + +public class EDataGraphUpdater +implements DASConstants +{ + public static void update( + EDataGraph eDataGraph, + LdapContext rootContext, + Map<EDataObject, String> dataObjectToRelativeDNCache ) + throws NamingException + { + EChangeSummary eChangeSummary = + (EChangeSummary) + eDataGraph.getChangeSummary(); + + EDataGraphUpdaterHelper. + processChangedDataObjects( + eChangeSummary, + rootContext, + dataObjectToRelativeDNCache); + + EDataGraphUpdaterHelper. + processCreatedDataObjects( + eChangeSummary, + rootContext, + dataObjectToRelativeDNCache); + + EDataGraphUpdaterHelper. + processDestroyedDataObjects( + eChangeSummary, + rootContext, + dataObjectToRelativeDNCache); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdaterHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdaterHelper.java new file mode 100644 index 0000000000..a53b5547fb --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/update/EDataGraphUpdaterHelper.java @@ -0,0 +1,228 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.emf.update; + +import java.util.Map; + +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.DirContext; +import javax.naming.directory.ModificationItem; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.emf.create.EDataGraphCreatorHelper; +import org.apache.tuscany.das.ldap.emf.create.EDataObjectCreatorHelper; +import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer; +import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.EMap; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.change.FeatureChange; +import org.eclipse.emf.ecore.sdo.EChangeSummary; +import org.eclipse.emf.ecore.sdo.EDataObject; + + +public class EDataGraphUpdaterHelper +{ + public static void processDestroyedDataObjects( + EChangeSummary eChangeSummary, + LdapContext containerContext, + Map<EDataObject, String> dataObjectToRelativeDNCache) + throws NamingException + { + EList<EObject> destroyedObjects = + eChangeSummary. + getObjectsToAttach(); + + for (EObject destroyedObject : destroyedObjects) + { + String destroyedObjectRelativeDN = dataObjectToRelativeDNCache.get(destroyedObject); + containerContext.destroySubcontext(destroyedObjectRelativeDN); + dataObjectToRelativeDNCache.remove(destroyedObject); + } + } + + public static void processCreatedDataObjects( + EChangeSummary eChangeSummary, + LdapContext rootContext, + Map<EDataObject, String> dataObjectToRelativeDNCache ) + throws NamingException + { + EList<EObject> createdObjects = + eChangeSummary. + getObjectsToDetach(); + + EDataGraphCreatorHelper.createChildren( + createdObjects, + rootContext, + dataObjectToRelativeDNCache); + } + + public static void processChangedDataObjects( + EChangeSummary eChangeSummary, + LdapContext containerContext, + Map<EDataObject, String> dataObjectToRelativeDNCache ) + throws NamingException + { + EMap<EObject, EList<FeatureChange>> objectChanges = + eChangeSummary.getObjectChanges(); + + for (EObject changedDataObject : objectChanges.keySet()) + { + EList<FeatureChange> featureChanges = + objectChanges.get(changedDataObject); + + ModificationItem[] modificationItems = + new ModificationItem[featureChanges.size()]; + + EClass changedDataObjectEClass = + changedDataObject.eClass(); + + String namespaceURI = + changedDataObjectEClass. + getEPackage(). + getNsURI(); + + for (int i = 0; i < featureChanges.size(); i++) + { + FeatureChange featureChange = + featureChanges.get(i); + + EStructuralFeature eStructuralFeature = + featureChange.getFeature(); + + if (eStructuralFeature instanceof EAttribute) + { + //TODO Note that we are not checking multiplicity many on EAttributes + String qualifiedEAttributeName = + SimpleTypeNamespaceQualifier. + qualify( + namespaceURI, + changedDataObjectEClass.getName(), + eStructuralFeature.getName() ); + + String normalizedEAttributeName = + QualifiedNameNormalizer. + normalize(qualifiedEAttributeName); + + //TODO PUt processEAttribute in a more generic class + Attribute attribute = + EDataObjectCreatorHelper.processEAttribute( + (EAttribute)eStructuralFeature, + namespaceURI, + changedDataObjectEClass, + (EDataObject) changedDataObject); + + modificationItems[i] = + new ModificationItem( + DirContext.REPLACE_ATTRIBUTE, + attribute); + } + else + { + String qualifiedEReferenceName = + SimpleTypeNamespaceQualifier. + qualify( + namespaceURI, + changedDataObjectEClass.getName(), + eStructuralFeature.getName() ); + + String normalizedEReferenceName = + QualifiedNameNormalizer. + normalize(qualifiedEReferenceName); + + Attribute attribute = + new BasicAttribute(normalizedEReferenceName); + + if (eStructuralFeature.isMany()) + { + EList<EDataObject> referenceList = + (EList<EDataObject>) changedDataObject.eGet(eStructuralFeature); + + if (referenceList.size() > 0 && referenceList!=null) + { + for (EDataObject eDataObject : referenceList) + { + attribute.add( + eDataObject. + eGet( + eDataObject. + eClass(). + getEIDAttribute())); + + modificationItems[i] = + new ModificationItem( + DirContext.REPLACE_ATTRIBUTE, + attribute); + } + } + else + { + modificationItems[i] = + new ModificationItem( + DirContext.REMOVE_ATTRIBUTE, + attribute); + } + } + else + { + EDataObject eDataObject = + (EDataObject) + changedDataObject. + eGet(eStructuralFeature); + + if (eDataObject != null) + { + attribute.add( + eDataObject. + eGet( + eDataObject. + eClass(). + getEIDAttribute())); + + modificationItems[i] = + new ModificationItem( + DirContext.REPLACE_ATTRIBUTE, + attribute); + } + else + { + modificationItems[i] = + new ModificationItem( + DirContext.REMOVE_ATTRIBUTE, + attribute); + } + } + } + } + String relativeDN = + dataObjectToRelativeDNCache. + get(changedDataObject); + + containerContext.modifyAttributes( + relativeDN, + modificationItems); + } + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/constants/EncryptionConstants.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/constants/EncryptionConstants.java new file mode 100644 index 0000000000..59b726b4f3 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/constants/EncryptionConstants.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.encryption.constants; + +public interface EncryptionConstants +{ + String MD5 = "MD5"; + String SHA1 = "SHA-1";//Produces longer hashes than MD5 +} diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/util/ChecksumUtils.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/util/ChecksumUtils.java new file mode 100644 index 0000000000..7c77ddf510 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/encryption/util/ChecksumUtils.java @@ -0,0 +1,38 @@ + +package org.apache.tuscany.das.ldap.encryption.util; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import org.apache.tuscany.das.ldap.encryption.constants.EncryptionConstants; + +public class ChecksumUtils +implements EncryptionConstants +{ + public static String computeMD5Hash(String string) + throws NoSuchAlgorithmException + { + MessageDigest messageDigest = MessageDigest.getInstance(MD5); + + byte[] digest = + messageDigest.digest(string.getBytes()); + + StringBuffer hexString = new StringBuffer(); + for (int i=0;i<digest.length;i++) { + hexString.append ( + Integer.toHexString(0xFF & digest[i])); + } + + char[] hexStringCharacters = hexString.toString().toCharArray(); + String checksum = ""; + + for( char i : hexStringCharacters) + { + int ascii = (int) i; + checksum = checksum + Integer.toString(ascii); + } + + return checksum; + } + +} diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/ComplexTypeOIDCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/ComplexTypeOIDCreator.java new file mode 100644 index 0000000000..c0bb3e9137 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/ComplexTypeOIDCreator.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.oid.create; + +import org.apache.tuscany.das.ldap.encryption.constants.EncryptionConstants; +import org.apache.tuscany.das.ldap.encryption.util.ChecksumUtils; +import org.apache.tuscany.das.ldap.util.ComplexTypeNamespaceQualifier; + +/** + * The Class UniqueOIDCreator. + * Creates unique OIDs for namespaced + * metadata such as the XSD DataType + * with (Class specific term) qualifiedNameURI + * http://www.w3.org/2001/XMLSchema/string + * + */ +public class ComplexTypeOIDCreator implements EncryptionConstants +{ + /** + * Creates a unique OID. + * + * @param instanceClassName the instance class name + * @param oidPrefix the OID Branch + * @param simpleTypeName the name + * @param namespaceURI the metadata namespace URI + * + * @return the string + * + * @throws Exception the exception + */ + public static String create( + String oidPrefix, + String namespaceURI, + String complexTypeName) + throws Exception + { + String qualifiedNameURI = + ComplexTypeNamespaceQualifier.qualify( + namespaceURI, + complexTypeName); + + String postfixOID = + ChecksumUtils.computeMD5Hash( + qualifiedNameURI); + + postfixOID = + OIDCreatorHelper. + calculateSegmentedOID(postfixOID); + + return oidPrefix + "." + postfixOID; + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/OIDCreatorHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/OIDCreatorHelper.java new file mode 100644 index 0000000000..ad82a61514 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/OIDCreatorHelper.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.oid.create; + +public class OIDCreatorHelper +{ + private static int MAX_OID_SEGMENT_LENGTH = 8; + /** + * Calculate segmented OID. + * + * @param oid the oid + * + * @return the string + * + * @throws Exception the exception + * + * Note that the OID must be divided + * into segments less than 9 characters + * long. This is an ApacheDS restriction + * on OID segment length. + */ + public static String calculateSegmentedOID(String oid) throws Exception + { + if (oid.length() < 10) + { + throw new Exception("The length of the oid must be greater than 9 in order to ensure uniqueness."); + } + int oidLength = oid.length(); + int numberOfPeriods = oidLength / MAX_OID_SEGMENT_LENGTH; + + int beginIndex = 0; + int endIndex = MAX_OID_SEGMENT_LENGTH; + + String segmentedOID = + oid.substring(beginIndex, endIndex ) + "."; + + for (int i = 2; i < numberOfPeriods; i++) + { + beginIndex = (i-1) * MAX_OID_SEGMENT_LENGTH + 1; + endIndex = i * MAX_OID_SEGMENT_LENGTH; + segmentedOID += oid.substring( beginIndex, endIndex ) + "."; + } + int finalSegmentLength = oid.length() - (endIndex + 2); + + if ( finalSegmentLength > MAX_OID_SEGMENT_LENGTH ) + { + segmentedOID += oid.substring( endIndex + 1,endIndex + 9 ) + "."; + segmentedOID += oid.substring( endIndex + 10, oid.length() ); + } + else + { + segmentedOID += oid.substring( endIndex + 1, oid.length() ); + } + return segmentedOID; + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/SimpleTypeOIDCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/SimpleTypeOIDCreator.java new file mode 100644 index 0000000000..3c083fc42f --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/oid/create/SimpleTypeOIDCreator.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.oid.create; + +import org.apache.tuscany.das.ldap.encryption.constants.EncryptionConstants; +import org.apache.tuscany.das.ldap.encryption.util.ChecksumUtils; +import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier; + +/** + * The Class SimpleTypeOIDCreator. + * Creates unique OIDs for namespaced + * metadata such as the XSD DataType + * with (Class specific term) qualifiedNameURI + * http://www.w3.org/2001/XMLSchema/string + * + */ +public class SimpleTypeOIDCreator implements EncryptionConstants +{ + /** + * Creates a unique OID. + * + * @param instanceClassName the instance class name + * @param oidPrefix the OID Branch + * @param complexTypeName the name + * @param namespaceURI the metadata namespace URI + * + * @return the string + * + * @throws Exception the exception + */ + public static String create( + String oidPrefix, + String namespaceURI, + String complexTypeName, + String simpleTypeName) + throws Exception + { + String qualifiedNameURI = + SimpleTypeNamespaceQualifier.qualify( + namespaceURI, + complexTypeName, + simpleTypeName); + + String postfixOID = ChecksumUtils.computeMD5Hash(qualifiedNameURI); + + postfixOID = OIDCreatorHelper.calculateSegmentedOID(postfixOID); + return oidPrefix + "." + postfixOID; + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/Prototype.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/Prototype.java new file mode 100644 index 0000000000..17f011e971 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/Prototype.java @@ -0,0 +1,74 @@ +package org.apache.tuscany.das.ldap.prototype.setup; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EFactory; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EcoreFactory; +import org.eclipse.emf.ecore.EcorePackage; + +public interface Prototype { + EClass userEClass = + PrototypeUtilities.createUserEClass(); + EClass authorizationEClass = + PrototypeUtilities.createAuthorizationEClass(); + EClass configurationEClass = + PrototypeUtilities.createConfigurationEClass(); + + EAttribute userNameEAttribute = + PrototypeUtilities.createUserNameEAttribute(); + EAttribute userAliasesEAttribute = + PrototypeUtilities.createUserAliasesEAttribute(); + + EAttribute userPasswordEAttribute = + PrototypeUtilities.createUserPasswordEAttribute(); + EAttribute userIDEAttribute = + PrototypeUtilities.createUserIDEAttribute(); + EAttribute userAgeEAttribute = + PrototypeUtilities.createUserAgeEAttribute(); + EAttribute userHeightEAttribute = + PrototypeUtilities.createUserHeightEAttribute(); + EAttribute userIsMaleEAttribute = + PrototypeUtilities.createUserIsMaleEAttribute(); + EReference userAuthorizationEReference = + PrototypeUtilities.createUserAuthorizationEReference(); + + EReference userConfigurationEReference = + PrototypeUtilities.createUserConfigurationEReference(); + + + + + EAttribute authorizationFileEAttribute = + PrototypeUtilities.createFileEAttribute(); + EAttribute authorizationReadEAttribute = + PrototypeUtilities.createReadAuthorizationEAttribute(); + EAttribute authorizationWriteEAttribute= + PrototypeUtilities.createWriteAuthorizationEAttribute(); + EAttribute authorizationExecuteEAttribute = + PrototypeUtilities.createExecuteAuthorizationEAttribute(); + EAttribute authorizationIDEAttribute = + PrototypeUtilities.createAuthorizationIDEAttribute(); + + EAttribute configurationIDEAttribute = + PrototypeUtilities.createConfigurationIDEAttribute(); + + EReference configurationAuthorizationEReference = + PrototypeUtilities.createConfigurationAuthorizationEReference(); + + EReference configurationAuthorizationsEReference = + PrototypeUtilities.createConfigurationAuthorizationsEReference(); + + + EPackage userEPackage = + PrototypeUtilities.createUserEPackage(); + + EFactory userEFactory = + userEPackage.getEFactoryInstance(); + + EcoreFactory ecoreFactory = + EcoreFactory.eINSTANCE; + EcorePackage ecorePackage = + EcorePackage.eINSTANCE; +} diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/PrototypeUtilities.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/PrototypeUtilities.java new file mode 100644 index 0000000000..11af604dfa --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/PrototypeUtilities.java @@ -0,0 +1,243 @@ +package org.apache.tuscany.das.ldap.prototype.setup; + +import org.apache.tuscany.das.ldap.testing.constants.DASTestingConstants; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.ecore.EcoreFactory; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.sdo.impl.DynamicEDataObjectImpl; + +public class PrototypeUtilities +implements DASTestingConstants { + + /* + * The User EClass is intended to be the root of the DataGraph + * It should have a multiplicity many containment reference of type + * Authorization and a containment reference of type Configuration + * The Configuration should have a single non-containment reference + * of type Authorization. + */ + + public static EClass createUserEClass() + { + EClass userEClass = + EcoreFactory.eINSTANCE.createEClass(); + + userEClass.setName("User"); + + return userEClass; + } + + public static EAttribute createUserIDEAttribute() + { + EAttribute id = + EcoreFactory.eINSTANCE.createEAttribute(); + id.setName( "id" ); + id.setEType( EcorePackage.eINSTANCE.getEString() ); + id.setID(true); + return id; + } + + public static EAttribute createUserNameEAttribute() + { + EAttribute userName = + EcoreFactory.eINSTANCE.createEAttribute(); + userName.setName( "userName" ); + userName.setEType( EcorePackage.eINSTANCE.getEString() ); + return userName; + } + + public static EAttribute createUserAliasesEAttribute() + { + EAttribute userAliases = + EcoreFactory.eINSTANCE.createEAttribute(); + userAliases.setName( "userAliases" ); + userAliases.setLowerBound( 0 ); + userAliases.setUpperBound( -1 ); + userAliases.setEType( EcorePackage.eINSTANCE.getEString() ); + return userAliases; + } + + public static EAttribute createUserPasswordEAttribute() + { + EAttribute userPassword = + EcoreFactory.eINSTANCE.createEAttribute(); + userPassword.setName( "userPassword" ); + userPassword.setEType( EcorePackage.eINSTANCE.getEString() ); + return userPassword; + } + + public static EAttribute createUserAgeEAttribute() + { + EAttribute userAge = + EcoreFactory.eINSTANCE.createEAttribute(); + userAge.setName( "userAge" ); + userAge.setEType( EcorePackage.eINSTANCE.getEInt() ); + return userAge; + } + + public static EAttribute createUserHeightEAttribute() + { + EAttribute userHeight = + EcoreFactory.eINSTANCE.createEAttribute(); + userHeight.setName( "userHeight" ); + userHeight.setEType( EcorePackage.eINSTANCE.getEDouble() ); + return userHeight; + } + + public static EAttribute createUserIsMaleEAttribute() + { + EAttribute isMale = + EcoreFactory.eINSTANCE.createEAttribute(); + isMale.setName( "isMale" ); + isMale.setEType( EcorePackage.eINSTANCE.getEBoolean() ); + return isMale; + } + + public static EReference createUserAuthorizationEReference() + { + EReference userAuthorizationEReference = + EcoreFactory.eINSTANCE.createEReference(); + userAuthorizationEReference.setLowerBound(0); + userAuthorizationEReference.setUpperBound(ETypedElement.UNBOUNDED_MULTIPLICITY); + userAuthorizationEReference.setContainment(true); + userAuthorizationEReference.setName("authorizationList"); + + return userAuthorizationEReference; + } + + public static EReference createUserConfigurationEReference() + { + EReference userConfigurationEReference = + EcoreFactory.eINSTANCE.createEReference(); + userConfigurationEReference.setLowerBound(0); + userConfigurationEReference.setUpperBound(1); + userConfigurationEReference.setContainment(true); + userConfigurationEReference.setName("configuration"); + + return userConfigurationEReference; + } + + + public static EPackage createUserEPackage() + { + EPackage userEPackage = + EcoreFactory.eINSTANCE.createEPackage(); + userEPackage.setName( "userPackage" ); + userEPackage.setNsPrefix( "user" ); + userEPackage.setNsURI( xsdNamespace ); + + userEPackage.setEFactoryInstance( + new DynamicEDataObjectImpl.FactoryImpl()); + + return userEPackage; + } + + public static EClass createAuthorizationEClass() + { + EClass authorizationEClass = + EcoreFactory.eINSTANCE.createEClass(); + + authorizationEClass.setName("Authorization"); + + return authorizationEClass; + } + + public static EAttribute createAuthorizationIDEAttribute() + { + EAttribute id = + EcoreFactory.eINSTANCE.createEAttribute(); + id.setName( "id" ); + id.setEType( EcorePackage.eINSTANCE.getEString() ); + id.setID(true); + return id; + } + + public static EAttribute createFileEAttribute() + { + EAttribute fileNameEAttribute = + EcoreFactory.eINSTANCE.createEAttribute(); + fileNameEAttribute.setName( "fileName" ); + fileNameEAttribute.setEType( EcorePackage.eINSTANCE.getEString() ); + return fileNameEAttribute; + + } + + public static EAttribute createWriteAuthorizationEAttribute() + { + EAttribute writeAuthorizationEAttribute = + EcoreFactory.eINSTANCE.createEAttribute(); + writeAuthorizationEAttribute.setName( "writeAuthorization" ); + writeAuthorizationEAttribute.setEType( EcorePackage.eINSTANCE.getEBoolean() ); + return writeAuthorizationEAttribute; + } + + public static EAttribute createReadAuthorizationEAttribute() + { + EAttribute readAuthorizationEAttribute = + EcoreFactory.eINSTANCE.createEAttribute(); + readAuthorizationEAttribute.setName( "readAuthorization" ); + readAuthorizationEAttribute.setEType( EcorePackage.eINSTANCE.getEBoolean() ); + return readAuthorizationEAttribute; + } + + public static EAttribute createExecuteAuthorizationEAttribute() + { + EAttribute readExecuteEAttribute = + EcoreFactory.eINSTANCE.createEAttribute(); + readExecuteEAttribute.setName( "executeAuthorization" ); + readExecuteEAttribute.setEType( EcorePackage.eINSTANCE.getEBoolean() ); + return readExecuteEAttribute; + } + + + public static EClass createConfigurationEClass() + { + EClass configurationEClass = + EcoreFactory.eINSTANCE.createEClass(); + + configurationEClass.setName("Configuration"); + + return configurationEClass; + } + + public static EAttribute createConfigurationIDEAttribute() + { + EAttribute id = + EcoreFactory.eINSTANCE.createEAttribute(); + id.setName( "id" ); + id.setEType( EcorePackage.eINSTANCE.getEString() ); + id.setID(true); + return id; + } + + public static EReference createConfigurationAuthorizationEReference() + { + EReference authorizationEReference = + EcoreFactory.eINSTANCE.createEReference(); + authorizationEReference.setLowerBound(0); + authorizationEReference.setUpperBound(1); + authorizationEReference.setContainment(false); + //authorizationEReference.setEType(createAuthorizationEClass()); Do this in the testing code. + authorizationEReference.setName("authorization"); + + return authorizationEReference; + } + + public static EReference createConfigurationAuthorizationsEReference() + { + EReference authorizationsEReference = + EcoreFactory.eINSTANCE.createEReference(); + authorizationsEReference.setLowerBound(0); + authorizationsEReference.setUpperBound(ETypedElement.UNBOUNDED_MULTIPLICITY); + authorizationsEReference.setContainment(false); + //authorizationEReference.setEType(createAuthorizationEClass()); Do this in the testing code. + authorizationsEReference.setName("authorizations"); + + return authorizationsEReference; + } + +} diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/CommonSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/CommonSetupTest.java new file mode 100644 index 0000000000..9b7673efe6 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/CommonSetupTest.java @@ -0,0 +1,264 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.prototype.setup.test; + +import java.io.File; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +import org.apache.commons.io.FileUtils; +import org.apache.tuscany.das.ldap.prototype.setup.Prototype; +import org.apache.tuscany.das.ldap.schema.embedded.setup.test.EcoreSchemaAndDASContextsSetup; +import org.apache.tuscany.das.ldap.schema.emf.create.EObjectClassCreator; +import org.apache.tuscany.das.ldap.schema.emf.destroy.EObjectClassDestroyer; +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.sdo.EDataObject; + +public class CommonSetupTest +extends EcoreSchemaAndDASContextsSetup +implements Prototype +{ + protected EObjectClassCreator eObjectClassCreator = null; + + protected EDataObject userDataObject = null; + protected EDataObject authorizationDataObject0 = null; + protected EDataObject authorizationDataObject1 = null; + protected EDataObject configurationDataObject = null; + + protected static List<EClass> + processedEClassifiers = null; + + protected String userDataObjectRDN = + "example-com-users-accounts-User-id=1"; + protected String authorizationDataObject1RDN = + "example-com-users-accounts-Authorization-id=2,cn=authorizationList,example-com-users-accounts-User-id=1"; + protected String authorizationDataObject2RDN = + "example-com-users-accounts-Authorization-id=3,cn=authorizationList,example-com-users-accounts-User-id=1"; + protected String configurationDataObjectRDN = + "example-com-users-accounts-Configuration-id=5,cn=configuration,example-com-users-accounts-User-id=1"; + + protected String configurationContainingFeatureRDN = + "cn=configuration"; + protected String authorizationListContainingFeatureRDN= + "cn=authorizationList"; + + protected LdapContext authorizationContainerContext = null; + protected LdapContext configurationContainerContext = null; + protected LdapContext userContainerContext = null; + + protected Map<EDataObject, String> dataObjectToRelativeDNCache = null; + + public void tearDown() throws NamingException, Exception + { + rootContext.destroySubcontext(userDataObjectRDN); + + EObjectClassDestroyer. + destroy( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + userEClass, + TUSCANY_OID_PREFIX_VALUE ); + + super.tearDown(); + } + + public void setUp() throws Exception + { + FileUtils.deleteDirectory(new File("server-work")); + + dataObjectToRelativeDNCache = + new Hashtable<EDataObject, String>(); + + super.setUp(); + + userAuthorizationEReference. + setEType(authorizationEClass); + + userConfigurationEReference. + setEType(configurationEClass); + + configurationAuthorizationEReference. + setEType(authorizationEClass); + + configurationAuthorizationsEReference. + setEType(authorizationEClass); + + userEClass. + getEStructuralFeatures(). + add( userNameEAttribute ); + + userEClass. + getEStructuralFeatures(). + add( userAliasesEAttribute ); + + userEClass. + getEStructuralFeatures(). + add( userPasswordEAttribute ); + userEClass. + getEStructuralFeatures(). + add( userAgeEAttribute ); + userEClass. + getEStructuralFeatures(). + add( userHeightEAttribute ); + userEClass. + getEStructuralFeatures(). + add( userIsMaleEAttribute ); + userEClass. + getEStructuralFeatures(). + add( userIDEAttribute ); + userEClass. + getEStructuralFeatures(). + add( userAuthorizationEReference ); + userEClass. + getEStructuralFeatures(). + add( userConfigurationEReference ); + + userEPackage.getEClassifiers().add(userEClass); + + userDataObject = + (EDataObject) + userEFactory.create(userEClass); + + userDataObject.eSet(userNameEAttribute,"ole"); + userDataObject.eSet(userPasswordEAttribute,"secret"); + userDataObject.eSet(userIDEAttribute, "1"); + userDataObject.eSet(userAgeEAttribute, 33); + userDataObject.eSet(userHeightEAttribute, 6.11); + userDataObject.eSet(userIsMaleEAttribute, true); + + EList<String> userAliases = new BasicEList<String>(); + userAliases.add("neo"); + userAliases.add("trinity"); + userAliases.add("morpheus"); + + userDataObject.eSet( userAliasesEAttribute, userAliases ); + + authorizationEClass. + getEStructuralFeatures(). + add(authorizationFileEAttribute); + + authorizationEClass. + getEStructuralFeatures(). + add(authorizationWriteEAttribute); + + authorizationEClass. + getEStructuralFeatures(). + add(authorizationReadEAttribute); + + authorizationEClass. + getEStructuralFeatures(). + add(authorizationExecuteEAttribute); + + authorizationEClass. + getEStructuralFeatures(). + add(authorizationIDEAttribute); + + userEPackage.getEClassifiers(). + add(authorizationEClass); + + authorizationDataObject0 = + (EDataObject) + userEFactory.create(authorizationEClass); + + authorizationDataObject1 = + (EDataObject) + userEFactory.create(authorizationEClass); + + authorizationDataObject0.eSet(authorizationFileEAttribute,"somefile.text"); + authorizationDataObject0.eSet(authorizationWriteEAttribute, true); + authorizationDataObject0.eSet(authorizationReadEAttribute,true); + authorizationDataObject0.eSet(authorizationExecuteEAttribute,true); + authorizationDataObject0.eSet(authorizationIDEAttribute, "2"); + + authorizationDataObject1.eSet(authorizationFileEAttribute,"someOtherfile.text"); + authorizationDataObject1.eSet(authorizationWriteEAttribute,Boolean.TRUE); + authorizationDataObject1.eSet(authorizationReadEAttribute,true); + authorizationDataObject1.eSet(authorizationExecuteEAttribute,true); + authorizationDataObject1.eSet(authorizationIDEAttribute, "3"); + + EList<EDataObject> userDataObjectAuthorizationList = + new BasicEList<EDataObject>(); + + userDataObjectAuthorizationList.add(authorizationDataObject0); + userDataObjectAuthorizationList.add(authorizationDataObject1); + + userDataObject.eSet( + userAuthorizationEReference, + userDataObjectAuthorizationList); + + configurationEClass. + getEStructuralFeatures(). + add(configurationIDEAttribute); + + configurationEClass. + getEStructuralFeatures(). + add(configurationAuthorizationEReference); + + configurationEClass. + getEStructuralFeatures(). + add(configurationAuthorizationsEReference); + + userEPackage.getEClassifiers(). + add(configurationEClass); + + configurationDataObject = + (EDataObject) + userEFactory.create(configurationEClass); + + userDataObject.eSet( + userConfigurationEReference, + configurationDataObject); + + configurationDataObject.eSet( + configurationIDEAttribute, + "5"); + + configurationDataObject.eSet( + configurationAuthorizationEReference, + authorizationDataObject0); + + configurationDataObject.eSet( + configurationAuthorizationsEReference, + userDataObjectAuthorizationList); + + processedEClassifiers = + new ArrayList<EClass>(); + + eObjectClassCreator = + new EObjectClassCreator(); + + eObjectClassCreator. + create( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + userEClass, + processedEClassifiers, + TUSCANY_OID_PREFIX_VALUE ); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataGraphSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataGraphSetupTest.java new file mode 100644 index 0000000000..c05db9f7e2 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataGraphSetupTest.java @@ -0,0 +1,138 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.prototype.setup.test; + +import javax.naming.NamingException; + +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.emf.create.EDataGraphCreator; +import org.apache.tuscany.das.ldap.schema.emf.destroy.EObjectClassDestroyer; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.sdo.EDataGraph; +import org.eclipse.emf.ecore.sdo.SDOFactory; +import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; + +public class EDataGraphSetupTest +extends CommonSetupTest +{ + protected EDataGraph eDataGraph = null; + protected boolean readException = false; + + public void tearDown() throws NamingException, Exception + { + if (dataObjectToRelativeDNCache.containsValue(authorizationDataObject1RDN) + || readException) + { + rootContext.destroySubcontext(authorizationDataObject1RDN); + } + if (dataObjectToRelativeDNCache.containsValue(authorizationDataObject2RDN) + || readException) + { + rootContext.destroySubcontext(authorizationDataObject2RDN); + } + if (dataObjectToRelativeDNCache.containsValue(configurationDataObjectRDN) + || readException) + { + rootContext.destroySubcontext(configurationDataObjectRDN); + } + userContainerContext.destroySubcontext(configurationContainingFeatureRDN); + + userContainerContext.destroySubcontext(authorizationListContainingFeatureRDN); + + EObjectClassDestroyer. + destroy( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + authorizationEClass, + TUSCANY_OID_PREFIX_VALUE ); + + EObjectClassDestroyer. + destroy( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + configurationEClass, + TUSCANY_OID_PREFIX_VALUE ); + + super.tearDown(); + } + + public void setUp() throws Exception + { + super.setUp(); + + eObjectClassCreator. + create( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + authorizationEClass, + processedEClassifiers, + TUSCANY_OID_PREFIX_VALUE ); + + eObjectClassCreator. + create( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + configurationEClass, + processedEClassifiers, + TUSCANY_OID_PREFIX_VALUE ); + + eDataGraph = + SDOFactory. + eINSTANCE. + createEDataGraph(); + + eDataGraph.setERootObject(userDataObject); + + ResourceSet resourceSet = new ResourceSetImpl(); + resourceSet.getResourceFactoryRegistry(). + getExtensionToFactoryMap().put + ("xml", + new XMLResourceFactoryImpl()); + + eDataGraph.setResourceSet(resourceSet); + + EDataGraphCreator.create( + eDataGraph, + rootContext, + dataObjectToRelativeDNCache); + + userContainerContext = + (LdapContext) + rootContext. + lookup(userDataObjectRDN); + + authorizationContainerContext = + (LdapContext) + userContainerContext. + lookup(authorizationListContainingFeatureRDN); + + configurationContainerContext = + (LdapContext) + userContainerContext. + lookup(configurationContainingFeatureRDN); + + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataObjectSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataObjectSetupTest.java new file mode 100644 index 0000000000..4c91f34e07 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/EDataObjectSetupTest.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.prototype.setup.test; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.emf.create.EDataObjectCreator; + +public class EDataObjectSetupTest +extends CommonSetupTest +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws Exception + { + super.setUp(); + + EDataObjectCreator.create( + userDataObject, + rootContext, + dataObjectToRelativeDNCache); + + userContainerContext = + (LdapContext) + rootContext. + lookup(userDataObjectRDN); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/LdapDASSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/LdapDASSetupTest.java new file mode 100644 index 0000000000..3225868ffe --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/prototype/setup/test/LdapDASSetupTest.java @@ -0,0 +1,218 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.prototype.setup.test; + +import java.io.File; +import java.util.Hashtable; +import java.util.Map; + +import javax.naming.NamingException; + +import junit.framework.TestCase; + +import org.apache.commons.io.FileUtils; +import org.apache.tuscany.das.ldap.prototype.setup.Prototype; +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.sdo.EDataGraph; +import org.eclipse.emf.ecore.sdo.EDataObject; +import org.eclipse.emf.ecore.sdo.SDOFactory; + +public class LdapDASSetupTest +extends TestCase +implements Prototype +{ + protected Map<EDataObject, String> dataObjectToRelativeDNCache = null; + protected EDataGraph eDataGraph = null; + protected EDataObject userDataObject = null; + protected EDataObject authorizationDataObject0 = null; + protected EDataObject authorizationDataObject1 = null; + protected EDataObject configurationDataObject = null; + + public void tearDown() throws NamingException, Exception + { + FileUtils.deleteDirectory(new File("server-work")); + } + + public void setUp() throws Exception + { + dataObjectToRelativeDNCache = + new Hashtable<EDataObject, String>(); + + userAuthorizationEReference. + setEType(authorizationEClass); + + userConfigurationEReference. + setEType(configurationEClass); + + configurationAuthorizationEReference. + setEType(authorizationEClass); + + configurationAuthorizationsEReference. + setEType(authorizationEClass); + + userEClass. + getEStructuralFeatures(). + add( userNameEAttribute ); + + userEClass. + getEStructuralFeatures(). + add( userAliasesEAttribute ); + + userEClass. + getEStructuralFeatures(). + add( userPasswordEAttribute ); + userEClass. + getEStructuralFeatures(). + add( userAgeEAttribute ); + userEClass. + getEStructuralFeatures(). + add( userHeightEAttribute ); + userEClass. + getEStructuralFeatures(). + add( userIsMaleEAttribute ); + userEClass. + getEStructuralFeatures(). + add( userIDEAttribute ); + userEClass. + getEStructuralFeatures(). + add( userAuthorizationEReference ); + userEClass. + getEStructuralFeatures(). + add( userConfigurationEReference ); + + userEPackage.getEClassifiers().add(userEClass); + + userDataObject = + (EDataObject) + userEFactory.create(userEClass); + + userDataObject.eSet(userNameEAttribute,"ole"); + userDataObject.eSet(userPasswordEAttribute,"secret"); + userDataObject.eSet(userIDEAttribute, "1"); + userDataObject.eSet(userAgeEAttribute, 33); + userDataObject.eSet(userHeightEAttribute, 6.11); + userDataObject.eSet(userIsMaleEAttribute, true); + + EList<String> userAliases = new BasicEList<String>(); + userAliases.add("neo"); + userAliases.add("trinity"); + userAliases.add("morpheus"); + + userDataObject.eSet( userAliasesEAttribute, userAliases ); + + authorizationEClass. + getEStructuralFeatures(). + add(authorizationFileEAttribute); + + authorizationEClass. + getEStructuralFeatures(). + add(authorizationWriteEAttribute); + + authorizationEClass. + getEStructuralFeatures(). + add(authorizationReadEAttribute); + + authorizationEClass. + getEStructuralFeatures(). + add(authorizationExecuteEAttribute); + + authorizationEClass. + getEStructuralFeatures(). + add(authorizationIDEAttribute); + + userEPackage.getEClassifiers(). + add(authorizationEClass); + + authorizationDataObject0 = + (EDataObject) + userEFactory.create(authorizationEClass); + + authorizationDataObject1 = + (EDataObject) + userEFactory.create(authorizationEClass); + + authorizationDataObject0.eSet(authorizationFileEAttribute,"somefile.text"); + authorizationDataObject0.eSet(authorizationWriteEAttribute, true); + authorizationDataObject0.eSet(authorizationReadEAttribute,true); + authorizationDataObject0.eSet(authorizationExecuteEAttribute,true); + authorizationDataObject0.eSet(authorizationIDEAttribute, "2"); + + authorizationDataObject1.eSet(authorizationFileEAttribute,"someOtherfile.text"); + authorizationDataObject1.eSet(authorizationWriteEAttribute,Boolean.TRUE); + authorizationDataObject1.eSet(authorizationReadEAttribute,true); + authorizationDataObject1.eSet(authorizationExecuteEAttribute,true); + authorizationDataObject1.eSet(authorizationIDEAttribute, "3"); + + EList<EDataObject> userDataObjectAuthorizationList = + new BasicEList<EDataObject>(); + + userDataObjectAuthorizationList.add(authorizationDataObject0); + userDataObjectAuthorizationList.add(authorizationDataObject1); + + userDataObject.eSet( + userAuthorizationEReference, + userDataObjectAuthorizationList); + + configurationEClass. + getEStructuralFeatures(). + add(configurationIDEAttribute); + + configurationEClass. + getEStructuralFeatures(). + add(configurationAuthorizationEReference); + + configurationEClass. + getEStructuralFeatures(). + add(configurationAuthorizationsEReference); + + userEPackage.getEClassifiers(). + add(configurationEClass); + + configurationDataObject = + (EDataObject) + userEFactory.create(configurationEClass); + + userDataObject.eSet( + userConfigurationEReference, + configurationDataObject); + + configurationDataObject.eSet( + configurationIDEAttribute, + "5"); + + configurationDataObject.eSet( + configurationAuthorizationEReference, + authorizationDataObject0); + + configurationDataObject.eSet( + configurationAuthorizationsEReference, + userDataObjectAuthorizationList); + + + eDataGraph = + SDOFactory. + eINSTANCE. + createEDataGraph(); + + eDataGraph.setERootObject(userDataObject); + + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/AbstractAttributeTypeCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/AbstractAttributeTypeCreator.java new file mode 100644 index 0000000000..c021607a2c --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/AbstractAttributeTypeCreator.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.create; + +/** + * The Class AbstractAttributeTypeCreator. + */ +public abstract class AbstractAttributeTypeCreator +extends AbstractTypeCreator +{ + + public AbstractAttributeTypeCreator() + { + super(); + + objectClassAttribute.add( META_ATTRIBUTE_TYPE ); + basicAttributes.put( M_COLLECTIVE, LDAP_FALSE ); + basicAttributes.put( M_EQUALITY, M_EQUALITY__NAME_OR_NUMERIC_ID_MATCH ); + basicAttributes.put( M_NO_USER_MODIFICATION, LDAP_FALSE); + basicAttributes.put( M_SINGLE_VALUE, LDAP_FALSE ); + basicAttributes.put( M_USAGE, LDAP_USER_APPLICATIONS); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/AbstractTypeCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/AbstractTypeCreator.java new file mode 100644 index 0000000000..6fbf988646 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/AbstractTypeCreator.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.create; + +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; + +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants; +import org.apache.tuscany.das.ldap.schema.constants.EnumeratedSchemaAttributeTypeValues; +import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants; +import org.apache.tuscany.das.ldap.schema.constants.SchemaAttributeTypeConstants; +import org.apache.tuscany.das.ldap.schema.constants.SchemaObjectClassConstants; + +public abstract class AbstractTypeCreator +implements +EnumeratedSchemaAttributeTypeValues, +SchemaAttributeTypeConstants, +AttributeTypeConstants, +SchemaObjectClassConstants, +ObjectClassConstants, +DASConstants +{ + protected Attribute objectClassAttribute; + protected Attributes basicAttributes; + + public AbstractTypeCreator() + { + objectClassAttribute = + new BasicAttribute( + OBJECT_CLASS, TOP ); + + objectClassAttribute.add( + META_TOP ); + + basicAttributes = new BasicAttributes(); + basicAttributes.put(objectClassAttribute); + basicAttributes.put( M_OBSOLETE, LDAP_FALSE ); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/ComplexTypeRDNCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/ComplexTypeRDNCreator.java new file mode 100644 index 0000000000..47e3e8a716 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/ComplexTypeRDNCreator.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.create; + +import org.apache.tuscany.das.ldap.oid.create.ComplexTypeOIDCreator; +import org.apache.tuscany.das.ldap.schema.constants.SchemaAttributeTypeConstants; + +/** + * The Class DataTypeRDNCreator. + */ +public class ComplexTypeRDNCreator +implements SchemaAttributeTypeConstants +{ + /** + * Create. + * + * @param oidPrefix the oid prefix + * @param namespaceURI the namespace URI + * @param complexTypeName the complex type name + * + * @return the string that is the rdn + * + * @throws Exception the exception + */ + public static String create( + String oidPrefix, + String namespaceURI, + String complexTypeName + ) + throws Exception + { + String oid = + ComplexTypeOIDCreator.create( + oidPrefix, + namespaceURI, + complexTypeName ); + + String rdn = + M_OID + "=" + oid; + + return rdn; + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SimpleTypeRDNCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SimpleTypeRDNCreator.java new file mode 100644 index 0000000000..6e8eaba018 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SimpleTypeRDNCreator.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.create; + +import org.apache.tuscany.das.ldap.oid.create.SimpleTypeOIDCreator; +import org.apache.tuscany.das.ldap.schema.constants.SchemaAttributeTypeConstants; + +/** + * The Class DataTypeRDNCreator. + */ +public class SimpleTypeRDNCreator +implements SchemaAttributeTypeConstants +{ + + /** + * Create. + * + * @param oidPrefix the oid prefix + * @param namespaceURI the namespace URI + * @param complexTypeName the name + * @param simpleTypeName the simple type name + * + * @return the string + * + * @throws Exception the exception + */ + public static String create( + String oidPrefix, + String namespaceURI, + String complexTypeName, + String simpleTypeName) + throws Exception + { + String oid = + SimpleTypeOIDCreator.create( + oidPrefix, + namespaceURI, + complexTypeName, + simpleTypeName); + + String rdn = + M_OID + "=" + oid; + + return rdn; + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SyntaxCheckerEntryCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SyntaxCheckerEntryCreator.java new file mode 100644 index 0000000000..6b115fd71f --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SyntaxCheckerEntryCreator.java @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.create; + +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants; +import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants; +import org.apache.tuscany.das.ldap.schema.constants.SchemaAttributeTypeConstants; +import org.apache.tuscany.das.ldap.schema.constants.SchemaObjectClassConstants; + +/** + * The Class SyntaxEntryCreator. + */ +public class SyntaxCheckerEntryCreator +implements +AttributeTypeConstants, +SchemaAttributeTypeConstants, +ObjectClassConstants, +SchemaObjectClassConstants +{ + /** + * Create. + * + * @param oidPrefix the oid prefix + * @param namespaceURI the namespace URI + * @param dataTypeName the name of the DataType + * @param syntaxesContext the directory context + * + * @throws Exception the exception + */ + public static void create( + String rdn, + LdapContext syntaxCheckerContext) + throws Exception + { + + Attributes attributes = + prepareSyntaxCheckerAttributes(); + + syntaxCheckerContext.createSubcontext( + rdn, + attributes); + } + + /** + * TODO - Move to helper + * Prepare SyntaxChecker attributes. + * + * @return the attributes + */ + public static Attributes prepareSyntaxCheckerAttributes() + { + Attribute objectClassAttribute = + new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add( META_TOP ); + objectClassAttribute.add( META_SYNTAX_CHECKER ); + + Attribute fqcnAttribute = + new BasicAttribute( + M_FQCN, + M_FQCN_DEFAULT_VALUE); + + Attributes attributes = new BasicAttributes(); + + attributes.put( objectClassAttribute ); + attributes.put( fqcnAttribute ); + + return attributes; + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SyntaxEntryCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SyntaxEntryCreator.java new file mode 100644 index 0000000000..024ef1e7b9 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/create/SyntaxEntryCreator.java @@ -0,0 +1,155 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.create; + +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; +import javax.naming.directory.DirContext; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants; +import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants; +import org.apache.tuscany.das.ldap.schema.constants.SchemaAttributeTypeConstants; +import org.apache.tuscany.das.ldap.schema.constants.SchemaObjectClassConstants; +import org.apache.tuscany.das.ldap.util.ComplexTypeNamespaceQualifier; + +/** + * The Class SyntaxEntryCreator. + */ +public class SyntaxEntryCreator +implements +AttributeTypeConstants, +SchemaAttributeTypeConstants, +ObjectClassConstants, +SchemaObjectClassConstants +{ + /** + * Create. + * + * @param oidPrefix the oid prefix + * @param namespaceURI the namespace URI + * @param dataTypeName the name of the DataType + * @param syntaxesContext the directory context + * + * @throws Exception the exception + */ + public static void create( + String oidPrefix, + String namespaceURI, + String dataTypeName, + LdapContext syntaxesContext, + LdapContext syntaxCheckersContext) + throws Exception + { + String syntaxDescription = + ComplexTypeNamespaceQualifier. + qualify( + namespaceURI, + dataTypeName); + + String rdn = + ComplexTypeRDNCreator. + create( + oidPrefix, + namespaceURI, + dataTypeName); + + Attributes syntaxAttributes = + prepareSyntaxAttributes( + syntaxDescription ); + + Attributes syntaxCheckerAttributes = + prepareSyntaxCheckerAttributes(); + + //TODO Put back in when bug gets resolved. + //TODO Remember to apply the namespace qualifier or we could just leave because it's in the description effectively + //attributes.put(M_NAME, name ); + //attributes.put("x-humandReadible", "false"); + //attributes.put("m-obsolete, "false"); + syntaxesContext.createSubcontext( + rdn, + syntaxAttributes); + + syntaxCheckersContext.createSubcontext( + rdn, + syntaxCheckerAttributes); + } + + /** + * TODO - Move to helper + * TODO - Optimize - we are prepping these each time when they could be cached + * Prepare syntax attributes. + * + * @param syntaxDescription the syntax description + * + * @return the attributes + */ + public static Attributes prepareSyntaxAttributes( + String syntaxDescription) + { + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, TOP); + objectClassAttribute.add( META_TOP ); + objectClassAttribute.add( META_SYNTAX ); + + Attribute descriptionAttribute = new BasicAttribute( + M_DESCRIPTION, + syntaxDescription); + + Attributes attributes = new BasicAttributes(); + + attributes.put( objectClassAttribute ); + attributes.put( descriptionAttribute ); + + return attributes; + } + + /** + * TODO - Move to helper + * TODO - Optimize - we are prepping these each time when they could be cached + * Prepare SyntaxChecker attributes. + * + * @return the attributes + */ + public static Attributes prepareSyntaxCheckerAttributes() + { + Attribute objectClassAttribute = + new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add( META_TOP ); + objectClassAttribute.add( META_SYNTAX_CHECKER ); + + Attribute fqcnAttribute = + new BasicAttribute( + M_FQCN, + M_FQCN_DEFAULT_VALUE); + + Attributes attributes = new BasicAttributes(); + + attributes.put( objectClassAttribute ); + attributes.put( fqcnAttribute ); + + return attributes; + } + +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetup.java new file mode 100644 index 0000000000..010baa800b --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetup.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +import org.apache.directory.apacheds.testing.setup.ADSEmbeddedHotPartitionTemplate; +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants; +import org.apache.tuscany.das.ldap.schema.constants.EnumeratedSchemaAttributeTypeValues; +import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants; +import org.apache.tuscany.das.ldap.schema.constants.SchemaAttributeTypeConstants; +import org.apache.tuscany.das.ldap.schema.constants.SchemaObjectClassConstants; +import org.apache.tuscany.das.ldap.testing.constants.DASTestingConstants; + +public abstract class AbstractTestSetup +extends ADSEmbeddedHotPartitionTemplate +implements +EnumeratedSchemaAttributeTypeValues, +SchemaAttributeTypeConstants, +AttributeTypeConstants, +SchemaObjectClassConstants, +ObjectClassConstants, +DASConstants, +DASTestingConstants +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws Exception + { + super.setUp(); + + dasPartitionContext = + connect("das"); + + schemaPartitionContext = + connect("schema"); + } + + protected LdapContext schemaPartitionContext = + null; + + protected LdapContext dasPartitionContext = + null; + + protected static final String SYNTAXES_CONTEXT_RDN = + OU + "=" + SYNTAXES_CONTEXT_NAME; + + protected static final String SYNTAX_CHECKERS_CONTEXT_RDN = + OU + "=" + SYNTAX_CHECKERS_CONTEXT_NAME; + + protected static final String ATTRIBUTE_TYPES_CONTEXT_RDN = + OU + "=" + ATTRIBUTE_TYPES_CONTEXT_NAME; + + protected static final String OBJECT_CLASSES_CONTEXT_RDN = + OU + "=" + OBJECT_CLASSES_CONTEXT_NAME; + + + + protected static final String XSD_CONTEXT_RDN = + CN + "=" + XSD_CONTEXT_NAME; + protected static final String DAS_CONTEXT_RDN = + CN + "=" + DAS_CONTEXT_NAME; + protected static final String ECORE_CONTEXT_RDN = + CN + "=" + ECORE_CONTEXT_NAME; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetupTest.java new file mode 100644 index 0000000000..6477225e1c --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetupTest.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; + +public class AbstractTestSetupTest +extends AbstractTestSetup +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws Exception + { + super.setUp(); + dasPartitionContext = + connect("das"); + schemaPartitionContext = + connect("schema"); + } + + public void testConnect() throws NamingException + { + assertNotNull(dasPartitionContext); + assertNotNull(schemaPartitionContext); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetup.java new file mode 100644 index 0000000000..fafd0144fb --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetup.java @@ -0,0 +1,47 @@ +package org.apache.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; +import javax.naming.directory.DirContext; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.create.InitialContextCreator; +import org.apache.tuscany.das.ldap.create.MetaContextCreator; +import org.apache.tuscany.das.ldap.destroy.InitialContextDestroyer; +import org.apache.tuscany.das.ldap.destroy.MetaContextDestroyer; + +public class DASContextSetup +extends AbstractTestSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + MetaContextDestroyer. + destroy( modelContext ); + + InitialContextDestroyer. + destroy( + modelContext, + dasPartitionContext ); + super.tearDown(); + + dasPartitionContext.close(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + modelContext = + InitialContextCreator. + create( + xsdNamespace, + dasPartitionContext); + + metaContext = + MetaContextCreator. + create( modelContext); + } + + protected LdapContext modelContext = null; + protected LdapContext metaContext = null; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetupTest.java new file mode 100644 index 0000000000..d6ecc250c6 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetupTest.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class DASContextSetupTest +extends DASContextSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void testModelContext() throws NamingException + { + assertNotNull(modelContext); + assertEquals( + "cn=accounts,cn=users,cn=example,cn=com,ou=das", + modelContext.getNameInNamespace()); + } + + public void testMetaContext() throws NamingException + { + assertNotNull(metaContext); + assertEquals("cn=meta,cn=accounts,cn=users,cn=example,cn=com,ou=das", + metaContext.getNameInNamespace()); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetup.java new file mode 100644 index 0000000000..da620aaf34 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetup.java @@ -0,0 +1,191 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; +import javax.naming.directory.DirContext; +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.schema.create.ComplexTypeRDNCreator; +import org.apache.tuscany.das.ldap.schema.create.SimpleTypeRDNCreator; + +public class DASSchemaContextsSetup +extends AbstractTestSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + dasSyntaxesContext.close(); + + dasSchemaSubContext.destroySubcontext( + SYNTAXES_CONTEXT_RDN ); + + dasAttributeTypesContext.close(); + + dasSchemaSubContext.destroySubcontext( + ATTRIBUTE_TYPES_CONTEXT_RDN ); + + dasSchemaSubContext.destroySubcontext( + OBJECT_CLASSES_CONTEXT_RDN ); + + dasSchemaSubContext.close(); + + schemaPartitionContext.destroySubcontext( + DAS_CONTEXT_RDN ); + + schemaPartitionContext.close(); + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + dasSchemaSubContext = + createDasSchemaSubContext(); + dasSyntaxesContext = + createDasSyntaxesContext(); + dasAttributeTypesContext = + createDasAttributeTypesContext(); + dasObjectClassesContext = + createDasObjectClassesContext(); + + mComplexMayRDN = + SimpleTypeRDNCreator.create( + TUSCANY_OID_PREFIX_VALUE, + DAS_XSD_NAMESPACE, + M_META_TOP_SDO_OBJECT_CLASS, + M_COMPLEX_MAY); + + mComplexMustRDN = + SimpleTypeRDNCreator.create( + TUSCANY_OID_PREFIX_VALUE, + DAS_XSD_NAMESPACE, + M_META_TOP_SDO_OBJECT_CLASS, + M_COMPLEX_MUST); + + idRDN = + SimpleTypeRDNCreator.create( + TUSCANY_OID_PREFIX_VALUE, + DAS_XSD_NAMESPACE, + M_META_TOP_SDO_OBJECT_CLASS, + ID); + + metaTopSDORDN = + ComplexTypeRDNCreator.create( + TUSCANY_OID_PREFIX_VALUE, + DAS_XSD_NAMESPACE, + M_META_TOP_SDO_OBJECT_CLASS); + } + + private DirContext createDasSchemaSubContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(META_SCHEMA); + + Attribute ecoreAttribute = new BasicAttribute( + CN, + DAS_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return schemaPartitionContext.createSubcontext( + DAS_CONTEXT_RDN, contextAttributes ); + } + + private DirContext createDasAttributeTypesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + ATTRIBUTE_TYPES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return dasSchemaSubContext.createSubcontext( + ATTRIBUTE_TYPES_CONTEXT_RDN, contextAttributes ); + } + + private DirContext createDasSyntaxesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + SYNTAXES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return dasSchemaSubContext.createSubcontext( + SYNTAXES_CONTEXT_RDN, contextAttributes ); + } + + private DirContext createDasObjectClassesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute attributeTypes = new BasicAttribute( + OU, + OBJECT_CLASSES_CONTEXT_NAME); + + contextAttributes.put( attributeTypes ); + contextAttributes.put( objectClassAttribute ); + + return dasSchemaSubContext.createSubcontext( + OBJECT_CLASSES_CONTEXT_RDN, + contextAttributes ); + } + + protected DirContext dasSchemaSubContext = null; + protected DirContext dasAttributeTypesContext = null; + protected DirContext dasSyntaxesContext = null; + protected DirContext dasObjectClassesContext = null; + + protected String mComplexMayRDN = null; + protected String mComplexMustRDN = null; + protected String idRDN = null; + protected String metaTopSDORDN = null; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetupTest.java new file mode 100644 index 0000000000..9adbe07463 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetupTest.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class DASSchemaContextsSetupTest +extends DASSchemaContextsSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void testCreateDASSchemaSubContext() + { + assertNotNull(dasSchemaSubContext); + } + + public void testCreateDasAttributeTypesContext() + { + assertNotNull(dasAttributeTypesContext); + } + + public void testCreateDasSyntaxesContext() + { + assertNotNull(dasSyntaxesContext); + } + + public void testCreateDasObjectClassesContext() + { + assertNotNull(dasObjectClassesContext); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetup.java new file mode 100644 index 0000000000..4fdaaea4b2 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetup.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.create.InitialContextCreator; +import org.apache.tuscany.das.ldap.create.MetaContextCreator; +import org.apache.tuscany.das.ldap.destroy.InitialContextDestroyer; +import org.apache.tuscany.das.ldap.destroy.MetaContextDestroyer; + +/* + * TODO Document that the name of a root object cannot be "meta" + * TODO Change "meta" to meta-inf + */ +public class EcoreSchemaAndDASContextsSetup +extends EcoreSchemaContextsSetup +implements DASConstants +{ + public void tearDown() + throws NamingException, Exception + { + MetaContextDestroyer. + destroy( rootContext ); + + InitialContextDestroyer. + destroy( + rootContext, + dasPartitionContext ); + + super.tearDown(); + + dasPartitionContext.close(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + + rootContext = + (LdapContext) + InitialContextCreator. + create( + xsdNamespace, + dasPartitionContext); + + metaContext = + (LdapContext) + MetaContextCreator. + create( rootContext); + } + + protected LdapContext rootContext = null; + protected LdapContext metaContext = null; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetupTest.java new file mode 100644 index 0000000000..e272262998 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetupTest.java @@ -0,0 +1,56 @@ +package org.apache.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class EcoreSchemaAndDASContextsSetupTest +extends EcoreSchemaAndDASContextsSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void testConnect() + { + assertNotNull(schemaPartitionContext); + } + + public void testCreateEcoreSchemaSubContext() + { + assertNotNull(ecoreSchemaSubContext); + } + + public void testCreateEcoreObjectClassesContext() + { + assertNotNull(ecoreObjectClassesContext); + } + + public void testCreateEcoreAttributeTypesContext() + { + assertNotNull(ecoreAttributeTypesContext); + } + + public void testCreateEcoreSyntaxesContext() + { + assertNotNull(ecoreSyntaxesContext); + } + + public void testCreateDasModelContext() + { + assertNotNull(rootContext); + } + + public void testCreateDasMetaContext() + { + assertNotNull(metaContext); + } + +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetup.java new file mode 100644 index 0000000000..88bd21f318 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetup.java @@ -0,0 +1,201 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class EcoreSchemaContextsSetup +extends AbstractTestSetup +implements DASConstants +{ + public void tearDown() + throws NamingException, Exception + { + ecoreSyntaxesContext. + close(); + + ecoreSchemaSubContext. + destroySubcontext( + SYNTAXES_CONTEXT_RDN ); + + ecoreSyntaxCheckersContext. + close(); + + ecoreSchemaSubContext. + destroySubcontext( + SYNTAX_CHECKERS_CONTEXT_RDN ); + + ecoreAttributeTypesContext. + close(); + ecoreSchemaSubContext. + destroySubcontext( + ATTRIBUTE_TYPES_CONTEXT_RDN ); + + ecoreObjectClassesContext. + close(); + + ecoreSchemaSubContext. + destroySubcontext( + OBJECT_CLASSES_CONTEXT_RDN ); + + ecoreSchemaSubContext. + close(); + schemaPartitionContext. + destroySubcontext( + ECORE_CONTEXT_RDN ); + + schemaPartitionContext.close(); + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + ecoreSchemaSubContext = createEcoreSchemaSubContext(); + ecoreSyntaxesContext = createEcoreSyntaxesContext(); + ecoreSyntaxCheckersContext = createEcoreSyntaxCheckersContext(); + ecoreObjectClassesContext = createEcoreObjectClassesContext(); + ecoreAttributeTypesContext = createEcoreAttributeTypesContext(); + } + + private LdapContext createEcoreSchemaSubContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(META_SCHEMA); + + Attribute ecoreAttribute = new BasicAttribute( + CN, + ECORE_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return (LdapContext) + schemaPartitionContext.createSubcontext( + ECORE_CONTEXT_RDN, contextAttributes ); + } + + + private LdapContext createEcoreObjectClassesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + OBJECT_CLASSES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return (LdapContext) + ecoreSchemaSubContext.createSubcontext( + OBJECT_CLASSES_CONTEXT_RDN, contextAttributes ); + } + + + + private LdapContext createEcoreAttributeTypesContext() + throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + ATTRIBUTE_TYPES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return (LdapContext) + ecoreSchemaSubContext.createSubcontext( + ATTRIBUTE_TYPES_CONTEXT_RDN, contextAttributes ); + } + + private LdapContext createEcoreSyntaxesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + SYNTAXES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return (LdapContext) + ecoreSchemaSubContext.createSubcontext( + SYNTAXES_CONTEXT_RDN, contextAttributes ); + } + + private LdapContext createEcoreSyntaxCheckersContext() + throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + SYNTAX_CHECKERS_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return (LdapContext) + ecoreSchemaSubContext.createSubcontext( + SYNTAX_CHECKERS_CONTEXT_RDN, + contextAttributes); + } + + protected LdapContext ecoreSchemaSubContext = null; + protected LdapContext ecoreObjectClassesContext = null; + protected LdapContext ecoreAttributeTypesContext = null; + protected LdapContext ecoreSyntaxesContext = null; + protected LdapContext ecoreSyntaxCheckersContext = null; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetupTest.java new file mode 100644 index 0000000000..f2c746dceb --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetupTest.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class EcoreSchemaContextsSetupTest +extends EcoreSchemaContextsSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void testCreateEcoreSchemaSubContext() + { + assertNotNull(ecoreSchemaSubContext); + } + + public void testCreateEcoreObjectClassesContext() + { + assertNotNull(ecoreObjectClassesContext); + } + + public void testCreateEcoreAttributeTypesContext() + { + assertNotNull(ecoreAttributeTypesContext); + } + + public void testCreateEcoreSyntaxesContext() + { + assertNotNull(ecoreSyntaxesContext); + } + + public void testCreateEcoreSyntaxCheckersContext() + { + assertNotNull(ecoreSyntaxCheckersContext); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetup.java new file mode 100644 index 0000000000..619bc7a94f --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetup.java @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class XSDSchemaContextsSetup +extends AbstractTestSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + xsdSyntaxesContext. + close(); + + xsdContext. + destroySubcontext( + SYNTAXES_CONTEXT_RDN ); + + xsdContext. + close(); + + schemaPartitionContext. + destroySubcontext( + XSD_CONTEXT_RDN ); + + schemaPartitionContext. + close(); + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + xsdContext = + createXsdContext(); + xsdSyntaxesContext = + createXsdSyntaxesContext(); + } + + private LdapContext createXsdContext() throws NamingException + { + Attributes contextAttributes = + new BasicAttributes(); + + Attribute objectClassAttribute = + new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(META_SCHEMA); + + Attribute ecoreAttribute = + new BasicAttribute( + CN, + XSD_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return (LdapContext) schemaPartitionContext.createSubcontext( + XSD_CONTEXT_RDN, contextAttributes ); + } + + private LdapContext createXsdSyntaxesContext() throws NamingException + { + Attributes contextAttributes = + new BasicAttributes(); + + Attribute objectClassAttribute = + new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = + new BasicAttribute( + OU, + SYNTAXES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return (LdapContext) xsdContext.createSubcontext( + SYNTAXES_CONTEXT_RDN, contextAttributes ); + } + protected LdapContext xsdContext = + null; + protected LdapContext xsdSyntaxCheckersContext = + null; + protected LdapContext xsdSyntaxesContext = + null; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetupTest.java new file mode 100644 index 0000000000..24ce5e6df1 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetupTest.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class XSDSchemaContextsSetupTest +extends XSDSchemaContextsSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void testCreateXsdContext() + { + assertNotNull(xsdContext); + } + + public void testCreateXsdSyntaxesContext() + { + assertNotNull(xsdSyntaxesContext); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/DataTypeToADSSyntaxMapProvider.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/DataTypeToADSSyntaxMapProvider.java new file mode 100644 index 0000000000..8bd50fb4cc --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/DataTypeToADSSyntaxMapProvider.java @@ -0,0 +1,54 @@ +package org.apache.tuscany.das.ldap.schema.emf.create; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.tuscany.das.ldap.constants.SyntaxOIDValues; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EcorePackage; + +public class DataTypeToADSSyntaxMapProvider +implements SyntaxOIDValues { + + EcorePackage ecorePackage = + EcorePackage.eINSTANCE; + + private static Map<EDataType, String> dataTypeToADSSyntaxOIDMap = null; + + //TODO Make this a singleton + public DataTypeToADSSyntaxMapProvider() + { + dataTypeToADSSyntaxOIDMap = new HashMap<EDataType, String>(); + create(); + } + + public Map<EDataType, String> getDataTypeToADSSyntaxMap() + { + return dataTypeToADSSyntaxOIDMap; + } + + private Map<EDataType, String> create() + { + dataTypeToADSSyntaxOIDMap.put( + ecorePackage.getEString(), + SYNTAX_STRING_OID_VALUE); + + dataTypeToADSSyntaxOIDMap.put( + ecorePackage.getEInt(), + SYNTAX_INTEGER_OID_VALUE); + + dataTypeToADSSyntaxOIDMap.put( + ecorePackage.getEIntegerObject(), + SYNTAX_INTEGER_OID_VALUE); + + dataTypeToADSSyntaxOIDMap.put( + ecorePackage.getEBoolean(), + SYNTAX_BOOLEAN_OID_VALUE); + + dataTypeToADSSyntaxOIDMap.put( + ecorePackage.getEBooleanObject(), + SYNTAX_BOOLEAN_OID_VALUE); + + return dataTypeToADSSyntaxOIDMap; + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EAttributeTypeCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EAttributeTypeCreator.java new file mode 100644 index 0000000000..5b8e65c221 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EAttributeTypeCreator.java @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.emf.create; + +import javax.naming.NamingException; +import javax.naming.directory.DirContext; + +import org.apache.tuscany.das.ldap.schema.create.AbstractAttributeTypeCreator; +import org.apache.tuscany.das.ldap.schema.create.SimpleTypeRDNCreator; +import org.apache.tuscany.das.ldap.schema.emf.provide.SyntaxOIDProvider; +import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer; +import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; + +public class EAttributeTypeCreator +extends AbstractAttributeTypeCreator +{ + public EAttributeTypeCreator() + { + super(); + } + /** + * Create. + * + * @param oidPrefix the oid prefix + * @param eAttribute the e attribute + * @param attributeTypesContext the attribute types context + * + * @throws Exception the exception + * @throws NamingException the naming exception + */ + public void create( + DirContext attributeTypesContext, + EAttribute eAttribute, + String oidPrefix) + throws NamingException, Exception + { + String eAttributeName = + eAttribute.getName(); + + EClass eContainingClass = + eAttribute.getEContainingClass(); + + String eContainingClassName = + eContainingClass.getName(); + + String namespaceURI = + eContainingClass. + getEPackage().getNsURI(); + + String qualifiedEAttributeNameURI = + SimpleTypeNamespaceQualifier.qualify( + namespaceURI, + eContainingClassName, + eAttributeName); + + String normalizedEAttributeName = + QualifiedNameNormalizer. + normalize(qualifiedEAttributeNameURI); + + EClassifier eDataType = + eAttribute.getEType(); + + SyntaxOIDProvider dataTypeToADSSyntaxMapProvider = + new SyntaxOIDProvider(); + + String syntaxOID = + dataTypeToADSSyntaxMapProvider. + getSyntaxOID(eDataType); + + basicAttributes.put( + M_DESCRIPTION, + eAttributeName); + + basicAttributes.put( + M_SYNTAX, + syntaxOID); + + basicAttributes.put( + M_NAME, + normalizedEAttributeName ); + + String rdn = + SimpleTypeRDNCreator.create( + oidPrefix, + namespaceURI, + eContainingClassName, + eAttributeName); + + attributeTypesContext.createSubcontext( + rdn, + basicAttributes); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreator.java new file mode 100644 index 0000000000..684509e0d9 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreator.java @@ -0,0 +1,202 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.ldap.schema.emf.create; + +import java.util.List; + +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.DirContext; + +import org.apache.tuscany.das.ldap.schema.create.AbstractTypeCreator; +import org.apache.tuscany.das.ldap.schema.create.ComplexTypeRDNCreator; +import org.apache.tuscany.das.ldap.util.ComplexTypeNamespaceQualifier; +import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer; +import org.eclipse.emf.ecore.EClass; + +public class EObjectClassCreator +extends AbstractTypeCreator +{ + public EObjectClassCreator() + { + super(); + } + /** + * Create. + * + * @param oidPrefix the oid prefix + * @param eAttribute the e attribute + * @param attributeTypesContext the attribute types context + * + * @throws Exception the exception + * @throws NamingException the naming exception + * + * Note that null can passed for the processedEClassifiers list + * only when the EClass has not parents. + */ + public void create( + DirContext metaContext, + DirContext attributeTypesContext, + DirContext objectClassesContext, + EClass eClass, + List<EClass> processedEClassifiers, + String oidPrefix) + throws NamingException, Exception + { + if ( processedEClassifiers != null ) + { + EClass eClassParent = + EcoreTypeSystemHelper. + getEClassParent( eClass ); + + if (eClassParent != null) + { + boolean isEClassProcessed = + EObjectClassCreatorHelper. + isEClassProcessed( + eClassParent, + processedEClassifiers); + + if (!isEClassProcessed) + { + this.create( + metaContext, + attributeTypesContext, + objectClassesContext, + eClassParent, + processedEClassifiers, + oidPrefix); + } + } + } + + objectClassAttribute.add( META_OBJECT_CLASS ); + + EcoreTypeSystemHelper. + createAttributeTypes( + attributeTypesContext, + eClass, + oidPrefix ); + + String namespaceURI = + eClass.getEPackage(). + getNsURI(); + + String qualifiedEClassNameURI = + ComplexTypeNamespaceQualifier. + qualify( + namespaceURI, + eClass.getName()); + + String normalizedEObjectName = + QualifiedNameNormalizer. + normalize(qualifiedEClassNameURI); + + + basicAttributes.put( + M_NAME, + normalizedEObjectName ); + + basicAttributes.put( + M_DESCRIPTION, + eClass.getName() ); + + basicAttributes.put( + M_OBSOLETE, + LDAP_FALSE ); + + //TODO Remember to test with parent combination. + EObjectClassCreatorHelper. + addParentAttribute( + basicAttributes, + namespaceURI, + eClass ); + + if (!eClass.isAbstract()) + { + basicAttributes.put( + M_TYPE_OBJECT_CLASS, + STRUCTURAL ); + } + else + { + basicAttributes.put( + M_TYPE_OBJECT_CLASS, + ABSTRACT ); + } + + + /* + EObjectClassCreatorHelper. + addEAttributes( + basicAttributes, + namespaceURI, + eClass ); + + EObjectClassCreatorHelper. + addEReferences( + basicAttributes, + namespaceURI, + eClass ); + */ + + + EObjectClassCreatorHelper. + addEStructuralFeatures( + basicAttributes, + namespaceURI, + eClass ); + + String rdn = + ComplexTypeRDNCreator. + create( + oidPrefix, + namespaceURI, + eClass.getName()); + + EObjectClassCreatorHelper. + createInheritanceMetaData( + metaContext, + eClass ); + + /* TODO - Remove once everything is simmered down + NamingEnumeration namingEnumeration = + basicAttributes.getAll(); + + while (namingEnumeration.hasMore()) + { + Attribute attribute = (Attribute) namingEnumeration.next(); + System.out.println(attribute); + } + */ + + + objectClassesContext. + createSubcontext( + rdn, + basicAttributes ); + + + if ( processedEClassifiers != null ) + { + processedEClassifiers.add(eClass); + } + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreatorHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreatorHelper.java new file mode 100644 index 0000000000..2a99ef8fb8 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EObjectClassCreatorHelper.java @@ -0,0 +1,378 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.ldap.schema.emf.create; + +import java.util.Iterator; +import java.util.List; + +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.DirContext; + +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants; +import org.apache.tuscany.das.ldap.schema.constants.EnumeratedSchemaAttributeTypeValues; +import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants; +import org.apache.tuscany.das.ldap.schema.constants.SchemaAttributeTypeConstants; +import org.apache.tuscany.das.ldap.schema.constants.SchemaObjectClassConstants; +import org.apache.tuscany.das.ldap.util.ComplexTypeNamespaceQualifier; +import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer; +import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; + +/** + * The Class EObjectClassCreatorHelper. + */ +public class EObjectClassCreatorHelper +implements +EnumeratedSchemaAttributeTypeValues, +SchemaAttributeTypeConstants, +AttributeTypeConstants, +SchemaObjectClassConstants, +ObjectClassConstants, +DASConstants +{ + /** + * Adds the parent attribute. + * + * @param namespaceURI the namespace URI + * @param objectClassAttributes the object class attributes + * @param eClass the e class + */ + public static void addParentAttribute( + Attributes objectClassAttributes, + String namespaceURI, + EClass eClass) + { + EClass eClassParent = + EcoreTypeSystemHelper.getEClassParent( eClass ); + + if(eClassParent !=null) + { + String qualifiedEClassParentNameURI = + ComplexTypeNamespaceQualifier. + qualify( + namespaceURI, + eClassParent. + getName()); + + String normalizedEObjectName = + QualifiedNameNormalizer. + normalize(qualifiedEClassParentNameURI); + + objectClassAttributes.put( + M_SUP_OBJECT_CLASS, + normalizedEObjectName); + } + else + { + objectClassAttributes.put( + M_SUP_OBJECT_CLASS, + META_OBJECT_CLASS ); + } + } + + /** + * Adds the E attributes. + * + * @param namespaceURI the namespace URI + * @param objectClassAttributes the object class attributes + * @param eClass the e class + */ + public static void addEAttributes( + Attributes objectClassAttributes, + String namespaceURI, + EClass eClass) + { + List<EAttribute> eAttributes = + eClass.getEAttributes(); + + Iterator<EAttribute> eAttributeIterator = + eAttributes.iterator(); + + EAttribute eAttribute = + null; + + String qualifiedEAttributeName = + null; + + Attribute mMayAttribute = + null; + + Attribute mMustAttribute = + null; + + while( eAttributeIterator.hasNext()) + { + eAttribute = eAttributeIterator.next(); + + qualifiedEAttributeName = + SimpleTypeNamespaceQualifier. + qualify( + namespaceURI, + eClass.getName(), + eAttribute.getName()); + + String normalizedEAttributeName = + QualifiedNameNormalizer. + normalize(qualifiedEAttributeName); + + if (!eAttribute.isRequired()) + { + if (mMayAttribute == null) + { + mMayAttribute = new BasicAttribute(M_MAY); + } + mMayAttribute.add(normalizedEAttributeName); + } + else + { + if (mMustAttribute == null) + { + mMustAttribute = new BasicAttribute(M_MUST); + } + mMustAttribute.add(normalizedEAttributeName); + } + } + + if (mMayAttribute != null) + { + objectClassAttributes.put( mMayAttribute ); + } + if (mMustAttribute != null) + { + objectClassAttributes.put( mMustAttribute ); + } + } + + /** + * Adds the E references. + * + * @param namespaceURI the namespace URI + * @param objectClassAttributes the object class attributes + * @param eClass the e class + */ + public static void addEReferences( + Attributes objectClassAttributes, + String namespaceURI, + EClass eClass) + { + List<EReference> eReferences = + eClass.getEReferences(); + + Iterator<EReference> eReferenceIterator = + eReferences.iterator(); + + EReference eReference = + null; + + String qualifiedEReferenceName = + null; + + Attribute mMayAttribute = + null; + + Attribute mMustAttribute = + null; + + while ( eReferenceIterator.hasNext()) + { + eReference = eReferenceIterator.next(); + + qualifiedEReferenceName = + SimpleTypeNamespaceQualifier. + qualify( + namespaceURI, + eClass.getName(), + eReference.getName()); + + String normalizedEReferenceName = + QualifiedNameNormalizer. + normalize(qualifiedEReferenceName); + + if (!eReference.isRequired()) + { + if (mMayAttribute == null) + { + mMayAttribute = new BasicAttribute(M_MAY); + } + mMayAttribute.add( normalizedEReferenceName ); + } + else + { + if (mMustAttribute == null) + { + mMustAttribute = new BasicAttribute(M_MUST); + } + mMustAttribute.add( normalizedEReferenceName ); + } + } + if (mMayAttribute != null) + { + objectClassAttributes.put( mMayAttribute ); + } + if (mMustAttribute != null) + { + objectClassAttributes.put( mMustAttribute ); + } + } + + /** + * Adds the E references. + * + * @param namespaceURI the namespace URI + * @param objectClassAttributes the object class attributes + * @param eClass the e class + */ + public static void addEStructuralFeatures( + Attributes objectClassAttributes, + String namespaceURI, + EClass eClass) + { + List<EStructuralFeature> eStructuralFeatures = + eClass.getEStructuralFeatures(); + + Iterator<EStructuralFeature> eStructuralFeatureIterator = + eStructuralFeatures.iterator(); + + EStructuralFeature eStructuralFeature = + null; + + String qualifiedEStructuralFeatureName = + null; + + Attribute mMayAttribute = + null; + + Attribute mMustAttribute = + null; + + while ( eStructuralFeatureIterator.hasNext()) + { + eStructuralFeature = + eStructuralFeatureIterator.next(); + + qualifiedEStructuralFeatureName = + SimpleTypeNamespaceQualifier. + qualify( + namespaceURI, + eClass.getName(), + eStructuralFeature.getName()); + + String normalizedEStructuralFeatureName = + QualifiedNameNormalizer. + normalize(qualifiedEStructuralFeatureName); + + + if (!eStructuralFeature.isRequired()) + { + if (mMayAttribute == null) + { + mMayAttribute = new BasicAttribute(M_MAY); + } + mMayAttribute.add( normalizedEStructuralFeatureName ); + } + else + { + if (mMustAttribute == null) + { + mMustAttribute = new BasicAttribute(M_MUST); + } + mMustAttribute.add( normalizedEStructuralFeatureName ); + } + } + if (mMayAttribute != null) + { + objectClassAttributes.put( mMayAttribute ); + } + if (mMustAttribute != null) + { + objectClassAttributes.put( mMustAttribute ); + } + + } + + + /** + * Checks if is E class processed. + * + * @param processedEClassifiers the processed E classifiers + * @param eClass the e class + * + * @return true, if is E class processed + */ + public static boolean isEClassProcessed( + EClass eClass, + List<EClass> processedEClassifiers) + { + return processedEClassifiers.contains( eClass ); + } + + /** + * Creates the inheritance meta data. + * + * @param metaContext the das model meta context + * @param eClass the e class + * + * @throws NamingException the naming exception + */ + public static void createInheritanceMetaData( + DirContext metaContext, + EClass eClass) + throws NamingException + { + EClass eClassParent = + EcoreTypeSystemHelper.getEClassParent( eClass ); + + String rdn = null; + + if (eClassParent != null) + { + DirContext eClassParentMetaContext = + null; + try + { + eClassParentMetaContext = + ( DirContext ) + metaContext. + lookup(eClassParent.getName()); + } + catch ( NamingException e ) + { + rdn = + CN + "=" + eClassParent.getName(); + + eClassParentMetaContext = + ( DirContext ) + metaContext. + createSubcontext( rdn ); + } + + rdn = CN + "=" + eClass.getName(); + + eClassParentMetaContext. + createSubcontext( rdn ); + } + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EReferenceTypeCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EReferenceTypeCreator.java new file mode 100644 index 0000000000..74c7faff71 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EReferenceTypeCreator.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.ldap.schema.emf.create; + +import javax.naming.NamingException; +import javax.naming.directory.DirContext; + +import org.apache.tuscany.das.ldap.constants.SyntaxOIDValues; +import org.apache.tuscany.das.ldap.schema.create.AbstractAttributeTypeCreator; +import org.apache.tuscany.das.ldap.schema.create.SimpleTypeRDNCreator; +import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer; +import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EReference; + +public class EReferenceTypeCreator +extends AbstractAttributeTypeCreator +implements SyntaxOIDValues +{ + public EReferenceTypeCreator() + { + super(); + } + + public void create( + DirContext attributeTypesContext, + EReference eReference, + String oidPrefix) + throws NamingException, Exception + { + String eReferenceName = + eReference.getName(); + + EClass eContainingClass = + eReference.getEContainingClass(); + + String eContainingClassName = + eContainingClass.getName(); + + String namespaceURI = + eContainingClass. + getEPackage(). + getNsURI(); + + String qualifiedEReferenceNameURI = + SimpleTypeNamespaceQualifier.qualify( + namespaceURI, + eContainingClassName, + eReferenceName); + + + String normalizedEReferenceName = + QualifiedNameNormalizer. + normalize(qualifiedEReferenceNameURI); + + basicAttributes.put( + M_DESCRIPTION, + eReferenceName); + + basicAttributes.put( + M_SYNTAX, + SYNTAX_STRING_OID_VALUE); + + basicAttributes.put( + M_NAME, + normalizedEReferenceName ); + + String rdn = + SimpleTypeRDNCreator.create( + oidPrefix, + namespaceURI, + eContainingClassName, + eReferenceName); + + attributeTypesContext.createSubcontext( + rdn, + basicAttributes); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EcoreTypeSystemHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EcoreTypeSystemHelper.java new file mode 100644 index 0000000000..b9e8fac0fa --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/EcoreTypeSystemHelper.java @@ -0,0 +1,388 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.emf.create; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Stack; + +import javax.naming.NamingException; +import javax.naming.directory.DirContext; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.schema.create.SyntaxEntryCreator; +import org.apache.tuscany.das.ldap.schema.emf.destroy.EStructuralFeatureTypeDestroyer; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; + +/** + * The Class EcoreTypeSystemCreatorHelper. + */ +public class EcoreTypeSystemHelper +{ + + /** + * Creates the E data types list. + * + * @param ePackage the e package + * + * @return the list< E data type> + */ + public static List<EDataType> createEDataTypesList( + EPackage ePackage) + { + List<EObject> list = ePackage.eContents(); + List<EDataType> eDataTypes = new ArrayList<EDataType>(); + Iterator<EObject> iterator = list.iterator(); + while (iterator.hasNext()) + { + Object object = iterator.next(); + if (object instanceof EDataType ) + { + eDataTypes.add( ( EDataType ) object ); + } + } + return eDataTypes; + } + + public static void createSyntaxCheckerEntries( + String oidPrefix, + LdapContext syntaxCheckersContext) throws Exception + + { + + } + + /** + * Creates the syntax entries. + * + * @param oidPrefix the oid prefix + * @param eDataTypes the e data types + * @param syntaxesContext the syntaxes context + * + * @throws Exception the exception + */ + public static void createSyntaxEntries( + List<EDataType> eDataTypes, + String oidPrefix, + LdapContext syntaxesContext, + LdapContext syntaxCheckersContext) throws Exception + { + Iterator<EDataType> eDataTypeIterator = + eDataTypes.iterator(); + + String eDataTypeName = + null; + String eDataTypeNamespaceURI = + null; + + while (eDataTypeIterator.hasNext()) + { + EDataType eDataType = + eDataTypeIterator.next(); + eDataTypeName = + eDataType.getName(); + eDataTypeNamespaceURI = + eDataType.getEPackage().getNsURI(); + + SyntaxEntryCreator.create( + oidPrefix, + eDataTypeNamespaceURI, + eDataTypeName, + syntaxesContext, + syntaxCheckersContext); + } + } + + /** + * Creates the E classifiers list. + * + * @param ePackage the e package + * + * @return the list< E class> + */ + public static List<EClass> createEClassifiersList( + EPackage ePackage) + { + List<EObject> list = ePackage.eContents(); + List<EClass> eClassifiers = new ArrayList<EClass>(); + Iterator<EObject> iterator = list.iterator(); + while (iterator.hasNext()) + { + Object object = iterator.next(); + if (object instanceof EClassifier ) + { + eClassifiers.add( ( EClass ) object ); + } + } + return eClassifiers; + } + + /** + * Creates the E classifier entries. + * + * @param eClassifiers the e classifiers + */ + public static void createEClassifierEntries( + List<EClass> eClassifiers) + { + + } + + /** + * Load parent E classifier stack. + * + * @param parentEClassifierStack the parent E classifier stack + * @param eClass the e class + * + * @return the stack< E class> + * + * Note that clients should pass null for the + * parentEClassifierStack argument. The method + * creates the stack when needed, and uses + * it during recursion. + */ + public static Stack<EClass> loadParentEClassifierStack( + EClass eClass, + Stack<EClass> parentEClassifierStack) + { + List<EClass> eClassParents = + eClass.getESuperTypes(); + + if (eClassParents.size() > 0) + { + Iterator<EClass> eClassParentIterator = + eClassParents.iterator(); + + while(eClassParentIterator.hasNext()) + { + EClass parentEClass = + eClassParentIterator.next(); + + if (!parentEClass.isInterface()) + { + if (parentEClassifierStack == null) + { + parentEClassifierStack = new Stack<EClass>(); + } + + parentEClassifierStack.push( parentEClass ); + + eClassParents = parentEClass.getESuperTypes(); + + if (eClassParents.size() == 0) + { + return parentEClassifierStack; + } + else + { + loadParentEClassifierStack( + parentEClass, + parentEClassifierStack ); + } + } + } + } + return parentEClassifierStack; + } + + /** + * Creates the E object class parents. + * + * @param oidPrefix the oid prefix + * @param objectClassesContext the object classes context + * @param eClass the e class + * + * @throws Exception the exception + * @throws NamingException the naming exception + */ + public static void createEObjectClassParents( + DirContext dasModelMetaContext, + DirContext attributeTypesContext, + DirContext objectClassesContext, + EClass eClass, + String oidPrefix) + throws NamingException, Exception + { + Stack<EClass> parentEClassifierStack = + EcoreTypeSystemHelper. + loadParentEClassifierStack( + eClass, + null); + + EClass parentEClass = null; + + for (int i=0; i<parentEClassifierStack.size(); i++) + { + parentEClass = parentEClassifierStack.pop(); + + EObjectClassCreator + eObjectClassCreator = + new EObjectClassCreator(); + + eObjectClassCreator.create( + dasModelMetaContext, + attributeTypesContext, + objectClassesContext, + parentEClass, + null, + oidPrefix); + } + } + + /** + * Creates the attribute types. + * + * @param oidPrefix the oid prefix + * @param eClass the e class + * @param attributeTypesContext the attribute types context + * + * @throws Exception the exception + * @throws NamingException the naming exception + */ + public static void createAttributeTypes( + DirContext attributeTypesContext, + EClass eClass, + String oidPrefix) + throws NamingException, Exception + { + List<EAttribute> eAttributes = + eClass.getEAttributes(); + + Iterator<EAttribute> eAttributeIterator = + eAttributes.iterator(); + + while (eAttributeIterator.hasNext()) + { + EAttribute eAttribute = eAttributeIterator.next(); + + EAttributeTypeCreator + eAttributeTypeCreator = + new EAttributeTypeCreator(); + + eAttributeTypeCreator.create( + attributeTypesContext, + eAttribute, + oidPrefix ); + } + + List<EReference> eReferences = + eClass.getEReferences(); + + Iterator<EReference> eReferenceIterator = + eReferences.iterator(); + + while(eReferenceIterator.hasNext()) + { + EReference eReference = + eReferenceIterator. + next(); + + EReferenceTypeCreator + eReferenceTypeCreator = + new EReferenceTypeCreator(); + + eReferenceTypeCreator.create( + attributeTypesContext, + eReference, + oidPrefix); + } + } + + /** + * Destroy attribute types. + * + * @param oidPrefix the oid prefix + * @param eClass the e class + * @param attributeTypesContext the attribute types context + * + * @throws Exception the exception + * @throws NamingException the naming exception + */ + public static void destroyAttributeTypes( + DirContext attributeTypesContext, + EClass eClass, + String oidPrefix) + throws NamingException, Exception + { + List<EStructuralFeature> + eStructuralFeatures = + eClass. + getEStructuralFeatures(); + + Iterator<EStructuralFeature> + eStructuralFeatureIterator = + eStructuralFeatures.iterator(); + + while (eStructuralFeatureIterator.hasNext()) + { + EStructuralFeature + eStructuralFeature = + eStructuralFeatureIterator.next(); + + EStructuralFeatureTypeDestroyer.destroy( + attributeTypesContext, + eStructuralFeature, + oidPrefix ); + } + } + + /** + * Gets the E class parent. + * + * @param eClass the e class + * + * @return the e class parent + */ + public static EClass getEClassParent(EClass eClass) + { + List<EClass> eClassParents = + eClass.getESuperTypes(); + + if (eClassParents.size() > 0) + { + Iterator<EClass> eClassParentIterator = + eClassParents.iterator(); + + while(eClassParentIterator.hasNext()) + { + EClass parentEClass = + eClassParentIterator.next(); + + if (!parentEClass.isInterface()) + { + return parentEClass; + } + else + { + return null; + } + } + } + return null; + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/ModelTypeSystemCreator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/ModelTypeSystemCreator.java new file mode 100644 index 0000000000..3a92143dc5 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/create/ModelTypeSystemCreator.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.emf.create; + +import java.util.ArrayList; +import java.util.List; + +import javax.naming.ldap.LdapContext; + +import org.eclipse.emf.ecore.EClass; + +public class ModelTypeSystemCreator +{ + private static List<EClass> processedEClassifiers = + new ArrayList<EClass>(); + + public static void create( + LdapContext dasModelMetaContext, + LdapContext attributeTypesContext, + LdapContext objectClassesContext, + List<EClass> eClassifiers, + String oidPrefix) + throws Exception + { + EObjectClassCreator eObjectClassCreator = + new EObjectClassCreator(); + + for (EClass eClass : eClassifiers) + { + eObjectClassCreator.create( + dasModelMetaContext, + attributeTypesContext, + objectClassesContext, + eClass, + processedEClassifiers, + oidPrefix ); + } + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/ECascadingObjectClassDestroyer.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/ECascadingObjectClassDestroyer.java new file mode 100644 index 0000000000..1ad3a1eb21 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/ECascadingObjectClassDestroyer.java @@ -0,0 +1,145 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.ldap.schema.emf.destroy; + +import java.util.Map; + +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; +import javax.naming.directory.DirContext; +import javax.naming.directory.SearchResult; + +import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants; +import org.eclipse.emf.ecore.EClass; + +/** + * The Class ECascadingObjectClassDestroyer. + * + * The purose of this class is to destroy a ObjectClass + * that is the parent of other ObjectClass entries. + * + * It first checks to see whether the EClass instance + * is a parent of other EClassifiers by examining + * whether the metaContext contains the EClass + * instance's name. + * + * If the EClass instance has an an metaContext child entry, + * then this instance is a parent of other EClassifiers. + * Therefore we check to see whether there are EClass + * instances left to delete that inherit from this EClass. + * + * If none are left we delete the parentMetaContext entry. + * If there are more children left, we leave the parentMetaContext + * entry in place and delete the children. + * + * If there is no parentMetaEntryContext, it means that this + * EClass instance does not have any children. Therefore it's + * safe to delete the corresponding ObjectClass. + */ +public class ECascadingObjectClassDestroyer +implements AttributeTypeConstants +{ + + + public static void destroy( + Map<String, EClass> eClassNameToEClassMap, + DirContext metaContext, + DirContext attributeTypesContext, + DirContext objectClassesContext, + EClass eClass, + String oidPrefix) + throws NamingException, Exception + { + String rdn = + null; + DirContext eClassParentMetaContext = + null; + try + { + eClassParentMetaContext = + ( DirContext ) + metaContext. + lookup( CN + "=" + eClass.getName() ); + } + catch (Exception e) + { + //This eClass can be deleted, because it is not used a super class. + } + + if (eClassParentMetaContext == null) + { + EObjectClassDestroyer.destroy( + metaContext, + attributeTypesContext, + objectClassesContext, + eClass, + oidPrefix ); + } + else + { + Attributes searchAttributes = + new BasicAttributes(true); + + searchAttributes.put(new BasicAttribute(CN)); + + NamingEnumeration<SearchResult> childEntries = + eClassParentMetaContext.search("", searchAttributes); + + if (childEntries.hasMore()) + { + while (childEntries.hasMore()) + { + SearchResult childEntry = + childEntries.next(); + + Attributes childEntryAttributes = + childEntry.getAttributes(); + + String eClassName = + ( String ) + childEntryAttributes.get( CN ).get(); + + EClass childEClass = + eClassNameToEClassMap.get( eClassName ); + + destroy( + eClassNameToEClassMap, + metaContext, + attributeTypesContext, + objectClassesContext, + childEClass, + oidPrefix ); + + EObjectClassDestroyer.destroy( + metaContext, + attributeTypesContext, + objectClassesContext, + eClass, + oidPrefix ); + + rdn = CN + "=" + eClass.getName(); + metaContext.destroySubcontext( rdn ); + } + } + } + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EObjectClassDestroyer.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EObjectClassDestroyer.java new file mode 100644 index 0000000000..16c7f893d6 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EObjectClassDestroyer.java @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.ldap.schema.emf.destroy; + +import javax.naming.NamingException; +import javax.naming.directory.DirContext; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants; +import org.apache.tuscany.das.ldap.schema.create.ComplexTypeRDNCreator; +import org.apache.tuscany.das.ldap.schema.emf.create.EcoreTypeSystemHelper; +import org.eclipse.emf.ecore.EClass; + +/** + * The Class EObjectClassDestroyer. + */ +public class EObjectClassDestroyer +implements AttributeTypeConstants +{ + public static void destroy( + DirContext metaContext, + DirContext attributeTypesContext, + DirContext objectClassesContext, + EClass eClass, + String oidPrefix) + throws NamingException, Exception + { + String namespaceURI = + eClass.getEPackage(). + getNsURI(); + + String rdn = + ComplexTypeRDNCreator. + create( + oidPrefix, + namespaceURI, + eClass.getName()); + + objectClassesContext. + destroySubcontext( + rdn); + + EcoreTypeSystemHelper. + destroyAttributeTypes( + attributeTypesContext, + eClass, + oidPrefix ); + + LdapContext parentMetaContext = + null; + + EClass eClassParent = + EcoreTypeSystemHelper. + getEClassParent( eClass ); + + /* + * After destroying the ObjecClass and its attributes + * we must also clean up the meta context. + */ + + if (eClassParent != null) + { + rdn = CN + "=" + eClassParent.getName(); + + parentMetaContext = + ( LdapContext ) + metaContext.lookup( rdn ); + + rdn = CN + "=" + eClass.getName(); + + parentMetaContext.destroySubcontext( rdn ); + } + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EStructuralFeatureTypeDestroyer.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EStructuralFeatureTypeDestroyer.java new file mode 100644 index 0000000000..2d88bc8803 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/destroy/EStructuralFeatureTypeDestroyer.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.ldap.schema.emf.destroy; + +import javax.naming.NamingException; +import javax.naming.directory.DirContext; + +import org.apache.tuscany.das.ldap.schema.create.AbstractAttributeTypeCreator; +import org.apache.tuscany.das.ldap.schema.create.SimpleTypeRDNCreator; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; + +public class EStructuralFeatureTypeDestroyer +extends AbstractAttributeTypeCreator +{ + public static void destroy( + DirContext attributeTypesContext, + EStructuralFeature eStructuralFeature, + String oidPrefix) + throws NamingException, Exception + { + EClass eContainingClass = + eStructuralFeature. + getEContainingClass(); + + String eContainingClassName = + eContainingClass. + getName(); + + String namespaceURI = + eContainingClass. + getEPackage(). + getNsURI(); + + String rdn = + SimpleTypeRDNCreator.create( + oidPrefix, + namespaceURI, + eContainingClassName, + eStructuralFeature.getName()); + + attributeTypesContext.destroySubcontext( + rdn); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/provide/SyntaxOIDProvider.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/provide/SyntaxOIDProvider.java new file mode 100644 index 0000000000..be0da66292 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/emf/provide/SyntaxOIDProvider.java @@ -0,0 +1,62 @@ +package org.apache.tuscany.das.ldap.schema.emf.provide; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.tuscany.das.ldap.constants.SyntaxOIDValues; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EcorePackage; + +public class SyntaxOIDProvider +implements SyntaxOIDValues { + + private static Map<EClassifier, String> dataTypeToADSSyntaxOIDMap = null; + + private EcorePackage ecorePackage = EcorePackage.eINSTANCE; + + //TODO Make this a singleton + public SyntaxOIDProvider() + { + dataTypeToADSSyntaxOIDMap = + new HashMap<EClassifier, String>(); + + this.create(); + ecorePackage = + EcorePackage.eINSTANCE; + } + + public String getSyntaxOID(EClassifier eClassifier) + { + String syntaxOID = dataTypeToADSSyntaxOIDMap.get(eClassifier); + if (syntaxOID == null) + { + return SYNTAX_STRING_OID_VALUE; + } + return syntaxOID; + } + + private Map<EClassifier, String> create() + { + dataTypeToADSSyntaxOIDMap.put( + EcorePackage.eINSTANCE.getEString(), + SYNTAX_STRING_OID_VALUE); + + dataTypeToADSSyntaxOIDMap.put( + EcorePackage.eINSTANCE.getEInt(), + SYNTAX_INTEGER_OID_VALUE); + + dataTypeToADSSyntaxOIDMap.put( + EcorePackage.eINSTANCE.getEIntegerObject(), + SYNTAX_INTEGER_OID_VALUE); + + dataTypeToADSSyntaxOIDMap.put( + EcorePackage.eINSTANCE.getEBoolean(), + SYNTAX_BOOLEAN_OID_VALUE); + + dataTypeToADSSyntaxOIDMap.put( + EcorePackage.eINSTANCE.getEBooleanObject(), + SYNTAX_BOOLEAN_OID_VALUE); + + return dataTypeToADSSyntaxOIDMap; + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/AbstractTestSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/AbstractTestSetup.java new file mode 100644 index 0000000000..95bbd23f8b --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/AbstractTestSetup.java @@ -0,0 +1,50 @@ + +package org.apache.tuscany.das.ldap.schema.setup.test; + +import javax.naming.directory.DirContext; +import javax.naming.ldap.LdapContext; + +import org.apache.directory.apacheds.testing.setup.JNDIConnectionTemplate; +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants; +import org.apache.tuscany.das.ldap.schema.constants.EnumeratedSchemaAttributeTypeValues; +import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants; +import org.apache.tuscany.das.ldap.schema.constants.SchemaAttributeTypeConstants; +import org.apache.tuscany.das.ldap.schema.constants.SchemaObjectClassConstants; + +public abstract class AbstractTestSetup +extends JNDIConnectionTemplate +implements +EnumeratedSchemaAttributeTypeValues, +SchemaAttributeTypeConstants, +AttributeTypeConstants, +SchemaObjectClassConstants, +ObjectClassConstants, +DASConstants +{ + protected LdapContext schemaContext = + null; + + protected static String PROVIDER_URL_VALUE = + "ldap://localhost:10389/ou=schema"; + + protected static final String SYNTAXES_CONTEXT_RDN = + OU + "=" + SYNTAXES_CONTEXT_NAME; + + protected static final String ATTRIBUTE_TYPES_CONTEXT_RDN = + OU + "=" + ATTRIBUTE_TYPES_CONTEXT_NAME; + + protected static final String OBJECT_CLASSES_CONTEXT_RDN = + OU + "=" + OBJECT_CLASSES_CONTEXT_NAME; + + protected static final String XSD_CONTEXT_RDN = + CN + "=" + XSD_CONTEXT_NAME; + protected static final String DAS_CONTEXT_RDN = + CN + "=" + DAS_CONTEXT_NAME; + protected static final String ECORE_CONTEXT_RDN = + CN + "=" + ECORE_CONTEXT_NAME; + + protected String xsdNamespace = + "http://example.com/users/accounts"; + +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASContextSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASContextSetup.java new file mode 100644 index 0000000000..7eef04e56d --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASContextSetup.java @@ -0,0 +1,56 @@ +package org.apache.tuscany.das.ldap.schema.setup.test; + +import javax.naming.NamingException; +import javax.naming.directory.DirContext; +import javax.naming.ldap.LdapContext; + +import org.apache.directory.apacheds.testing.setup.JNDIHotPartitionConnectionTemplate; +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.create.InitialContextCreator; +import org.apache.tuscany.das.ldap.create.MetaContextCreator; +import org.apache.tuscany.das.ldap.destroy.InitialContextDestroyer; +import org.apache.tuscany.das.ldap.destroy.MetaContextDestroyer; + +public class DASContextSetup +extends JNDIHotPartitionConnectionTemplate +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + MetaContextDestroyer. + destroy( modelContext ); + + InitialContextDestroyer. + destroy( + modelContext, + dasPartitionContext ); + super.tearDown(); + + dasPartitionContext.close(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + dasPartitionContext = + connect("das"); + + modelContext = + (LdapContext) + InitialContextCreator. + create( + xsdNamespace, + dasPartitionContext); + + //Meta Context + //---------------------------------------------- + metaContext = + (LdapContext) MetaContextCreator. + create( + modelContext); + } + protected LdapContext dasPartitionContext = null; + protected LdapContext modelContext = null; + protected LdapContext metaContext = null; + protected LdapContext schemaContext = null; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASContextSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASContextSetupTest.java new file mode 100644 index 0000000000..8e0d4674dc --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASContextSetupTest.java @@ -0,0 +1,34 @@ +package org.apache.tuscany.das.ldap.schema.setup.test; + +import javax.naming.NamingException; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class DASContextSetupTest +extends DASContextSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void testCreateDASPartitionContext() + { + assertNotNull(dasPartitionContext); + } + + public void testModelContext() + { + assertNotNull(modelContext); + } + public void testMetaContext() + { + assertNotNull(metaContext); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASSchemaContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASSchemaContextsSetup.java new file mode 100644 index 0000000000..9f4d2bb330 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASSchemaContextsSetup.java @@ -0,0 +1,191 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.setup.test; + +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; +import javax.naming.directory.DirContext; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.schema.create.ComplexTypeRDNCreator; +import org.apache.tuscany.das.ldap.schema.create.SimpleTypeRDNCreator; + +public class DASSchemaContextsSetup +extends AbstractTestSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + dasSyntaxesContext.close(); + + dasContext.destroySubcontext( + SYNTAXES_CONTEXT_RDN ); + + dasAttributeTypesContext.close(); + + dasContext.destroySubcontext( + ATTRIBUTE_TYPES_CONTEXT_RDN ); + + dasContext.destroySubcontext( + OBJECT_CLASSES_CONTEXT_RDN ); + + dasContext.close(); + + schemaContext.destroySubcontext( + DAS_CONTEXT_RDN ); + + schemaContext.close(); + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + schemaContext = connect(); + dasContext = (LdapContext) createDasContext(); + dasSyntaxesContext = (LdapContext) createDasSyntaxesContext(); + dasAttributeTypesContext = (LdapContext) createDasAttributeTypesContext(); + dasObjectClassesContext = (LdapContext) createDasObjectClassesContext(); + + mComplexMayRDN = + SimpleTypeRDNCreator.create( + TUSCANY_OID_PREFIX_VALUE, + DAS_XSD_NAMESPACE, + M_META_TOP_SDO_OBJECT_CLASS, + M_COMPLEX_MAY); + + mComplexMustRDN = + SimpleTypeRDNCreator.create( + TUSCANY_OID_PREFIX_VALUE, + DAS_XSD_NAMESPACE, + M_META_TOP_SDO_OBJECT_CLASS, + M_COMPLEX_MUST); + + idRDN = + SimpleTypeRDNCreator.create( + TUSCANY_OID_PREFIX_VALUE, + DAS_XSD_NAMESPACE, + M_META_TOP_SDO_OBJECT_CLASS, + ID); + + + metaTopSDORDN = + ComplexTypeRDNCreator.create( + TUSCANY_OID_PREFIX_VALUE, + DAS_XSD_NAMESPACE, + M_META_TOP_SDO_OBJECT_CLASS); + } + + private DirContext createDasContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(META_SCHEMA); + + Attribute ecoreAttribute = new BasicAttribute( + CN, + DAS_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return schemaContext.createSubcontext( + DAS_CONTEXT_RDN, contextAttributes ); + } + + private DirContext createDasAttributeTypesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + ATTRIBUTE_TYPES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return dasContext.createSubcontext( + ATTRIBUTE_TYPES_CONTEXT_RDN, contextAttributes ); + } + + private DirContext createDasSyntaxesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + SYNTAXES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return dasContext.createSubcontext( + SYNTAXES_CONTEXT_RDN, contextAttributes ); + } + + private DirContext createDasObjectClassesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute attributeTypes = new BasicAttribute( + OU, + OBJECT_CLASSES_CONTEXT_NAME); + + contextAttributes.put( attributeTypes ); + contextAttributes.put( objectClassAttribute ); + + return dasContext.createSubcontext( + OBJECT_CLASSES_CONTEXT_RDN, + contextAttributes ); + } + + protected LdapContext dasContext = null; + protected LdapContext dasAttributeTypesContext = null; + protected LdapContext dasSyntaxesContext = null; + protected LdapContext dasObjectClassesContext = null; + + protected String mComplexMayRDN = null; + protected String mComplexMustRDN = null; + protected String idRDN = null; + protected String metaTopSDORDN = null; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASSchemaContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASSchemaContextsSetupTest.java new file mode 100644 index 0000000000..35c1f79524 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/DASSchemaContextsSetupTest.java @@ -0,0 +1,48 @@ +package org.apache.tuscany.das.ldap.schema.setup.test; + +import javax.naming.NamingException; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class DASSchemaContextsSetupTest +extends DASSchemaContextsSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + + public void testConnect() + { + assertNotNull(schemaContext); + } + + public void testCreateEcoreContext() + { + assertNotNull(dasContext); + } + + + public void testCreateDasAttributeTypesContext() + { + assertNotNull(dasAttributeTypesContext); + } + + public void testCreateDasSyntaxesContext() + { + assertNotNull(dasSyntaxesContext); + } + + public void testCreateDasObjectClassesContext() + { + assertNotNull(dasObjectClassesContext); + } + +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaAndDASContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaAndDASContextsSetup.java new file mode 100644 index 0000000000..6d9164c755 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaAndDASContextsSetup.java @@ -0,0 +1,131 @@ +package org.apache.tuscany.das.ldap.schema.setup.test; + +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; +import javax.naming.directory.DirContext; +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class EcoreSchemaAndDASContextsSetup +extends DASContextSetup +implements DASConstants +{ + public void tearDown() + throws NamingException, Exception + { + ecoreSyntaxesContext.close(); + ecoreContext.destroySubcontext( SYNTAXES_CONTEXT_RDN ); + + ecoreAttributeTypesContext.close(); + ecoreContext.destroySubcontext( ATTRIBUTE_TYPES_CONTEXT_RDN ); + + ecoreObjectClassesContext.close(); + ecoreContext.destroySubcontext( OBJECT_CLASSES_CONTEXT_RDN ); + + ecoreContext.close(); + schemaContext.destroySubcontext( ECORE_CONTEXT_RDN ); + + schemaContext.close(); + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + schemaContext = connect("schema"); + ecoreContext = createEcoreContext(); + ecoreSyntaxesContext = createEcoreSyntaxesContext(); + ecoreObjectClassesContext = createEcoreObjectClassesContext(); + ecoreAttributeTypesContext = createEcoreAttributeTypesContext(); + } + + private DirContext createEcoreContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(META_SCHEMA); + + Attribute ecoreAttribute = new BasicAttribute( + CN, + ECORE_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return schemaContext.createSubcontext( + ECORE_CONTEXT_RDN, contextAttributes ); + } + + private DirContext createEcoreObjectClassesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + OBJECT_CLASSES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return ecoreContext.createSubcontext( + OBJECT_CLASSES_CONTEXT_RDN, contextAttributes ); + } + + + + private DirContext createEcoreAttributeTypesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + ATTRIBUTE_TYPES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return ecoreContext.createSubcontext( + ATTRIBUTE_TYPES_CONTEXT_RDN, contextAttributes ); + } + + + private DirContext createEcoreSyntaxesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + SYNTAXES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return ecoreContext.createSubcontext( + SYNTAXES_CONTEXT_RDN, contextAttributes ); + } + + protected DirContext ecoreContext = null; + protected DirContext ecoreObjectClassesContext = null; + protected DirContext ecoreAttributeTypesContext = null; + protected DirContext ecoreSyntaxesContext = null; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaAndDASContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaAndDASContextsSetupTest.java new file mode 100644 index 0000000000..b7a7a7834b --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaAndDASContextsSetupTest.java @@ -0,0 +1,56 @@ +package org.apache.tuscany.das.ldap.schema.setup.test; + +import javax.naming.NamingException; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class EcoreSchemaAndDASContextsSetupTest +extends EcoreSchemaAndDASContextsSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void testConnect() + { + assertNotNull(schemaContext); + } + + public void testCreateEcoreContext() + { + assertNotNull(ecoreContext); + } + + public void testCreateEcoreObjectClassesContext() + { + assertNotNull(ecoreObjectClassesContext); + } + + public void testCreateEcoreAttributeTypesContext() + { + assertNotNull(ecoreAttributeTypesContext); + } + + public void testCreateEcoreSyntaxesContext() + { + assertNotNull(ecoreSyntaxesContext); + } + + public void testCreateDasModelContext() + { + assertNotNull(modelContext); + } + + public void testCreateDasMetaContext() + { + assertNotNull(metaContext); + } + +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaContextsSetup.java new file mode 100644 index 0000000000..fb8ca08b5f --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaContextsSetup.java @@ -0,0 +1,132 @@ +package org.apache.tuscany.das.ldap.schema.setup.test; + +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; +import javax.naming.directory.DirContext; +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class EcoreSchemaContextsSetup +extends AbstractTestSetup +implements DASConstants +{ + public void tearDown() + throws NamingException, Exception + { + ecoreSyntaxesContext.close(); + ecoreContext.destroySubcontext( SYNTAXES_CONTEXT_RDN ); + + ecoreAttributeTypesContext.close(); + ecoreContext.destroySubcontext( ATTRIBUTE_TYPES_CONTEXT_RDN ); + + ecoreObjectClassesContext.close(); + ecoreContext.destroySubcontext( OBJECT_CLASSES_CONTEXT_RDN ); + + ecoreContext.close(); + schemaContext.destroySubcontext( ECORE_CONTEXT_RDN ); + + schemaContext.close(); + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + schemaContext = connect(); + ecoreContext = createEcoreContext(); + ecoreSyntaxesContext = createEcoreSyntaxesContext(); + ecoreObjectClassesContext = createEcoreObjectClassesContext(); + ecoreAttributeTypesContext = createEcoreAttributeTypesContext(); + } + + private DirContext createEcoreContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(META_SCHEMA); + + Attribute ecoreAttribute = new BasicAttribute( + CN, + ECORE_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return schemaContext.createSubcontext( + ECORE_CONTEXT_RDN, contextAttributes ); + } + + + private DirContext createEcoreObjectClassesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + OBJECT_CLASSES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return ecoreContext.createSubcontext( + OBJECT_CLASSES_CONTEXT_RDN, contextAttributes ); + } + + + + private DirContext createEcoreAttributeTypesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + ATTRIBUTE_TYPES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return ecoreContext.createSubcontext( + ATTRIBUTE_TYPES_CONTEXT_RDN, contextAttributes ); + } + + + private DirContext createEcoreSyntaxesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + SYNTAXES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return ecoreContext.createSubcontext( + SYNTAXES_CONTEXT_RDN, contextAttributes ); + } + + protected DirContext ecoreContext = null; + protected DirContext ecoreObjectClassesContext = null; + protected DirContext ecoreAttributeTypesContext = null; + protected DirContext ecoreSyntaxesContext = null; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaContextsSetupTest.java new file mode 100644 index 0000000000..060f017e35 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/EcoreSchemaContextsSetupTest.java @@ -0,0 +1,45 @@ +package org.apache.tuscany.das.ldap.schema.setup.test; + +import javax.naming.NamingException; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class EcoreSchemaContextsSetupTest +extends EcoreSchemaContextsSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void testConnect() + { + assertNotNull(schemaContext); + } + + public void testCreateEcoreContext() + { + assertNotNull(ecoreContext); + } + + public void testCreateEcoreObjectClassesContext() + { + assertNotNull(ecoreObjectClassesContext); + } + + public void testCreateEcoreAttributeTypesContext() + { + assertNotNull(ecoreAttributeTypesContext); + } + + public void testCreateEcoreSyntaxesContext() + { + assertNotNull(ecoreSyntaxesContext); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextSetup.java new file mode 100644 index 0000000000..11fb2a3af9 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextSetup.java @@ -0,0 +1,21 @@ +package org.apache.tuscany.das.ldap.schema.setup.test; + +import javax.naming.NamingException; +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class SchemaContextSetup +extends AbstractTestSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + schemaContext.close(); + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + schemaContext = connect(); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextSetupTest.java new file mode 100644 index 0000000000..dacbf2b2ec --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextSetupTest.java @@ -0,0 +1,25 @@ +package org.apache.tuscany.das.ldap.schema.setup.test; + +import javax.naming.NamingException; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class SchemaContextSetupTest +extends SchemaContextSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void testConnect() + { + assertNotNull(schemaContext); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextsSetup.java new file mode 100644 index 0000000000..92f86bc402 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextsSetup.java @@ -0,0 +1,231 @@ +package org.apache.tuscany.das.ldap.schema.setup.test; + +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; +import javax.naming.directory.DirContext; + +public class SchemaContextsSetup +extends AbstractTestSetup +{ + public void tearDown() throws NamingException, Exception + { + dasSyntaxesContext.close(); + dasContext.destroySubcontext( SYNTAXES_CONTEXT_RDN ); + + dasAttributeTypesContext.close(); + dasContext.destroySubcontext( ATTRIBUTE_TYPES_CONTEXT_RDN ); + + dasObjectClassesContext.close(); + dasContext.destroySubcontext( OBJECT_CLASSES_CONTEXT_RDN ); + dasContext.close(); + + xsdSyntaxesContext.close(); + xsdContext.destroySubcontext( SYNTAXES_CONTEXT_RDN ); + + xsdContext.close(); + schemaContext.destroySubcontext( XSD_CONTEXT_RDN ); + + ecoreSyntaxesContext.close(); + ecoreContext.destroySubcontext( SYNTAXES_CONTEXT_RDN ); + + ecoreContext.close(); + schemaContext.destroySubcontext( ECORE_CONTEXT_RDN ); + + schemaContext.destroySubcontext( DAS_CONTEXT_RDN ); + schemaContext.close(); + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + schemaContext = connect(); + dasContext = createDASContext(); + dasSyntaxesContext = createSyntaxesContext(); + dasAttributeTypesContext = createAttributeTypesContext(); + dasObjectClassesContext = createObjectClassesContext(); + xsdContext = createXSDContext(); + xsdSyntaxesContext = createXSDSyntaxesContext(); + ecoreContext = createEcoreContext(); + ecoreSyntaxesContext = createEcoreSyntaxesContext(); + } + + private DirContext createDASContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(META_SCHEMA); + + Attribute dasAttribute = new BasicAttribute( + CN, + DAS_CONTEXT_NAME); + + contextAttributes.put( dasAttribute ); + contextAttributes.put( objectClassAttribute ); + + return schemaContext.createSubcontext( + DAS_CONTEXT_RDN, contextAttributes ); + } + + + private DirContext createXSDContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(META_SCHEMA); + + Attribute xsdAttribute = new BasicAttribute( + CN, + XSD_CONTEXT_NAME); + + contextAttributes.put( xsdAttribute ); + contextAttributes.put( objectClassAttribute ); + + return schemaContext.createSubcontext( + XSD_CONTEXT_RDN, contextAttributes ); + } + + private DirContext createXSDSyntaxesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute xsdAttribute = new BasicAttribute( + OU, + SYNTAXES_CONTEXT_NAME); + + contextAttributes.put( xsdAttribute ); + contextAttributes.put( objectClassAttribute ); + + return xsdContext.createSubcontext( + SYNTAXES_CONTEXT_RDN, contextAttributes ); + } + + + private DirContext createEcoreContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(META_SCHEMA); + + Attribute ecoreAttribute = new BasicAttribute( + CN, + ECORE_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return schemaContext.createSubcontext( + ECORE_CONTEXT_RDN, contextAttributes ); + } + + + private DirContext createEcoreSyntaxesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + SYNTAXES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return ecoreContext.createSubcontext( + SYNTAXES_CONTEXT_RDN, contextAttributes ); + } + + private DirContext createSyntaxesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute syntaxesRDNAttribute = new BasicAttribute( + OU, + SYNTAXES_CONTEXT_NAME); + + contextAttributes.put( objectClassAttribute ); + contextAttributes.put( syntaxesRDNAttribute ); + + return dasContext.createSubcontext( + SYNTAXES_CONTEXT_RDN, contextAttributes ); + } + + + private DirContext createAttributeTypesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute attributeTypes = new BasicAttribute( + OU, + ATTRIBUTE_TYPES_CONTEXT_NAME); + + contextAttributes.put( attributeTypes ); + contextAttributes.put( objectClassAttribute ); + + return dasContext.createSubcontext( + ATTRIBUTE_TYPES_CONTEXT_RDN, contextAttributes ); + } + + private DirContext createObjectClassesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute attributeTypes = new BasicAttribute( + OU, + OBJECT_CLASSES_CONTEXT_NAME); + + contextAttributes.put( attributeTypes ); + contextAttributes.put( objectClassAttribute ); + + return dasContext.createSubcontext( + OBJECT_CLASSES_CONTEXT_RDN, + contextAttributes ); + } + + protected DirContext dasContext = null; + protected DirContext xsdContext = null; + protected DirContext xsdSyntaxesContext = null; + protected DirContext ecoreContext = null; + protected DirContext ecoreSyntaxesContext = null; + protected DirContext dasSyntaxesContext = null; + protected DirContext dasAttributeTypesContext = null; + protected DirContext dasObjectClassesContext = null; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextsSetupTest.java new file mode 100644 index 0000000000..dfea532518 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/SchemaContextsSetupTest.java @@ -0,0 +1,71 @@ +package org.apache.tuscany.das.ldap.schema.setup.test; + +import javax.naming.NamingException; + +public class SchemaContextsSetupTest +extends SchemaContextsSetup +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void testConnect() + { + assertNotNull(schemaContext); + } + + + public void testCreateDASContext() + { + assertNotNull(dasContext); + } + + + public void testCreateXSDContext() + { + assertNotNull(xsdContext); + } + + + + public void testCreateXSDSyntaxesContext() + { + assertNotNull(xsdSyntaxesContext); + } + + + public void testCreateEcoreContext() + { + assertNotNull(ecoreContext); + } + + + + public void testCreateEcoreSyntaxesContext() + { + assertNotNull(ecoreSyntaxesContext); + } + + public void testCreateSyntaxesContext() + { + assertNotNull(dasSyntaxesContext); + } + + public void testCreateAttributeTypesContext() + { + assertNotNull(dasAttributeTypesContext); + } + + + public void testCreateObjectClassesContext() + { + assertNotNull(dasObjectClassesContext); + } + +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/XSDSchemaContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/XSDSchemaContextsSetup.java new file mode 100644 index 0000000000..4b9cd22e44 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/XSDSchemaContextsSetup.java @@ -0,0 +1,76 @@ +package org.apache.tuscany.das.ldap.schema.setup.test; + +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; +import javax.naming.directory.DirContext; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class XSDSchemaContextsSetup +extends AbstractTestSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + xsdSyntaxesContext.close(); + xsdContext.destroySubcontext( SYNTAXES_CONTEXT_RDN ); + xsdContext.close(); + schemaContext.destroySubcontext( XSD_CONTEXT_RDN ); + schemaContext.close(); + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + schemaContext = connect(); + xsdContext = createXsdContext(); + xsdSyntaxesContext = createXsdSyntaxesContext(); + } + + private DirContext createXsdContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(META_SCHEMA); + + Attribute ecoreAttribute = new BasicAttribute( + CN, + XSD_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return schemaContext.createSubcontext( + XSD_CONTEXT_RDN, contextAttributes ); + } + + private DirContext createXsdSyntaxesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + SYNTAXES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return xsdContext.createSubcontext( + SYNTAXES_CONTEXT_RDN, contextAttributes ); + } + + protected DirContext xsdContext = null; + protected DirContext xsdSyntaxesContext = null; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/XSDSchemaContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/XSDSchemaContextsSetupTest.java new file mode 100644 index 0000000000..a0bb8fb69d --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/setup/test/XSDSchemaContextsSetupTest.java @@ -0,0 +1,35 @@ +package org.apache.tuscany.das.ldap.schema.setup.test; + +import javax.naming.NamingException; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class XSDSchemaContextsSetupTest +extends XSDSchemaContextsSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void testConnect() + { + assertNotNull(schemaContext); + } + + public void testCreateEcoreContext() + { + assertNotNull(xsdContext); + } + + public void testCreateEcoreSyntaxesContext() + { + assertNotNull(xsdSyntaxesContext); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/testing/constants/DASTestingConstants.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/testing/constants/DASTestingConstants.java new file mode 100644 index 0000000000..2ee1d37650 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/testing/constants/DASTestingConstants.java @@ -0,0 +1,9 @@ +package org.apache.tuscany.das.ldap.testing.constants; + +public interface DASTestingConstants { + + String xsdNamespace = + "http://example.com/users/accounts"; + + +} diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/ComplexTypeNamespaceQualifier.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/ComplexTypeNamespaceQualifier.java new file mode 100644 index 0000000000..1185d968d3 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/ComplexTypeNamespaceQualifier.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.ldap.util; + +// TODO: Auto-generated Javadoc +/** + * The Class DataTypeNamespaceQualifier. + */ +public class ComplexTypeNamespaceQualifier +{ + /** + * Qualify. + * + * @param namespaceURI the namespace URI + * @param complexTypeName the name + * + * @return the string + */ + public static String qualify(String namespaceURI, String complexTypeName ) + { + return namespaceURI + "/" + complexTypeName; + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/IDGenerator.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/IDGenerator.java new file mode 100644 index 0000000000..f41d192bd0 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/IDGenerator.java @@ -0,0 +1,10 @@ +package org.apache.tuscany.das.ldap.util; + +public class IDGenerator { + + static long currentID= System.currentTimeMillis(); + + static public synchronized long generate(){ + return currentID++; + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/JNDIUtil.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/JNDIUtil.java new file mode 100644 index 0000000000..be19f0b6c4 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/JNDIUtil.java @@ -0,0 +1,168 @@ + +package org.apache.tuscany.das.ldap.util; + +import javax.naming.NamingException; +import javax.naming.directory.DirContext; + +/** + * The Class JNDIUtil. + */ +public class JNDIUtil +{ + /** + * Calculate DN components. + * + * @param context the context + * + * @return the string[] containing the components of the DN + * + * @throws NamingException the naming exception + */ + public static String[] calculateDNComponents( + DirContext context) + throws NamingException + { + String contextDN = + context.getNameInNamespace(); + + String[] initialContextComponents = + contextDN.split( "[,]" ); + + return initialContextComponents; + } + + + /** + * Calculate DN components. + * + * @param contextDN the context DN + * + * @return the string[] containing the components of the DN + * + * @throws NamingException the naming exception + */ + public static String[] calculateDNComponents( + String contextDN) + throws NamingException + { + String[] initialContextComponents = + contextDN.split( "[,]" ); + + return initialContextComponents; + } + + /** + * Gets the parent context. + * + * @param partitionContext the partition context + * @param childContext the child context + * + * @return the parent context (Null if the child context is the root) + * + * @throws NamingException the naming exception + */ + public static DirContext getParentContext( + DirContext childContext, + DirContext partitionContext) + throws NamingException + { + String[] childContextDNComponents = + calculateDNComponents( childContext ); + + String[] partitionDNComponents = + calculateDNComponents( partitionContext ); + + DirContext parentContext = null; + + if (childContextDNComponents.length == partitionDNComponents.length) + { + return null; + } + else if ( (childContextDNComponents.length - 1) == partitionDNComponents.length) + { + return partitionContext; + } + else + { + String parentLookupDN = + calculateParentRelativeDN( + childContext, partitionContext.getNameInNamespace() ); + + + + parentContext = + ( DirContext ) partitionContext.lookup( parentLookupDN ); + } + return parentContext; + } + + + /** + * Calculate parent relative DN. + * The parent relative DN is the + * DN of the parent context, relative + * to the partition context. + * + * So if the partition context is + * <i>ou=system</i> and + * the child context has DN + * <i>cn=accounts, cn=users, cn=example, ou=system</i> + * + * then the parent relative DN is + * <i>cn=users, cn=example</i> + * + * @param childContext the child context + * @param partitionDN the partition DN + * + * @return the string + * + * @throws NamingException the naming exception + */ + public static String calculateParentRelativeDN( + DirContext childContext, + String partitionDN) + throws NamingException + { + String parentRelativeDN = null; + + String[] childContextDNComponents = + calculateDNComponents( childContext ); + + String[] partitionDNComponents = + calculateDNComponents( partitionDN ); + + if (childContextDNComponents.length == + partitionDNComponents.length) + { + return null; + } + else if (childContextDNComponents.length == + partitionDNComponents.length + 1) + { + String childRDN = childContextDNComponents[0]; + String childContextDN = childContext.getNameInNamespace(); + + int beginIndex = childRDN.length() + 1; + int endIndex = childContextDN.length(); + + parentRelativeDN = childContextDN.substring( + beginIndex, endIndex ); + + return parentRelativeDN; + } + else + { + String childRDN = childContextDNComponents[0]; + String childContextDN = childContext.getNameInNamespace(); + + int beginIndex = childRDN.length() + 1; + int endIndex = + childContextDN.length() - + ( partitionDN.length() +1); + + parentRelativeDN = childContextDN.substring( + beginIndex, endIndex ); + } + return parentRelativeDN; + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/LDAPNormalizer.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/LDAPNormalizer.java new file mode 100644 index 0000000000..2d0be469bc --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/LDAPNormalizer.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.util; + +public class LDAPNormalizer +{ + + /** + * Normalize a qualified string for LDAP + * by replacing periods with dashes. + * + * @param qualifiedName the qualified name + */ + public static void normalize(String qualifiedName) + { + qualifiedName = qualifiedName.replace( ".", "-" ); + } + + + +} diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/QualifiedNameNormalizer.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/QualifiedNameNormalizer.java new file mode 100644 index 0000000000..51b34f5d0f --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/QualifiedNameNormalizer.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.util; + +public class QualifiedNameNormalizer +{ + /** + * Normalize a qualified string for LDAP + * by replacing periods with dashes. + * + * @param qualifiedName the qualified name + */ + public static String normalize(String qualifiedName) + { + qualifiedName = qualifiedName.replace("http://", ""); + qualifiedName = qualifiedName.replace("/", "-"); + return qualifiedName.replace(".", "-"); + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/SimpleTypeNamespaceQualifier.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/SimpleTypeNamespaceQualifier.java new file mode 100644 index 0000000000..40dc6e0b09 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/SimpleTypeNamespaceQualifier.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.das.ldap.util; + +// TODO: Auto-generated Javadoc +/** + * The Class DataTypeNamespaceQualifier. + */ +public class SimpleTypeNamespaceQualifier +{ + /** + * Qualify. + * + * @param namespaceURI the namespace URI + * @param complexTypeName the name + * + * @return the string + */ + public static String qualify(String namespaceURI, String complexTypeName, String simpleTypeName ) + { + return namespaceURI + "/" + complexTypeName + "/" + simpleTypeName; + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceToInitialContextTransformer.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceToInitialContextTransformer.java new file mode 100644 index 0000000000..87ff89071a --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceToInitialContextTransformer.java @@ -0,0 +1,49 @@ + +package org.apache.tuscany.das.ldap.util; + +import org.eclipse.emf.common.util.URI; + +/** + * The Class XSDNamespaceToInitialContextTransformer. + * + * Takes the XSD Namespace used by the DataObjects + * and transforms it into the DN of the initial context + * used for the root DataObject entry. + */ +public class XSDNamespaceToInitialContextTransformer +{ + /** + * Transform. + * + * @param namespaceURIString the namespace URI string + * + * @return the DN of the initial context + * + * @throws Exception the exception + */ + public static String transform(String namespaceURIString) throws Exception + { + URI namespaceURI = URI.createURI(namespaceURIString); + String authority = namespaceURI.authority(); + + String path = namespaceURI.path(); + + String[] authorityTokens = authority.split( "[.]" ); + String[] pathTokens = path.split("[/]"); + + String DN = new String(""); + + for (int i = (pathTokens.length-1); i > 0; i--) + { + DN = DN + "cn=" + pathTokens[i] + ", "; + } + + for (int i = 0; i <= (authorityTokens.length-2); i++) + { + DN = DN + "cn=" + authorityTokens[i] + ", "; + } + + DN = DN + "ou=" + authorityTokens[authorityTokens.length-1]; + return DN; + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceURITokenizer.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceURITokenizer.java new file mode 100644 index 0000000000..833cf0e7ae --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/util/XSDNamespaceURITokenizer.java @@ -0,0 +1,26 @@ + +package org.apache.tuscany.das.ldap.util; + +import org.eclipse.emf.common.util.URI; + +public class XSDNamespaceURITokenizer +{ + + public static String[] createAuthorityTokens( URI xsdNamespaceURI ) + { + String authority = xsdNamespaceURI.authority(); + String[] authorityTokens = authority.split( "[.]" ); + return authorityTokens; + } + + public static String[] createPathTokens(URI xsdNamespace) + { + String path = xsdNamespace.path(); + if (path != null) + { + return path.split("[/]"); + } + else + return null; + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/connect/test/ADSEmbeddedConnectionTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/connect/test/ADSEmbeddedConnectionTest.java new file mode 100644 index 0000000000..d77b4491a4 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/connect/test/ADSEmbeddedConnectionTest.java @@ -0,0 +1,54 @@ +package org.apache.tuscany.das.ldap.connect.test; + +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.connect.ADSEmbeddedConnection; +import org.apache.tuscany.model.Configuration; +import org.apache.tuscany.model.ConfigurationFactory; + +import junit.framework.TestCase; + +public class ADSEmbeddedConnectionTest extends TestCase { + + public void testConnect() throws Exception + { + Configuration configuration = + ConfigurationFactory. + INSTANCE. + createConfiguration(); + + ADSEmbeddedConnection adsEmbeddedConnection = + new ADSEmbeddedConnection(configuration); + + LdapContext dasContext = + adsEmbeddedConnection. + connect( + configuration. + getDasPartitionName()); + + assertEquals( + dasContext.getNameInNamespace(), + "ou=das"); + + LdapContext schemaContext = + adsEmbeddedConnection. + connect( + configuration. + getSchemaPartitionName()); + + assertEquals( + schemaContext.getNameInNamespace(), + "ou=schema"); + + configuration.setDasPartitionName("system"); + + LdapContext systemContext = + adsEmbeddedConnection.connect(configuration.getDasPartitionName()); + + assertEquals( + systemContext.getNameInNamespace(), + "ou=system"); + + adsEmbeddedConnection.shutdown(); + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/InitialContextCreatorHelperTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/InitialContextCreatorHelperTest.java new file mode 100644 index 0000000000..96c449099d --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/InitialContextCreatorHelperTest.java @@ -0,0 +1,189 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.create.test; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.create.InitialContextCreatorHelper; + +import org.apache.tuscany.das.ldap.schema.embedded.setup.test.AbstractTestSetup; +import org.apache.tuscany.das.ldap.util.XSDNamespaceURITokenizer; +import org.eclipse.emf.common.util.URI; + +/* + * Note these tests require a running instance of ApacheDS + */ + +public class InitialContextCreatorHelperTest +extends AbstractTestSetup +{ + protected String xsdNamespace = "http://example.com/users/accounts"; + protected URI xsdNamespaceURI = URI.createURI( xsdNamespace ); + + LdapContext comContext = null; + LdapContext exampleContext = null; + LdapContext usersContext = null; + + public void setUp() throws Exception + { + super.setUp(); + } + + public void tearDown() throws Exception + { + super.tearDown(); + } + + public void testCreateSystemSubContext() throws NamingException + { + String testContextRDN = "cn=newContext"; + + Object testContext = null; + + try { + testContext = dasPartitionContext.lookup( testContextRDN ); + } + catch (Exception e) + { + //good + } + + assertNull(testContext); + + InitialContextCreatorHelper.createSubContext( + dasPartitionContext, + testContextRDN, + null); + + testContext = dasPartitionContext.lookup( testContextRDN ); + + assertNotNull(testContext); + dasPartitionContext.destroySubcontext( testContextRDN ); + } + + public void testCreateExistingSystemSubContext() throws NamingException + { + String testContextRDN = "cn=newContext"; + Object testContext = null; + + try { + testContext = dasPartitionContext.lookup( testContextRDN ); + } + catch (Exception e) + { + //good + } + + assertNull(testContext); + + InitialContextCreatorHelper.createSubContext( + dasPartitionContext, + testContextRDN, + null); + + //Run the same code again. + InitialContextCreatorHelper.createSubContext( + dasPartitionContext, + testContextRDN, + null); + + testContext = dasPartitionContext.lookup( testContextRDN ); + + assertNotNull(testContext); + dasPartitionContext.destroySubcontext( testContextRDN ); + } + + + public void testCreateAuthorityContext() + throws NamingException + { + try + { + comContext = + ( LdapContext ) + dasPartitionContext.lookup("cn=com"); + } + catch ( NamingException e ) + { + //Good - the subcontext does not exist + } + assertTrue(comContext==null); + + String[] authorityTokens = + XSDNamespaceURITokenizer.createAuthorityTokens(xsdNamespaceURI); + + InitialContextCreatorHelper.createAuthorityContext( + dasPartitionContext, + authorityTokens ); + + comContext = + ( LdapContext ) dasPartitionContext.lookup("cn=com"); + + assertNotNull(comContext); + + exampleContext = + ( LdapContext ) comContext.lookup("cn=example"); + + assertNotNull(exampleContext); + + comContext.destroySubcontext( "cn=example" ); + dasPartitionContext.destroySubcontext( "cn=com" ); + } + + public void testCreatePathContext() throws NamingException + { + String[] authorityTokens = + XSDNamespaceURITokenizer. + createAuthorityTokens(xsdNamespaceURI); + + exampleContext = + InitialContextCreatorHelper. + createAuthorityContext( + dasPartitionContext, + authorityTokens ); + + String[] pathTokens = + XSDNamespaceURITokenizer. + createPathTokens(xsdNamespaceURI); + + InitialContextCreatorHelper. + createPathContext( + exampleContext, + pathTokens ); + + comContext = + ( LdapContext ) + dasPartitionContext. + lookup("cn=com"); + + exampleContext = + ( LdapContext ) + comContext. + lookup("cn=example"); + + usersContext = ( LdapContext ) exampleContext.lookup("cn=users"); + + usersContext.destroySubcontext( "cn=accounts" ); + exampleContext.destroySubcontext( "cn=users" ); + comContext.destroySubcontext( "cn=example" ); + dasPartitionContext.destroySubcontext( "cn=com" ); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/InitialContextCreatorTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/InitialContextCreatorTest.java new file mode 100644 index 0000000000..75834a7502 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/InitialContextCreatorTest.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.create.test; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.create.InitialContextCreator; +import org.apache.tuscany.das.ldap.schema.embedded.setup.test.AbstractTestSetup; + +public class InitialContextCreatorTest +extends AbstractTestSetup +{ + public void testCreate() throws NamingException + { + LdapContext comContext = null; + LdapContext exampleContext = null; + LdapContext usersContext = null; + LdapContext accountsContext = null; + LdapContext rootContext = null; + + rootContext = + InitialContextCreator.create( + xsdNamespace, + dasPartitionContext ); + + assertEquals( + rootContext.getNameInNamespace(), + "cn=accounts,cn=users,cn=example,cn=com,ou=das"); + + comContext = + ( LdapContext ) + dasPartitionContext.lookup( "cn=com" ); + exampleContext = ( LdapContext )comContext.lookup( "cn=example" ); + usersContext = ( LdapContext ) exampleContext.lookup( "cn=users" ); + accountsContext = ( LdapContext ) usersContext.lookup( "cn=accounts" ); + accountsContext = ( LdapContext ) usersContext.lookup( "cn=accounts" ); + + assertNotNull(comContext); + assertNotNull(exampleContext); + assertNotNull(usersContext); + assertNotNull(accountsContext); + + usersContext. + destroySubcontext( "cn=accounts" ); + + exampleContext. + destroySubcontext( "cn=users" ); + + comContext. + destroySubcontext( "cn=example" ); + + dasPartitionContext. + destroySubcontext( "cn=com" ); + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/MetaContextCreatorTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/MetaContextCreatorTest.java new file mode 100644 index 0000000000..904ef2f2c6 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/MetaContextCreatorTest.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.create.test; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.create.InitialContextCreator; +import org.apache.tuscany.das.ldap.create.MetaContextCreator; +import org.apache.tuscany.das.ldap.destroy.InitialContextDestroyer; +import org.apache.tuscany.das.ldap.destroy.MetaContextDestroyer; +import org.apache.tuscany.das.ldap.schema.embedded.setup.test.AbstractTestSetup; + +public class MetaContextCreatorTest +extends AbstractTestSetup +{ + private LdapContext modelContext = null; + private LdapContext metaContext = null; + + public void tearDown() + throws NamingException + { + MetaContextDestroyer.destroy( modelContext ); + + InitialContextDestroyer.destroy( + modelContext, + dasPartitionContext ); + } + + public void setUp() throws Exception + { + super.setUp(); + modelContext = + InitialContextCreator. + create( + xsdNamespace, + dasPartitionContext); + + metaContext = + MetaContextCreator. + create(modelContext ); + } + + public void testCreate() throws NamingException + { + assertTrue(true); + + assertEquals( + "cn=meta,cn=accounts,cn=users,cn=example,cn=com,ou=das", + metaContext.getNameInNamespace() ); + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/UniqueOIDCreatorHelperTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/UniqueOIDCreatorHelperTest.java new file mode 100644 index 0000000000..6e9ba56779 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/create/test/UniqueOIDCreatorHelperTest.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.create.test; + +import org.apache.tuscany.das.ldap.oid.create.OIDCreatorHelper; + +import junit.framework.TestCase; + +public class UniqueOIDCreatorHelperTest +extends TestCase +{ + public void testCalculateSegmentedOID() throws Exception + { + String input1 = "56102578"; + String input2 = "5610257834"; + + String result = + "will not pass if exception not caught"; + try { + result = + OIDCreatorHelper. + calculateSegmentedOID( input1 ); + } + catch (Exception e) + { + result = "passed"; + } + assertEquals(result, "passed"); + + result = + OIDCreatorHelper. + calculateSegmentedOID( input2 ); + + assertEquals(result, "56102578.4"); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/destroy/test/InitialContextDestroyerTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/destroy/test/InitialContextDestroyerTest.java new file mode 100644 index 0000000000..5ce43587df --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/destroy/test/InitialContextDestroyerTest.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.destroy.test; + +import javax.naming.NamingException; +import javax.naming.directory.DirContext; + +import org.apache.tuscany.das.ldap.destroy.InitialContextDestroyer; +import org.apache.tuscany.das.ldap.schema.embedded.setup.test.AbstractTestSetup; + +public class InitialContextDestroyerTest extends AbstractTestSetup +{ + DirContext test1Context = null; + DirContext test2Context = null; + DirContext test3Context = null; + + /* + * Tests that the initial context destroyer + * destroys child projects before parent projects. + */ + public void testDestroy() throws NamingException + { + test1Context = + ( DirContext ) + dasPartitionContext. + createSubcontext( "cn=test1" ); + + test2Context = + ( DirContext ) + test1Context. + createSubcontext( "cn=test2" ); + + test3Context = + ( DirContext ) + test2Context. + createSubcontext( "cn=test3" ); + + Object test = null; + test = + dasPartitionContext. + lookup( "cn=test1" ); + + assertNotNull(test); + + InitialContextDestroyer. + destroy( + test3Context, + dasPartitionContext); + + try + { + test = dasPartitionContext.lookup( "cn=test1" ); + } + catch (Exception e) + { + test = "caught"; + } + + assertSame("caught", test); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/create/test/EDataGraphCreatorTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/create/test/EDataGraphCreatorTest.java new file mode 100644 index 0000000000..2f2b8a24de --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/create/test/EDataGraphCreatorTest.java @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.emf.create.test; + +import javax.naming.NamingException; +import javax.naming.directory.Attributes; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.prototype.setup.test.EDataGraphSetupTest; + + +public class EDataGraphCreatorTest +extends EDataGraphSetupTest +{ + public void testCreate() throws NamingException + { + assertEquals( + "example-com-users-accounts-User-id=1,cn=accounts,cn=users,cn=example,cn=com,ou=das", + userContainerContext.getNameInNamespace()); + + Attributes userEntryAttributes = + userContainerContext.getAttributes(""); + + assertEquals( + userEntryAttributes.get( + "example-com-users-accounts-User-userPassword").get(), + "secret"); + + assertEquals( + userEntryAttributes.get( + "example-com-users-accounts-User-authorizationList").get(0), "2"); + + assertEquals( + userEntryAttributes.get( + "example-com-users-accounts-User-authorizationList").get(1), "3"); + + assertEquals( + userEntryAttributes.get("example-com-users-accounts-User-userName").get(), + "ole"); + + assertEquals( + "cn=authorizationList,example-com-users-accounts-User-id=1,cn=accounts,cn=users,cn=example,cn=com,ou=das", + authorizationContainerContext.getNameInNamespace()); + + LdapContext authorizationEntry1Context = + (LdapContext) + rootContext. + lookup(authorizationDataObject1RDN); + + assertEquals( + "example-com-users-accounts-Authorization-id=2,cn=authorizationList,example-com-users-accounts-User-id=1,cn=accounts,cn=users,cn=example,cn=com,ou=das", + authorizationEntry1Context.getNameInNamespace()); + + Attributes authorizationEntry1Attributes = + rootContext. + getAttributes(authorizationDataObject1RDN); + + assertEquals( + authorizationEntry1Attributes.get("example-com-users-accounts-Authorization-fileName").get(), + "somefile.text"); + + assertEquals( + authorizationEntry1Attributes.get("example-com-users-accounts-Authorization-writeAuthorization").get(), + "TRUE"); + + + LdapContext authorizationEntry2Context = + (LdapContext) + rootContext. + lookup(authorizationDataObject2RDN); + + assertEquals( + "example-com-users-accounts-Authorization-id=3,cn=authorizationList,example-com-users-accounts-User-id=1,cn=accounts,cn=users,cn=example,cn=com,ou=das", + authorizationEntry2Context.getNameInNamespace()); + + + Attributes authorizationEntry2Attributes = + rootContext. + getAttributes(authorizationDataObject2RDN); + + assertEquals( + authorizationEntry2Attributes.get("example-com-users-accounts-Authorization-fileName").get(), + "someOtherfile.text"); + + assertEquals( + "cn=configuration,example-com-users-accounts-User-id=1,cn=accounts,cn=users,cn=example,cn=com,ou=das", + configurationContainerContext.getNameInNamespace()); + + String configurationEntryRDN = + "example-com-users-accounts-Configuration-id=5"; + + LdapContext configurationEntryContext = + (LdapContext) + configurationContainerContext. + lookup(configurationEntryRDN); + + assertEquals( + "example-com-users-accounts-Configuration-id=5,cn=configuration,example-com-users-accounts-User-id=1,cn=accounts,cn=users,cn=example,cn=com,ou=das", + configurationEntryContext.getNameInNamespace()); + + Attributes configurationEntryAttributes = + configurationContainerContext. + getAttributes(configurationEntryRDN); + + assertEquals( + configurationEntryAttributes.get("example-com-users-accounts-Configuration-authorization").get(), + "2"); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/create/test/EDataObjectCreatorTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/create/test/EDataObjectCreatorTest.java new file mode 100644 index 0000000000..c3b6fc5475 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/create/test/EDataObjectCreatorTest.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.emf.create.test; + +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.prototype.setup.test.EDataObjectSetupTest; + +public class EDataObjectCreatorTest +extends EDataObjectSetupTest +{ + protected String eDataObjectRDN = null; + protected LdapContext namedContainerContext = null; + + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws Exception + { + super.setUp(); + } + + public void testCreate() throws NamingException + { + assertEquals( + "example-com-users-accounts-User-id=1,cn=accounts,cn=users,cn=example,cn=com,ou=das", + userContainerContext.getNameInNamespace()); + + Attributes attributes = + userContainerContext.getAttributes(""); + + assertEquals( + attributes.get("example-com-users-accounts-User-userPassword").get(), + "secret"); + + assertEquals( + attributes.get("example-com-users-accounts-User-userName").get(), + "ole"); + assertEquals( + attributes.get("example-com-users-accounts-User-userPassword").get(), + "secret"); + assertEquals( + attributes.get("example-com-users-accounts-User-userAge").get(), + "33"); + assertEquals( + attributes.get("example-com-users-accounts-User-userHeight").get(), + "6.11"); + + assertEquals( + attributes.get("example-com-users-accounts-User-authorizationList").size(), + 2); + + Attribute aliasesAttribute = attributes.get("example-com-users-accounts-User-userAliases"); + + assertEquals( + aliasesAttribute.size(), + 3); + + assertEquals(aliasesAttribute.get(0), "neo"); + assertEquals(aliasesAttribute.get(1), "trinity"); + assertEquals(aliasesAttribute.get(2), "morpheus"); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/read/test/EDataGraphReaderTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/read/test/EDataGraphReaderTest.java new file mode 100644 index 0000000000..ea609544cf --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/read/test/EDataGraphReaderTest.java @@ -0,0 +1,156 @@ +/* + * 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.test; + +import java.util.Hashtable; + +import javax.naming.NamingException; + +import org.apache.tuscany.das.ldap.emf.read.EDataGraphReader; +import org.apache.tuscany.das.ldap.prototype.setup.test.EDataGraphSetupTest; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.sdo.EDataObject; + +public class EDataGraphReaderTest +extends EDataGraphSetupTest +{ + public void testRead() throws NamingException + { + dataObjectToRelativeDNCache = + new Hashtable<EDataObject, String>(); + + eDataGraph = + EDataGraphReader.read( + userEClass, + "1", + rootContext, + dataObjectToRelativeDNCache); + + EDataObject retrievedUserDataObject = + (EDataObject) eDataGraph.getRootObject(); + + assertEquals( + dataObjectToRelativeDNCache. + get(retrievedUserDataObject).toString(), + "example-com-users-accounts-User-id=1"); + + assertEquals(retrievedUserDataObject.eGet(userNameEAttribute), "ole"); + assertEquals(retrievedUserDataObject.eGet(userPasswordEAttribute), "secret"); + assertEquals(retrievedUserDataObject.eGet(userAgeEAttribute), 33); + assertEquals(retrievedUserDataObject.eGet(userHeightEAttribute), 6.11); + assertEquals(retrievedUserDataObject.eGet(userIsMaleEAttribute), true); + + EList<EDataObject> retrievedAuthorizationContainmentList = + (EList<EDataObject>) + retrievedUserDataObject. + eGet(userAuthorizationEReference); + + assertEquals(retrievedAuthorizationContainmentList.size(), 2); + + EDataObject retrievedAuthorizationEDataObject1 = + retrievedAuthorizationContainmentList.get(0); + + assertEquals( + dataObjectToRelativeDNCache. + get(retrievedAuthorizationEDataObject1).toString(), + "example-com-users-accounts-Authorization-id=2,cn=authorizationList,example-com-users-accounts-User-id=1"); + + assertEquals( + retrievedAuthorizationEDataObject1. + eGet(authorizationIDEAttribute), "2"); + assertEquals( + retrievedAuthorizationEDataObject1. + eGet(authorizationFileEAttribute), "somefile.text"); + assertEquals( + retrievedAuthorizationEDataObject1. + eGet(authorizationWriteEAttribute), true); + assertEquals( + retrievedAuthorizationEDataObject1. + eGet(authorizationReadEAttribute), true); + assertEquals( + retrievedAuthorizationEDataObject1. + eGet(authorizationExecuteEAttribute), true); + + EDataObject retrievedAuthorizationEDataObject2 = + retrievedAuthorizationContainmentList.get(1); + + assertEquals( + dataObjectToRelativeDNCache. + get(retrievedAuthorizationEDataObject2).toString(), + "example-com-users-accounts-Authorization-id=3,cn=authorizationList,example-com-users-accounts-User-id=1"); + + assertEquals( + retrievedAuthorizationEDataObject2. + eGet(authorizationIDEAttribute), "3"); + + EDataObject retrievedConfigurationEDataObject = + (EDataObject) retrievedUserDataObject. + eGet(userConfigurationEReference); + + assertEquals( + dataObjectToRelativeDNCache. + get(retrievedConfigurationEDataObject).toString(), + "example-com-users-accounts-Configuration-id=5,cn=configuration,example-com-users-accounts-User-id=1"); + + assertEquals( + "5", + retrievedConfigurationEDataObject. + eGet(configurationIDEAttribute)); + + EDataObject referencedAuthorizationDataObject = + (EDataObject) retrievedConfigurationEDataObject. + eGet(configurationAuthorizationEReference); + + assertSame( + retrievedAuthorizationEDataObject1, + referencedAuthorizationDataObject); + + EList<EDataObject> referenceAuthorizationsList = + (EList<EDataObject>) retrievedConfigurationEDataObject. + eGet(configurationAuthorizationsEReference); + + assertEquals(2, referenceAuthorizationsList.size() ); + } + + public void testReadException() + { + dataObjectToRelativeDNCache = + new Hashtable<EDataObject, String>(); + + try + { + eDataGraph = + EDataGraphReader.read( + userEClass, + "1", + metaContext, + dataObjectToRelativeDNCache); + } + catch ( NamingException e ) + { + readException = true; + } + + assertTrue(readException); + } + + + +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/read/test/EDataObjectReaderTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/read/test/EDataObjectReaderTest.java new file mode 100644 index 0000000000..9617599acb --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/read/test/EDataObjectReaderTest.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.emf.read.test; + +import javax.naming.NamingException; + +import org.apache.tuscany.das.ldap.emf.read.EDataObjectReader; +import org.apache.tuscany.das.ldap.prototype.setup.test.EDataObjectSetupTest; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.sdo.EDataObject; + +public class EDataObjectReaderTest +extends EDataObjectSetupTest +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws Exception + { + super.setUp(); + } + + public void testRead() throws NamingException + { + EDataObject eDataObject = + EDataObjectReader.read( + userEClass, + "1", + rootContext); + + assertEquals(eDataObject.eGet(userNameEAttribute), "ole"); + assertEquals(eDataObject.eGet(userPasswordEAttribute), "secret"); + assertEquals(eDataObject.eGet(userAgeEAttribute), 33); + assertEquals(eDataObject.eGet(userHeightEAttribute), 6.11); + assertEquals(eDataObject.eGet(userIsMaleEAttribute), true); + + EList userAliases = ( EList ) eDataObject.eGet(userAliasesEAttribute); + assertEquals(userAliases.size(), 3); + assertEquals(userAliases.get(0), "neo"); + assertEquals(userAliases.get(1), "trinity"); + assertEquals(userAliases.get(2), "morpheus"); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/test/LdapDASHelperTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/test/LdapDASHelperTest.java new file mode 100644 index 0000000000..ef8a197f7c --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/test/LdapDASHelperTest.java @@ -0,0 +1,185 @@ +/* + * 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.test; + +import java.io.File; +import java.util.Hashtable; +import java.util.Map; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +import junit.framework.TestCase; + +import org.apache.commons.io.FileUtils; +import org.apache.tuscany.das.ldap.connect.ADSEmbeddedConnection; +import org.apache.tuscany.das.ldap.emf.Context; +import org.apache.tuscany.das.ldap.emf.LdapDAS; +import org.apache.tuscany.das.ldap.emf.LdapDASHelper; +import org.apache.tuscany.model.Configuration; +import org.apache.tuscany.model.ConfigurationFactory; +import org.apache.tuscany.model.DASMeta; +import org.eclipse.emf.ecore.sdo.EDataGraph; +import org.eclipse.emf.ecore.sdo.EDataObject; + +public class LdapDASHelperTest extends TestCase +{ + + private LdapContext schemaContext = null; + private ADSEmbeddedConnection adsEmbeddedConnection; + Configuration configuration = null; + + public void tearDown() throws NamingException, Exception + { + adsEmbeddedConnection.shutdown(); + } + + public void setUp() throws Exception + { + /* + * Note that I had to move the schemaContext + * creation inside each test method due to a + * bug in ADS. + */ + FileUtils.deleteDirectory(new File("server-work")); + + configuration = + ConfigurationFactory. + INSTANCE. + createConfiguration(); + + adsEmbeddedConnection = + new ADSEmbeddedConnection( + configuration); + } + + + public void testReadDasMeta() throws Exception + { + Configuration configuration = + ConfigurationFactory. + INSTANCE. + createConfiguration(); + + configuration.setEmbedded( true ); + + LdapDAS ldapDAS = new LdapDAS(configuration); + + Context context = ldapDAS.getContext(); + + + Map<EDataObject, String> metaDataObjectToRelativeDNCache = + new Hashtable<EDataObject, String>(); + + EDataGraph dasMetaDataGraph = + LdapDASHelper.readDasMeta( + context, + metaDataObjectToRelativeDNCache ); + + assertEquals( + "org-apache-tuscany-das-ldap-configuration-model-ecore-v100-DASMeta-id=0", + metaDataObjectToRelativeDNCache.values().toArray()[0]); + + DASMeta dasMeta = ( DASMeta ) dasMetaDataGraph.getRootObject(); + + assertEquals( + dasMeta, + metaDataObjectToRelativeDNCache.keySet().toArray()[0] ); + + assertEquals( + "org-apache-tuscany-das-ldap-configuration-model-ecore-v100-DASMeta-id=0", + metaDataObjectToRelativeDNCache.get(dasMeta)); + } + + public void testCreateEcoreContext() throws NamingException + { + schemaContext = + adsEmbeddedConnection. + connect( + configuration.getSchemaPartitionName() ); + + LdapContext ecoreContext = + LdapDASHelper.createEcoreContext( + schemaContext); + + assertEquals( + ecoreContext.getNameInNamespace(), + "cn=ecore,ou=schema" ); + + schemaContext.destroySubcontext( "cn=ecore" ); + } + + public void testCreateEcoreObjectClassesContext() throws NamingException + { + schemaContext = + adsEmbeddedConnection. + connect( + configuration.getSchemaPartitionName() ); + + LdapContext ecoreContext = + LdapDASHelper.createEcoreContext( + schemaContext); + + LdapContext ecoreObjectClassesContext = + LdapDASHelper. + createEcoreObjectClassesContext( + schemaContext ); + + ecoreObjectClassesContext = + LdapDASHelper. + createEcoreObjectClassesContext( + schemaContext ); + + assertEquals( + ecoreObjectClassesContext.getNameInNamespace(), + "ou=objectClasses,cn=ecore,ou=schema"); + + + ecoreContext.destroySubcontext( "ou=objectClasses" ); + schemaContext.destroySubcontext( "cn=ecore" ); + } + + public void testCreateEcoreAttributeTypesContext() throws NamingException + { + schemaContext = + adsEmbeddedConnection. + connect( + configuration.getSchemaPartitionName() ); + + LdapContext ecoreContext = + LdapDASHelper.createEcoreContext( + schemaContext); + + LdapContext ecoreAttributeTypesContext = + LdapDASHelper. + createEcoreAttributeTypesContext( schemaContext ); + + ecoreAttributeTypesContext = + LdapDASHelper. + createEcoreAttributeTypesContext( schemaContext ); + + assertEquals( + ecoreAttributeTypesContext.getNameInNamespace(), + "ou=attributeTypes,cn=ecore,ou=schema"); + + ecoreContext.destroySubcontext( "ou=attributeTypes" ); + schemaContext.destroySubcontext( "cn=ecore" ); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/test/LdapDASTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/test/LdapDASTest.java new file mode 100644 index 0000000000..feeed1e253 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/test/LdapDASTest.java @@ -0,0 +1,437 @@ +/* + * 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.test; + +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.emf.Context; +import org.apache.tuscany.das.ldap.emf.LdapDAS; +import org.apache.tuscany.das.ldap.prototype.setup.test.LdapDASSetupTest; +import org.apache.tuscany.model.Configuration; +import org.apache.tuscany.model.ConfigurationFactory; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.sdo.EChangeSummary; +import org.eclipse.emf.ecore.sdo.EDataGraph; +import org.eclipse.emf.ecore.sdo.EDataObject; + + +public class LdapDASTest extends LdapDASSetupTest +{ + Configuration configuration = null; + LdapDAS ldapDAS = null; + + public void setUp() throws Exception + { + super.setUp(); + configuration = + ConfigurationFactory. + INSTANCE. + createConfiguration(); + + configuration.setEmbedded( true ); + ldapDAS = new LdapDAS(configuration); + } + + public void tearDown() throws NamingException, Exception + { + ldapDAS.getAdsEmbeddedConnection().shutdown(); + super.tearDown(); + } + + public void testConstructor() throws NamingException + { + Context context = ldapDAS.getContext(); + assertEquals( + "ou=das", + context.getDasContext().getNameInNamespace()); + assertEquals( + "cn=meta,ou=das", + context.getDasMetaContext().getNameInNamespace()); + assertEquals( + "ou=attributeTypes,cn=ecore,ou=schema", + context.getEcoreAttributeTypesContext().getNameInNamespace()); + assertEquals( + "ou=objectClasses,cn=ecore,ou=schema", + context.getEcoreObjectClassesContext().getNameInNamespace()); + } + + public void testCreate() throws Exception, NamingException + { + ldapDAS.create( eDataGraph ); + + Context context = + ldapDAS.getContext(); + + dataObjectToRelativeDNCache = + context.getDataObjectToRelativeDNCache(); + + Map<String, LdapContext> xsdNamespaceToLdapContextMap = + context. + getXsdNamespaceToLdapContextMap(); + + EDataObject rootObject = + ( EDataObject ) + eDataGraph.getRootObject(); + + String namespace = + rootObject. + eClass(). + getEPackage(). + getNsURI(); + + assertEquals( + "http://example.com/users/accounts", + namespace); + + LdapContext rootContext = + xsdNamespaceToLdapContextMap. + get( namespace ); + + assertEquals( + "cn=accounts,cn=users,cn=example,cn=com,ou=das", + rootContext.getNameInNamespace() ); + + String userDataObjectRDN = + dataObjectToRelativeDNCache.get( rootObject ); + + //============================================================ + //Verify the RDN + //============================================================ + + assertEquals( + "example-com-users-accounts-User-id=1", + userDataObjectRDN ); + + //============================================================ + //Verify the attribute values + //============================================================ + + Attributes attributes = + rootContext. + getAttributes( userDataObjectRDN ); + + assertEquals( + attributes.get("objectClass").get(), + "example-com-users-accounts-User"); + + assertEquals( + attributes.get("objectClass").get(1), + "metaObjectClass"); + + assertEquals( + attributes.get("objectClass").get(2), + "metaTop"); + + assertEquals( + attributes.get("objectClass").get(3), + "top"); + + assertEquals( + attributes.get("example-com-users-accounts-User-userAge").get(), + "33"); + + assertEquals( + attributes.get("example-com-users-accounts-User-userName").get(), + "ole"); + + assertEquals( + attributes.get("example-com-users-accounts-User-userPassword").get(), + "secret"); + + assertEquals( + attributes.get("example-com-users-accounts-User-userHeight").get(), + "6.11"); + + assertEquals( + attributes.get("example-com-users-accounts-User-id").get(), + "1"); + + assertEquals( + attributes.get("example-com-users-accounts-User-isMale").get(), + "TRUE"); + + + assertEquals( + attributes.get("example-com-users-accounts-User-userAliases").get(), + "neo"); + + assertEquals( + attributes.get("example-com-users-accounts-User-userAliases").get(1), + "trinity"); + + assertEquals( + attributes.get("example-com-users-accounts-User-userAliases").get(2), + "morpheus"); + + assertEquals( + attributes.get("example-com-users-accounts-User-configuration").get(), + "5"); + + assertEquals( + attributes.get("example-com-users-accounts-User-authorizationList").get(), + "2"); + + assertEquals( + attributes.get("example-com-users-accounts-User-authorizationList").get(1), + "3"); + + + EDataObject configurationObject = + ( EDataObject ) rootObject. + eGet( userConfigurationEReference ); + + String userConfigurationDataObjectRDN = + dataObjectToRelativeDNCache. + get( configurationObject ); + + //============================================================ + //Verify the RDN + //============================================================ + + assertEquals( + "example-com-users-accounts-Configuration-id=5,cn=configuration,example-com-users-accounts-User-id=1", + userConfigurationDataObjectRDN); + + attributes = rootContext.getAttributes( userConfigurationDataObjectRDN ); + + //============================================================ + //Verify the Attributes + //============================================================ + + assertEquals( + attributes.get("objectClass").get(), + "example-com-users-accounts-Configuration"); + + assertEquals( + attributes.get("objectClass").get(1), + "metaObjectClass"); + + assertEquals( + attributes.get("objectClass").get(2), + "metaTop"); + + assertEquals( + attributes.get("objectClass").get(3), + "top"); + + assertEquals( + attributes.get("example-com-users-accounts-Configuration-authorization").get(), + "2"); + + assertEquals( + attributes.get("example-com-users-accounts-Configuration-id").get(), + "5"); + + assertEquals( + attributes.get("example-com-users-accounts-Configuration-authorizations").get(), + "2"); + + assertEquals( + attributes.get("example-com-users-accounts-Configuration-authorizations").get(1), + "3"); + + EList<EDataObject> authorizationList = + ( EList<EDataObject> ) rootObject. + eGet( userAuthorizationEReference ); + + EDataObject authorizationDataObject1 = + authorizationList.get( 0 ); + + String userAuthorizationDataObject1RDN = + dataObjectToRelativeDNCache. + get( authorizationDataObject1 ); + + //============================================================ + //Verify the RDN + //============================================================ + + assertEquals( + "example-com-users-accounts-Authorization-id=2,cn=authorizationList,example-com-users-accounts-User-id=1", + userAuthorizationDataObject1RDN); + + attributes = rootContext.getAttributes( userAuthorizationDataObject1RDN ); + + //============================================================ + //Verify the Attributes + //============================================================ + + assertEquals( + attributes.get("objectClass").get(), + "example-com-users-accounts-Authorization"); + + assertEquals( + attributes.get("example-com-users-accounts-Authorization-id").get(), + "2"); + + assertEquals( + attributes.get("example-com-users-accounts-Authorization-executeAuthorization").get(), + "TRUE"); + + assertEquals( + attributes.get("example-com-users-accounts-Authorization-readAuthorization").get(), + "TRUE"); + + assertEquals( + attributes.get("example-com-users-accounts-Authorization-writeAuthorization").get(), + "TRUE"); + + assertEquals( + attributes.get("example-com-users-accounts-Authorization-fileName").get(), + "somefile.text"); + + + EDataObject authorizationDataObject2 = + authorizationList.get( 1 ); + + String userAuthorizationDataObject2RDN = + dataObjectToRelativeDNCache. + get( authorizationDataObject2 ); + + //============================================================ + //Verify the RDN + //============================================================ + + assertEquals( + "example-com-users-accounts-Authorization-id=3,cn=authorizationList,example-com-users-accounts-User-id=1", + userAuthorizationDataObject2RDN); + + attributes = rootContext.getAttributes( userAuthorizationDataObject2RDN ); + + //============================================================ + //Verify the Attributes + //============================================================ + + assertEquals( + attributes.get("objectClass").get(), + "example-com-users-accounts-Authorization"); + + assertEquals( + attributes.get("example-com-users-accounts-Authorization-id").get(), + "3"); + + assertEquals( + attributes.get("example-com-users-accounts-Authorization-executeAuthorization").get(), + "TRUE"); + + assertEquals( + attributes.get("example-com-users-accounts-Authorization-readAuthorization").get(), + "TRUE"); + + assertEquals( + attributes.get("example-com-users-accounts-Authorization-writeAuthorization").get(), + "TRUE"); + + assertEquals( + attributes.get("example-com-users-accounts-Authorization-fileName").get(), + "someOtherfile.text"); + + + /* Finding out the values of the attributes + NamingEnumeration namingEnumeration = attributes.getAll(); + while (namingEnumeration.hasMore()) + { + Attribute attribute = ( Attribute ) namingEnumeration.next(); + System.out.println(attribute); + } + */ + } + + public void testRead() throws NamingException, Exception + { + /* + * More exhaustive testing has been done on the + * class that LdapDAS.read() delegates to. + */ + ldapDAS.create( eDataGraph ); + + EDataGraph newEDataGraph = + ldapDAS.read( userEClass, "1" ); + + EDataObject rootObject = + ( EDataObject ) newEDataGraph.getRootObject(); + + assertEquals( + rootObject.eGet( userNameEAttribute), + "ole"); + + EDataObject configurationObject = + ( EDataObject ) + rootObject.eGet( userConfigurationEReference ); + + assertEquals( + configurationObject.eGet( configurationIDEAttribute), + "5"); + + } + + public void testUpdate() throws NamingException, Exception + { + /* + * More exhaustive testing has been done on the + * class that LdapDAS.update() delegates to. + */ + ldapDAS.create( eDataGraph ); + + EDataGraph newEDataGraph = ldapDAS.read( userEClass, "1" ); + + + //newEDataGraph.getChangeSummary().beginLogging(); + EChangeSummary eChangeSummary = ( EChangeSummary ) newEDataGraph.getChangeSummary(); + eChangeSummary.beginLogging(); + + EDataObject rootObject = + ( EDataObject ) newEDataGraph.getRootObject(); + + rootObject.eSet( userNameEAttribute, "Brooke" ); + rootObject.eSet( userAgeEAttribute, 5 ); + + //newEDataGraph.getChangeSummary().endLogging(); + + eChangeSummary.endLogging(); + ldapDAS.update( newEDataGraph ); + + LdapContext rootContext = ldapDAS.getContext(). + getXsdNamespaceToLdapContextMap(). + get( + rootObject. + eClass(). + getEPackage(). + getNsURI()); + + Attributes attributes = + rootContext. + getAttributes( + "example-com-users-accounts-User-id=1" ); + + assertEquals( + attributes.get("example-com-users-accounts-User-userAge").get(), + "5"); + + assertEquals( + attributes.get("example-com-users-accounts-User-userName").get(), + "Brooke"); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/update/test/EDataGraphUpdateTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/update/test/EDataGraphUpdateTest.java new file mode 100644 index 0000000000..d76ccccac0 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/emf/update/test/EDataGraphUpdateTest.java @@ -0,0 +1,180 @@ +/* + * 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.test; + +import java.util.Hashtable; + +import javax.naming.NamingException; +import javax.naming.directory.Attributes; + +import org.apache.tuscany.das.ldap.emf.read.EDataGraphReader; +import org.apache.tuscany.das.ldap.emf.update.EDataGraphUpdater; +import org.apache.tuscany.das.ldap.prototype.setup.test.EDataGraphSetupTest; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.sdo.EChangeSummary; +import org.eclipse.emf.ecore.sdo.EDataObject; + +public class EDataGraphUpdateTest +extends EDataGraphSetupTest +{ + public void testUpdate() throws NamingException + { + dataObjectToRelativeDNCache = + new Hashtable<EDataObject, String>(); + + eDataGraph = + EDataGraphReader.read( + userEClass, + "1", + rootContext, + dataObjectToRelativeDNCache); + + assertTrue( + dataObjectToRelativeDNCache. + containsValue(authorizationDataObject1RDN)); + assertTrue( + dataObjectToRelativeDNCache. + containsValue(authorizationDataObject2RDN)); + + userDataObject = + (EDataObject) eDataGraph.getRootObject(); + + String userEntryRDN = dataObjectToRelativeDNCache.get(userDataObject); + Attributes attributes = rootContext.getAttributes(userEntryRDN); + + assertEquals(userDataObject.eGet(userNameEAttribute), "ole"); + assertEquals(userDataObject.eGet(userPasswordEAttribute), "secret"); + assertEquals(userDataObject.eGet(userAgeEAttribute), 33); + assertEquals(userDataObject.eGet(userHeightEAttribute), 6.11); + assertEquals(userDataObject.eGet(userIsMaleEAttribute), true); + assertEquals("2", attributes.get("example-com-users-accounts-User-authorizationList").get(0)); + assertEquals("3", attributes.get("example-com-users-accounts-User-authorizationList").get(1)); + + EChangeSummary eChangeSummary = + (EChangeSummary) eDataGraph.getChangeSummary(); + + eChangeSummary.beginLogging(); + + userDataObject.eSet(userIsMaleEAttribute, false); + userDataObject.eSet(userHeightEAttribute, 2.00); + userDataObject.eSet(userAgeEAttribute, 80); + userDataObject.eSet(userPasswordEAttribute, "totallysecret"); + + EList<EDataObject> userAuthorizationReferenceList = + (EList)userDataObject + .eGet(userAuthorizationEReference); + + userAuthorizationReferenceList.remove(0); + + assertEquals(userDataObject.eGet(userIsMaleEAttribute), false); + assertEquals(userDataObject.eGet(userHeightEAttribute), 2.00); + assertEquals(userDataObject.eGet(userAgeEAttribute), 80); + assertEquals(userDataObject.eGet(userPasswordEAttribute), "totallysecret"); + + eChangeSummary.endLogging(); + + EDataGraphUpdater.update( + eDataGraph, + rootContext, + dataObjectToRelativeDNCache); + + attributes = rootContext.getAttributes(userEntryRDN); + + assertEquals("FALSE", attributes.get("example-com-users-accounts-User-isMale").get()); + assertEquals("2.0", attributes.get("example-com-users-accounts-User-userHeight").get()); + assertEquals("80", attributes.get("example-com-users-accounts-User-userAge").get()); + assertEquals("totallysecret", attributes.get("example-com-users-accounts-User-userPassword").get()); + assertEquals("5", attributes.get("example-com-users-accounts-User-configuration").get()); + + /* + * Test that the ID of the Authorization instance with id 2 was removed + */ + assertEquals( + "3", + attributes. + get("example-com-users-accounts-User-authorizationList"). + get(0)); + + /* + * Also make sure that the dataObjectToRelativeDNCache was updated + */ + assertFalse( + dataObjectToRelativeDNCache. + containsValue(authorizationDataObject1RDN)); + + eChangeSummary.beginLogging(); + + userDataObject.eUnset(userConfigurationEReference); + userAuthorizationReferenceList.remove(0); + + eChangeSummary.endLogging(); + + EDataGraphUpdater.update( + eDataGraph, + rootContext, + dataObjectToRelativeDNCache); + + attributes = rootContext.getAttributes(userEntryRDN); + + boolean isConfigurationAttributeDeleted = false; + + try { + attributes.get("example-com-users-accounts-User-configuration").get(); + } + catch (Exception e) + { + isConfigurationAttributeDeleted = true; + } + assertTrue(isConfigurationAttributeDeleted); + + boolean isAuthorizationlListAttributeDeleted = false; + + try { + attributes.get("example-com-users-accounts-User-authorizationList").get(); + } + catch (Exception e) + { + isAuthorizationlListAttributeDeleted = true; + } + assertTrue(isAuthorizationlListAttributeDeleted); + assertFalse( + dataObjectToRelativeDNCache. + containsValue(authorizationDataObject2RDN)); + + eChangeSummary.beginLogging(); + + userAuthorizationReferenceList.add(authorizationDataObject0); + userAuthorizationReferenceList.add(authorizationDataObject1); + + eChangeSummary.endLogging(); + + EDataGraphUpdater.update( + eDataGraph, + rootContext, + dataObjectToRelativeDNCache); + + assertTrue( + dataObjectToRelativeDNCache. + containsValue(authorizationDataObject1RDN)); + assertTrue( + dataObjectToRelativeDNCache. + containsValue(authorizationDataObject2RDN)); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/learning/test/LearningTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/learning/test/LearningTest.java new file mode 100644 index 0000000000..ce603e17f0 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/learning/test/LearningTest.java @@ -0,0 +1,38 @@ +package org.apache.tuscany.das.ldap.learning.test; + +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.SearchResult; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.schema.embedded.setup.test.AbstractTestSetup; + +public class LearningTest extends AbstractTestSetup { + + public void testSearch() throws NamingException + { + LdapContext contextL0 = + (LdapContext) + dasPartitionContext.createSubcontext("cn=L0"); + + contextL0.createSubcontext("cn=L1"); + + Attributes searchAttributes = + new BasicAttributes(true); + + searchAttributes.put(new BasicAttribute("cn")); + + NamingEnumeration answer = contextL0.search("", searchAttributes); + while (answer.hasMore()) { + + SearchResult result = (SearchResult)answer.next(); + Attributes attributes = result.getAttributes(); + assertEquals("L1", attributes.get("cn").get().toString()); + } + dasPartitionContext.destroySubcontext("cn=L1, cn=L0"); + dasPartitionContext.destroySubcontext("cn=L0"); + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/create/test/EAttributeTypeCreatorTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/create/test/EAttributeTypeCreatorTest.java new file mode 100644 index 0000000000..c52a9ede1c --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/create/test/EAttributeTypeCreatorTest.java @@ -0,0 +1,127 @@ +/* + * 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.test; + +import javax.naming.NamingException; +import javax.naming.directory.DirContext; + +import org.apache.tuscany.das.ldap.schema.create.SimpleTypeRDNCreator; +import org.apache.tuscany.das.ldap.schema.emf.create.EAttributeTypeCreator; +import org.apache.tuscany.das.ldap.schema.emf.destroy.EStructuralFeatureTypeDestroyer; +import org.apache.tuscany.das.ldap.schema.embedded.setup.test.EcoreSchemaContextsSetup; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EcoreFactory; +import org.eclipse.emf.ecore.EcorePackage; + +public class EAttributeTypeCreatorTest +extends EcoreSchemaContextsSetup +{ + private static final String namespaceURI = + "http://org.apache.tuscany/datatypes"; + + private static EcoreFactory ecoreFactory = + EcoreFactory.eINSTANCE; + + private static EcorePackage ecorePackage = + EcorePackage.eINSTANCE; + + private static EAttribute eAttribute = + ecoreFactory.createEAttribute(); + + private static String eAttributeName = + "ole"; + + private static DirContext eAttributeEntryContext = + null; + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void tearDown() throws NamingException, Exception + { + EStructuralFeatureTypeDestroyer. + destroy( + ecoreAttributeTypesContext, + eAttribute, + TUSCANY_OID_PREFIX_VALUE); + + super.tearDown(); + } + + public void testCreate() throws NamingException, Exception + { + EPackage ePackage = + ecoreFactory. + createEPackage(); + + ePackage. + setNsURI(namespaceURI); + + EClass eContainingClass = + ecoreFactory. + createEClass(); + + String eContainingClassName = + eContainingClass.getName(); + + ePackage. + getEClassifiers(). + add( eContainingClass ); + + eContainingClass. + getEStructuralFeatures(). + add(eAttribute); + + eAttribute. + setName(eAttributeName); + + eAttribute. + setEType(ecorePackage.getEString()); + + EAttributeTypeCreator + eAttributeTypeCreator = + new EAttributeTypeCreator(); + + eAttributeTypeCreator. + create( + ecoreAttributeTypesContext, + eAttribute, + TUSCANY_OID_PREFIX_VALUE ); + + String rdn = + SimpleTypeRDNCreator. + create( + TUSCANY_OID_PREFIX_VALUE, + namespaceURI, + eContainingClassName, + eAttributeName); + + eAttributeEntryContext = + ( DirContext ) + ecoreAttributeTypesContext. + lookup( rdn ); + + assertNotNull(eAttributeEntryContext); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/create/test/EObjectClassCreatorHelperTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/create/test/EObjectClassCreatorHelperTest.java new file mode 100644 index 0000000000..056658b3c1 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/create/test/EObjectClassCreatorHelperTest.java @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.das.ldap.schema.emf.create.test; + +import javax.naming.NamingException; +import javax.naming.directory.DirContext; + +import org.apache.tuscany.das.ldap.schema.emf.create.EObjectClassCreatorHelper; +import org.apache.tuscany.das.ldap.schema.emf.create.EcoreTypeSystemHelper; +import org.apache.tuscany.das.ldap.schema.embedded.setup.test.DASContextSetup; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EcoreFactory; + +public class EObjectClassCreatorHelperTest +extends DASContextSetup +{ + private static EcoreFactory ecoreFactory = + EcoreFactory.eINSTANCE; + + private EClass eClassL0 = + null; + + private EClass eClassL1 = + null; + + public void setUp() + throws NamingException, Exception + { + super.setUp(); + + eClassL0 = + ecoreFactory. + createEClass(); + eClassL0.setName( "L0" ); + + eClassL1 = + ecoreFactory. + createEClass(); + eClassL1.setName( "L1" ); + + eClassL1. + getESuperTypes(). + add(eClassL0); + } + + public void testCreateInheritanceMetaData() + throws NamingException + { + EObjectClassCreatorHelper. + createInheritanceMetaData( + metaContext, + eClassL1 ); + + DirContext parentContext = + ( DirContext ) + metaContext. + lookup( "cn=" + eClassL0.getName() ); + + assertNotNull(parentContext); + + DirContext childContext = + ( DirContext ) + parentContext. + lookup( "cn=" + eClassL1.getName() ); + + assertNotNull(childContext); + + parentContext.destroySubcontext( + "cn=" + eClassL1.getName() ); + + metaContext.destroySubcontext( + "cn=" + eClassL0.getName() ); + } + + public void testGetEClassParent() + { + EClass eClassParent = + null; + + eClassParent = + EcoreTypeSystemHelper. + getEClassParent(eClassL1); + + assertSame(eClassL0, eClassParent); + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/create/test/EObjectClassCreatorTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/create/test/EObjectClassCreatorTest.java new file mode 100644 index 0000000000..9ef6f6e086 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/create/test/EObjectClassCreatorTest.java @@ -0,0 +1,411 @@ +/* + * 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.test; + +import java.util.ArrayList; +import java.util.List; + +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.directory.Attributes; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.schema.create.ComplexTypeRDNCreator; +import org.apache.tuscany.das.ldap.schema.emf.create.EObjectClassCreator; +import org.apache.tuscany.das.ldap.schema.emf.destroy.EObjectClassDestroyer; +import org.apache.tuscany.das.ldap.schema.embedded.setup.test.EcoreSchemaAndDASContextsSetup; +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.EcoreFactory; +import org.eclipse.emf.ecore.EcorePackage; + +public class EObjectClassCreatorTest +extends EcoreSchemaAndDASContextsSetup +{ + boolean isObjectClassL0Created = false; + boolean isObjectClassL1Created = false; + + public void tearDown() + throws NamingException, Exception + { + if (isObjectClassL1Created) + { + EObjectClassDestroyer. + destroy( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL1, + TUSCANY_OID_PREFIX_VALUE ); + + metaContext. + destroySubcontext( + "cn="+eClassL0.getName() ); + } + + if (isObjectClassL0Created) + { + EObjectClassDestroyer. + destroy( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL0, + TUSCANY_OID_PREFIX_VALUE ); + } + + super.tearDown(); + } + + public void setUp() + throws NamingException, Exception + { + super.setUp(); + + ecoreFactory = + EcoreFactory.eINSTANCE; + ecorePackage = + EcorePackage.eINSTANCE; + + processedEClassifiers = + new ArrayList<EClass>(); + + eClassL0 = + ecoreFactory.createEClass(); + + eClassL1 = + ecoreFactory.createEClass(); + + eClassL0.setName( "L0" ); + eClassL1.setName( "L1" ); + + isObjectClassL0Created = false; + isObjectClassL1Created = false; + + } + + /* + * Tests that eClassL0 and eClassL1 are both + * created an the corresponding entries exist + * in the meta section of the model. + */ + public void testCreate0() + throws NamingException, Exception + { + eClassL1. + getESuperTypes(). + add(eClassL0); + + EPackage ePackage = + ecoreFactory. + createEPackage(); + + ePackage. + setNsURI(xsdNamespace); + + ePackage. + getEClassifiers(). + add( eClassL0 ); + + ePackage. + getEClassifiers(). + add( eClassL1 ); + + + EObjectClassCreator + eObjectClassCreator = + new EObjectClassCreator(); + + eObjectClassCreator. + create( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL1, + processedEClassifiers, + TUSCANY_OID_PREFIX_VALUE ); + + String rdnL0 = + ComplexTypeRDNCreator. + create( + TUSCANY_OID_PREFIX_VALUE, + xsdNamespace, + eClassL0.getName()); + + eObjectClassL0EntryContext = + ( LdapContext ) + ecoreObjectClassesContext. + lookup( rdnL0 ); + + assertNotNull( + eObjectClassL0EntryContext); + + isObjectClassL0Created = true; + + String rdnL1 = + ComplexTypeRDNCreator. + create( + TUSCANY_OID_PREFIX_VALUE, + xsdNamespace, + eClassL1.getName()); + + eObjectClassL1EntryContext = + ( LdapContext ) + ecoreObjectClassesContext. + lookup( rdnL1 ); + + assertNotNull( + eObjectClassL1EntryContext); + + isObjectClassL1Created = true; + } + + /* + * Test that eClassL0 is added to the list + * of processed eClassifiers and that the + * corresponding ObjectClass is created. + * + * Also test the employeeNameEAttribute + * and departmentEReferences are added. + */ + public void testCreate1() + throws NamingException, Exception + { + EPackage ePackage = + ecoreFactory. + createEPackage(); + + ePackage. + setNsURI(xsdNamespace); + + ePackage. + getEClassifiers(). + add( eClassL0 ); + + + EAttribute employeeNameEAttribute = + ecoreFactory.createEAttribute(); + employeeNameEAttribute.setName( + "employeeName" ); + employeeNameEAttribute.setEType( + ecorePackage.getEString() ); + + eClassL0. + getEStructuralFeatures(). + add(employeeNameEAttribute); + + EReference departmentEReference = + ecoreFactory.createEReference(); + departmentEReference.setName( "department" ); + departmentEReference.setEType( eClassL0 ); + + eClassL0. + getEStructuralFeatures(). + add(departmentEReference); + + EObjectClassCreator + eObjectClassCreator = + new EObjectClassCreator(); + + eObjectClassCreator. + create( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL0, + processedEClassifiers, + TUSCANY_OID_PREFIX_VALUE ); + + assertTrue(processedEClassifiers.contains( eClassL0 )); + + String rdnL0 = + ComplexTypeRDNCreator. + create( + TUSCANY_OID_PREFIX_VALUE, + xsdNamespace, + eClassL0.getName()); + + eObjectClassL0EntryContext = + ( LdapContext ) + ecoreObjectClassesContext. + lookup( rdnL0 ); + + assertNotNull( + eObjectClassL0EntryContext); + + isObjectClassL0Created = true; + + Attributes attributes = + eObjectClassL0EntryContext.getAttributes( "" ); + + NamingEnumeration namingEnumeration = + attributes.get( M_MAY ).getAll(); + + boolean hasDepartmentValue = + false; + boolean hasEmployeeNameValue = + false; + + String departmentValue = + "example-com-users-accounts-L0-department"; + + String employeeNameValue = + "example-com-users-accounts-L0-employeeName"; + + + while (namingEnumeration.hasMore()) + { + String attributeValue = + namingEnumeration.next().toString(); + if (departmentValue.equals(attributeValue)) + { + hasDepartmentValue = true; + } + if (employeeNameValue.equals(attributeValue)) + { + hasEmployeeNameValue = true; + } + } + assertTrue(hasDepartmentValue); + assertTrue(hasEmployeeNameValue); + } + + /* + * Test that both ObjectClasses are created + * when eClassL1 inherits from eClassL0, + * but eClass0's ObjectClass entry + * is already created. + */ + public void testCreate3() + throws NamingException, Exception + { + EPackage ePackage = + ecoreFactory. + createEPackage(); + + ePackage. + setNsURI(xsdNamespace); + + ePackage. + getEClassifiers(). + add( eClassL0 ); + + ePackage. + getEClassifiers(). + add( eClassL1 ); + + EObjectClassCreator + eObjectClassCreator = + new EObjectClassCreator(); + + eObjectClassCreator. + create( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL0, + processedEClassifiers, + TUSCANY_OID_PREFIX_VALUE ); + + isObjectClassL0Created = true; + + eClassL1. + getESuperTypes(). + add(eClassL0); + + eObjectClassCreator. + create( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL1, + processedEClassifiers, + TUSCANY_OID_PREFIX_VALUE ); + + String rdnL0 = + ComplexTypeRDNCreator. + create( + TUSCANY_OID_PREFIX_VALUE, + xsdNamespace, + eClassL0.getName()); + + eObjectClassL0EntryContext = + ( LdapContext ) + ecoreObjectClassesContext. + lookup( rdnL0 ); + + assertNotNull( + eObjectClassL0EntryContext); + + isObjectClassL0Created = true; + + String rdnL1 = + ComplexTypeRDNCreator. + create( + TUSCANY_OID_PREFIX_VALUE, + xsdNamespace, + eClassL1.getName()); + + eObjectClassL1EntryContext = + ( LdapContext ) + ecoreObjectClassesContext. + lookup( rdnL1 ); + + assertNotNull( + eObjectClassL1EntryContext); + + isObjectClassL1Created = true; + } + + private static EcoreFactory ecoreFactory = + null; + + private static EcorePackage ecorePackage = + null; + + private static EClass eClassL0 = + null; + + private static EClass eClassL1 = + null; + + + private static List<EClass> + processedEClassifiers = + null; + + private static LdapContext + eObjectClassL0EntryContext = + null; + + private static LdapContext + eObjectClassL1EntryContext = + null; + + private static LdapContext + eClassL0MetaContext = + null; + + private static LdapContext + eClassL1MetaContext = + null; + }
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/create/test/EReferenceTypeCreatorTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/create/test/EReferenceTypeCreatorTest.java new file mode 100644 index 0000000000..c316231c99 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/create/test/EReferenceTypeCreatorTest.java @@ -0,0 +1,125 @@ +/* + * 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.test; + +import javax.naming.NamingException; +import javax.naming.directory.DirContext; + +import org.apache.tuscany.das.ldap.schema.create.SimpleTypeRDNCreator; +import org.apache.tuscany.das.ldap.schema.emf.create.EReferenceTypeCreator; +import org.apache.tuscany.das.ldap.schema.emf.destroy.EStructuralFeatureTypeDestroyer; +import org.apache.tuscany.das.ldap.schema.embedded.setup.test.EcoreSchemaContextsSetup; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EcoreFactory; + +public class EReferenceTypeCreatorTest +extends EcoreSchemaContextsSetup +{ + private static final String namespaceURI = + "http://org.apache.tuscany/datatypes"; + + private static EcoreFactory ecoreFactory = + EcoreFactory.eINSTANCE; + + private static EReference eReference = + ecoreFactory.createEReference(); + + private static String eReferenceName = + "ole"; + + private static DirContext eReferenceEntryContext = + null; + + public void setUp() + throws NamingException, Exception + { + super.setUp(); + } + + public void tearDown() + throws NamingException, Exception + { + EStructuralFeatureTypeDestroyer. + destroy( + ecoreAttributeTypesContext, + eReference, + TUSCANY_OID_PREFIX_VALUE); + + super.tearDown(); + } + + public void testCreate() throws NamingException, Exception + { + EPackage ePackage = + ecoreFactory. + createEPackage(); + + ePackage. + setNsURI(namespaceURI); + + EClass eContainingClass = + ecoreFactory. + createEClass(); + + String eContainingClassName = + eContainingClass.getName(); + + ePackage. + getEClassifiers(). + add( eContainingClass ); + + eContainingClass. + getEStructuralFeatures(). + add(eReference); + + eReference. + setName(eReferenceName); + + eReference. + setEType(eContainingClass); + + EReferenceTypeCreator + eReferenceTypeCreator = + new EReferenceTypeCreator(); + + eReferenceTypeCreator. + create( + ecoreAttributeTypesContext, + eReference, + TUSCANY_OID_PREFIX_VALUE ); + + String rdn = + SimpleTypeRDNCreator. + create( + TUSCANY_OID_PREFIX_VALUE, + namespaceURI, + eContainingClassName, + eReferenceName); + + eReferenceEntryContext = + ( DirContext ) + ecoreAttributeTypesContext. + lookup( rdn ); + + assertNotNull(eReferenceEntryContext); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/create/test/EcoreTypeSystemCreatorHelperTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/create/test/EcoreTypeSystemCreatorHelperTest.java new file mode 100644 index 0000000000..02ffe54627 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/create/test/EcoreTypeSystemCreatorHelperTest.java @@ -0,0 +1,58 @@ +/* + * 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.test; + +import java.util.Stack; + +import org.apache.tuscany.das.ldap.schema.emf.create.EcoreTypeSystemHelper; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EcoreFactory; + +import junit.framework.TestCase; + +public class EcoreTypeSystemCreatorHelperTest +extends TestCase +{ + EcoreFactory ecoreFactory = + EcoreFactory.eINSTANCE; + + public void testLoadParentEClassifierStack() + { + EClass eClassL0 = + ecoreFactory.createEClass(); + + EClass eClassL1 = + ecoreFactory.createEClass(); + + EClass eClassL2 = + ecoreFactory.createEClass(); + + eClassL2.getESuperTypes().add(eClassL1); + + eClassL1.getESuperTypes().add(eClassL0); + + Stack<EClass> testStack = + EcoreTypeSystemHelper. + loadParentEClassifierStack( + eClassL2, + null); + + assertEquals(testStack.size(), 2); + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/destroy/test/ECascadingObjectClassDestroyerTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/destroy/test/ECascadingObjectClassDestroyerTest.java new file mode 100644 index 0000000000..9de0d189ba --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/destroy/test/ECascadingObjectClassDestroyerTest.java @@ -0,0 +1,397 @@ +/* + * 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.test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.naming.NamingException; +import javax.naming.directory.DirContext; + +import org.apache.tuscany.das.ldap.schema.create.ComplexTypeRDNCreator; +import org.apache.tuscany.das.ldap.schema.emf.create.EObjectClassCreator; +import org.apache.tuscany.das.ldap.schema.emf.destroy.ECascadingObjectClassDestroyer; +import org.apache.tuscany.das.ldap.schema.embedded.setup.test.EcoreSchemaAndDASContextsSetup; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EcoreFactory; +import org.eclipse.emf.ecore.EcorePackage; + +/* + * TODO Make sure that we test EAttribute deletion as well. + */ +public class ECascadingObjectClassDestroyerTest +extends EcoreSchemaAndDASContextsSetup +{ + public void tearDown() + throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() + throws NamingException, Exception + { + super.setUp(); + + ecoreFactory = + EcoreFactory.eINSTANCE; + ecorePackage = + EcorePackage.eINSTANCE; + + processedEClassifiers = + new ArrayList<EClass>(); + + eClassL0 = + ecoreFactory. + createEClass(); + + eClassL1 = + ecoreFactory. + createEClass(); + + eClassL0.setName( "L0" ); + eClassL1.setName( "L1" ); + + eClassNameToEClassMap = + new HashMap<String, EClass>(); + + eClassNameToEClassMap.put( + eClassL0.getName(), + eClassL0 ); + + eClassNameToEClassMap.put( + eClassL1.getName(), + eClassL1 ); + + } + + /* + * Test the deletion of two + * single level hierarchy ObjectClasses + */ + public void testCreate1() + throws NamingException, Exception + { + eClassL1. + getESuperTypes(). + add(eClassL0); + + EPackage ePackage = + ecoreFactory. + createEPackage(); + + ePackage. + setNsURI(xsdNamespace); + + ePackage. + getEClassifiers(). + add( eClassL0 ); + + ePackage. + getEClassifiers(). + add( eClassL1 ); + + + EObjectClassCreator + eObjectClassCreator = + new EObjectClassCreator(); + + eObjectClassCreator. + create( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL1, + processedEClassifiers, + TUSCANY_OID_PREFIX_VALUE ); + + String rdnL0 = + ComplexTypeRDNCreator. + create( + TUSCANY_OID_PREFIX_VALUE, + xsdNamespace, + eClassL0.getName()); + + String rdnL1 = + ComplexTypeRDNCreator. + create( + TUSCANY_OID_PREFIX_VALUE, + xsdNamespace, + eClassL1.getName()); + + eObjectClassL0EntryContext = + ( DirContext ) + ecoreObjectClassesContext. + lookup( rdnL0 ); + + eObjectClassL1EntryContext = + ( DirContext ) + ecoreObjectClassesContext. + lookup( rdnL1 ); + + assertNotNull( + eObjectClassL0EntryContext); + + assertNotNull( + eObjectClassL1EntryContext); + + eClassL0MetaContext = + ( DirContext ) + metaContext. + lookup( + "cn=" + eClassL0.getName() ); + + assertNotNull( + eClassL0MetaContext ); + + eClassL1MetaContext = + ( DirContext ) + eClassL0MetaContext. + lookup( + "cn=" + eClassL1.getName() ); + + assertNotNull( + eClassL0MetaContext ); + + assertNotNull( + eClassL1MetaContext ); + + + ECascadingObjectClassDestroyer. + destroy( + eClassNameToEClassMap, + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL0, + TUSCANY_OID_PREFIX_VALUE ); + + try + { + eObjectClassL0EntryContext = + ( DirContext ) + ecoreObjectClassesContext. + lookup( rdnL0 ); + } + catch (Exception e) + { + eObjectClassL0EntryContext = + null; + } + + try + { + eObjectClassL1EntryContext = + ( DirContext ) + ecoreObjectClassesContext. + lookup( rdnL1 ); + } + catch (Exception e) + { + eObjectClassL1EntryContext = + null; + } + + assertNull( + eObjectClassL0EntryContext); + + assertNull( + eObjectClassL1EntryContext); + + try + { + eClassL0MetaContext = + ( DirContext ) + metaContext. + lookup( + "cn=" + eClassL0.getName() ); + + } + catch (Exception e) + { + assertNotNull( + eClassL0MetaContext ); + } + } + + + private static EcoreFactory ecoreFactory = + null; + + private static EcorePackage ecorePackage = + null; + + private static EClass eClassL0 = + null; + + private static EClass eClassL1 = + null; + + private static List<EClass> + processedEClassifiers = + null; + + private static DirContext + eObjectClassL0EntryContext = + null; + + private static DirContext + eObjectClassL1EntryContext = + null; + + private static DirContext + eClassL0MetaContext = + null; + + private static DirContext + eClassL1MetaContext = + null; + + private Map<String, EClass> eClassNameToEClassMap = + null; + + /* + * Test the deletion of two + * single level hierarchy ObjectClasses + */ + public void testCreate0() + throws NamingException, Exception + { + EPackage ePackage = + ecoreFactory. + createEPackage(); + + ePackage. + setNsURI(xsdNamespace); + + ePackage. + getEClassifiers(). + add( eClassL0 ); + + ePackage. + getEClassifiers(). + add( eClassL1 ); + + + EObjectClassCreator + eObjectClassCreator = + new EObjectClassCreator(); + + eObjectClassCreator. + create( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL0, + processedEClassifiers, + TUSCANY_OID_PREFIX_VALUE ); + + eObjectClassCreator. + create( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL1, + processedEClassifiers, + TUSCANY_OID_PREFIX_VALUE ); + + String rdnL0 = + ComplexTypeRDNCreator. + create( + TUSCANY_OID_PREFIX_VALUE, + xsdNamespace, + eClassL0.getName()); + + String rdnL1 = + ComplexTypeRDNCreator. + create( + TUSCANY_OID_PREFIX_VALUE, + xsdNamespace, + eClassL1.getName()); + + eObjectClassL0EntryContext = + ( DirContext ) + ecoreObjectClassesContext. + lookup( rdnL0 ); + + eObjectClassL1EntryContext = + ( DirContext ) + ecoreObjectClassesContext. + lookup( rdnL1 ); + + assertNotNull( + eObjectClassL0EntryContext); + + assertNotNull( + eObjectClassL1EntryContext); + + ECascadingObjectClassDestroyer. + destroy( + eClassNameToEClassMap, + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL0, + TUSCANY_OID_PREFIX_VALUE ); + + ECascadingObjectClassDestroyer. + destroy( + eClassNameToEClassMap, + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL1, + TUSCANY_OID_PREFIX_VALUE ); + try + { + eObjectClassL0EntryContext = + ( DirContext ) + ecoreObjectClassesContext. + lookup( rdnL0 ); + } + catch (Exception e) + { + eObjectClassL0EntryContext = + null; + } + + try + { + eObjectClassL1EntryContext = + ( DirContext ) + ecoreObjectClassesContext. + lookup( rdnL1 ); + } + catch (Exception e) + { + eObjectClassL1EntryContext = + null; + } + + assertNull( + eObjectClassL0EntryContext); + + assertNull( + eObjectClassL1EntryContext); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/destroy/test/EObjectClassDestroyerTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/destroy/test/EObjectClassDestroyerTest.java new file mode 100644 index 0000000000..8370eaff52 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/destroy/test/EObjectClassDestroyerTest.java @@ -0,0 +1,457 @@ +/* + * 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.test; + +import java.util.ArrayList; +import java.util.List; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.prototype.setup.Prototype; +import org.apache.tuscany.das.ldap.schema.create.ComplexTypeRDNCreator; +import org.apache.tuscany.das.ldap.schema.emf.create.EObjectClassCreator; +import org.apache.tuscany.das.ldap.schema.emf.destroy.EObjectClassDestroyer; +import org.apache.tuscany.das.ldap.schema.embedded.setup.test.EcoreSchemaAndDASContextsSetup; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EcoreFactory; +import org.eclipse.emf.ecore.EcorePackage; + +/* + * TODO Make sure that we test EAttribute deletion as well. + */ +public class EObjectClassDestroyerTest +extends EcoreSchemaAndDASContextsSetup +implements Prototype +{ + public void tearDown() + throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() + throws NamingException, Exception + { + super.setUp(); + + ecoreFactory = + EcoreFactory.eINSTANCE; + ecorePackage = + EcorePackage.eINSTANCE; + + + processedEClassifiers = + new ArrayList<EClass>(); + + eClassL0 = + ecoreFactory. + createEClass(); + + eClassL1 = + ecoreFactory. + createEClass(); + + eClassL0.setName( "L0" ); + eClassL1.setName( "L1" ); + } + + /* + * Test the deletion of two + * single level hierarchy ObjectClasses + */ + public void testDestroy0() + throws NamingException, Exception + { + EPackage ePackage = + ecoreFactory. + createEPackage(); + + ePackage. + setNsURI(xsdNamespace); + + ePackage. + getEClassifiers(). + add( eClassL0 ); + + ePackage. + getEClassifiers(). + add( eClassL1 ); + + + EObjectClassCreator + eObjectClassCreator = + new EObjectClassCreator(); + + eObjectClassCreator. + create( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL0, + processedEClassifiers, + TUSCANY_OID_PREFIX_VALUE ); + + eObjectClassCreator. + create( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL1, + processedEClassifiers, + TUSCANY_OID_PREFIX_VALUE ); + + String rdnL0 = + ComplexTypeRDNCreator. + create( + TUSCANY_OID_PREFIX_VALUE, + xsdNamespace, + eClassL0.getName()); + + String rdnL1 = + ComplexTypeRDNCreator. + create( + TUSCANY_OID_PREFIX_VALUE, + xsdNamespace, + eClassL1.getName()); + + eObjectClassL0EntryContext = + ( LdapContext ) + ecoreObjectClassesContext. + lookup( rdnL0 ); + + eObjectClassL1EntryContext = + ( LdapContext ) + ecoreObjectClassesContext. + lookup( rdnL1 ); + + assertNotNull( + eObjectClassL0EntryContext); + + assertNotNull( + eObjectClassL1EntryContext); + + EObjectClassDestroyer. + destroy( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL0, + TUSCANY_OID_PREFIX_VALUE ); + + EObjectClassDestroyer. + destroy( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL1, + TUSCANY_OID_PREFIX_VALUE ); + + try + { + eObjectClassL0EntryContext = + ( LdapContext ) + ecoreObjectClassesContext. + lookup( rdnL0 ); + } + catch (Exception e) + { + eObjectClassL0EntryContext = + null; + } + + try + { + eObjectClassL1EntryContext = + ( LdapContext ) + ecoreObjectClassesContext. + lookup( rdnL1 ); + } + catch (Exception e) + { + eObjectClassL1EntryContext = + null; + } + + assertNull( + eObjectClassL0EntryContext); + + assertNull( + eObjectClassL1EntryContext); + } + + /* + * Testt the deletion of two + * ObjectClasses where L1 inherits from + * L0 + */ + + public void testDestroy1() + throws NamingException, Exception + { + eClassL1. + getESuperTypes(). + add(eClassL0); + + EPackage ePackage = + ecoreFactory. + createEPackage(); + + ePackage. + setNsURI(xsdNamespace); + + ePackage. + getEClassifiers(). + add( eClassL0 ); + + ePackage. + getEClassifiers(). + add( eClassL1 ); + + + EObjectClassCreator + eObjectClassCreator = + new EObjectClassCreator(); + + eObjectClassCreator. + create( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL1, + processedEClassifiers, + TUSCANY_OID_PREFIX_VALUE ); + + String rdnL0 = + ComplexTypeRDNCreator. + create( + TUSCANY_OID_PREFIX_VALUE, + xsdNamespace, + eClassL0.getName()); + + String rdnL1 = + ComplexTypeRDNCreator. + create( + TUSCANY_OID_PREFIX_VALUE, + xsdNamespace, + eClassL1.getName()); + + eObjectClassL0EntryContext = + ( LdapContext ) + ecoreObjectClassesContext. + lookup( rdnL0 ); + + eObjectClassL1EntryContext = + ( LdapContext ) + ecoreObjectClassesContext. + lookup( rdnL1 ); + + assertNotNull( + eObjectClassL0EntryContext); + + assertNotNull( + eObjectClassL1EntryContext); + + eClassL0MetaContext = + ( LdapContext ) + metaContext. + lookup( + "cn=" + eClassL0.getName() ); + + assertNotNull( + eClassL0MetaContext ); + + eClassL1MetaContext = + ( LdapContext ) + eClassL0MetaContext. + lookup( + "cn=" + eClassL1.getName() ); + + assertNotNull( + eClassL0MetaContext ); + + assertNotNull( + eClassL1MetaContext ); + + EObjectClassDestroyer. + destroy( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL1, + TUSCANY_OID_PREFIX_VALUE ); + + EObjectClassDestroyer. + destroy( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + eClassL0, + TUSCANY_OID_PREFIX_VALUE ); + + try + { + eObjectClassL0EntryContext = + ( LdapContext ) + ecoreObjectClassesContext. + lookup( rdnL0 ); + } + catch (Exception e) + { + eObjectClassL0EntryContext = + null; + } + + try + { + eObjectClassL1EntryContext = + ( LdapContext ) + ecoreObjectClassesContext. + lookup( rdnL1 ); + } + catch (Exception e) + { + eObjectClassL1EntryContext = + null; + } + + assertNull( + eObjectClassL0EntryContext); + + assertNull( + eObjectClassL1EntryContext); + + + eClassL0MetaContext = + ( LdapContext ) + metaContext. + lookup( + "cn=" + eClassL0.getName() ); + + assertNotNull( + eClassL0MetaContext ); + + try + { + eClassL1MetaContext = + ( LdapContext ) + eClassL0MetaContext. + lookup( + "cn=" + eClassL1.getName() ); + + } + catch (Exception e) + { + eClassL1MetaContext = + null; + } + + assertNull( + eClassL1MetaContext); + + metaContext. + destroySubcontext( + "cn=" + eClassL0.getName() ); + } + + /* + * Test the deletion of an ObjectClass that has + * has attributes. + */ + public void testDestroy2() throws NamingException, Exception + { + userEClass.getEStructuralFeatures().add(userIDEAttribute); + userEClass.getEStructuralFeatures().add(userNameEAttribute); + userEClass.getEStructuralFeatures().add(userPasswordEAttribute); + userEClass.getEStructuralFeatures().add(userAuthorizationEReference); + + EPackage ePackage = + ecoreFactory. + createEPackage(); + + ePackage. + setNsURI(xsdNamespace); + + ePackage. + getEClassifiers(). + add( userEClass ); + + EObjectClassCreator + eObjectClassCreator = + new EObjectClassCreator(); + + eObjectClassCreator. + create( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + userEClass, + processedEClassifiers, + TUSCANY_OID_PREFIX_VALUE ); + + String rdnL0 = + ComplexTypeRDNCreator. + create( + TUSCANY_OID_PREFIX_VALUE, + xsdNamespace, + userEClass.getName()); + + EObjectClassDestroyer. + destroy( + metaContext, + ecoreAttributeTypesContext, + ecoreObjectClassesContext, + userEClass, + TUSCANY_OID_PREFIX_VALUE ); + } + + private static EcoreFactory ecoreFactory = + null; + + private static EcorePackage ecorePackage = + null; + + private static EClass eClassL0 = + null; + + private static EClass eClassL1 = + null; + + private static List<EClass> + processedEClassifiers = + null; + + private static LdapContext + eObjectClassL0EntryContext = + null; + + private static LdapContext + eObjectClassL1EntryContext = + null; + + private static LdapContext + eClassL0MetaContext = + null; + + private static LdapContext + eClassL1MetaContext = + null; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/util/test/JNDIUtilTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/util/test/JNDIUtilTest.java new file mode 100644 index 0000000000..a962484c8d --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/util/test/JNDIUtilTest.java @@ -0,0 +1,109 @@ +package org.apache.tuscany.das.ldap.util.test; + +import javax.naming.NamingException; +import javax.naming.directory.DirContext; + +import org.apache.tuscany.das.ldap.schema.embedded.setup.test.AbstractTestSetup; +import org.apache.tuscany.das.ldap.util.JNDIUtil; + +/* + * Note that these tests rely on the ADS Partition + * ou=system, which is also the directoryContext + * that the tests start with. + */ +public class JNDIUtilTest +extends AbstractTestSetup +{ + DirContext test1Context = null; + DirContext test2Context = null; + DirContext test3Context = null; + + public void setUp() throws Exception + { + super.setUp(); + test1Context = + ( DirContext ) + dasPartitionContext. + createSubcontext( "cn=test1" ); + + test2Context = + ( DirContext ) + test1Context. + createSubcontext( "cn=test2" ); + + test3Context = + ( DirContext ) + test2Context. + createSubcontext( "cn=test3" ); + } + + public void tearDown() throws Exception + { + test2Context.destroySubcontext( "cn=test3" ); + test1Context.destroySubcontext("cn=test2"); + dasPartitionContext.destroySubcontext("cn=test1"); + super.tearDown(); + } + + public void testCalculateParentRelativeDN() throws NamingException + { + String partitionDN = "ou=das"; + + String testA = + JNDIUtil.calculateParentRelativeDN( + test2Context, partitionDN ); + + String testB = + JNDIUtil.calculateParentRelativeDN( + test3Context, partitionDN ); + + String testC = + JNDIUtil.calculateParentRelativeDN( test1Context, partitionDN ); + + assertTrue(testA.equals( "cn=test1" )); + assertTrue(testB.equals( "cn=test2,cn=test1" )); + assertTrue(testC.equals( "ou=das" )); + + } + + public void testCalculateDNComponents() throws NamingException + { + String[] contextComponents = JNDIUtil.calculateDNComponents( test3Context ); + assertTrue(contextComponents.length==4); + + contextComponents = null; + + contextComponents = JNDIUtil.calculateDNComponents( test3Context.getNameInNamespace() ); + assertTrue(contextComponents.length==4); + } + + public void testGetParentContext() throws NamingException + { + DirContext parentContext = + JNDIUtil. + getParentContext( + test3Context, + dasPartitionContext ); + + assertTrue( + parentContext.getNameInNamespace(). + equals("cn=test2,cn=test1,ou=das")); + + parentContext = + JNDIUtil.getParentContext( + test1Context, + dasPartitionContext ); + + assertTrue( + parentContext.getNameInNamespace(). + equals("ou=das")); + + parentContext = + JNDIUtil. + getParentContext( + dasPartitionContext, + dasPartitionContext ); + + assertTrue(null == parentContext); + } +} diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/util/test/QualifiedNameNormalizerTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/util/test/QualifiedNameNormalizerTest.java new file mode 100644 index 0000000000..30b37dee91 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/util/test/QualifiedNameNormalizerTest.java @@ -0,0 +1,42 @@ +/* + * 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.test; + +import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer; + +import junit.framework.TestCase; + +public class QualifiedNameNormalizerTest +extends TestCase +{ + public void testNormalize() + { + String qualifiedName = + "http://example.com/users/accounts/L0"; + + String normalizedName = + QualifiedNameNormalizer. + normalize(qualifiedName); + + assertEquals( + "example-com-users-accounts-L0", + normalizedName); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/util/test/XSDNamespaceURITokenizerTest.java b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/util/test/XSDNamespaceURITokenizerTest.java new file mode 100644 index 0000000000..708eae7920 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/util/test/XSDNamespaceURITokenizerTest.java @@ -0,0 +1,36 @@ + +package org.apache.tuscany.das.ldap.util.test; + +import org.apache.tuscany.das.ldap.schema.embedded.setup.test.AbstractTestSetup; + +import org.apache.tuscany.das.ldap.util.XSDNamespaceURITokenizer; +import org.eclipse.emf.common.util.URI; + +public class XSDNamespaceURITokenizerTest +extends AbstractTestSetup +{ + public void testCreateAuthorityTokens() + { + String[] authorityTokens = + XSDNamespaceURITokenizer. + createAuthorityTokens( + URI.createURI(xsdNamespace)); + + assertTrue(authorityTokens[0].equals( "example")); + assertTrue(authorityTokens[1].equals( "com")); + assertTrue(authorityTokens.length == 2); + } + + public void testCreatePathTokens() + { + String[] pathTokens = + XSDNamespaceURITokenizer. + createPathTokens( + URI.createURI(xsdNamespace)); + + assertTrue(pathTokens[1].equals("users")); + assertTrue(pathTokens[2].equals("accounts")); + assertTrue(pathTokens.length == 3); + } + +} diff --git a/das-java/contrib/ldap/das.ldap/src/test/resources/log4j.properties b/das-java/contrib/ldap/das.ldap/src/test/resources/log4j.properties new file mode 100644 index 0000000000..75e557ac3b --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/test/resources/log4j.properties @@ -0,0 +1,6 @@ +log4j.rootCategory=ERROR, stdout + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n + diff --git a/das-java/contrib/ldap/pom.xml b/das-java/contrib/ldap/pom.xml new file mode 100644 index 0000000000..b6c1b72723 --- /dev/null +++ b/das-java/contrib/ldap/pom.xml @@ -0,0 +1,270 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.das</groupId> + <artifactId>tuscany-das</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + <artifactId>tuscany-das-ldap</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + </plugins> + </build> + <dependencyManagement> + <dependencies> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>compile</scope> + </dependency> + + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ant</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>codegen</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>codegen-ecore</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>codegen-ecore-ui</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>codegen-ui</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>common</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>commonj-sdo</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>common-ui</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>converter</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore-change</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore-change-edit</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore-edit</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore-sdo</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore-sdo-edit</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>ecore-xmi</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>edit</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>edit-ui</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>emf</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>exporter</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>importer</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>importer-ecore</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>importer-java</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>importer-rose</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-ecore2ecore</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-ecore2ecore-editor</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-ecore2xml</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-ecore2xml-ui</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-ui</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-xsd2ecore</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.emf</groupId> + <artifactId>mapping-xsd2ecore-editor</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.xsd</groupId> + <artifactId>ecore-exporter</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.xsd</groupId> + <artifactId>ecore-importer</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.xsd</groupId> + <artifactId>edit</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>org.eclipse.xsd</groupId> + <artifactId>xsd</artifactId> + <version>2.3.0</version> + </dependency> + + </dependencies> + </dependencyManagement> + + <repositories> + <repository> + <id>emf-maven-mirror</id> + <url> + http://mirrors.cat.pdx.edu/eclipse/tools/emf/maven2/ + </url> + </repository> + </repositories> + + <modules> + <module>das.ldap</module> + <module>das.ldap.constants</module> + <module>das.ldap.configuration.model.v100</module> + <module>das.ldap.configuration.model.ecore.v100</module> + </modules> +</project> |