Merged HEAD (5.2) to 5.2.N (5.2.1)

127615 jkaabimofrad: Merged API-STRIKES-BACK (5.2.0) to HEAD (5.2)
      127462 jkaabimofrad: Merged 5.1.N (5.1.2) to API-STRIKES-BACK (5.2.0)
         127454 jkaabimofrad: MNT-16224, RA-1093: Fixed Quickshare issue where deleting a shared node didn't remove the 'shared' aspect. The fix also takes care of the shared nodes that have been deleted but not yet restored, as well as, shared nodes that have already been restored from the trashcan (allow the user to un-share).


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@127722 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-06-03 15:19:17 +00:00
parent 6a4c63b03d
commit 29cc2d9ca8
2 changed files with 89 additions and 0 deletions

View File

@@ -140,6 +140,9 @@ public class QuickShareServiceImpl implements QuickShareService,
private PreferenceService preferenceService;
/** Component to determine which behaviours are active and which not */
private BehaviourFilter behaviourFilter;
private SearchService searchService;
private SiteService siteService;
private AuthorityService authorityService;
private SearchService searchService;
private SiteService siteService;
@@ -276,6 +279,36 @@ public class QuickShareServiceImpl implements QuickShareService,
this.behaviourFilter = behaviourFilter;
}
/**
* Spring configuration
*
* @param searchService the searchService to set
*/
public void setSearchService(SearchService searchService)
{
this.searchService = searchService;
}
/**
* Spring configuration
*
* @param siteService the siteService to set
*/
public void setSiteService(SiteService siteService)
{
this.siteService = siteService;
}
/**
* Spring configuration
*
* @param authorityService the authorityService to set
*/
public void setAuthorityService(AuthorityService authorityService)
{
this.authorityService = authorityService;
}
/**
* Enable or disable this service.
*/
@@ -316,6 +349,9 @@ public class QuickShareServiceImpl implements QuickShareService,
PropertyCheck.mandatory(this, "behaviourFilter", behaviourFilter);
PropertyCheck.mandatory(this, "defaultEmailSender", defaultEmailSender);
PropertyCheck.mandatory(this, "clientAppConfig", clientAppConfig);
PropertyCheck.mandatory(this, "searchService", searchService);
PropertyCheck.mandatory(this, "siteService", siteService);
PropertyCheck.mandatory(this, "authorityService", authorityService);
}
/**
@@ -903,6 +939,55 @@ public class QuickShareServiceImpl implements QuickShareService,
}
}
@Override
public boolean canDeleteSharedLink(NodeRef nodeRef, String sharedByUserId)
{
boolean canDeleteSharedLink = false;
String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
String siteName = getSiteName(nodeRef);
boolean isSharedByCurrentUser = currentUser.equals(sharedByUserId);
if (siteName != null)
{
// node belongs to a site - current user must be a manager or collaborator or someone who shared the link
String role = siteService.getMembersRole(siteName, currentUser);
if (isSharedByCurrentUser || (role != null && (role.equals(SiteModel.SITE_MANAGER) || role.equals(SiteModel.SITE_COLLABORATOR))))
{
canDeleteSharedLink = true;
}
}
else if (isSharedByCurrentUser || (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 String getUrl(String url)
{
if (url.endsWith("/"))
@@ -1090,3 +1175,4 @@ public class QuickShareServiceImpl implements QuickShareService,
}
}
}