org.bedework.caldav.server.CaldavBwNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bw-caldav-server Show documentation
Show all versions of bw-caldav-server Show documentation
A generic CalDAV server - used by bedework
/* ********************************************************************
Licensed to Jasig under one or more contributor license
agreements. See the NOTICE file distributed with this work
for additional information regarding copyright ownership.
Jasig licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a
copy of the License at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.bedework.caldav.server;
import org.bedework.caldav.server.sysinterface.SysIntf;
import org.bedework.util.calendar.XcalUtil;
import org.bedework.util.misc.ToString;
import org.bedework.util.xml.tagdefs.CalWSSoapTags;
import org.bedework.util.xml.tagdefs.CalWSXrdDefs;
import org.bedework.util.xml.tagdefs.CaldavTags;
import org.bedework.util.xml.tagdefs.XrdTags;
import org.bedework.webdav.servlet.shared.WdCollection;
import org.bedework.webdav.servlet.shared.WdEntity;
import org.bedework.webdav.servlet.shared.WebdavException;
import org.bedework.webdav.servlet.shared.WebdavNsIntf;
import org.bedework.webdav.servlet.shared.WebdavNsNode;
import org.oasis_open.docs.ns.xri.xrd_1.LinkType;
import org.oasis_open.docs.ns.xri.xrd_1.PropertyType;
import org.oasis_open.docs.ws_calendar.ns.soap.CalendarAccessFeatureType;
import org.oasis_open.docs.ws_calendar.ns.soap.CreationDateTimeType;
import org.oasis_open.docs.ws_calendar.ns.soap.DisplayNameType;
import org.oasis_open.docs.ws_calendar.ns.soap.GetPropertiesBasePropertyType;
import org.oasis_open.docs.ws_calendar.ns.soap.ResourceOwnerType;
import org.oasis_open.docs.ws_calendar.ns.soap.SupportedFeaturesType;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.function.Supplier;
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
/** Class to represent a caldav node.
*
* @author Mike Douglass douglm - rpi.edu
*/
public abstract class CaldavBwNode extends WebdavNsNode {
// protected CaldavURI cdURI;
protected boolean rootNode;
protected CalDAVCollection> col;
private final static HashMap propertyNames =
new HashMap<>();
private final static Collection supportedReports =
new ArrayList<>();
private final static HashMap calWSSoapNames =
new HashMap<>();
static {
supportedReports.add(CaldavTags.calendarMultiget); // Calendar access
supportedReports.add(CaldavTags.calendarQuery); // Calendar access
addCalWSSoapName(CalWSSoapTags.creationDateTime, true);
addCalWSSoapName(CalWSSoapTags.displayName, true);
addCalWSSoapName(CalWSSoapTags.lastModifiedDateTime, true);
addCalWSSoapName(CalWSSoapTags.supportedFeatures, true);
}
/** Information about properties returned in an XRD object for the restful
* protocol
*/
public static final class PropertyTagXrdEntry extends PropertyTagEntry {
/** */
public final String xrdName;
/** */
public final boolean inLink;
/**
* @param tag
* @param xrdName
* @param inPropAll
* @param inLink
*/
public PropertyTagXrdEntry(final QName tag,
final String xrdName,
final boolean inPropAll,
final boolean inLink) {
super(tag, inPropAll);
this.xrdName = xrdName;
this.inLink = inLink;
}
}
private final static HashMap xrdNames =
new HashMap<>();
static {
addXrdEntry(xrdNames, CalWSXrdDefs.created, true, false);
addXrdEntry(xrdNames, CalWSXrdDefs.displayname, true, true);
addXrdEntry(xrdNames, CalWSXrdDefs.lastModified, true, false);
addXrdEntry(xrdNames, CalWSXrdDefs.owner, true, false);
}
/* for accessing calendars */
private final SysIntf sysi;
CaldavBwNode(final CaldavURI cdURI,
final SysIntf sysi) {
this(sysi, cdURI.getPath(), cdURI.isCollection(),
cdURI.getUri());
}
CaldavBwNode(final SysIntf sysi,
final String path,
final boolean collection,
final String uri) {
super(sysi, sysi.getUrlHandler(), path, collection, uri);
this.sysi = sysi;
rootNode = (uri != null) && uri.equals("/");
}
CaldavBwNode(final boolean collection,
final SysIntf sysi,
final String uri) {
super(sysi, sysi.getUrlHandler(), null, collection, uri);
//this.cdURI = cdURI;
this.sysi = sysi;
rootNode = (uri != null) && uri.equals("/");
}
/** Returns a string value suitable for the web service token
*
* @return String token
*/
public abstract String getEtokenValue();
/* ====================================================================
* Public methods
* ==================================================================== */
/**
* @return the interface
*/
public SysIntf getIntf() {
return sysi;
}
@Override
public WdCollection> getCollection(final boolean deref) {
if (!deref) {
return col;
}
return col.resolveAlias(true); // True to resolve all subaliases
}
@Override
public WdCollection> getImmediateTargetCollection() {
return col.resolveAlias(false); // False => don't resolve all subaliases
}
/**
* @return boolean if this is a calendar
*/
public boolean isCalendarCollection() {
if (!isCollection()) {
return false;
}
final CalDAVCollection> c = (CalDAVCollection>)getCollection(true);
if (c == null) {
return false;
}
return c.getCalType() == CalDAVCollection.calTypeCalendarCollection;
}
/**
* @return CalSvcI
*/
public SysIntf getSysi() {
return sysi;
}
/** Return a set of Qname defining reports this node supports.
*
* @return Collection of QName
*/
@Override
public Collection getSupportedReports() {
final Collection res = new ArrayList<>();
res.addAll(super.getSupportedReports());
res.addAll(supportedReports);
return res;
}
@Override
public String getSyncToken() {
return null;
}
/* ====================================================================
* Required webdav properties
* ==================================================================== */
@Override
public boolean getContentBinary() {
return false;
}
@Override
public Collection extends WdEntity>> getChildren(
final Supplier
© 2015 - 2025 Weber Informatics LLC | Privacy Policy