Search in sources :

Example 1 with NIOAdaptorProperties

use of es.bsc.compss.types.resources.jaxb.NIOAdaptorProperties in project compss by bsc-wdc.

the class Validator method validateAdaptor.

private void validateAdaptor(AdaptorType adaptor) throws InvalidElementException {
    // Validate inner elements
    List<JAXBElement<?>> innerElements = adaptor.getSubmissionSystemOrPortsOrBrokerAdaptor();
    if (innerElements != null) {
        boolean subsysTagFound = false;
        boolean portsTagFound = false;
        boolean brokerAdaptorTagFound = false;
        boolean propertiesTagFound = false;
        boolean userTagFound = false;
        for (JAXBElement<?> obj : innerElements) {
            if (obj.getName().equals(new QName("SubmissionSystem"))) {
                if (subsysTagFound) {
                    // Second occurency, throw exception
                    throw new InvalidElementException("Adaptor", "Attribute " + obj.getName(), "Appears more than once");
                } else {
                    subsysTagFound = true;
                    validateSubmissionSystem(((SubmissionSystemType) obj.getValue()));
                }
            } else if (obj.getName().equals(new QName("Ports"))) {
                if (portsTagFound) {
                    // Second occurency, throw exception
                    throw new InvalidElementException("Adaptor", "Attribute " + obj.getName(), "Appears more than once");
                } else if (brokerAdaptorTagFound || propertiesTagFound) {
                    // Cannot define multiple adaptor properties
                    throw new InvalidElementException("Adaptor", "Attribute " + obj.getName(), "An adaptor property (GAT or External) was already defined");
                } else {
                    portsTagFound = true;
                    validateNIOAdaptorProperties(((NIOAdaptorProperties) obj.getValue()));
                }
            } else if (obj.getName().equals(new QName("BrokerAdaptor"))) {
                if (brokerAdaptorTagFound) {
                    // Second occurency, throw exception
                    throw new InvalidElementException("Adaptor", "Attribute " + obj.getName(), "Appears more than once");
                } else if (portsTagFound || propertiesTagFound) {
                    // Cannot define multiple adaptor properties
                    throw new InvalidElementException("Adaptor", "Attribute " + obj.getName(), "An adaptor property (NIO or External) was already defined");
                } else {
                    brokerAdaptorTagFound = true;
                    validateGATAdaptorProperties(((String) obj.getValue()));
                }
            } else if (obj.getName().equals(new QName("Properties"))) {
                if (propertiesTagFound) {
                    // Second occurency, throw exception
                    throw new InvalidElementException("Adaptor", "Attribute " + obj.getName(), "Appears more than once");
                } else if (portsTagFound || brokerAdaptorTagFound) {
                    // Cannot define multiple adaptor properties
                    throw new InvalidElementException("Adaptor", "Attribute " + obj.getName(), "An adaptor property (NIO or GAT) was already defined");
                } else {
                    propertiesTagFound = true;
                    validateExternalAdaptorProperties(((ExternalAdaptorProperties) obj.getValue()));
                }
            } else if (obj.getName().equals(new QName("User"))) {
                if (userTagFound) {
                    // Second occurency, throw exception
                    throw new InvalidElementException("Adaptor", "Attribute " + obj.getName(), "Appears more than once");
                } else {
                    userTagFound = true;
                }
            } else {
                throw new InvalidElementException("Adaptor " + adaptor.getName(), "Attribute" + obj.getName(), "Incorrect attribute");
            }
        }
        // Check minimum appearences
        if (!subsysTagFound) {
            throw new InvalidElementException("Adaptor " + adaptor.getName(), "Attribute SubmissionSystem", "Doesn't appear");
        }
        if (!portsTagFound && !brokerAdaptorTagFound && !propertiesTagFound) {
            throw new InvalidElementException("Adaptor " + adaptor.getName(), "Attribute Adaptor properties (NIO, GAT or External)", "Doesn't appear");
        }
    } else {
        // Empty inner elements
        throw new InvalidElementException("Adaptor", "", "Content is empty");
    }
}
Also used : SubmissionSystemType(es.bsc.compss.types.resources.jaxb.SubmissionSystemType) QName(javax.xml.namespace.QName) InvalidElementException(es.bsc.compss.types.resources.exceptions.InvalidElementException) NIOAdaptorProperties(es.bsc.compss.types.resources.jaxb.NIOAdaptorProperties) JAXBElement(javax.xml.bind.JAXBElement) ExternalAdaptorProperties(es.bsc.compss.types.resources.jaxb.ExternalAdaptorProperties)

Aggregations

InvalidElementException (es.bsc.compss.types.resources.exceptions.InvalidElementException)1 ExternalAdaptorProperties (es.bsc.compss.types.resources.jaxb.ExternalAdaptorProperties)1 NIOAdaptorProperties (es.bsc.compss.types.resources.jaxb.NIOAdaptorProperties)1 SubmissionSystemType (es.bsc.compss.types.resources.jaxb.SubmissionSystemType)1 JAXBElement (javax.xml.bind.JAXBElement)1 QName (javax.xml.namespace.QName)1