Author: chathura
Date: Wed Jan 23 00:51:51 2008
New Revision: 12748

Log:


Fixed resource metadata handling in wsdl and xsd imports.



Modified:
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/WSDLMediaTypeHandler.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/XSDMediaTypeHandler.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/utils/SchemaFileProcessor.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/utils/WSDLFileProcessor.java

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/WSDLMediaTypeHandler.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/WSDLMediaTypeHandler.java
       (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/WSDLMediaTypeHandler.java
       Wed Jan 23 00:51:51 2008
@@ -52,7 +52,7 @@
 
     public boolean importResource(String path, String sourceURL, Resource 
metadata) throws RegistryException {
 
-        wsdlFileProcessor.saveWSDLFileToRegistry(sourceURL, 
getParentPath(path), true);
+        wsdlFileProcessor.saveWSDLFileToRegistry(sourceURL, 
getParentPath(path), true, metadata);
         return true;
     }
 

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/XSDMediaTypeHandler.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/XSDMediaTypeHandler.java
        (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/XSDMediaTypeHandler.java
        Wed Jan 23 00:51:51 2008
@@ -52,7 +52,7 @@
 
     public boolean importResource(String path, String sourceURL, Resource 
metadata) throws RegistryException {
 
-        schemaFileProcessor.saveSchemaFileToRegistry(sourceURL, 
getParentPath(path), true);
+        schemaFileProcessor.saveSchemaFileToRegistry(sourceURL, 
getParentPath(path), true, metadata);
         return true;
     }
 

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/utils/SchemaFileProcessor.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/utils/SchemaFileProcessor.java
  (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/utils/SchemaFileProcessor.java
  Wed Jan 23 00:51:51 2008
@@ -50,10 +50,10 @@
      * @throws FileNotFoundException
      */
 
-    public void saveSchemaFileToRegistry(String location, String 
registryBasePath,boolean processInclueds)
+    public void saveSchemaFileToRegistry(String location, String 
registryBasePath,boolean processInclueds, Resource metadata)
             throws RegistryException {
 
-        saveSchemaFileToRegistry(location, new HashMap(), 
registryBasePath,processInclueds);
+        saveSchemaFileToRegistry(location, new HashMap(), 
registryBasePath,processInclueds, metadata);
     }
 
     /**
@@ -61,7 +61,7 @@
      * @param processedSchemaMap - this map contains schema source URI vs new 
schema locaitons.
      */
     public void saveSchemaFileToRegistry(String location,
-                                         Map processedSchemaMap, String 
registryBasePath,boolean processInclueds)
+                                         Map processedSchemaMap, String 
registryBasePath,boolean processInclueds, Resource metadata)
             throws RegistryException {
 
         XmlSchemaCollection xmlSchemaCollection = new XmlSchemaCollection();
@@ -71,7 +71,7 @@
         XmlSchema xmlSchema = xmlSchemaCollection.read(inputSource, null);
         // this is not an inline wsdl schema. so pass null to change map.
         calculateNewSchemaNames(xmlSchema, processedSchemaMap, new HashSet(), 
false,processInclueds);
-        saveSchemaFileToRegistry(xmlSchema, processedSchemaMap, null, new 
HashSet(), false, registryBasePath,processInclueds);
+        saveSchemaFileToRegistry(xmlSchema, processedSchemaMap, null, new 
HashSet(), false, registryBasePath,processInclueds, metadata);
     }
 
     /**
@@ -152,7 +152,8 @@
                                          Set visitedShemas,
                                          boolean isWsdlInlineSchema,
                                          String registryBasePath,
-                                         boolean processIncludes) throws 
RegistryException {
+                                         boolean processIncludes,
+                                         Resource metadata) throws 
RegistryException {
 
         if (processIncludes) {
             // first process the imports and includes
@@ -170,7 +171,7 @@
                         innerSchema = xmlSchemaExternal.getSchema();
                         if 
(!visitedShemas.contains(innerSchema.getSourceURI())) {
                             
saveSchemaFileToRegistry(xmlSchemaExternal.getSchema(),
-                                    processedSchemaMap, null, visitedShemas, 
false, registryBasePath,processIncludes);
+                                    processedSchemaMap, null, visitedShemas, 
false, registryBasePath,processIncludes, null);
                         }
 
                         // add the new name to changeschema map
@@ -198,6 +199,10 @@
             byte[] xsdContent = byteArrayOutputStream.toByteArray();
 
             Resource xsdResource = new Resource();
+            if (metadata != null) {
+                xsdResource.setMediaType(metadata.getMediaType());
+                xsdResource.setDescription(metadata.getDescription());
+            }
             xsdResource.setContent(xsdContent);
             defaultMediaTypeHandler.put(registryBasePath + 
RegistryConstants.PATH_SEPARATOR + fileNameToSave, xsdResource);
 

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/utils/WSDLFileProcessor.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/utils/WSDLFileProcessor.java
    (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/utils/WSDLFileProcessor.java
    Wed Jan 23 00:51:51 2008
@@ -58,7 +58,7 @@
      * @param location
      * @throws WSDLException
      */
-    public void saveWSDLFileToRegistry(String location, String 
registryBasePath,boolean processImports)
+    public void saveWSDLFileToRegistry(String location, String 
registryBasePath,boolean processImports, Resource metadata)
             throws RegistryException {
         WSDLReader wsdlReader = null;
 
@@ -83,7 +83,7 @@
         Map processedWSDLMap = new HashMap();
         calculateWSDLNamesAndChangeTypes(wsdlDefinition, processedWSDLMap, new 
HashMap(),
                                          new HashSet(), 
registryBasePath,processImports);
-        saveWSDLFileToRegistry(wsdlDefinition, processedWSDLMap, new 
HashSet(), registryBasePath,processImports);
+        saveWSDLFileToRegistry(wsdlDefinition, processedWSDLMap, new 
HashSet(), registryBasePath,processImports, metadata);
     }
 
     /**
@@ -153,7 +153,7 @@
                     schemaFileProcessor.calculateNewSchemaNames(
                             xmlSchema, processedScheamMap, new HashSet(), 
true, processImports);
                     schemaFileProcessor.saveSchemaFileToRegistry(
-                            xmlSchema, processedScheamMap, changedLocationMap, 
new HashSet(), true, registryBasePath,processImports);
+                            xmlSchema, processedScheamMap, changedLocationMap, 
new HashSet(), true, registryBasePath,processImports, null);
                     // update the current schema locations with the generated 
ones.
                     changeLocations(schemaExtension.getElement(), 
changedLocationMap);
                 }
@@ -178,7 +178,8 @@
                                        Map processedWSDLMap,
                                        Set visitedWSDLs,
                                        String registryBasePath,
-                                       boolean processImports) throws 
RegistryException {
+                                       boolean processImports,
+                                       Resource metadata) throws 
RegistryException {
 
         if (processImports) {
             // first we have to process the imports and change the
@@ -197,7 +198,7 @@
                     if 
(!visitedWSDLs.contains(innerDefinition.getDocumentBaseURI())) {
                         // we have not process this wsdl file earlier
                         saveWSDLFileToRegistry(innerDefinition, 
processedWSDLMap, visitedWSDLs,
-                                registryBasePath,processImports);
+                                registryBasePath,processImports, null);
                     }
                     // set the import location according to the new location
                     wsdlImport.setLocationURI((String) processedWSDLMap.get(
@@ -223,6 +224,11 @@
             String wsdlPath =
                     registryBasePath + RegistryConstants.PATH_SEPARATOR + 
importedResourceName;
             Resource wsdlResource = new Resource();
+
+            if (metadata != null) {
+                wsdlResource.setMediaType(metadata.getMediaType());
+                wsdlResource.setDescription(metadata.getDescription());
+            }
             wsdlResource.setContent(wsdlResourceContent);
             defaultMediaTypeHandler.put(wsdlPath, wsdlResource);
 

_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev

Reply via email to