org.apache.jackrabbit.webdav.property.DavPropertyName Java Examples
The following examples show how to use
org.apache.jackrabbit.webdav.property.DavPropertyName.
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: DavItemResourceBase.java From cosmo with Apache License 2.0 | 6 votes |
protected void setLiveProperty(WebDavProperty property, boolean create) throws CosmoDavException { if (item == null) { return; } DavPropertyName name = property.getName(); if (property.getValue() == null) { throw new UnprocessableEntityException("Property " + name + " requires a value"); } if (name.equals(DavPropertyName.CREATIONDATE) || name.equals(DavPropertyName.GETLASTMODIFIED) || name.equals(DavPropertyName.GETETAG) || name.equals(DavPropertyName.RESOURCETYPE) || name.equals(DavPropertyName.ISCOLLECTION) || name.equals(OWNER) || name.equals(PRINCIPALCOLLECTIONSET) || name.equals(UUID)) { throw new ProtectedPropertyModificationException(name); } if (name.equals(DavPropertyName.DISPLAYNAME)) { item.setDisplayName(property.getValueText()); } }
Example #2
Source File: PropFindContent.java From cosmo with Apache License 2.0 | 6 votes |
/** * toXML. * {@inheritDoc} * @param doc - The document. * @return The element. */ public Element toXml(Document doc) { Element propfind = DomUtil.createElement(doc, XML_PROPFIND, NAMESPACE); if (propertyNames.isEmpty()) { // allprop Element allprop = DomUtil.createElement(doc, XML_ALLPROP, NAMESPACE); propfind.appendChild(allprop); } else { for (DavPropertyName propname: propertyNames) { Element name = DomUtil.createElement(doc, propname.getName(), propname.getNamespace()); Element prop = DomUtil.createElement(doc, XML_PROP, NAMESPACE); prop.appendChild(name); propfind.appendChild(prop); } } return propfind; }
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: 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 #5
Source File: DavItemResourceBase.java From cosmo with Apache License 2.0 | 6 votes |
protected void removeLiveProperty(DavPropertyName name) throws CosmoDavException { if (item == null) { return; } if (name.equals(DavPropertyName.CREATIONDATE) || name.equals(DavPropertyName.GETLASTMODIFIED) || name.equals(DavPropertyName.GETETAG) || name.equals(DavPropertyName.DISPLAYNAME) || name.equals(DavPropertyName.RESOURCETYPE) || name.equals(DavPropertyName.ISCOLLECTION) || name.equals(OWNER) || name.equals(PRINCIPALCOLLECTIONSET) || name.equals(UUID)) { throw new ProtectedPropertyModificationException(name); } getProperties().remove(name); }
Example #6
Source File: MultigetHandler.java From openmeetings with Apache License 2.0 | 6 votes |
public MultigetHandler(List<String> hrefs, boolean onlyEtag, String path, OmCalendar calendar, HttpClient client, HttpClientContext context, AppointmentDao appointmentDao, IcalUtils utils) { super(path, calendar, client, context, appointmentDao, utils); this.onlyEtag = onlyEtag; if (hrefs == null || hrefs.isEmpty() || calendar.getSyncType() == SyncType.NONE) { isMultigetDisabled = true; } else { DavPropertyNameSet properties = new DavPropertyNameSet(); properties.add(DavPropertyName.GETETAG); CalendarData calendarData = null; if (!onlyEtag) { calendarData = new CalendarData(); } CompFilter vcalendar = new CompFilter(Calendar.VCALENDAR); vcalendar.addCompFilter(new CompFilter(Component.VEVENT)); query = new CalendarMultiget(properties, calendarData, false, false); query.setHrefs(hrefs); } }
Example #7
Source File: Field.java From davmail with GNU General Public License v2.0 | 6 votes |
/** * Create field for namespace and name of type propertyType. * * @param alias logical name in DavMail * @param namespace Exchange namespace * @param name Exchange name * @param propertyType property type * @param responseAlias property name in SEARCH response (as responsealias in request) * @param cast response cast type (e.g. bin.base64) * @param updateAlias some properties use a different alias in PROPPATCH requests */ protected Field(String alias, Namespace namespace, String name, PropertyType propertyType, String responseAlias, String cast, String updateAlias) { this.alias = alias; // property name in PROPFIND requests davPropertyName = DavPropertyName.create(name, namespace); // property name in PROPPATCH requests updatePropertyName = DavPropertyName.create(updateAlias, namespace); // a few type based flags isMultivalued = propertyType != null && propertyType.toString().endsWith("Array"); isIntValue = propertyType == PropertyType.Long || propertyType == PropertyType.Integer || propertyType == PropertyType.Short; isBooleanValue = propertyType == PropertyType.Boolean; isFloatValue = propertyType == PropertyType.Float || propertyType == PropertyType.Double; isDateValue = propertyType == PropertyType.SystemTime; this.uri = namespace.getURI() + name; if (responseAlias == null) { this.requestPropertyString = '"' + uri + '"'; this.responsePropertyName = davPropertyName; } else { this.requestPropertyString = '"' + uri + "\" as " + responseAlias; this.responsePropertyName = DavPropertyName.create(responseAlias, EMPTY); } this.cast = cast; }
Example #8
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 #9
Source File: DeltaVResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) public DavResource[] getReferenceResources(DavPropertyName hrefPropertyName) throws DavException { DavProperty prop = getProperty(hrefPropertyName); List resources = new ArrayList(); if (prop != null && prop instanceof HrefProperty) { HrefProperty hp = (HrefProperty) prop; // process list of hrefs List hrefs = hp.getHrefs(); for (Iterator iter = hrefs.iterator(); iter.hasNext();) { String href = (String) iter.next(); DavResourceLocator locator = getLocator().getFactory().createResourceLocator(getLocator().getPrefix(), href); resources.add(createResourceFromLocator(locator)); } } else { throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR); } return (DavResource[]) resources.toArray(new DavResource[0]); }
Example #10
Source File: DavResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * @see DavResource#getProperty(org.apache.jackrabbit.webdav.property.DavPropertyName) */ public DavProperty getProperty(DavPropertyName name) { initProperties(); log.debug("getProperty(..) " + name); return properties.get(name); }
Example #11
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 #12
Source File: DavCalendarResource.java From cosmo with Apache License 2.0 | 5 votes |
/** */ protected void setLiveProperty(WebDavProperty property, boolean create) throws CosmoDavException { super.setLiveProperty(property, create); DavPropertyName name = property.getName(); if (name.equals(DavPropertyName.GETCONTENTTYPE)) { throw new ProtectedPropertyModificationException(name); } }
Example #13
Source File: DavResourceBase.java From cosmo with Apache License 2.0 | 5 votes |
/** * Calls {@link #setLiveProperty(WebDavProperty)} or {@link setDeadProperty(WebDavProperty)}. */ protected void setResourceProperty(WebDavProperty property, boolean create) throws CosmoDavException { DavPropertyName name = property.getName(); if (name.equals(SUPPORTEDREPORTSET)) { throw new ProtectedPropertyModificationException(name); } if (isLiveProperty(property.getName())) { setLiveProperty(property, create); } else { setDeadProperty(property); } properties.add(property); }
Example #14
Source File: TestCaldav.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testPropfindRoot() throws IOException, DavException { DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet(); davPropertyNameSet.add(DavPropertyName.create("current-user-principal", Namespace.getNamespace("DAV:"))); davPropertyNameSet.add(DavPropertyName.create("principal-URL", Namespace.getNamespace("DAV:"))); davPropertyNameSet.add(DavPropertyName.create("resourcetype", Namespace.getNamespace("DAV:"))); PropFindMethod method = new PropFindMethod("/", davPropertyNameSet, 0); httpClient.executeMethod(method); assertEquals(HttpStatus.SC_MULTI_STATUS, method.getStatusCode()); method.getResponseBodyAsMultiStatus(); }
Example #15
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 #16
Source File: StandardDavProperty.java From cosmo with Apache License 2.0 | 5 votes |
public StandardDavProperty(DavPropertyName name, Object value, String lang, boolean isProtected) { this.name = name; this.value = value; this.isProtected = isProtected; if (! StringUtils.isBlank(lang)) { this.lang = lang; } }
Example #17
Source File: DavResourceBase.java From cosmo with Apache License 2.0 | 5 votes |
/** * Calls {@link #removeLiveProperty(DavPropertyName)} or {@link removeDeadProperty(DavPropertyName)}. */ protected void removeResourceProperty(DavPropertyName name) throws CosmoDavException { if (name.equals(SUPPORTEDREPORTSET)) { throw new ProtectedPropertyModificationException(name); } if (isLiveProperty(name)) { removeLiveProperty(name); } else { removeDeadProperty(name); } properties.remove(name); }
Example #18
Source File: Field.java From davmail with GNU General Public License v2.0 | 5 votes |
/** * Create property value object for field and value. * * @param alias field alias * @param value field value * @return property value object * @see ExchangePropPatchMethod */ public static PropertyValue createPropertyValue(String alias, String value) { Field field = Field.get(alias); DavPropertyName davPropertyName = field.davPropertyName; if (value == null) { // return DavPropertyName to remove property return new PropertyValue(davPropertyName.getNamespace().getURI(), davPropertyName.getName()); } else if (field.isMultivalued) { StringBuilder buffer = new StringBuilder(); // multivalued field, split values separated by \n String[] values = value.split("\n"); for (final String singleValue : values) { buffer.append("<v>"); buffer.append(StringUtil.xmlEncode(singleValue)); buffer.append("</v>"); } return new PropertyValue(davPropertyName.getNamespace().getURI(), davPropertyName.getName(), buffer.toString()); } else if (field.isBooleanValue) { if ("true".equals(value)) { return new PropertyValue(davPropertyName.getNamespace().getURI(), davPropertyName.getName(), "1", "boolean"); } else if ("false".equals(value)) { return new PropertyValue(davPropertyName.getNamespace().getURI(), davPropertyName.getName(), "0", "boolean"); } else { throw new RuntimeException("Invalid value for " + field.alias + ": " + value); } } else if (field.isFloatValue) { return new PropertyValue(davPropertyName.getNamespace().getURI(), davPropertyName.getName(), StringUtil.xmlEncode(value), "float"); } else if (field.isIntValue) { return new PropertyValue(field.updatePropertyName.getNamespace().getURI(), field.updatePropertyName.getName(), StringUtil.xmlEncode(value), "int"); } else if (field.isDateValue) { return new PropertyValue(field.updatePropertyName.getNamespace().getURI(), field.updatePropertyName.getName(), StringUtil.xmlEncode(value), "dateTime.tz"); } else { return new PropertyValue(davPropertyName.getNamespace().getURI(), davPropertyName.getName(), StringUtil.xmlEncode(value)); } }
Example #19
Source File: DavResourceBase.java From cosmo with Apache License 2.0 | 5 votes |
public void removeProperty(DavPropertyName propertyName) throws DavException { if (!exists()) { throw new NotFoundException(); } removeResourceProperty(propertyName); }
Example #20
Source File: TestCaldavHttpClient4.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testWellKnown() throws IOException { DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet(); davPropertyNameSet.add(DavPropertyName.create("current-user-principal", Namespace.getNamespace("DAV:"))); davPropertyNameSet.add(DavPropertyName.create("principal-URL", Namespace.getNamespace("DAV:"))); davPropertyNameSet.add(DavPropertyName.create("resourcetype", Namespace.getNamespace("DAV:"))); HttpPropfind method = new HttpPropfind("/.well-known/caldav", davPropertyNameSet, 0) { @Override public boolean succeeded(HttpResponse response) { return response.getStatusLine().getStatusCode() == DavServletResponse.SC_MOVED_PERMANENTLY; } }; httpClient.executeDavRequest(method); }
Example #21
Source File: TestCaldavHttpClient4.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testPropfindRoot() throws IOException { DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet(); davPropertyNameSet.add(DavPropertyName.create("current-user-principal", Namespace.getNamespace("DAV:"))); davPropertyNameSet.add(DavPropertyName.create("principal-URL", Namespace.getNamespace("DAV:"))); davPropertyNameSet.add(DavPropertyName.create("resourcetype", Namespace.getNamespace("DAV:"))); HttpPropfind method = new HttpPropfind("/", davPropertyNameSet, 0); httpClient.executeDavRequest(method); }
Example #22
Source File: TestCaldavHttpClient4.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testPropfindPublicPrincipal() throws IOException { DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet(); davPropertyNameSet.add(DavPropertyName.create("calendar-home-set", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav"))); davPropertyNameSet.add(DavPropertyName.create("calendar-user-address-set", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav"))); davPropertyNameSet.add(DavPropertyName.create("schedule-inbox-URL", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav"))); davPropertyNameSet.add(DavPropertyName.create("schedule-outbox-URL", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav"))); HttpPropfind method = new HttpPropfind("/principals/public/testcalendar/", davPropertyNameSet, 0); MultiStatus multiStatus = httpClient.executeDavRequest(method); MultiStatusResponse[] responses = multiStatus.getResponses(); assertEquals(1, responses.length); }
Example #23
Source File: DavCollectionBase.java From cosmo with Apache License 2.0 | 5 votes |
/** */ protected void removeLiveProperty(DavPropertyName name) throws CosmoDavException { super.removeLiveProperty(name); CollectionItem cc = (CollectionItem) getItem(); if (cc == null) { return; } if (name.equals(EXCLUDEFREEBUSYROLLUP)) { cc.setExcludeFreeBusyRollup(false); } }
Example #24
Source File: DavItemResourceBase.java From cosmo with Apache License 2.0 | 5 votes |
private QName propNameToQName(DavPropertyName name) { if (name == null) { final String msg = "name cannot be null"; throw new IllegalArgumentException(msg); } Namespace ns = name.getNamespace(); String uri = ns != null ? ns.getURI() : ""; return entityFactory.createQName(uri, name.getName()); }
Example #25
Source File: DavFile.java From cosmo with Apache License 2.0 | 5 votes |
/** */ protected void setLiveProperty(WebDavProperty property, boolean create) throws CosmoDavException { super.setLiveProperty(property, create); FileItem content = (FileItem) getItem(); if (content == null) { return; } DavPropertyName name = property.getName(); String text = property.getValueText(); if (name.equals(DavPropertyName.GETCONTENTLANGUAGE)) { content.setContentLanguage(text); return; } if (name.equals(DavPropertyName.GETCONTENTTYPE)) { String type = ContentTypeUtil.getMimeType(text); if (StringUtils.isBlank(type)) { throw new BadRequestException("Property " + name + " requires a valid media type"); } content.setContentType(type); content.setContentEncoding(ContentTypeUtil.getEncoding(text)); } }
Example #26
Source File: PrincipalMatchReport.java From cosmo with Apache License 2.0 | 5 votes |
private static DavPropertyName findPrincipalProperty(ReportInfo info) throws CosmoDavException { Element pp = info.getContentElement(ELEMENT_ACL_PRINCIPAL_PROPERTY, NAMESPACE); if (pp == null) { return null; } ElementIterator ei = DomUtil.getChildren(pp); if (! ei.hasNext()) { return null; } return DavPropertyName.createFromXml(ei.nextElement()); }
Example #27
Source File: PrincipalPropertySearchReport.java From cosmo with Apache License 2.0 | 5 votes |
private boolean matchSpec(SearchSpec spec, DavUserPrincipal principal) throws CosmoDavException { for (DavPropertyName name : spec.getProperties()) { if (! matchProperty((WebDavProperty)principal.getProperty(name), spec.getMatch())) { return false; } } return true; }
Example #28
Source File: PrincipalPropertySearchReport.java From cosmo with Apache License 2.0 | 5 votes |
public static SearchSpec createFromXml(Element root) throws CosmoDavException { if (! DomUtil.matches(root, "property-search", NAMESPACE)) { throw new IllegalArgumentException("Expected root element DAV:property-search"); } Element p = DomUtil.getChildElement(root, "prop", NAMESPACE); if (p == null) { throw new BadRequestException("Expected DAV:prop child of DAV:property-search"); } ElementIterator pi = DomUtil.getChildren(p); if (! pi.hasNext()) { throw new BadRequestException("Expected at least one child of DAV:prop"); } HashSet<DavPropertyName> properties = new HashSet<DavPropertyName>(); while (pi.hasNext()) { DavPropertyName name = DavPropertyName.createFromXml(pi.nextElement()); properties.add(name); } Element m = DomUtil.getChildElement(root, "match", NAMESPACE); if (m == null) { throw new BadRequestException("Expected DAV:match child of DAV:property-search"); } String match = DomUtil.getText(m); return new SearchSpec(properties, match); }
Example #29
Source File: StandardDavProperty.java From cosmo with Apache License 2.0 | 5 votes |
/** * <p> * Returns an instance of <code>StandardDavProperty</code> representing * the given element. The element itself is provided as the property value. * If either the element or its parent element has the attribute * <code>xml:lang</code>, that attribute's value is provided as the * property's language. The resulting property is not "protected" (i.e. * it will not appear in "allprop" <code>PROPFIND</code> responses). * </p> */ public static StandardDavProperty createFromXml(Element e) { DavPropertyName name = DavPropertyName.createFromXml(e); String lang = DomUtil.getAttribute(e, XML_LANG, NAMESPACE_XML); if (lang == null && e.getParentNode() != null && e.getParentNode().getNodeType() == Node.ELEMENT_NODE) { lang = DomUtil.getAttribute((Element)e.getParentNode(), XML_LANG, NAMESPACE_XML); } return new StandardDavProperty(name, e, lang); }
Example #30
Source File: DavItemResourceBase.java From cosmo with Apache License 2.0 | 5 votes |
protected void removeDeadProperty(DavPropertyName name) throws CosmoDavException { if (LOG.isDebugEnabled()) { LOG.debug("removing property " + name + " on " + getResourcePath()); } item.removeAttribute(propNameToQName(name)); }