mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merged BRANCHES/DEV/CLOUD1-BUG-FIX to HEAD:
42572: CLOUD-794: "Activities should be posted for CMIS (to enable both Public API + Mobile clients)" - note: also enable WebDAV activities by default (in both cases => file add/update/delete) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@42809 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -59,6 +59,16 @@
|
||||
|
||||
<bean id="CMISService_Control" class="org.alfresco.opencmis.AlfrescoCmisServiceInterceptor" />
|
||||
|
||||
<bean id="cmisActivityPoster" class="org.alfresco.opencmis.ActivityPosterImpl">
|
||||
<property name="activityService" ref="activityService" />
|
||||
<property name="siteService" ref="SiteService" />
|
||||
<property name="tenantService" ref="tenantService" />
|
||||
<property name="nodeService" ref="NodeService" />
|
||||
<property name="fileFolderService" ref="FileFolderService" />
|
||||
<property name="hiddenAspect" ref="hiddenAspect" />
|
||||
<property name="activitiesEnabled" value="${opencmis.activities.enabled}" />
|
||||
</bean>
|
||||
|
||||
<bean id="CMISConnector" class="org.alfresco.opencmis.CMISConnector">
|
||||
<property name="store" value="${opencmis.connector.default.store}" />
|
||||
<property name="rootPath" value="${opencmis.connector.default.rootPath}" />
|
||||
@@ -87,6 +97,9 @@
|
||||
<property name="OpenCMISDictionaryService" ref="OpenCMISDictionaryService" />
|
||||
<property name="OpenCMISQueryService" ref="OpenCMISQueryService" />
|
||||
|
||||
<property name="activityPoster" ref="cmisActivityPoster" />
|
||||
<property name="hiddenAspect" ref="hiddenAspect" />
|
||||
<property name="siteService" ref="SiteService" />
|
||||
<property name="descriptorService" ref="DescriptorService" />
|
||||
<property name="nodeService" ref="NodeService" />
|
||||
<property name="fileFolderService" ref="FileFolderService" />
|
||||
|
@@ -44,7 +44,7 @@ system.webdav.servlet.enabled=true
|
||||
system.webdav.url.path.prefix=
|
||||
system.webdav.storeName=${protocols.storeName}
|
||||
system.webdav.rootPath=${protocols.rootPath}
|
||||
system.webdav.activities.enabled=false
|
||||
system.webdav.activities.enabled=true
|
||||
|
||||
# Is the JBPM Deploy Process Servlet enabled?
|
||||
# Default is false. Should not be enabled in production environments as the
|
||||
@@ -716,6 +716,7 @@ opencmis.connector.default.typesDefaultDepth=-1
|
||||
opencmis.connector.default.objectsDefaultMaxItems=10000
|
||||
opencmis.connector.default.objectsDefaultDepth=100
|
||||
opencmis.connector.default.openHttpSession=false
|
||||
opencmis.activities.enabled=true
|
||||
|
||||
# IMAP
|
||||
imap.server.enabled=false
|
||||
|
43
source/java/org/alfresco/opencmis/ActivityPoster.java
Normal file
43
source/java/org/alfresco/opencmis/ActivityPoster.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.opencmis;
|
||||
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* OpenCMIS methods can ActivityPoster to create entries in the activity feed.
|
||||
*
|
||||
* @author sglover
|
||||
*/
|
||||
public interface ActivityPoster
|
||||
{
|
||||
void postFileAdded(FileInfo fileInfo);
|
||||
|
||||
void postFileUpdated(NodeRef nodeRef);
|
||||
|
||||
void postFileDeleted(
|
||||
String parentPath,
|
||||
NodeRef parentNodeRef,
|
||||
NodeRef nodeRef,
|
||||
String siteId,
|
||||
String fileName);
|
||||
|
||||
String getParentPath(NodeRef nodeRef);
|
||||
}
|
311
source/java/org/alfresco/opencmis/ActivityPosterImpl.java
Normal file
311
source/java/org/alfresco/opencmis/ActivityPosterImpl.java
Normal file
@@ -0,0 +1,311 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.opencmis;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.activities.ActivityType;
|
||||
import org.alfresco.repo.model.filefolder.HiddenAspect;
|
||||
import org.alfresco.repo.model.filefolder.HiddenAspect.Visibility;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.cmr.activities.ActivityService;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.util.FileFilterMode.Client;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* OpenCMIS methods may use an instance of this class to post activity data.
|
||||
*
|
||||
* @see ActivityPoster
|
||||
* @author sglover
|
||||
*/
|
||||
public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
||||
{
|
||||
private static final String APP_TOOL = "CMIS";
|
||||
public static final char PathSeperatorChar = '/';
|
||||
|
||||
// Logging
|
||||
private static Log logger = LogFactory.getLog(ActivityPoster.class);
|
||||
|
||||
private ActivityService activityService;
|
||||
private SiteService siteService;
|
||||
private TenantService tenantService;
|
||||
private NodeService nodeService;
|
||||
private FileFolderService fileFolderService;
|
||||
private HiddenAspect hiddenAspect;
|
||||
|
||||
private boolean activitiesEnabled = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public ActivityPosterImpl()
|
||||
{
|
||||
}
|
||||
|
||||
public void setHiddenAspect(HiddenAspect hiddenAspect)
|
||||
{
|
||||
this.hiddenAspect = hiddenAspect;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setTenantService(TenantService tenantService)
|
||||
{
|
||||
this.tenantService = tenantService;
|
||||
}
|
||||
|
||||
public void setSiteService(SiteService siteService)
|
||||
{
|
||||
this.siteService = siteService;
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void setActivityService(ActivityService activityService)
|
||||
{
|
||||
this.activityService = activityService;
|
||||
}
|
||||
|
||||
public void setActivitiesEnabled(boolean activitiesEnabled)
|
||||
{
|
||||
this.activitiesEnabled = activitiesEnabled;
|
||||
}
|
||||
|
||||
private boolean isHidden(NodeRef nodeRef)
|
||||
{
|
||||
return nodeService.hasAspect(nodeRef, ContentModel.ASPECT_HIDDEN);
|
||||
}
|
||||
|
||||
private final String getPathFromNode(NodeRef rootNodeRef, NodeRef nodeRef) throws FileNotFoundException
|
||||
{
|
||||
// Check if the nodes are valid, or equal
|
||||
if (rootNodeRef == null || nodeRef == null)
|
||||
throw new IllegalArgumentException("Invalid node(s) in getPathFromNode call");
|
||||
|
||||
// short cut if the path node is the root node
|
||||
if (rootNodeRef.equals(nodeRef))
|
||||
return "";
|
||||
|
||||
// get the path elements
|
||||
List<FileInfo> pathInfos = fileFolderService.getNamePath(rootNodeRef, nodeRef);
|
||||
|
||||
// build the path string
|
||||
StringBuilder sb = new StringBuilder(pathInfos.size() * 20);
|
||||
for (FileInfo fileInfo : pathInfos)
|
||||
{
|
||||
sb.append(PathSeperatorChar);
|
||||
sb.append(fileInfo.getName());
|
||||
}
|
||||
// done
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Build name path for node: \n" +
|
||||
" root: " + rootNodeRef + "\n" +
|
||||
" target: " + nodeRef + "\n" +
|
||||
" path: " + sb);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
PropertyCheck.mandatory(this, "activityService", activityService);
|
||||
PropertyCheck.mandatory(this, "siteService", siteService);
|
||||
PropertyCheck.mandatory(this, "tenantService", tenantService);
|
||||
PropertyCheck.mandatory(this, "nodeService", nodeService);
|
||||
PropertyCheck.mandatory(this, "fileFolderService", fileFolderService);
|
||||
}
|
||||
|
||||
private String getCurrentTenantDomain()
|
||||
{
|
||||
String tenantDomain = tenantService.getCurrentUserDomain();
|
||||
if (tenantDomain == null)
|
||||
{
|
||||
return TenantService.DEFAULT_DOMAIN;
|
||||
}
|
||||
return tenantDomain;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void postFileAdded(FileInfo fileInfo)
|
||||
{
|
||||
if(activitiesEnabled && !fileInfo.isHidden())
|
||||
{
|
||||
NodeRef nodeRef = fileInfo.getNodeRef();
|
||||
SiteInfo siteInfo = siteService.getSite(nodeRef);
|
||||
String siteId = (siteInfo != null ? siteInfo.getShortName() : null);
|
||||
NodeRef parentNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef();
|
||||
|
||||
postFileActivity(ActivityType.FILE_ADDED, null, parentNodeRef, nodeRef, siteId, fileInfo.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void postFileUpdated(NodeRef nodeRef)
|
||||
{
|
||||
if(activitiesEnabled && hiddenAspect.getVisibility(Client.cmis, nodeRef) == Visibility.Visible)
|
||||
{
|
||||
SiteInfo siteInfo = siteService.getSite(nodeRef);
|
||||
String siteId = (siteInfo != null ? siteInfo.getShortName() : null);
|
||||
String fileName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
|
||||
postFileActivity(ActivityType.FILE_UPDATED, null, null, nodeRef, siteId, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void postFileDeleted(
|
||||
String parentPath,
|
||||
NodeRef parentNodeRef,
|
||||
NodeRef nodeRef,
|
||||
String siteId,
|
||||
String fileName)
|
||||
{
|
||||
if(activitiesEnabled)
|
||||
{
|
||||
postFileActivity(ActivityType.FILE_DELETED, parentPath, parentNodeRef, nodeRef, siteId, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
public String getParentPath(NodeRef nodeRef)
|
||||
{
|
||||
SiteInfo siteInfo = siteService.getSite(nodeRef);
|
||||
String siteId = (siteInfo != null ? siteInfo.getShortName() : null);
|
||||
NodeRef parentNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef();
|
||||
NodeRef documentLibrary = siteService.getContainer(siteId, SiteService.DOCUMENT_LIBRARY);
|
||||
String parentPath = "/";
|
||||
try
|
||||
{
|
||||
parentPath = getPathFromNode(documentLibrary, parentNodeRef);
|
||||
}
|
||||
catch (FileNotFoundException error)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("No " + SiteService.DOCUMENT_LIBRARY + " container found.");
|
||||
}
|
||||
}
|
||||
|
||||
return parentPath;
|
||||
}
|
||||
|
||||
private void postFileActivity(
|
||||
String activityType,
|
||||
String parentPath,
|
||||
NodeRef parentNodeRef,
|
||||
NodeRef nodeRef,
|
||||
String siteId,
|
||||
String fileName)
|
||||
{
|
||||
JSONObject json = createActivityJSON(getCurrentTenantDomain(), parentPath, parentNodeRef, nodeRef, fileName);
|
||||
|
||||
activityService.postActivity(
|
||||
activityType,
|
||||
siteId,
|
||||
APP_TOOL,
|
||||
json.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create JSON suitable for create, modify or delete activity posts. Returns a new JSONObject
|
||||
* containing appropriate key/value pairs.
|
||||
*
|
||||
* @param tenantDomain
|
||||
* @param nodeRef
|
||||
* @param fileName
|
||||
* @throws WebDAVServerException
|
||||
* @return JSONObject
|
||||
*/
|
||||
private JSONObject createActivityJSON(
|
||||
String tenantDomain,
|
||||
String parentPath,
|
||||
NodeRef parentNodeRef,
|
||||
NodeRef nodeRef,
|
||||
String fileName)
|
||||
{
|
||||
JSONObject json = new JSONObject();
|
||||
try
|
||||
{
|
||||
json.put("nodeRef", nodeRef);
|
||||
|
||||
if (parentNodeRef != null)
|
||||
{
|
||||
// Used for deleted files.
|
||||
json.put("parentNodeRef", parentNodeRef);
|
||||
}
|
||||
|
||||
if (parentPath != null)
|
||||
{
|
||||
// Used for deleted files.
|
||||
json.put("page", "documentlibrary?path=" + parentPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Used for added or modified files.
|
||||
json.put("page", "document-details?nodeRef=" + nodeRef);
|
||||
}
|
||||
json.put("title", fileName);
|
||||
|
||||
if (!tenantDomain.equals(TenantService.DEFAULT_DOMAIN))
|
||||
{
|
||||
// Only used in multi-tenant setups.
|
||||
json.put("tenantDomain", tenantDomain);
|
||||
}
|
||||
}
|
||||
catch (JSONException error)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("", error);
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
}
|
@@ -1152,8 +1152,9 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
||||
final File tempFile = copyToTempFile(contentStream);
|
||||
final Charset encoding = (tempFile == null ? null : getEncoding(tempFile, contentStream.getMimeType()));
|
||||
|
||||
NodeRef nodeRef = connector.getFileFolderService().create(
|
||||
parentInfo.getNodeRef(), name, type.getAlfrescoClass()).getNodeRef();
|
||||
FileInfo fileInfo = connector.getFileFolderService().create(
|
||||
parentInfo.getNodeRef(), name, type.getAlfrescoClass());
|
||||
NodeRef nodeRef = fileInfo.getNodeRef();
|
||||
connector.setProperties(nodeRef, type, properties, new String[] { PropertyIds.NAME, PropertyIds.OBJECT_TYPE_ID });
|
||||
connector.applyPolicies(nodeRef, type, policies);
|
||||
connector.applyACL(nodeRef, type, addAces, removeAces);
|
||||
@@ -1172,7 +1173,11 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
||||
|
||||
removeTempFile(tempFile);
|
||||
|
||||
return connector.createObjectId(nodeRef);
|
||||
String objectId = connector.createObjectId(nodeRef);
|
||||
|
||||
connector.getActivityPoster().postFileAdded(fileInfo);
|
||||
|
||||
return objectId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1209,14 +1214,17 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
||||
|
||||
try
|
||||
{
|
||||
NodeRef nodeRef = connector.getFileFolderService().copy(
|
||||
sourceNodeRef, parentInfo.getNodeRef(), name).getNodeRef();
|
||||
FileInfo fileInfo = connector.getFileFolderService().copy(
|
||||
sourceNodeRef, parentInfo.getNodeRef(), name);
|
||||
NodeRef nodeRef = fileInfo.getNodeRef();
|
||||
connector.setProperties(nodeRef, type, properties, new String[] {
|
||||
PropertyIds.NAME, PropertyIds.OBJECT_TYPE_ID });
|
||||
connector.applyPolicies(nodeRef, type, policies);
|
||||
connector.applyACL(nodeRef, type, addAces, removeAces);
|
||||
connector.applyVersioningState(nodeRef, versioningState);
|
||||
|
||||
connector.getActivityPoster().postFileAdded(fileInfo);
|
||||
|
||||
return connector.createObjectId(nodeRef);
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
@@ -1360,6 +1368,8 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
||||
}
|
||||
|
||||
objectId.setValue(connector.createObjectId(nodeRef));
|
||||
|
||||
connector.getActivityPoster().postFileUpdated(nodeRef);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1385,6 +1395,8 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
||||
|
||||
connector.getNodeService().setProperty(nodeRef, ContentModel.PROP_CONTENT, null);
|
||||
|
||||
connector.getActivityPoster().postFileUpdated(nodeRef);
|
||||
|
||||
objectId.setValue(connector.createObjectId(nodeRef));
|
||||
}
|
||||
|
||||
@@ -1467,6 +1479,8 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
||||
{
|
||||
getObjectInfo(repositoryId, objectId.getValue(), "*", IncludeRelationships.NONE);
|
||||
}
|
||||
|
||||
connector.getActivityPoster().postFileUpdated(nodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1517,7 +1531,7 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
||||
"Could not delete folder with at least one child!");
|
||||
}
|
||||
|
||||
connector.getNodeService().deleteNode(nodeRef);
|
||||
connector.deleteNode(nodeRef, false);
|
||||
break; // Reason for do-while
|
||||
}
|
||||
|
||||
@@ -1545,7 +1559,7 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
||||
// attempt to delete the node
|
||||
if (allVersions)
|
||||
{
|
||||
connector.getNodeService().deleteNode(nodeRef);
|
||||
connector.deleteNode(nodeRef, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1554,7 +1568,7 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
||||
|
||||
if (infoImpl.getVersionHistory().getPredecessor(version) == null)
|
||||
{
|
||||
connector.getNodeService().deleteNode(nodeRef);
|
||||
connector.deleteNode(nodeRef, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1628,7 +1642,7 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
||||
}
|
||||
|
||||
// attempt to delete the node
|
||||
connector.getNodeService().deleteNode(nodeRef);
|
||||
connector.deleteNode(nodeRef, false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -58,6 +58,8 @@ import org.alfresco.opencmis.search.CMISResultSet;
|
||||
import org.alfresco.opencmis.search.CMISResultSetColumn;
|
||||
import org.alfresco.opencmis.search.CMISResultSetRow;
|
||||
import org.alfresco.repo.cache.SimpleCache;
|
||||
import org.alfresco.repo.model.filefolder.HiddenAspect;
|
||||
import org.alfresco.repo.model.filefolder.HiddenAspect.Visibility;
|
||||
import org.alfresco.repo.policy.BehaviourFilter;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
@@ -99,6 +101,8 @@ import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.cmr.version.VersionService;
|
||||
import org.alfresco.service.cmr.version.VersionType;
|
||||
import org.alfresco.service.descriptor.Descriptor;
|
||||
@@ -107,6 +111,8 @@ import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.FileFilterMode;
|
||||
import org.alfresco.util.FileFilterMode.Client;
|
||||
import org.apache.chemistry.opencmis.commons.BasicPermissions;
|
||||
import org.apache.chemistry.opencmis.commons.PropertyIds;
|
||||
import org.apache.chemistry.opencmis.commons.data.Ace;
|
||||
@@ -250,8 +256,14 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
private NamespaceService namespaceService;
|
||||
private SearchService searchService;
|
||||
private DictionaryService dictionaryService;
|
||||
private SiteService siteService;
|
||||
|
||||
private ActivityPoster activityPoster;
|
||||
|
||||
private BehaviourFilter behaviourFilter;
|
||||
|
||||
private HiddenAspect hiddenAspect;
|
||||
|
||||
private StoreRef storeRef;
|
||||
private String rootPath;
|
||||
private Map<String, List<String>> kindToRenditionNames;
|
||||
@@ -277,7 +289,6 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
// --------------------------------------------------------------
|
||||
// Configuration
|
||||
// --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sets the root store.
|
||||
*
|
||||
@@ -289,6 +300,32 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
this.storeRef = new StoreRef(store);
|
||||
}
|
||||
|
||||
public void setSiteService(SiteService siteService)
|
||||
{
|
||||
this.siteService = siteService;
|
||||
}
|
||||
|
||||
public void setActivityPoster(ActivityPoster activityPoster)
|
||||
{
|
||||
this.activityPoster = activityPoster;
|
||||
}
|
||||
|
||||
public ActivityPoster getActivityPoster()
|
||||
{
|
||||
return activityPoster;
|
||||
}
|
||||
|
||||
public void setHiddenAspect(HiddenAspect hiddenAspect)
|
||||
{
|
||||
this.hiddenAspect = hiddenAspect;
|
||||
}
|
||||
|
||||
public boolean isHidden(NodeRef nodeRef)
|
||||
{
|
||||
final Client client = FileFilterMode.getClient();
|
||||
return (hiddenAspect.getVisibility(client, nodeRef) == Visibility.NotVisible);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the root path.
|
||||
*
|
||||
@@ -669,6 +706,11 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
// Alfresco methods
|
||||
// --------------------------------------------------------------
|
||||
|
||||
public SiteInfo getSite(NodeRef nodeRef)
|
||||
{
|
||||
return siteService.getSite(nodeRef);
|
||||
}
|
||||
|
||||
public boolean disableBehaviour(QName className, NodeRef nodeRef)
|
||||
{
|
||||
boolean wasEnabled = behaviourFilter.isEnabled(nodeRef, className);
|
||||
@@ -694,6 +736,35 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
return getRootNodeRef().getStoreRef();
|
||||
}
|
||||
|
||||
public void deleteNode(NodeRef nodeRef, boolean postActivity)
|
||||
{
|
||||
// post activity after removal of the node
|
||||
postActivity &= hiddenAspect.getVisibility(Client.cmis, nodeRef) == Visibility.Visible;
|
||||
String parentPath = null;
|
||||
NodeRef parentNodeRef = null;
|
||||
SiteInfo siteInfo = null;
|
||||
String siteId = null;
|
||||
String fileName = null;
|
||||
|
||||
// get this information before the node is deleted
|
||||
if(postActivity)
|
||||
{
|
||||
parentPath = activityPoster.getParentPath(nodeRef);
|
||||
parentNodeRef = getNodeService().getPrimaryParent(nodeRef).getParentRef();
|
||||
siteInfo = siteService.getSite(nodeRef);
|
||||
siteId = (siteInfo != null ? siteInfo.getShortName() : null);
|
||||
fileName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
}
|
||||
|
||||
getNodeService().deleteNode(nodeRef);
|
||||
|
||||
// post activity after removal of the node
|
||||
if(postActivity)
|
||||
{
|
||||
activityPoster.postFileDeleted(parentPath, parentNodeRef, nodeRef, siteId, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the root folder node ref.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user