mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
127616 jkaabimofrad: Merged API-STRIKES-BACK (5.2.0) to HEAD (5.2) 127464 jkaabimofrad: RA-1093: Removed a common method as it was pushed down to the QuickShareService as a result of the MNT-16224 fix. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@127723 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -33,7 +33,6 @@ import org.alfresco.repo.quickshare.QuickShareServiceImpl.QuickShareEmailRequest
|
|||||||
import org.alfresco.repo.search.QueryParameterDefImpl;
|
import org.alfresco.repo.search.QueryParameterDefImpl;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||||
import org.alfresco.repo.site.SiteModel;
|
|
||||||
import org.alfresco.repo.tenant.TenantUtil;
|
import org.alfresco.repo.tenant.TenantUtil;
|
||||||
import org.alfresco.rest.antlr.WhereClauseParser;
|
import org.alfresco.rest.antlr.WhereClauseParser;
|
||||||
import org.alfresco.rest.api.Nodes;
|
import org.alfresco.rest.api.Nodes;
|
||||||
@@ -77,9 +76,7 @@ import org.alfresco.service.cmr.search.ResultSet;
|
|||||||
import org.alfresco.service.cmr.search.ResultSetRow;
|
import org.alfresco.service.cmr.search.ResultSetRow;
|
||||||
import org.alfresco.service.cmr.search.SearchParameters;
|
import org.alfresco.service.cmr.search.SearchParameters;
|
||||||
import org.alfresco.service.cmr.search.SearchService;
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
import org.alfresco.service.cmr.security.AuthorityService;
|
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
import org.alfresco.service.cmr.site.SiteService;
|
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
@@ -107,7 +104,7 @@ import java.util.Set;
|
|||||||
*
|
*
|
||||||
* @author janv
|
* @author janv
|
||||||
* @author Jamal Kaabi-Mofrad
|
* @author Jamal Kaabi-Mofrad
|
||||||
*
|
*
|
||||||
* @since publicapi1.0
|
* @since publicapi1.0
|
||||||
*/
|
*/
|
||||||
public class QuickShareLinksImpl implements QuickShareLinks, InitializingBean
|
public class QuickShareLinksImpl implements QuickShareLinks, InitializingBean
|
||||||
@@ -124,12 +121,10 @@ public class QuickShareLinksImpl implements QuickShareLinks, InitializingBean
|
|||||||
|
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
private PersonService personService;
|
private PersonService personService;
|
||||||
private AuthorityService authorityService;
|
|
||||||
private MimetypeService mimeTypeService;
|
private MimetypeService mimeTypeService;
|
||||||
private SearchService searchService;
|
private SearchService searchService;
|
||||||
private DictionaryService dictionaryService;
|
private DictionaryService dictionaryService;
|
||||||
private NamespaceService namespaceService;
|
private NamespaceService namespaceService;
|
||||||
private SiteService siteService;
|
|
||||||
|
|
||||||
public void setServiceRegistry(ServiceRegistry sr)
|
public void setServiceRegistry(ServiceRegistry sr)
|
||||||
{
|
{
|
||||||
@@ -166,12 +161,10 @@ public class QuickShareLinksImpl implements QuickShareLinks, InitializingBean
|
|||||||
|
|
||||||
this.nodeService = sr.getNodeService();
|
this.nodeService = sr.getNodeService();
|
||||||
this.personService = sr.getPersonService();
|
this.personService = sr.getPersonService();
|
||||||
this.authorityService = sr.getAuthorityService();
|
|
||||||
this.mimeTypeService = sr.getMimetypeService();
|
this.mimeTypeService = sr.getMimetypeService();
|
||||||
this.searchService = sr.getSearchService();
|
this.searchService = sr.getSearchService();
|
||||||
this.dictionaryService = sr.getDictionaryService();
|
this.dictionaryService = sr.getDictionaryService();
|
||||||
this.namespaceService = sr.getNamespaceService();
|
this.namespaceService = sr.getNamespaceService();
|
||||||
this.siteService = sr.getSiteService();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -280,7 +273,7 @@ public class QuickShareLinksImpl implements QuickShareLinks, InitializingBean
|
|||||||
NodeRef nodeRef = quickShareService.getTenantNodeRefFromSharedId(sharedId).getSecond();
|
NodeRef nodeRef = quickShareService.getTenantNodeRefFromSharedId(sharedId).getSecond();
|
||||||
|
|
||||||
String sharedByUserId = (String)nodeService.getProperty(nodeRef, QuickShareModel.PROP_QSHARE_SHAREDBY);
|
String sharedByUserId = (String)nodeService.getProperty(nodeRef, QuickShareModel.PROP_QSHARE_SHAREDBY);
|
||||||
if (! canDeleteSharedLink(nodeRef, sharedByUserId))
|
if (!quickShareService.canDeleteSharedLink(nodeRef, sharedByUserId))
|
||||||
{
|
{
|
||||||
throw new PermissionDeniedException("Can't perform unshare action: " + sharedId);
|
throw new PermissionDeniedException("Can't perform unshare action: " + sharedId);
|
||||||
}
|
}
|
||||||
@@ -558,7 +551,7 @@ public class QuickShareLinksImpl implements QuickShareLinks, InitializingBean
|
|||||||
// note: if noAuth mode then do not return allowable operations (eg. but can be optionally returned when finding shared links)
|
// note: if noAuth mode then do not return allowable operations (eg. but can be optionally returned when finding shared links)
|
||||||
if ((! noAuth) && includeParam.contains(PARAM_INCLUDE_ALLOWABLEOPERATIONS))
|
if ((! noAuth) && includeParam.contains(PARAM_INCLUDE_ALLOWABLEOPERATIONS))
|
||||||
{
|
{
|
||||||
if (canDeleteSharedLink(nodeRef, sharedByUserId))
|
if (quickShareService.canDeleteSharedLink(nodeRef, sharedByUserId))
|
||||||
{
|
{
|
||||||
qs.setAllowableOperations(Collections.singletonList(Nodes.OP_DELETE));
|
qs.setAllowableOperations(Collections.singletonList(Nodes.OP_DELETE));
|
||||||
}
|
}
|
||||||
@@ -578,54 +571,6 @@ public class QuickShareLinksImpl implements QuickShareLinks, InitializingBean
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO push down to QuickShareService and also update v0 webscript (UnshareContentDelete)
|
|
||||||
private boolean canDeleteSharedLink(NodeRef nodeRef, String sharedByUserId)
|
|
||||||
{
|
|
||||||
boolean canDeleteSharedLink = false;
|
|
||||||
|
|
||||||
String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
|
|
||||||
String siteName = getSiteName(nodeRef);
|
|
||||||
|
|
||||||
if (siteName != null)
|
|
||||||
{
|
|
||||||
// node belongs to a site - current user must be a manager or collaborator (irrespective of whether they shared the link or not)
|
|
||||||
String role = siteService.getMembersRole(siteName, currentUser);
|
|
||||||
if (role.equals(SiteModel.SITE_MANAGER) || role.equals(SiteModel.SITE_COLLABORATOR))
|
|
||||||
{
|
|
||||||
canDeleteSharedLink = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((currentUser.equals(sharedByUserId)) || (authorityService.isAdminAuthority(currentUser)))
|
|
||||||
{
|
|
||||||
// node does not belongs to a site - current user must be the person who shared the link or an admin
|
|
||||||
canDeleteSharedLink = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return canDeleteSharedLink;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getSiteName(NodeRef nodeRef)
|
|
||||||
{
|
|
||||||
NodeRef parent = nodeService.getPrimaryParent(nodeRef).getParentRef();
|
|
||||||
while (parent != null && !nodeService.getType(parent).equals(SiteModel.TYPE_SITE))
|
|
||||||
{
|
|
||||||
// check that we can read parent name
|
|
||||||
String parentName = (String) nodeService.getProperty(parent, ContentModel.PROP_NAME);
|
|
||||||
|
|
||||||
if (nodeService.getPrimaryParent(nodeRef) != null)
|
|
||||||
{
|
|
||||||
parent = nodeService.getPrimaryParent(parent).getParentRef();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parent == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nodeService.getProperty(parent, ContentModel.PROP_NAME).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkEnabled()
|
private void checkEnabled()
|
||||||
{
|
{
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
|
Reference in New Issue
Block a user