Return-Path: X-Original-To: apmail-incubator-airavata-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-airavata-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2430A9870 for ; Mon, 9 Apr 2012 21:01:54 +0000 (UTC) Received: (qmail 36282 invoked by uid 500); 9 Apr 2012 21:01:54 -0000 Delivered-To: apmail-incubator-airavata-commits-archive@incubator.apache.org Received: (qmail 36243 invoked by uid 500); 9 Apr 2012 21:01:54 -0000 Mailing-List: contact airavata-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: airavata-dev@incubator.apache.org Delivered-To: mailing list airavata-commits@incubator.apache.org Received: (qmail 36236 invoked by uid 99); 9 Apr 2012 21:01:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Apr 2012 21:01:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Apr 2012 21:01:50 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 3B33723888FE; Mon, 9 Apr 2012 21:01:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1311439 - /incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java Date: Mon, 09 Apr 2012 21:01:29 -0000 To: airavata-commits@incubator.apache.org From: lahiru@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120409210129.3B33723888FE@eris.apache.org> Author: lahiru Date: Mon Apr 9 21:01:28 2012 New Revision: 1311439 URL: http://svn.apache.org/viewvc?rev=1311439&view=rev Log: loading preconfigured hostDescriptions. Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java?rev=1311439&r1=1311438&r2=1311439&view=diff ============================================================================== --- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java (original) +++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java Mon Apr 9 21:01:28 2012 @@ -21,12 +21,12 @@ package org.apache.airavata.xbaya.interpretor; -import java.io.File; -import java.io.IOException; +import java.io.*; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.Properties; @@ -48,6 +48,8 @@ import org.apache.airavata.xbaya.graph.s import org.apache.airavata.xbaya.monitor.MonitorException; import org.apache.airavata.xbaya.ode.ODEClient; import org.apache.airavata.xbaya.wf.Workflow; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.impl.builder.StAXOMBuilder; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.description.AxisService; import org.apache.axis2.engine.ServiceLifeCycle; @@ -59,9 +61,13 @@ import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import javax.jcr.RepositoryException; +import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; /** * WorkflowInterpretorSkeleton java skeleton for the axisService @@ -295,40 +301,33 @@ public class WorkflowInterpretorSkeleton private List getDefinedHostDescriptions() { URL url = this.getClass().getClassLoader().getResource("host.xml"); - File fXmlFile = new File(url.getPath()); - DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder dBuilder = null; ArrayList hostDescriptions = new ArrayList(); + XMLStreamReader reader = null; try { - dBuilder = dbFactory.newDocumentBuilder(); - Document doc = dBuilder.parse(fXmlFile); - doc.getDocumentElement().normalize(); - System.out.println("Root element :" + doc.getDocumentElement().getNodeName()); - NodeList nList = doc.getElementsByTagName("server"); - for (int temp = 0; temp < nList.getLength(); temp++) { - Node nNode = nList.item(temp); - HostDescription hostDescription ; - if (nNode.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) nNode; - if(XMLUtil.getTagValue("gram.endpoint", eElement) != null){ - hostDescription = new HostDescription(GlobusHostType.type); - ((GlobusHostType)hostDescription.getType()).addGlobusGateKeeperEndPoint(XMLUtil.getTagValue("gram.endpoint", eElement)); - ((GlobusHostType)hostDescription.getType()).addGridFTPEndPoint(XMLUtil.getTagValue("gridftp.endpoint", eElement)); - }else{ - hostDescription = new HostDescription(HostDescriptionType.type); - } - (hostDescription.getType()).setHostName(XMLUtil.getTagValue("name", eElement)); - (hostDescription.getType()).setHostAddress(XMLUtil.getTagValue("host", eElement)); - hostDescriptions.add(hostDescription); - } - } - } catch (ParserConfigurationException e) { + File fXmlFile = new File(url.getPath()); + reader = XMLInputFactory.newInstance().createXMLStreamReader(new FileReader(fXmlFile)); + } catch (XMLStreamException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } catch (SAXException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } catch (IOException e) { + } catch (FileNotFoundException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } + StAXOMBuilder builder = new StAXOMBuilder(reader); + OMElement documentElement = builder.getDocumentElement(); + Iterator server = documentElement.getChildrenWithName(new QName("server")); + while (server.hasNext()) { + OMElement next = (OMElement) server.next(); + HostDescription hostDescription; + if (next.getFirstChildWithName(new QName("gram.endpoint")) != null) { + hostDescription = new HostDescription(GlobusHostType.type); + ((GlobusHostType) hostDescription.getType()).addGlobusGateKeeperEndPoint(next.getFirstChildWithName(new QName("gram.endpoint")).getText()); + ((GlobusHostType) hostDescription.getType()).addGridFTPEndPoint(next.getFirstChildWithName(new QName("gridftp.endpoint")).getText()); + } else { + hostDescription = new HostDescription(HostDescriptionType.type); + } + (hostDescription.getType()).setHostName(next.getFirstChildWithName(new QName("name")).getText()); + (hostDescription.getType()).setHostAddress(next.getFirstChildWithName(new QName("host")).getText()); + hostDescriptions.add(hostDescription); + } return hostDescriptions; } }