List of usage examples for org.w3c.dom DOMException getMessage
public String getMessage()
From source file:ddf.catalog.services.xsltlistener.XsltResponseQueueTransformer.java
@Override public ddf.catalog.data.BinaryContent transform(SourceResponse upstreamResponse, Map<String, Serializable> arguments) throws CatalogTransformerException { LOGGER.debug("Transforming ResponseQueue with XSLT tranformer"); long grandTotal = -1; try {//from w w w .j a va 2 s .c o m DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.newDocument(); Node resultsElement = doc.appendChild(createElement(doc, XML_RESULTS_NAMESPACE, "results", null)); // TODO use streaming XSLT, not DOM List<Result> results = upstreamResponse.getResults(); grandTotal = upstreamResponse.getHits(); for (Result result : results) { Metacard metacard = result.getMetacard(); String thisMetacard = metacard.getMetadata(); if (metacard != null && thisMetacard != null) { Element metacardElement = createElement(doc, XML_RESULTS_NAMESPACE, "metacard", null); if (metacard.getId() != null) { metacardElement .appendChild(createElement(doc, XML_RESULTS_NAMESPACE, "id", metacard.getId())); } if (metacard.getMetacardType().toString() != null) { metacardElement.appendChild(createElement(doc, XML_RESULTS_NAMESPACE, "type", metacard.getMetacardType().getName())); } if (metacard.getTitle() != null) { metacardElement.appendChild( createElement(doc, XML_RESULTS_NAMESPACE, "title", metacard.getTitle())); } if (result.getRelevanceScore() != null) { metacardElement.appendChild(createElement(doc, XML_RESULTS_NAMESPACE, "score", result.getRelevanceScore().toString())); } if (result.getDistanceInMeters() != null) { metacardElement.appendChild(createElement(doc, XML_RESULTS_NAMESPACE, "distance", result.getDistanceInMeters().toString())); } if (metacard.getSourceId() != null) { metacardElement.appendChild( createElement(doc, XML_RESULTS_NAMESPACE, "site", metacard.getSourceId())); } if (metacard.getContentTypeName() != null) { String contentType = metacard.getContentTypeName(); Element typeElement = createElement(doc, XML_RESULTS_NAMESPACE, "content-type", contentType); // TODO revisit what to put in the qualifier typeElement.setAttribute("qualifier", "content-type"); metacardElement.appendChild(typeElement); } if (metacard.getResourceURI() != null) { try { metacardElement.appendChild(createElement(doc, XML_RESULTS_NAMESPACE, "product", metacard.getResourceURI().toString())); } catch (DOMException e) { LOGGER.warn(" Unable to create resource uri element", e); } } if (metacard.getThumbnail() != null) { metacardElement.appendChild(createElement(doc, XML_RESULTS_NAMESPACE, "thumbnail", Base64.encodeBase64String(metacard.getThumbnail()))); try { String mimeType = URLConnection .guessContentTypeFromStream(new ByteArrayInputStream(metacard.getThumbnail())); metacardElement .appendChild(createElement(doc, XML_RESULTS_NAMESPACE, "t_mimetype", mimeType)); } catch (IOException e) { // TODO Auto-generated catch block metacardElement.appendChild( createElement(doc, XML_RESULTS_NAMESPACE, "t_mimetype", "image/png")); } } DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); if (metacard.getCreatedDate() != null) { metacardElement.appendChild(createElement(doc, XML_RESULTS_NAMESPACE, "created", fmt.print(metacard.getCreatedDate().getTime()))); } // looking at the date last modified if (metacard.getModifiedDate() != null) { metacardElement.appendChild(createElement(doc, XML_RESULTS_NAMESPACE, "updated", fmt.print(metacard.getModifiedDate().getTime()))); } if (metacard.getEffectiveDate() != null) { metacardElement.appendChild(createElement(doc, XML_RESULTS_NAMESPACE, "effective", fmt.print(metacard.getEffectiveDate().getTime()))); } if (metacard.getLocation() != null) { metacardElement.appendChild( createElement(doc, XML_RESULTS_NAMESPACE, "location", metacard.getLocation())); } Element documentElement = doc.createElementNS(XML_RESULTS_NAMESPACE, "document"); metacardElement.appendChild(documentElement); resultsElement.appendChild(metacardElement); Node importedNode = doc.importNode(new XPathHelper(thisMetacard).getDocument().getFirstChild(), true); documentElement.appendChild(importedNode); } else { LOGGER.debug("Null content/document returned to XSLT ResponseQueueTransformer"); continue; } } if (LOGGER.isDebugEnabled()) { DOMImplementationLS domImplementation = (DOMImplementationLS) doc.getImplementation(); LSSerializer lsSerializer = domImplementation.createLSSerializer(); LOGGER.debug("Generated XML input for transform: " + lsSerializer.writeToString(doc)); } LOGGER.debug("Starting responsequeue xslt transform."); Transformer transformer; Map<String, Object> mergedMap = new HashMap<String, Object>(); mergedMap.put(GRAND_TOTAL, grandTotal); if (arguments != null) { mergedMap.putAll(arguments); } BinaryContent resultContent; StreamResult resultOutput = null; Source source = new DOMSource(doc); ByteArrayOutputStream baos = new ByteArrayOutputStream(); resultOutput = new StreamResult(baos); try { transformer = templates.newTransformer(); } catch (TransformerConfigurationException tce) { throw new CatalogTransformerException("Could not perform Xslt transform: " + tce.getException(), tce.getCause()); } if (mergedMap != null && !mergedMap.isEmpty()) { for (Map.Entry<String, Object> entry : mergedMap.entrySet()) { if (LOGGER.isDebugEnabled()) { LOGGER.debug( "Adding parameter to transform {" + entry.getKey() + ":" + entry.getValue() + "}"); } transformer.setParameter(entry.getKey(), entry.getValue()); } } try { transformer.transform(source, resultOutput); byte[] bytes = baos.toByteArray(); LOGGER.debug("Transform complete."); resultContent = new XsltTransformedContent(bytes, mimeType); } catch (TransformerException te) { LOGGER.error("Could not perform Xslt transform: " + te.getException(), te.getCause()); throw new CatalogTransformerException("Could not perform Xslt transform: " + te.getException(), te.getCause()); } finally { // transformer.reset(); // don't need to do that unless we are putting it back into a // pool -- which we should do, but that can wait until later. } return resultContent; } catch (ParserConfigurationException e) { LOGGER.warn("Error creating new document: " + e.getMessage(), e.getCause()); throw new CatalogTransformerException("Error merging entries to xml feed.", e); } }
From source file:org.apache.cocoon.webapps.session.context.RequestSessionContext.java
/** * Build attributes XML//from w ww. java2 s. c o m */ private void buildAttributesXML(Element root) throws ProcessingException { Document doc = root.getOwnerDocument(); Element attrElement = doc.createElementNS(null, "attributes"); String attrName; Element attr; root.appendChild(attrElement); Enumeration all = this.request.getAttributeNames(); while (all.hasMoreElements() == true) { attrName = (String) all.nextElement(); try { attr = doc.createElementNS(null, attrName); attrElement.appendChild(attr); DOMUtil.valueOf(attr, this.request.getAttribute(attrName)); } catch (DOMException de) { // Some request attributes have names that are invalid as element names. // Example : "FOM JavaScript GLOBAL SCOPE/file://my/path/to/flow/script.js" this.logger.info("RequestSessionContext: Cannot create XML element from request attribute '" + attrName + "' : " + de.getMessage()); } } }
From source file:org.apache.shindig.gadgets.parse.nekohtml.SocialMarkupHtmlParserTest.java
@Test public void testInvalid() throws Exception { String content = "<html><div id=\"div_super\" class=\"div_super\" valign:\"middle\"></div></html>"; try {//w w w . ja v a2s .com parser.parseDom(content); assertTrue("No exception caught", false); } catch (DOMException e) { assertTrue(e.getMessage().contains("INVALID_CHARACTER_ERR")); assertTrue(e.getMessage().contains("Around ...<div id=\"div_super\" class=\"div_super\"...")); } }
From source file:org.jahia.services.htmlvalidator.WAIValidator.java
/** * Validates an HTML fragment starting from any Node. * // w w w . ja va 2 s. c o m * * @param node * The starting Node. * @param source * @return A list of Result Objects, the list will be empty in case no errors occurred. */ protected List<Result> validateHtml(Element node, Source source) { final List<Result> errors = new ArrayList<Result>(); try { validateHtml(node, errors, 0, source); } catch (DOMException de) { logger.error("Cannot validate html: " + de.getMessage(), de); final Result ve = new Result( getFormatted("org.jahia.services.htmlvalidator.WAIValidator.cannotValidate", "Cannot validate html: " + de.getMessage(), new Object[] { de.getMessage() })); setPosition(node, source, ve); errors.add(ve); } return errors; }
From source file:org.pepstock.jem.jbpm.JBpmFactory.java
/** * Validates the JCL content, calling the JBPM API * @param jcl default JCL to store into job * @param content JCL content/*from ww w .j av a 2 s. c o m*/ * @throws JBpmException if any error occurs */ private void validate(Jcl jcl, String content) throws JBpmException { // read the BPMN Metadata, loading in properties object Properties p = new Properties(); // creates all readers StringReader reader = new StringReader(content); InputSource source = new InputSource(reader); SimpleRuntimeEnvironment jbpmEnvironment = null; String jobName = null; // SCANS JCL to get JOBNAME // JOBNAME = attribute ID of PROCESS element try { // creates DOM objects DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setIgnoringComments(false); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(source); // scan XML to read comment NodeList nl = doc.getDocumentElement().getChildNodes(); // scans all nodes for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node.getNodeType() == Element.ELEMENT_NODE) { Element el = (Element) node; String tagName = null; // checks if name space if (el.getTagName().contains(":")) { tagName = StringUtils.substringAfter(el.getTagName(), ":"); } else { tagName = el.getTagName(); } // checks only if is a PROCESS element if (tagName.equalsIgnoreCase(PROCESS_XML_ELEMENT)) { // gets ID attribute to set JOBNAME String jobNameAttr = el.getAttribute(ID_XML_ATTRIBUTE); if (jobNameAttr != null) { // puts on properties p.setProperty(JBpmKeys.JBPM_JOB_NAME, jobNameAttr); } else { throw new JBpmException(JBpmMessage.JEMM031E); } } } } // checks if project has attribute name, if yes, uses it as JOB NAME // otherwise get the JEM property to define it jobName = p.getProperty(JBpmKeys.JBPM_JOB_NAME); // Anyway job name can't be null. if yes, exception occurs if (jobName == null) { throw new JBpmException(JBpmMessage.JEMM031E); } // loads JCL jobname jcl.setJobName(jobName); // creates JBPM environment to check BPMN2 syntax SimpleRegisterableItemsFactory factory = new SimpleRegisterableItemsFactory(); jbpmEnvironment = new SimpleRuntimeEnvironment(factory); jbpmEnvironment.setUsePersistence(false); Resource res = ResourceFactory.newReaderResource(new StringReader(content), CharSet.DEFAULT_CHARSET_NAME); jbpmEnvironment.addAsset(res, ResourceType.BPMN2); // gets process to read metadata org.kie.api.definition.process.Process process = jbpmEnvironment.getKieBase().getProcess(jobName); // if process is null, exception if (process == null) { throw new JBpmException(JBpmMessage.JEMM063E); } // loads all METADATA p.putAll(process.getMetaData()); // check again because you could put the job name on metadata jcl.setJobName(p.getProperty(JBpmKeys.JBPM_JOB_NAME)); // loads the JBPM process ID in a map to reuse when a JBPM task will be scheduled Map<String, Object> jclMap = new HashMap<String, Object>(); jclMap.put(JBpmKeys.JBPM_JOB_NAME, jobName); jcl.setProperties(jclMap); } catch (DOMException e) { throw new JBpmException(JBpmMessage.JEMM047E, e, e.getMessage()); } catch (ParserConfigurationException e) { throw new JBpmException(JBpmMessage.JEMM047E, e, e.getMessage()); } catch (SAXException e) { throw new JBpmException(JBpmMessage.JEMM047E, e, e.getMessage()); } catch (Exception e) { throw new JBpmException(JBpmMessage.JEMM047E, e, e.getMessage()); } finally { // clean up of JBPM environment if (jbpmEnvironment != null && jobName != null) { try { jbpmEnvironment.getKieBase().removeProcess(jobName); } catch (Exception e) { LogAppl.getInstance().debug(e.getMessage(), e); } } } // if I'm here, JCL is correct // extracts the locking scope and checks if the value is correct // the value is not save in JCL because is not helpful to node but // at runtime so it will be read again from ANT listener String lockingScopeProperty = p.getProperty(JBpmKeys.JBPM_LOCKING_SCOPE); if (lockingScopeProperty != null && !lockingScopeProperty.equalsIgnoreCase(JBpmKeys.JBPM_JOB_SCOPE) && !lockingScopeProperty.equalsIgnoreCase(JBpmKeys.JBPM_STEP_SCOPE) && !lockingScopeProperty.equalsIgnoreCase(JBpmKeys.JBPM_TASK_SCOPE)) { throw new JBpmException(JBpmMessage.JEMM032E, JBpmKeys.JBPM_LOCKING_SCOPE, lockingScopeProperty); } // Extracts from ANT enviroment property String environment = p.getProperty(JBpmKeys.JBPM_ENVIRONMENT); // if null, uses current environment assigned to JEM NODE if (environment == null) { environment = Main.EXECUTION_ENVIRONMENT.getEnvironment(); } // Extracts from ANT domain property String domain = p.getProperty(JBpmKeys.JBPM_DOMAIN); // if null, uses domain default if (domain == null) { domain = Jcl.DEFAULT_DOMAIN; } // Extracts from ANT email addresses notification property String emailAddresses = p.getProperty(JBpmKeys.JBPM_EMAILS_NOTIFICATION); if (null != emailAddresses) { jcl.setEmailNotificationAddresses(emailAddresses); } // Extracts from ANT affinity property String affinity = p.getProperty(JBpmKeys.JBPM_AFFINITY); // if null, uses affinity default if (affinity == null) { affinity = Jcl.DEFAULT_AFFINITY; } // Extracts from ANT user property String user = p.getProperty(JBpmKeys.JBPM_USER); if (null != user) { jcl.setUser(user); } // Extracts from ANT classpath property String classPath = p.getProperty(JBpmKeys.JBPM_CLASSPATH); // if classpath is not set, changes if some variables are in if (classPath != null) { jcl.setClassPath(super.resolvePathNames(classPath, ConfigKeys.JEM_CLASSPATH_PATH_NAME)); } // Extracts from ANT prior classpath property String priorClassPath = p.getProperty(JBpmKeys.JBPM_PRIOR_CLASSPATH); // if classpath is not set, changes if some variables are in if (priorClassPath != null) { jcl.setPriorClassPath(super.resolvePathNames(priorClassPath, ConfigKeys.JEM_CLASSPATH_PATH_NAME)); } // Extracts from ANT memory property. If missing, default is 256 int memory = Parser.parseInt(p.getProperty(JBpmKeys.JBPM_MEMORY), Jcl.DEFAULT_MEMORY); // Extracts from ANT hold property. If missing, default is FALSE boolean hold = Parser.parseBoolean(p.getProperty(JBpmKeys.JBPM_HOLD), false); // Extracts from ANT priority property. If missing, default is 10 int priority = Parser.parseInt(p.getProperty(JBpmKeys.JBPM_PRIORITY), Jcl.DEFAULT_PRIORITY); // saves all info inside of JCL object for further computing jcl.setEnvironment(environment); jcl.setDomain(domain); jcl.setAffinity(affinity); jcl.setHold(hold); jcl.setPriority(priority); jcl.setMemory(memory); }
From source file:org.sakaiproject.chat2.model.impl.ChatEntityProducer.java
/** * {@inheritDoc}//from w w w. j a va 2s .c o m */ public String merge(String siteId, Element root, String archivePath, String fromSiteId, Map attachmentNames, Map userIdTrans, Set userListAllowImport) { logger.debug("trying to merge chat"); // buffer for the results log StringBuilder results = new StringBuilder(); int count = 0; if (siteId != null && siteId.trim().length() > 0) { try { NodeList allChildrenNodes = root.getChildNodes(); int length = allChildrenNodes.getLength(); for (int i = 0; i < length; i++) { count++; Node siteNode = allChildrenNodes.item(i); if (siteNode.getNodeType() == Node.ELEMENT_NODE) { Element chatElement = (Element) siteNode; if (chatElement.getTagName().equals(ChatManager.CHAT)) { Site site = SiteService.getSite(siteId); if (site.getToolForCommonId(ChatManager.CHAT_TOOL_ID) != null) { // add the chat rooms and synoptic tool options NodeList chatNodes = chatElement.getChildNodes(); int lengthChatNodes = chatNodes.getLength(); for (int cn = 0; cn < lengthChatNodes; cn++) { Node chatNode = chatNodes.item(cn); if (chatNode.getNodeType() == Node.ELEMENT_NODE) { Element channelElement = (Element) chatNode; if (channelElement.getTagName().equals(CHANNEL_PROP)) { ChatChannel channel = ChatChannel.xmlToChatChannel(channelElement, siteId); //save the channel getChatManager().updateChannel(channel, false); } else if (channelElement.getTagName().equals(SYNOPTIC_TOOL)) { ToolConfiguration synTool = site .getToolForCommonId("sakai.synoptic.chat"); Properties synProps = synTool.getPlacementConfig(); NodeList synPropNodes = channelElement.getChildNodes(); for (int props = 0; props < synPropNodes.getLength(); props++) { Node propsNode = synPropNodes.item(props); if (propsNode.getNodeType() == Node.ELEMENT_NODE) { Element synPropEl = (Element) propsNode; if (synPropEl.getTagName().equals(PROPERTIES)) { NodeList synProperties = synPropEl.getChildNodes(); for (int p = 0; p < synProperties.getLength(); p++) { Node propertyNode = synProperties.item(p); if (propertyNode.getNodeType() == Node.ELEMENT_NODE) { Element propEl = (Element) propertyNode; if (propEl.getTagName().equals(PROPERTY)) { String propName = propEl.getAttribute(NAME); String propValue = propEl.getAttribute(VALUE); if (propName != null && propName.length() > 0 && propValue != null && propValue.length() > 0) { synProps.setProperty(propName, propValue); } } } } } } } } } } SiteService.save(site); } } } } results.append("merging chat " + siteId + " (" + count + ") chat items.\n"); } catch (DOMException e) { logger.error(e.getMessage(), e); results.append("merging " + getLabel() + " failed during xml parsing.\n"); } catch (Exception e) { logger.error(e.getMessage(), e); results.append("merging " + getLabel() + " failed.\n"); } } return results.toString(); }
From source file:org.sakaiproject.lessonbuildertool.service.LessonBuilderEntityProducer.java
/** * {@inheritDoc}/*w w w. jav a 2 s . c o m*/ */ public String merge(String siteId, Element root, String archivePath, String fromSiteId, Map attachmentNames, Map userIdTrans, Set userListAllowImport, Map<String, String> entityMap) { StringBuilder results = new StringBuilder(); // map old to new page ids Map<Long, Long> pageMap = new HashMap<Long, Long>(); Map<Long, Long> itemMap = new HashMap<Long, Long>(); int count = 0; boolean needFix = false; String oldServer = root.getAttribute("server"); if (siteId != null && siteId.trim().length() > 0) { try { // create pages first, build up map of old to new page NodeList pageNodes = root.getElementsByTagName("page"); int numPages = pageNodes.getLength(); for (int p = 0; p < numPages; p++) { Node pageNode = pageNodes.item(p); if (pageNode.getNodeType() == Node.ELEMENT_NODE) { Element pageElement = (Element) pageNode; String title = pageElement.getAttribute("title"); if (title == null) title = "Page"; String oldPageIdString = pageElement.getAttribute("pageid"); if (oldPageIdString == null) oldPageIdString = "0"; Long oldPageId = Long.valueOf(oldPageIdString); SimplePage page = simplePageToolDao.makePage("0", siteId, title, 0L, 0L); String gradebookPoints = pageElement.getAttribute("gradebookpoints"); if (gradebookPoints != null && !gradebookPoints.equals("")) { page.setGradebookPoints(Double.valueOf(gradebookPoints)); } String folder = pageElement.getAttribute("folder"); if (folder != null && !folder.equals("")) page.setFolder(folder); simplePageToolDao.quickSaveItem(page); if (gradebookPoints != null && !gradebookPoints.equals("")) { gradebookIfc.addExternalAssessment(siteId, "lesson-builder:" + page.getPageId(), null, title, Double.valueOf(gradebookPoints), null, "Lesson Builder"); } pageMap.put(oldPageId, page.getPageId()); } } // process pages again to create the items pageNodes = root.getElementsByTagName("page"); numPages = pageNodes.getLength(); for (int p = 0; p < numPages; p++) { Node pageNode = pageNodes.item(p); if (pageNode.getNodeType() == Node.ELEMENT_NODE) { Element pageElement = (Element) pageNode; if (makePage(pageElement, oldServer, siteId, fromSiteId, pageMap, itemMap, entityMap)) needFix = true; } } if (needFix) { Site site = siteService.getSite(siteId); ResourcePropertiesEdit rp = site.getPropertiesEdit(); rp.addProperty("lessonbuilder-needsfixup", "2"); siteService.save(site); // unfortunately in duplicate site, site-admin has the site open, so this doesn't actually do anything // site-manage will stomp on it. However it does work for the other import operations, which is where // we need it, since site manage will call the fixup itself for duplicate } for (int p = 0; p < numPages; p++) { Node pageNode = pageNodes.item(p); if (pageNode.getNodeType() == Node.ELEMENT_NODE) { Element pageElement = (Element) pageNode; fixItems(pageElement, oldServer, siteId, fromSiteId, pageMap, itemMap); } } // process tools and top-level pages // need to fill in the tool id for top level pages and set parents to null NodeList tools = root.getElementsByTagName("lessonbuilder"); int numTools = tools.getLength(); for (int i = 0; i < numTools; i++) { Node node = tools.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; // there's an element at top level with no attributes. ignore it String oldToolId = trimToNull(element.getAttribute("toolid")); if (oldToolId != null) { String toolTitle = trimToNull(element.getAttribute("name")); String rolelist = element.getAttribute("functions.require"); if (toolTitle != null) { Tool tr = toolManager.getTool(LESSONBUILDER_ID); SitePage page = null; ToolConfiguration tool = null; Site site = siteService.getSite(siteId); // some code in site action creates all the pages and tools and some doesn't // so see if we already have this page and tool Collection<ToolConfiguration> toolConfs = site.getTools(myToolIds()); if (toolConfs != null && !toolConfs.isEmpty()) { for (ToolConfiguration config : toolConfs) { if (config.getToolId().equals(LESSONBUILDER_ID)) { SitePage p = config.getContainingPage(); // only use the Sakai page if it has the right title // and we don't already have lessson builder info for it if (p != null && toolTitle.equals(p.getTitle()) && simplePageToolDao .getTopLevelPageId(config.getPageId()) == null) { page = p; tool = config; break; } } } } // if we alrady have an appropriate blank page from the template, page and tool are set if (page == null) { page = site.addPage(); tool = page.addTool(LESSONBUILDER_ID); } String toolId = tool.getPageId(); if (toolId == null) { logger.error("unable to find new toolid for copy of " + oldToolId); continue; } tool.setTitle(toolTitle); if (rolelist != null) tool.getPlacementConfig().setProperty("functions.require", rolelist); count++; page.setTitle(toolTitle); page.setTitleCustom(true); siteService.save(site); // now fix up the page. new format has it as attribute String pageId = trimToNull(element.getAttribute("pageId")); if (pageId == null) { // old format. we should have a page node // normally just one Node pageNode = element.getFirstChild(); if (pageNode == null || pageNode.getNodeType() != Node.ELEMENT_NODE) { logger.error("page node not element"); continue; } Element pageElement = (Element) pageNode; pageId = trimToNull(pageElement.getAttribute("pageid")); } if (pageId == null) { logger.error("page node without old pageid"); continue; } // fix up the new copy of the page to be top level SimplePage simplePage = simplePageToolDao .getPage(pageMap.get(Long.valueOf(pageId))); if (simplePage == null) { logger.error("can't find new copy of top level page"); continue; } simplePage.setParent(null); simplePage.setTopParent(null); simplePage.setToolId(toolId); simplePageToolDao.quickUpdate(simplePage); // create the vestigial item for this top level page SimplePageItem item = simplePageToolDao.makeItem(0, 0, SimplePageItem.PAGE, Long.toString(simplePage.getPageId()), simplePage.getTitle()); simplePageToolDao.quickSaveItem(item); } } } } results.append("merging link tool " + siteId + " (" + count + ") items.\n"); } catch (DOMException e) { logger.error(e.getMessage(), e); results.append("merging " + getLabel() + " failed during xml parsing.\n"); } catch (Exception e) { logger.error(e.getMessage(), e); results.append("merging " + getLabel() + " failed.\n"); } } return results.toString(); }
From source file:org.sakaiproject.tool.assessment.qti.asi.ASIBaseClass.java
/** * DOCUMENTATION PENDING/*from w ww .j a v a 2 s . c o m*/ * * @param xpath DOCUMENTATION PENDING * * @return DOCUMENTATION PENDING */ protected String getFieldentry(String xpath) { if (log.isDebugEnabled()) { log.debug("getFieldentry(String " + xpath + ")"); } String val = null; int no = 0; List metadataList; try { metadataList = this.selectNodes(xpath); no = metadataList.size(); if (metadataList.size() > 0) { Document document = this.getDocument(); Element fieldentry = (Element) metadataList.get(0); CharacterData fieldentryText = (CharacterData) fieldentry.getFirstChild(); Integer getTime = null; if ((fieldentryText != null) && (fieldentryText.getNodeValue() != null) && (fieldentryText.getNodeValue().trim().length() > 0)) { val = fieldentryText.getNodeValue(); } } } catch (DOMException ex) { log.error(ex.getMessage(), ex); } catch (Exception ex) { log.error(ex.getMessage(), ex); } return val; }
From source file:org.sakaiproject.tool.assessment.qti.helper.item.ItemHelperBase.java
/** * Update path with value//w ww .j a v a 2 s. c om * * @param itemXml the item xml * @param xpath the xpath * @param value the value to set * * @return the item xml */ public Item updateItemXml(Item itemXml, String xpath, String value) { if (log.isDebugEnabled()) { log.debug("updateItemXml(Item " + itemXml + ", String" + xpath + ", String" + value + ")"); } try { itemXml.update(xpath, value); } catch (DOMException e) { log.error(e.getMessage(), e); } catch (Exception e) { log.error(e.getMessage(), e); } return itemXml; }
From source file:org.sakaiproject.tool.assessment.qti.helper.section.SectionHelperBase.java
/** * Update the Section XML for Xpath//from ww w .j a v a 2s.c o m * * @param sectionXml the Section XML * @param xpath the Xpath * @param value the value for Xpath * * @return the updated Section XML */ public Section updateSectionXml(Section sectionXml, String xpath, String value) { if (log.isDebugEnabled()) { log.debug("updateSectionXml(Item " + sectionXml + ", String" + xpath + ", String" + value + ")"); } try { sectionXml.update(xpath, value); } catch (DOMException e) { log.error(e.getMessage(), e); } catch (Exception e) { log.error(e.getMessage(), e); } return sectionXml; }