Java Code Examples for org.apache.jackrabbit.webdav.property.DavPropertyName#equals()

The following examples show how to use org.apache.jackrabbit.webdav.property.DavPropertyName#equals() . 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: DavContentBase.java    From cosmo with Apache License 2.0 6 votes vote down vote up
/** */
protected void setLiveProperty(WebDavProperty property, boolean create)
    throws CosmoDavException {
    super.setLiveProperty(property, create);

    ContentItem content = (ContentItem) getItem();
    if (content == null) {
        return;
    }

    DavPropertyName name = property.getName();
    if (name.equals(DavPropertyName.GETCONTENTLENGTH)) {
        throw new ProtectedPropertyModificationException(name);
    }

    // content type is settable by subclasses
}
 
Example 2
Source File: DavCollectionBase.java    From cosmo with Apache License 2.0 6 votes vote down vote up
/** */
protected void setLiveProperty(WebDavProperty property, boolean create)
        throws CosmoDavException {
    super.setLiveProperty(property, create);

    CollectionItem cc = (CollectionItem) getItem();
    if (cc == null) {
        return;
    }

    DavPropertyName name = property.getName();
    if (property.getValue() == null) {
        throw new UnprocessableEntityException("Property " + name
                + " requires a value");
    }

    if (name.equals(EXCLUDEFREEBUSYROLLUP)) {
        Boolean flag = Boolean.valueOf(property.getValueText());
        cc.setExcludeFreeBusyRollup(flag);
    }
}
 
Example 3
Source File: DavItemResourceBase.java    From cosmo with Apache License 2.0 6 votes vote down vote up
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 4
Source File: DavItemResourceBase.java    From cosmo with Apache License 2.0 6 votes vote down vote up
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 5
Source File: DavContentBase.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/** */
protected void removeLiveProperty(DavPropertyName name, boolean create)
    throws CosmoDavException {
    super.removeLiveProperty(name);

    ContentItem content = (ContentItem) getItem();
    if (content == null) {
        return;
    }

    if (name.equals(DavPropertyName.GETCONTENTLENGTH) ||
        name.equals(DavPropertyName.GETCONTENTTYPE)) {
        throw new ProtectedPropertyModificationException(name);
    }
}
 
Example 6
Source File: DavFile.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/** */
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 7
Source File: DavFile.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/** */
protected void removeLiveProperty(DavPropertyName name)
    throws CosmoDavException {
    super.removeLiveProperty(name);

    FileItem content = (FileItem) getItem();
    if (content == null) {
        return;
    }

    if (name.equals(DavPropertyName.GETCONTENTLANGUAGE)) {
        content.setContentLanguage(null);
        return;
    }
}
 
Example 8
Source File: DavCollectionBase.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/** */
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 9
Source File: DavResourceBase.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * 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 10
Source File: DavResourceBase.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * 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 11
Source File: DavCalendarResource.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/** */
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 12
Source File: DavCalendarCollection.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * The CALDAV:supported-calendar-component-set property is used to specify restrictions on the calendar component
 * types that calendar object resources may contain in a calendar collection. Any attempt by the client to store
 * calendar object resources with component types not listed in this property, if it exists, MUST result in an
 * error, with the CALDAV:supported-calendar-component precondition (Section 5.3.2.1) being violated. Since this
 * property is protected, it cannot be changed by clients using a PROPPATCH request.
 */
protected void setLiveProperty(WebDavProperty property, boolean create) throws CosmoDavException {
    super.setLiveProperty(property, create);

    CalendarCollectionStamp cc = getCalendarCollectionStamp();
    if (cc == null) {
        return;
    }

    DavPropertyName name = property.getName();
    if (property.getValue() == null) {
        throw new UnprocessableEntityException("Property " + name + " requires a value");
    }

    if (!(create && name.equals(SUPPORTEDCALENDARCOMPONENTSET)) && (name.equals(SUPPORTEDCALENDARCOMPONENTSET)
            || name.equals(SUPPORTEDCALENDARDATA) || name.equals(MAXRESOURCESIZE) || name.equals(GET_CTAG))) {
        throw new ProtectedPropertyModificationException(name);
    }

    if (name.equals(CALENDARDESCRIPTION)) {
        cc.setDescription(property.getValueText());
        cc.setLanguage(property.getLanguage());
        return;
    }

    if (name.equals(CALENDARTIMEZONE)) {
        cc.setTimezoneCalendar(TimeZoneExtractor.extract(property));
    }
    if (name.equals(XCaldavConstants.CALENDAR_COLOR)) {
        cc.setColor(property.getValueText());
    }
    if (name.equals(XCaldavConstants.CALENDAR_VISIBLE)) {
        cc.setVisibility(Boolean.parseBoolean(property.getValueText()));
    }
}
 
Example 13
Source File: DavCalendarCollection.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/** */
protected void removeLiveProperty(DavPropertyName name) throws CosmoDavException {
    super.removeLiveProperty(name);

    CalendarCollectionStamp cc = getCalendarCollectionStamp();
    if (cc == null) {
        return;
    }

    if (name.equals(SUPPORTEDCALENDARCOMPONENTSET) || name.equals(SUPPORTEDCALENDARDATA)
            || name.equals(MAXRESOURCESIZE) || name.equals(GET_CTAG)) {
        throw new ProtectedPropertyModificationException(name);
    }

    if (name.equals(CALENDARDESCRIPTION)) {
        cc.setDescription(null);
        cc.setLanguage(null);
        return;
    }

    if (name.equals(CALENDARTIMEZONE)) {
        cc.setTimezoneCalendar(null);
        return;
    }
    if (name.equals(XCaldavConstants.CALENDAR_COLOR)) {
        cc.setColor(null);
    }
    if (name.equals(XCaldavConstants.CALENDAR_VISIBLE)) {
        cc.setVisibility(null);
    }
}