List of usage examples for org.dom4j DocumentHelper parseText
public static Document parseText(String text) throws DocumentException
parseText
parses the given text as an XML document and returns the newly created Document.
From source file:org.springfield.flanders.homer.LazyHomer.java
License:Open Source License
private static void readMounts() { mounts = new HashMap<String, MountProperties>(); ServiceInterface smithers = ServiceManager.getService("smithers"); if (smithers == null) { LOG.error("No smithers found to get mount properties!"); return;/*from ww w . j a v a 2 s . c o m*/ } String mountslist = smithers.get("/domain/internal/service/flanders/mounts", null, null); System.out.println(mountslist); try { Document result = DocumentHelper.parseText(mountslist); for (Iterator<Node> iter = result.getRootElement().nodeIterator(); iter.hasNext();) { Element child = (Element) iter.next(); if (!child.getName().equals("properties")) { String name = child.attributeValue("id"); String hostname = child.selectSingleNode("properties/hostname") == null ? "" : child.selectSingleNode("properties/hostname").getText(); String path = child.selectSingleNode("properties/path") == null ? "" : child.selectSingleNode("properties/path").getText(); String account = child.selectSingleNode("properties/account") == null ? "" : child.selectSingleNode("properties/account").getText(); String password = child.selectSingleNode("properties/password") == null ? "" : child.selectSingleNode("properties/password").getText(); String protocol = child.selectSingleNode("properties/protocol") == null ? "" : child.selectSingleNode("properties/protocol").getText(); String ffmpegPath = child.selectSingleNode("properties/ffmpegpath") == null ? "" : child.selectSingleNode("properties/ffmpegpath").getText(); MountProperties mp = new MountProperties(); mp.setHostname(hostname); mp.setPath(path); mp.setAccount(account); mp.setPassword(password); mp.setProtocol(protocol); mp.setFfmpegPath(ffmpegPath); mounts.put(name, mp); } } } catch (DocumentException e) { LOG.info("LazyHomer: " + e.getMessage()); } }
From source file:org.springfield.flanders.restlet.FlandersResource.java
License:Open Source License
@Post public void handlePost(Representation representation) { String xml = ""; log.info("entering the POST!!!!!"); try {/*from w ww . ja v a 2s .com*/ if (representation == null) { getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST); getResponse().setEntity("<status>Error: the request data could not be read</status>", MediaType.TEXT_XML); } else { xml = representation.getText(); } } catch (IOException e2) { e2.printStackTrace(); return; } System.out.println("REPRESENTATION: " + xml); if (representation != null && xml != null) { Document document = null; try { document = DocumentHelper.parseText(xml); } catch (DocumentException e1) { e1.printStackTrace(); } Node node = document.selectSingleNode("//root"); String mount = node.valueOf("mount"); String source = node.valueOf("source"); String stream = node.valueOf("stream"); String filename = node.valueOf("file"); String mjpegIndex = node.valueOf("index"); if (mjpegIndex != null && mjpegIndex.equals("true") && mount != null && source != null) { MountProperties mp = LazyHomer.getMountProperties(mount); if (mp != null) { String response = MjpegIndexer.extractMetaData(source, mp.getPath()); getResponse().setEntity(new StringRepresentation(response)); } else { getResponse().setStatus(Status.SERVER_ERROR_INTERNAL); getResponse().setEntity("<status>Error: internal mount properties not found</status>", MediaType.TEXT_XML); } } else if (source != null && mount != null) { if (!mount.equals("")) { MountProperties mp = LazyHomer.getMountProperties(mount); if (mp.getProtocol().equals("file")) { source = mp.getPath() + source; } else if (mp.getProtocol().equals("ftp")) { /** get the video file from streaming machines to the the flanders server */ String fileName = source.substring(source.lastIndexOf("/") + 1); String rawUri = source.substring(0, source.lastIndexOf("/")); String vidUri = rawUri.substring(0, rawUri.lastIndexOf("/rawvideo/") + 1); if (getVideoByFtp(mp.getHostname(), mp.getAccount(), mp.getPassword(), fileName, mp.getPath(), rawUri, vidUri)) { source = mp.getPath() + vidUri + File.separator + fileName; } } } String ext = FileHelper.getFileExtension(source); if (ext != null) { String response = FfprobeMetaDataExtractor.extractMetaData(source); getResponse().setEntity(new StringRepresentation(response)); } else { getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST); getResponse().setEntity("<status>Error: incorrect parameters</status>", MediaType.TEXT_XML); } } else if (stream != null && filename != null) { String response = RtmpdumpMetadataExtractor.extractMetaData(stream, filename); getResponse().setEntity(new StringRepresentation(response)); } else { getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST); getResponse().setEntity("<status>Error: incorrect parameters</status>", MediaType.TEXT_XML); } } }
From source file:org.springfield.fs.Fs.java
License:Open Source License
public static FsNode getNode(String path) { FsNode result = new FsNode(); result.setPath(path);/* ww w . ja v a2 s . c o m*/ path += "/properties"; String xml = "<fsxml><properties><depth>0</depth></properties></fsxml>"; ServiceInterface smithers = ServiceManager.getService("smithers"); if (smithers == null) { System.out.println("org.springfield.fs.Fs : service not found smithers"); return null; } String node = smithers.get(path, xml, "text/xml"); if (node.indexOf("<error id=\"404\">") != -1) { return null; // node not found } try { Document doc = DocumentHelper.parseText(node); for (Iterator<Node> iter = doc.getRootElement().nodeIterator(); iter.hasNext();) { Element p = (Element) iter.next(); result.setName(p.getName()); result.setId(p.attribute("id").getText()); if (p.attribute("referid") != null) { String referid = p.attribute("referid").getText(); if (referid != null) result.setReferid(referid); } for (Iterator<Node> iter2 = p.nodeIterator(); iter2.hasNext();) { Element p2 = (Element) iter2.next(); if (p2.getName().equals("properties")) { for (Iterator<Node> iter3 = p2.nodeIterator(); iter3.hasNext();) { Object p3 = iter3.next(); if (p3 instanceof Element) { String pname = ((Element) p3).getName(); String pvalue = ((Element) p3).getText(); if (pvalue.indexOf("Solistai Laima") != -1) { System.out.println("D1=" + pvalue); System.out.println("D2=" + FsEncoding.decode(pvalue)); } result.setProperty(pname, FsEncoding.decode(pvalue)); } else { } } } } } } catch (Exception e) { e.printStackTrace(); } return result; }
From source file:org.springfield.fs.Fs.java
License:Open Source License
public static List<FsNode> getNodes(String path, int depth) { List<FsNode> result = new ArrayList<FsNode>(); String xml = "<fsxml><properties><depth>" + depth + "</depth></properties></fsxml>"; String nodes = ""; ServiceInterface smithers = ServiceManager.getService("smithers"); if (smithers == null) { System.out.println("org.springfield.fs.Fs : service not found smithers"); return null; }//from ww w . j a v a 2 s. c om nodes = smithers.get(path, xml, "text/xml"); path = path.substring(path.indexOf("/domain/")); if (nodes.indexOf("<error id=\"404\">") != -1) { return null; // node not found } LOG.debug("nodes " + nodes); try { Document doc = DocumentHelper.parseText(nodes); if (isMainNode(path)) { for (Iterator<Node> iter = doc.getRootElement().nodeIterator(); iter.hasNext();) { Element node = (Element) iter.next(); FsNode nn = new FsNode(); if (!node.getName().equals("properties")) { nn.setName(node.getName()); nn.setId(node.attribute("id").getText()); nn.setPath(path + "/" + nn.getName() + "/" + nn.getId()); if (node.attribute("referid") != null) { String referid = node.attribute("referid").getText(); if (referid != null) nn.setReferid(referid); } result.add(nn); for (Iterator<Node> iter2 = node.nodeIterator(); iter2.hasNext();) { Element p2 = (Element) iter2.next(); if (p2.getName().equals("properties")) { for (Iterator<Node> iter3 = p2.nodeIterator(); iter3.hasNext();) { Object o = iter3.next(); if (o instanceof Element) { Element p3 = (Element) o; String pname = p3.getName(); String pvalue = p3.getText(); nn.setProperty(pname, FsEncoding.decode(pvalue)); } } } } } } } else { //System.out.println("IS SUBNODE"); for (Iterator<Node> iter = doc.getRootElement().nodeIterator(); iter.hasNext();) { Element node = (Element) iter.next(); for (Iterator<Node> iter2 = node.nodeIterator(); iter2.hasNext();) { Element node2 = (Element) iter2.next(); FsNode nn = new FsNode(); if (!node2.getName().equals("properties")) { nn.setName(node2.getName()); nn.setId(node2.attribute("id").getText()); nn.setPath(path + "/" + nn.getName() + "/" + nn.getId()); for (Iterator<Node> iter3 = node2.nodeIterator(); iter3.hasNext();) { Element p2 = (Element) iter3.next(); if (p2.getName().equals("properties")) { for (Iterator<Node> iter4 = p2.nodeIterator(); iter4.hasNext();) { Object o = iter4.next(); if (o instanceof Element) { Element p3 = (Element) o; String pname = p3.getName(); String pvalue = p3.getText(); if (pvalue.indexOf("Solistai Laima") != -1) { System.out.println("D1=" + pvalue); System.out.println("D2=" + FsEncoding.decode(pvalue)); } nn.setProperty(pname, FsEncoding.decode(pvalue)); } } } } result.add(nn); } } } } } catch (Exception e) { e.printStackTrace(); } return result; }
From source file:org.springfield.fs.Fs.java
License:Open Source License
public static FSList getReferParents(String path) { ServiceInterface smithers = ServiceManager.getService("smithers"); if (smithers == null) { System.out.println("org.springfield.fs.Fs : service not found smithers"); return null; }// www.jav a2 s .c o m String body = "<fsxml mimetype=\"application/fscommand\" id=\"showrefs\">"; body += "<properties>"; body += "</properties>"; body += "</fsxml>"; System.out.println("PATH=" + path); System.out.println("BODY3=" + body); //String result = LazyHomer.sendRequestBart("POST",currentpath,body,"text/xml"); String result = smithers.post(path, body, "application/fscommand"); System.out.println("R=" + result); FSList list = new FSList(); try { Document doc = DocumentHelper.parseText(result); if (doc != null) { for (Iterator<Node> iter = doc.getRootElement().nodeIterator(); iter.hasNext();) { Element node = (Element) iter.next(); System.out.println("PAR NAME=" + node.getName()); String parentpath = node.getText(); System.out.println("PAR2 NAME=" + parentpath); FsNode parent = Fs.getNode(parentpath); System.out.println("PAR3b NAME=" + parent); if (parent != null) { list.addNode(parent); } else { System.out.println("Mojo : can't load refering node " + parentpath); } } System.out.println("PAR4 NAME=" + list.size()); return list; } } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:org.springfield.fs.FSListManager.java
License:Open Source License
public static List<FsNode> getNodes(String path, int depth, int start, int limit) { //System.out.println("T="+new Date().getTime()); List<FsNode> result = new ArrayList<FsNode>(); String limitStr = ""; if (limit > 0) { limitStr = "<limit>" + limit + "</limit>"; }//from w w w . j a v a2 s . c o m String xml = "<fsxml><properties><start>" + start + "</start>" + limitStr + "<depth>" + depth + "</depth></properties></fsxml>"; String nodes = ""; if (path.indexOf("http://") == -1) { //danielfix nodes = LazyHomer.sendRequestBart("GET",path,xml,"text/xml"); ServiceInterface smithers = ServiceManager.getService("smithers"); if (smithers == null) { System.out.println("org.springfield.fs.FSListManager : service not found smithers"); return null; } //System.out.println("GET MEM="+path); nodes = smithers.get(path, xml, "text/xml"); if (nodes != null) { //System.out.println("NODES MEMORY SIZE="+nodes.length()+" PATH="+path); } else { System.out.println("EMPTY GET ON=" + path); } } else { nodes = HttpHelper.sendRequest("GET", path, "text/xml", "text/xml").toString(); path = path.substring(path.indexOf("/domain/")); } try { Document doc = DocumentHelper.parseText(nodes); if (isMainNode(path)) { for (Iterator<Node> iter = doc.getRootElement().nodeIterator(); iter.hasNext();) { Element node = (Element) iter.next(); FsNode nn = new FsNode(); if (!node.getName().equals("properties")) { nn.setName(node.getName()); nn.setId(node.attribute("id").getText()); nn.setPath(path + "/" + nn.getId()); if (node.attribute("referid") != null) { nn.setReferid(node.attribute("referid").getText()); } result.add(nn); for (Iterator<Node> iter3 = node.nodeIterator(); iter3.hasNext();) { Element p2 = (Element) iter3.next(); if (p2.getName().equals("properties")) { for (Iterator<Node> iter4 = p2.nodeIterator(); iter4.hasNext();) { Object o = iter4.next(); if (o instanceof Element) { Element p3 = (Element) o; String pname = p3.getName(); String pvalue = p3.getText(); //System.out.println("NODE NAME="+pname+" "+pvalue); nn.setProperty(pname, FsEncoding.decode(pvalue)); } } } } } else { // so this is the property node } } } else { for (Iterator<Node> iter = doc.getRootElement().nodeIterator(); iter.hasNext();) { Element node = (Element) iter.next(); for (Iterator<Node> iter2 = node.nodeIterator(); iter2.hasNext();) { Element node2 = (Element) iter2.next(); FsNode nn = new FsNode(); if (!node2.getName().equals("properties")) { //System.out.println("NAME2="+node2.getName()); nn.setName(node2.getName()); nn.setId(node2.attribute("id").getText()); nn.setPath(path + "/" + nn.getName() + "/" + nn.getId()); if (node.attribute("referid") != null) { nn.setReferid(node.attribute("referid").getText()); } result.add(nn); for (Iterator<Node> iter3 = node2.nodeIterator(); iter3.hasNext();) { Element p2 = (Element) iter3.next(); if (p2.getName().equals("properties")) { for (Iterator<Node> iter4 = p2.nodeIterator(); iter4.hasNext();) { Object o = iter4.next(); if (o instanceof Element) { Element p3 = (Element) o; String pname = p3.getName(); String pvalue = p3.getText(); nn.setProperty(pname, FsEncoding.decode(pvalue)); } } } } } } } } } catch (Exception e) { e.printStackTrace(); } //System.out.println("T2="+new Date().getTime()); return result; }
From source file:org.springfield.fs.FsNode.java
License:Open Source License
public static FsNode parseFsNode(String fsxml) { try {//from w w w . j a va 2s . c o m FsNode newnode = new FsNode(); Document doc = DocumentHelper.parseText(fsxml); if (doc != null) { Element rootnode = doc.getRootElement(); String name = rootnode.getName(); String id = rootnode.attributeValue("id"); //System.out.println("PARSE NODE NAME="+name+" ID="+id); newnode.setName(name); newnode.setId(id); for (Iterator<Node> iter = doc.getRootElement().nodeIterator(); iter.hasNext();) { Element node = (Element) iter.next(); //System.out.print("NAME="+node.getName()); if (node.getName().equals("properties")) { for (Iterator<Node> iter2 = node.nodeIterator(); iter2.hasNext();) { Node node2 = iter2.next(); if (node2 instanceof Element) { Element child2 = (Element) node2; String pname = child2.getName(); String pvalue = child2.getText(); newnode.setProperty(pname, pvalue); //System.out.println("PARSED NODE PNAME="+pname+" PVALUE="+pvalue); } } } } } return newnode; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:org.springfield.kodos.homer.LazyHomer.java
License:Open Source License
private Boolean checkKnown() { String xml = "<fsxml><properties><depth>1</depth></properties></fsxml>"; ServiceInterface smithers = ServiceManager.getService("smithers"); if (smithers == null) return false; String nodes = smithers.get("/domain/internal/service/kodos/nodes", xml, "text/xml"); boolean iamok = false; try {/*from w ww .j a v a2s .c om*/ boolean foundmynode = false; Document result = DocumentHelper.parseText(nodes); for (Iterator<Node> iter = result.getRootElement().nodeIterator(); iter.hasNext();) { Element child = (Element) iter.next(); if (!child.getName().equals("properties")) { String ipnumber = child.attributeValue("id"); String status = child.selectSingleNode("properties/status").getText(); String name = child.selectSingleNode("properties/name").getText(); // lets put all in our kodos list KodosProperties mp = kodoss.get(ipnumber); if (mp == null) { mp = new KodosProperties(); kodoss.put(ipnumber, mp); } mp.setIpNumber(ipnumber); mp.setName(name); mp.setStatus(status); mp.setDefaultLogLevel(child.selectSingleNode("properties/defaultloglevel").getText()); mp.setPreferedSmithers(child.selectSingleNode("properties/preferedsmithers").getText()); if (ipnumber.equals(myip)) { foundmynode = true; if (name.equals("unknown")) { System.out.println( "This kodos is not verified change its name, use smithers todo this for ip " + myip); } else { // so we have a name (verified) return true iamok = true; } } } } if (!foundmynode) { if (retryCounter < 30) { //retry 30 times (= 5 min) to handle temp smithers downtime (eg daily restarts) retryCounter++; } else { LOG.info("LazyHomer : Creating my processing node " + LazyHomer.getSmithersUrl() + "/domain/internal/service/kodos/properties"); String os = "unknown"; // we assume windows ? try { os = System.getProperty("os.name"); } catch (Exception e) { System.out.println("LazyHomer : " + e.getMessage()); } String newbody = "<fsxml>"; newbody += "<nodes id=\"" + myip + "\"><properties>"; newbody += "<name>unknown</name>"; newbody += "<status>off</status>"; newbody += "<activesmithers>" + selectedsmithers.getIpNumber() + "</activesmithers>"; newbody += "<lastseen>" + new Date().getTime() + "</lastseen>"; newbody += "<preferedsmithers>" + myip + "</preferedsmithers>"; if (isWindows()) { newbody += "<defaultloglevel>info</defaultloglevel>"; newbody += "<temporarydirectory>c:\\springfield\\kodos\\temp</temporarydirectory>"; } if (isMac()) { newbody += "<defaultloglevel>info</defaultloglevel>"; newbody += "<temporarydirectory>/springfield/kodos/temp</temporarydirectory>"; } if (isUnix()) { newbody += "<defaultloglevel>info</defaultloglevel>"; newbody += "<temporarydirectory>/springfield/kodos/temp</temporarydirectory>"; } else { newbody += "<defaultloglevel>info</defaultloglevel>"; newbody += "<temporarydirectory>c:\\springfield\\kodos\\temp</temporarydirectory>"; } newbody += "</properties></nodes></fsxml>"; smithers.put("/domain/internal/service/kodos/properties", newbody, "text/xml"); } } } catch (Exception e) { LOG.info("LazyHomer exception doc"); e.printStackTrace(); } return iamok; }
From source file:org.springfield.lenny.homer.LazyHomer.java
License:Open Source License
private Boolean checkKnown() { String xml = "<fsxml><properties><depth>1</depth></properties></fsxml>"; ServiceInterface smithers = ServiceManager.getService("smithers"); if (smithers == null) return false; String nodes = smithers.get("/domain/internal/service/lenny/nodes", xml, "text/xml"); boolean iamok = false; try {//w ww. jav a 2 s. c o m boolean foundmynode = false; Document result = DocumentHelper.parseText(nodes); for (Iterator<Node> iter = result.getRootElement().nodeIterator(); iter.hasNext();) { Element child = (Element) iter.next(); if (!child.getName().equals("properties")) { String ipnumber = child.attributeValue("id"); String status = child.selectSingleNode("properties/status").getText(); String name = child.selectSingleNode("properties/name").getText(); // lets put all in our lennies list LennyProperties mp = lennies.get(ipnumber); if (mp == null) { mp = new LennyProperties(); lennies.put(ipnumber, mp); } mp.setIpNumber(ipnumber); mp.setName(name); mp.setStatus(status); mp.setDefaultLogLevel(child.selectSingleNode("properties/defaultloglevel").getText()); mp.setPreferedSmithers(child.selectSingleNode("properties/preferedsmithers").getText()); mp.setApiKey(apiKey); if (ipnumber.equals(myip)) { foundmynode = true; retryCounter = 0; if (name.equals("unknown")) { System.out.println( "This lenny is not verified change its name, use smithers todo this for ip " + myip); } else { // so we have a name (verified) return true iamok = true; } } } } if (!foundmynode) { if (retryCounter < 30) { //retry 30 times (= 5 min) to handle temp smithers downtime (eg daily restarts) retryCounter++; } else { LOG.info("LazyHomer : Creating my processing node " + LazyHomer.getSmithersUrl() + "/domain/internal/service/lenny/properties"); String os = "unknown"; // we assume windows ? try { os = System.getProperty("os.name"); } catch (Exception e) { System.out.println("LazyHomer : " + e.getMessage()); } String newbody = "<fsxml><properties>"; newbody += "<info>Transcoding nodes</info></properties>"; newbody += "<nodes id=\"" + myip + "\"><properties>"; newbody += "<name>unknown</name>"; newbody += "<status>off</status>"; newbody += "<activesmithers>" + selectedsmithers.getIpNumber() + "</activesmithers>"; newbody += "<lastseen>" + new Date().getTime() + "</lastseen>"; newbody += "<preferedsmithers>" + myip + "</preferedsmithers>"; newbody += "<apikey/>"; newbody += "<defaultloglevel>info</defaultloglevel>"; newbody += "</properties></nodes></fsxml>"; smithers.put("/domain/internal/service/lenny/properties", newbody, "text/xml"); } } } catch (Exception e) { LOG.info("LazyHomer exception doc"); e.printStackTrace(); } return iamok; }
From source file:org.springfield.lenny.restlet.LennyResource.java
License:Open Source License
/** * Add a ticket /*w ww . j a va 2s .c o m*/ * * @param body * @return */ private Pair<Status, String> addTicket(String fsxml) { String ticket, uri, ip, role; String[] uriArray; ticket = uri = ip = role = ""; long expiry = 0L; int maxRequests = Integer.MAX_VALUE; Pair<Status, String> r; try { Document doc = DocumentHelper.parseText(fsxml); ticket = doc.selectSingleNode("/fsxml/properties/ticket") == null ? "" : doc.selectSingleNode("/fsxml/properties/ticket").getText(); uri = doc.selectSingleNode("/fsxml/properties/uri") == null ? "" : doc.selectSingleNode("/fsxml/properties/uri").getText(); ip = doc.selectSingleNode("/fsxml/properties/ip") == null ? "" : doc.selectSingleNode("/fsxml/properties/ip").getText(); role = doc.selectSingleNode("/fsxml/properties/role") == null ? "" : doc.selectSingleNode("/fsxml/properties/role").getText(); expiry = doc.selectSingleNode("/fsxml/properties/expiry") == null ? 0L : Long.parseLong(doc.selectSingleNode("/fsxml/properties/expiry").getText()); maxRequests = doc.selectSingleNode("/fsxml/properties/maxRequests") == null ? Integer.MAX_VALUE : Integer.parseInt(doc.selectSingleNode("/fsxml/properties/maxRequests").getText()); } catch (Exception e) { e.printStackTrace(); logger.error("error " + e.getMessage()); r = new Pair<Status, String>(Status.CLIENT_ERROR_BAD_REQUEST, property2fsxml("status", "Bad request")); return r; } uriArray = new String[] { uri }; //correct full uris to relative uris if (uri.indexOf(".noterik.com/progressive/") > -1) { uri = uri.substring(uri.indexOf("/domain/")); } if (uri.indexOf("/collection/") > -1 && uri.indexOf("/presentation/") > -1) { //resolve collection presentation, can contain multiple videos logger.info("Getting videos for " + uri); String[] tmpArray = new String[] { uri }; ServiceInterface smithers = ServiceManager.getService("smithers"); if (smithers != null) { String response = smithers.get(uri, null, null); logger.debug("collection presentation response = " + response); // parse Document doc = null; try { doc = DocumentHelper.parseText(response); } catch (DocumentException e) { logger.error("Could not parse collection respopnse from smithers", e); } if (doc != null) { String presentation = doc.selectSingleNode("//presentation/@referid") == null ? "" : doc.selectSingleNode("//presentation/@referid").getText(); response = smithers.get(presentation, null, null); logger.debug("presentation response = " + response); try { doc = DocumentHelper.parseText(response); } catch (DocumentException e) { logger.error("Could not parse presentation respopnse from smithers", e); } if (doc != null) { List<Node> videos = doc.selectNodes("//videoplaylist/video/@referid"); List<Node> audios = doc.selectNodes("//videoplaylist/audio/@referid"); tmpArray = new String[videos.size() + audios.size()]; int j = 0; for (Iterator<Node> i = videos.iterator(); i.hasNext();) { tmpArray[j] = i.next().getText(); logger.debug("Adding " + tmpArray[j]); j++; } for (Iterator<Node> i = audios.iterator(); i.hasNext();) { tmpArray[j] = i.next().getText(); logger.debug("Adding " + tmpArray[j]); j++; } } } uriArray = tmpArray; } } if (ticket.equals("") || uriArray.length == 0 || ip.equals("") || role.equals("") || expiry == 0L) { logger.error("Error in ticket: t=" + ticket + " u=" + Arrays.toString(uriArray) + " i=" + ip + " r=" + role + " e=" + expiry); r = new Pair<Status, String>(Status.CLIENT_ERROR_BAD_REQUEST, property2fsxml("status", "Bad request")); return r; } AccessListEntry entry = new AccessListEntry(uriArray, ip, role, expiry, maxRequests); accesslist.put(ticket, entry); logger.info("Added ticket [" + ticket + ", " + uriArray.toString() + ", " + ip + ", " + role + ", " + expiry + ", " + maxRequests + "]"); r = new Pair<Status, String>(Status.SUCCESS_OK, property2fsxml("status", "Successfully added")); return r; }