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/10/05 15:50:28 UTC
svn commit: r1529453 - in
/directory/escimo/branches/json-schema-experiment/schema/src/main/java/org:
./ apache/ apache/directory/ apache/directory/scim/
apache/directory/scim/schema/
Author: kayyagari
Date: Sat Oct 5 13:50:28 2013
New Revision: 1529453
URL: http://svn.apache.org/r1529453
Log:
o top level class for all resources
o a utility class for schema reading
Added:
directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/
directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/
directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/directory/
directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/directory/scim/
directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/directory/scim/schema/
directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/directory/scim/schema/CoreResource.java
directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/directory/scim/schema/MetaData.java
directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/directory/scim/schema/SchemaUtil.java
Added: directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/directory/scim/schema/CoreResource.java
URL: http://svn.apache.org/viewvc/directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/directory/scim/schema/CoreResource.java?rev=1529453&view=auto
==============================================================================
--- directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/directory/scim/schema/CoreResource.java (added)
+++ directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/directory/scim/schema/CoreResource.java Sat Oct 5 13:50:28 2013
@@ -0,0 +1,114 @@
+/*
+ * 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.schema;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * TODO CoreResource.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class CoreResource
+{
+ private List<CoreResource> extResources;
+
+ private MetaData meta;
+
+ private String schemaId;
+
+ private String resourceDesc;
+
+ public void addExtendedResource( CoreResource resource )
+ {
+ if( extResources == null )
+ {
+ extResources = new ArrayList<CoreResource>();
+ }
+
+ extResources.add( resource );
+ }
+
+ /**
+ * @return the extResources
+ */
+ public List<CoreResource> getExtResources()
+ {
+ return extResources;
+ }
+
+ /**
+ * @param extResources the extResources to set
+ */
+ public void setExtResources( List<CoreResource> extResources )
+ {
+ this.extResources = extResources;
+ }
+
+ /**
+ * @return the meta
+ */
+ public MetaData getMeta()
+ {
+ return meta;
+ }
+
+ /**
+ * @param meta the meta to set
+ */
+ public void setMeta( MetaData meta )
+ {
+ this.meta = meta;
+ }
+
+ /**
+ * @return the schemaId
+ */
+ public String getSchemaId()
+ {
+ return schemaId;
+ }
+
+ /**
+ * @param schemaId the schemaId to set
+ */
+ public void setSchemaId( String schemaId )
+ {
+ this.schemaId = schemaId;
+ }
+
+ /**
+ * @return the resourceDesc
+ */
+ public String getResourceDesc()
+ {
+ return resourceDesc;
+ }
+
+ /**
+ * @param resourceDesc the resourceDesc to set
+ */
+ public void setResourceDesc( String resourceDesc )
+ {
+ this.resourceDesc = resourceDesc;
+ }
+
+}
Added: directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/directory/scim/schema/MetaData.java
URL: http://svn.apache.org/viewvc/directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/directory/scim/schema/MetaData.java?rev=1529453&view=auto
==============================================================================
--- directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/directory/scim/schema/MetaData.java (added)
+++ directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/directory/scim/schema/MetaData.java Sat Oct 5 13:50:28 2013
@@ -0,0 +1,154 @@
+/*
+ * 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.schema;
+
+
+import java.util.Date;
+import java.util.List;
+
+
+/**
+ * TODO MetaData.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MetaData
+{
+ private String resourceType;
+
+ private Date created;
+
+ private Date lastModified;
+
+ private String location;
+
+ private String version;
+
+ private List<String> attributes;
+
+
+ /**
+ * @return the resourceType
+ */
+ public String getResourceType()
+ {
+ return resourceType;
+ }
+
+
+ /**
+ * @param resourceType the resourceType to set
+ */
+ public void setResourceType( String resourceType )
+ {
+ this.resourceType = resourceType;
+ }
+
+
+ /**
+ * @return the created
+ */
+ public Date getCreated()
+ {
+ return created;
+ }
+
+
+ /**
+ * @param created the created to set
+ */
+ public void setCreated( Date created )
+ {
+ this.created = created;
+ }
+
+
+ /**
+ * @return the lastModified
+ */
+ public Date getLastModified()
+ {
+ return lastModified;
+ }
+
+
+ /**
+ * @param lastModified the lastModified to set
+ */
+ public void setLastModified( Date lastModified )
+ {
+ this.lastModified = lastModified;
+ }
+
+
+ /**
+ * @return the location
+ */
+ public String getLocation()
+ {
+ return location;
+ }
+
+
+ /**
+ * @param location the location to set
+ */
+ public void setLocation( String location )
+ {
+ this.location = location;
+ }
+
+
+ /**
+ * @return the version
+ */
+ public String getVersion()
+ {
+ return version;
+ }
+
+
+ /**
+ * @param version the version to set
+ */
+ public void setVersion( String version )
+ {
+ this.version = version;
+ }
+
+
+ /**
+ * @return the attributes
+ */
+ public List<String> getAttributes()
+ {
+ return attributes;
+ }
+
+
+ /**
+ * @param attributes the attributes to set
+ */
+ public void setAttributes( List<String> attributes )
+ {
+ this.attributes = attributes;
+ }
+
+}
Added: directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/directory/scim/schema/SchemaUtil.java
URL: http://svn.apache.org/viewvc/directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/directory/scim/schema/SchemaUtil.java?rev=1529453&view=auto
==============================================================================
--- directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/directory/scim/schema/SchemaUtil.java (added)
+++ directory/escimo/branches/json-schema-experiment/schema/src/main/java/org/apache/directory/scim/schema/SchemaUtil.java Sat Oct 5 13:50:28 2013
@@ -0,0 +1,88 @@
+/*
+ * 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.schema;
+
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * TODO SchemaUtil.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SchemaUtil
+{
+ public static List<URL> getDefaultSchemas()
+ {
+ String[] stockNames =
+ { "user-schema.json", "group-schema.json", "enterprise-user-schema.json" };
+ List<URL> lst = new ArrayList<URL>();
+
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ for ( String s : stockNames )
+ {
+ URL u = cl.getResource( s );
+ lst.add( u );
+ }
+
+ return lst;
+ }
+
+
+ public static String getSchemaJson( URL url ) throws IOException
+ {
+ BufferedReader br = null;
+ try
+ {
+ br = new BufferedReader( new InputStreamReader( url.openStream() ) );
+
+ String s;
+
+ StringBuilder sb = new StringBuilder();
+ while ( ( s = br.readLine() ) != null )
+ {
+ sb.append( s );
+ }
+
+ return sb.toString();
+ }
+ finally
+ {
+ if ( br != null )
+ {
+ try
+ {
+ br.close();
+ }
+ catch ( IOException e )
+ {
+ // ignore
+ }
+ }
+ }
+ }
+
+}