org.apache.jackrabbit.webdav.property.DavPropertySet Java Examples
The following examples show how to use
org.apache.jackrabbit.webdav.property.DavPropertySet.
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: DavFile.java From cosmo with Apache License 2.0 | 6 votes |
/** */ protected void loadLiveProperties(DavPropertySet properties) { super.loadLiveProperties(properties); FileItem content = (FileItem) getItem(); if (content == null) { return; } if (content.getContentLanguage() != null) { properties.add(new ContentLanguage(content.getContentLanguage())); } properties.add(new ContentLength(content.getContentLength())); properties.add(new ContentType(content.getContentType(), content.getContentEncoding())); }
Example #2
Source File: DavExchangeSession.java From davmail with GNU General Public License v2.0 | 6 votes |
/** * Build Contact instance from multistatusResponse info * * @param multiStatusResponse response * @throws IOException on error * @throws DavMailException on error */ public Contact(MultiStatusResponse multiStatusResponse) throws IOException, DavMailException { setHref(URIUtil.decode(multiStatusResponse.getHref())); DavPropertySet properties = multiStatusResponse.getProperties(HttpStatus.SC_OK); permanentUrl = getURLPropertyIfExists(properties, "permanenturl"); etag = getPropertyIfExists(properties, "etag"); displayName = getPropertyIfExists(properties, "displayname"); for (String attributeName : CONTACT_ATTRIBUTES) { String value = getPropertyIfExists(properties, attributeName); if (value != null) { if ("bday".equals(attributeName) || "anniversary".equals(attributeName) || "lastmodified".equals(attributeName) || "datereceived".equals(attributeName)) { value = convertDateFromExchange(value); } else if ("haspicture".equals(attributeName) || "private".equals(attributeName)) { value = "1".equals(value) ? "true" : "false"; } put(attributeName, value); } } }
Example #3
Source File: WebdavFileContentInfoFactory.java From commons-vfs with Apache License 2.0 | 6 votes |
@Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { final WebdavFileObject file = (WebdavFileObject) FileObjectUtils.getAbstractFileObject(fileContent.getFile()); String contentType = null; String contentEncoding = null; final DavPropertyNameSet nameSet = new DavPropertyNameSet(); nameSet.add(DavPropertyName.GETCONTENTTYPE); final DavPropertySet propertySet = file.getProperties((URLFileName) file.getName(), nameSet, true); DavProperty property = propertySet.get(DavPropertyName.GETCONTENTTYPE); if (property != null) { contentType = (String) property.getValue(); } property = propertySet.get(WebdavFileObject.RESPONSE_CHARSET); if (property != null) { contentEncoding = (String) property.getValue(); } return new DefaultFileContentInfo(contentType, contentEncoding); }
Example #4
Source File: DavUserPrincipal.java From cosmo with Apache License 2.0 | 6 votes |
protected void loadLiveProperties(DavPropertySet properties) { properties.add(new CreationDate(user.getCreationDate())); properties.add(new DisplayName(getDisplayName())); properties.add(new ResourceType(getResourceTypes())); properties.add(new IsCollection(isCollection())); properties.add(new Etag(user.getEntityTag())); properties.add(new LastModified(user.getModifiedDate())); properties.add(new CalendarHomeSet(getResourceLocator(), user)); // for now scheduling is an option if(isSchedulingEnabled()) { properties.add(new CalendarUserAddressSet(user, userIdentitySupplier)); properties.add(new ScheduleInboxURL(getResourceLocator(), user)); properties.add(new ScheduleOutboxURL(getResourceLocator(), user)); } properties.add(new AlternateUriSet()); properties.add(new PrincipalUrl(getResourceLocator(), user)); properties.add(new GroupMembership()); }
Example #5
Source File: CtagHandler.java From openmeetings with Apache License 2.0 | 6 votes |
@Override BaseDavRequest internalSyncItems() throws IOException, DavException { //Calendar already inited. DavPropertyNameSet properties = new DavPropertyNameSet(); properties.add(DNAME_GETCTAG); HttpPropFindMethod method = new HttpPropFindMethod(path, properties, CalDAVConstants.DEPTH_0); HttpResponse httpResponse = client.execute(method, context); if (method.succeeded(httpResponse)) { for (MultiStatusResponse response : method.getResponseBodyAsMultiStatus(httpResponse).getResponses()) { DavPropertySet set = response.getProperties(SC_OK); String ctag = AppointmentManager.getTokenFromProperty(set.get(DNAME_GETCTAG)); if (ctag != null && !ctag.equals(calendar.getToken())) { EtagsHandler etagsHandler = new EtagsHandler(path, calendar, client, context, appointmentDao, utils); etagsHandler.syncItems(); calendar.setToken(ctag); } } } else { log.error("Error executing PROPFIND Method, with status Code: {}", httpResponse.getStatusLine().getStatusCode()); } return method; }
Example #6
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 #7
Source File: TestExchangePropfindMethod.java From davmail with GNU General Public License v2.0 | 6 votes |
public void testGetFolder() throws IOException { ExchangeSession.Folder folder = session.getFolder("INBOX"); assertNotNull(folder); DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet(); // davPropertyNameSet.add(Field.getPropertyName("displayname")); //PropFindMethod propFindMethod = new PropFindMethod(URIUtil.encodePath(((DavExchangeSession)session).getFolderPath(folder.folderPath))); //session.httpClient.executeMethod(propFindMethod); //propFindMethod.getResponseBodyAsMultiStatus(); ExchangePropFindMethod exchangePropFindMethod = new ExchangePropFindMethod(URIUtil.encodePath(((DavExchangeSession)session).getFolderPath(folder.folderPath)), davPropertyNameSet, 0); //PropFindMethod propFindMethod = new PropFindMethod(URIUtil.encodePath(((DavExchangeSession)session).getFolderPath(folder.folderPath))); session.httpClient.executeMethod(exchangePropFindMethod); MultiStatusResponse response = exchangePropFindMethod.getResponse(); DavPropertySet properties = response.getProperties(HttpStatus.SC_OK); System.out.println(properties); }
Example #8
Source File: DavExchangeSession.java From davmail with GNU General Public License v2.0 | 6 votes |
protected String getItemProperty(String permanentUrl, String propertyName) throws IOException, DavException { String result = null; DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet(); davPropertyNameSet.add(Field.getPropertyName(propertyName)); PropFindMethod propFindMethod = new PropFindMethod(encodeAndFixUrl(permanentUrl), davPropertyNameSet, 0); try { try { DavGatewayHttpClientFacade.executeHttpMethod(httpClient, propFindMethod); } catch (UnknownHostException e) { propFindMethod.releaseConnection(); // failover for misconfigured Exchange server, replace host name in url restoreHostName = true; propFindMethod = new PropFindMethod(encodeAndFixUrl(permanentUrl), davPropertyNameSet, 0); DavGatewayHttpClientFacade.executeHttpMethod(httpClient, propFindMethod); } MultiStatus responses = propFindMethod.getResponseBodyAsMultiStatus(); if (responses.getResponses().length > 0) { DavPropertySet properties = responses.getResponses()[0].getProperties(HttpStatus.SC_OK); result = getPropertyIfExists(properties, propertyName); } } finally { propFindMethod.releaseConnection(); } return result; }
Example #9
Source File: DavItemResourceBase.java From cosmo with Apache License 2.0 | 6 votes |
protected void loadDeadProperties(DavPropertySet properties) { for (Iterator<Map.Entry<QName, Attribute>> i = item.getAttributes() .entrySet().iterator(); i.hasNext();) { Map.Entry<QName, Attribute> entry = i.next(); // skip attributes that are not meant to be shown as dead // properties if (getDeadPropertyFilter().contains(entry.getKey().getNamespace())) { continue; } DavPropertyName propName = qNameToPropName(entry.getKey()); // ignore live properties, as they'll be loaded separately if (isLiveProperty(propName)) { continue; } // XXX: language Object propValue = entry.getValue().getValue(); properties.add(new StandardDavProperty(propName, propValue, false)); } }
Example #10
Source File: HC4DavExchangeSession.java From davmail with GNU General Public License v2.0 | 6 votes |
/** * Build Contact instance from multistatusResponse info * * @param multiStatusResponse response * @throws IOException on error * @throws DavMailException on error */ public Contact(MultiStatusResponse multiStatusResponse) throws IOException, DavMailException { setHref(URIUtil.decode(multiStatusResponse.getHref())); DavPropertySet properties = multiStatusResponse.getProperties(HttpStatus.SC_OK); permanentUrl = getURLPropertyIfExists(properties, "permanenturl"); etag = getPropertyIfExists(properties, "etag"); displayName = getPropertyIfExists(properties, "displayname"); for (String attributeName : CONTACT_ATTRIBUTES) { String value = getPropertyIfExists(properties, attributeName); if (value != null) { if ("bday".equals(attributeName) || "anniversary".equals(attributeName) || "lastmodified".equals(attributeName) || "datereceived".equals(attributeName)) { value = convertDateFromExchange(value); } else if ("haspicture".equals(attributeName) || "private".equals(attributeName)) { value = "1".equals(value) ? "true" : "false"; } put(attributeName, value); } } }
Example #11
Source File: Webdav4FileContentInfoFactory.java From commons-vfs with Apache License 2.0 | 6 votes |
@Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { final Webdav4FileObject file = (Webdav4FileObject) FileObjectUtils.getAbstractFileObject(fileContent.getFile()); String contentType = null; String contentEncoding = null; final DavPropertyNameSet nameSet = new DavPropertyNameSet(); nameSet.add(DavPropertyName.GETCONTENTTYPE); final DavPropertySet propertySet = file.getProperties((GenericURLFileName) file.getName(), nameSet, true); DavProperty property = propertySet.get(DavPropertyName.GETCONTENTTYPE); if (property != null) { contentType = (String) property.getValue(); } property = propertySet.get(Webdav4FileObject.RESPONSE_CHARSET); if (property != null) { contentEncoding = (String) property.getValue(); } return new DefaultFileContentInfo(contentType, contentEncoding); }
Example #12
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 #13
Source File: HC4DavExchangeSession.java From davmail with GNU General Public License v2.0 | 5 votes |
protected byte[] getBinaryPropertyIfExists(DavPropertySet properties, @SuppressWarnings("SameParameterValue") String alias) { byte[] property = null; String base64Property = getPropertyIfExists(properties, alias); if (base64Property != null) { property = IOUtil.decodeBase64(base64Property); } return property; }
Example #14
Source File: StandardDavRequest.java From cosmo with Apache License 2.0 | 5 votes |
/** * * @return DavPropertySet * @throws CosmoDavException */ private DavPropertySet parseMkCalendarRequest() throws CosmoDavException { DavPropertySet propertySet = new DavPropertySet(); Document requestDocument = getSafeRequestDocument(false); if (requestDocument == null) { return propertySet; } Element root = requestDocument.getDocumentElement(); if (!DomUtil.matches(root, ELEMENT_CALDAV_MKCALENDAR, NAMESPACE_CALDAV)) { throw new BadRequestException("Expected " + QN_MKCALENDAR + " root element"); } Element set = DomUtil.getChildElement(root, XML_SET, NAMESPACE); if (set == null) { throw new BadRequestException("Expected " + QN_SET + " child of " + QN_MKCALENDAR); } Element prop = DomUtil.getChildElement(set, XML_PROP, NAMESPACE); if (prop == null) { throw new BadRequestException("Expected " + QN_PROP + " child of " + QN_SET); } ElementIterator i = DomUtil.getChildren(prop); while (i.hasNext()){ propertySet.add(StandardDavProperty.createFromXml(i.nextElement())); } return propertySet; }
Example #15
Source File: HC4DavExchangeSession.java From davmail with GNU General Public License v2.0 | 5 votes |
protected double getDoublePropertyIfExists(DavPropertySet properties, @SuppressWarnings("SameParameterValue") String alias) { DavProperty property = properties.get(Field.getResponsePropertyName(alias)); if (property == null) { return 0; } else { return Double.parseDouble((String) property.getValue()); } }
Example #16
Source File: DavExchangeSession.java From davmail with GNU General Public License v2.0 | 5 votes |
protected byte[] getBinaryPropertyIfExists(DavPropertySet properties, @SuppressWarnings("SameParameterValue") String alias) { byte[] property = null; String base64Property = getPropertyIfExists(properties, alias); if (base64Property != null) { property = IOUtil.decodeBase64(base64Property); } return property; }
Example #17
Source File: DavUserPrincipalCollection.java From cosmo with Apache License 2.0 | 5 votes |
protected void loadLiveProperties(DavPropertySet properties) { properties.add(new DisplayName(getDisplayName())); properties.add(new ResourceType(getResourceTypes())); properties.add(new IsCollection(isCollection())); properties.add(new CurrentUserPrincipal(getResourceLocator(), getSecurityManager().getSecurityContext().getUser())); }
Example #18
Source File: ArchivaVirtualDavResource.java From archiva with Apache License 2.0 | 5 votes |
public ArchivaVirtualDavResource(List<StorageAsset> localResources, String logicalResource, MimeTypes mimeTypes, ArchivaDavResourceLocator locator, DavResourceFactory factory ) { this.localResources = localResources; this.logicalResource = logicalResource; this.locator = locator; this.factory = factory; this.properties = new DavPropertySet(); }
Example #19
Source File: HC4DavExchangeSession.java From davmail with GNU General Public License v2.0 | 5 votes |
protected long getLongPropertyIfExists(DavPropertySet properties, @SuppressWarnings("SameParameterValue") String alias) { DavProperty property = properties.get(Field.getPropertyName(alias)); if (property == null) { return 0; } else { return Long.parseLong((String) property.getValue()); } }
Example #20
Source File: DavCalendarCollection.java From cosmo with Apache License 2.0 | 5 votes |
/** */ protected void loadLiveProperties(DavPropertySet properties) { super.loadLiveProperties(properties); CalendarCollectionStamp cc = getCalendarCollectionStamp(); if (cc == null) { return; } if (cc.getDescription() != null) { properties.add(new CalendarDescription(cc.getDescription(), cc.getLanguage())); } if (cc.getTimezoneCalendar() != null) { properties.add(new CalendarTimezone(cc.getTimezoneCalendar().toString())); } // add CS:getctag property, which is the collection's entitytag // if it exists Item item = getItem(); if (item != null && item.getEntityTag() != null) { properties.add(new GetCTag(item.getEntityTag())); } properties.add(new SupportedCalendarComponentSet()); properties.add(new SupportedCollationSet()); properties.add(new SupportedCalendarData()); properties.add(new MaxResourceSize()); if (cc.getVisibility() != null) { properties.add(new CalendarVisibility(cc.getVisibility())); } if (cc.getColor() != null) { properties.add(new CalendarColor(cc.getColor())); } if (cc.getDisplayName() != null) { properties.add(new DisplayName(cc.getDisplayName())); } }
Example #21
Source File: DavExchangeSession.java From davmail with GNU General Public License v2.0 | 5 votes |
protected Message buildMessage(MultiStatusResponse responseEntity) throws IOException { Message message = new Message(); message.messageUrl = URIUtil.decode(responseEntity.getHref()); DavPropertySet properties = responseEntity.getProperties(HttpStatus.SC_OK); message.permanentUrl = getURLPropertyIfExists(properties, "permanenturl"); message.size = getIntPropertyIfExists(properties, "messageSize"); message.uid = getPropertyIfExists(properties, "uid"); message.contentClass = getPropertyIfExists(properties, "contentclass"); message.imapUid = getLongPropertyIfExists(properties, "imapUid"); message.read = "1".equals(getPropertyIfExists(properties, "read")); message.junk = "1".equals(getPropertyIfExists(properties, "junk")); message.flagged = "2".equals(getPropertyIfExists(properties, "flagStatus")); message.draft = (getIntPropertyIfExists(properties, "messageFlags") & 8) != 0; String lastVerbExecuted = getPropertyIfExists(properties, "lastVerbExecuted"); message.answered = "102".equals(lastVerbExecuted) || "103".equals(lastVerbExecuted); message.forwarded = "104".equals(lastVerbExecuted); message.date = convertDateFromExchange(getPropertyIfExists(properties, "date")); message.deleted = "1".equals(getPropertyIfExists(properties, "deleted")); String lastmodified = convertDateFromExchange(getPropertyIfExists(properties, "lastmodified")); message.recent = !message.read && lastmodified != null && lastmodified.equals(message.date); message.keywords = getPropertyIfExists(properties, "keywords"); if (LOGGER.isDebugEnabled()) { StringBuilder buffer = new StringBuilder(); buffer.append("Message"); if (message.imapUid != 0) { buffer.append(" IMAP uid: ").append(message.imapUid); } if (message.uid != null) { buffer.append(" uid: ").append(message.uid); } buffer.append(" href: ").append(responseEntity.getHref()).append(" permanenturl:").append(message.permanentUrl); LOGGER.debug(buffer.toString()); } return message; }
Example #22
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 #23
Source File: CalendarCollectionProvider.java From cosmo with Apache License 2.0 | 5 votes |
@Override public void mkcalendar(DavRequest request, DavResponse response, DavCollection collection) throws CosmoDavException, IOException { if (collection.exists()) { throw new ExistsException(); } DavItemCollection parent = (DavItemCollection) collection.getParent(); if (!parent.exists()) { throw new MissingParentException("One or more intermediate collections must be created"); } if (parent.isCalendarCollection()) { throw new InvalidCalendarLocationException( "A calendar collection may not be created within a calendar collection"); } // XXX DAV:needs-privilege DAV:bind on parent collection if (LOG.isDebugEnabled()) { LOG.debug("MKCALENDAR at {}", collection.getResourcePath()); } DavPropertySet properties = request.getMkCalendarSetProperties(); MultiStatusResponse msr = collection.getParent().addCollection(collection, properties); if (properties.isEmpty() || !hasNonOK(msr)) { response.setStatus(201); response.setHeader("Cache-control", "no-cache"); response.setHeader("Pragma", "no-cache"); return; } MultiStatus ms = new MultiStatus(); ms.addResponse(msr); response.sendMultiStatus(ms); }
Example #24
Source File: BaseProvider.java From cosmo with Apache License 2.0 | 5 votes |
/** * * {@inheritDoc} */ public void proppatch(DavRequest request, DavResponse response, WebDavResource resource) throws CosmoDavException, IOException { if (!resource.exists()) { throw new NotFoundException(); } DavPropertySet set = request.getProppatchSetProperties(); DavPropertyNameSet remove = request.getProppatchRemoveProperties(); MultiStatus ms = new MultiStatus(); MultiStatusResponse msr = resource.updateProperties(set, remove); ms.addResponse(msr); response.sendMultiStatus(ms); }
Example #25
Source File: StandardDavRequest.java From cosmo with Apache License 2.0 | 5 votes |
/** * * {@inheritDoc} */ public DavPropertySet getMkCalendarSetProperties() throws CosmoDavException { if (mkcalendarSet == null) { mkcalendarSet = parseMkCalendarRequest(); } return mkcalendarSet; }
Example #26
Source File: StandardDavRequest.java From cosmo with Apache License 2.0 | 5 votes |
/** * * {@inheritDoc} */ public DavPropertySet getProppatchSetProperties() throws CosmoDavException { if (proppatchSet == null) { parsePropPatchRequest(); } return proppatchSet; }
Example #27
Source File: DavCollectionBase.java From cosmo with Apache License 2.0 | 5 votes |
/** */ protected void loadLiveProperties(DavPropertySet properties) { super.loadLiveProperties(properties); CollectionItem cc = (CollectionItem) getItem(); if (cc == null) { return; } properties.add(new ExcludeFreeBusyRollup(cc.isExcludeFreeBusyRollup())); }
Example #28
Source File: DavItemResourceBase.java From cosmo with Apache License 2.0 | 5 votes |
protected void loadLiveProperties(DavPropertySet properties) { if (item == null) { return; } properties.add(new CreationDate(item.getCreationDate())); properties.add(new LastModified(item.getModifiedDate())); properties.add(new Etag(getETag())); properties.add(new DisplayName(getDisplayName())); properties.add(new ResourceType(getResourceTypes())); properties.add(new IsCollection(isCollection())); properties.add(new Owner(getResourceLocator(), item.getOwner())); properties.add(new PrincipalCollectionSet(getResourceLocator())); properties.add(new Uuid(item.getUid())); }
Example #29
Source File: DavCalendarResource.java From cosmo with Apache License 2.0 | 5 votes |
/** */ protected void loadLiveProperties(DavPropertySet properties) { super.loadLiveProperties(properties); try { byte[] calendarBytes = getCalendar().toString().getBytes("UTF-8"); properties.add(new ContentLength(Long.valueOf(calendarBytes.length))); } catch (Exception e) { throw new CosmoException("Can't convert calendar", e); } properties.add(new ContentType(ICALENDAR_MEDIA_TYPE, "UTF-8")); }
Example #30
Source File: DavItemResourceBase.java From cosmo with Apache License 2.0 | 5 votes |
public MultiStatusResponse updateProperties(DavPropertySet setProperties, DavPropertyNameSet removePropertyNames) throws CosmoDavException { MultiStatusResponse msr = super.updateProperties(setProperties, removePropertyNames); if (hasNonOK(msr)) { return msr; } updateItem(); return msr; }