X-Git-Url: https://git.argeo.org/?p=gpl%2Fargeo-suite.git;a=blobdiff_plain;f=publishing%2Forg.argeo.publishing.ui%2Fsrc%2Forg%2Fargeo%2Fdocbook%2Fui%2FDbkTextInterpreter.java;fp=publishing%2Forg.argeo.publishing.ui%2Fsrc%2Forg%2Fargeo%2Fdocbook%2Fui%2FDbkTextInterpreter.java;h=51af55e46f02544b1f983515330a914dc57c3ac3;hp=f13826bd693f1d66aff097f78e7923db1b79aa7c;hb=9dd16d64cc4ea274c33a4c1acaa289c46bf5251f;hpb=9cfd54a608937b5373c6ac880a9874aa542bb2a1 diff --git a/publishing/org.argeo.publishing.ui/src/org/argeo/docbook/ui/DbkTextInterpreter.java b/publishing/org.argeo.publishing.ui/src/org/argeo/docbook/ui/DbkTextInterpreter.java index f13826b..51af55e 100644 --- a/publishing/org.argeo.publishing.ui/src/org/argeo/docbook/ui/DbkTextInterpreter.java +++ b/publishing/org.argeo.publishing.ui/src/org/argeo/docbook/ui/DbkTextInterpreter.java @@ -5,8 +5,10 @@ import javax.jcr.Node; import javax.jcr.Property; import javax.jcr.RepositoryException; -import org.argeo.cms.CmsException; import org.argeo.cms.text.TextInterpreter; +import org.argeo.jcr.Jcr; +import org.argeo.jcr.JcrException; +import org.argeo.jcr.JcrxType; /** Based on HTML with a few Wiki-like shortcuts. */ public class DbkTextInterpreter implements TextInterpreter { @@ -20,13 +22,13 @@ public class DbkTextInterpreter implements TextInterpreter { String raw = convertToStorage(node, content); validateBeforeStoring(raw); Node jcrText; - if (!node.hasNode(DocBookNames.JCR_XMLTEXT)) - jcrText = node.addNode(DocBookNames.JCR_XMLTEXT, DocBookTypes.XMLTEXT); + if (!node.hasNode(Jcr.JCR_XMLTEXT)) + jcrText = node.addNode(Jcr.JCR_XMLTEXT, JcrxType.JCRX_XMLTEXT); else - jcrText = node.getNode(DocBookNames.JCR_XMLTEXT); - jcrText.setProperty(DocBookNames.JCR_XMLCHARACTERS, raw); + jcrText = node.getNode(Jcr.JCR_XMLTEXT); + jcrText.setProperty(Jcr.JCR_XMLCHARACTERS, raw); } else { - throw new CmsException("Don't know how to interpret " + node); + throw new IllegalArgumentException("Don't know how to interpret " + node); } } else {// property Property property = (Property) item; @@ -34,7 +36,7 @@ public class DbkTextInterpreter implements TextInterpreter { } // item.getSession().save(); } catch (RepositoryException e) { - throw new CmsException("Cannot set content on " + item, e); + throw new JcrException("Cannot set content on " + item, e); } } @@ -44,7 +46,7 @@ public class DbkTextInterpreter implements TextInterpreter { String raw = raw(item); return convertFromStorage(item, raw); } catch (RepositoryException e) { - throw new CmsException("Cannot get " + item + " for edit", e); + throw new JcrException("Cannot get " + item + " for edit", e); } } @@ -55,20 +57,20 @@ public class DbkTextInterpreter implements TextInterpreter { if (item instanceof Node) { Node node = (Node) item; if (node.isNodeType(DocBookTypes.PARA)) { - Node jcrText = node.getNode(DocBookNames.JCR_XMLTEXT); - String txt = jcrText.getProperty(DocBookNames.JCR_XMLCHARACTERS).getString(); + Node jcrText = node.getNode(Jcr.JCR_XMLTEXT); + String txt = jcrText.getProperty(Jcr.JCR_XMLCHARACTERS).getString(); // TODO make it more robust txt = txt.replace("\n", "").replace("\t", ""); return txt; } else { - throw new CmsException("Don't know how to interpret " + node); + throw new IllegalArgumentException("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); + throw new JcrException("Cannot get " + item + " content", e); } }