X-Git-Url: https://git.argeo.org/?p=gpl%2Fargeo-suite.git;a=blobdiff_plain;f=publishing%2Forg.argeo.publishing.ui%2Fsrc%2Forg%2Fargeo%2Fcms%2Ftext%2FIdentityTextInterpreter.java;fp=publishing%2Forg.argeo.publishing.ui%2Fsrc%2Forg%2Fargeo%2Fcms%2Ftext%2FIdentityTextInterpreter.java;h=0000000000000000000000000000000000000000;hp=ce59ed6630f2bb3c613ffeff53574c00c79d1c9f;hb=2824e4dce1c2239500f865efaac23f2880b12277;hpb=2c7baf5cc1437770abc7df32e29e3c9ca29b7132 diff --git a/publishing/org.argeo.publishing.ui/src/org/argeo/cms/text/IdentityTextInterpreter.java b/publishing/org.argeo.publishing.ui/src/org/argeo/cms/text/IdentityTextInterpreter.java deleted file mode 100644 index ce59ed6..0000000 --- a/publishing/org.argeo.publishing.ui/src/org/argeo/cms/text/IdentityTextInterpreter.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.argeo.cms.text; - -import javax.jcr.Item; -import javax.jcr.Node; -import javax.jcr.Property; -import javax.jcr.RepositoryException; - -import org.argeo.cms.CmsException; - -/** Based on HTML with a few Wiki-like shortcuts. */ -public class IdentityTextInterpreter implements TextInterpreter, CmsNames { - - @Override - public void write(Item item, String content) { - try { - if (item instanceof Node) { - Node node = (Node) item; - if (node.isNodeType(CmsTypes.CMS_STYLED)) { - String raw = convertToStorage(node, content); - validateBeforeStoring(raw); - node.setProperty(CMS_CONTENT, raw); - } else { - throw new CmsException("Don't know how to interpret " + node); - } - } else {// property - Property property = (Property) item; - property.setValue(content); - } - // item.getSession().save(); - } catch (RepositoryException e) { - throw new CmsException("Cannot set content on " + item, e); - } - } - - @Override - public String readSimpleHtml(Item item) { - return raw(item); - } - - @Override - public String read(Item item) { - try { - String raw = raw(item); - return convertFromStorage(item, raw); - } catch (RepositoryException e) { - throw new CmsException("Cannot get " + item + " for edit", e); - } - } - - @Override - public String raw(Item item) { - try { - item.getSession().refresh(true); - if (item instanceof Node) { - Node node = (Node) item; - if (node.isNodeType(CmsTypes.CMS_STYLED)) { - // WORKAROUND FOR BROKEN PARARAPHS - if (!node.hasProperty(CMS_CONTENT)) { - node.setProperty(CMS_CONTENT, ""); - node.getSession().save(); - } - - return node.getProperty(CMS_CONTENT).getString(); - } else { - throw new CmsException("Don't know how to interpret " + node); - } - } else {// property - Property property = (Property) item; - return property.getString(); - } - } catch (RepositoryException e) { - throw new CmsException("Cannot get " + item + " content", e); - } - } - - // EXTENSIBILITY - /** - * To be overridden, in order to make sure that only valid strings are being - * stored. - */ - protected void validateBeforeStoring(String raw) { - } - - /** To be overridden, in order to support additional formatting. */ - protected String convertToStorage(Item item, String content) throws RepositoryException { - return content; - - } - - /** To be overridden, in order to support additional formatting. */ - protected String convertFromStorage(Item item, String content) throws RepositoryException { - return content; - } -}