List of usage examples for org.dom4j Element attribute
Attribute attribute(QName qName);
From source file:net.unicon.academus.apps.messaging.engine.MessageReportViewAction.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 . 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 MessageReportViewAction(owner, handle, choices); }
From source file:net.unicon.academus.apps.messaging.engine.NextPrevMessageAction.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 .j a va 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(","); } // Move. Attribute m = e.attribute("move"); if (m == null) { String msg = "Element <action> is missing required attribute " + "'mode'."; throw new XmlFormatException(msg); } String move = m.getValue(); return new NextPrevMessageAction(owner, handle, choices, move); }
From source file:net.unicon.academus.apps.messaging.engine.ReadMessageAction.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 ww 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(","); } String mode = null; h = e.attribute("mode"); if (h != null) { mode = h.getValue(); } return new ReadMessageAction(owner, handle, choices, mode); }
From source file:net.unicon.academus.apps.messaging.engine.ReadMessageQuery.java
License:Open Source License
private String resolveActions(String actions) { String rslt = null;/*from w ww . j a va 2 s . c om*/ Map callbackActions = new HashMap(); try { Element e = (new SAXReader()).read(new StringReader(actions)).getRootElement(); if (e.getName().equals("external-action")) { URL url = generateUrl(e); //System.out.println("Url: "+url.toString()); InputStream is = url.openStream(); rslt = bufferStream(is); } } catch (Exception ex) { ex.printStackTrace(System.err); rslt = null; } //System.out.println("resolveActions(): rslt = "+rslt); if (rslt != null) { try { // Parse the response Element e = (new SAXReader()).read(new StringReader(rslt)).getRootElement(); StringBuffer buf = new StringBuffer(); Element e2 = (Element) e.selectSingleNode("label"); if (e2 != null) buf.append(e2.asXML()); e2 = (Element) e.selectSingleNode("description"); if (e2 != null) buf.append(e2.asXML()); List elist = e.selectNodes("user-action"); Iterator it = elist.iterator(); while (it.hasNext()) { Element el = (Element) it.next(); Attribute handle = el.attribute("handle"); if (handle == null) throw new IllegalArgumentException("Attribute 'handle' required on <user-action>"); URL url = generateUrl(el); //System.out.println("[CallbackAction] Handle: "+handle.getValue()+" Url: "+url.toString()); callbackActions.put(handle.getValue(), url); // Now generate the part for the screen... buf.append("<option handle=\"").append(handle.getValue()).append("\">") .append(el.selectSingleNode("label").asXML()) .append(el.selectSingleNode("description").asXML()).append("</option>"); } elist = e.selectNodes("message"); it = elist.iterator(); while (it.hasNext()) { Element el = (Element) it.next(); buf.append("<message>").append(EntityEncoder.encodeEntities(el.getText())).append("</message>"); } rslt = buf.toString(); } catch (Exception ex) { ex.printStackTrace(System.err); rslt = null; } } muc.setCallbackActions(callbackActions); return rslt; }
From source file:net.unicon.academus.apps.messaging.engine.ReadMessageQuery.java
License:Open Source License
private URL generateUrl(Element e) throws Exception { Attribute t = e.attribute("ref"); if (t == null) throw new IllegalArgumentException("Attribute 'ref' required"); String loc = muc.getAppContext().getCallbackLocation(t.getValue()); if (loc == null) throw new IllegalStateException("Unable to resolve callback reference: " + t.getValue()); StringBuffer query = new StringBuffer(); final String sep = "&"; final String map = "="; List params = e.selectNodes("param"); Iterator it = params.iterator(); Attribute name = null;/*w ww . j a v a 2 s. c om*/ Attribute val = null; Element p = null; if (it.hasNext()) { p = (Element) it.next(); name = p.attribute("name"); val = p.attribute("value"); query.append(name.getValue()).append(map).append(val.getValue()); } while (it.hasNext()) { p = (Element) it.next(); name = p.attribute("name"); val = p.attribute("value"); query.append(sep).append(name.getValue()).append(map).append(val.getValue()); } return new URL(loc + "?" + query.toString()); }
From source file:net.unicon.academus.apps.messaging.engine.ReturnViewAction.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 a va2s . 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]; return new ReturnViewAction(owner, handle, choices); }
From source file:net.unicon.academus.apps.messaging.engine.SaveMessageAction.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. jav a2 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()); // to-screen. Attribute t = e.attribute("to-screen"); if (t == null) { String msg = "Element <action> is missing required attribute " + "'to-screen'."; throw new XmlFormatException(msg); } String toScreen = t.getValue(); // Choices. String[] choices = new String[0]; Attribute p = e.attribute("inpt"); if (p != null) { choices = p.getValue().split(","); } return new SaveMessageAction(owner, handle, choices, toScreen); }
From source file:net.unicon.academus.apps.messaging.engine.SendMessageAction.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. j a v a 2s .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) throw new XmlFormatException("ComposeNavigateAction requires attribute 'inpt'."); choices = p.getValue().split(","); return new SendMessageAction(owner, handle, choices); }
From source file:net.unicon.academus.apps.messaging.engine.SetMessageItemsPerPageAction.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 ww w . ja 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 SetMessageItemsPerPageAction(owner, handle, choices); }
From source file:net.unicon.academus.apps.messaging.engine.SetReportItemsPerPageAction.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 . 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 SetReportItemsPerPageAction(owner, handle, choices); }