/** * Returns a new copy of a Document implementation. This will return an <code>IPortalDocument * </code> implementation. * * @return an empty org.w3c.dom.Document implementation */ public static Document getThreadDocument() { return getThreadDocumentBuilder().newDocument(); }
@Override public Node convertToDom(XMLEventReader xmlEventReader) throws XMLStreamException { // Convert the XmlEventReader into a DOM final XMLOutputFactory xmlOutputFactory = this.getXmlOutputFactory(); final DOMResult sourceDom = new DOMResult(DocumentFactory.getThreadDocument()); final XMLEventWriter sourceWriter = xmlOutputFactory.createXMLEventWriter(sourceDom); sourceWriter.add(xmlEventReader); sourceWriter.flush(); sourceWriter.close(); return sourceDom.getNode(); }
private Document loadTestDocument() throws IOException, SAXException { final InputStream testDocStream = this.getClass().getResourceAsStream("/org/apereo/portal/xml/xmlUtilitiesTest.xml"); final Document testDoc = DocumentFactory.getDocumentFromStream(testDocStream, "xmlUtilitiesTest.xml"); IOUtils.closeQuietly(testDocStream); return testDoc; } }
@Override public Node convertToDom(XMLEventReader xmlEventReader) throws XMLStreamException { // Convert the XmlEventReader into a DOM final XMLOutputFactory xmlOutputFactory = this.getXmlOutputFactory(); final DOMResult sourceDom = new DOMResult(DocumentFactory.getThreadDocument()); final XMLEventWriter sourceWriter = xmlOutputFactory.createXMLEventWriter(sourceDom); sourceWriter.add(xmlEventReader); sourceWriter.flush(); sourceWriter.close(); return sourceDom.getNode(); }
public static Document constructILF(Document PLF, List<Document> sequence, IPerson person) { if (LOG.isDebugEnabled()) { LOG.debug("Constructing ILF for IPerson='" + person + "'"); } // first construct the destination document and root element. The root // element should be a complete copy of the PLF's root including its // node identifier in the new document. This requires the use of // the implementation class to set the identifier for that node // in the document. Document result = DocumentFactory.getThreadDocument(); Element plfLayout = PLF.getDocumentElement(); Element ilfLayout = (Element) result.importNode(plfLayout, false); result.appendChild(ilfLayout); Element plfRoot = (Element) plfLayout.getFirstChild(); Element ilfRoot = (Element) result.importNode(plfRoot, false); ilfLayout.appendChild(ilfRoot); if (ilfRoot.getAttribute(Constants.ATT_ID) != null) ilfRoot.setIdAttribute(Constants.ATT_ID, true); // build the auth principal for determining if pushed channels can be // used by this user EntityIdentifier ei = person.getEntityIdentifier(); AuthorizationServiceFacade authS = AuthorizationServiceFacade.instance(); IAuthorizationPrincipal ap = authS.newPrincipal(ei.getKey(), ei.getType()); // now merge fragments one at a time into ILF document for (final Document document : sequence) { mergeFragment(document, result, ap); } return result; }
/** * Returns a new copy of a Document implementation. This will return an <code>IPortalDocument * </code> implementation. * * @return an empty org.w3c.dom.Document implementation */ public static Document getThreadDocument() { return getThreadDocumentBuilder().newDocument(); }
/** * Method for acquiring copies of fragment layouts to assist in debugging. No infrastructure * code calls this but channels designed to expose the structure of the cached fragments use * this to obtain copies. * * @return Map */ @Override public Map<String, Document> getFragmentLayoutCopies() { // since this is only visible in fragment list in administrative portlet, use default portal // locale final Locale defaultLocale = localeManagerFactory.getPortalLocales().get(0); final Map<String, Document> layouts = new HashMap<>(); final List<FragmentDefinition> definitions = this.fragmentUtils.getFragmentDefinitions(); for (final FragmentDefinition fragmentDefinition : definitions) { final Document layout = DocumentFactory.getThreadDocument(); final UserView userView = this.fragmentUtils.getUserView(fragmentDefinition, defaultLocale); if (userView == null) { logger.warn( "No UserView found for FragmentDefinition {}, it will be skipped.", fragmentDefinition.getName()); continue; } final Node copy = layout.importNode(userView.getLayout().getDocumentElement(), true); layout.appendChild(copy); layouts.put(fragmentDefinition.getOwnerId(), layout); } return layouts; }
public static Document getDocumentFromStream(InputStream stream, String publicId) throws IOException, SAXException { DocumentBuilder builder = getThreadDocumentBuilder(); InputSource source = new InputSource(stream); source.setPublicId(publicId); Document doc = builder.parse(source); return doc; }
int userId = person.getID(); final int realUserId = userId; Document doc = DocumentFactory.getThreadDocument(); Element root = doc.createElement("layout");
public static Document getDocumentFromStream(InputStream stream, String publicId) throws IOException, SAXException { DocumentBuilder builder = getThreadDocumentBuilder(); InputSource source = new InputSource(stream); source.setPublicId(publicId); Document doc = builder.parse(source); return doc; }
public static Document getDocumentFromStream( InputStream stream, EntityResolver er, String publicId) throws IOException, SAXException { DocumentBuilder builder = getThreadDocumentBuilder(); builder.setEntityResolver(er); InputSource source = new InputSource(stream); source.setPublicId(publicId); Document doc = builder.parse(source); return doc; }
public static Document getDocumentFromStream( InputStream stream, EntityResolver er, String publicId) throws IOException, SAXException { DocumentBuilder builder = getThreadDocumentBuilder(); builder.setEntityResolver(er); InputSource source = new InputSource(stream); source.setPublicId(publicId); Document doc = builder.parse(source); return doc; }