public static void notifyEdit(Document doc) { MutableContent mc = (MutableContent) doc.getUserData(MUTABLE_CONTENT_LISTENER); if (mc != null) { mc.documentChanged(); } }
public static void notifyEdit(Document doc) { MutableContent mc = (MutableContent) doc.getUserData(MUTABLE_CONTENT_LISTENER); if (mc != null) { mc.documentChanged(); } }
public static void notifyEdit(Document doc) { MutableContent mc = (MutableContent) doc.getUserData(MUTABLE_CONTENT_LISTENER); if (mc != null) { mc.documentChanged(); } }
public void rewrite(Gadget gadget, MutableContent mc) { Document doc = mc.getDocument(); NodeList list = doc.getElementsByTagName("base"); for (int i = 0; i < list.getLength(); i++) { Element baseElement = (Element) list.item(i); baseElement.getParentNode().removeChild(baseElement); if (baseElement.hasAttribute("href") && logger.isLoggable(Level.FINE)) { logger.fine("Removing base tag pointing to: " + baseElement.getAttribute("href") + " for gadget: " + gadget.getContext().getUrl().toString()); } } mc.documentChanged(); }
public void rewrite(Gadget gadget, MutableContent mc) { Document doc = mc.getDocument(); NodeList list = doc.getElementsByTagName("base"); for (int i = 0; i < list.getLength(); i++) { Element baseElement = (Element) list.item(i); baseElement.getParentNode().removeChild(baseElement); if (baseElement.hasAttribute("href") && logger.isLoggable(Level.FINE)) { logger.fine("Removing base tag pointing to: " + baseElement.getAttribute("href") + " for gadget: " + gadget.getContext().getUrl().toString()); } } mc.documentChanged(); }
public void rewrite(Gadget gadget, MutableContent mc) { Document doc = mc.getDocument(); NodeList list = doc.getElementsByTagName("base"); for (int i = 0; i < list.getLength(); i++) { Element baseElement = (Element) list.item(i); baseElement.getParentNode().removeChild(baseElement); if (baseElement.hasAttribute("href") && logger.isLoggable(Level.FINE)) { logger.fine("Removing base tag pointing to: " + baseElement.getAttribute("href") + " for gadget: " + gadget.getContext().getUrl().toString()); } } mc.documentChanged(); }
private MutableContent getContent(int docChangedTimes) { MutableContent mc = createMock(MutableContent.class); expect(mc.getDocument()).andReturn(doc).once(); if (docChangedTimes > 0) { mc.documentChanged(); expectLastCall().times(docChangedTimes); } replay(mc); return mc; } }
public void rewrite(Gadget gadget, MutableContent mutableContent) throws RewritingException { // Don't touch sanitized gadgets. if (gadget.sanitizeOutput()) { return; } // Quickly return if opensocial-i18n feature is not needed. if (!gadget.getAllFeatures().contains(I18N_FEATURE_NAME)) { return; } try { Document document = mutableContent.getDocument(); Element head = (Element)DomUtil.getFirstNamedChildNode(document.getDocumentElement(), "head"); injectI18NConstants(gadget, head); mutableContent.documentChanged(); } catch (GadgetException e) { throw new RewritingException(e, e.getHttpStatusCode()); } }
private MutableContent getContent(int docChangedTimes) { MutableContent mc = createMock(MutableContent.class); expect(mc.getDocument()).andReturn(doc).once(); if (docChangedTimes > 0) { mc.documentChanged(); expectLastCall().times(docChangedTimes); } replay(mc); return mc; } }
private MutableContent getContent(int docChangedTimes) { MutableContent mc = createMock(MutableContent.class); expect(mc.getDocument()).andReturn(doc).once(); if (docChangedTimes > 0) { mc.documentChanged(); expectLastCall().times(docChangedTimes); } replay(mc); return mc; } }
public void rewrite(Gadget gadget, MutableContent mutableContent) throws RewritingException { // Don't touch sanitized gadgets. if (gadget.sanitizeOutput()) { return; } // Quickly return if opensocial-i18n feature is not needed. if (!gadget.getAllFeatures().contains(I18N_FEATURE_NAME)) { return; } try { Document document = mutableContent.getDocument(); Element head = (Element)DomUtil.getFirstNamedChildNode(document.getDocumentElement(), "head"); injectI18NConstants(gadget, head); mutableContent.documentChanged(); } catch (GadgetException e) { throw new RewritingException(e, e.getHttpStatusCode()); } }
public void rewrite(Gadget gadget, MutableContent mutableContent) throws RewritingException { // Don't touch sanitized gadgets. if (gadget.sanitizeOutput()) { return; } // Quickly return if opensocial-i18n feature is not needed. if (!gadget.getAllFeatures().contains(I18N_FEATURE_NAME)) { return; } try { Document document = mutableContent.getDocument(); Element head = (Element)DomUtil.getFirstNamedChildNode(document.getDocumentElement(), "head"); injectI18NConstants(gadget, head); mutableContent.documentChanged(); } catch (GadgetException e) { throw new RewritingException(e, e.getHttpStatusCode()); } }
mutableContent.documentChanged(); } catch (GadgetException e) { throw new RewritingException(e.getLocalizedMessage(), e, e.getHttpStatusCode());
mutableContent.documentChanged(); } catch (GadgetException e) { throw new RewritingException(e.getLocalizedMessage(), e, e.getHttpStatusCode());
@Test public void modifyContentReflectedInTreeAndBytes() throws Exception { assertEquals(0, mhc.getNumChanges()); mhc.setContent("NEW CONTENT"); assertEquals(1, mhc.getNumChanges()); assertEquals("NEW CONTENT", new String(IOUtils.toByteArray(mhc.getContentBytes()), "UTF8")); Document document = mhc.getDocument(); assertEquals(1, document.getChildNodes().getLength()); assertEquals("NEW CONTENT", document.getChildNodes().item(0).getTextContent()); mhc.documentChanged(); assertEquals(2, mhc.getNumChanges()); }
@Test public void modifyContentReflectedInTreeAndBytes() throws Exception { assertEquals(0, mhc.getNumChanges()); mhc.setContent("NEW CONTENT"); assertEquals(1, mhc.getNumChanges()); assertEquals("NEW CONTENT", new String(IOUtils.toByteArray(mhc.getContentBytes()), "UTF8")); Document document = mhc.getDocument(); assertEquals(1, document.getChildNodes().getLength()); assertEquals("NEW CONTENT", document.getChildNodes().item(0).getTextContent()); mhc.documentChanged(); assertEquals(2, mhc.getNumChanges()); }
@Test public void modifyContentReflectedInTreeAndBytes() throws Exception { assertEquals(0, mhc.getNumChanges()); mhc.setContent("NEW CONTENT"); assertEquals(1, mhc.getNumChanges()); assertEquals("NEW CONTENT", new String(IOUtils.toByteArray(mhc.getContentBytes()), "UTF8")); Document document = mhc.getDocument(); assertEquals(1, document.getChildNodes().getLength()); assertEquals("NEW CONTENT", document.getChildNodes().item(0).getTextContent()); mhc.documentChanged(); assertEquals(2, mhc.getNumChanges()); }
@Test public void modifyContentReflectedInTreeUtf8() throws Exception { String theContent = "N\uFFFDW C\uFFFDNT\uFFFDNT"; assertEquals(0, mhc.getNumChanges()); mhc.setContent(theContent); assertEquals(1, mhc.getNumChanges()); assertEquals(theContent, new String(IOUtils.toByteArray(mhc.getContentBytes()), "UTF8")); Document document = mhc.getDocument(); assertEquals(1, document.getChildNodes().getLength()); assertEquals(theContent, document.getChildNodes().item(0).getTextContent()); mhc.documentChanged(); assertEquals(2, mhc.getNumChanges()); }
@Test public void modifyContentReflectedInTreeUtf8() throws Exception { String theContent = "N\uFFFDW C\uFFFDNT\uFFFDNT"; assertEquals(0, mhc.getNumChanges()); mhc.setContent(theContent); assertEquals(1, mhc.getNumChanges()); assertEquals(theContent, new String(IOUtils.toByteArray(mhc.getContentBytes()), "UTF8")); Document document = mhc.getDocument(); assertEquals(1, document.getChildNodes().getLength()); assertEquals(theContent, document.getChildNodes().item(0).getTextContent()); mhc.documentChanged(); assertEquals(2, mhc.getNumChanges()); }
@Test public void modifyContentReflectedInTreeUtf8() throws Exception { String theContent = "N\uFFFDW C\uFFFDNT\uFFFDNT"; assertEquals(0, mhc.getNumChanges()); mhc.setContent(theContent); assertEquals(1, mhc.getNumChanges()); assertEquals(theContent, new String(IOUtils.toByteArray(mhc.getContentBytes()), "UTF8")); Document document = mhc.getDocument(); assertEquals(1, document.getChildNodes().getLength()); assertEquals(theContent, document.getChildNodes().item(0).getTextContent()); mhc.documentChanged(); assertEquals(2, mhc.getNumChanges()); }