You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2013/07/27 08:09:58 UTC
svn commit: r1507578 - in /directory/escimo/trunk:
common/src/main/java/org/apache/directory/scim/
common/src/main/resources/org/ common/src/main/resources/org/apache/
common/src/main/resources/org/apache/directory/
common/src/main/resources/org/apache...
Author: kayyagari
Date: Sat Jul 27 06:09:57 2013
New Revision: 1507578
URL: http://svn.apache.org/r1507578
Log:
schema mappings
Added:
directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ResourceNotFoundException.java
directory/escimo/trunk/common/src/main/resources/org/
directory/escimo/trunk/common/src/main/resources/org/apache/
directory/escimo/trunk/common/src/main/resources/org/apache/directory/
directory/escimo/trunk/common/src/main/resources/org/apache/directory/scim/
directory/escimo/trunk/common/src/main/resources/org/apache/directory/scim/common/
directory/escimo/trunk/common/src/main/resources/org/apache/directory/scim/common/Response.java
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ComplexAttribute.java
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ScimAttribute.java
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/SimpleAttribute.java
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/User.java
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/BaseType.java
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ComplexType.java
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/DynamicType.java
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ResourceSchema.java
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleType.java
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleTypeGroup.java
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/TypedType.java
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/UserSchema.java
Modified:
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java
directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/UserService.java
Added: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ResourceNotFoundException.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ResourceNotFoundException.java?rev=1507578&view=auto
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ResourceNotFoundException.java (added)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ResourceNotFoundException.java Sat Jul 27 06:09:57 2013
@@ -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.directory.scim;
+
+
+/**
+ * TODO ResourceNotFoundException.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ResourceNotFoundException extends Exception
+{
+ String message;
+
+
+ public ResourceNotFoundException( String message )
+ {
+ this.message = message;
+ }
+
+
+ public ResourceNotFoundException( Throwable t )
+ {
+ super( t );
+ }
+
+
+ public ResourceNotFoundException( String message, Throwable t )
+ {
+ super( t );
+ this.message = message;
+ }
+
+
+ @Override
+ public String getMessage()
+ {
+ if ( message == null )
+ {
+ return super.getMessage();
+ }
+
+ return message;
+ }
+
+}
Added: directory/escimo/trunk/common/src/main/resources/org/apache/directory/scim/common/Response.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/resources/org/apache/directory/scim/common/Response.java?rev=1507578&view=auto
==============================================================================
--- directory/escimo/trunk/common/src/main/resources/org/apache/directory/scim/common/Response.java (added)
+++ directory/escimo/trunk/common/src/main/resources/org/apache/directory/scim/common/Response.java Sat Jul 27 06:09:57 2013
@@ -0,0 +1,370 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2013.07.10 at 11:09:39 PM GMT+05:30
+//
+
+
+package org.apache.directory.scim.common;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for Response complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="Response">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <choice>
+ * <element ref="{urn:scim:schemas:core:1.0}Resource" minOccurs="0"/>
+ * <group ref="{urn:scim:schemas:core:1.0}Resources"/>
+ * <element name="errors" minOccurs="0">
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="error" type="{urn:scim:schemas:core:1.0}Error" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </element>
+ * </choice>
+ * <any namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "Response", propOrder = {
+ "resource",
+ "totalResults",
+ "itemsPerPage",
+ "startIndex",
+ "resources",
+ "errors",
+ "any"
+})
+public class Response {
+
+ @XmlElement(name = "Resource", namespace = "urn:scim:schemas:core:1.0")
+ protected Resource resource;
+ protected Long totalResults;
+ protected Integer itemsPerPage;
+ protected Long startIndex;
+ @XmlElement(name = "Resources")
+ protected Response.Resources resources;
+ protected Response.Errors errors;
+ @XmlAnyElement(lax = true)
+ protected List<Object> any;
+
+ /**
+ * Gets the value of the resource property.
+ *
+ * @return
+ * possible object is
+ * {@link Resource }
+ *
+ */
+ public Resource getResource() {
+ return resource;
+ }
+
+ /**
+ * Sets the value of the resource property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Resource }
+ *
+ */
+ public void setResource(Resource value) {
+ this.resource = value;
+ }
+
+ /**
+ * Gets the value of the totalResults property.
+ *
+ * @return
+ * possible object is
+ * {@link Long }
+ *
+ */
+ public Long getTotalResults() {
+ return totalResults;
+ }
+
+ /**
+ * Sets the value of the totalResults property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Long }
+ *
+ */
+ public void setTotalResults(Long value) {
+ this.totalResults = value;
+ }
+
+ /**
+ * Gets the value of the itemsPerPage property.
+ *
+ * @return
+ * possible object is
+ * {@link Integer }
+ *
+ */
+ public Integer getItemsPerPage() {
+ return itemsPerPage;
+ }
+
+ /**
+ * Sets the value of the itemsPerPage property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Integer }
+ *
+ */
+ public void setItemsPerPage(Integer value) {
+ this.itemsPerPage = value;
+ }
+
+ /**
+ * Gets the value of the startIndex property.
+ *
+ * @return
+ * possible object is
+ * {@link Long }
+ *
+ */
+ public Long getStartIndex() {
+ return startIndex;
+ }
+
+ /**
+ * Sets the value of the startIndex property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Long }
+ *
+ */
+ public void setStartIndex(Long value) {
+ this.startIndex = value;
+ }
+
+ /**
+ * Gets the value of the resources property.
+ *
+ * @return
+ * possible object is
+ * {@link Response.Resources }
+ *
+ */
+ public Response.Resources getResources() {
+ return resources;
+ }
+
+ /**
+ * Sets the value of the resources property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Response.Resources }
+ *
+ */
+ public void setResources(Response.Resources value) {
+ this.resources = value;
+ }
+
+ /**
+ * Gets the value of the errors property.
+ *
+ * @return
+ * possible object is
+ * {@link Response.Errors }
+ *
+ */
+ public Response.Errors getErrors() {
+ return errors;
+ }
+
+ /**
+ * Sets the value of the errors property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Response.Errors }
+ *
+ */
+ public void setErrors(Response.Errors value) {
+ this.errors = value;
+ }
+
+ /**
+ * Gets the value of the any property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the any property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getAny().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link Object }
+ *
+ *
+ */
+ public List<Object> getAny() {
+ if (any == null) {
+ any = new ArrayList<Object>();
+ }
+ return this.any;
+ }
+
+
+ /**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="error" type="{urn:scim:schemas:core:1.0}Error" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {
+ "error"
+ })
+ public static class Errors {
+
+ @XmlElement(nillable = true)
+ protected List<Error> error;
+
+ /**
+ * Gets the value of the error property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the error property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getError().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link Error }
+ *
+ *
+ */
+ public List<Error> getError() {
+ if (error == null) {
+ error = new ArrayList<Error>();
+ }
+ return this.error;
+ }
+
+ }
+
+
+ /**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="Resource" type="{urn:scim:schemas:core:1.0}Resource" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {
+ "resource"
+ })
+ public static class Resources {
+
+ @XmlElement(name = "Resource", nillable = true)
+ protected List<Resource> resource;
+
+ /**
+ * Gets the value of the resource property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the resource property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getResource().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link Resource }
+ *
+ *
+ */
+ public List<Resource> getResource() {
+ if (resource == null) {
+ resource = new ArrayList<Resource>();
+ }
+ return this.resource;
+ }
+
+ }
+
+}
Added: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ComplexAttribute.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ComplexAttribute.java?rev=1507578&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ComplexAttribute.java (added)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ComplexAttribute.java Sat Jul 27 06:09:57 2013
@@ -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.directory.scim;
+
+
+import java.util.List;
+
+
+/**
+ * TODO SimpleAttribute.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ComplexAttribute extends ScimAttribute
+{
+ public ComplexAttribute( String name )
+ {
+ super( name );
+ }
+
+ private List<SimpleAttribute> atList;
+}
Added: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ScimAttribute.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ScimAttribute.java?rev=1507578&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ScimAttribute.java (added)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ScimAttribute.java Sat Jul 27 06:09:57 2013
@@ -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.scim;
+
+
+/**
+ * TODO ScimAttribute.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ScimAttribute
+{
+ private String name;
+
+
+ public ScimAttribute( String name )
+ {
+ this.name = name;
+ }
+
+
+ public String getName()
+ {
+ return name;
+ }
+
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+}
Added: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/SimpleAttribute.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/SimpleAttribute.java?rev=1507578&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/SimpleAttribute.java (added)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/SimpleAttribute.java Sat Jul 27 06:09:57 2013
@@ -0,0 +1,57 @@
+/*
+ * 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.scim;
+
+
+/**
+ * TODO SimpleAttribute.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SimpleAttribute extends ScimAttribute
+{
+ private String value;
+
+
+ public SimpleAttribute( String name )
+ {
+ super( name );
+ }
+
+
+ public SimpleAttribute( String name, String value )
+ {
+ super( name );
+ this.value = value;
+ }
+
+
+ public String getValue()
+ {
+ return value;
+ }
+
+
+ public void setValue( String value )
+ {
+ this.value = value;
+ }
+
+}
Added: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/User.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/User.java?rev=1507578&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/User.java (added)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/User.java Sat Jul 27 06:09:57 2013
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.scim;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * TODO User.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class User
+{
+ private List<SimpleAttribute> simpleList;
+
+ private List<ComplexAttribute> complexList;
+
+ private Map<String,List<ScimAttribute>> uriAtMap = new HashMap<String, List<ScimAttribute>>();
+
+ public void addAttribute( String uri, ScimAttribute at )
+ {
+ List<ScimAttribute> atList = uriAtMap.get( uri );
+
+ if( atList == null )
+ {
+ atList = new ArrayList<ScimAttribute>();
+ uriAtMap.put( uri, atList );
+ }
+
+ atList.add( at );
+ }
+}
Added: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java?rev=1507578&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java (added)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java Sat Jul 27 06:09:57 2013
@@ -0,0 +1,204 @@
+/*
+ * 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.scim.ldap;
+
+
+import static org.apache.directory.api.ldap.model.constants.SchemaConstants.ALL_ATTRIBUTES_ARRAY;
+import static org.apache.directory.api.ldap.model.message.SearchScope.SUBTREE;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.api.ldap.codec.standalone.StandaloneLdapApiService;
+import org.apache.directory.api.ldap.model.cursor.EntryCursor;
+import org.apache.directory.api.ldap.model.cursor.SearchCursor;
+import org.apache.directory.api.ldap.model.entry.Attribute;
+import org.apache.directory.api.ldap.model.entry.Entry;
+import org.apache.directory.api.ldap.model.message.Response;
+import org.apache.directory.api.ldap.model.message.SearchRequest;
+import org.apache.directory.api.ldap.model.message.SearchRequestImpl;
+import org.apache.directory.api.ldap.model.message.SearchResultEntry;
+import org.apache.directory.api.ldap.model.message.SearchScope;
+import org.apache.directory.api.ldap.model.message.controls.EntryChange;
+import org.apache.directory.api.ldap.model.message.controls.PersistentSearch;
+import org.apache.directory.api.ldap.model.message.controls.PersistentSearchImpl;
+import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.util.Base64;
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.scim.ResourceNotFoundException;
+import org.apache.directory.scim.SimpleAttribute;
+import org.apache.directory.scim.User;
+import org.apache.directory.scim.ldap.schema.BaseType;
+import org.apache.directory.scim.ldap.schema.ComplexType;
+import org.apache.directory.scim.ldap.schema.SimpleType;
+import org.apache.directory.scim.ldap.schema.SimpleTypeGroup;
+import org.apache.directory.scim.ldap.schema.TypedType;
+import org.apache.directory.scim.ldap.schema.UserSchema;
+
+
+/**
+ * TODO LdapResourceProvider.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LdapResourceProvider
+{
+ private LdapConnection connection;
+
+ private LdapSchemaMapper schema;
+
+ private UserSchema userSchema;
+
+
+ public LdapResourceProvider( LdapConnection connection )
+ {
+ schema = new LdapSchemaMapper();
+ schema.loadMappings();
+ userSchema = schema.getUserSchema();
+ }
+
+
+ public User getUser( String id ) throws ResourceNotFoundException
+ {
+ SimpleType st = ( SimpleType ) userSchema.getCoreAttribute( "id" );
+ String userIdName = st.getMappedTo();
+
+ String filter = "(" + userIdName + "=" + id + ")";
+
+ Entry entry = null;
+
+ try
+ {
+ EntryCursor cursor = connection.search( userSchema.getBaseDn(), filter, SUBTREE, ALL_ATTRIBUTES_ARRAY );
+
+ if ( cursor.next() )
+ {
+ entry = cursor.get();
+ }
+
+ cursor.close();
+
+ }
+ catch ( Exception e )
+ {
+ throw new ResourceNotFoundException( e );
+ }
+
+ if ( entry == null )
+ {
+ throw new ResourceNotFoundException( "No User resource found with the ID " + id );
+ }
+
+ return toUser( entry );
+ }
+
+
+ public User toUser( Entry entry ) throws Exception
+ {
+ Collection<BaseType> coreTypes = userSchema.getCoreAttributes();
+
+ User user = new User();
+
+ for ( BaseType bt : coreTypes )
+ {
+ if ( bt instanceof SimpleType )
+ {
+ SimpleType st = ( SimpleType ) bt;
+
+ if(!st.isShow())
+ {
+ continue;
+ }
+
+ String name = st.getName();
+ Attribute at = entry.get( st.getMappedTo() );
+ if ( at != null )
+ {
+ String value = null;
+ if( at.isHumanReadable() )
+ {
+ value = at.getString();
+ }
+ else
+ {
+ value = new String( Base64.encode( at.getBytes() ) );
+ }
+
+ user.addAttribute( bt.getUri(), new SimpleAttribute( name, value ) );
+ }
+ }
+ else if ( bt instanceof ComplexType )
+ {
+ ComplexType ct = ( ComplexType ) bt;
+
+ if(!ct.isShow())
+ {
+ continue;
+ }
+
+ SimpleTypeGroup stg = ct.getStGroup();
+ List<SimpleType> lstTyps = stg.getLstSTypes();
+
+ }
+ }
+
+ Iterator<Attribute> itr = entry.iterator();
+ return null;
+ }
+
+
+ public static void main( String[] args ) throws Exception
+ {
+ System.setProperty( StandaloneLdapApiService.DEFAULT_CONTROLS_LIST,
+ "org.apache.directory.api.ldap.codec.controls.cascade.CascadeFactory," +
+ "org.apache.directory.api.ldap.codec.controls.manageDsaIT.ManageDsaITFactory," +
+ "org.apache.directory.api.ldap.codec.controls.search.entryChange.EntryChangeFactory," +
+ "org.apache.directory.api.ldap.codec.controls.search.pagedSearch.PagedResultsFactory," +
+ "org.apache.directory.api.ldap.codec.controls.search.persistentSearch.PersistentSearchFactory," +
+ "org.apache.directory.api.ldap.codec.controls.search.subentries.SubentriesFactory" );
+
+ LdapNetworkConnection c = new LdapNetworkConnection( "localhost", 10389 );
+ c.setTimeOut( Long.MAX_VALUE );
+ c.loadSchema();
+ c.bind( "uid=admin,ou=system", "secret" );
+
+ PersistentSearch ps = new PersistentSearchImpl();
+ ps.setChangesOnly( false );
+ ps.setReturnECs( true );
+
+ SearchRequest searchRequest = new SearchRequestImpl().setBase( new Dn(
+ "ou=system" ) ).setFilter( "(objectclass=*)" ).setScope(
+ SearchScope.SUBTREE ).addControl( ps );
+ searchRequest.addAttributes( "uid" );
+
+ SearchCursor cursor = c.search( searchRequest );
+
+ while ( cursor.next() )
+ {
+ Response response = cursor.get();
+ SearchResultEntry se = ( SearchResultEntry ) response;
+ System.out.println( se.getEntry() );
+ System.out.println( se.getControl( EntryChange.OID ) );
+ }
+ cursor.close();
+ }
+}
Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java?rev=1507578&r1=1507577&r2=1507578&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java Sat Jul 27 06:09:57 2013
@@ -24,12 +24,23 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
+import org.apache.directory.api.util.Strings;
import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.scim.SchemaMapper;
-import org.apache.directory.scim.common.User;
+import org.apache.directory.scim.ldap.schema.BaseType;
+import org.apache.directory.scim.ldap.schema.ComplexType;
+import org.apache.directory.scim.ldap.schema.ResourceSchema;
+import org.apache.directory.scim.ldap.schema.SimpleType;
+import org.apache.directory.scim.ldap.schema.SimpleTypeGroup;
+import org.apache.directory.scim.ldap.schema.TypedType;
+import org.apache.directory.scim.ldap.schema.UserSchema;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
@@ -48,6 +59,13 @@ public class LdapSchemaMapper implements
private static final Logger LOG = LoggerFactory.getLogger( LdapSchemaMapper.class );
+ private Map<String, BaseType> groupSchema = new HashMap<String, BaseType>();
+
+ private UserSchema userSchema;
+
+ public LdapSchemaMapper()
+ {
+ }
public LdapSchemaMapper( LdapConnection connection )
{
@@ -65,10 +83,19 @@ public class LdapSchemaMapper implements
}
+ /**
+ * @return the userSchema
+ */
+ public UserSchema getUserSchema()
+ {
+ return userSchema;
+ }
+
public void loadMappings()
{
- InputStream in = this.getClass().getResourceAsStream( "escimo-ldap-mapping.xml" );
+ InputStream in = this.getClass().getClassLoader().getResourceAsStream( "escimo-ldap-mapping.xml" );
loadMappings( in );
+ System.out.println( groupSchema );
}
@@ -85,23 +112,44 @@ public class LdapSchemaMapper implements
{
StringBuilder sb = new StringBuilder();
String s = null;
-
+
while ( ( s = r.readLine() ) != null )
{
sb.append( s )
- .append( "\n" );
+ .append( "\n" );
}
-
+
Document doc = DocumentHelper.parseText( sb.toString() );
-
+
// the entities element
Element root = doc.getRootElement();
if ( root.elements().isEmpty() )
{
- throw new IllegalStateException( "Invalid schema mapping file" );
+ throw new IllegalStateException( "Invalid schema mapping file" );
}
- Element elmUser = root.element( "user" );
+ Element elmUser = root.element( "userType" );
+
+ String baseDn = elmUser.attributeValue( "baseDn" );
+ String filter = elmUser.attributeValue( "filter" );
+
+ userSchema = new UserSchema( baseDn, filter );
+
+ List<Element> lstSchema = elmUser.elements( "schema" );
+ List<Element> lstRef = elmUser.elements( "schemaRef" );
+ parseResourceSchema( lstRef, lstSchema, userSchema );
+
+ /*
+ Element elmGroup = root.element( "groupType" );
+
+ String baseDn = elmGroup.attributeValue( "baseDn" );
+ String filter = elmGroup.attributeValue( "filter" );
+
+ userSchema = new GroupSchema( baseDn, filter );
+
+ List<Element> lstSchema = elmGroup.elements( "schema" );
+ List<Element> lstRef = elmGroup.elements( "schemaRef" );
+ */
}
catch ( Exception e )
{
@@ -110,13 +158,13 @@ public class LdapSchemaMapper implements
}
finally
{
- if( r != null )
+ if ( r != null )
{
try
{
r.close();
}
- catch( IOException e )
+ catch ( IOException e )
{
LOG.warn( "Failed to close the inputstream of the schema mapping file", e );
}
@@ -124,4 +172,175 @@ public class LdapSchemaMapper implements
}
}
+ private void parseResourceSchema( List<Element> lstRef, List<Element> lstSchema, ResourceSchema resourceSchema )
+ {
+ for( Element ref : lstRef )
+ {
+ String refId = ref.attributeValue( "id" );
+ for( Element elmSchema : lstSchema )
+ {
+ String schemaId = elmSchema.attributeValue( "id" );
+ if(refId.equals( schemaId ))
+ {
+ parseSchema( elmSchema, resourceSchema );
+ break;
+ }
+ }
+ }
+
+ }
+
+
+ private void parseSchema( Element schemaRoot, ResourceSchema resourceSchema )
+ {
+ String uri = schemaRoot.attributeValue( "uri" );
+
+ resourceSchema.addUri( uri );
+
+ List<Element> simpleAtElmList = schemaRoot.elements( "attribute" );
+
+ for ( Element el : simpleAtElmList )
+ {
+ SimpleType st = parseSimpleType( el, uri );
+ if ( st != null )
+ {
+ resourceSchema.addAttributeType( st.getName(), st );
+ }
+ }
+
+ // load complex-attributes
+ List<Element> complexAtElmList = schemaRoot.elements( "complex-attribute" );
+
+ for ( Element elmComplex : complexAtElmList )
+ {
+ String name = elmComplex.attributeValue( "name" );
+
+ if ( Strings.isEmpty( name ) )
+ {
+ throw new IllegalStateException( "name is missing in the complex-attribute configuration element "
+ + elmComplex.asXML() );
+ }
+
+ String baseDn = elmComplex.attributeValue( "baseDn" );
+ String filter = elmComplex.attributeValue( "filter" );
+
+ Element elmAtGroup = elmComplex.element( "at-group" );
+ if ( elmAtGroup != null )
+ {
+ SimpleTypeGroup stg = parseAtGroup( elmAtGroup, uri );
+ if ( stg != null )
+ {
+ ComplexType ct = new ComplexType( name, uri, stg, baseDn, filter );
+ resourceSchema.addAttributeType( name, ct );
+ }
+
+ }
+ else
+ {
+ List<Element> lstElmTypes = elmComplex.elements( "type" );
+
+ List<TypedType> lstTypes = new ArrayList<TypedType>();
+
+ for ( Element elmType : lstElmTypes )
+ {
+ Element elmTypeAtGroup = elmComplex.element( "at-group" );
+ SimpleTypeGroup stg = parseAtGroup( elmTypeAtGroup, uri );
+
+ String show = elmType.attributeValue( "show" );
+
+ if ( Strings.isEmpty( show ) )
+ {
+ show = "true";
+ }
+
+ String primary = elmType.attributeValue( "primary" );
+
+ if ( Strings.isEmpty( primary ) )
+ {
+ primary = "false";
+ }
+
+ String typeName = elmType.attributeValue( "name" );
+
+ if ( Strings.isEmpty( typeName ) )
+ {
+ throw new IllegalArgumentException( "name is missing in the type element " + elmType.asXML() );
+ }
+
+ TypedType tt = new TypedType( typeName, stg, Boolean.parseBoolean( show ), Boolean.parseBoolean( primary ), uri );
+ lstTypes.add( tt );
+ }
+
+ ComplexType ct = new ComplexType( name, uri, lstTypes, baseDn, filter );
+ resourceSchema.addAttributeType( name, ct );
+ }
+ }
+ }
+
+
+ private SimpleTypeGroup parseAtGroup( Element elmAtGroup, String uri )
+ {
+ SimpleTypeGroup stg = null;
+
+ List<SimpleType> lstSTypes = null;
+
+ if ( elmAtGroup != null )
+ {
+ lstSTypes = new ArrayList<SimpleType>();
+
+ List<Element> elmSTypes = elmAtGroup.elements( "attribute" );
+ for ( Element elmAt : elmSTypes )
+ {
+ SimpleType st = parseSimpleType( elmAt, uri );
+ if ( st != null )
+ {
+ lstSTypes.add( st );
+ }
+ }
+
+ String format = null;
+
+ Element elmFormat = elmAtGroup.element( "formatted" );
+ if ( elmFormat != null )
+ {
+ format = elmFormat.attributeValue( "format" );
+ }
+
+ if ( !lstSTypes.isEmpty() )
+ {
+ stg = new SimpleTypeGroup( lstSTypes, format );
+ }
+ }
+
+ return stg;
+ }
+
+
+ private SimpleType parseSimpleType( Element el, String uri )
+ {
+ String name = el.attributeValue( "name" );
+
+ if ( Strings.isEmpty( name ) )
+ {
+ throw new IllegalStateException( "name is missing in the attribute configuration element " + el.asXML() );
+ }
+
+ String mappedTo = el.attributeValue( "mappedTo" );
+
+ if ( Strings.isEmpty( mappedTo ) )
+ {
+ LOG.debug( "No LDAP attribute was mapped to the SCIM attribute {}, skipping", name );
+ return null;
+ }
+
+ boolean show = Boolean.parseBoolean( el.attributeValue( "show" ) );
+
+ return new SimpleType( name, mappedTo, uri, show );
+ }
+
+ public static void main( String[] args )
+ {
+ LdapSchemaMapper lsm = new LdapSchemaMapper();
+ lsm.loadMappings();
+ }
}
Added: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/BaseType.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/BaseType.java?rev=1507578&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/BaseType.java (added)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/BaseType.java Sat Jul 27 06:09:57 2013
@@ -0,0 +1,76 @@
+/*
+ * 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.scim.ldap.schema;
+
+
+/**
+ * TODO BaseType.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class BaseType
+{
+ private String uri;
+
+ public static final String CORE_URI = "urn:scim:schemas:core:1.0";
+
+ public BaseType( String uri )
+ {
+ this.uri = uri;
+ }
+
+
+ public boolean isSimple()
+ {
+ return false;
+ }
+
+
+ public boolean isComplex()
+ {
+ return false;
+ }
+
+
+ public boolean isTyped()
+ {
+ return false;
+ }
+
+ public boolean isCoreAttribute()
+ {
+ return CORE_URI.equals( uri );
+ }
+
+ /**
+ * @return the uri
+ */
+ public String getUri()
+ {
+ return uri;
+ }
+
+
+ public boolean isDynamic()
+ {
+ return false;
+ }
+
+}
Added: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ComplexType.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ComplexType.java?rev=1507578&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ComplexType.java (added)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ComplexType.java Sat Jul 27 06:09:57 2013
@@ -0,0 +1,147 @@
+/*
+ * 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.scim.ldap.schema;
+
+
+import java.util.List;
+
+
+/**
+ * TODO SimpleType.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ComplexType extends BaseType
+{
+ private String name;
+
+ private SimpleTypeGroup stGroup;
+
+ private List<TypedType> typedList;
+
+ private boolean show = true;
+
+ private String baseDn;
+
+ private String filter;
+
+ /** used for setting the value of "formatted" attribute */
+ private String format;
+
+ public ComplexType( String name, String uri, SimpleTypeGroup stGroup, String baseDn, String filter )
+ {
+ super(uri);
+ this.name = name;
+ this.stGroup = stGroup;
+ this.baseDn = baseDn;
+ this.filter = filter;
+ }
+
+
+ public ComplexType( String name, String uri, List<TypedType> typedList, String baseDn, String filter )
+ {
+ super(uri);
+ this.name = name;
+ this.typedList = typedList;
+ this.baseDn = baseDn;
+ this.filter = filter;
+ }
+
+ /**
+ * @return the typedList
+ */
+ public List<TypedType> getTypedList()
+ {
+ return typedList;
+ }
+
+
+ /**
+ * @return the stGroup
+ */
+ public SimpleTypeGroup getStGroup()
+ {
+ return stGroup;
+ }
+
+
+ /**
+ * @return the show
+ */
+ public boolean isShow()
+ {
+ return show;
+ }
+
+
+ /**
+ * @return the baseDn
+ */
+ public String getBaseDn()
+ {
+ return baseDn;
+ }
+
+
+ /**
+ * @return the filter
+ */
+ public String getFilter()
+ {
+ return filter;
+ }
+
+
+ /**
+ * @return the format
+ */
+ public String getFormat()
+ {
+ return format;
+ }
+
+
+ /**
+ * @return the name
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+
+ @Override
+ public boolean isComplex()
+ {
+ return true;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ return "ComplexType [name=" + name + ", stGroup=" + stGroup + ", typedList="
+ + typedList + ", show=" + show + ", format=" + format + "]";
+ }
+
+}
Added: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/DynamicType.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/DynamicType.java?rev=1507578&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/DynamicType.java (added)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/DynamicType.java Sat Jul 27 06:09:57 2013
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.scim.ldap.schema;
+
+
+/**
+ * TODO DynamicType.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DynamicType extends BaseType
+{
+ private SimpleTypeGroup atGroup;
+
+ private boolean show = true;
+
+ private String baseDn;
+
+ private String filter;
+
+ public DynamicType(String baseDn, String filter, SimpleTypeGroup atGroup, String uri )
+ {
+ super(uri);
+ this.baseDn = baseDn;
+ this.filter = filter;
+ this.atGroup = atGroup;
+ }
+
+ @Override
+ public boolean isDynamic()
+ {
+ return true;
+ }
+
+}
Added: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ResourceSchema.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ResourceSchema.java?rev=1507578&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ResourceSchema.java (added)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ResourceSchema.java Sat Jul 27 06:09:57 2013
@@ -0,0 +1,111 @@
+/*
+ * 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.scim.ldap.schema;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ *
+ * TODO ResourceSchema.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class ResourceSchema
+{
+ private String baseDn;
+ private String filter;
+
+ private List<String> uris = new ArrayList<String>();
+
+ private Map<String, BaseType> coreTypes = new HashMap<String, BaseType>();
+ private Map<String, BaseType> extendedTypes = new HashMap<String, BaseType>();
+
+
+ public ResourceSchema( String baseDn, String filter )
+ {
+ this.baseDn = baseDn;
+ this.filter = filter;
+ }
+
+
+ public BaseType getCoreAttribute( String name )
+ {
+ return coreTypes.get( name );
+ }
+
+
+ public BaseType getExtAttribute( String name )
+ {
+ return extendedTypes.get( name );
+ }
+
+
+ public void addAttributeType( String name, BaseType type )
+ {
+ if ( type != null )
+ {
+ if ( type.isCoreAttribute() )
+ {
+ coreTypes.put( name, type );
+ }
+ else
+ {
+ extendedTypes.put( name, type );
+ }
+ }
+ }
+
+
+ public Collection<BaseType> getCoreAttributes()
+ {
+ return coreTypes.values();
+ }
+
+
+ public void addUri( String uri )
+ {
+ uris.add( uri );
+ }
+
+
+ /**
+ * @return the baseDn
+ */
+ public String getBaseDn()
+ {
+ return baseDn;
+ }
+
+
+ /**
+ * @return the filter
+ */
+ public String getFilter()
+ {
+ return filter;
+ }
+
+}
Added: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleType.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleType.java?rev=1507578&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleType.java (added)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleType.java Sat Jul 27 06:09:57 2013
@@ -0,0 +1,89 @@
+/*
+ * 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.scim.ldap.schema;
+
+
+/**
+ * TODO SimpleType.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SimpleType extends BaseType
+{
+ private String name;
+
+ private String mappedTo;
+
+ private boolean show = true;
+
+
+ public SimpleType( String name, String mappedTo, String uri, boolean show )
+ {
+ super(uri);
+ this.name = name;
+ this.mappedTo = mappedTo;
+ this.show = show;
+ }
+
+
+ /**
+ * @return the name
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+
+ /**
+ * @return the mappedTo
+ */
+ public String getMappedTo()
+ {
+ return mappedTo;
+ }
+
+
+ /**
+ * @return the show
+ */
+ public boolean isShow()
+ {
+ return show;
+ }
+
+
+ @Override
+ public boolean isSimple()
+ {
+ return true;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ return "SimpleType [name=" + name + ", mappedTo=" + mappedTo + ", show=" + show + "]";
+ }
+
+}
Added: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleTypeGroup.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleTypeGroup.java?rev=1507578&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleTypeGroup.java (added)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleTypeGroup.java Sat Jul 27 06:09:57 2013
@@ -0,0 +1,71 @@
+/*
+ * 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.scim.ldap.schema;
+
+
+import java.util.Collections;
+import java.util.List;
+
+
+/**
+ * TODO SimpleTypeGroup.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SimpleTypeGroup
+{
+ private List<SimpleType> lstSTypes;
+
+ private String format;
+
+ public SimpleTypeGroup( List<SimpleType> lstSTypes, String format )
+ {
+ this.lstSTypes = lstSTypes;
+ }
+
+
+ /**
+ * @return the format
+ */
+ public String getFormat()
+ {
+ return format;
+ }
+
+
+ /**
+ * @return the lstSTypes
+ */
+ public List<SimpleType> getLstSTypes()
+ {
+ return Collections.unmodifiableList( lstSTypes );
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ return "SimpleTypeGroup [lstSTypes=" + lstSTypes + ", format=" + format + "]";
+ }
+
+}
Added: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/TypedType.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/TypedType.java?rev=1507578&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/TypedType.java (added)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/TypedType.java Sat Jul 27 06:09:57 2013
@@ -0,0 +1,89 @@
+/*
+ * 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.scim.ldap.schema;
+
+
+/**
+ * TODO SimpleType.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class TypedType extends BaseType
+{
+ private String name;
+
+ private SimpleTypeGroup atGroup;
+
+ private boolean show = true;
+
+ private boolean primary = false;
+
+
+ public TypedType( String name, SimpleTypeGroup atGroup, boolean show, boolean primary, String uri )
+ {
+ super(uri);
+ this.name = name;
+ this.atGroup = atGroup;
+ this.show = show;
+ this.primary = primary;
+ }
+
+ /**
+ * @return the atGroup
+ */
+ public SimpleTypeGroup getAtGroup()
+ {
+ return atGroup;
+ }
+
+ /**
+ * @return the show
+ */
+ public boolean isShow()
+ {
+ return show;
+ }
+
+ /**
+ * @return the primary
+ */
+ public boolean isPrimary()
+ {
+ return primary;
+ }
+
+ @Override
+ public boolean isTyped()
+ {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ return "TypedType [type=" + name + ", atGroup=" + atGroup + ", show=" + show + ", primary="
+ + primary + "]";
+ }
+
+
+}
Added: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/UserSchema.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/UserSchema.java?rev=1507578&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/UserSchema.java (added)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/UserSchema.java Sat Jul 27 06:09:57 2013
@@ -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.directory.scim.ldap.schema;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * TODO UserSchema.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class UserSchema extends ResourceSchema
+{
+ public UserSchema( String baseDn, String filter )
+ {
+ super( baseDn, filter );
+ }
+
+}
Modified: directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/UserService.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/UserService.java?rev=1507578&r1=1507577&r2=1507578&view=diff
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/UserService.java (original)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/UserService.java Sat Jul 27 06:09:57 2013
@@ -36,7 +36,8 @@ public class UserService
@GET
@Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- public User getUser( @PathParam("user") String userId )
+ @Path("{id}")
+ public User getUser( @PathParam("id") String userId )
{
return null;
}