Search in sources :

Example 1 with ResourceDescriptionType

use of org.oasis_open.docs.ws_calendar.ns.soap.ResourceDescriptionType in project bw-caldav by Bedework.

the class CaldavCalNode method generateCalWsProperty.

@Override
public boolean generateCalWsProperty(final List<GetPropertiesBasePropertyType> props, final QName tag, final WebdavNsIntf intf, final boolean allProp) throws WebdavException {
    try {
        if (tag.equals(CalWSSoapTags.childCollection)) {
            for (WebdavNsNode child : intf.getChildren(this, null)) {
                CaldavBwNode cn = (CaldavBwNode) child;
                ChildCollectionType cc = new ChildCollectionType();
                cc.setHref(cn.getUrlValue());
                List<Object> rtypes = cc.getCalendarCollectionOrCollection();
                if (!cn.isCollection()) {
                    continue;
                }
                rtypes.add(new CollectionType());
                if (cn.isCalendarCollection()) {
                    rtypes.add(new CalendarCollectionType());
                }
                props.add(cc);
            }
            return true;
        }
        if (tag.equals(CalWSSoapTags.lastModifiedDateTime)) {
            String val = col.getLastmod();
            if (val == null) {
                return true;
            }
            LastModifiedDateTimeType lmdt = new LastModifiedDateTimeType();
            lmdt.setDateTime(XcalUtil.fromDtval(val));
            props.add(lmdt);
            return true;
        }
        if (tag.equals(CalWSSoapTags.maxAttendeesPerInstance)) {
            if (!rootNode) {
                return true;
            }
            Integer val = getSysi().getAuthProperties().getMaxAttendeesPerInstance();
            if (val != null) {
                props.add(intProp(new MaxAttendeesPerInstanceType(), val));
            }
            return true;
        }
        if (tag.equals(CalWSSoapTags.maxDateTime)) {
            return true;
        }
        if (tag.equals(CalWSSoapTags.maxInstances)) {
            if (!rootNode) {
                return true;
            }
            Integer val = getSysi().getAuthProperties().getMaxInstances();
            if (val != null) {
                props.add(intProp(new MaxInstancesType(), val));
            }
            return true;
        }
        if (tag.equals(CalWSSoapTags.maxResourceSize)) {
            if (!rootNode) {
                return true;
            }
            Integer val = getSysi().getAuthProperties().getMaxUserEntitySize();
            if (val != null) {
                props.add(intProp(new MaxResourceSizeType(), val));
            }
            return true;
        }
        if (tag.equals(CalWSSoapTags.minDateTime)) {
            return true;
        }
        if (tag.equals(CalWSSoapTags.principalHome)) {
            if (!rootNode || intf.getAnonymous()) {
                return true;
            }
            SysIntf si = getSysi();
            CalPrincipalInfo cinfo = si.getCalPrincipalInfo(si.getPrincipal());
            if (cinfo.userHomePath != null) {
                props.add(strProp(new PrincipalHomeType(), cinfo.userHomePath));
            }
            return true;
        }
        if (tag.equals(CalWSSoapTags.resourceDescription)) {
            String s = col.getDescription();
            if (s != null) {
                props.add(strProp(new ResourceDescriptionType(), s));
            }
            return true;
        }
        if (tag.equals(CalWSSoapTags.resourceType)) {
            ResourceTypeType rt = new ResourceTypeType();
            int calType;
            CalDAVCollection<?> c = // deref this
            (CalDAVCollection<?>) getCollection(true);
            if (c == null) {
                // Probably no access -- fake it up as a collection
                calType = CalDAVCollection.calTypeCollection;
            } else {
                calType = c.getCalType();
            }
            List<Object> rtypes = rt.getCalendarCollectionOrCollectionOrInbox();
            rtypes.add(new CollectionType());
            if (calType == CalDAVCollection.calTypeInbox) {
                rtypes.add(new InboxType());
            } else if (calType == CalDAVCollection.calTypeOutbox) {
                rtypes.add(new OutboxType());
            } else if (calType == CalDAVCollection.calTypeCalendarCollection) {
                rtypes.add(new CalendarCollectionType());
            }
            props.add(rt);
            return true;
        }
        if (tag.equals(CalWSSoapTags.resourceTimezoneId)) {
            String tzid = col.getTimezone();
            if (tzid != null) {
                props.add(strProp(new ResourceTimezoneIdType(), tzid));
            }
            return true;
        }
        if (tag.equals(CalWSSoapTags.supportedCalendarComponentSet)) {
            SupportedCalendarComponentSetType sccs = new SupportedCalendarComponentSetType();
            CalDAVCollection<?> c = // deref this
            (CalDAVCollection<?>) getCollection(true);
            List<String> comps = c.getSupportedComponents();
            if (Util.isEmpty(comps)) {
                return false;
            }
            ObjectFactory of = new ObjectFactory();
            for (String s : comps) {
                JAXBElement<? extends BaseComponentType> el = null;
                switch(s) {
                    case "VEVENT":
                        el = of.createVevent(new VeventType());
                        break;
                    case "VTODO":
                        el = of.createVtodo(new VtodoType());
                        break;
                    case "VAVAILABILITY":
                        el = of.createVavailability(new VavailabilityType());
                        break;
                }
                if (el != null) {
                    sccs.getBaseComponent().add(el);
                }
            }
            props.add(sccs);
            return true;
        }
        // Not known - try higher
        return super.generateCalWsProperty(props, tag, intf, allProp);
    } catch (WebdavException wde) {
        throw wde;
    } catch (Throwable t) {
        throw new WebdavException(t);
    }
}
Also used : ChildCollectionType(org.oasis_open.docs.ws_calendar.ns.soap.ChildCollectionType) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) MaxAttendeesPerInstanceType(org.oasis_open.docs.ws_calendar.ns.soap.MaxAttendeesPerInstanceType) MaxInstancesType(org.oasis_open.docs.ws_calendar.ns.soap.MaxInstancesType) MaxResourceSizeType(org.oasis_open.docs.ws_calendar.ns.soap.MaxResourceSizeType) InboxType(org.oasis_open.docs.ws_calendar.ns.soap.InboxType) ObjectFactory(ietf.params.xml.ns.icalendar_2.ObjectFactory) VeventType(ietf.params.xml.ns.icalendar_2.VeventType) ResourceTypeType(org.oasis_open.docs.ws_calendar.ns.soap.ResourceTypeType) ChildCollectionType(org.oasis_open.docs.ws_calendar.ns.soap.ChildCollectionType) CalendarCollectionType(org.oasis_open.docs.ws_calendar.ns.soap.CalendarCollectionType) CollectionType(org.oasis_open.docs.ws_calendar.ns.soap.CollectionType) PrincipalHomeType(org.oasis_open.docs.ws_calendar.ns.soap.PrincipalHomeType) WebdavNsNode(org.bedework.webdav.servlet.shared.WebdavNsNode) CalPrincipalInfo(org.bedework.caldav.server.sysinterface.CalPrincipalInfo) BigInteger(java.math.BigInteger) ResourceTimezoneIdType(org.oasis_open.docs.ws_calendar.ns.soap.ResourceTimezoneIdType) SysIntf(org.bedework.caldav.server.sysinterface.SysIntf) VavailabilityType(ietf.params.xml.ns.icalendar_2.VavailabilityType) VtodoType(ietf.params.xml.ns.icalendar_2.VtodoType) SupportedCalendarComponentSetType(org.oasis_open.docs.ws_calendar.ns.soap.SupportedCalendarComponentSetType) ResourceDescriptionType(org.oasis_open.docs.ws_calendar.ns.soap.ResourceDescriptionType) LastModifiedDateTimeType(org.oasis_open.docs.ws_calendar.ns.soap.LastModifiedDateTimeType) CalendarCollectionType(org.oasis_open.docs.ws_calendar.ns.soap.CalendarCollectionType) OutboxType(org.oasis_open.docs.ws_calendar.ns.soap.OutboxType)

Aggregations

ObjectFactory (ietf.params.xml.ns.icalendar_2.ObjectFactory)1 VavailabilityType (ietf.params.xml.ns.icalendar_2.VavailabilityType)1 VeventType (ietf.params.xml.ns.icalendar_2.VeventType)1 VtodoType (ietf.params.xml.ns.icalendar_2.VtodoType)1 BigInteger (java.math.BigInteger)1 CalPrincipalInfo (org.bedework.caldav.server.sysinterface.CalPrincipalInfo)1 SysIntf (org.bedework.caldav.server.sysinterface.SysIntf)1 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)1 WebdavNsNode (org.bedework.webdav.servlet.shared.WebdavNsNode)1 CalendarCollectionType (org.oasis_open.docs.ws_calendar.ns.soap.CalendarCollectionType)1 ChildCollectionType (org.oasis_open.docs.ws_calendar.ns.soap.ChildCollectionType)1 CollectionType (org.oasis_open.docs.ws_calendar.ns.soap.CollectionType)1 InboxType (org.oasis_open.docs.ws_calendar.ns.soap.InboxType)1 LastModifiedDateTimeType (org.oasis_open.docs.ws_calendar.ns.soap.LastModifiedDateTimeType)1 MaxAttendeesPerInstanceType (org.oasis_open.docs.ws_calendar.ns.soap.MaxAttendeesPerInstanceType)1 MaxInstancesType (org.oasis_open.docs.ws_calendar.ns.soap.MaxInstancesType)1 MaxResourceSizeType (org.oasis_open.docs.ws_calendar.ns.soap.MaxResourceSizeType)1 OutboxType (org.oasis_open.docs.ws_calendar.ns.soap.OutboxType)1 PrincipalHomeType (org.oasis_open.docs.ws_calendar.ns.soap.PrincipalHomeType)1 ResourceDescriptionType (org.oasis_open.docs.ws_calendar.ns.soap.ResourceDescriptionType)1