Search in sources :

Example 1 with WebDavService

use of org.alfresco.service.cmr.webdav.WebDavService in project alfresco-remote-api by Alfresco.

the class PutMethod method postActivity.

/**
 * Create an activity post.
 *
 * @throws WebDAVServerException
 */
protected void postActivity() throws WebDAVServerException {
    WebDavService davService = getDAVHelper().getServiceRegistry().getWebDavService();
    if (!davService.activitiesEnabled()) {
        // Don't post activities if this behaviour is disabled.
        return;
    }
    String path = getPath();
    String siteId = getSiteId();
    String tenantDomain = getTenantDomain();
    if (siteId.equals(WebDAVHelper.EMPTY_SITE_ID)) {
        // There is not enough information to publish site activity.
        return;
    }
    FileInfo contentNodeInfo = null;
    try {
        contentNodeInfo = getNodeForPath(getRootNodeRef(), path);
        NodeRef nodeRef = contentNodeInfo.getNodeRef();
        // Don't post activity data for hidden files, resource forks etc.
        if (!getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_HIDDEN)) {
            if (isCreated()) {
                // file added
                activityPoster.postFileFolderAdded(siteId, tenantDomain, null, contentNodeInfo);
            } else {
                // file updated
                activityPoster.postFileFolderUpdated(siteId, tenantDomain, contentNodeInfo);
            }
        }
    } catch (FileNotFoundException error) {
        throw new WebDAVServerException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
}
Also used : WebDavService(org.alfresco.service.cmr.webdav.WebDavService) NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) FileNotFoundException(org.alfresco.service.cmr.model.FileNotFoundException)

Example 2 with WebDavService

use of org.alfresco.service.cmr.webdav.WebDavService in project alfresco-remote-api by Alfresco.

the class DeleteMethod method postActivity.

/**
 * Create a deletion activity post.
 *
 * @param parent The FileInfo for the deleted file's parent.
 * @param deletedFile The FileInfo for the deleted file.
 * @throws WebDAVServerException
 */
protected void postActivity(FileInfo parent, FileInfo deletedFile, String siteId) throws WebDAVServerException {
    WebDavService davService = getDAVHelper().getServiceRegistry().getWebDavService();
    if (!davService.activitiesEnabled()) {
        // Don't post activities if this behaviour is disabled.
        return;
    }
    String tenantDomain = getTenantDomain();
    // Check there is enough information to publish site activity.
    if (!siteId.equals(WebDAVHelper.EMPTY_SITE_ID)) {
        SiteService siteService = getServiceRegistry().getSiteService();
        NodeRef documentLibrary = siteService.getContainer(siteId, SiteService.DOCUMENT_LIBRARY);
        String parentPath = "/";
        try {
            parentPath = getDAVHelper().getPathFromNode(documentLibrary, parent.getNodeRef());
        } catch (FileNotFoundException error) {
            if (logger.isDebugEnabled()) {
                logger.debug("No " + SiteService.DOCUMENT_LIBRARY + " container found.");
            }
        }
        activityPoster.postFileFolderDeleted(siteId, tenantDomain, parentPath, parent, deletedFile);
    }
}
Also used : WebDavService(org.alfresco.service.cmr.webdav.WebDavService) NodeRef(org.alfresco.service.cmr.repository.NodeRef) SiteService(org.alfresco.service.cmr.site.SiteService) FileNotFoundException(org.alfresco.service.cmr.model.FileNotFoundException)

Example 3 with WebDavService

use of org.alfresco.service.cmr.webdav.WebDavService in project alfresco-remote-api by Alfresco.

the class MkcolMethod method postActivity.

/**
 * Create a folder added activity post.
 *
 * @throws WebDAVServerException
 */
private void postActivity(FileInfo fileInfo) throws WebDAVServerException {
    WebDavService davService = getDAVHelper().getServiceRegistry().getWebDavService();
    if (!davService.activitiesEnabled()) {
        // Don't post activities if this behaviour is disabled.
        return;
    }
    String siteId = getSiteId();
    String tenantDomain = getTenantDomain();
    // Check there is enough information to publish site activity.
    if (!siteId.equals(WebDAVHelper.EMPTY_SITE_ID)) {
        SiteService siteService = getServiceRegistry().getSiteService();
        NodeRef documentLibrary = siteService.getContainer(siteId, SiteService.DOCUMENT_LIBRARY);
        String path = "/";
        try {
            path = getDAVHelper().getPathFromNode(documentLibrary, fileInfo.getNodeRef());
        } catch (FileNotFoundException error) {
            if (logger.isDebugEnabled()) {
                logger.debug("No " + SiteService.DOCUMENT_LIBRARY + " container found.");
            }
        }
        activityPoster.postFileFolderAdded(siteId, tenantDomain, path, fileInfo);
    }
}
Also used : WebDavService(org.alfresco.service.cmr.webdav.WebDavService) NodeRef(org.alfresco.service.cmr.repository.NodeRef) SiteService(org.alfresco.service.cmr.site.SiteService) FileNotFoundException(org.alfresco.service.cmr.model.FileNotFoundException)

Aggregations

FileNotFoundException (org.alfresco.service.cmr.model.FileNotFoundException)3 NodeRef (org.alfresco.service.cmr.repository.NodeRef)3 WebDavService (org.alfresco.service.cmr.webdav.WebDavService)3 SiteService (org.alfresco.service.cmr.site.SiteService)2 FileInfo (org.alfresco.service.cmr.model.FileInfo)1