public Importable translate(Node resourceNode, Document descriptor, String contextPath, String archiveBasePath) { String content = XPathHelper.getNodeValue("/CONTENT/BODY/TEXT", descriptor); String title = XPathHelper.getNodeValue("/CONTENT/TITLE/@value", descriptor).replaceAll("/", "_"); int priority = Integer.parseInt(((Element)resourceNode).getAttribute("priority")); contextPath = contextPath + title; //Validator.escapeResourceName(title); TextDocument text = new TextDocument(); text.setContent(content); text.setTitle(title); text.setContextPath(contextPath); text.setSequenceNum(priority); return text; }
title = ((TextDocument)thing).getTitle(); contents = new ByteArrayInputStream(((TextDocument)thing).getContent().getBytes()); id = contentHostingService.getSiteCollection(siteId) + thing.getContextPath(); contentType = "text/plain";
title = ((TextDocument)thing).getTitle(); contents = new ByteArrayInputStream(((TextDocument)thing).getContent().getBytes()); id = contentHostingService.getSiteCollection(siteId) + thing.getContextPath(); contentType = "text/plain";
public Importable translate(Node resourceNode, Document descriptor, String contextPath, String archiveBasePath) { String content = XPathHelper.getNodeValue("/CONTENT/BODY/TEXT", descriptor); String title = XPathHelper.getNodeValue("/CONTENT/TITLE/@value", descriptor).trim().replaceAll("\\<.*?\\>", "").replaceAll("/", "_"); int priority = Integer.parseInt(((Element)resourceNode).getAttribute("priority")); // SmartText replaces the double-quote with the HTML entity equivalent content.replaceAll(""", "\""); contextPath = contextPath + title; //Validator.escapeResourceName(title); //Some smart text has files, frequently zipped up 'learning modules' if (!XPathHelper.selectNode("/CONTENT/FILES", descriptor).hasChildNodes()) { TextDocument text = new TextDocument(); text.setContent(content); text.setTitle(title); text.setContextPath(contextPath); text.setSequenceNum(priority); return text; } else { Folder folder = new Folder(); folder.setDescription(content); folder.setTitle(title); folder.setPath(contextPath); folder.setSequenceNum(priority); return folder; } }