org.apache.jackrabbit.webdav.property.DefaultDavProperty Java Examples
The following examples show how to use
org.apache.jackrabbit.webdav.property.DefaultDavProperty.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExchangeDavMethod.java From davmail with GNU General Public License v2.0 | 6 votes |
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)); } } } } }
Example #2
Source File: ExchangeDavRequest.java From davmail with GNU General Public License v2.0 | 6 votes |
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)); } } } } }
Example #3
Source File: TestCaldavHttpClient4.java From davmail with GNU General Public License v2.0 | 6 votes |
public void testRenameCalendar() throws IOException, URISyntaxException { String folderName = "testcalendarfolder"; String renamedFolderName = "renamedcalendarfolder"; URI uri = new URIBuilder().setPath("/users/" + session.getEmail() + "/calendar/" + folderName + '/').build(); // first delete calendar session.deleteFolder("calendar/" + folderName); session.deleteFolder("calendar/" + renamedFolderName); session.createCalendarFolder("calendar/" + folderName, null); DavPropertySet davPropertySet = new DavPropertySet(); davPropertySet.add(new DefaultDavProperty<>(DavPropertyName.create("displayname", Namespace.getNamespace("DAV:")), renamedFolderName)); HttpProppatch propPatchMethod = new HttpProppatch(uri, davPropertySet, new DavPropertyNameSet()); httpClient.executeDavRequest(propPatchMethod); ExchangeSession.Folder renamedFolder = session.getFolder("calendar/" + renamedFolderName); assertNotNull(renamedFolder); }
Example #4
Source File: WebdavFileObject.java From commons-vfs with Apache License 2.0 | 6 votes |
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); }
Example #5
Source File: WebdavFileObject.java From commons-vfs with Apache License 2.0 | 6 votes |
DavPropertySet getProperties(final URLFileName name, final int type, final DavPropertyNameSet nameSet, final boolean addEncoding) throws FileSystemException { try { final String urlStr = toUrlString(name); final PropFindMethod method = new PropFindMethod(urlStr, type, nameSet, DavConstants.DEPTH_0); setupMethod(method); execute(method); if (method.succeeded()) { final MultiStatus multiStatus = method.getResponseBodyAsMultiStatus(); final MultiStatusResponse response = multiStatus.getResponses()[0]; final DavPropertySet props = response.getProperties(HttpStatus.SC_OK); if (addEncoding) { final DavProperty prop = new DefaultDavProperty(RESPONSE_CHARSET, method.getResponseCharSet()); props.add(prop); } return props; } return new DavPropertySet(); } catch (final FileSystemException fse) { throw fse; } catch (final Exception e) { throw new FileSystemException("vfs.provider.webdav/get-property.error", e, getName(), name, type, nameSet.getContent(), addEncoding); } }
Example #6
Source File: Webdav4FileObject.java From commons-vfs with Apache License 2.0 | 6 votes |
private void setUserName(final GenericURLFileName fileName, final String urlStr) throws IOException { final DavPropertySet setProperties = new DavPropertySet(); final DavPropertyNameSet removeProperties = new DavPropertyNameSet(); 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; setProperties.add(new DefaultDavProperty(DeltaVConstants.COMMENT, comment)); } } setProperties.add(new DefaultDavProperty(DeltaVConstants.CREATOR_DISPLAYNAME, name)); final HttpProppatch request = new HttpProppatch(urlStr, setProperties, removeProperties); setupRequest(request); executeRequest(request); }
Example #7
Source File: VersionControlledResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * Fill the property set for this resource. * * @see DavResourceImpl#initProperties() */ protected void initProperties() { if (!propsInitialized) { super.initProperties(); properties.add(new HrefProperty(VERSION_HISTORY, locator.getResourcePath(), true)); // DAV:auto-version property: there is no auto version, explicit // EVENT_CHECKEDOUT is required. properties.add(new DefaultDavProperty(AUTO_VERSION, null, false)); if(resource==null) return; properties.add(new DefaultDavProperty(DavPropertyName.DISPLAYNAME, resource.getName(), false)); properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTTYPE, AbstractWebdavServlet.getContext().getMimeType(resource.getName()), false)); if (resource.isFolder()) return; SupportedLock supportedLock = new SupportedLock(); supportedLock.addEntry(Type.WRITE, Scope.EXCLUSIVE); properties.add(new DefaultDavProperty(DavPropertyName.SUPPORTEDLOCK, supportedLock, false)); String baseVHref = getLocatorFromResource(resource).getHref(false); if (resource.isCheckedOut() || resource.isLocked()) { log.debug("{} is checkedout", resource.getName()); properties.add(new HrefProperty(CHECKED_OUT, baseVHref, true)); properties.add(new HrefProperty(VersionResource.PREDECESSOR_SET, locator.getResourcePath(), false)); DefaultActiveLock activeLock = new DefaultActiveLock(); activeLock.setOwner(resource.getLockUser()); properties.add(new DefaultDavProperty(DavPropertyName.LOCKDISCOVERY, activeLock, false)); properties.add(new DefaultDavProperty("activelock", activeLock, Namespace.XMLNS_NAMESPACE)); } else { properties.add(new HrefProperty(CHECKED_IN, locator.getResourcePath(), true)); } } }
Example #8
Source File: VersionResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
protected void initProperties() { if (!propsInitialized) { super.initProperties(); properties.add(new DefaultDavProperty(VERSION_NAME, resource .getVersionLabel(), true)); properties.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE, resource.getVersionDate())); properties.add(new HrefProperty(VersionResource.VERSION_HISTORY, locator.getResourcePath() + resource.getID(), true)); properties.add(new DefaultDavProperty(DeltaVConstants.COMMENT, resource.getComment())); } }
Example #9
Source File: ExchangeDavMethod.java From davmail with GNU General Public License v2.0 | 5 votes |
protected void handleMultiValuedProperty(XMLStreamReader reader, MultiStatusResponse multiStatusResponse) throws XMLStreamException { String tagLocalName = reader.getLocalName(); Namespace namespace = Namespace.getNamespace(reader.getNamespaceURI()); ArrayList<String> values = new ArrayList<>(); 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)); }
Example #10
Source File: Field.java From davmail with GNU General Public License v2.0 | 5 votes |
/** * Create DavProperty object for field alias and value. * * @param alias DavMail field alias * @param value field value * @return DavProperty with value or DavPropertyName for null values */ public static PropEntry createDavProperty(String alias, String value) { Field field = Field.get(alias); if (value == null) { // return DavPropertyName to remove property return field.updatePropertyName; } else if (field.isMultivalued) { // multivalued field, split values separated by \n List<XmlSerializable> valueList = new ArrayList<>(); String[] values = value.split(","); for (final String singleValue : values) { valueList.add(document -> DomUtil.createElement(document, "v", XML, singleValue)); } return new DefaultDavProperty<>(field.updatePropertyName, valueList); } else if (field.isBooleanValue && !"haspicture".equals(alias)) { if ("true".equals(value)) { return new DefaultDavProperty<>(field.updatePropertyName, "1"); } else if ("false".equals(value)) { return new DefaultDavProperty<>(field.updatePropertyName, "0"); } else { throw new RuntimeException("Invalid value for " + field.alias + ": " + value); } } else { return new DefaultDavProperty<>(field.updatePropertyName, value); } }
Example #11
Source File: ExchangeDavRequest.java From davmail with GNU General Public License v2.0 | 5 votes |
protected void handleMultiValuedProperty(XMLStreamReader reader, MultiStatusResponse multiStatusResponse) throws XMLStreamException { String tagLocalName = reader.getLocalName(); Namespace namespace = Namespace.getNamespace(reader.getNamespaceURI()); ArrayList<String> values = new ArrayList<>(); 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)); }
Example #12
Source File: ArchivaVirtualDavResource.java From archiva with Apache License 2.0 | 5 votes |
/** * Fill the set of properties */ protected void initProperties() { if ( !exists() || propsInitialized ) { return; } // set (or reset) fundamental properties if ( getDisplayName() != null ) { properties.add( new DefaultDavProperty<>( DavPropertyName.DISPLAYNAME, getDisplayName() ) ); } if ( isCollection() ) { properties.add( new ResourceType( ResourceType.COLLECTION ) ); // Windows XP support properties.add( new DefaultDavProperty<>( DavPropertyName.ISCOLLECTION, "1" ) ); } else { properties.add( new ResourceType( ResourceType.DEFAULT_RESOURCE ) ); // Windows XP support properties.add( new DefaultDavProperty<>( DavPropertyName.ISCOLLECTION, "0" ) ); } // Need to get the ISO8601 date for properties DateTime dt = new DateTime( 0 ); DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); String modifiedDate = fmt.print( dt ); properties.add( new DefaultDavProperty<>( DavPropertyName.GETLASTMODIFIED, modifiedDate ) ); properties.add( new DefaultDavProperty<>( DavPropertyName.CREATIONDATE, modifiedDate ) ); properties.add( new DefaultDavProperty<>( DavPropertyName.GETCONTENTLENGTH, 0 ) ); propsInitialized = true; }
Example #13
Source File: WebdavFileObject.java From commons-vfs with Apache License 2.0 | 5 votes |
/** * Sets an attribute of this file. Is only called if {@link #doGetType} does not return {@link FileType#IMAGINARY}. */ @Override protected void doSetAttribute(final String attrName, final Object value) throws Exception { try { final URLFileName fileName = (URLFileName) getName(); final String urlStr = toUrlString(fileName); final DavPropertySet properties = new DavPropertySet(); final DavPropertyNameSet propertyNameSet = new DavPropertyNameSet(); final DavProperty property = new DefaultDavProperty(attrName, value, Namespace.EMPTY_NAMESPACE); if (value != null) { properties.add(property); } else { propertyNameSet.add(property.getName()); // remove property } final PropPatchMethod method = new PropPatchMethod(urlStr, properties, propertyNameSet); setupMethod(method); execute(method); if (!method.succeeded()) { throw new FileSystemException("Property '" + attrName + "' could not be set."); } } catch (final FileSystemException fse) { throw fse; } catch (final Exception e) { throw new FileSystemException("vfs.provider.webdav/set-attributes", e, getName(), attrName); } }
Example #14
Source File: Webdav4FileObject.java From commons-vfs with Apache License 2.0 | 5 votes |
/** * Sets an attribute of this file. Is only called if {@link #doGetType} does not return {@link FileType#IMAGINARY}. */ @Override protected void doSetAttribute(final String attrName, final Object value) throws Exception { try { final GenericURLFileName fileName = (GenericURLFileName) getName(); final String urlStr = toUrlString(fileName); final DavPropertySet properties = new DavPropertySet(); final DavPropertyNameSet propertyNameSet = new DavPropertyNameSet(); final DavProperty property = new DefaultDavProperty(attrName, value, Namespace.EMPTY_NAMESPACE); if (value != null) { properties.add(property); } else { propertyNameSet.add(property.getName()); // remove property } final HttpProppatch request = new HttpProppatch(urlStr, properties, propertyNameSet); setupRequest(request); final HttpResponse response = executeRequest(request); if (!request.succeeded(response)) { throw new FileSystemException("Property '" + attrName + "' could not be set."); } } catch (final FileSystemException fse) { throw fse; } catch (final Exception e) { throw new FileSystemException("vfs.provider.webdav/set-attributes", e, getName(), attrName); } }
Example #15
Source File: Webdav4FileObject.java From commons-vfs with Apache License 2.0 | 5 votes |
DavPropertySet getProperties(final GenericURLFileName name, final int type, final DavPropertyNameSet nameSet, final boolean addEncoding) throws FileSystemException { try { final String urlStr = toUrlString(name); final HttpPropfind request = new HttpPropfind(urlStr, type, nameSet, DavConstants.DEPTH_0); setupRequest(request); final HttpResponse res = executeRequest(request); if (request.succeeded(res)) { final MultiStatus multiStatus = request.getResponseBodyAsMultiStatus(res); final MultiStatusResponse response = multiStatus.getResponses()[0]; final DavPropertySet props = response.getProperties(HttpStatus.SC_OK); if (addEncoding) { final ContentType resContentType = ContentType.getOrDefault(res.getEntity()); final DavProperty prop = new DefaultDavProperty(RESPONSE_CHARSET, resContentType.getCharset().name()); props.add(prop); } return props; } return new DavPropertySet(); } catch (final FileSystemException fse) { throw fse; } catch (final Exception e) { throw new FileSystemException("vfs.provider.webdav/get-property.error", e, getName(), name, type, nameSet.getContent(), addEncoding); } }
Example #16
Source File: DavResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
/** * Fill the set of properties */ protected void initProperties() { if (!exists() || propsInitialized) { return; } // set (or reset) fundamental properties if (getDisplayName() != null) { properties.add(new DefaultDavProperty(DavPropertyName.DISPLAYNAME, getDisplayName())); } if (isCollection()) { properties.add(new ResourceType(ResourceType.COLLECTION)); // Windows XP support properties.add(new DefaultDavProperty(DavPropertyName.ISCOLLECTION, "1")); } else { properties.add(new ResourceType(ResourceType.DEFAULT_RESOURCE)); // Windows XP support properties.add(new DefaultDavProperty(DavPropertyName.ISCOLLECTION, "0")); } /* * set current lock information. If no lock is set to this resource, an * empty lockdiscovery will be returned in the response. */ // properties.add(new LockDiscovery(getLock(Type.WRITE, // Scope.EXCLUSIVE))); /* lock support information: all locks are lockable. */ // SupportedLock supportedLock = new SupportedLock(); // supportedLock.addEntry(Type.WRITE, Scope.EXCLUSIVE); // properties.add(supportedLock); properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTLENGTH, this.resource.getContentLength())); // Set Dav property LastModified long lastmodTime = IOUtil.UNDEFINED_TIME; if (this.resource.getLastModified() != null) { lastmodTime = this.resource.getLastModified().getTime(); } String lastModified = IOUtil.getLastModified(lastmodTime); properties.add(new DefaultDavProperty(DavPropertyName.GETLASTMODIFIED, lastModified)); // Set Dav property CreationDate long creationTime = IOUtil.UNDEFINED_TIME; if (this.resource.getCreationDate() != null) { creationTime = this.resource.getCreationDate().getTime(); } String creationDate = IOUtil.getCreated(creationTime); properties.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE, creationDate)); propsInitialized = true; }