1 13 package info.magnolia.cms.exchange.simple; 14 15 import info.magnolia.cms.core.ie.filters.VersionFilter; 16 17 import org.xml.sax.Attributes ; 18 import org.xml.sax.SAXException ; 19 import org.xml.sax.XMLReader ; 20 import org.xml.sax.helpers.AttributesImpl ; 21 22 23 28 class FrozenElementFilter extends VersionFilter { 29 30 33 private int inVersionElement; 34 35 38 private String nodeName; 39 40 44 protected FrozenElementFilter(XMLReader parent) { 45 super(parent); 46 } 47 48 protected void setNodeName(String name) { 49 this.nodeName = name; 50 } 51 52 55 public void endElement(String uri, String localName, String qName) throws SAXException { 56 57 if (inVersionElement > 0) { 58 inVersionElement--; 59 return; 60 } 61 62 super.endElement(uri, localName, qName); 63 } 64 65 68 public void characters(char[] ch, int start, int length) throws SAXException { 69 if (inVersionElement == 0) { 71 super.characters(ch, start, length); 72 } 73 } 74 75 78 public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { 79 80 if (inVersionElement > 0) { 81 inVersionElement++; 82 return; 83 } 84 if ("sv:property".equals(qName)) { String attName = atts.getValue("sv:name"); if (attName != null) { 87 if ("jcr:predecessors".equals(attName) 88 || "jcr:baseVersion".equals(attName) 89 || "jcr:primaryType".equals(attName) 90 || "jcr:uuid".equals(attName) 91 || "jcr:mixinTypes".equals(attName) 92 || "jcr:isCheckedOut".equals(attName) 93 || "jcr:created".equals(attName) 94 || "mgnl:sequenceposition".equals(attName) 95 || "jcr:versionHistory" .equals(attName)) { 97 inVersionElement++; 98 return; 99 } 100 else if ("jcr:frozenPrimaryType".equals(attName)) { 101 AttributesImpl attributesImpl = new AttributesImpl (atts); 102 int index = attributesImpl.getIndex("sv:name"); 103 attributesImpl.setValue(index, "jcr:primaryType"); 104 atts = attributesImpl; 105 } 106 else if ("jcr:frozenMixinTypes".equals(attName)) { 107 AttributesImpl attributesImpl = new AttributesImpl (atts); 108 int index = attributesImpl.getIndex("sv:name"); 109 attributesImpl.setValue(index, "jcr:mixinTypes"); 110 atts = attributesImpl; 111 } 112 else if ("jcr:frozenUuid".equals(attName)) { 113 AttributesImpl attributesImpl = new AttributesImpl (atts); 114 int index = attributesImpl.getIndex("sv:name"); 115 attributesImpl.setValue(index, "jcr:uuid"); 116 atts = attributesImpl; 117 } 118 } 119 } 120 else if ("sv:node".equals(qName)) { 121 String attName = atts.getValue("sv:name"); 122 if (attName != null) { 123 if ("jcr:frozenNode".equals(attName)) { 124 AttributesImpl attributesImpl = new AttributesImpl (atts); 125 int index = attributesImpl.getIndex("sv:name"); 126 attributesImpl.setValue(index, this.nodeName); 127 atts = attributesImpl; 128 } 129 } 130 } 131 132 super.startElement(uri, localName, qName, atts); 133 } 134 135 } 136 | Popular Tags |