Example usage for org.dom4j Attribute getValue

List of usage examples for org.dom4j Attribute getValue

Introduction

In this page you can find the example usage for org.dom4j Attribute getValue.

Prototype

String getValue();

Source Link

Document

Returns the value of the attribute.

Usage

From source file:net.unicon.academus.apps.gateway.engine.ChangeCredentialsAction.java

License:Open Source License

public static IAction parse(Element e, IWarlockFactory owner) throws WarlockException {

    // Assertions.
    if (e == null) {
        String msg = "Argument 'e [Element]' cannot be null.";
        throw new IllegalArgumentException(msg);
    }/*from www  . j a  va2 s.  com*/
    if (!e.getName().equals("action")) {
        String msg = "Argument 'e [Element]' must be an <action> element.";
        throw new IllegalArgumentException(msg);
    }
    if (owner == null) {
        String msg = "Argument 'owner' cannot be null.";
        throw new IllegalArgumentException(msg);
    }

    // Handle.
    Attribute h = e.attribute("handle");
    if (h == null) {
        String msg = "Element <action> is missing required attribute " + "'handle'.";
        throw new XmlFormatException(msg);
    }
    Handle handle = Handle.create(h.getValue());

    // Choices.
    String[] choices = new String[0];
    Attribute p = e.attribute("inpt");
    if (p != null) {
        choices = p.getValue().split(",");
    }

    return new ChangeCredentialsAction(owner, handle, choices);

}

From source file:net.unicon.academus.apps.gateway.engine.MainViewAction.java

License:Open Source License

public static IAction parse(Element e, IWarlockFactory owner) throws WarlockException {

    // Assertions.
    if (e == null) {
        String msg = "Argument 'e [Element]' cannot be null.";
        throw new IllegalArgumentException(msg);
    }//w w  w .  j  a v a  2  s .  co  m
    if (!e.getName().equals("action")) {
        String msg = "Argument 'e [Element]' must be an <action> element.";
        throw new IllegalArgumentException(msg);
    }
    if (owner == null) {
        String msg = "Argument 'owner' cannot be null.";
        throw new IllegalArgumentException(msg);
    }

    // Handle.
    Attribute h = e.attribute("handle");
    if (h == null) {
        String msg = "Element <action> is missing required attribute " + "'handle'.";
        throw new XmlFormatException(msg);
    }
    Handle handle = Handle.create(h.getValue());

    // Choices.
    String[] choices = new String[0];
    Attribute p = e.attribute("inpt");
    if (p != null) {
        choices = p.getValue().split(",");
    }

    return new MainViewAction(owner, handle, choices);

}

From source file:net.unicon.academus.apps.gateway.engine.SingleIframeAction.java

License:Open Source License

public static IAction parse(Element e, IWarlockFactory owner) throws WarlockException {

    // Assertions.
    if (e == null) {
        String msg = "Argument 'e [Element]' cannot be null.";
        throw new IllegalArgumentException(msg);
    }/*from w  ww .  j av  a2s .  c o m*/
    if (!e.getName().equals("action")) {
        String msg = "Argument 'e [Element]' must be an <action> element.";
        throw new IllegalArgumentException(msg);
    }
    if (owner == null) {
        String msg = "Argument 'owner' cannot be null.";
        throw new IllegalArgumentException(msg);
    }

    // Handle.
    Attribute h = e.attribute("handle");
    if (h == null) {
        String msg = "Element <action> is missing required attribute " + "'handle'.";
        throw new XmlFormatException(msg);
    }
    Handle handle = Handle.create(h.getValue());

    // Choices.
    String[] choices = new String[0];
    Attribute p = e.attribute("inpt");
    if (p != null) {
        choices = p.getValue().split(",");
    }

    return new SingleIframeAction(owner, handle, choices);

}

From source file:net.unicon.academus.apps.gateway.engine.UpdateCredentialsAction.java

License:Open Source License

public static IAction parse(Element e, IWarlockFactory owner) throws WarlockException {

    // Assertions.
    if (e == null) {
        String msg = "Argument 'e [Element]' cannot be null.";
        throw new IllegalArgumentException(msg);
    }//from   www .jav a  2  s . c  o  m
    if (!e.getName().equals("action")) {
        String msg = "Argument 'e [Element]' must be an <action> element.";
        throw new IllegalArgumentException(msg);
    }
    if (owner == null) {
        String msg = "Argument 'owner' cannot be null.";
        throw new IllegalArgumentException(msg);
    }

    // Handle.
    Attribute h = e.attribute("handle");
    if (h == null) {
        String msg = "Element <action> is missing required attribute " + "'handle'.";
        throw new XmlFormatException(msg);
    }
    Handle handle = Handle.create(h.getValue());

    // Choices.
    String[] choices = new String[0];
    Attribute p = e.attribute("inpt");
    if (p != null) {
        choices = p.getValue().split(",");
    }

    return new UpdateCredentialsAction(owner, handle, choices);

}

From source file:net.unicon.academus.apps.messaging.BatchImporter.java

License:Open Source License

public static MessageCenter configure(String configFile, String mcenter) throws Exception {
    Element configElement = (Element) (new SAXReader()).read(configFile).selectSingleNode("messaging");

    configElement = ConfigHelper.handle(configElement, false);

    // Bootstrap datasources with SimpleDataSource...
    List bsList = configElement.selectNodes("//*[@needsDataSource='true']");
    if (!bsList.isEmpty()) {
        try {/* w  ww .  j  a v  a  2  s  .  co m*/
            DataSource ds = new SimpleDataSource();

            for (Iterator it = bsList.iterator(); it.hasNext();) {
                Element e = (Element) it.next();

                Attribute impl = e.attribute("impl");
                if (impl == null)
                    throw new IllegalArgumentException("Elements with the 'needsDataSource' attribute "
                            + " must have an 'impl' attribute.");

                Class.forName(impl.getValue()).getDeclaredMethod("bootstrap", new Class[] { DataSource.class })
                        .invoke(null, new Object[] { ds });
            }
        } catch (Throwable e) {
            e.printStackTrace(System.err);
            error("Failed the DataSource bootstrapping. Please correct any errors.");
        }
    }

    // Handle any global configuration for the message factories.
    List mList = configElement.selectNodes("message-factory");
    for (Iterator mIt = mList.iterator(); mIt.hasNext();) {
        Element e = (Element) mIt.next();
        Attribute impl = e.attribute("impl");
        if (impl == null)
            throw new IllegalArgumentException("Element <message-factory> must have an 'impl'" + " attribute.");
        try {
            Class.forName(impl.getValue()).getDeclaredMethod("parse", new Class[] { Element.class })
                    .invoke(null, new Object[] { e });
        } catch (Throwable t) {
            throw new RuntimeException("Failed to parse the <message-factory> element.", t);
        }
    }

    Element e = (Element) configElement.selectSingleNode("message-center[@id='" + mcenter + "']");

    return new MessageCenter(e);
}

From source file:net.unicon.academus.apps.messaging.engine.ChangeMessagePageAction.java

License:Open Source License

public static IAction parse(Element e, IWarlockFactory owner) throws WarlockException {

    // Assertions.
    if (e == null) {
        String msg = "Argument 'e [Element]' cannot be null.";
        throw new IllegalArgumentException(msg);
    }/* w  w  w  . j a v  a  2s  . c  o m*/
    if (!e.getName().equals("action")) {
        String msg = "Argument 'e [Element]' must be an <action> element.";
        throw new IllegalArgumentException(msg);
    }
    if (owner == null) {
        String msg = "Argument 'owner+' cannot be null.";
        throw new IllegalArgumentException(msg);
    }

    // Handle.
    Attribute h = e.attribute("handle");
    if (h == null) {
        String msg = "Element <action> is missing required attribute " + "'handle'.";
        throw new XmlFormatException(msg);
    }
    Handle handle = Handle.create(h.getValue());

    // Choices.
    String[] choices = new String[0];
    Attribute p = e.attribute("inpt");
    if (p != null) {
        choices = p.getValue().split(",");
    }

    // Move.
    Attribute m = e.attribute("move");
    if (m == null) {
        String msg = "Element <action> is missing required attribute " + "'mode'.";
        throw new XmlFormatException(msg);
    }
    PageChange change = PageChange.getInstance(m.getValue());

    return new ChangeMessagePageAction(owner, handle, choices, change);

}

From source file:net.unicon.academus.apps.messaging.engine.ChangeMessageSortAction.java

License:Open Source License

public static IAction parse(Element e, IWarlockFactory owner) throws WarlockException {

    // Assertions.
    if (e == null) {
        String msg = "Argument 'e [Element]' cannot be null.";
        throw new IllegalArgumentException(msg);
    }/*from w  w  w . jav a 2  s  . c  o  m*/
    if (!e.getName().equals("action")) {
        String msg = "Argument 'e [Element]' must be an <action> element.";
        throw new IllegalArgumentException(msg);
    }
    if (owner == null) {
        String msg = "Argument 'owner+' cannot be null.";
        throw new IllegalArgumentException(msg);
    }

    // Handle.
    Attribute h = e.attribute("handle");
    if (h == null) {
        String msg = "Element <action> is missing required attribute " + "'handle'.";
        throw new XmlFormatException(msg);
    }
    Handle handle = Handle.create(h.getValue());

    // Choices.
    String[] choices = new String[0];
    Attribute p = e.attribute("inpt");
    if (p != null) {
        choices = p.getValue().split(",");
    }

    // Mode.
    Attribute m = e.attribute("mode");
    if (m == null) {
        String msg = "Element <action> is missing required attribute " + "'mode'.";
        throw new XmlFormatException(msg);
    }
    String mode = m.getValue();

    return new ChangeMessageSortAction(owner, handle, choices, mode);

}

From source file:net.unicon.academus.apps.messaging.engine.ChangeRecipientSortAction.java

License:Open Source License

public static IAction parse(Element e, IWarlockFactory owner) throws WarlockException {

    // Assertions.
    if (e == null) {
        String msg = "Argument 'e [Element]' cannot be null.";
        throw new IllegalArgumentException(msg);
    }/*from   www . ja v a 2 s.c  om*/
    if (!e.getName().equals("action")) {
        String msg = "Argument 'e [Element]' must be an <action> element.";
        throw new IllegalArgumentException(msg);
    }
    if (owner == null) {
        String msg = "Argument 'owner+' cannot be null.";
        throw new IllegalArgumentException(msg);
    }

    // Handle.
    Attribute h = e.attribute("handle");
    if (h == null) {
        String msg = "Element <action> is missing required attribute " + "'handle'.";
        throw new XmlFormatException(msg);
    }
    Handle handle = Handle.create(h.getValue());

    // Choices.
    String[] choices = new String[0];
    Attribute p = e.attribute("inpt");
    if (p != null) {
        choices = p.getValue().split(",");
    }

    // Mode.
    Attribute m = e.attribute("mode");
    if (m == null) {
        String msg = "Element <action> is missing required attribute " + "'mode'.";
        throw new XmlFormatException(msg);
    }
    String mode = m.getValue();

    return new ChangeRecipientSortAction(owner, handle, choices, mode);

}

From source file:net.unicon.academus.apps.messaging.engine.ChangeReportPageAction.java

License:Open Source License

public static IAction parse(Element e, IWarlockFactory owner) throws WarlockException {

    // Assertions.
    if (e == null) {
        String msg = "Argument 'e [Element]' cannot be null.";
        throw new IllegalArgumentException(msg);
    }/* w  ww  . j  ava 2 s  . c  o  m*/
    if (!e.getName().equals("action")) {
        String msg = "Argument 'e [Element]' must be an <action> element.";
        throw new IllegalArgumentException(msg);
    }
    if (owner == null) {
        String msg = "Argument 'owner+' cannot be null.";
        throw new IllegalArgumentException(msg);
    }

    // Handle.
    Attribute h = e.attribute("handle");
    if (h == null) {
        String msg = "Element <action> is missing required attribute " + "'handle'.";
        throw new XmlFormatException(msg);
    }
    Handle handle = Handle.create(h.getValue());

    // Choices.
    String[] choices = new String[0];
    Attribute p = e.attribute("inpt");
    if (p != null) {
        choices = p.getValue().split(",");
    }

    // Move.
    Attribute m = e.attribute("move");
    if (m == null) {
        String msg = "Element <action> is missing required attribute " + "'mode'.";
        throw new XmlFormatException(msg);
    }
    PageChange change = PageChange.getInstance(m.getValue());

    return new ChangeReportPageAction(owner, handle, choices, change);

}

From source file:net.unicon.academus.apps.messaging.engine.ComposeMessageAction.java

License:Open Source License

public static IAction parse(Element e, IWarlockFactory owner) throws WarlockException {

    // Assertions.
    if (e == null) {
        String msg = "Argument 'e [Element]' cannot be null.";
        throw new IllegalArgumentException(msg);
    }/*from w  ww .  ja  v a  2 s.  c  o  m*/
    if (!e.getName().equals("action")) {
        String msg = "Argument 'e [Element]' must be an <action> element.";
        throw new IllegalArgumentException(msg);
    }
    if (owner == null) {
        String msg = "Argument 'owner' cannot be null.";
        throw new IllegalArgumentException(msg);
    }

    // Handle.
    Attribute h = e.attribute("handle");
    if (h == null) {
        String msg = "Element <action> is missing required attribute " + "'handle'.";
        throw new XmlFormatException(msg);
    }
    Handle handle = Handle.create(h.getValue());

    // Choices.
    String[] choices = new String[0];
    Attribute p = e.attribute("inpt");
    if (p != null) {
        choices = p.getValue().split(",");
    }

    // Mode (Edit or Preview).
    String mode = "edit";
    p = e.attribute("mode");
    if (p != null) {
        mode = p.getValue().toLowerCase();
    }

    return new ComposeMessageAction(owner, handle, choices, mode);

}