org.wso2.registry.jdbc.mediatypes.utils
Class SchemaFileProcessor

java.lang.Object
  extended by org.wso2.registry.jdbc.mediatypes.utils.SchemaFileProcessor

public class SchemaFileProcessor
extends java.lang.Object


Constructor Summary
SchemaFileProcessor(DefaultMediaTypeHandler defaultMediaTypeHandler)
           
 
Method Summary
 void calculateNewSchemaNames(org.apache.ws.commons.schema.XmlSchema xmlSchema, java.util.Map processedSchemaMap, java.util.Set visitedSchemas, boolean isWSDLInlineSchema, boolean processIncludes)
          calculate the new schema file names to save the schema.
 java.lang.String saveSchemaFileToRegistry(java.lang.String location, java.util.Map processedSchemaMap, java.lang.String registryBasePath, boolean processIncludes, Resource metadata)
          Import a schema file to the registry after saving all its includes and imports to the registry and updating the schema locations accordingly.
 java.lang.String saveSchemaFileToRegistry(java.lang.String location, java.lang.String registryBasePath, boolean processIncludes, Resource metadata)
          Import a schema file to the registry after saving all its includes and imports to the registry and updating the schema locations accordingly.
 void saveSchemaFileToRegistry(org.apache.ws.commons.schema.XmlSchema xmlSchema, java.util.Map processedSchemaMap, java.util.Map changeSchemaNames, java.util.Set visitedSchemas, boolean isWSDLInlineSchema, java.lang.String registryBasePath, boolean processIncludes, Resource metadata)
          Save the schemas to the registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaFileProcessor

public SchemaFileProcessor(DefaultMediaTypeHandler defaultMediaTypeHandler)
Method Detail

saveSchemaFileToRegistry

public java.lang.String saveSchemaFileToRegistry(java.lang.String location,
                                                 java.lang.String registryBasePath,
                                                 boolean processIncludes,
                                                 Resource metadata)
                                          throws RegistryException
Import a schema file to the registry after saving all its includes and imports to the registry and updating the schema locations accordingly.

Parameters:
location - the original schema location
registryBasePath - base path of the registry
processIncludes - true if we should recurse through includes
metadata - template Resource from which to obtain media-type, description, etc.
Returns:
the resulting path of the new resource
Throws:
RegistryException

saveSchemaFileToRegistry

public java.lang.String saveSchemaFileToRegistry(java.lang.String location,
                                                 java.util.Map processedSchemaMap,
                                                 java.lang.String registryBasePath,
                                                 boolean processIncludes,
                                                 Resource metadata)
                                          throws RegistryException
Import a schema file to the registry after saving all its includes and imports to the registry and updating the schema locations accordingly.

Parameters:
location - the original schema location
processedSchemaMap - a Map from original URI (String) to new schema location (String)
registryBasePath - base path of the registry
processIncludes - true if we should recurse through includes
metadata - template Resource from which to obtain media-type, description, etc.
Returns:
the resulting path of the new resource
Throws:
RegistryException

calculateNewSchemaNames

public void calculateNewSchemaNames(org.apache.ws.commons.schema.XmlSchema xmlSchema,
                                    java.util.Map processedSchemaMap,
                                    java.util.Set visitedSchemas,
                                    boolean isWSDLInlineSchema,
                                    boolean processIncludes)
calculate the new schema file names to save the schema. Here we can not save the schema file as it is since there may be recursive imports. So what we have to do is to first determine the schema names to be saved and then change the schema locations accordingly. In this method first we iterate through the imports and includes and find the names. have used the visitedSchemas variable to keep track of the visited schemas to avoid the recursion.

Parameters:
xmlSchema - the schema to we'd like to save into the registry
processedSchemaMap - a Map from original URI (String) to new schema location (String)
visitedSchemas - a Set of previously visited schema source uris
isWSDLInlineSchema - true if the given schema is an inline schema of a wsdl - if so, we do not need to calculate a name for it
processIncludes - true if we should process includes

saveSchemaFileToRegistry

public void saveSchemaFileToRegistry(org.apache.ws.commons.schema.XmlSchema xmlSchema,
                                     java.util.Map processedSchemaMap,
                                     java.util.Map changeSchemaNames,
                                     java.util.Set visitedSchemas,
                                     boolean isWSDLInlineSchema,
                                     java.lang.String registryBasePath,
                                     boolean processIncludes,
                                     Resource metadata)
                              throws RegistryException
Save the schemas to the registry. used the calculated names in the processedSchemaMap to change the schema locations.

Parameters:
xmlSchema - the schema to save
processedSchemaMap - a Map from original URI (String) to new schema location (String)
changeSchemaNames - a Map from original URIs to changed URIs. Used to update the WSDL inline schema imports/includes when saving WSDLs.
visitedSchemas - a Set of schema URIs (Strings) that we've already visited
isWSDLInlineSchema - true if this is an inline schema from a WSDL
registryBasePath - the base path of the registry
processIncludes - true if we should recurse into includes of this schema
metadata - template Resource for metadata (media-type, description)
Throws:
RegistryException


Copyright © 2007 Apache Web Services Project. All Rights Reserved.