SupunM, As an exercise, identify all the coding convention violations in the commit below :)
On Tue, Jan 3, 2012 at 5:29 PM, <sup...@wso2.com> wrote: > Author: supunm > Date: Tue Jan 3 03:59:34 2012 > New Revision: 118488 > URL: http://wso2.org/svn/browse/wso2?view=rev&revision=118488 > > Log: > adding WSDL2CodeClient > > Added: > > trunk/carbon/components/wsdl2code/org.wso2.carbon.modules.wsdl2code.ui/src/main/java/org/wso2/carbon/wsdl2code/ui/WSDL2CodeClient.java > > Added: > trunk/carbon/components/wsdl2code/org.wso2.carbon.modules.wsdl2code.ui/src/main/java/org/wso2/carbon/wsdl2code/ui/WSDL2CodeClient.java > URL: > http://wso2.org/svn/browse/wso2/trunk/carbon/components/wsdl2code/org.wso2.carbon.modules.wsdl2code.ui/src/main/java/org/wso2/carbon/wsdl2code/ui/WSDL2CodeClient.java?pathrev=118488 > > ============================================================================== > --- (empty file) > +++ > trunk/carbon/components/wsdl2code/org.wso2.carbon.modules.wsdl2code.ui/src/main/java/org/wso2/carbon/wsdl2code/ui/WSDL2CodeClient.java > Tue Jan 3 03:59:34 2012 > @@ -0,0 +1,64 @@ > +package org.wso2.carbon.wsdl2code.ui; > + > +import org.apache.axis2.AxisFault; > +import org.apache.axis2.client.Options; > +import org.apache.axis2.client.ServiceClient; > +import org.apache.axis2.context.ConfigurationContext; > +import org.apache.commons.logging.Log; > +import org.apache.commons.logging.LogFactory; > +import org.wso2.carbon.wsdl2code.stub.types.carbon.CodegenDownloadData; > +import org.wso2.carbon.wsdl2code.stub.WSDL2CodeServiceStub; > +import javax.activation.DataHandler; > +import javax.servlet.ServletOutputStream; > +import javax.servlet.http.HttpServletResponse; > +import java.io.IOException; > +import java.io.InputStream; > +import java.rmi.RemoteException; > +import java.util.ResourceBundle; > + > +public class WSDL2CodeClient { > + > + private static final Log log = > LogFactory.getLog(WSDL2CodeClient.class); > + private static final String BUNDLE = > "org.wso2.carbon.service.mgt.ui.i18n.Resources"; > + private ResourceBundle bundle; > + public WSDL2CodeServiceStub stub; > + > + public WSDL2CodeClient(ConfigurationContext configContext, String > backendServerURL, > + String cookie) throws AxisFault { > + > + String backendServiceURL = backendServerURL + "WSDL2CodeService"; > + stub = new WSDL2CodeServiceStub(configContext, backendServiceURL); > + ServiceClient client = stub._getServiceClient(); > + Options option = client.getOptions(); > + option.setManageSession(true); > + > > option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, > cookie); > + > + } > + > + public void codegen(String[] options, HttpServletResponse response) > throws AxisFault { > + try { > + ServletOutputStream out = response.getOutputStream(); > + CodegenDownloadData downloadData = stub.codegen(options); > + if (downloadData != null) { > + DataHandler handler = downloadData.getCodegenFileData(); > + response.setHeader("Content-Disposition", "fileName=" + > downloadData.getFileName()); > + response.setContentType(handler.getContentType()); > + InputStream in = handler.getDataSource().getInputStream(); > + int nextChar; > + while ((nextChar = in.read()) != -1) { > + out.write((char) nextChar); > + } > + out.flush(); > + in.close(); > + } else { > + out.write("The requested service archive was not found on > the server".getBytes()); > + } > + } catch (RemoteException e) { > + log.error(e.getMessage(), e); > + throw new AxisFault(e.getMessage(), e); > + } catch (IOException e) { > + log.error(e.getMessage(), e); > + throw new AxisFault(e.getMessage(), e); > + } > + } > +} > _______________________________________________ > Carbon-commits mailing list > carbon-comm...@wso2.org > https://wso2.org/cgi-bin/mailman/listinfo/carbon-commits > -- *Afkham Azeez* Director of Architecture; WSO2, Inc.; http://wso2.com Member; Apache Software Foundation; http://www.apache.org/ * <http://www.apache.org/>** email: **az...@wso2.com* <az...@wso2.com>* cell: +94 77 3320919 blog: **http://blog.afkham.org* <http://blog.afkham.org>* twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez> * linked-in: **http://lk.linkedin.com/in/afkhamazeez* * * *Lean . Enterprise . Middleware*
_______________________________________________ Carbon-dev mailing list Carbon-dev@wso2.org http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev