List of usage examples for org.dom4j Element addAttribute
Element addAttribute(QName qName, String value);
From source file:com.noterik.bart.fs.action.PresentationIndexQueueAction.java
License:Open Source License
private void addJob(String presentationUri, String eventUri) { /* only add valid presentations */ if (presentationUri.startsWith("/")) { long timestamp = new Date().getTime(); Document xml = DocumentFactory.getInstance().createDocument(); Element fsxml = xml.addElement("fsxml"); Element properties = fsxml.addElement("properties"); properties.addElement("presentation").addText(presentationUri); properties.addElement("priority").addText(String.valueOf(getPriority(eventUri))); properties.addElement("timestamp").addText(String.valueOf(timestamp)); Element presentation = fsxml.addElement("presentation"); presentation.addAttribute("id", "1"); presentation.addAttribute("referid", presentationUri); logger.debug(xml.asXML());/*from ww w . ja v a2 s. c o m*/ logger.debug(queueUri); FSXMLRequestHandler.instance().handlePOST(queueUri, xml.asXML()); } }
From source file:com.noterik.bart.fs.fscommand.dynamic.config.flash.java
License:Open Source License
private void addPlayer(Node configNode) { List<Node> players = configNode.selectNodes("//player"); for (Iterator<Node> iter = players.iterator(); iter.hasNext();) { Element player = (Element) iter.next(); String refer = player.selectSingleNode("@referid") == null ? "" : player.selectSingleNode("@referid").getText(); if (!refer.equals("")) { Document playerXml = FSXMLRequestHandler.instance().getNodeProperties(refer, false); if (playerXml != null) { Element p = (Element) playerXml.selectSingleNode("fsxml/player").detach(); p.addAttribute("fullid", refer); fsxml.add(p);//from w ww . j a va 2 s . c o m } } } }
From source file:com.noterik.bart.fs.fscommand.dynamic.presentation.playout.flash.java
License:Open Source License
private static List<Element> addPlayer(Node configNode) { List<Node> players = configNode.selectNodes("//player"); List<Element> result = new ArrayList<Element>(); for (Iterator<Node> iter = players.iterator(); iter.hasNext();) { Element player = (Element) iter.next(); String refer = player.selectSingleNode("@referid") == null ? "" : player.selectSingleNode("@referid").getText(); if (!refer.equals("")) { Document playerXml = cache.get(refer); if (playerXml == null && !cache.isEmpty(refer)) { playerXml = FSXMLRequestHandler.instance().getNodeProperties(refer, false); // daniel cache.put(refer, playerXml); }/*w w w . j av a2 s .co m*/ if (playerXml != null) { Element p = (Element) playerXml.selectSingleNode("fsxml/player").detach(); p.addAttribute("fullid", refer); result.add(p); } } } return result; }
From source file:com.noterik.bart.fs.fscommand.dynamic.presentation.playout.flash.java
License:Open Source License
private static Node getPresentation(String presentation) { Document pres = cache.get(presentation); if (pres == null) { pres = FSXMLRequestHandler.instance().getNodeProperties(presentation, false); cache.put(presentation, pres);/*from w ww .j a va 2s . c o m*/ } String refer = ""; if (pres != null) { refer = pres.selectSingleNode("fsxml/presentation/@referid") == null ? "" : pres.selectSingleNode("fsxml/presentation/@referid").getText(); if (refer != "") { pres = cache.get(refer); if (pres == null) { pres = FSXMLRequestHandler.instance().getNodeProperties(refer, false); cache.put(refer, pres); } } } if (pres != null) { Element pr = (Element) pres.selectSingleNode("fsxml/presentation").detach(); if (!refer.equals("")) { pr.addAttribute("fullid", refer); return pr; } return pr; } return null; }
From source file:com.noterik.bart.fs.fscommand.dynamic.presentation.playout.flash.java
License:Open Source License
private static List<Element> addVideos(Node presentationNode) { List<Node> videos = presentationNode.selectNodes("//videoplaylist/video"); ArrayList<String> refers = new ArrayList<String>(videos.size()); List<Element> vids = new ArrayList<Element>(); for (Iterator<Node> iter = videos.iterator(); iter.hasNext();) { Element video = (Element) iter.next(); String refer = video.selectSingleNode("@referid") == null ? "" : video.selectSingleNode("@referid").getText(); logger.debug("getting video " + refer); if (!refer.equals("") && !refers.contains(refer)) { refers.add(refer);/*from ww w .j a v a2s . com*/ Document videoXml = cache.get(refer); if (videoXml == null) { videoXml = FSXMLRequestHandler.instance().getNodeProperties(refer, false); cache.put(refer, videoXml); } if (videoXml != null) { Element vid = (Element) videoXml.selectSingleNode("fsxml/video").detach(); vid.addAttribute("fullid", refer); //System.out.println("U="+vid.asXML()); vids.add(vid); } } } return vids; }
From source file:com.noterik.bart.fs.fscommand.dynamic.video.playout.flash.java
License:Open Source License
private static Node getVideo(String video) { Document vid = cache.get(video); if (vid == null) { vid = FSXMLRequestHandler.instance().getNodeProperties(video, false); cache.put(video, vid);//from w w w. j av a2 s . c o m } String refer = ""; if (vid != null) { refer = vid.selectSingleNode("fsxml/video/@referid") == null ? "" : vid.selectSingleNode("fsxml/video/@referid").getText(); if (refer != "") { vid = cache.get(refer); if (vid == null) { vid = FSXMLRequestHandler.instance().getNodeProperties(refer, false); cache.put(refer, vid); } } } if (vid != null) { Element v = (Element) vid.selectSingleNode("fsxml/video").detach(); if (!refer.equals("")) { v.addAttribute("fullid", refer); } else { v.addAttribute("fullid", video); } return v; } return null; }
From source file:com.noterik.bart.fs.fscommand.dynamic.video.playout.flash.java
License:Open Source License
private static Element addPlaceholderPresentation(String uri) { Document xml = DocumentHelper.createDocument(); Element presentation = xml.addElement("presentation"); presentation.addAttribute("id", "1"); String baseUri = uri.substring(0, uri.lastIndexOf("/video/")); presentation.addAttribute("fullid", baseUri + "/presentation/1"); Element properties = presentation.addElement("properties"); properties.addEntity("title", "test title"); properties.addEntity("description", "test description"); Element videoplaylist = presentation.addElement("videoplaylist"); videoplaylist.addAttribute("id", "1"); videoplaylist.addElement("properties"); Element vid = videoplaylist.addElement("video"); vid.addAttribute("id", "1"); vid.addAttribute("referid", uri); return presentation; }
From source file:com.noterik.bart.fs.fscommand.ResolutionMetaCommand.java
License:Open Source License
private Element createMeta(String input) { String basePath = "/springfield/smithers/data/"; if (LazyHomer.isWindows()) { basePath = "c:\\springfield\\smithers\\data\\"; }//from ww w .j av a 2s. c om File srcFolder = new File(basePath + input); if (!srcFolder.exists()) return null; if (!srcFolder.isDirectory()) return null; File[] metafiles = srcFolder.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { if (name.equals(".") || name.equals("..")) { return false; } if (name.toUpperCase().endsWith(".META")) { return true; } return false; } }); Element metanode = DocumentHelper.createElement("resolutionmeta"); // set the id and aim it to our original video metanode.addAttribute("id", "1"); // create the properties and set them (this can be done easer?) Element p = DocumentHelper.createElement("properties"); Element dataunits = DocumentHelper.createElement("dataunits"); //Element availableinputs = DocumentHelper.createElement("inputs"); String body = "<![CDATA["; String sep = ""; body += "{"; for (int i = 0; i < metafiles.length; i++) { File f = metafiles[i]; Properties meta = readMetaFile(f); String filename = f.getName(); String name = filename.substring(0, filename.lastIndexOf(".")); if (meta.getProperty("startmeasurement") != null) { body += sep + "\"" + name + "\" : { \"name\" : \"" + meta.getProperty("name") + "\", \"unit\" : \"" + meta.getProperty("unit") + "\", \"startmeasurement\" : \"" + meta.getProperty("startmeasurement") + "\", \"endmeasurement\" : \"" + meta.getProperty("endmeasurement") + "\"}"; } else { body += sep + "\"" + name + "\" : { \"name\" : \"" + meta.getProperty("name") + "\", \"unit\" : \"" + meta.getProperty("unit") + "\"}"; } sep = ","; } body += "}"; body += "]]>"; dataunits.setText(body); body = ""; sep = ""; for (inputs val : inputs.values()) { body += sep + val; sep = ","; } //availableinputs.setText(body); //p.add(availableinputs); p.add(dataunits); // add the properties to the video node so it plays just that part. metanode.add(p); return metanode; }
From source file:com.noterik.bart.fs.fscommand.ResolutionMetaCommand.java
License:Open Source License
private Element createMeta(String sbfFile, inputs input) { SBFReader sbfr = new SBFReader(sbfFile); Element metanode = DocumentHelper.createElement("resolutionmeta"); // set the id and aim it to our original video metanode.addAttribute("id", "1"); // create the properties and set them (this can be done easer?) Element p = DocumentHelper.createElement("properties"); Element dataunits = DocumentHelper.createElement("dataunits"); Element availableinputs = DocumentHelper.createElement("inputs"); String body = ""; SBFile dataFile = sbfr.getDataFile(); int cols = (int) dataFile.getColumnCount(); String sep = ""; body += "{";//from w w w . j av a2 s . c om for (int i = 1; i < cols; i++) { body += sep + "\"" + input + "_" + Integer.toString(i) + "\" : { \"name\" : \"" + dataFile.getDataColumns(i) + "\", \"unit\" : \"" + dataFile.getUnitColumns(i) + "\"}"; sep = ","; } body += "}"; sbfr = null; dataunits.setText(body); body = ""; sep = ""; for (inputs val : inputs.values()) { body += sep + val; sep = ","; } availableinputs.setText(body); p.add(availableinputs); p.add(dataunits); // add the properties to the video node so it plays just that part. metanode.add(p); return metanode; }
From source file:com.openedit.users.filesystem.FileSystemUserManager.java
License:Open Source License
public void saveUser(User user) throws UserManagerException { if (user.isVirtual()) { log.error("Cannot save virtual users: " + user.getUserName()); return;//from w w w . j a v a 2s .c o m } DocumentFactory factory = DocumentFactory.getInstance(); Document doc = factory.createDocument(); Element userElem = doc.addElement("user"); userElem.addAttribute("enabled", Boolean.toString(user.isEnabled())); if (user.getUserName() == null) { int id = getUserIdCounter().incrementCount(); String newid = String.valueOf(id); user.setId(newid); } Element userNameElem = userElem.addElement("user-name"); userNameElem.setText(user.getUserName()); Element passwordElem = userElem.addElement("password"); // if (user.getPassword() != null && !user.getPassword().equals("")) { String ps = user.getPassword(); ps = encrypt(ps); //password may have changed we should set it so it's not in plain text anymore. user.setPassword(ps); passwordElem.setText(ps); } Element creationDateElem = userElem.addElement("creation-date"); if (user.getCreationDate() != null) { creationDateElem.setText(String.valueOf(user.getCreationDate().getTime())); } else { creationDateElem.setText(String.valueOf(System.currentTimeMillis())); } //Tuan add property lastLogined-Time Element lastLoginTime = userElem.addElement("lastLogined-Time"); lastLoginTime.setText(DateStorageUtil.getStorageUtil().formatForStorage(new Date())); MapPropertyContainer map = (MapPropertyContainer) user.getPropertyContainer(); if (map != null) { Element propertiesElem = map.createPropertiesElement("properties"); userElem.add(propertiesElem); } if (user.getGroups() != null) { for (Iterator iter = user.getGroups().iterator(); iter.hasNext();) { Group group = (Group) iter.next(); Element child = userElem.addElement("group"); child.addAttribute("id", group.getId()); } } File file = loadUserFile(user.getUserName()); getXmlUtil().saveXml(doc, file); getUserNameToUserMap().put(user.getUserName(), user); }