mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
64429: Merged WAT1 (4.3/Cloud) to HEAD-BUG-FIX (4.3/Cloud) 62555: ACE-493, ACE-503 and ACE-511: Modified sites service APIs to support Manage Sites feature. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@64575 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
package org.alfresco.repo.site;
|
package org.alfresco.repo.site;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -52,6 +53,12 @@ public class SiteInfoImpl implements SiteInfo
|
|||||||
/** Site visibility */
|
/** Site visibility */
|
||||||
private SiteVisibility visibility;
|
private SiteVisibility visibility;
|
||||||
|
|
||||||
|
/** Site created date */
|
||||||
|
private Date createdDate;
|
||||||
|
|
||||||
|
/** Site last modified date */
|
||||||
|
private Date lastModifiedDate;
|
||||||
|
|
||||||
/** Set of custom properties that have been defined for site */
|
/** Set of custom properties that have been defined for site */
|
||||||
private Map<QName, Serializable> customProperties = new HashMap<QName, Serializable>(1);
|
private Map<QName, Serializable> customProperties = new HashMap<QName, Serializable>(1);
|
||||||
|
|
||||||
@@ -215,6 +222,38 @@ public class SiteInfoImpl implements SiteInfo
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.service.cmr.site.SiteInfo#getCreatedDate()
|
||||||
|
*/
|
||||||
|
public Date getCreatedDate()
|
||||||
|
{
|
||||||
|
return this.createdDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.service.cmr.site.SiteInfo#setCreatedDate(java.util.Date)
|
||||||
|
*/
|
||||||
|
public void setCreatedDate(Date createdDate)
|
||||||
|
{
|
||||||
|
this.createdDate = createdDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.service.cmr.site.SiteInfo#getLastModifiedDate()
|
||||||
|
*/
|
||||||
|
public Date getLastModifiedDate()
|
||||||
|
{
|
||||||
|
return this.lastModifiedDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.service.cmr.site.SiteInfo#setLastModifiedDate(java.util.Date)
|
||||||
|
*/
|
||||||
|
public void setLastModifiedDate(Date lastModifiedDate)
|
||||||
|
{
|
||||||
|
this.lastModifiedDate = lastModifiedDate;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override equals for this ref type
|
* Override equals for this ref type
|
||||||
*
|
*
|
||||||
|
@@ -22,6 +22,7 @@ import java.io.Serializable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -77,6 +78,7 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
|||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||||
import org.alfresco.service.cmr.search.LimitBy;
|
import org.alfresco.service.cmr.search.LimitBy;
|
||||||
import org.alfresco.service.cmr.search.ResultSet;
|
import org.alfresco.service.cmr.search.ResultSet;
|
||||||
import org.alfresco.service.cmr.search.SearchParameters;
|
import org.alfresco.service.cmr.search.SearchParameters;
|
||||||
@@ -198,10 +200,10 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
|||||||
|
|
||||||
public void setPreferenceService(PreferenceService preferenceService)
|
public void setPreferenceService(PreferenceService preferenceService)
|
||||||
{
|
{
|
||||||
this.preferenceService = preferenceService;
|
this.preferenceService = preferenceService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set node service
|
* Set node service
|
||||||
*/
|
*/
|
||||||
public void setNodeService(NodeService nodeService)
|
public void setNodeService(NodeService nodeService)
|
||||||
@@ -340,7 +342,7 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
|||||||
|
|
||||||
public void setSysAdminParams(SysAdminParams sysAdminParams)
|
public void setSysAdminParams(SysAdminParams sysAdminParams)
|
||||||
{
|
{
|
||||||
this.sysAdminParams = sysAdminParams;
|
this.sysAdminParams = sysAdminParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBehaviourFilter(BehaviourFilter behaviourFilter)
|
public void setBehaviourFilter(BehaviourFilter behaviourFilter)
|
||||||
@@ -450,36 +452,36 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
|||||||
final String description,
|
final String description,
|
||||||
final SiteVisibility visibility)
|
final SiteVisibility visibility)
|
||||||
{
|
{
|
||||||
return createSite(sitePreset, passedShortName, title, description, visibility, SiteModel.TYPE_SITE);
|
return createSite(sitePreset, passedShortName, title, description, visibility, SiteModel.TYPE_SITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SiteInfo createSite(final String sitePreset,
|
public SiteInfo createSite(final String sitePreset,
|
||||||
String passedShortName,
|
String passedShortName,
|
||||||
final String title,
|
final String title,
|
||||||
final String description,
|
final String description,
|
||||||
final SiteVisibility visibility,
|
final SiteVisibility visibility,
|
||||||
final QName siteType)
|
final QName siteType)
|
||||||
{
|
{
|
||||||
// Check that the provided site type is a subtype of TYPE_SITE
|
// Check that the provided site type is a subtype of TYPE_SITE
|
||||||
if (SiteModel.TYPE_SITE.equals(siteType) == false &&
|
if (SiteModel.TYPE_SITE.equals(siteType) == false &&
|
||||||
dictionaryService.isSubClass(siteType, TYPE_SITE) == false)
|
dictionaryService.isSubClass(siteType, TYPE_SITE) == false)
|
||||||
{
|
{
|
||||||
throw new SiteServiceException(MSG_INVALID_SITE_TYPE, new Object[]{siteType});
|
throw new SiteServiceException(MSG_INVALID_SITE_TYPE, new Object[]{siteType});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove spaces from shortName
|
// Remove spaces from shortName
|
||||||
final String shortName = passedShortName.replaceAll(" ", "");
|
final String shortName = passedShortName.replaceAll(" ", "");
|
||||||
|
|
||||||
// Check to see if we already have a site of this name
|
// Check to see if we already have a site of this name
|
||||||
NodeRef existingSite = getSiteNodeRef(shortName, false);
|
NodeRef existingSite = getSiteNodeRef(shortName, false);
|
||||||
if (existingSite != null || authorityService.authorityExists(getSiteGroup(shortName, true)))
|
if (existingSite != null || authorityService.authorityExists(getSiteGroup(shortName, true)))
|
||||||
{
|
{
|
||||||
// Throw an exception since we have a duplicate site name
|
// Throw an exception since we have a duplicate site name
|
||||||
throw new SiteServiceException(MSG_UNABLE_TO_CREATE, new Object[]{shortName});
|
throw new SiteServiceException(MSG_UNABLE_TO_CREATE, new Object[]{shortName});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the site name isn't too long
|
// Check that the site name isn't too long
|
||||||
// Authorities are limited to 100 characters by the PermissionService
|
// Authorities are limited to 100 characters by the PermissionService
|
||||||
int longestPermissionLength = 0;
|
int longestPermissionLength = 0;
|
||||||
for (String permission : permissionService.getSettablePermissions(siteType))
|
for (String permission : permissionService.getSettablePermissions(siteType))
|
||||||
{
|
{
|
||||||
@@ -488,12 +490,12 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
|||||||
}
|
}
|
||||||
int maximumPermisionGroupLength = 99 - longestPermissionLength;
|
int maximumPermisionGroupLength = 99 - longestPermissionLength;
|
||||||
|
|
||||||
if (getSiteGroup(shortName, true).length() > maximumPermisionGroupLength)
|
if (getSiteGroup(shortName, true).length() > maximumPermisionGroupLength)
|
||||||
{
|
{
|
||||||
throw new SiteServiceException(MSG_SITE_SHORT_NAME_TOO_LONG, new Object[] {
|
throw new SiteServiceException(MSG_SITE_SHORT_NAME_TOO_LONG, new Object[] {
|
||||||
shortName, maximumPermisionGroupLength - getSiteGroup("", true).length()
|
shortName, maximumPermisionGroupLength - getSiteGroup("", true).length()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the site parent node reference
|
// Get the site parent node reference
|
||||||
final NodeRef siteParent = getSiteParent(shortName);
|
final NodeRef siteParent = getSiteParent(shortName);
|
||||||
@@ -1133,7 +1135,10 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
|||||||
|
|
||||||
// Create and return the site information
|
// Create and return the site information
|
||||||
Map<QName, Serializable> customProperties = getSiteCustomProperties(properties);
|
Map<QName, Serializable> customProperties = getSiteCustomProperties(properties);
|
||||||
|
|
||||||
siteInfo = new SiteInfoImpl(sitePreset, shortName, title, description, visibility, customProperties, siteNodeRef);
|
siteInfo = new SiteInfoImpl(sitePreset, shortName, title, description, visibility, customProperties, siteNodeRef);
|
||||||
|
siteInfo.setCreatedDate(DefaultTypeConverter.INSTANCE.convert(Date.class, properties.get(ContentModel.PROP_CREATED)));
|
||||||
|
siteInfo.setLastModifiedDate(DefaultTypeConverter.INSTANCE.convert(Date.class, properties.get(ContentModel.PROP_MODIFIED)));
|
||||||
|
|
||||||
return siteInfo;
|
return siteInfo;
|
||||||
}
|
}
|
||||||
@@ -1157,13 +1162,13 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
|||||||
if (visibilityValue == null)
|
if (visibilityValue == null)
|
||||||
{
|
{
|
||||||
// Examine each permission to see if this is a public site or not
|
// Examine each permission to see if this is a public site or not
|
||||||
Set<AccessPermission> permissions;
|
Set<AccessPermission> permissions;
|
||||||
try {
|
try {
|
||||||
permissions = this.permissionService.getAllSetPermissions(siteNodeRef);
|
permissions = this.permissionService.getAllSetPermissions(siteNodeRef);
|
||||||
} catch (AccessDeniedException ae){
|
} catch (AccessDeniedException ae){
|
||||||
// We might not have permission to examine the permissions
|
// We might not have permission to examine the permissions
|
||||||
return visibility;
|
return visibility;
|
||||||
}
|
}
|
||||||
for (AccessPermission permission : permissions)
|
for (AccessPermission permission : permissions)
|
||||||
{
|
{
|
||||||
if (permission.getAuthority().equals(PermissionService.ALL_AUTHORITIES) == true &&
|
if (permission.getAuthority().equals(PermissionService.ALL_AUTHORITIES) == true &&
|
||||||
@@ -1614,7 +1619,7 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
|||||||
}
|
}
|
||||||
if(callback.isDone())
|
if(callback.isDone())
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GROUP:
|
case GROUP:
|
||||||
@@ -1647,12 +1652,12 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// No name filter add this group
|
// No name filter add this group
|
||||||
callback.siteMember(authority, permission);
|
callback.siteMember(authority, permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(callback.isDone())
|
if(callback.isDone())
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1678,21 +1683,21 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
|||||||
if (addUser)
|
if (addUser)
|
||||||
{
|
{
|
||||||
// Add the collapsed user into the members list if they do not already appear in the list
|
// Add the collapsed user into the members list if they do not already appear in the list
|
||||||
callback.siteMember(subUser, entry.getValue());
|
callback.siteMember(subUser, entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(callback.isDone())
|
if(callback.isDone())
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PagingResults<SiteMembership> listMembersPaged(String shortName, boolean collapseGroups, List<Pair<SiteService.SortFields, Boolean>> sortProps, PagingRequest pagingRequest)
|
public PagingResults<SiteMembership> listMembersPaged(String shortName, boolean collapseGroups, List<Pair<SiteService.SortFields, Boolean>> sortProps, PagingRequest pagingRequest)
|
||||||
{
|
{
|
||||||
SiteMembershipCannedQueryFactory sitesCannedQueryFactory = (SiteMembershipCannedQueryFactory)cannedQueryRegistry.getNamedObject("sitesCannedQueryFactory");
|
SiteMembershipCannedQueryFactory sitesCannedQueryFactory = (SiteMembershipCannedQueryFactory)cannedQueryRegistry.getNamedObject("sitesCannedQueryFactory");
|
||||||
|
|
||||||
CannedQueryPageDetails pageDetails = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems());
|
CannedQueryPageDetails pageDetails = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems());
|
||||||
|
|
||||||
@@ -1712,11 +1717,11 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
|||||||
SiteMembersCannedQueryParams parameterBean = new SiteMembersCannedQueryParams(shortName, collapseGroups);
|
SiteMembersCannedQueryParams parameterBean = new SiteMembersCannedQueryParams(shortName, collapseGroups);
|
||||||
CannedQueryParameters params = new CannedQueryParameters(parameterBean, pageDetails, sortDetails, pagingRequest.getRequestTotalCountMax(), pagingRequest.getQueryExecutionId());
|
CannedQueryParameters params = new CannedQueryParameters(parameterBean, pageDetails, sortDetails, pagingRequest.getRequestTotalCountMax(), pagingRequest.getQueryExecutionId());
|
||||||
|
|
||||||
CannedQuery<SiteMembership> query = sitesCannedQueryFactory.getCannedQuery(params);
|
CannedQuery<SiteMembership> query = sitesCannedQueryFactory.getCannedQuery(params);
|
||||||
|
|
||||||
CannedQueryResults<SiteMembership> results = query.execute();
|
CannedQueryResults<SiteMembership> results = query.execute();
|
||||||
|
|
||||||
return getPagingResults(pagingRequest, results);
|
return getPagingResults(pagingRequest, results);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2063,21 +2068,21 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
|||||||
List<String> roles = getMembersRoles(shortName, authorityName);
|
List<String> roles = getMembersRoles(shortName, authorityName);
|
||||||
if (roles.size() != 0)
|
if (roles.size() != 0)
|
||||||
{
|
{
|
||||||
if (roles.size() > 1 && roleComparator != null)
|
if (roles.size() > 1 && roleComparator != null)
|
||||||
{
|
{
|
||||||
// Need to sort the roles into the most important first.
|
// Need to sort the roles into the most important first.
|
||||||
SortedSet<String> sortedRoles = new TreeSet<String>(roleComparator);
|
SortedSet<String> sortedRoles = new TreeSet<String>(roleComparator);
|
||||||
for (String role : roles)
|
for (String role : roles)
|
||||||
{
|
{
|
||||||
sortedRoles.add(role);
|
sortedRoles.add(role);
|
||||||
}
|
}
|
||||||
result = sortedRoles.first();
|
result = sortedRoles.first();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// don't search on precedence or only one result
|
// don't search on precedence or only one result
|
||||||
result = roles.get(0);
|
result = roles.get(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -2323,8 +2328,8 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
|||||||
{
|
{
|
||||||
// TODO if this is the only site manager do not down grade their
|
// TODO if this is the only site manager do not down grade their
|
||||||
// permissions
|
// permissions
|
||||||
if(canAddMember(shortName, authorityName, role))
|
if(canAddMember(shortName, authorityName, role))
|
||||||
{
|
{
|
||||||
// Check that we are not about to remove the last site manager
|
// Check that we are not about to remove the last site manager
|
||||||
checkLastManagerRemoval(shortName, authorityName, currentRole);
|
checkLastManagerRemoval(shortName, authorityName, currentRole);
|
||||||
|
|
||||||
@@ -2529,20 +2534,20 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public PagingResults<FileInfo> listContainers(String shortName, PagingRequest pagingRequest)
|
public PagingResults<FileInfo> listContainers(String shortName, PagingRequest pagingRequest)
|
||||||
{
|
{
|
||||||
SiteContainersCannedQueryFactory sitesContainersCannedQueryFactory = (SiteContainersCannedQueryFactory)cannedQueryRegistry.getNamedObject("siteContainersCannedQueryFactory");
|
SiteContainersCannedQueryFactory sitesContainersCannedQueryFactory = (SiteContainersCannedQueryFactory)cannedQueryRegistry.getNamedObject("siteContainersCannedQueryFactory");
|
||||||
|
|
||||||
CannedQueryPageDetails pageDetails = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems());
|
CannedQueryPageDetails pageDetails = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems());
|
||||||
CannedQuerySortDetails sortDetails = new CannedQuerySortDetails(new Pair<Object, SortOrder>(SiteContainersCannedQueryParams.SortFields.ContainerName, SortOrder.ASCENDING));
|
CannedQuerySortDetails sortDetails = new CannedQuerySortDetails(new Pair<Object, SortOrder>(SiteContainersCannedQueryParams.SortFields.ContainerName, SortOrder.ASCENDING));
|
||||||
SiteContainersCannedQueryParams parameterBean = new SiteContainersCannedQueryParams(getSiteNodeRef(shortName));
|
SiteContainersCannedQueryParams parameterBean = new SiteContainersCannedQueryParams(getSiteNodeRef(shortName));
|
||||||
CannedQueryParameters params = new CannedQueryParameters(parameterBean, pageDetails, sortDetails, pagingRequest.getRequestTotalCountMax(), pagingRequest.getQueryExecutionId());
|
CannedQueryParameters params = new CannedQueryParameters(parameterBean, pageDetails, sortDetails, pagingRequest.getRequestTotalCountMax(), pagingRequest.getQueryExecutionId());
|
||||||
|
|
||||||
CannedQuery<FileInfo> query = sitesContainersCannedQueryFactory.getCannedQuery(params);
|
CannedQuery<FileInfo> query = sitesContainersCannedQueryFactory.getCannedQuery(params);
|
||||||
|
|
||||||
CannedQueryResults<FileInfo> results = query.execute();
|
CannedQueryResults<FileInfo> results = query.execute();
|
||||||
|
|
||||||
return getPagingResults(pagingRequest, results);
|
return getPagingResults(pagingRequest, results);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2832,10 +2837,10 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
|||||||
// Check that we are not about to remove the last site manager
|
// Check that we are not about to remove the last site manager
|
||||||
if (SiteModel.SITE_MANAGER.equals(role) == true)
|
if (SiteModel.SITE_MANAGER.equals(role) == true)
|
||||||
{
|
{
|
||||||
int siteAuthorities = countAuthoritiesWithRole(shortName, SiteModel.SITE_MANAGER);
|
int siteAuthorities = countAuthoritiesWithRole(shortName, SiteModel.SITE_MANAGER);
|
||||||
if (siteAuthorities <= 1)
|
if (siteAuthorities <= 1)
|
||||||
{
|
{
|
||||||
throw new SiteServiceException(MSG_DO_NOT_CHANGE_MGR, new Object[] {authorityName});
|
throw new SiteServiceException(MSG_DO_NOT_CHANGE_MGR, new Object[] {authorityName});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2860,9 +2865,9 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PagingResults<SiteMembership> listSitesPaged(final String userName, List<Pair<SiteService.SortFields, Boolean>> sortProps, final PagingRequest pagingRequest)
|
public PagingResults<SiteMembership> listSitesPaged(final String userName, List<Pair<SiteService.SortFields, Boolean>> sortProps, final PagingRequest pagingRequest)
|
||||||
{
|
{
|
||||||
SiteMembershipCannedQueryFactory sitesCannedQueryFactory = (SiteMembershipCannedQueryFactory)cannedQueryRegistry.getNamedObject("sitesCannedQueryFactory");
|
SiteMembershipCannedQueryFactory sitesCannedQueryFactory = (SiteMembershipCannedQueryFactory)cannedQueryRegistry.getNamedObject("sitesCannedQueryFactory");
|
||||||
|
|
||||||
CannedQueryPageDetails pageDetails = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems());
|
CannedQueryPageDetails pageDetails = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems());
|
||||||
|
|
||||||
@@ -2882,69 +2887,69 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
|||||||
SitesCannedQueryParams parameterBean = new SitesCannedQueryParams(userName);
|
SitesCannedQueryParams parameterBean = new SitesCannedQueryParams(userName);
|
||||||
CannedQueryParameters params = new CannedQueryParameters(parameterBean, pageDetails, sortDetails, pagingRequest.getRequestTotalCountMax(), pagingRequest.getQueryExecutionId());
|
CannedQueryParameters params = new CannedQueryParameters(parameterBean, pageDetails, sortDetails, pagingRequest.getRequestTotalCountMax(), pagingRequest.getQueryExecutionId());
|
||||||
|
|
||||||
CannedQuery<SiteMembership> query = sitesCannedQueryFactory.getCannedQuery(params);
|
CannedQuery<SiteMembership> query = sitesCannedQueryFactory.getCannedQuery(params);
|
||||||
|
|
||||||
CannedQueryResults<SiteMembership> results = query.execute();
|
CannedQueryResults<SiteMembership> results = query.execute();
|
||||||
|
|
||||||
return getPagingResults(pagingRequest, results);
|
return getPagingResults(pagingRequest, results);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T extends Object> PagingResults<T> getPagingResults(PagingRequest pagingRequest, final CannedQueryResults<T> results)
|
private <T extends Object> PagingResults<T> getPagingResults(PagingRequest pagingRequest, final CannedQueryResults<T> results)
|
||||||
{
|
{
|
||||||
List<T> entities = null;
|
List<T> entities = null;
|
||||||
if (results.getPageCount() > 0)
|
if (results.getPageCount() > 0)
|
||||||
{
|
{
|
||||||
entities = results.getPages().get(0);
|
entities = results.getPages().get(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
entities = Collections.emptyList();
|
entities = Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
// set total count
|
// set total count
|
||||||
final Pair<Integer, Integer> totalCount;
|
final Pair<Integer, Integer> totalCount;
|
||||||
if (pagingRequest.getRequestTotalCountMax() > 0)
|
if (pagingRequest.getRequestTotalCountMax() > 0)
|
||||||
{
|
{
|
||||||
totalCount = results.getTotalResultCount();
|
totalCount = results.getTotalResultCount();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
totalCount = null;
|
totalCount = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<T> members = new ArrayList<T>(entities.size());
|
final List<T> members = new ArrayList<T>(entities.size());
|
||||||
for (T entity : entities)
|
for (T entity : entities)
|
||||||
{
|
{
|
||||||
members.add(entity);
|
members.add(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PagingResults<T>()
|
return new PagingResults<T>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public String getQueryExecutionId()
|
public String getQueryExecutionId()
|
||||||
{
|
{
|
||||||
return results.getQueryExecutionId();
|
return results.getQueryExecutionId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> getPage()
|
public List<T> getPage()
|
||||||
{
|
{
|
||||||
return members;
|
return members;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasMoreItems()
|
public boolean hasMoreItems()
|
||||||
{
|
{
|
||||||
return results.hasMoreItems();
|
return results.hasMoreItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Pair<Integer, Integer> getTotalResultCount()
|
public Pair<Integer, Integer> getTotalResultCount()
|
||||||
{
|
{
|
||||||
return totalCount;
|
return totalCount;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private sites have separate ACLs on each component and don't inherit from the
|
* Private sites have separate ACLs on each component and don't inherit from the
|
||||||
|
@@ -202,6 +202,39 @@ public class ScriptSiteService extends BaseScopableProcessorExtension
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the sites available in the repository based on the user's access right. For example,
|
||||||
|
* Site Administrator can access all the sites (Public, MODERATED and PRIVATE). The returned list can optionally
|
||||||
|
* be filtered by name and site preset. If no filters are specified then all the available sites are returned.
|
||||||
|
*
|
||||||
|
* NOTE: If the filter starts with a * a Lucene based search will be performed, this may discover a wider range
|
||||||
|
* of results i.e. those sites that contain the search term as opposed to those that start with the search term,
|
||||||
|
* but newly created sites may not be found until the underlying search indexes are updated.
|
||||||
|
*
|
||||||
|
* @param filter inclusion filter for returned sites. Only sites whose cm:name OR cm:title
|
||||||
|
* OR cm:description start with the filter string will be returned.
|
||||||
|
* @param sitePresetFilter site preset filter
|
||||||
|
* @param size max results size crop if >0
|
||||||
|
* @return Site[] a list of the site filtered as appropriate
|
||||||
|
*/
|
||||||
|
public Site[] getSitesAsSiteAdmin(final String filter, final String sitePresetFilter, final int size)
|
||||||
|
{
|
||||||
|
if (siteService.isSiteAdmin(AuthenticationUtil.getFullyAuthenticatedUser()))
|
||||||
|
{
|
||||||
|
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Site[]>()
|
||||||
|
{
|
||||||
|
public Site[] doWork() throws Exception
|
||||||
|
{
|
||||||
|
return getSites(filter, sitePresetFilter, size);
|
||||||
|
}
|
||||||
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return getSites(filter, sitePresetFilter, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List the sites available in the repository. The returned list can optionally be filtered by name and site
|
* List the sites available in the repository. The returned list can optionally be filtered by name and site
|
||||||
* preset.
|
* preset.
|
||||||
@@ -314,13 +347,28 @@ public class ScriptSiteService extends BaseScopableProcessorExtension
|
|||||||
* <p>
|
* <p>
|
||||||
* Returns null if the site does not exist.
|
* Returns null if the site does not exist.
|
||||||
*
|
*
|
||||||
* @param shortName short name of the site
|
* @param shortName short name of the site
|
||||||
* @return Site the site, null if does not exist
|
* @return Site the site, null if does not exist
|
||||||
*/
|
*/
|
||||||
public Site getSite(String shortName)
|
public Site getSite(final String shortName)
|
||||||
{
|
{
|
||||||
|
SiteInfo siteInfo = null;
|
||||||
Site site = null;
|
Site site = null;
|
||||||
SiteInfo siteInfo = this.siteService.getSite(shortName);
|
if (siteService.isSiteAdmin(AuthenticationUtil.getFullyAuthenticatedUser()))
|
||||||
|
{
|
||||||
|
siteInfo = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<SiteInfo>()
|
||||||
|
{
|
||||||
|
public SiteInfo doWork() throws Exception
|
||||||
|
{
|
||||||
|
return siteService.getSite(shortName);
|
||||||
|
}
|
||||||
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
siteInfo = this.siteService.getSite(shortName);
|
||||||
|
}
|
||||||
|
|
||||||
if (siteInfo != null)
|
if (siteInfo != null)
|
||||||
{
|
{
|
||||||
site = new Site(siteInfo, this.serviceRegistry, this.siteService, getScope());
|
site = new Site(siteInfo, this.serviceRegistry, this.siteService, getScope());
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
package org.alfresco.repo.site.script;
|
package org.alfresco.repo.site.script;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -271,6 +272,26 @@ public class Site implements Serializable
|
|||||||
return this.siteRoleGroups;
|
return this.siteRoleGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the site created date
|
||||||
|
*
|
||||||
|
* @return <code>Date</code> site created date
|
||||||
|
*/
|
||||||
|
public Date getCreatedDate()
|
||||||
|
{
|
||||||
|
return this.siteInfo.getCreatedDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the site last modified date
|
||||||
|
*
|
||||||
|
* @return <code>Date</code> site last modified date
|
||||||
|
*/
|
||||||
|
public Date getLastModifiedDate()
|
||||||
|
{
|
||||||
|
return this.siteInfo.getLastModifiedDate();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves any outstanding updates to the site details.
|
* Saves any outstanding updates to the site details.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -280,9 +301,23 @@ public class Site implements Serializable
|
|||||||
{
|
{
|
||||||
if (this.isDirty == true)
|
if (this.isDirty == true)
|
||||||
{
|
{
|
||||||
// Update the site details
|
if (siteService.isSiteAdmin(AuthenticationUtil.getFullyAuthenticatedUser()))
|
||||||
this.siteService.updateSite(this.siteInfo);
|
{
|
||||||
|
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Void>()
|
||||||
|
{
|
||||||
|
public Void doWork() throws Exception
|
||||||
|
{
|
||||||
|
// Update the site details as a site-admin
|
||||||
|
siteService.updateSite(siteInfo);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Update the site details
|
||||||
|
this.siteService.updateSite(this.siteInfo);
|
||||||
|
}
|
||||||
// Reset the dirty flag
|
// Reset the dirty flag
|
||||||
this.isDirty = false;
|
this.isDirty = false;
|
||||||
}
|
}
|
||||||
@@ -293,8 +328,23 @@ public class Site implements Serializable
|
|||||||
*/
|
*/
|
||||||
public void deleteSite()
|
public void deleteSite()
|
||||||
{
|
{
|
||||||
// Delete the site
|
if (siteService.isSiteAdmin(AuthenticationUtil.getFullyAuthenticatedUser()))
|
||||||
this.siteService.deleteSite(this.siteInfo.getShortName());
|
{
|
||||||
|
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Void>()
|
||||||
|
{
|
||||||
|
public Void doWork() throws Exception
|
||||||
|
{
|
||||||
|
// Delete the site
|
||||||
|
siteService.deleteSite(siteInfo.getShortName());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Delete the site
|
||||||
|
this.siteService.deleteSite(this.siteInfo.getShortName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
package org.alfresco.service.cmr.site;
|
package org.alfresco.service.cmr.site;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.api.AlfrescoPublicApi;
|
import org.alfresco.api.AlfrescoPublicApi;
|
||||||
@@ -124,4 +125,32 @@ public interface SiteInfo extends PermissionCheckValue
|
|||||||
*/
|
*/
|
||||||
public abstract Serializable getCustomProperty(QName name);
|
public abstract Serializable getCustomProperty(QName name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the site created date
|
||||||
|
*
|
||||||
|
* @return <code>Date</code> site created date
|
||||||
|
*/
|
||||||
|
public abstract Date getCreatedDate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the site created date
|
||||||
|
*
|
||||||
|
* @param createdDate site created date
|
||||||
|
*/
|
||||||
|
public abstract void setCreatedDate(Date createdDate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the site last modified date
|
||||||
|
*
|
||||||
|
* @return <code>Date</code> site last modified date
|
||||||
|
*/
|
||||||
|
public abstract Date getLastModifiedDate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the site last modified date
|
||||||
|
*
|
||||||
|
* @param lastModifiedDate site last modified date
|
||||||
|
*/
|
||||||
|
public abstract void setLastModifiedDate(Date lastModifiedDate);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user