You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2011/05/14 20:35:02 UTC
svn commit: r1103180 [3/23] - in
/incubator/airavata/donations/ogce-donation: ./ modules/ modules/utils/
modules/utils/schemas/ modules/utils/schemas/gfac-schema-utils/
modules/utils/schemas/gfac-schema-utils/generated/
modules/utils/schemas/gfac-schem...
Added: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/beans/utils/ServiceParam.java
URL: http://svn.apache.org/viewvc/incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/beans/utils/ServiceParam.java?rev=1103180&view=auto
==============================================================================
--- incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/beans/utils/ServiceParam.java (added)
+++ incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/beans/utils/ServiceParam.java Sat May 14 18:34:50 2011
@@ -0,0 +1,59 @@
+/*
+// * Copyright (c) 2009 Pervasive Lab, Indiana University. All rights reserved.
+ *
+ * This software is open source. See the bottom of this file for the license.
+ *
+ * $Id: $
+ */
+
+package org.ogce.schemas.gfac.beans.utils;
+
+/**
+ * @author Ye Fan
+ */
+public class ServiceParam {
+
+ public String paramName;
+
+ public String paramValue;
+
+ public String paramDesc;
+
+ /**
+ * @return the paramName
+ */
+ public String getParamName() {
+ return paramName;
+ }
+
+ /**
+ * @param paramName
+ * the paramName to set
+ */
+ public void setParamName(String paramName) {
+ this.paramName = paramName;
+ }
+
+ /**
+ * @return the paramValue
+ */
+ public String getParamValue() {
+ return paramValue;
+ }
+
+ /**
+ * @param paramValue
+ * the paramValue to set
+ */
+ public void setParamValue(String paramValue) {
+ this.paramValue = paramValue;
+ }
+
+ public void setParamDesc(String paramDesc) {
+ this.paramDesc = paramDesc;
+ }
+
+ public String getParamDesc() {
+ return paramDesc;
+ }
+}
Added: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/beans/utils/ServiceUtils.java
URL: http://svn.apache.org/viewvc/incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/beans/utils/ServiceUtils.java?rev=1103180&view=auto
==============================================================================
--- incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/beans/utils/ServiceUtils.java (added)
+++ incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/beans/utils/ServiceUtils.java Sat May 14 18:34:50 2011
@@ -0,0 +1,287 @@
+/*
+// * Copyright (c) 2009 Pervasive Lab, Indiana University. All rights reserved.
+ *
+ * This software is open source. See the bottom of this file for the license.
+ *
+ * $Id: $
+ */
+
+package org.ogce.schemas.gfac.beans.utils;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.xmlbeans.XmlException;
+import org.ogce.schemas.gfac.beans.MethodBean;
+import org.ogce.schemas.gfac.beans.ServiceBean;
+import org.ogce.schemas.gfac.documents.ApplicationType;
+import org.ogce.schemas.gfac.documents.InputDataType;
+import org.ogce.schemas.gfac.documents.InputParameterType;
+import org.ogce.schemas.gfac.documents.MethodType;
+import org.ogce.schemas.gfac.documents.OutputDataType;
+import org.ogce.schemas.gfac.documents.OutputParameterType;
+import org.ogce.schemas.gfac.documents.PortTypeType;
+import org.ogce.schemas.gfac.documents.ServiceMapDocument;
+import org.ogce.schemas.gfac.documents.ServiceMapType;
+import org.ogce.schemas.gfac.documents.ServiceType;
+import org.ogce.schemas.gfac.documents.ApplicationType.ApplicationName;
+import org.ogce.schemas.gfac.documents.ServiceType.ServiceName;
+import org.ogce.schemas.gfac.validator.SchemaValidator;
+import org.ogce.schemas.gfac.wsdl.WSDLConstants;
+import org.ogce.schemas.gfac.wsdl.WSDLGenerator;
+
+/**
+ * @author Ye Fan
+ */
+public class ServiceUtils {
+
+ public static String simpleServiceXMLRequest(ServiceBean serviceInfo)
+ throws GFacSchemaException {
+
+ ServiceMapDocument serviceMapDocument = ServiceMapDocument.Factory
+ .newInstance();
+ ServiceMapType serviceMapType = serviceMapDocument.addNewServiceMap();
+ ServiceType serviceType = serviceMapType.addNewService();
+ serviceType.setServiceDescription(serviceInfo.getServiceDescription());
+
+ QName serviceQName;
+ if (serviceInfo.getServiceName().startsWith("{")) {
+ serviceQName = QName.valueOf(serviceInfo.getServiceName().trim());
+ } else {
+ serviceQName = new QName(serviceInfo.getObjectNamespace(),
+ serviceInfo.getServiceName().trim());
+ }
+
+ ServiceName serviceName = serviceType.getServiceName();
+ if (serviceName == null) {
+ serviceName = serviceType.addNewServiceName();
+ ;
+ }
+ serviceName.setStringValue(serviceQName.getLocalPart());
+ serviceName.setTargetNamespace(serviceInfo.getObjectNamespace());
+
+ PortTypeType pt;
+ if (serviceMapType.getPortTypeArray() != null
+ && serviceMapType.getPortTypeArray().length > 0) {
+ pt = serviceMapType.getPortTypeArray(0);
+ } else {
+ pt = serviceMapType.addNewPortType();
+ }
+
+ // ArrayList<MethodBean> operations = serviceInfo.getOperations();
+ List<MethodBean> operations = new ArrayList<MethodBean>();
+ operations.add(serviceInfo.getMethodBean());
+
+ for (int i = 0; i < operations.size(); i++) {
+ MethodBean op = (MethodBean) operations.get(i);
+
+ if (op == null) {
+ throw new GFacSchemaException("Operation can not be Null");
+ }
+
+ MethodType[] methods = pt.getMethodArray();
+ MethodType method = null;
+ if (methods != null) {
+ for (MethodType oldMethod : methods) {
+ if (op.getMethodName().equals(oldMethod.getMethodName())) {
+ method = oldMethod;
+ }
+ }
+ }
+ if (method == null) {
+ method = pt.addNewMethod();
+ }
+ method.setMethodName(op.getMethodName());
+ method.setMethodDescription(op.getMethodDescription());
+ ApplicationType appType = method.getApplication();
+ if (appType == null) {
+ appType = method.addNewApplication();
+ }
+ appType.setParamValuesOnly(true);
+ ApplicationName appNameType = appType.getApplicationName();
+ if (appNameType == null) {
+ appNameType = appType.addNewApplicationName();
+ }
+ QName appName = new QName(serviceInfo.getObjectNamespace(),
+ serviceInfo.getApplicationName());
+ appNameType.setStringValue(appName.getLocalPart());
+ appNameType.setTargetNamespace(appName.getNamespaceURI());
+ appType.setApplicationDescription(op.getMethodDescription());
+
+ // Boolean parameters from Service screen
+ if (op.isStageOutputDataFiles()) {
+ method.setStageOutputDataFiles(true);
+ }
+
+ if (op.isForceFileStagingToWorkDir()) {
+ method.setForceFileStagingToWorkDir(true);
+ }
+
+ if (op.isUseLEADNameListFile()) {
+ appType.setUseLEADNameListFile(true);
+ }
+
+ if (op.isUseLEADNameListPropertiesFile()) {
+ appType.setUseLEADNameListPropertiesFile(true);
+ }
+
+ InputParameterType[] inputs = method.getInputParameterArray();
+ HashMap<String, InputParameterType> inputMap = new HashMap<String, InputParameterType>();
+ if (inputs != null) {
+ for (InputParameterType inputParameterType : inputs) {
+ inputMap.put(inputParameterType.getParameterName(),
+ inputParameterType);
+ }
+ }
+
+ OutputParameterType[] outputs = method.getOutputParameterArray();
+ HashMap<String, OutputParameterType> outputMap = new HashMap<String, OutputParameterType>();
+ if (inputs != null) {
+ for (OutputParameterType outputParameterType : outputs) {
+ outputMap.put(outputParameterType.getParameterName(),
+ outputParameterType);
+ }
+ }
+
+ ArrayList<ParamObject> inputparams = op.getInputParms();
+ for (int y = 0; y < inputparams.size(); y++) {
+ ParamObject param = (ParamObject) inputparams.get(y);
+ InputParameterType inputParm = inputMap.get(param.getName());
+ if (inputParm == null) {
+ inputParm = method.addNewInputParameter();
+ }
+ inputParm.setParameterName(param.getName());
+ inputParm.setParameterDescription(param.getDesc());
+ InputDataType.Enum type = InputDataType.Enum.forString(param
+ .getType());
+ inputParm.setParameterType(type);
+ }
+
+ ArrayList<ParamObject> outputparams = op.getOutputParms();
+ for (int y = 0; y < outputparams.size(); y++) {
+ ParamObject param = (ParamObject) outputparams.get(y);
+ OutputParameterType outputParm = outputMap.get(param.getName());
+ if (outputParm == null) {
+ outputParm = method.addNewOutputParameter();
+ }
+ outputParm.setParameterName(param.getName());
+ outputParm.setParameterDescription(param.getDesc());
+ OutputDataType.Enum type = OutputDataType.Enum.forString(param
+ .getType());
+ outputParm.setParameterType(type);
+ }
+ }
+
+ if (serviceInfo.getNotAfterInactiveMinutes() != 0) {
+ if (serviceMapType.getLifeTime() == null) {
+ serviceMapType.addNewLifeTime().setNotAfterInactiveMinutes(
+ serviceInfo.getNotAfterInactiveMinutes());
+ } else {
+ serviceMapType.getLifeTime().setNotAfterInactiveMinutes(
+ serviceInfo.getNotAfterInactiveMinutes());
+ }
+ }
+
+ SchemaValidator validator = new SchemaValidator(serviceMapType);
+ validator.validate();
+
+ return serviceMapDocument.xmlText();
+ }
+
+ public static ServiceBean serviceBeanRequest(String serviceMapStr)
+ throws XmlException, IOException {
+
+ int notAfterInactiveMinutes = 15;
+
+ ServiceBean serviceBean = new ServiceBean();
+ ServiceMapDocument serviceMapDocument = ServiceMapDocument.Factory
+ .parse(new StringReader(serviceMapStr));
+ ServiceMapType serviceMapType = serviceMapDocument.getServiceMap();
+ ServiceType serviceType = serviceMapType.getService();
+ serviceBean.setServiceDescription(serviceType.getServiceDescription());
+
+ if (serviceMapType.getLifeTime() != null) {
+ notAfterInactiveMinutes = serviceMapType.getLifeTime()
+ .getNotAfterInactiveMinutes();
+ }
+ MethodType method = findOperationWithApplication(serviceMapType);
+ ApplicationType appType = method.getApplication();
+ ApplicationName appxbeanName = method.getApplication()
+ .getApplicationName();
+ String appName = new QName(appxbeanName.getTargetNamespace(),
+ appxbeanName.getStringValue()).toString();
+ MethodBean methodBean = new MethodBean(method.getMethodName(), method
+ .getMethodDescription(), method.isSetStageOutputDataFiles(),
+ method.isSetForceFileStagingToWorkDir(), appType
+ .isSetUseLEADNameListFile(), appType
+ .isSetUseLEADNameListPropertiesFile());
+
+ InputParameterType[] inputparams = method.getInputParameterArray();
+ for (int index = 0; index < inputparams.length; index++) {
+
+ InputParameterType inputParameterType = inputparams[index];
+ methodBean.addInputParms(new ParamObject(inputParameterType
+ .getParameterName(), inputParameterType.getParameterType()
+ .toString(), index, inputParameterType
+ .getParameterDescription()));
+
+ }
+
+ OutputParameterType[] outparams = method.getOutputParameterArray();
+ for (int index = 0; index < outparams.length; index++) {
+
+ OutputParameterType outputParameterType = outparams[index];
+ methodBean.addOutputParms(new ParamObject(outputParameterType
+ .getParameterName(), outputParameterType.getParameterType()
+ .toString(), index, outputParameterType
+ .getParameterDescription()));
+
+ }
+
+ serviceBean.setApplicationName(appName);
+ serviceBean.setServiceName(serviceMapType.getService().getServiceName()
+ .getStringValue());
+ serviceBean.setApplicationName(appxbeanName.getStringValue());
+ serviceBean.setNotAfterInactiveMinutes(notAfterInactiveMinutes);
+ serviceBean.setMethodBean(methodBean);
+ serviceBean.setObjectNamespace(serviceMapType.getService()
+ .getServiceName().getTargetNamespace());
+
+ return serviceBean;
+ }
+
+ public static String createAwsdl4ServiceMap(String serviceMapAsStr) throws GFacSchemaException {
+ try {
+ ServiceMapType serviceMap = ServiceMapDocument.Factory.parse(serviceMapAsStr)
+ .getServiceMap();
+
+ QName serviceQname = new QName(serviceMap.getService().getServiceName()
+ .getTargetNamespace(), serviceMap.getService().getServiceName().getStringValue());
+ WSDLGenerator wsdlGenerator = new WSDLGenerator();
+ Hashtable serviceTable = wsdlGenerator.generateWSDL(null, serviceQname, null, serviceMap,
+ true);
+ String wsdl = (String) serviceTable.get(WSDLConstants.AWSDL);
+ return wsdl;
+ } catch (XmlException e) {
+ throw new GFacSchemaException(e);
+ }
+ }
+
+ private static MethodType findOperationWithApplication(
+ ServiceMapType serviceMap) {
+ MethodType[] methods = serviceMap.getPortTypeArray()[0]
+ .getMethodArray();
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getApplication() != null) {
+ return methods[i];
+ }
+ }
+ return null;
+ }
+}
Added: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/beans/utils/XmlFormatter.java
URL: http://svn.apache.org/viewvc/incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/beans/utils/XmlFormatter.java?rev=1103180&view=auto
==============================================================================
--- incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/beans/utils/XmlFormatter.java (added)
+++ incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/beans/utils/XmlFormatter.java Sat May 14 18:34:50 2011
@@ -0,0 +1,54 @@
+package org.ogce.schemas.gfac.beans.utils;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.xml.serialize.OutputFormat;
+import org.apache.xml.serialize.XMLSerializer;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class XmlFormatter {
+
+ /**
+ * @param unformattedXml
+ * @return formattedXml
+ */
+ public static String format(String unformattedXml) {
+ try {
+ final Document document = parseXmlFile(unformattedXml);
+ OutputFormat format = new OutputFormat(document);
+ format.setLineWidth(65);
+ format.setIndenting(true);
+ format.setIndent(2);
+ Writer out = new StringWriter();
+ XMLSerializer serializer = new XMLSerializer(out, format);
+ serializer.serialize(document);
+ return out.toString();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static Document parseXmlFile(String in) {
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ InputSource is = new InputSource(new StringReader(in));
+ return db.parse(is);
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException(e);
+ } catch (SAXException e) {
+ throw new RuntimeException(e);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
\ No newline at end of file
Added: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/test/ApplicationTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/test/ApplicationTest.java?rev=1103180&view=auto
==============================================================================
--- incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/test/ApplicationTest.java (added)
+++ incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/test/ApplicationTest.java Sat May 14 18:34:50 2011
@@ -0,0 +1,50 @@
+package org.ogce.schemas.gfac.test;
+
+import org.apache.xmlbeans.XmlException;
+import org.ogce.schemas.gfac.beans.ApplicationBean;
+import org.ogce.schemas.gfac.beans.utils.ApplicationUtils;
+import org.ogce.schemas.gfac.beans.utils.XmlFormatter;
+
+import junit.framework.TestCase;
+
+public class ApplicationTest extends TestCase{
+ private ApplicationBean appBean = new ApplicationBean();
+ private String appDesc;
+
+ @Override
+ public void setUp() {
+ appBean.setApplicationName("GfacSchemaAppTest");
+ appBean.setHostName("test.test.test.test");
+ appBean.setExecutable("/bin/exec");
+ appBean.setWorkDir("/workspace");
+ appBean.setTmpDir("/tmp");
+ appBean.setJobType("single");
+ appBean.setQueue("debug");
+ appBean.setMaxWallTime(new Integer(1000));
+ appBean.setPcount(new Integer(4));
+ appBean.setProjectName("IUNCSA0000123");
+ appBean.setLeadNameListFile("LeadFile");
+ }
+
+ public void testApplicationUtilsXMLRequest() {
+ System.out.println(XmlFormatter.format(ApplicationUtils.simpleAppXMLRequest(appBean)));
+ }
+
+ public void testApplicationUtilsBeanRequest() throws XmlException {
+ /* Get XMLString by ApplicationBean */
+ appDesc = XmlFormatter.format(ApplicationUtils.simpleAppXMLRequest(appBean));
+
+ /* Generate new ApplicationBean by XMLString */
+ ApplicationBean bean = ApplicationUtils.simpleApplicationBeanRequest(appDesc);
+ appDesc = appDesc.replaceAll(" ", "");
+ appDesc = appDesc.replaceAll("\n", "");
+
+ /* Get new XMLString by new ApplicationBean */
+ String appDescToCompare = XmlFormatter.format(ApplicationUtils.simpleAppXMLRequest(bean));
+ appDescToCompare = appDescToCompare.replaceAll(" ", "");
+ appDescToCompare = appDescToCompare.replaceAll("\n", "");
+
+ /* Old XMLString should be identical to new XMLString */
+ assertEquals(appDesc.equals(appDescToCompare), true);
+ }
+}
Added: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/test/HostTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/test/HostTest.java?rev=1103180&view=auto
==============================================================================
--- incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/test/HostTest.java (added)
+++ incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/test/HostTest.java Sat May 14 18:34:50 2011
@@ -0,0 +1,48 @@
+package org.ogce.schemas.gfac.test;
+
+import org.apache.xmlbeans.XmlException;
+import org.ogce.schemas.gfac.beans.HostBean;
+import org.ogce.schemas.gfac.beans.utils.GFacSchemaException;
+import org.ogce.schemas.gfac.beans.utils.HostUtils;
+import org.ogce.schemas.gfac.beans.utils.XmlFormatter;
+
+import junit.framework.TestCase;
+
+public class HostTest extends TestCase {
+ private HostBean hostBean = new HostBean();
+ private String hostDesc;
+
+ @Override
+ public void setUp() {
+ hostBean.setHostName("bigred.teragrid.iu.edu");
+ hostBean.setTmpDir("/N/dc/projects/lead/scratch/pub-workdirs/");
+ hostBean.setGateKeeperendPointReference("https://gatekeeper.bigred.iu.teragrid.org:8443/wsrf/services/ManagedJobFactoryService");
+ hostBean.setJdkName("jdk1.5");
+ hostBean.setWsGram(true);
+ hostBean.setGateKeeperJobManager("Loadleveler");
+ hostBean.setGridFtpendPointReference("gridftp1.bigred.teragrid.iu.edu:2812");
+ }
+
+ public void testHostUtilsXMLRequest() throws GFacSchemaException {
+ hostDesc = XmlFormatter.format(HostUtils.simpleHostXMLRequest(hostBean));
+ System.out.println(hostDesc);
+ }
+
+ public void testHostHostUtilsBeanRequest() throws XmlException, GFacSchemaException {
+ /* Get XMLString by HostBean */
+ hostDesc = XmlFormatter.format(HostUtils.simpleHostXMLRequest(hostBean));
+
+ /* Generate new HostBean by XMLString */
+ HostBean bean = HostUtils.simpleHostBeanRequest(hostDesc);
+ hostDesc = hostDesc.replaceAll(" ", "");
+ hostDesc = hostDesc.replaceAll("\n", "");
+
+ /* Get new XMLString by new HostBean */
+ String hostDescToCompare = XmlFormatter.format(HostUtils.simpleHostXMLRequest(bean));
+ hostDescToCompare = hostDescToCompare.replaceAll(" ", "");
+ hostDescToCompare = hostDescToCompare.replaceAll("\n", "");
+
+ /* Old XMLString should be identical to new XMLString */
+ assertEquals(hostDesc.equals(hostDescToCompare), true);
+ }
+}
Added: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/test/ServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/test/ServiceTest.java?rev=1103180&view=auto
==============================================================================
--- incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/test/ServiceTest.java (added)
+++ incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/test/ServiceTest.java Sat May 14 18:34:50 2011
@@ -0,0 +1,56 @@
+package org.ogce.schemas.gfac.test;
+
+import java.io.IOException;
+
+import org.apache.xmlbeans.XmlException;
+import org.ogce.schemas.gfac.beans.MethodBean;
+import org.ogce.schemas.gfac.beans.ServiceBean;
+import org.ogce.schemas.gfac.beans.utils.GFacSchemaException;
+import org.ogce.schemas.gfac.beans.utils.ParamObject;
+import org.ogce.schemas.gfac.beans.utils.ServiceUtils;
+import org.ogce.schemas.gfac.beans.utils.XmlFormatter;
+
+import junit.framework.TestCase;
+
+public class ServiceTest extends TestCase {
+ private ServiceBean serviceBean = new ServiceBean();
+ private String serviceMapStr;
+
+ @Override
+ public void setUp() {
+ serviceBean.setServiceName("GfacSchemaServiceTest");
+ serviceBean.setApplicationName("GfacSchemaAppTest");
+ serviceBean.setServiceDescription("This is for service xml test");
+
+ MethodBean methodBean = new MethodBean();
+ methodBean.setMethodName("GfacSchemaMethodTest");
+ methodBean.setMethodDescription("This is for method xml test");
+ methodBean.addInputParms(new ParamObject("count", "Integer", 0, "number"));
+ methodBean.addInputParms(new ParamObject("name", "String", 1, "name"));
+ methodBean.addOutputParms(new ParamObject("weight", "Float", 0, "desired weight"));
+ serviceBean.setMethodBean(methodBean);
+ serviceBean.setNotAfterInactiveMinutes(15);
+ }
+
+ public void testServiceUtilsXMLRequest() throws GFacSchemaException {
+ System.out.println(XmlFormatter.format(ServiceUtils.simpleServiceXMLRequest(serviceBean)));
+ }
+
+ public void testServiceUtilsBeanRequest() throws GFacSchemaException, XmlException, IOException {
+ /* Get XMLString by ServiceBean */
+ serviceMapStr = XmlFormatter.format(ServiceUtils.simpleServiceXMLRequest(serviceBean));
+
+ /* Generate new ServiceBean by XMLString */
+ ServiceBean bean = ServiceUtils.serviceBeanRequest(serviceMapStr);
+ serviceMapStr = serviceMapStr.replaceAll(" ", "");
+ serviceMapStr = serviceMapStr.replaceAll("\n", "");
+
+ /* Get new XMLString by new ServiceBean */
+ String serviceMapStrToCompare = XmlFormatter.format(ServiceUtils.simpleServiceXMLRequest(bean));
+ serviceMapStrToCompare = serviceMapStrToCompare.replaceAll(" ", "");
+ serviceMapStrToCompare = serviceMapStrToCompare.replaceAll("\n", "");
+
+ /* Old XMLString should be identical to new XMLString */
+ assertEquals(serviceMapStr.equals(serviceMapStrToCompare), true);
+ }
+}
Added: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/utils/GFacConstants.java
URL: http://svn.apache.org/viewvc/incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/utils/GFacConstants.java?rev=1103180&view=auto
==============================================================================
--- incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/utils/GFacConstants.java (added)
+++ incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/utils/GFacConstants.java Sat May 14 18:34:50 2011
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2009 Pervasive Lab, Indiana University. All rights reserved.
+ *
+ * This software is open source. See the bottom of this file for the license.
+ *
+ * $Id: $
+ */
+
+package org.ogce.schemas.gfac.utils;
+
+/**
+ * @author Ye Fan
+ */
+public class GFacConstants {
+
+ public static final String SHUTDOWN = "Shutdown";
+
+ public static final String PING = "Ping";
+
+ public static final String KILL = "Kill";
+
+ public static final String ARRAY_VALUE = "value";
+
+ public static final String _127_0_0_1 = "127.0.0.1";
+
+ public static final String BROKER_URL = "http://tyr14.cs.indiana.edu:12346/";
+
+ public static final String CAPMAN_URL = "http://linbox3.extreme.indiana.edu:3579/capman";
+
+ public static final String GFAC_NAMESPACE = "http://www.extreme.indiana.edu/namespaces/2004/01/gFac";
+
+ public static final String CREATE_SERVICE = "CreateService";
+
+ public static final String LEAD_HEADER_NAMESPACE = "http://lead.extreme.indiana.edu/namespaces/2005/10/lead-context-header";
+
+ public static final String TRANSPORT_LEVEL = "TransportLevel";
+
+ public static final String MESSAGE_SIGNATURE = "MessageSignature";
+
+ // Specific to application service
+ public static final String SERVICE_URI = "SERVICE_URI";
+
+ public static final String METHOD_NAME = "METHOD_NAME";
+
+ public static final String SERVICE_NAME = "SERVICE_NAME";
+
+ public static final String APP_SERVICE_STRING_PARAM = "AFAC_STRING_PARAM";
+
+ public static final String SERVICE_RESP_MSG_SUFFIX = "_ResponseMessage";
+
+ public static final String SERVICE_INPUT_PARAMS_TYPE_SUFFIX = "_InputParamsType";
+
+ public static final String SERVICE_OUTPUT_PARAMS_TYPE_SUFFIX = "_OutputParamsType";
+
+ public static final String SERVICE_REQ_MSG_SUFFIX = "_RequestMessage";
+
+ public static final String SERVICE_IN_PARAMS_SUFFIX = "_InputParams";
+
+ public static final String SERVICE_OUT_PARAMS_SUFFIX = "_OutputParams";
+
+ public static final String SERVICE_TMP_DIR = "AFAC_TMP_DIR";
+
+ public static final String SERVICE_INPUT_MESSAGE_NAME = "AFAC_INPUT_MESSAGE_NAME";
+
+ // Misc constants
+ public static final int GSI_FTP_PORT = 2811;
+
+ public static final String HOST = "host";
+
+ public static final String UTF8 = "UTF-8";
+
+ public static final String ADMIN_TOPIC = "ADMIN";
+
+ public static final String LOCALHOST = "localhost";
+
+ public static class Types {
+ public static final String TYPE_STRING = "String";
+
+ public static final String TYPE_INT = "Integer";
+
+ public static final String TYPE_FLOAT = "Float";
+
+ public static final String TYPE_DOUBLE = "Double";
+
+ public static final String TYPE_BOOLEAN = "Boolean";
+
+ public static final String TYPE_QNAME = "QName";
+
+ public static final String TYPE_URI = "URI";
+
+ public static final String TYPE_STRING_ARRAY = "StringArray";
+
+ public static final String TYPE_INT_ARRAY = "IntegerArray";
+
+ public static final String TYPE_FLAOT_ARRAY = "FloatArray";
+
+ public static final String TYPE_DOUBLE_ARRAY = "DoubleArray";
+
+ public static final String TYPE_BOOLEAN_ARRAY = "BooleanArray";
+
+ public static final String TYPE_QNAME_ARRAY = "QNameArray";
+
+ public static final String TYPE_URI_ARRAY = "URIArray";
+
+ public static final String TYPE_LEADFILEID = "LEADFileID";
+
+ public static final String TYPE_LEADFILEID_ARRAY = "LEADFileIDArray";
+
+ public static final String TYPE_STDOUT = "StdOut";
+
+ public static final String TYPE_STDERRORs = "StdErr";
+
+ public static final String LEAD_NAMELIST_FILE = "LEADNameListFile";
+
+ public static final String LEAD_NAMELIST_PROPERTIES_FILE = "LEADNameListPropertiesFile";
+
+ public static final String LEAD_CROSSCUT_PARAMETERS = "LeadCrosscutParameters";
+
+ public static final String TYPE_DATAID = "DataID";
+
+ public static final String TYPE_DATAID_ARRAY = "DataIDArray";
+
+ }
+
+ public static final String LOGGER_NAME = "gfac-schema-utils.logger";
+
+ public static interface InbuitOperations {
+ public static final String OP_KILL = "Kill";
+
+ public static final String OP_PING = "Ping";
+
+ public static final String OP_SHUTDOWN = "Shutdown";
+ }
+
+}
Added: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/utils/GfacUtils.java
URL: http://svn.apache.org/viewvc/incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/utils/GfacUtils.java?rev=1103180&view=auto
==============================================================================
--- incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/utils/GfacUtils.java (added)
+++ incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/utils/GfacUtils.java Sat May 14 18:34:50 2011
@@ -0,0 +1,499 @@
+package org.ogce.schemas.gfac.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.net.InetAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Random;
+import java.util.UUID;
+import java.util.Vector;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.xmlbeans.XmlException;
+
+import org.ietf.jgss.GSSCredential;
+import org.ogce.schemas.gfac.beans.utils.GFacSchemaException;
+import org.ogce.schemas.gfac.documents.ApplicationDescriptionDocument;
+import org.ogce.schemas.gfac.documents.ApplicationDescriptionType;
+import org.ogce.schemas.gfac.documents.HostDescriptionDocument;
+import org.ogce.schemas.gfac.documents.HostDescriptionType;
+import org.ogce.schemas.gfac.documents.MethodType;
+import org.ogce.schemas.gfac.documents.PortTypeType;
+import org.ogce.schemas.gfac.documents.ServiceMapType;
+import org.ogce.schemas.gfac.documents.ServiceType.ServiceName;
+import org.ogce.schemas.gfac.validator.SchemaValidator;
+import org.ogce.schemas.gfac.wsdl.MessageContext;
+import org.xmlpull.mxp1_serializer.MXSerializer;
+import org.xmlpull.v1.builder.Iterable;
+import org.xmlpull.v1.builder.XmlBuilderException;
+import org.xmlpull.v1.builder.XmlDocument;
+import org.xmlpull.v1.builder.XmlElement;
+import org.xmlpull.v1.builder.XmlInfosetBuilder;
+
+import xsul.XmlConstants;
+import xsul.invoker.http.HttpDynamicInfosetInvoker;
+import xsul.lead.LeadContextHeader;
+import xsul.soap.SoapUtil;
+import xsul.ws_addressing.WsaInvoker;
+import xsul.ws_addressing.WsaMessageInformationHeaders;
+import xsul.ws_addressing.WsaRelatesTo;
+import xsul.wsif.impl.WSIFMessageElement;
+
+public class GfacUtils {
+
+ private final static String PROPERTY_SERIALIZER_INDENTATION = "http://xmlpull.org/v1/doc/properties.html#serializer-indentation";
+
+ private final static String INDENT = " ";
+ private static AtomicInteger tempFileCount = new AtomicInteger();
+
+ private static Random random = new Random();
+
+
+ public static void writeToFile(InputStream is, File file) throws IOException {
+ FileWriter fw = new FileWriter(file);
+
+ // get the standard out of the application and write to file
+
+ Reader reader = new InputStreamReader(is);
+ char[] cbuf = new char[1024];
+ while ((reader.read(cbuf, 0, 1024)) != -1) {
+ fw.write(cbuf);
+ }
+ fw.close();
+ reader.close();
+ is.close();
+ }
+
+ public static void writeToFile(String data, File file) throws IOException {
+ FileWriter fw = new FileWriter(file);
+
+ // get the standard out of the application and write to file
+ fw.write(data);
+ fw.close();
+ }
+
+ public static String readFromStream(InputStream in) throws IOException {
+ StringBuffer wsdlStr = new StringBuffer();
+
+ int read;
+
+ byte[] buf = new byte[1024];
+ while ((read = in.read(buf)) > 0) {
+ wsdlStr.append(new String(buf, 0, read));
+ }
+ in.close();
+ return wsdlStr.toString();
+ }
+
+
+ public static HostDescriptionType parseHostDescirption(String hostDescStr) throws GFacSchemaException {
+ try {
+ HostDescriptionType hostDesc = HostDescriptionDocument.Factory.parse(hostDescStr)
+ .getHostDescription();
+ SchemaValidator validator = new SchemaValidator(hostDesc);
+ validator.validate();
+ return hostDesc;
+ } catch (XmlException e) {
+ throw new GFacSchemaException(e);
+ } catch (Exception e) {
+ throw new GFacSchemaException(e);
+ }
+ }
+
+ public static ApplicationDescriptionType parseAppDescirption(Reader reader)
+ throws GFacSchemaException {
+ try {
+ ApplicationDescriptionType appDesc = ApplicationDescriptionDocument.Factory.parse(
+ reader).getApplicationDescription();
+ SchemaValidator validator = new SchemaValidator(appDesc);
+ validator.validate();
+ return appDesc;
+ } catch (XmlException e) {
+ throw new GFacSchemaException(e);
+ } catch (IOException e) {
+ throw new GFacSchemaException(e);
+ } catch (Exception e) {
+ throw new GFacSchemaException(e);
+ }
+ }
+
+ public static MethodType findOperationFromServiceMap(String operationName,
+ ServiceMapType serviceMap) throws GFacSchemaException {
+ PortTypeType portType = serviceMap.getPortTypeArray()[0];
+ MethodType[] methods = portType.getMethodArray();
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getMethodName().equals(operationName)) {
+ return methods[i];
+ }
+ }
+
+ if (isInbuiltOperation(operationName)) {
+ MethodType method = portType.addNewMethod();
+ method.setMethodName(operationName);
+ return method;
+ }
+
+ throw new GFacSchemaException("Method name " + operationName + " not found");
+ }
+
+ public static MethodType findOperationWithApplication(ServiceMapType serviceMap)
+ throws GFacSchemaException {
+ MethodType[] methods = serviceMap.getPortTypeArray()[0].getMethodArray();
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getApplication() != null) {
+ return methods[i];
+ }
+ }
+ return null;
+ }
+
+ public static boolean isLocalHost(String appHost) throws GFacSchemaException {
+ try {
+ String localHost = InetAddress.getLocalHost().getCanonicalHostName();
+
+ if (localHost.equals(appHost) || GFacConstants.LOCALHOST.equals(appHost)
+ || GFacConstants._127_0_0_1.equals(appHost)) {
+ return true;
+ } else {
+ return false;
+ }
+ } catch (UnknownHostException e) {
+ throw new GFacSchemaException(e);
+ }
+ }
+
+ public static boolean isArray(String typeName) {
+ // <simpleType name="outputDataType">
+ // <restriction base="xsd:string">
+ // <enumeration value="String"/>
+ // <enumeration value="Integer"/>
+ // <enumeration value="Float"/>
+ // <enumeration value="Double"/>
+ // <enumeration value="Boolean"/>
+ // <enumeration value="QName"/>
+ // <enumeration value="URI"/>
+ // <enumeration value="StringArray"/>
+ // <enumeration value="IntegerArray"/>
+ // <enumeration value="FloatArray"/>
+ // <enumeration value="DoubleArray"/>
+ // <enumeration value="BooleanArray"/>
+ // <enumeration value="QNameArray"/>
+ // <enumeration value="URIArray"/>
+ // <enumeration value="LEADFileID"/>
+ // <enumeration value="LEADFileIDArray"/>
+ // <enumeration value="StdOut"/>
+ // <enumeration value="StdErr"/>
+ // </restriction>
+ // </simpleType>
+ if (typeName.endsWith("Array")) {
+ // TODO make it more tigter
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * This method perpare the arguments to be passed to the invocation
+ *
+ * @param inputMessage
+ * @param parmsValuesOnly,
+ * this is usually true. If it is false, the parameters are
+ * passed as Name value pairs. If the parameter name is foo and
+ * it is a array type parameters will be passed as foo0,foo1 ....
+ * @return
+ * @throws GFacSchemaException
+ */
+ public static ArrayList<String> prepareParameters(MessageContext inputMessage,
+ boolean parmsValuesOnly) throws GFacSchemaException {
+ try {
+ ArrayList<String> params = new ArrayList<String>();
+ Iterator<String> names = inputMessage.getParameterNames();
+ while (names.hasNext()) {
+ String name = names.next();
+ String type = inputMessage.getParameterType(name);
+
+ if (GFacConstants.Types.TYPE_DATAID.equals(type)) {
+ // add parameter name if needed
+ if (!parmsValuesOnly) {
+ params.add(name);
+ }
+ params.add(new URI(inputMessage.getStringParameterValue(name)).getPath());
+ } else if (GFacConstants.Types.TYPE_DATAID_ARRAY.equals(type)) {
+ Object value = inputMessage.getParameterValue(name);
+ if (value instanceof Object[]) {
+ Object[] valueArray = (Object[]) value;
+ for (int j = 0; j < valueArray.length; j++) {
+ // add parameter name if needed
+ if (!parmsValuesOnly) {
+ params.add(name + j);
+ }
+ params.add(new URI(valueArray[j].toString()).getPath());
+ }
+ }
+ } else if (GFacConstants.Types.TYPE_LEADFILEID.equals(type)
+ || GFacConstants.Types.TYPE_URI.equals(type)) {
+ // add parameter name if needed
+ if (!parmsValuesOnly) {
+ params.add(name);
+ }
+ params.add(new URI(inputMessage.getStringParameterValue(name)).getPath());
+ } else if (GFacConstants.Types.TYPE_LEADFILEID_ARRAY.equals(type)
+ || GFacConstants.Types.TYPE_URI_ARRAY.equals(type)) {
+ Object value = inputMessage.getParameterValue(name);
+ if (value instanceof Object[]) {
+ Object[] valueArray = (Object[]) value;
+ for (int j = 0; j < valueArray.length; j++) {
+ // add parameter name if needed
+ if (!parmsValuesOnly) {
+ params.add(name + j);
+ }
+ params.add(new URI(valueArray[j].toString()).getPath());
+ }
+ }
+ } else {
+ if (GfacUtils.isArray(type)) {
+ Object value = inputMessage.getParameterValue(name);
+ if (value instanceof Object[]) {
+ Object[] valueArray = (Object[]) value;
+ for (int j = 0; j < valueArray.length; j++) {
+ // add parameter name if needed
+ if (!parmsValuesOnly) {
+ params.add(name + j);
+ }
+ params.add(valueArray[j].toString());
+ }
+ }
+ } else {
+ if (!parmsValuesOnly) {
+ params.add(name);
+ }
+ params.add(inputMessage.getStringParameterValue(name));
+ }
+
+ // add parameter name if needed
+ }
+ }
+ return params;
+ } catch (URISyntaxException e) {
+ throw new GFacSchemaException(e);
+ }
+ }
+
+ public static boolean isInbuiltOperation(String name) {
+ return GFacConstants.InbuitOperations.OP_KILL.equals(name)
+ || GFacConstants.InbuitOperations.OP_PING.equals(name)
+ || GFacConstants.InbuitOperations.OP_SHUTDOWN.equals(name);
+ }
+
+ public static String findStringValue(String name, WSIFMessageElement response) {
+ return (String) response.getObjectPart(name);
+ }
+
+ public static ArrayList<String> findArrayValue(String name, WSIFMessageElement response) {
+ XmlElement param = response.element(null, name);
+ if (param != null) {
+ Iterable it = param.elements(null, "value");
+ if (it != null) {
+ ArrayList<String> values = new ArrayList<String>();
+
+ Iterator arrayValues = it.iterator();
+ while (arrayValues.hasNext()) {
+ values.add(((XmlElement) arrayValues.next()).requiredTextContent());
+ }
+ return values;
+ }
+ }
+ return null;
+ }
+
+ public static void printArray(ArrayList<String> list) {
+ for (Iterator iter = list.iterator(); iter.hasNext();) {
+ System.out.println(iter.next());
+ }
+ }
+
+ public static String createServiceDirName(QName serviceName) {
+ String date = new Date().toString();
+ date = date.replaceAll(" ", "_");
+ date = date.replaceAll(":", "_");
+ return serviceName.getLocalPart() + "_" + date + "_" + UUID.randomUUID();
+ }
+
+ public static String createErrorMessage(Exception e) {
+ StringWriter errStrW = new StringWriter();
+ e.printStackTrace(new PrintWriter(errStrW));
+ return errStrW.getBuffer().toString();
+ }
+
+ public static String prettyPrint2String(XmlElement ele) {
+ try {
+ MXSerializer serializer = new MXSerializer();
+ StringWriter writer = new StringWriter();
+ serializer.setOutput(writer);
+ serializer.setProperty(PROPERTY_SERIALIZER_INDENTATION, INDENT);
+ XmlConstants.BUILDER.serialize(ele, serializer);
+ return writer.toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return "Error happend pretty printing";
+ }
+ }
+
+ public static void prettyPrint(XmlElement ele) throws GFacSchemaException {
+ try {
+
+ System.out.println(prettyPrint2String(ele));
+
+ } catch (IllegalArgumentException e) {
+ throw new GFacSchemaException(e);
+ } catch (IllegalStateException e) {
+ throw new GFacSchemaException(e);
+ } catch (XmlBuilderException e) {
+ throw new GFacSchemaException(e);
+ }
+ }
+
+ public static URI createGsiftpURI(String host, String localPath) throws GFacSchemaException {
+ try {
+ StringBuffer buf = new StringBuffer();
+ buf.append("gsiftp://").append(host).append("/").append(localPath);
+ return new URI(buf.toString());
+ } catch (URISyntaxException e) {
+ throw new GFacSchemaException(e);
+ }
+ }
+
+ public static Vector<URI> listLocalDir(String dirName, String localhost) throws GFacSchemaException {
+ try {
+ Vector<URI> files = new Vector<URI>();
+ File dir = new File(dirName);
+
+ if (dir.exists()) {
+ File[] fileList = dir.listFiles();
+ for (File file : fileList) {
+ if (!file.getName().equals(".") && !file.getName().equals("..")) {
+ URI uri = new URI("gsiftp://" + localhost + "/" + file.getAbsolutePath());
+ files.add(uri);
+ }
+ }
+ } else {
+ throw new GFacSchemaException("can not find the output data directory to list files");
+ }
+ return files;
+ } catch (URISyntaxException e) {
+ throw new GFacSchemaException(e);
+ }
+ }
+
+ public static QName getServiceNameFromServiceMap(ServiceMapType serviceMap) {
+ ServiceName serviceName = serviceMap.getService().getServiceName();
+ return new QName(serviceName.getTargetNamespace(), serviceName.getStringValue());
+ }
+
+
+
+ public static URI createWorkflowQName(QName name) throws GFacSchemaException {
+ try {
+ return new URI("urn:qname:" + name.getNamespaceURI() + ":" + name.getLocalPart());
+ } catch (URISyntaxException e) {
+ throw new GFacSchemaException(e);
+ }
+ }
+
+ public static String findStrProperty(Properties config, String name, String defaultVal) {
+ String value = config.getProperty(name);
+ if (value == null) {
+ return defaultVal;
+ }
+ return value.trim();
+ }
+
+ public static boolean findBooleanProperty(Properties config, String name, boolean defaultVal) {
+ String value = config.getProperty(name);
+ if (value == null) {
+ return defaultVal;
+ }
+ return Boolean.valueOf(value.trim());
+ }
+
+
+ private static XmlInfosetBuilder builder = XmlConstants.BUILDER;;
+
+ public static String buildAnnotations(QName name, String value) {
+ XmlElement anno = builder.newFragment(name.getNamespaceURI(), name.getLocalPart());
+ anno.addChild(value);
+ return builder.serializeToString(anno);
+ }
+
+ public static QName findApplcationName(ServiceMapType serviceMap) throws GFacSchemaException{
+ MethodType method = GfacUtils.findOperationWithApplication(serviceMap);
+
+ if (method == null) {
+ throw new GFacSchemaException("None of the methods has application defined");
+ }
+
+ String applicationName = method.getApplication().getApplicationName().getStringValue();
+ String applicationNameNs = method.getApplication().getApplicationName()
+ .getTargetNamespace();
+ return new QName(applicationNameNs, applicationName);
+ }
+
+ public static String formatJobStatus(String jobid,String jobstatus){
+ return "Status of job " + jobid + "is " + jobstatus ;
+ }
+
+ public static String findServiceRegistryUrl(LeadContextHeader header){
+ if(header == null){
+ return null;
+ }else{
+ URI serviceRegistryUrl = header.getXRegistryUrl();
+ if(serviceRegistryUrl == null){
+ serviceRegistryUrl = header.getResourceCatalogUrl();
+ }
+ if(serviceRegistryUrl != null){
+ return serviceRegistryUrl.toString();
+ }else{
+ return null;
+ }
+ }
+ }
+
+
+ public static String createRandomName(String name){
+ return name + System.currentTimeMillis() + "_" + tempFileCount.incrementAndGet();
+ }
+
+ public static Throwable getRootCause(Throwable e){
+ Throwable cause = e.getCause();
+ while(cause != null && cause.getCause() != null){
+ cause = cause.getCause();
+ }
+ if(cause == null){
+ return e;
+ }else{
+ return cause;
+ }
+ }
+
+ public static Random getRandom(){
+ return random;
+ }
+}
Propchange: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/utils/GfacUtils.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/utils/ParameterFilter.java
URL: http://svn.apache.org/viewvc/incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/utils/ParameterFilter.java?rev=1103180&view=auto
==============================================================================
--- incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/utils/ParameterFilter.java (added)
+++ incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/utils/ParameterFilter.java Sat May 14 18:34:50 2011
@@ -0,0 +1,10 @@
+package org.ogce.schemas.gfac.utils;
+
+import org.ogce.schemas.gfac.beans.utils.GFacSchemaException;
+
+
+public interface ParameterFilter {
+ public boolean filter(String paramName,String paramType) throws GFacSchemaException;
+}
+
+
Propchange: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/utils/ParameterFilter.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/AppDescValidator.java
URL: http://svn.apache.org/viewvc/incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/AppDescValidator.java?rev=1103180&view=auto
==============================================================================
--- incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/AppDescValidator.java (added)
+++ incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/AppDescValidator.java Sat May 14 18:34:50 2011
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2002-2004 Extreme! Lab, Indiana University. All rights reserved.
+ *
+ * This software is open source. See the bottom of this file for the licence.
+ *
+ * $Id: AppDescValidator.java,v 1.1.2.1 2006/05/30 01:43:24 gkandasw Exp $
+ */
+
+
+/**
+ * @version $Revision: 1.1.2.1 $
+ * @author Gopi Kandaswamy [mailto:gkandasw@cs.indiana.edu]
+ */
+
+package org.ogce.schemas.gfac.validator;
+
+import org.ogce.schemas.gfac.beans.utils.GFacSchemaException;
+import org.ogce.schemas.gfac.documents.ApplicationDescriptionType;
+import org.ogce.schemas.gfac.documents.DeploymentDescriptionType;
+
+public class AppDescValidator
+{
+ public void validateApplicationDescription(ApplicationDescriptionType appDesc) throws GFacSchemaException
+ {
+ if(appDesc.getApplicationName() == null)
+ {
+ throw new GFacSchemaException("Every application must have a name");
+ }
+
+ if(appDesc.getApplicationName().getTargetNamespace() == null)
+ {
+ throw new GFacSchemaException("Every application must have a target namespace");
+ }
+
+ if(appDesc.getDeploymentDescription() == null)
+ {
+ throw new GFacSchemaException("Every application must have a deployment description");
+ }
+
+ DeploymentDescriptionType deployDesc = appDesc.getDeploymentDescription();
+
+ if(deployDesc.getHostName() == null)
+ {
+ throw new GFacSchemaException("You must specify a host name in the application description document");
+ }
+
+ if(deployDesc.getExecutable() == null)
+ {
+ throw new GFacSchemaException("You must specify the path to the application/executable");
+ }
+ }
+}
+
+
+/*
+ * Indiana University Extreme! Lab Software License, Version 1.2
+ *
+ * Copyright (C) 2002 The Trustees of Indiana University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1) All redistributions of source code must retain the above
+ * copyright notice, the list of authors in the original source
+ * code, this list of conditions and the disclaimer listed in this
+ * license;
+ *
+ * 2) All redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the disclaimer
+ * listed in this license in the documentation and/or other
+ * materials provided with the distribution;
+ *
+ * 3) Any documentation included with all redistributions must include
+ * the following acknowledgement:
+ *
+ * "This product includes software developed by the Indiana
+ * University Extreme! Lab. For further information please visit
+ * http://www.extreme.indiana.edu/"
+ *
+ * Alternatively, this acknowledgment may appear in the software
+ * itself, and wherever such third-party acknowledgments normally
+ * appear.
+ *
+ * 4) The name "Indiana Univeristy" or "Indiana Univeristy
+ * Extreme! Lab" shall not be used to endorse or promote
+ * products derived from this software without prior written
+ * permission from Indiana University. For written permission,
+ * please contact http://www.extreme.indiana.edu/.
+ *
+ * 5) Products derived from this software may not use "Indiana
+ * Univeristy" name nor may "Indiana Univeristy" appear in their name,
+ * without prior written permission of the Indiana University.
+ *
+ * Indiana University provides no reassurances that the source code
+ * provided does not infringe the patent or any other intellectual
+ * property rights of any other entity. Indiana University disclaims any
+ * liability to any recipient for claims brought by any other entity
+ * based on infringement of intellectual property rights or otherwise.
+ *
+ * LICENSEE UNDERSTANDS THAT SOFTWARE IS PROVIDED "AS IS" FOR WHICH
+ * NO WARRANTIES AS TO CAPABILITIES OR ACCURACY ARE MADE. INDIANA
+ * UNIVERSITY GIVES NO WARRANTIES AND MAKES NO REPRESENTATION THAT
+ * SOFTWARE IS FREE OF INFRINGEMENT OF THIRD PARTY PATENT, COPYRIGHT, OR
+ * OTHER PROPRIETARY RIGHTS. INDIANA UNIVERSITY MAKES NO WARRANTIES THAT
+ * SOFTWARE IS FREE FROM "BUGS", "VIRUSES", "TROJAN HORSES", "TRAP
+ * DOORS", "WORMS", OR OTHER HARMFUL CODE. LICENSEE ASSUMES THE ENTIRE
+ * RISK AS TO THE PERFORMANCE OF SOFTWARE AND/OR ASSOCIATED MATERIALS,
+ * AND TO THE PERFORMANCE AND VALIDITY OF INFORMATION GENERATED USING
+ * SOFTWARE.
+ */
+
Propchange: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/AppDescValidator.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/HostDescValidator.java
URL: http://svn.apache.org/viewvc/incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/HostDescValidator.java?rev=1103180&view=auto
==============================================================================
--- incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/HostDescValidator.java (added)
+++ incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/HostDescValidator.java Sat May 14 18:34:50 2011
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2002-2004 Extreme! Lab, Indiana University. All rights reserved.
+ *
+ * This software is open source. See the bottom of this file for the licence.
+ *
+ * $Id: HostDescValidator.java,v 1.1.2.1 2006/05/30 01:43:24 gkandasw Exp $
+ */
+
+
+/**
+ * @version $Revision: 1.1.2.1 $
+ * @author Gopi Kandaswamy [mailto:gkandasw@cs.indiana.edu]
+ */
+
+package org.ogce.schemas.gfac.validator;
+
+import org.ogce.schemas.gfac.beans.utils.GFacSchemaException;
+import org.ogce.schemas.gfac.documents.HostDescriptionType;
+
+
+public class HostDescValidator
+{
+ // FIXME: Although this is a basic validator, a more comprehensive validation is required
+ public void validateHostDescription(HostDescriptionType hostDesc) throws GFacSchemaException
+ {
+ if(hostDesc.getHostName() == null)
+ {
+ throw new GFacSchemaException("Every host description document must have a host name");
+ }
+
+ if(hostDesc.getHostConfiguration() == null)
+ {
+ throw new GFacSchemaException("HostConfiguration is required in every host description document");
+ }
+
+ if(hostDesc.getHostConfiguration().getTmpDir() == null)
+ {
+ throw new GFacSchemaException("You must specify a tmp directory on this host");
+ }
+ }
+}
+
+
+/*
+ * Indiana University Extreme! Lab Software License, Version 1.2
+ *
+ * Copyright (C) 2002 The Trustees of Indiana University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1) All redistributions of source code must retain the above
+ * copyright notice, the list of authors in the original source
+ * code, this list of conditions and the disclaimer listed in this
+ * license;
+ *
+ * 2) All redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the disclaimer
+ * listed in this license in the documentation and/or other
+ * materials provided with the distribution;
+ *
+ * 3) Any documentation included with all redistributions must include
+ * the following acknowledgement:
+ *
+ * "This product includes software developed by the Indiana
+ * University Extreme! Lab. For further information please visit
+ * http://www.extreme.indiana.edu/"
+ *
+ * Alternatively, this acknowledgment may appear in the software
+ * itself, and wherever such third-party acknowledgments normally
+ * appear.
+ *
+ * 4) The name "Indiana Univeristy" or "Indiana Univeristy
+ * Extreme! Lab" shall not be used to endorse or promote
+ * products derived from this software without prior written
+ * permission from Indiana University. For written permission,
+ * please contact http://www.extreme.indiana.edu/.
+ *
+ * 5) Products derived from this software may not use "Indiana
+ * Univeristy" name nor may "Indiana Univeristy" appear in their name,
+ * without prior written permission of the Indiana University.
+ *
+ * Indiana University provides no reassurances that the source code
+ * provided does not infringe the patent or any other intellectual
+ * property rights of any other entity. Indiana University disclaims any
+ * liability to any recipient for claims brought by any other entity
+ * based on infringement of intellectual property rights or otherwise.
+ *
+ * LICENSEE UNDERSTANDS THAT SOFTWARE IS PROVIDED "AS IS" FOR WHICH
+ * NO WARRANTIES AS TO CAPABILITIES OR ACCURACY ARE MADE. INDIANA
+ * UNIVERSITY GIVES NO WARRANTIES AND MAKES NO REPRESENTATION THAT
+ * SOFTWARE IS FREE OF INFRINGEMENT OF THIRD PARTY PATENT, COPYRIGHT, OR
+ * OTHER PROPRIETARY RIGHTS. INDIANA UNIVERSITY MAKES NO WARRANTIES THAT
+ * SOFTWARE IS FREE FROM "BUGS", "VIRUSES", "TROJAN HORSES", "TRAP
+ * DOORS", "WORMS", OR OTHER HARMFUL CODE. LICENSEE ASSUMES THE ENTIRE
+ * RISK AS TO THE PERFORMANCE OF SOFTWARE AND/OR ASSOCIATED MATERIALS,
+ * AND TO THE PERFORMANCE AND VALIDITY OF INFORMATION GENERATED USING
+ * SOFTWARE.
+ */
+
+
Propchange: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/HostDescValidator.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/ResourceDescValidator.java
URL: http://svn.apache.org/viewvc/incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/ResourceDescValidator.java?rev=1103180&view=auto
==============================================================================
--- incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/ResourceDescValidator.java (added)
+++ incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/ResourceDescValidator.java Sat May 14 18:34:50 2011
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2002-2004 Extreme! Lab, Indiana University. All rights reserved.
+ *
+ * This software is open source. See the bottom of this file for the licence.
+ *
+ * $Id: ResourceDescValidator.java,v 1.1.2.1 2006/05/30 01:43:24 gkandasw Exp $
+ */
+
+
+/**
+ * @version $Revision: 1.1.2.1 $
+ * @author Gopi Kandaswamy [mailto:gkandasw@cs.indiana.edu]
+ */
+
+package org.ogce.schemas.gfac.validator;
+
+public class ResourceDescValidator
+{
+}
+
+
+/*
+ * Indiana University Extreme! Lab Software License, Version 1.2
+ *
+ * Copyright (C) 2002 The Trustees of Indiana University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1) All redistributions of source code must retain the above
+ * copyright notice, the list of authors in the original source
+ * code, this list of conditions and the disclaimer listed in this
+ * license;
+ *
+ * 2) All redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the disclaimer
+ * listed in this license in the documentation and/or other
+ * materials provided with the distribution;
+ *
+ * 3) Any documentation included with all redistributions must include
+ * the following acknowledgement:
+ *
+ * "This product includes software developed by the Indiana
+ * University Extreme! Lab. For further information please visit
+ * http://www.extreme.indiana.edu/"
+ *
+ * Alternatively, this acknowledgment may appear in the software
+ * itself, and wherever such third-party acknowledgments normally
+ * appear.
+ *
+ * 4) The name "Indiana Univeristy" or "Indiana Univeristy
+ * Extreme! Lab" shall not be used to endorse or promote
+ * products derived from this software without prior written
+ * permission from Indiana University. For written permission,
+ * please contact http://www.extreme.indiana.edu/.
+ *
+ * 5) Products derived from this software may not use "Indiana
+ * Univeristy" name nor may "Indiana Univeristy" appear in their name,
+ * without prior written permission of the Indiana University.
+ *
+ * Indiana University provides no reassurances that the source code
+ * provided does not infringe the patent or any other intellectual
+ * property rights of any other entity. Indiana University disclaims any
+ * liability to any recipient for claims brought by any other entity
+ * based on infringement of intellectual property rights or otherwise.
+ *
+ * LICENSEE UNDERSTANDS THAT SOFTWARE IS PROVIDED "AS IS" FOR WHICH
+ * NO WARRANTIES AS TO CAPABILITIES OR ACCURACY ARE MADE. INDIANA
+ * UNIVERSITY GIVES NO WARRANTIES AND MAKES NO REPRESENTATION THAT
+ * SOFTWARE IS FREE OF INFRINGEMENT OF THIRD PARTY PATENT, COPYRIGHT, OR
+ * OTHER PROPRIETARY RIGHTS. INDIANA UNIVERSITY MAKES NO WARRANTIES THAT
+ * SOFTWARE IS FREE FROM "BUGS", "VIRUSES", "TROJAN HORSES", "TRAP
+ * DOORS", "WORMS", OR OTHER HARMFUL CODE. LICENSEE ASSUMES THE ENTIRE
+ * RISK AS TO THE PERFORMANCE OF SOFTWARE AND/OR ASSOCIATED MATERIALS,
+ * AND TO THE PERFORMANCE AND VALIDITY OF INFORMATION GENERATED USING
+ * SOFTWARE.
+ */
+
Propchange: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/ResourceDescValidator.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/SchemaValidator.java
URL: http://svn.apache.org/viewvc/incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/SchemaValidator.java?rev=1103180&view=auto
==============================================================================
--- incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/SchemaValidator.java (added)
+++ incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/SchemaValidator.java Sat May 14 18:34:50 2011
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2002-2004 Extreme! Lab, Indiana University. All rights reserved.
+ *
+ * This software is open source. See the bottom of this file for the licence.
+ *
+ * $Id: SchemaValidator.java,v 1.1.2.1 2006/05/30 01:43:24 gkandasw Exp $
+ */
+
+
+/**
+ * @version $Revision: 1.1.2.1 $
+ * @author Gopi Kandaswamy [mailto:gkandasw@cs.indiana.edu]
+ */
+
+package org.ogce.schemas.gfac.validator;
+
+import org.ogce.schemas.gfac.beans.utils.GFacSchemaException;
+import org.ogce.schemas.gfac.documents.ApplicationDescriptionType;
+import org.ogce.schemas.gfac.documents.HostDescriptionType;
+import org.ogce.schemas.gfac.documents.ServiceMapType;
+
+public class SchemaValidator
+{
+ private ServiceMapType serviceMap = null;
+ private HostDescriptionType hostDesc = null;
+ private ApplicationDescriptionType appDesc = null;
+
+ public SchemaValidator(ServiceMapType serviceMap)
+ {
+ this.serviceMap = serviceMap;
+ }
+ public SchemaValidator(HostDescriptionType hostDesc)
+ {
+ this.hostDesc = hostDesc;
+ }
+ public SchemaValidator(ApplicationDescriptionType appDesc)
+ {
+ this.appDesc = appDesc;
+ }
+
+ public void validate() throws GFacSchemaException
+ {
+ if(serviceMap != null)
+ {
+ ServiceMapValidator validator = new ServiceMapValidator();
+ validator.validateServiceMap(serviceMap);
+ }
+ else if(appDesc != null)
+ {
+ AppDescValidator validator = new AppDescValidator();
+ validator.validateApplicationDescription(appDesc);
+ }
+ else if (hostDesc != null)
+ {
+ HostDescValidator validator = new HostDescValidator();
+ validator.validateHostDescription(hostDesc);
+ }
+ }
+}
+
+/*
+ * Indiana University Extreme! Lab Software License, Version 1.2
+ *
+ * Copyright (c) 2002-2004 The Trustees of Indiana University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1) All redistributions of source code must retain the above
+ * copyright notice, the list of authors in the original source
+ * code, this list of conditions and the disclaimer listed in this
+ * license;
+ *
+ * 2) All redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the disclaimer
+ * listed in this license in the documentation and/or other
+ * materials provided with the distribution;
+ *
+ * 3) Any documentation included with all redistributions must include
+ * the following acknowledgement:
+ *
+ * "This product includes software developed by the Indiana
+ * University Extreme! Lab. For further information please visit
+ * http://www.extreme.indiana.edu/"
+ *
+ * Alternatively, this acknowledgment may appear in the software
+ * itself, and wherever such third-party acknowledgments normally
+ * appear.
+ *
+ * 4) The name "Indiana University" or "Indiana University
+ * Extreme! Lab" shall not be used to endorse or promote
+ * products derived from this software without prior written
+ * permission from Indiana University. For written permission,
+ * please contact http://www.extreme.indiana.edu/.
+ *
+ * 5) Products derived from this software may not use "Indiana
+ * University" name nor may "Indiana University" appear in their name,
+ * without prior written permission of the Indiana University.
+ *
+ * Indiana University provides no reassurances that the source code
+ * provided does not infringe the patent or any other intellectual
+ * property rights of any other entity. Indiana University disclaims any
+ * liability to any recipient for claims brought by any other entity
+ * based on infringement of intellectual property rights or otherwise.
+ *
+ * LICENSEE UNDERSTANDS THAT SOFTWARE IS PROVIDED "AS IS" FOR WHICH
+ * NO WARRANTIES AS TO CAPABILITIES OR ACCURACY ARE MADE. INDIANA
+ * UNIVERSITY GIVES NO WARRANTIES AND MAKES NO REPRESENTATION THAT
+ * SOFTWARE IS FREE OF INFRINGEMENT OF THIRD PARTY PATENT, COPYRIGHT, OR
+ * OTHER PROPRIETARY RIGHTS. INDIANA UNIVERSITY MAKES NO WARRANTIES THAT
+ * SOFTWARE IS FREE FROM "BUGS", "VIRUSES", "TROJAN HORSES", "TRAP
+ * DOORS", "WORMS", OR OTHER HARMFUL CODE. LICENSEE ASSUMES THE ENTIRE
+ * RISK AS TO THE PERFORMANCE OF SOFTWARE AND/OR ASSOCIATED MATERIALS,
+ * AND TO THE PERFORMANCE AND VALIDITY OF INFORMATION GENERATED USING
+ * SOFTWARE.
+ */
+
Propchange: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/SchemaValidator.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/ServiceMapValidator.java
URL: http://svn.apache.org/viewvc/incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/ServiceMapValidator.java?rev=1103180&view=auto
==============================================================================
--- incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/ServiceMapValidator.java (added)
+++ incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/ServiceMapValidator.java Sat May 14 18:34:50 2011
@@ -0,0 +1,219 @@
+/*
+ * Copyright (c) 2002-2004 Extreme! Lab, Indiana University. All rights reserved.
+ *
+ * This software is open source. See the bottom of this file for the licence.
+ *
+ * $Id: ServiceMapValidator.java,v 1.1.2.1 2006/05/30 01:43:24 gkandasw Exp $
+ */
+
+
+/**
+ * @version $Revision: 1.1.2.1 $
+ * @author Gopi Kandaswamy [mailto:gkandasw@cs.indiana.edu]
+ */
+
+package org.ogce.schemas.gfac.validator;
+
+import org.ogce.schemas.gfac.beans.utils.GFacSchemaException;
+import org.ogce.schemas.gfac.documents.ApplicationType;
+import org.ogce.schemas.gfac.documents.InputParameterType;
+import org.ogce.schemas.gfac.documents.MethodType;
+import org.ogce.schemas.gfac.documents.OutputParameterType;
+import org.ogce.schemas.gfac.documents.ParameterValueType;
+import org.ogce.schemas.gfac.documents.PortTypeType;
+import org.ogce.schemas.gfac.documents.ServiceMapType;
+import org.ogce.schemas.gfac.documents.ServiceType;
+import org.ogce.schemas.gfac.utils.GFacConstants;
+
+
+
+
+public class ServiceMapValidator
+{
+ // FIXME: Although this is a basic validator, a more comprehensive validation is required
+ public void validateServiceMap(ServiceMapType serviceMap) throws GFacSchemaException
+ {
+ ServiceType service = serviceMap.getService();
+ if(service == null)
+ {
+ throw new GFacSchemaException("Service cannot be null");
+ }
+
+ if(service.getServiceName() == null)
+ {
+ throw new GFacSchemaException("Service name cannot be null");
+ }
+
+ if(service.getServiceName().getTargetNamespace() == null)
+ {
+ throw new GFacSchemaException("Target namespace for service cannot be null");
+ }
+
+ PortTypeType[] portTypes = serviceMap.getPortTypeArray();
+
+ if(portTypes == null)
+ {
+ throw new GFacSchemaException("Service must have at least one port type");
+ }
+
+ for (int i = 0; i < portTypes.length; ++i)
+ {
+ MethodType[] methods = portTypes[i].getMethodArray();
+ if(methods == null || methods.length <= 0 )
+ {
+ throw new GFacSchemaException("Each port type must have at least one method a.k.a operation");
+ }
+
+ for(int j = 0; j < methods.length; ++j)
+ {
+ MethodType method = methods[i];
+ if(method.getMethodName() == null)
+ {
+ throw new GFacSchemaException("Every method must have a name");
+ }
+
+ if(method.getMethodName().equals(GFacConstants.PING) ||
+ method.getMethodName().equals(GFacConstants.SHUTDOWN) ||
+ method.getMethodName().equals(GFacConstants.KILL) ||
+ method.getMethodName().equals(GFacConstants.CREATE_SERVICE))
+ {
+ if(method.getApplication() != null)
+ {
+ throw new GFacSchemaException("Ping, Shutdown, Kill and CreateService are system defined methods");
+ }
+ }
+
+
+ if(!(method.getMethodName().equals(GFacConstants.PING) ||
+ method.getMethodName().equals(GFacConstants.SHUTDOWN) ||
+ method.getMethodName().equals(GFacConstants.KILL) ||
+ method.getMethodName().equals(GFacConstants.CREATE_SERVICE)))
+ {
+ if(method.getApplication() == null)
+ {
+ throw new GFacSchemaException("Every user defined method must have one application associated with it");
+ }
+
+
+ ApplicationType app = method.getApplication();
+
+ if(app.getApplicationName() == null)
+ {
+ throw new GFacSchemaException("Application must have a name");
+ }
+
+ if(app.getApplicationName().getTargetNamespace() == null)
+ {
+ throw new GFacSchemaException("Application must have a target namespace");
+ }
+
+ InputParameterType[] inputs = method.getInputParameterArray();
+ if(inputs != null && inputs.length > 0)
+ {
+ InputParameterType input = inputs[i];
+ if(input.getParameterName() == null)
+ {
+ throw new GFacSchemaException("Every input parameter must have a parameter name");
+ }
+
+ if(input.getParameterType() == null)
+ {
+ throw new GFacSchemaException("Every input parameter must have a valid data type");
+ }
+
+ ParameterValueType[] values = input.getParameterValueArray();
+
+ if(values != null && values.length > 0)
+ {
+ for(int k = 0; k < values.length; ++k)
+ {
+ if(values[k].getValue() == null)
+ {
+ throw new GFacSchemaException("Every parameter value must have a value");
+ }
+ }
+ }
+
+ }
+
+ OutputParameterType[] outputs = method.getOutputParameterArray();
+ if(outputs != null && outputs.length > 0)
+ {
+ OutputParameterType output = outputs[i];
+ if(output.getParameterName() == null)
+ {
+ throw new GFacSchemaException("Every output parameter must have a parameter name");
+ }
+
+ if(output.getParameterType() == null)
+ {
+ throw new GFacSchemaException("Every output parameter must have a data type");
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
+
+
+/*
+ * Indiana University Extreme! Lab Software License, Version 1.2
+ *
+ * Copyright (C) 2002 The Trustees of Indiana University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1) All redistributions of source code must retain the above
+ * copyright notice, the list of authors in the original source
+ * code, this list of conditions and the disclaimer listed in this
+ * license;
+ *
+ * 2) All redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the disclaimer
+ * listed in this license in the documentation and/or other
+ * materials provided with the distribution;
+ *
+ * 3) Any documentation included with all redistributions must include
+ * the following acknowledgement:
+ *
+ * "This product includes software developed by the Indiana
+ * University Extreme! Lab. For further information please visit
+ * http://www.extreme.indiana.edu/"
+ *
+ * Alternatively, this acknowledgment may appear in the software
+ * itself, and wherever such third-party acknowledgments normally
+ * appear.
+ *
+ * 4) The name "Indiana Univeristy" or "Indiana Univeristy
+ * Extreme! Lab" shall not be used to endorse or promote
+ * products derived from this software without prior written
+ * permission from Indiana University. For written permission,
+ * please contact http://www.extreme.indiana.edu/.
+ *
+ * 5) Products derived from this software may not use "Indiana
+ * Univeristy" name nor may "Indiana Univeristy" appear in their name,
+ * without prior written permission of the Indiana University.
+ *
+ * Indiana University provides no reassurances that the source code
+ * provided does not infringe the patent or any other intellectual
+ * property rights of any other entity. Indiana University disclaims any
+ * liability to any recipient for claims brought by any other entity
+ * based on infringement of intellectual property rights or otherwise.
+ *
+ * LICENSEE UNDERSTANDS THAT SOFTWARE IS PROVIDED "AS IS" FOR WHICH
+ * NO WARRANTIES AS TO CAPABILITIES OR ACCURACY ARE MADE. INDIANA
+ * UNIVERSITY GIVES NO WARRANTIES AND MAKES NO REPRESENTATION THAT
+ * SOFTWARE IS FREE OF INFRINGEMENT OF THIRD PARTY PATENT, COPYRIGHT, OR
+ * OTHER PROPRIETARY RIGHTS. INDIANA UNIVERSITY MAKES NO WARRANTIES THAT
+ * SOFTWARE IS FREE FROM "BUGS", "VIRUSES", "TROJAN HORSES", "TRAP
+ * DOORS", "WORMS", OR OTHER HARMFUL CODE. LICENSEE ASSUMES THE ENTIRE
+ * RISK AS TO THE PERFORMANCE OF SOFTWARE AND/OR ASSOCIATED MATERIALS,
+ * AND TO THE PERFORMANCE AND VALIDITY OF INFORMATION GENERATED USING
+ * SOFTWARE.
+ */
+
Propchange: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/validator/ServiceMapValidator.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/wsdl/AbstractContext.java
URL: http://svn.apache.org/viewvc/incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/wsdl/AbstractContext.java?rev=1103180&view=auto
==============================================================================
--- incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/wsdl/AbstractContext.java (added)
+++ incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/wsdl/AbstractContext.java Sat May 14 18:34:50 2011
@@ -0,0 +1,15 @@
+package org.ogce.schemas.gfac.wsdl;
+
+import java.util.HashMap;
+
+public class AbstractContext {
+ protected final HashMap<String, Object> properties = new HashMap<String, Object>();
+
+ public void setProperty(String key, Object value) {
+ properties.put(key, value);
+ }
+
+ public Object getProperty(String key) {
+ return properties.get(key);
+ }
+}
Propchange: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/wsdl/AbstractContext.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/wsdl/DataIDType.java
URL: http://svn.apache.org/viewvc/incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/wsdl/DataIDType.java?rev=1103180&view=auto
==============================================================================
--- incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/wsdl/DataIDType.java (added)
+++ incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/wsdl/DataIDType.java Sat May 14 18:34:50 2011
@@ -0,0 +1,74 @@
+package org.ogce.schemas.gfac.wsdl;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+
+import org.ogce.schemas.gfac.beans.utils.GFacSchemaException;
+import org.xmlpull.v1.builder.XmlElement;
+
+/**
+ * Represents a DataID (A schema with real names), currently it only sends a one
+ * location value.
+ * @author Srinath Perera(hperera@cs.indiana.edu)
+ */
+public class DataIDType {
+ public static final String LOCATION_ATTRIBUTE = "location";
+
+ private URI dataID;
+
+ private ArrayList<URI> dataLocations = new ArrayList<URI>();
+
+ public URI getRealLocation() {
+ if (dataLocations.size() > 0) {
+ return dataLocations.get(0);
+ } else {
+ return null;
+ }
+ }
+
+ public DataIDType(XmlElement ele) throws GFacSchemaException {
+ try {
+ String value = ele.requiredTextContent();
+ if (value != null) {
+ this.dataID = new URI(value);
+ } else {
+ throw new GFacSchemaException(
+ "Illegal InputMessage, No value content found for the parameter "
+ + ele.getName() + "/value");
+ }
+ String location = ele.getAttributeValue(null, DataIDType.LOCATION_ATTRIBUTE);
+ if (location != null) {
+ addDataLocation(new URI(location));
+ }
+ } catch (URISyntaxException e) {
+ throw new GFacSchemaException(e);
+ }
+ }
+
+ public DataIDType(URI dataID) {
+ super();
+ this.dataID = dataID;
+ }
+
+ public void addDataLocation(URI dataLocation) {
+ dataLocations.add(dataLocation);
+ }
+
+ public ArrayList<URI> getDataLocations() {
+ return dataLocations;
+ }
+
+ public URI getDataID() {
+ return dataID;
+ }
+
+ public void fillData(XmlElement ele) {
+ ele.addChild(dataID.toString());
+ URI location = getRealLocation();
+ if (location != null) {
+ ele.addAttribute(DataIDType.LOCATION_ATTRIBUTE, location.toString());
+ }
+ }
+
+}
Propchange: incubator/airavata/donations/ogce-donation/modules/utils/schemas/gfac-schema-utils/src/main/java/org/ogce/schemas/gfac/wsdl/DataIDType.java
------------------------------------------------------------------------------
svn:executable = *