org.apache.jackrabbit.webdav.property.DavPropertyNameSet Java Examples

The following examples show how to use org.apache.jackrabbit.webdav.property.DavPropertyNameSet. 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: MultigetReport.java    From cosmo with Apache License 2.0 6 votes vote down vote up
/**
 * Resolves the hrefs provided in the report info to resources.
 */
protected void runQuery()
    throws CosmoDavException {
    DavPropertyNameSet propspec = createResultPropSpec();

    if (getResource() instanceof DavCollection) {
        DavCollection collection = (DavCollection) getResource();
        for (String href : hrefs) {
            WebDavResource target = collection.findMember(href);
            if (target != null) {
                getMultiStatus().addResponse(buildMultiStatusResponse(target, propspec));
            }
            else {
                getMultiStatus().addResponse(new MultiStatusResponse(href,404));
            }
        }
        return;
    }

    if (getResource() instanceof DavCalendarResource) {
        getMultiStatus().addResponse(buildMultiStatusResponse(getResource(), propspec));
        return;
    }

    throw new UnprocessableEntityException(getType() + " report not supported for non-calendar resources");
}
 
Example #2
Source File: Webdav4FileObject.java    From commons-vfs with Apache License 2.0 6 votes vote down vote up
private void setUserName(final GenericURLFileName fileName, final String urlStr) throws IOException {
    final DavPropertySet setProperties = new DavPropertySet();
    final DavPropertyNameSet removeProperties = new DavPropertyNameSet();
    String name = builder.getCreatorName(getFileSystem().getFileSystemOptions());
    final String userName = fileName.getUserName();
    if (name == null) {
        name = userName;
    } else {
        if (userName != null) {
            final String comment = "Modified by user " + userName;
            setProperties.add(new DefaultDavProperty(DeltaVConstants.COMMENT, comment));
        }
    }
    setProperties.add(new DefaultDavProperty(DeltaVConstants.CREATOR_DISPLAYNAME, name));
    final HttpProppatch request = new HttpProppatch(urlStr, setProperties, removeProperties);
    setupRequest(request);
    executeRequest(request);
}
 
Example #3
Source File: Webdav4FileContentInfoFactory.java    From commons-vfs with Apache License 2.0 6 votes vote down vote up
@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 #4
Source File: TestCaldavHttpClient4.java    From davmail with GNU General Public License v2.0 6 votes vote down vote up
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 #5
Source File: WebdavFileObject.java    From commons-vfs with Apache License 2.0 6 votes vote down vote up
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 #6
Source File: CtagHandler.java    From openmeetings with Apache License 2.0 6 votes vote down vote up
@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 #7
Source File: MultigetHandler.java    From openmeetings with Apache License 2.0 6 votes vote down vote up
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 #8
Source File: WebdavFileContentInfoFactory.java    From commons-vfs with Apache License 2.0 6 votes vote down vote up
@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 #9
Source File: TestExchangePropfindMethod.java    From davmail with GNU General Public License v2.0 6 votes vote down vote up
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 #10
Source File: DavExchangeSession.java    From davmail with GNU General Public License v2.0 6 votes vote down vote up
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 #11
Source File: HC4DavExchangeSession.java    From davmail with GNU General Public License v2.0 6 votes vote down vote up
protected void checkPublicFolder() {
    // check public folder access
    try {
        publicFolderUrl = URIUtils.resolve(httpClientAdapter.getUri(), PUBLIC_ROOT).toString();
        DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet();
        davPropertyNameSet.add(Field.getPropertyName("displayname"));

        HttpPropfind httpPropfind = new HttpPropfind(publicFolderUrl, davPropertyNameSet, 0);
        httpClientAdapter.executeDavRequest(httpPropfind);
        // update public folder URI
        publicFolderUrl = httpPropfind.getURI().toString();

    } catch (IOException e) {
        LOGGER.warn("Public folders not available: " + (e.getMessage() == null ? e : e.getMessage()));
        // default public folder path
        publicFolderUrl = PUBLIC_ROOT;
    }
}
 
Example #12
Source File: Webdav4FileObject.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/**
 * Sets an attribute of this file. Is only called if {@link #doGetType} does not return {@link FileType#IMAGINARY}.
 */
@Override
protected void doSetAttribute(final String attrName, final Object value) throws Exception {
    try {
        final GenericURLFileName fileName = (GenericURLFileName) getName();
        final String urlStr = toUrlString(fileName);
        final DavPropertySet properties = new DavPropertySet();
        final DavPropertyNameSet propertyNameSet = new DavPropertyNameSet();
        final DavProperty property = new DefaultDavProperty(attrName, value, Namespace.EMPTY_NAMESPACE);
        if (value != null) {
            properties.add(property);
        } else {
            propertyNameSet.add(property.getName()); // remove property
        }

        final HttpProppatch request = new HttpProppatch(urlStr, properties, propertyNameSet);
        setupRequest(request);
        final HttpResponse response = executeRequest(request);
        if (!request.succeeded(response)) {
            throw new FileSystemException("Property '" + attrName + "' could not be set.");
        }
    } catch (final FileSystemException fse) {
        throw fse;
    } catch (final Exception e) {
        throw new FileSystemException("vfs.provider.webdav/set-attributes", e, getName(), attrName);
    }
}
 
Example #13
Source File: Webdav4FileObject.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
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 #14
Source File: TestCaldav.java    From davmail with GNU General Public License v2.0 5 votes vote down vote up
public void testWellKnown() 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("/.well-known/caldav", davPropertyNameSet, 0);
    httpClient.executeMethod(method);
    assertEquals(HttpStatus.SC_MOVED_PERMANENTLY, method.getStatusCode());
}
 
Example #15
Source File: TestCaldav.java    From davmail with GNU General Public License v2.0 5 votes vote down vote up
public void testPropfindPrincipal() throws IOException, DavException {
    //Settings.setLoggingLevel("httpclient.wire", Level.DEBUG);

    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")));
    PropFindMethod method = new PropFindMethod("/principals/users/" + session.getEmail() + "/", davPropertyNameSet, 0);
    httpClient.executeMethod(method);
    assertEquals(HttpStatus.SC_MULTI_STATUS, method.getStatusCode());
    MultiStatus multiStatus = method.getResponseBodyAsMultiStatus();
    MultiStatusResponse[] responses = multiStatus.getResponses();
    assertEquals(1, responses.length);
}
 
Example #16
Source File: TestCaldav.java    From davmail with GNU General Public License v2.0 5 votes vote down vote up
public void testPrincipalUrl() throws IOException, DavException {
    DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet();
    davPropertyNameSet.add(DavPropertyName.create("principal-URL", Namespace.getNamespace("DAV:")));
    PropFindMethod method = new PropFindMethod("/principals/users/"+session.getEmail(), davPropertyNameSet, 0);
    httpClient.executeMethod(method);
    method.getResponseBodyAsMultiStatus();
    assertEquals(HttpStatus.SC_MULTI_STATUS, method.getStatusCode());
}
 
Example #17
Source File: TestCaldavHttpClient4.java    From davmail with GNU General Public License v2.0 5 votes vote down vote up
public void testGetOtherUserCalendar() throws IOException {
    HttpPropfind method = new HttpPropfind("/principals/users/" + Settings.getProperty("davmail.usera"),
            DavConstants.PROPFIND_ALL_PROP, new DavPropertyNameSet(), DavConstants.DEPTH_INFINITY);
    try (CloseableHttpResponse response = httpClient.execute(method)) {
        assertEquals(HttpStatus.SC_MULTI_STATUS, response.getStatusLine().getStatusCode());
    }
}
 
Example #18
Source File: TestCaldav.java    From davmail with GNU General Public License v2.0 5 votes vote down vote up
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 #19
Source File: TestCaldav.java    From davmail with GNU General Public License v2.0 5 votes vote down vote up
public void testPropfindAddressBook() throws IOException, DavException {
    DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet();
    //davPropertyNameSet.add(DavPropertyName.create("getctag", Namespace.getNamespace("http://calendarserver.org/ns/")));
    davPropertyNameSet.add(DavPropertyName.create("getetag", Namespace.getNamespace("DAV:")));
    PropFindMethod method = new PropFindMethod("/users/" + session.getEmail()+"/addressbook/", davPropertyNameSet, 1);
    httpClient.getParams().setParameter(HttpMethodParams.USER_AGENT, "Address%20Book/883 CFNetwork/454.12.4 Darwin/10.8.0 (i386) (MacBookPro3%2C1)");
    httpClient.executeMethod(method);
    assertEquals(HttpStatus.SC_MULTI_STATUS, method.getStatusCode());
    method.getResponseBodyAsMultiStatus();
}
 
Example #20
Source File: TestCaldav.java    From davmail with GNU General Public License v2.0 5 votes vote down vote up
public void testPropfindPublicPrincipal() throws IOException, DavException {
    //Settings.setLoggingLevel("httpclient.wire", Level.DEBUG);

    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")));
    PropFindMethod method = new PropFindMethod("/principals/public/testcalendar/", davPropertyNameSet, 0);
    httpClient.executeMethod(method);
    assertEquals(HttpStatus.SC_MULTI_STATUS, method.getStatusCode());
    MultiStatus multiStatus = method.getResponseBodyAsMultiStatus();
    MultiStatusResponse[] responses = multiStatus.getResponses();
    assertEquals(1, responses.length);
}
 
Example #21
Source File: TestCaldavHttpClient4.java    From davmail with GNU General Public License v2.0 5 votes vote down vote up
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 #22
Source File: WebdavFileObject.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/**
 * Sets an attribute of this file. Is only called if {@link #doGetType} does not return {@link FileType#IMAGINARY}.
 */
@Override
protected void doSetAttribute(final String attrName, final Object value) throws Exception {
    try {
        final URLFileName fileName = (URLFileName) getName();
        final String urlStr = toUrlString(fileName);
        final DavPropertySet properties = new DavPropertySet();
        final DavPropertyNameSet propertyNameSet = new DavPropertyNameSet();
        final DavProperty property = new DefaultDavProperty(attrName, value, Namespace.EMPTY_NAMESPACE);
        if (value != null) {
            properties.add(property);
        } else {
            propertyNameSet.add(property.getName()); // remove property
        }

        final PropPatchMethod method = new PropPatchMethod(urlStr, properties, propertyNameSet);
        setupMethod(method);
        execute(method);
        if (!method.succeeded()) {
            throw new FileSystemException("Property '" + attrName + "' could not be set.");
        }
    } catch (final FileSystemException fse) {
        throw fse;
    } catch (final Exception e) {
        throw new FileSystemException("vfs.provider.webdav/set-attributes", e, getName(), attrName);
    }
}
 
Example #23
Source File: MultiStatusReport.java    From cosmo with Apache License 2.0 5 votes vote down vote up
public final void buildMultistatus() throws CosmoDavException {

        DavPropertyNameSet resultProps = this.createResultPropSpec();
        for (WebDavResource resource : this.getResults()) {
            MultiStatusResponse response = this.buildMultiStatusResponse(resource, resultProps);
            multistatus.addResponse(response);
        }
    }
 
Example #24
Source File: MultiStatusReport.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
    * Returns a <code>MultiStatusResponse</code> describing the specified resource including the specified properties.
    */
   protected MultiStatusResponse buildMultiStatusResponse(WebDavResource resource, DavPropertyNameSet props)
           throws CosmoDavException {
       if (props.isEmpty()) {
           String href = resource.getResourceLocator().getHref(resource.isCollection());
           return new MultiStatusResponse(href, 200);
       }
return new MultiStatusResponse(resource, props, this.propfindType);
   }
 
Example #25
Source File: StandardDavRequest.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * 
 */
public DavPropertyNameSet getProppatchRemoveProperties()
        throws CosmoDavException {
    if (proppatchRemove == null) {
        parsePropPatchRequest();
    }
    return proppatchRemove;
}
 
Example #26
Source File: CaldavMultiStatusReport.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * Includes the resource's calendar data in the response as the
 * <code>CALDAV:calendar-data</code> property if it was requested. The
 * calendar data is filtered if a filter was included in the request.
 */
protected MultiStatusResponse
    buildMultiStatusResponse(WebDavResource resource,
                             DavPropertyNameSet props)
    throws CosmoDavException {
    MultiStatusResponse msr =
        super.buildMultiStatusResponse(resource, props);

    DavCalendarResource dcr = (DavCalendarResource) resource;
    if (getPropFindProps().contains(CALENDARDATA)) {
        msr.add(new CalendarData(readCalendarData(dcr)));
    }

    return msr;
}
 
Example #27
Source File: BaseProvider.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * {@inheritDoc}
 */
public void propfind(DavRequest request, DavResponse response, WebDavResource resource)
        throws CosmoDavException, IOException {
    if (!resource.exists()) {
        throw new NotFoundException();
    }
    int depth = getDepth(request);
    if (depth != DEPTH_0 && !resource.isCollection()) {
        throw new BadRequestException("Depth must be 0 for non-collection resources");
    }

    DavPropertyNameSet props = null;
    int type = -1;

    try {

        props = request.getPropFindProperties();

        type = request.getPropFindType();

    } catch (DavException de) {
        throw new CosmoDavException(de);
    }

    // Since the propfind properties could not be determined in the
    // security filter in order to check specific property privileges, the
    // check must be done manually here.
    checkPropFindAccess(resource, props, type);

    MultiStatus ms = new MultiStatus();
    ms.addResourceProperties(resource, props, type, depth);

    response.sendMultiStatus(ms);
}
 
Example #28
Source File: BaseProvider.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * {@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 #29
Source File: StandardDavRequest.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * {@inheritDoc}
 */
public DavPropertyNameSet getPropFindProperties() throws CosmoDavException {
    if (propfindProps == null) {
        parsePropFindRequest();
    }
    return propfindProps;
}
 
Example #30
Source File: DavItemResourceBase.java    From cosmo with Apache License 2.0 5 votes vote down vote up
public MultiStatusResponse updateProperties(DavPropertySet setProperties,
        DavPropertyNameSet removePropertyNames) throws CosmoDavException {
    MultiStatusResponse msr = super.updateProperties(setProperties,
            removePropertyNames);
    if (hasNonOK(msr)) {
        return msr;
    }

    updateItem();

    return msr;
}