List of usage examples for org.w3c.dom Element getAttributeNS
public String getAttributeNS(String namespaceURI, String localName) throws DOMException;
From source file:org.springframework.integration.config.xml.AbstractIntegrationNamespaceHandler.java
private static boolean matchesVersion(Element element) { String schemaLocation = element.getAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "schemaLocation"); return !StringUtils.hasText(schemaLocation) // no namespace on this element || schemaLocation.matches("(?m).*spring-integration-[a-z-]*" + VERSION + ".xsd.*") // correct version || schemaLocation.matches("(?m).*spring-integration[a-z-]*.xsd.*") // version-less schema || !schemaLocation.matches("(?m).*spring-integration.*"); // no spring-integration schemas }
From source file:org.springframework.security.config.SecurityNamespaceHandler.java
private boolean matchesVersionInternal(Element element) { String schemaLocation = element.getAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "schemaLocation"); return schemaLocation.matches("(?m).*spring-security-4\\.2.*.xsd.*") || schemaLocation.matches("(?m).*spring-security.xsd.*") || !schemaLocation.matches("(?m).*spring-security.*"); }
From source file:org.unitedinternet.cosmo.calendar.hcalendar.HCalendarParser.java
/** * Builds property.//from w w w.ja v a 2 s. c o m * @param element The element. * @param propName The prop name. * @param handler The content handler. * @throws ParserException - if something is wrong this exception is thrown. */ private void buildProperty(Element element, String propName, ContentHandler handler) throws ParserException { if (element == null) { return; } if (LOG.isDebugEnabled()) { LOG.debug("Building property " + propName); } String className = className(propName); String elementName = element.getLocalName().toLowerCase(CosmoConstants.LANGUAGE_LOCALE); String value = null; if (elementName.equals("abbr")) { // "If an <abbr> element is used for a property, then the 'title' // attribute of the <abbr> element is the value of the property, // instead of the contents of the element, which instead provide a // human presentable version of the value." value = element.getAttribute("title"); if (StringUtils.isBlank(value)) { throw new ParserException("Abbr element '" + className + "' requires a non-empty title", -1); } if (LOG.isDebugEnabled()) { LOG.debug("Setting value '" + value + "' from title attribute"); } } else if (isHeaderElement(elementName)) { // try title first. if that's not set, fall back to text content. value = element.getAttribute("title"); if (!StringUtils.isBlank(value)) { if (LOG.isDebugEnabled()) { LOG.debug("Setting value '" + value + "' from title attribute"); } } else { value = getTextContent(element); if (LOG.isDebugEnabled()) { LOG.debug("Setting value '" + value + "' from text content"); } } } else if (elementName.equals("a") && isUrlProperty(propName)) { value = element.getAttribute("href"); if (StringUtils.isBlank(value)) { throw new ParserException("A element '" + className + "' requires a non-empty href", -1); } if (LOG.isDebugEnabled()) { LOG.debug("Setting value '" + value + "' from href attribute"); } } else if (elementName.equals("img")) { if (isUrlProperty(propName)) { value = element.getAttribute("src"); if (StringUtils.isBlank(value)) { throw new ParserException("Img element '" + className + "' requires a non-empty src", -1); } if (LOG.isDebugEnabled()) { LOG.debug("Setting value '" + value + "' from src attribute"); } } else { value = element.getAttribute("alt"); if (StringUtils.isBlank(value)) { throw new ParserException("Img element '" + className + "' requires a non-empty alt", -1); } if (LOG.isDebugEnabled()) { LOG.debug("Setting value '" + value + "' from alt attribute"); } } } else { value = getTextContent(element); if (!StringUtils.isBlank(value) && LOG.isDebugEnabled()) { LOG.debug("Setting value '" + value + "' from text content"); } } if (StringUtils.isBlank(value) && LOG.isDebugEnabled()) { LOG.debug("Skipping property with empty value"); return; } handler.startProperty(propName); // if it's a date property, we have to convert from the // hCalendar-formatted date (RFC 3339) to an iCalendar-formatted date if (isDateProperty(propName)) { try { Date date = icalDate(value); value = date.toString(); if (!(date instanceof DateTime)) { try { handler.parameter(Parameter.VALUE, Value.DATE.getValue()); } catch (URISyntaxException e) { LOG.warn("", e); } } } catch (ParseException e) { throw new ParserException("Malformed date value for element '" + className + "'", -1, e); } } if (isTextProperty(propName)) { String lang = element.getAttributeNS(XMLConstants.XML_NS_URI, "lang"); if (!StringUtils.isBlank(lang)) { try { handler.parameter(Parameter.LANGUAGE, lang); } catch (Exception e) { LOG.warn("", e); } } } // XXX: other parameters? try { handler.propertyValue(value); } catch (URISyntaxException e) { throw new ParserException("Malformed URI value for element '" + className + "'", -1, e); } catch (ParseException e) { throw new ParserException("Malformed value for element '" + className + "'", -1, e); } catch (IOException e) { throw new CosmoIOException("Unknown error setting property value for element '" + className + "'", e); } handler.endProperty(propName); }
From source file:org.wso2.carbon.bpel.b4p.extension.BPEL4PeopleExtensionOperation.java
/** * Called when the response for the above service is received * * @param mexId MessageExchange id/*ww w. j a va 2 s. c o m*/ */ @Override public void onRequestReceived(String mexId) throws FaultException { if (log.isDebugEnabled()) { log.debug("People Activity Response received : mexId " + mexId); } Element notificationMessageEle = extensionContext.getInternalInstance().getMyRequest(mexId); if ("".equals(outputVarName) || outputVarName == null) { // if output variable is null or empty, these is no way to process the response from the task as we do // not have // a variable from bpel file to assign the values to. Hence what what we can do is to return a fault and // exit. log.error( "Output variable not specified correctly for the remoteTask activity.Hence the error condition." + "Please verify and correct your BPEL process remoteTask"); extensionContext.completeWithFault(cid, new FaultException(BPEL4PeopleConstants.B4P_FAULT, BPEL4PeopleConstants.NON_RECOVERABLE_ERROR)); } else { Node part = extensionContext.getPartData(notificationMessageEle, outputVarName); if (messageTraceLog.isTraceEnabled()) { messageTraceLog.trace("B4P Response Message: " + DOMUtils.domToString(notificationMessageEle)); messageTraceLog.trace("B4P Response Part: " + DOMUtils.domToString(part)); } if (CoordinationConfiguration.getInstance().isHumantaskCoordinationEnabled() && notificationMessageEle.hasChildNodes()) { String taskID = ""; Element correlationHeader = DOMUtils.findChildByName(notificationMessageEle, new QName(BPEL4PeopleConstants.B4P_NAMESPACE, BPEL4PeopleConstants.B4P_CORRELATION_HEADER), true); if (correlationHeader != null) { taskID = correlationHeader.getAttributeNS(BPEL4PeopleConstants.B4P_NAMESPACE, BPEL4PeopleConstants.B4P_CORRELATION_HEADER_ATTRIBUTE); try { deleteCoordinationTaskData(taskID); } catch (Exception e) { log.error("Error occurred while cleaning coordination data for task id " + taskID, e); } } //Checking for fault Element fault = DOMUtils.findChildByName(notificationMessageEle, new QName(WSConstants.WS_HT_COORDINATION_PROTOCOL_FAULT)); if (fault != null) { if (fault.hasAttribute("headerPart")) { if (log.isDebugEnabled()) { log.debug( "Throwing Fault to People Activity Scope since received Fault Protocol Message " + "for task" + taskID + "."); } extensionContext.completeWithFault(cid, new FaultException(BPEL4PeopleConstants.B4P_FAULT, BPEL4PeopleConstants.NON_RECOVERABLE_ERROR)); ; } } //Checking for Skip Element skipped = DOMUtils.findChildByName(notificationMessageEle, new QName(WSConstants.WS_HT_COORDINATION_PROTOCOL_SKIPPED)); if (skipped != null) { if (skipped.hasAttribute("headerPart")) { if (log.isDebugEnabled()) { log.debug("Skipping People Activity since received Skipped Protocol Message for task " + taskID + "."); } //Set extension as complete, since task is skipped. No value write to output variable. extensionContext.complete(cid); return; } } } extensionContext.writeVariable(outputVarName, notificationMessageEle); extensionContext.complete(cid); } }
From source file:org.xsystem.bpmn2.formats.xml.XMLParser3.java
Expression parseExpression(Element child) { String exType = child.getAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "type"); if (exType != null && exType.equals("bpmn2:tFormalExpression")) { FormalExpression expression = new FormalExpressionImpl(definitions); parseAttributes(expression, child); String value = XMLUtil.getContentText(child); expression.setBody(value);/*from w w w. j av a 2s . c o m*/ return expression; } else { exType = "mvel"; FormalExpression expression = new FormalExpressionImpl(definitions); expression.setLanguage(exType); // parseAttributes(expression, child); String value = XMLUtil.getContentText(child); expression.setBody(value); return expression; } }
From source file:ru.codeinside.gws.crypto.cryptopro.CryptoProvider.java
private static Element first(final Node parent, final String uri, final String localName, final String attrUri, final String attr, final String attrValue) { final NodeList nodes = parent.getChildNodes(); final int n = nodes.getLength(); for (int i = 0; i < n; i++) { final Node node = nodes.item(i); if (node instanceof Element) { final Element element = (Element) node; if (localName.equals(element.getLocalName()) && uri.equals(element.getNamespaceURI()) && attrValue.equals(element.getAttributeNS(attrUri, attr))) { return element; }/*from ww w .j av a 2s. c o m*/ } } return null; }
From source file:uk.ac.bbsrc.tgac.miso.notification.service.IlluminaTransformer.java
@Override public Map<String, String> transform(Set<File> files) { log.info("Processing " + files.size() + " Illumina run directories..."); int count = 0; //TODO modify this to use a JSONObject instead of a Map HashMap<String, JSONArray> map = new HashMap<String, JSONArray>(); map.put("Running", new JSONArray()); map.put("Completed", new JSONArray()); map.put("Unknown", new JSONArray()); map.put("Failed", new JSONArray()); for (File rootFile : files) { count++;// w w w .j a v a2s . com String countStr = "[#" + count + "/" + files.size() + "] "; if (rootFile.isDirectory()) { if (rootFile.canRead()) { JSONObject run = new JSONObject(); File oldStatusFile = new File(rootFile, "/Data/Status.xml"); File newStatusFile = new File(rootFile, "/Data/reports/Status.xml"); File runParameters = new File(rootFile, "/runParameters.xml"); File runInfo = new File(rootFile, "/RunInfo.xml"); File completeFile = new File(rootFile, "/Run.completed"); try { boolean complete = true; String runName = rootFile.getName(); run.put("runName", runName); run.put("fullPath", rootFile.getCanonicalPath()); //follow symlinks! if (!oldStatusFile.exists() && !newStatusFile.exists()) { //probably MiSeq File otherRunParameters = new File(rootFile, "/runParameters.xml"); Boolean lastCycleLogFileExists = false; File lastCycleLogFile = null; if (runInfo.exists()) { run.put("runinfo", SubmissionUtils.transform(runInfo)); Document runInfoDoc = SubmissionUtils.emptyDocument(); SubmissionUtils.transform(runInfo, runInfoDoc); //runName = statusDoc.getElementsByTagName("RunName").item(0).getTextContent(); //run.put("runName", runName); //run.put("sequencerName", statusDoc.getElementsByTagName("InstrumentName").item(0).getTextContent()); int numReads = runInfoDoc.getElementsByTagName("Read").getLength(); int numCycles = 0; int sumCycles = 0; NodeList nl = runInfoDoc.getElementsByTagName("Read"); for (int i = 0; i < nl.getLength(); i++) { Element e = (Element) nl.item(i); if (!"".equals(e.getAttributeNS(null, "NumCycles"))) { sumCycles += Integer.parseInt(e.getAttributeNS(null, "NumCycles")); if (!"".equals(e.getAttributeNS(null, "IsIndexedRead")) && "N".equals(e.getAttributeNS(null, "IsIndexedRead"))) { numCycles = Integer.parseInt(e.getAttributeNS(null, "NumCycles")); } } } lastCycleLogFile = new File(rootFile, "/Logs/" + runName + "_Cycle" + sumCycles + "_Log.00.log"); if (lastCycleLogFile.exists()) { lastCycleLogFileExists = true; } else { File dir = new File(rootFile, "/Logs/"); FileFilter fileFilter = new WildcardFileFilter("*Post Run Step.log"); File[] filterFiles = dir.listFiles(fileFilter); if (filterFiles != null) { List filterFilesList = Arrays.asList(filterFiles); if (filterFilesList.size() > 0) { lastCycleLogFileExists = true; } } } //int imgCycle = new Integer(statusDoc.getElementsByTagName("ImgCycle").item(0).getTextContent()); //int scoreCycle = new Integer(statusDoc.getElementsByTagName("ScoreCycle").item(0).getTextContent()); //int callCycle = new Integer(statusDoc.getElementsByTagName("CallCycle").item(0).getTextContent()); run.put("numCycles", numCycles); if (!new File(rootFile, "/Basecalling_Netcopy_complete_SINGLEREAD.txt").exists()) { for (int i = 0; i < numReads; i++) { if (!new File(rootFile, "/Basecalling_Netcopy_complete_Read" + (i + 1) + ".txt").exists()) { if (!new File(rootFile, "/Basecalling_Netcopy_complete_READ" + (i + 1) + ".txt") .exists()) { log.debug(countStr + runName + " :: No Basecalling_Netcopy_complete_Read" + (i + 1) + ".txt / Basecalling_Netcopy_complete_READ" + (i + 1) + ".txt!"); complete = false; break; } } } } run.put("sequencerName", runInfoDoc.getElementsByTagName("Instrument").item(0).getTextContent()); if (runInfoDoc.getElementsByTagName("FlowcellId").getLength() != 0) { run.put("containerlId", runInfoDoc.getElementsByTagName("FlowcellId").item(0).getTextContent()); } else if (runInfoDoc.getElementsByTagName("Flowcell").getLength() != 0) { run.put("containerId", runInfoDoc.getElementsByTagName("Flowcell").item(0).getTextContent()); } if (runInfoDoc.getElementsByTagName("FlowcellLayout").getLength() != 0) { NamedNodeMap n = runInfoDoc.getElementsByTagName("FlowcellLayout").item(0) .getAttributes(); if (n.getLength() != 0) { Node attr = n.getNamedItem("LaneCount"); if (attr != null) { run.put("laneCount", attr.getTextContent()); } } } } if (runParameters.exists()) { run.put("runparams", SubmissionUtils.transform(runParameters)); Document runParamDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder() .newDocument(); SubmissionUtils.transform(runParameters, runParamDoc); if (!run.has("containerId") && runParamDoc.getElementsByTagName("Barcode").getLength() != 0) { run.put("containerId", runParamDoc.getElementsByTagName("Barcode").item(0).getTextContent()); } } else if (otherRunParameters.exists()) { run.put("runparams", SubmissionUtils.transform(otherRunParameters)); Document runParamDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder() .newDocument(); SubmissionUtils.transform(otherRunParameters, runParamDoc); if (!run.has("containerId") && runParamDoc.getElementsByTagName("Barcode").getLength() != 0) { run.put("containerId", runParamDoc.getElementsByTagName("Barcode").item(0).getTextContent()); } } checkDates(rootFile, run); boolean failed = checkLogs(rootFile, run); if (complete) { if (!new File(rootFile, "/Basecalling_Netcopy_complete.txt").exists() && !lastCycleLogFileExists) { log.debug(countStr + runName + " :: All Basecalling_Netcopy_complete_ReadX.txt exist but Basecalling_Netcopy_complete.txt doesn't exist and last cycle log file doesn't exist."); if (failed) { log.debug("Run has likely failed."); map.get("Failed").add(run); } else { log.debug("Run is unknown."); map.get("Unknown").add(run); } } else if (new File(rootFile, "/Basecalling_Netcopy_complete.txt").exists() && !lastCycleLogFileExists) { log.debug(countStr + runName + " :: All Basecalling_Netcopy_complete_ReadX.txt exist and Basecalling_Netcopy_complete.txt exists but last cycle log file doesn't exist."); if (failed) { log.debug("Run has likely failed."); map.get("Failed").add(run); } else { log.debug("Run is unknown."); map.get("Unknown").add(run); } } else { log.debug(countStr + runName + " :: All Basecalling_Netcopy_complete*.txt exist and last cycle log file exists. Run is complete"); map.get("Completed").add(run); } } else { if (!completeFile.exists()) { if (!new File(rootFile, "/Basecalling_Netcopy_complete.txt").exists() && (lastCycleLogFile != null && !lastCycleLogFile.exists())) { log.debug(countStr + runName + " :: A Basecalling_Netcopy_complete_ReadX.txt doesn't exist and last cycle log file doesn't exist."); if (failed) { log.debug("Run has likely failed."); map.get("Failed").add(run); } else { log.debug("Run is not complete."); map.get("Running").add(run); } } else { log.debug(countStr + runName + " :: Basecalling_Netcopy_complete*.txt don't exist and last cycle log file doesn't exist."); if (failed) { log.debug("Run has likely failed."); map.get("Failed").add(run); } else { log.debug("Run is unknown."); map.get("Unknown").add(run); } } } else { log.debug(countStr + runName + " :: Basecalling_Netcopy_complete*.txt don't exist and last cycle log file doesn't exist, but RTAComplete.txt exists. Run is complete"); map.get("Completed").add(run); } } } else if (oldStatusFile.exists()) { if (oldStatusFile.canRead()) { Document statusDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder() .newDocument(); SubmissionUtils.transform(oldStatusFile, statusDoc); runName = statusDoc.getElementsByTagName("RunName").item(0).getTextContent(); run.put("runName", runName); run.put("status", SubmissionUtils.transform(oldStatusFile)); } else { run.put("status", "<error><RunName>" + runName + "</RunName><ErrorMessage>Cannot read status file</ErrorMessage></error>"); } if (runInfo.exists() && runInfo.canRead()) { run.put("runinfo", SubmissionUtils.transform(runInfo)); Document runInfoDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder() .newDocument(); SubmissionUtils.transform(runInfo, runInfoDoc); if (!run.has("sequencerName")) { run.put("sequencerName", runInfoDoc.getElementsByTagName("Instrument").item(0).getTextContent()); } if (runInfoDoc.getElementsByTagName("FlowcellId").getLength() != 0) { run.put("containerId", runInfoDoc.getElementsByTagName("FlowcellId").item(0).getTextContent()); } else if (runInfoDoc.getElementsByTagName("Flowcell").getLength() != 0) { run.put("containerId", runInfoDoc.getElementsByTagName("Flowcell").item(0).getTextContent()); } if (runInfoDoc.getElementsByTagName("FlowcellLayout").getLength() != 0) { NamedNodeMap n = runInfoDoc.getElementsByTagName("FlowcellLayout").item(0) .getAttributes(); if (n.getLength() != 0) { Node attr = n.getNamedItem("LaneCount"); if (attr != null) { run.put("laneCount", attr.getTextContent()); } } } } if (runParameters.exists() && runParameters.canRead()) { run.put("runparams", SubmissionUtils.transform(runParameters)); Document runParamDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder() .newDocument(); SubmissionUtils.transform(runParameters, runParamDoc); if (!run.has("sequencerName")) { run.put("sequencerName", runParamDoc.getElementsByTagName("ScannerID").item(0).getTextContent()); } if (!run.has("containerId") && runParamDoc.getElementsByTagName("Barcode").getLength() != 0) { run.put("containerId", runParamDoc.getElementsByTagName("Barcode").item(0).getTextContent()); } } checkDates(rootFile, run); boolean failed = checkLogs(rootFile, run); if (!completeFile.exists()) { if (run.has("completionDate")) { log.debug(countStr + runName + " :: Completed"); map.get("Completed").add(run); } else { if (failed) { log.debug("Run has likely failed."); map.get("Failed").add(run); } else { log.debug(countStr + runName + " :: Running"); map.get("Running").add(run); } } } else { log.debug(countStr + runName + " :: Completed"); map.get("Completed").add(run); } } else if (newStatusFile.exists()) { if (newStatusFile.canRead()) { Document statusDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder() .newDocument(); SubmissionUtils.transform(newStatusFile, statusDoc); runName = statusDoc.getElementsByTagName("RunName").item(0).getTextContent(); run.put("runName", runName); int numReads = new Integer( statusDoc.getElementsByTagName("NumberOfReads").item(0).getTextContent()); int numCycles = new Integer( statusDoc.getElementsByTagName("NumCycles").item(0).getTextContent()); int imgCycle = new Integer( statusDoc.getElementsByTagName("ImgCycle").item(0).getTextContent()); int scoreCycle = new Integer( statusDoc.getElementsByTagName("ScoreCycle").item(0).getTextContent()); int callCycle = new Integer( statusDoc.getElementsByTagName("CallCycle").item(0).getTextContent()); run.put("numCycles", numCycles); if (!new File(rootFile, "/Basecalling_Netcopy_complete_SINGLEREAD.txt").exists()) { for (int i = 0; i < numReads; i++) { if (!new File(rootFile, "/Basecalling_Netcopy_complete_Read" + (i + 1) + ".txt").exists()) { if (!new File(rootFile, "/Basecalling_Netcopy_complete_READ" + (i + 1) + ".txt") .exists()) { log.debug(countStr + runName + " :: No Basecalling_Netcopy_complete_Read" + (i + 1) + ".txt / Basecalling_Netcopy_complete_READ" + (i + 1) + ".txt!"); complete = false; break; } } } } run.put("status", SubmissionUtils.transform(newStatusFile)); if (runInfo.exists()) { run.put("runinfo", SubmissionUtils.transform(runInfo)); Document runInfoDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder() .newDocument(); SubmissionUtils.transform(runInfo, runInfoDoc); if (!run.has("sequencerName")) { run.put("sequencerName", runInfoDoc.getElementsByTagName("Instrument") .item(0).getTextContent()); } if (runInfoDoc.getElementsByTagName("FlowcellId").getLength() != 0) { run.put("containerId", runInfoDoc.getElementsByTagName("FlowcellId").item(0) .getTextContent()); } else if (runInfoDoc.getElementsByTagName("Flowcell").getLength() != 0) { run.put("containerId", runInfoDoc.getElementsByTagName("Flowcell").item(0) .getTextContent()); } if (runInfoDoc.getElementsByTagName("FlowcellLayout").getLength() != 0) { NamedNodeMap n = runInfoDoc.getElementsByTagName("FlowcellLayout").item(0) .getAttributes(); if (n.getLength() != 0) { Node attr = n.getNamedItem("LaneCount"); if (attr != null) { run.put("laneCount", attr.getTextContent()); } } } } if (runParameters.exists()) { run.put("runparams", SubmissionUtils.transform(runParameters)); Document runParamDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder() .newDocument(); SubmissionUtils.transform(runParameters, runParamDoc); if (!run.has("sequencerName")) { run.put("sequencerName", runParamDoc.getElementsByTagName("ScannerID") .item(0).getTextContent()); } if (!run.has("containerId") && runParamDoc.getElementsByTagName("Barcode").getLength() != 0) { run.put("containerId", runParamDoc.getElementsByTagName("Barcode").item(0) .getTextContent()); } } checkDates(rootFile, run); boolean failed = checkLogs(rootFile, run); if (complete) { if (!new File(rootFile, "/Basecalling_Netcopy_complete.txt").exists() && (numCycles != imgCycle || numCycles != scoreCycle || numCycles != callCycle)) { log.debug(countStr + runName + " :: All Basecalling_Netcopy_complete_ReadX.txt exist but Basecalling_Netcopy_complete.txt doesn't exist and cycles don't match."); if (failed) { log.debug("Run has likely failed."); map.get("Failed").add(run); } else { log.debug("Run is unknown."); map.get("Unknown").add(run); } } else if (new File(rootFile, "/Basecalling_Netcopy_complete.txt").exists() && (numCycles != imgCycle || numCycles != scoreCycle || numCycles != callCycle)) { log.debug(countStr + runName + " :: All Basecalling_Netcopy_complete_ReadX.txt exist and Basecalling_Netcopy_complete.txt exists but cycles don't match."); if (failed) { log.debug("Run has likely failed."); map.get("Failed").add(run); } else { log.debug("Run is unknown."); map.get("Unknown").add(run); } } else { log.debug(countStr + runName + " :: All Basecalling_Netcopy_complete*.txt exist and cycles match. Run is complete"); map.get("Completed").add(run); } } else { if (!completeFile.exists()) { if (!new File(rootFile, "/Basecalling_Netcopy_complete.txt").exists() && (numCycles != imgCycle || numCycles != scoreCycle || numCycles != callCycle)) { log.debug(countStr + runName + " :: A Basecalling_Netcopy_complete_ReadX.txt doesn't exist and cycles don't match."); if (failed) { log.debug("Run has likely failed."); map.get("Failed").add(run); } else { log.debug("Run is not complete."); map.get("Running").add(run); } } else { log.debug(countStr + runName + " :: Basecalling_Netcopy_complete*.txt don't exist and cycles don't match."); if (failed) { log.debug("Run has likely failed."); map.get("Failed").add(run); } else { log.debug("Run is unknown."); map.get("Unknown").add(run); } } } else { log.debug(countStr + runName + " :: Basecalling_Netcopy_complete*.txt don't exist and cycles don't match, but Run.completed exists. Run is complete"); map.get("Completed").add(run); } } } else { run.put("status", "<error><RunName>" + runName + "</RunName><ErrorMessage>Cannot read status file</ErrorMessage></error>"); checkDates(rootFile, run); boolean failed = checkLogs(rootFile, run); if (!completeFile.exists()) { if (!new File(rootFile, "/Basecalling_Netcopy_complete.txt").exists()) { log.debug(countStr + runName + " :: Cannot read Status.xml and Basecalling_Netcopy_complete.txt/Run.completed doesn't exist."); if (failed) { log.debug("Run has likely failed."); map.get("Failed").add(run); } else { log.debug("Run is unknown."); map.get("Unknown").add(run); } } else { map.get("Completed").add(run); log.debug(countStr + runName + " :: Cannot read Status.xml and Basecalling_Netcopy_complete.txt exists. Run is unknown"); } } else { log.debug(countStr + runName + " :: Basecalling_Netcopy_complete.txt exists and Run.completed exists. Run is complete"); map.get("Completed").add(run); } } } else { run.put("status", "<error><RunName>" + runName + "</RunName><ErrorMessage>No status file exists</ErrorMessage></error>"); checkDates(rootFile, run); boolean failed = checkLogs(rootFile, run); if (!completeFile.exists()) { if (!new File(rootFile, "/Basecalling_Netcopy_complete.txt").exists()) { log.debug(countStr + runName + " :: Status.xml doesn't exist and Basecalling_Netcopy_complete.txt/Run.completed doesn't exist."); if (failed) { log.debug("Run has likely failed."); map.get("Failed").add(run); } else { log.debug("Run is unknown."); map.get("Unknown").add(run); } } else { log.debug(countStr + runName + " :: Status.xml doesn't exist but Basecalling_Netcopy_complete.txt exists. Run is completed"); map.get("Completed").add(run); } } else { log.debug(countStr + runName + " :: Basecalling_Netcopy_complete.txt exists and Run.completed exists. Run is complete"); map.get("Completed").add(run); } } } catch (ParserConfigurationException e) { log.error("Error configuring parser: " + e.getMessage()); e.printStackTrace(); } catch (TransformerException e) { log.error("Error transforming XML: " + e.getMessage()); e.printStackTrace(); } catch (IOException e) { log.error("Error with file IO: " + e.getMessage()); e.printStackTrace(); } } else { log.error(rootFile.getName() + " :: Permission denied"); } } } HashMap<String, String> smap = new HashMap<String, String>(); for (String key : map.keySet()) { smap.put(key, map.get(key).toString()); } return smap; }
From source file:VASSAL.tools.image.svg.SVGRenderer.java
public SVGRenderer(String file, InputStream in) throws IOException { // load the SVG try {/*from w ww. j a v a 2 s . c om*/ // We synchronize on docFactory becuase it does internal caching // of the Documents it produces. This ensures that a Document is // being modified on one thread only. synchronized (docFactory) { doc = docFactory.createDocument(file, in); } in.close(); } catch (DOMException e) { throw (IOException) new IOException().initCause(e); } finally { IOUtils.closeQuietly(in); } // get the default image size final Element root = doc.getDocumentElement(); defaultW = Float.parseFloat(root.getAttributeNS(null, "width").replaceFirst("px", "")); defaultH = Float.parseFloat(root.getAttributeNS(null, "height").replaceFirst("px", "")); }
From source file:xsul.dsig.globus.security.authentication.SOAPBodyIdResolver.java
public XMLSignatureInput engineResolve(Attr uri, String BaseURI) throws ResourceResolverException { String uriNodeValue = uri.getNodeValue(); NodeList resultNodes = null;/*w ww. j a va 2 s .co m*/ Document doc = uri.getOwnerDocument(); // this must be done so that Xalan can catch ALL namespaces XMLUtils.circumventBug2650(doc); CachedXPathAPI cXPathAPI = new CachedXPathAPI(); /* * URI="#chapter1" * Identifies a node-set containing the element with ID attribute * value 'chapter1' of the XML resource containing the signature. * XML Signature (and its applications) modify this node-set to * include the element plus all descendents including namespaces and * attributes -- but not comments. */ String id = uriNodeValue.substring(1); Element selectedElem = WSSecurityUtil.findFirstBodyElement(doc); if (selectedElem == null) { throw new ResourceResolverException("generic.EmptyMessage", new Object[] { "Body element not found" }, uri, BaseURI); } String cId = selectedElem.getAttributeNS(WSConstants.WSU_NS, "Id"); if ((cId == null) || (cId.length() == 0)) { cId = selectedElem.getAttributeNS(WSConstants.SOAP_SEC_NS, "id"); } if (!id.equals(cId)) { selectedElem = (Element) selectedElem.getParentNode(); cId = selectedElem.getAttributeNS(WSConstants.WSU_NS, "Id"); if ((cId == null) || (cId.length() == 0)) { cId = selectedElem.getAttributeNS(WSConstants.SOAP_SEC_NS, "id"); } if (!id.equals(cId)) { throw new ResourceResolverException("generic.EmptyMessage", new Object[] { "Id not found" }, uri, BaseURI); } } try { resultNodes = cXPathAPI.selectNodeList(selectedElem, Canonicalizer.XPATH_C14N_WITH_COMMENTS_SINGLE_NODE//.XPATH_C14N_OMIT_COMMENTS_SINGLE_NODE ); } catch (javax.xml.transform.TransformerException ex) { throw new ResourceResolverException("generic.EmptyMessage", ex, uri, BaseURI); } Set resultSet = XMLUtils.convertNodelistToSet(resultNodes); XMLSignatureInput result = new XMLSignatureInput(resultSet);//, cXPathAPI); result.setMIMEType("text/xml"); try { URI uriNew = new URI(new URI(BaseURI), uri.getNodeValue()); result.setSourceURI(uriNew.toString()); } catch (URI.MalformedURIException ex) { result.setSourceURI(BaseURI); } return result; }