use of org.apache.jackrabbit.spi.commons.nodetype.compact.CompactNodeTypeDefWriter in project jackrabbit by apache.
the class AbstractRecord method writeNodeTypeDef.
/**
* {@inheritDoc}
*/
public void writeNodeTypeDef(QNodeTypeDefinition ntd) throws JournalException {
try {
StringWriter sw = new StringWriter();
CompactNodeTypeDefWriter writer = new CompactNodeTypeDefWriter(sw, nsResolver, resolver);
writer.write(ntd);
writer.close();
writeString(sw.toString());
} catch (IOException e) {
String msg = "I/O error while writing node type definition.";
throw new JournalException(msg, e);
}
}
use of org.apache.jackrabbit.spi.commons.nodetype.compact.CompactNodeTypeDefWriter in project jackrabbit by apache.
the class RepositoryServiceImpl method createRegisterNodeTypesProperty.
private DavProperty<List<XmlSerializable>> createRegisterNodeTypesProperty(SessionInfo sessionInfo, QNodeTypeDefinition[] nodeTypeDefinitions, final boolean allowUpdate) throws IOException {
// create xml elements for both cnd and allow update value.
List<XmlSerializable> val = new ArrayList<XmlSerializable>();
StringWriter sw = new StringWriter();
CompactNodeTypeDefWriter writer = new CompactNodeTypeDefWriter(sw, new NamespaceResolverImpl(sessionInfo), true);
writer.write(Arrays.asList(nodeTypeDefinitions));
writer.close();
final String cnd = sw.toString();
val.add(new XmlSerializable() {
public Element toXml(Document document) {
Element cndElem = document.createElementNS(JcrRemotingConstants.NS_URI, JcrRemotingConstants.NS_PREFIX + ":" + JcrRemotingConstants.XML_CND);
DomUtil.setText(cndElem, cnd);
return cndElem;
}
});
val.add(new XmlSerializable() {
public Element toXml(Document document) {
Element allowElem = document.createElementNS(JcrRemotingConstants.NS_URI, JcrRemotingConstants.NS_PREFIX + ":" + JcrRemotingConstants.XML_ALLOWUPDATE);
DomUtil.setText(allowElem, Boolean.toString(allowUpdate));
return allowElem;
}
});
return new DefaultDavProperty<List<XmlSerializable>>(JcrRemotingConstants.JCR_NODETYPES_CND_LN, val, ItemResourceConstants.NAMESPACE, false);
}
Aggregations