Package org.ogce.schemas.gfac.documents

Examples of org.ogce.schemas.gfac.documents.ServiceMapDocument


   */
  public String updateObject(RegistryService regService, BeanObject serviceObject) throws GfacException {
    ServiceBean serviceMap = (ServiceBean) serviceObject;
    QName serviceName = new QName(serviceMap.getServiceName());

    ServiceMapDocument oldServiceMap = RegistryUtil.getServiceMap(regService, serviceName);
    String serviceMapStr = serviceXMLRequest(regService, serviceMap, null);

    if (oldServiceMap != null) {
      regService.removeServiceMap(serviceName.toString());
    }
    try {
      RegistryUtil.registerServiceMapFromStr(regService, serviceMapStr);
    } catch (Exception e) {
      if (oldServiceMap != null) {
        RegistryUtil.registerServiceMapFromStr(regService, oldServiceMap.xmlText());
      }
      throw new GfacException(e, FaultCode.ErrorAtClientWhileWsCall);
    }
    // System.out.println("######"+serviceMapStr);

View Full Code Here


   * @return serviceString for XRegistry
   * @throws GfacException
   */
  private static String serviceXMLRequest(RegistryService regService, ServiceBean serviceInfo,
      ServiceMapDocument template) throws GfacException {
    ServiceMapDocument smd;
    ServiceMapType smt;
    ServiceType st;

    if (template != null) {
      smd = template;
      smt = smd.getServiceMap();
      st = smt.getService();
    } else {
      smd = ServiceMapDocument.Factory.newInstance();
      smt = smd.addNewServiceMap();
      st = smt.addNewService();
    }

    QName serviceName;
    if (serviceInfo.getServiceName().startsWith("{")) {
      serviceName = QName.valueOf(serviceInfo.getServiceName().trim());
    } else {
      serviceName = new QName(serviceInfo.getObjectNamespace(), serviceInfo.getServiceName().trim());
    }

    ServiceName sn = st.getServiceName();
    if (sn == null) {
      sn = st.addNewServiceName();
      ;
    }
    sn.setStringValue(serviceName.getLocalPart());
    sn.setTargetNamespace(serviceInfo.getObjectNamespace());

    PortTypeType pt;
    if (smt.getPortTypeArray() != null && smt.getPortTypeArray().length > 0) {
      pt = smt.getPortTypeArray(0);
    } else {
      pt = smt.addNewPortType();
    }

    ArrayList<Object> operations = serviceInfo.getOperations();

    for (int i = 0; i < operations.size(); i++) {
      MethodBean op = (MethodBean) operations.get(i);

      if (op == null) {
        throw new GfacException("Operation can not be Null", FaultCode.InvaliedLocalArgumnet);
      }

      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 (smt.getLifeTime() == null) {
        smt.addNewLifeTime().setNotAfterInactiveMinutes(serviceInfo.getNotAfterInactiveMinutes());
      } else {
        smt.getLifeTime().setNotAfterInactiveMinutes(serviceInfo.getNotAfterInactiveMinutes());
      }
    }
    return smd.xmlText();

  }
View Full Code Here

    return smd.xmlText();

  }

  public static String simpleServiceXMLRequest(ServiceBean serviceInfo) throws GfacException {
    ServiceMapDocument smd;
    ServiceMapType smt;
    ServiceType st;

    smd = ServiceMapDocument.Factory.newInstance();
    smt = smd.addNewServiceMap();
    st = smt.addNewService();

    QName serviceName;
    if (serviceInfo.getServiceName().startsWith("{")) {
      serviceName = QName.valueOf(serviceInfo.getServiceName().trim());
    } else {
      serviceName = new QName(serviceInfo.getObjectNamespace(), serviceInfo.getServiceName().trim());
    }

    ServiceName sn = st.getServiceName();
    if (sn == null) {
      sn = st.addNewServiceName();
      ;
    }
    sn.setStringValue(serviceName.getLocalPart());
    sn.setTargetNamespace(serviceInfo.getObjectNamespace());

    PortTypeType pt;
    if (smt.getPortTypeArray() != null && smt.getPortTypeArray().length > 0) {
      pt = smt.getPortTypeArray(0);
    } else {
      pt = smt.addNewPortType();
    }

    ArrayList<Object> operations = serviceInfo.getOperations();

    for (int i = 0; i < operations.size(); i++) {
      MethodBean op = (MethodBean) operations.get(i);

      if (op == null) {
        throw new GfacException("Operation can not be Null", FaultCode.InvaliedLocalArgumnet);
      }

      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 (smt.getLifeTime() == null) {
        smt.addNewLifeTime().setNotAfterInactiveMinutes(serviceInfo.getNotAfterInactiveMinutes());
      } else {
        smt.getLifeTime().setNotAfterInactiveMinutes(serviceInfo.getNotAfterInactiveMinutes());
      }
    }
    return smd.xmlText();

  }
View Full Code Here

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();
  }
View Full Code Here

      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()
View Full Code Here

TOP

Related Classes of org.ogce.schemas.gfac.documents.ServiceMapDocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.