Author: azeez
Date: Mon Dec  3 07:10:47 2007
New Revision: 10448

Log:

Merging WSAS 2.1 branch to the trunk

Added:
   trunk/commons/codegen/src/main/resources/codegen-pom.xsl
      - copied unchanged from r10403, 
branches/wsas/java/2.1/commons/codegen/src/main/resources/codegen-pom.xsl
Modified:
   trunk/commons/codegen/pom.xml
   
trunk/commons/codegen/src/main/java/org/wso2/codegen/service/ajax/DynamicCodeGeneratorService.java
   
trunk/commons/codegen/src/main/java/org/wso2/codegen/service/wsdl2code/WSDL2Code.java
   trunk/commons/codegen/src/main/resources/codegen-options.xml
   trunk/commons/codegen/www/wsdl2code2.xsl

Modified: trunk/commons/codegen/pom.xml
==============================================================================
--- trunk/commons/codegen/pom.xml       (original)
+++ trunk/commons/codegen/pom.xml       Mon Dec  3 07:10:47 2007
@@ -287,6 +287,11 @@
             <artifactId>wstx-asl</artifactId>
             <version>3.2.1</version>
         </dependency>
+        <dependency>
+            <groupId>jaxen</groupId>
+            <artifactId>jaxen</artifactId>
+            <version>1.1-beta-10</version>
+        </dependency>
     </dependencies>
 
     <repositories>
@@ -346,6 +351,35 @@
 
     </pluginRepositories>
 
+    <profiles>
+         <profile>
+             <activation>
+                 <property>
+                     <name>sign</name>
+                 </property>
+             </activation>
+             <build>
+                 <plugins>
+                     <plugin>
+                         <groupId>org.apache.maven.plugins</groupId>
+                         <artifactId>maven-gpg-plugin</artifactId>
+                         <version>1.0-alpha-3</version>
+                         <executions>
+                             <execution>
+                                 <id>sign-artifacts</id>
+                                 <phase>verify</phase>
+                                 <goals>
+                                     <goal>sign</goal>
+                                 </goals>
+                             </execution>
+                         </executions>
+                     </plugin>
+                 </plugins>
+             </build>
+         </profile>
+     </profiles>
+        
+
     <distributionManagement>
         <repository>
             <id>wso2-maven2-repository</id>
@@ -360,13 +394,13 @@
     </distributionManagement>
 
     <properties>
-        <axis2.version>1.3</axis2.version>
+        <axis2.version>SNAPSHOT</axis2.version>
         <wso2codegen.version>${pom.version}</wso2codegen.version>
         <wso2utils.version>SNAPSHOT</wso2utils.version>
         <dynamiccodegen.version>SNAPSHOT</dynamiccodegen.version>
-        <neethi.version>2.0.2</neethi.version>
-        <axiom.version>1.2.5</axiom.version>
-        <XmlSchema.version>1.3.2</XmlSchema.version>
+        <neethi.version>SNAPSHOT</neethi.version>
+        <axiom.version>SNAPSHOT</axiom.version>
+        <XmlSchema.version>SNAPSHOT</XmlSchema.version>
         <xbean.version>2.1.0</xbean.version>
 
         <woden.version>1.0-incubating-SNAPSHOT</woden.version>

Modified: 
trunk/commons/codegen/src/main/java/org/wso2/codegen/service/ajax/DynamicCodeGeneratorService.java
==============================================================================
--- 
trunk/commons/codegen/src/main/java/org/wso2/codegen/service/ajax/DynamicCodeGeneratorService.java
  (original)
+++ 
trunk/commons/codegen/src/main/java/org/wso2/codegen/service/ajax/DynamicCodeGeneratorService.java
  Mon Dec  3 07:10:47 2007
@@ -186,7 +186,7 @@
                     "</h4>" +
                     "</div>";
 
-            transformer.setParameter("image-path", "extensions/core/images/");
+            transformer.setParameter("show-alternate", "false");
             transformer.setParameter("breadcrumbs", injectValue);
             transformer.transform(xmlSource, tryItResult);
 

Modified: 
trunk/commons/codegen/src/main/java/org/wso2/codegen/service/wsdl2code/WSDL2Code.java
==============================================================================
--- 
trunk/commons/codegen/src/main/java/org/wso2/codegen/service/wsdl2code/WSDL2Code.java
       (original)
+++ 
trunk/commons/codegen/src/main/java/org/wso2/codegen/service/wsdl2code/WSDL2Code.java
       Mon Dec  3 07:10:47 2007
@@ -15,29 +15,35 @@
  */
 package org.wso2.codegen.service.wsdl2code;
 
+import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.xpath.AXIOMXPath;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.util.CommandLineOptionParser;
 import org.apache.axis2.util.CommandLineOption;
 import org.apache.axis2.util.CommandLineOptionConstants;
+import org.apache.axis2.util.CommandLineOptionParser;
 import org.apache.axis2.wsdl.codegen.CodeGenerationEngine;
 import org.apache.axis2.wsdl.util.WSDL2JavaOptionsValidator;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.wso2.utils.AntBuildException;
-import org.wso2.utils.AntBuildInvoker;
+import org.jaxen.JaxenException;
+import org.jaxen.XPath;
+import org.wso2.utils.ArchiveManipulator;
 import org.wso2.utils.FileManipulator;
 import org.wso2.utils.WSO2Constants;
 
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-import java.io.InputStream;
+import javax.xml.transform.*;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.*;
 import java.util.*;
 
 /**
@@ -46,16 +52,16 @@
 public class WSDL2Code {
 
     private static Log log = LogFactory.getLog(WSDL2Code.class);
+    private static final String CODEGEN_POM_XSL = "codegen-pom.xsl";
 
     /**
      * User will be able to get the codegen options file
      *
      * @return OMElement
-     * @throws AxisFault
+     * @throws AxisFault throws an AxisFault
      */
     public OMElement getCodegenOptions() throws AxisFault {
         //Codegen option file is taken from classpath
-        //TODO configure through axis2.xml
         String s1 = "codegen-options.xml";
         InputStream inStream = getClass().getResourceAsStream(s1);
         if (inStream == null) {
@@ -153,27 +159,76 @@
         }
         //set the output name
         CommandLineOption option =
-                    (CommandLineOption)allOptions.
-                            
get(CommandLineOptionConstants.WSDL2JavaConstants.SERVICE_NAME_OPTION);
+                (CommandLineOption) allOptions.
+                        
get(CommandLineOptionConstants.WSDL2JavaConstants.SERVICE_NAME_OPTION);
 
-        if (option != null && option.getOptionValue() != null) {
-            System.setProperty("name", option.getOptionValue());
-        } else {
-           System.setProperty("name", uuid + "_generated");
-        }
         try {
-            // Copy the source files into the build/classes dir so that the 
created client.jar file
-            // will contains the sources as well
-            File srcDir = new File(codegenOutputDir + File.separator + "src");
-            File destDir = new File(codegenOutputDir + File.separator + 
"build" +
-                                    File.separator + "classes");
-            destDir.mkdirs();
-            new FileManipulator().copyDir(srcDir, destDir);
-            // Call ant and create the jar file. This jar file should be 
uniquely identifiable
-            AntBuildInvoker ant = new AntBuildInvoker(new 
File(codegenOutputDir + "build.xml"));
-//            ant.invokeTarget("jar.client");
-            ant.invokeDefaultTarget();
+            //achive destination
+            uuid = String.valueOf(System.currentTimeMillis() + Math.random());
+            File destDir = new File(MessageContext.
+                    getCurrentMessageContext().getConfigurationContext().
+                    getProperty(WSO2Constants.WORK_DIR) + File.separator + 
"tools_codegen" +
+                                                        File.separator +
+                                                        uuid);
+            if (!destDir.exists()) {
+                destDir.mkdirs();
+            }
+            String destArchive = destDir.getAbsolutePath() + File.separator + 
uuid + ".zip";
+            InputStream pomXslInputStream = 
getClass().getResourceAsStream(CODEGEN_POM_XSL);
+            if (pomXslInputStream == null) {
+                pomXslInputStream = 
Thread.currentThread().getContextClassLoader()
+                        .getResourceAsStream(CODEGEN_POM_XSL);
+            }
+
+            String name = uuid;
+            boolean isBuildXml = false;
+            String version = "1.0";
+            File buildXml = new File(codegenOutputDir, "build.xml");
+            if (buildXml.exists() && buildXml.isFile()) {
+                isBuildXml = true;
+                InputStream buildInputStream = new FileInputStream(buildXml);
+                XMLStreamReader streamReader =
+                        
XMLInputFactory.newInstance().createXMLStreamReader(buildInputStream);
+                StAXOMBuilder builder = new StAXOMBuilder(streamReader);
+                XPath xp = new AXIOMXPath("/project/[EMAIL PROTECTED]'name']");
+                OMElement documentElement = builder.getDocumentElement();
+                OMElement nameEle = (OMElement) 
xp.selectSingleNode(documentElement);
+                if (nameEle != null) {
+                    OMAttribute omAttribute = nameEle.getAttribute(new 
QName("value"));
+                    String nameVal = omAttribute.getAttributeValue();
+                    if (nameVal != null) {
+                        name = nameVal;
+                    }
+                }
+            }
+            OMFactory fac = OMAbstractFactory.getOMFactory();
+            OMElement infoEle = fac.createOMElement(new QName("info"));
+            OMElement nameEle = fac.createOMElement(new QName("name"));
+            nameEle.setText(name);
+            infoEle.addChild(nameEle);
+            OMElement isBuildXmlEle = fac.createOMElement(new 
QName("isBuildXml"));
+            isBuildXmlEle.setText(Boolean.valueOf(isBuildXml).toString());
+            infoEle.addChild(isBuildXmlEle);
+            OMElement versionEle = fac.createOMElement(new QName("version"));
+            versionEle.setText(version);
+            infoEle.addChild(versionEle);
+            ByteArrayOutputStream bao = new ByteArrayOutputStream();
+            infoEle.serialize(bao);
+            InputStream xmlInputStream = new 
ByteArrayInputStream(bao.toByteArray());
+
+            if (pomXslInputStream != null) {
+                File pomFileOut = new File(codegenOutputDir, "pom.xml");
+                FileOutputStream pomFileOutputStream = new 
FileOutputStream(pomFileOut);
+                Source xmlSource = new StreamSource(xmlInputStream);
+                Source xslSource = new StreamSource(pomXslInputStream);
+                Result result = new StreamResult(pomFileOutputStream);
+                Transformer transformer =
+                        
TransformerFactory.newInstance().newTransformer(xslSource);
+                transformer.transform(xmlSource, result);
+            }
 
+            new ArchiveManipulator().archiveDir(destArchive, new 
File(codegenOutputDir).getPath());
+            new FileManipulator().deleteDir(new File(codegenOutputDir));
             Map fileResourcesMap =
                     (Map) 
MessageContext.getCurrentMessageContext().getConfigurationContext()
                             .getProperty(WSO2Constants.FILE_RESOURCE_MAP);
@@ -184,41 +239,30 @@
                         .setProperty(WSO2Constants.FILE_RESOURCE_MAP,
                                      fileResourcesMap);
             }
-
-            // Look for the jar in the build/lib dir
-            File f = new File(codegenOutputDir + File.separator + "build" +
-                              File.separator + "lib");
-            File[] files = f.listFiles(new FileFilter() {
-                public boolean accept(File f) {
-                    return f.getName().endsWith("-client.jar");
-                }
-            });
-
-            if (files != null) {
-                if (files.length == 0) {
-                    files = f.listFiles(new FileFilter() {
-                        public boolean accept(File f) {
-                            return f.getName().endsWith(".aar");
-                        }
-                    });
-                }
-            }
-
-            if ((files != null) && (files[0] != null) &&
-                (files[0].getAbsoluteFile() != null)) {
-                fileResourcesMap.put(uuid,
-                                     
files[0].getAbsoluteFile().getAbsolutePath());
-            }
+            fileResourcesMap.put(uuid, destArchive);
             return WSO2Constants.ContextPaths.DOWNLOAD_PATH + "?id=" + uuid;
 
         } catch (IOException e) {
             String msg = WSDL2Code.class.getName() + " IOException has 
occured.";
             log.error(msg, e);
-            throw AxisFault.makeFault(e);
-        } catch (AntBuildException e) {
-            String msg = WSDL2Code.class.getName() + " AntBuildException has 
occured.";
+            throw new AxisFault(msg, e);
+        } catch (XMLStreamException e) {
+            String msg =
+                    WSDL2Code.class.getName() + " error encountred while 
reading the build.xml";
             log.error(msg, e);
-            throw AxisFault.makeFault(e);
+            throw new AxisFault(msg, e);
+        } catch (JaxenException e) {
+            String msg = WSDL2Code.class.getName() + " xpath error has 
occured";
+            log.error(msg, e);
+            throw new AxisFault(msg, e);
+        } catch (TransformerConfigurationException e) {
+            String msg = WSDL2Code.class.getName() + " transformation error 
has occured";
+            log.error(msg, e);
+            throw new AxisFault(msg, e);
+        } catch (TransformerException e) {
+            String msg = WSDL2Code.class.getName() + " transformation error 
has occured";
+            log.error(msg, e);
+            throw new AxisFault(msg, e);
         }
     }
 

Modified: trunk/commons/codegen/src/main/resources/codegen-options.xml
==============================================================================
--- trunk/commons/codegen/src/main/resources/codegen-options.xml        
(original)
+++ trunk/commons/codegen/src/main/resources/codegen-options.xml        Mon Dec 
 3 07:10:47 2007
@@ -90,7 +90,6 @@
         <description>WSDL Version</description>
         <values>
             <value>1.1</value>
-            <value>2</value>
             <value>2.0</value>
         </values>
     </argument>
@@ -119,11 +118,11 @@
         <name>xsdconfig</name>
         <description>Use XMLBeans .xsdconfig file. Valid only with -d 
xmlbeans</description>
     </argument>
-    <argument uiType="skip">
+    <argument uiType="check">
         <name>ap</name>
         <description>Generate code for all ports</description>
     </argument>
-    <argument uiType="skip">
+    <argument uiType="check">
         <name>or</name>
         <description>Overwrite the existing classes</description>
     </argument>

Modified: trunk/commons/codegen/www/wsdl2code2.xsl
==============================================================================
--- trunk/commons/codegen/www/wsdl2code2.xsl    (original)
+++ trunk/commons/codegen/www/wsdl2code2.xsl    Mon Dec  3 07:10:47 2007
@@ -99,8 +99,7 @@
                         <xsl:when test="$uiType='text-area'">
                             <textarea>
                                 <xsl:attribute 
name="class">toolsClass</xsl:attribute>
-                                <xsl:attribute name="clos">40</xsl:attribute>
-                                <xsl:attribute name="rows">6</xsl:attribute>
+                                <xsl:attribute 
name="style">height:100px;width:345px</xsl:attribute>
                                 <xsl:attribute name="id"><xsl:value-of 
select="$name"/>_<xsl:value-of select="$idSuffix"/></xsl:attribute>
                             </textarea>
                         </xsl:when>

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

Reply via email to