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");
}
}
}
}
}