private static DavProperty<List<XmlSerializable>> createNodeTypeProperty(String localName, String[] ntNames) { // convert the specified node type names to a xml-serializable value List<XmlSerializable> val = new ArrayList<XmlSerializable>(); for (final String ntName : ntNames) { val.add(new XmlSerializable() { public Element toXml(Document document) { return NodeTypeUtil.ntNameToXml(ntName, document); } }); } return new DefaultDavProperty<List<XmlSerializable>>(localName, val, ItemResourceConstants.NAMESPACE, false); }
private static DavProperty<List<XmlSerializable>> createNodeTypeProperty(String localName, String[] ntNames) { // convert the specified node type names to a xml-serializable value List<XmlSerializable> val = new ArrayList<XmlSerializable>(); for (final String ntName : ntNames) { val.add(new XmlSerializable() { public Element toXml(Document document) { return NodeTypeUtil.ntNameToXml(ntName, document); } }); } return new DefaultDavProperty<List<XmlSerializable>>(localName, val, ItemResourceConstants.NAMESPACE, false); }
private static DavProperty<List<XmlSerializable>> createValuesProperty(Value[] jcrValues) { // convert the specified jcr values to a xml-serializable value List<XmlSerializable> val = new ArrayList<XmlSerializable>(); for (final Value jcrValue : jcrValues) { val.add(new XmlSerializable() { public Element toXml(Document document) { try { return ValueUtil.valueToXml(jcrValue, document); } catch (RepositoryException e) { throw new RuntimeException(e); } } }); } return new DefaultDavProperty<List<XmlSerializable>>(JcrRemotingConstants.JCR_VALUES_LN, val, ItemResourceConstants.NAMESPACE, false); }
private static DavProperty<List<XmlSerializable>> createValuesProperty(Value[] jcrValues) { // convert the specified jcr values to a xml-serializable value List<XmlSerializable> val = new ArrayList<XmlSerializable>(); for (final Value jcrValue : jcrValues) { val.add(new XmlSerializable() { public Element toXml(Document document) { try { return ValueUtil.valueToXml(jcrValue, document); } catch (RepositoryException e) { throw new RuntimeException(e); } } }); } return new DefaultDavProperty<List<XmlSerializable>>(JcrRemotingConstants.JCR_VALUES_LN, val, ItemResourceConstants.NAMESPACE, false); }
public void setContentLength(long contentLength) { if (contentLength > IOUtil.UNDEFINED_LENGTH) { properties.add(new DefaultDavProperty<String>(DavPropertyName.GETCONTENTLENGTH, contentLength + "")); } }
public void setETag(String etag) { if (etag != null) { properties.add(new DefaultDavProperty<String>(DavPropertyName.GETETAG, etag)); } }
public void setContentLanguage(String contentLanguage) { if (contentLanguage != null) { properties.add(new DefaultDavProperty<String>(DavPropertyName.GETCONTENTLANGUAGE, contentLanguage)); } }
public void setModificationTime(long modTime) { if (modTime <= IOUtil.UNDEFINED_TIME) { modificationTime = new Date().getTime(); } else { modificationTime = modTime; } String lastModified = IOUtil.getLastModified(modificationTime); properties.add(new DefaultDavProperty<String>(DavPropertyName.GETLASTMODIFIED, lastModified)); }
private DavProperty<List<XmlSerializable>> createUnRegisterNodeTypesProperty(SessionInfo sessionInfo, Name[] nodeTypeNames) throws IOException, RepositoryException { NamePathResolver resolver = getNamePathResolver(sessionInfo); List<XmlSerializable> val = new ArrayList<XmlSerializable>(); for (Name ntName : nodeTypeNames) { final String jcrName = resolver.getJCRName(ntName); val.add(new XmlSerializable() { public Element toXml(Document document) { Element ntNameElem = document.createElementNS(JcrRemotingConstants.NS_URI, JcrRemotingConstants.NS_PREFIX + ":" + JcrRemotingConstants.XML_NODETYPENAME); org.w3c.dom.Text txt = document.createTextNode(jcrName); ntNameElem.appendChild(txt); return ntNameElem; } }); } return new DefaultDavProperty<List<XmlSerializable>>(JcrRemotingConstants.JCR_NODETYPES_CND_LN, val, ItemResourceConstants.NAMESPACE, false); }
private DavProperty<List<XmlSerializable>> createUnRegisterNodeTypesProperty(SessionInfo sessionInfo, Name[] nodeTypeNames) throws IOException, RepositoryException { NamePathResolver resolver = getNamePathResolver(sessionInfo); List<XmlSerializable> val = new ArrayList<XmlSerializable>(); for (Name ntName : nodeTypeNames) { final String jcrName = resolver.getJCRName(ntName); val.add(new XmlSerializable() { public Element toXml(Document document) { Element ntNameElem = document.createElementNS(JcrRemotingConstants.NS_URI, JcrRemotingConstants.NS_PREFIX + ":" + JcrRemotingConstants.XML_NODETYPENAME); org.w3c.dom.Text txt = document.createTextNode(jcrName); ntNameElem.appendChild(txt); return ntNameElem; } }); } return new DefaultDavProperty<List<XmlSerializable>>(JcrRemotingConstants.JCR_NODETYPES_CND_LN, val, ItemResourceConstants.NAMESPACE, false); }
public void setContentType(String mimeType, String encoding) { String contentType = IOUtil.buildContentType(mimeType, encoding); if (contentType != null) { properties.add(new DefaultDavProperty<String>(DavPropertyName.GETCONTENTTYPE, contentType)); } }
public void setCreationTime(long creationTime) { String created = IOUtil.getCreated(creationTime); properties.add(new DefaultDavProperty<String>(DavPropertyName.CREATIONDATE, created)); }
protected void handleMultiValuedProperty(XMLStreamReader reader, MultiStatusResponse multiStatusResponse) throws XMLStreamException { String tagLocalName = reader.getLocalName(); Namespace namespace = Namespace.getNamespace(reader.getNamespaceURI()); ArrayList<String> values = new ArrayList<String>(); while (reader.hasNext() && !XMLStreamUtil.isEndTag(reader, tagLocalName)) { reader.next(); if (XMLStreamUtil.isStartTag(reader)) { String tagContent = getTagContent(reader); if (tagContent != null) { values.add(tagContent); } } } multiStatusResponse.add(new DefaultDavProperty(tagLocalName, values, namespace)); }
protected void initProperties(DavPropertySet propertySet) { super.initProperties(propertySet); propertySet.add(new DefaultDavProperty(DavPropertyName.GETCONTENTLENGTH, getContentLength())); propertySet.add(new DefaultDavProperty(DavPropertyName.GETCONTENTTYPE, getContentType())); }
@Override public void init(XWikiDavResource parent, String name, String relativePath) throws DavException { super.init(parent, name, relativePath); String strTimeOfCreation = DavConstants.creationDateFormat.format(timeOfCreation); getProperties().add(new DefaultDavProperty(DavPropertyName.CREATIONDATE, strTimeOfCreation)); String strTimeOfModification = DavConstants.modificationDateFormat.format(timeOfLastModification); getProperties().add(new DefaultDavProperty(DavPropertyName.GETLASTMODIFIED, strTimeOfModification)); getProperties().add(new DefaultDavProperty(DavPropertyName.GETETAG, strTimeOfModification)); getProperties().add(new DefaultDavProperty(DavPropertyName.GETCONTENTLANGUAGE, "en")); String contentType = isCollection() ? "text/directory" : "application/octet-stream"; getProperties().add(new DefaultDavProperty(DavPropertyName.GETCONTENTTYPE, contentType)); int contentLength = (data != null) ? data.length : 0; getProperties().add(new DefaultDavProperty(DavPropertyName.GETCONTENTLENGTH, contentLength)); }
public void setProperty(Object propertyName, Object propertyValue) { if (propertyValue == null) { log.warn("Ignore 'setProperty' for " + propertyName + "with null value."); return; } if (propertyValue instanceof DavProperty) { properties.add((DavProperty<?>)propertyValue); } else { DavPropertyName pName; if (propertyName instanceof DavPropertyName) { pName = (DavPropertyName)propertyName; } else { // create property name with default DAV: namespace pName = DavPropertyName.create(propertyName.toString()); } properties.add(new DefaultDavProperty<Object>(pName, propertyValue)); } } }
private void setUserName(final URLFileName fileName, final String urlStr) throws IOException { final List<DefaultDavProperty> list = new ArrayList<>(); String name = builder.getCreatorName(getFileSystem().getFileSystemOptions()); final String userName = fileName.getUserName(); if (name == null) { name = userName; } else { if (userName != null) { final String comment = "Modified by user " + userName; list.add(new DefaultDavProperty(DeltaVConstants.COMMENT, comment)); } } list.add(new DefaultDavProperty(DeltaVConstants.CREATOR_DISPLAYNAME, name)); final PropPatchMethod method = new PropPatchMethod(urlStr, list); setupMethod(method); execute(method); } }
protected void handleProperty(XMLStreamReader reader, MultiStatusResponse multiStatusResponse) throws XMLStreamException { while (reader.hasNext() && !XMLStreamUtil.isEndTag(reader, "prop")) { reader.next(); if (XMLStreamUtil.isStartTag(reader)) { Namespace namespace = Namespace.getNamespace(reader.getNamespaceURI()); String tagLocalName = reader.getLocalName(); if (reader.getAttributeCount() > 0 && "mv.string".equals(reader.getAttributeValue(0))) { handleMultiValuedProperty(reader, multiStatusResponse); } else { String tagContent = getTagContent(reader); if (tagContent != null) { multiStatusResponse.add(new DefaultDavProperty(tagLocalName, tagContent, namespace)); } } } } }
/** * @param data Data to be set as the content of this temporary file. * @param modificationTime Time of modification. */ public void update(byte[] data, Date modificationTime) { this.data = data.clone(); setModified(modificationTime); getProperties().add(new DefaultDavProperty(DavPropertyName.GETCONTENTLENGTH, this.data.length)); }
/** * Fill the property set for this resource. */ @Override protected void initProperties() { super.initProperties(); // change resource type defined by default item collection properties.add(new ResourceType(ResourceType.VERSION_HISTORY)); // jcr specific property pointing to the node this history belongs to try { properties.add(new DefaultDavProperty<String>(JCR_VERSIONABLEUUID, ((VersionHistory)item).getVersionableIdentifier())); } catch (RepositoryException e) { log.error(e.getMessage()); } } }