mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +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;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -52,6 +53,12 @@ public class SiteInfoImpl implements SiteInfo
|
||||
/** Site 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 */
|
||||
private Map<QName, Serializable> customProperties = new HashMap<QName, Serializable>(1);
|
||||
|
||||
@@ -215,6 +222,38 @@ public class SiteInfoImpl implements SiteInfo
|
||||
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
|
||||
*
|
||||
|
@@ -22,6 +22,7 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
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.NodeService;
|
||||
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.ResultSet;
|
||||
import org.alfresco.service.cmr.search.SearchParameters;
|
||||
@@ -198,10 +200,10 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
||||
|
||||
public void setPreferenceService(PreferenceService preferenceService)
|
||||
{
|
||||
this.preferenceService = preferenceService;
|
||||
}
|
||||
this.preferenceService = preferenceService;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
@@ -340,7 +342,7 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
||||
|
||||
public void setSysAdminParams(SysAdminParams sysAdminParams)
|
||||
{
|
||||
this.sysAdminParams = sysAdminParams;
|
||||
this.sysAdminParams = sysAdminParams;
|
||||
}
|
||||
|
||||
public void setBehaviourFilter(BehaviourFilter behaviourFilter)
|
||||
@@ -450,36 +452,36 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
||||
final String description,
|
||||
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,
|
||||
String passedShortName,
|
||||
final String title,
|
||||
String passedShortName,
|
||||
final String title,
|
||||
final String description,
|
||||
final SiteVisibility visibility,
|
||||
final QName siteType)
|
||||
{
|
||||
// Check that the provided site type is a subtype of TYPE_SITE
|
||||
if (SiteModel.TYPE_SITE.equals(siteType) == false &&
|
||||
dictionaryService.isSubClass(siteType, TYPE_SITE) == false)
|
||||
{
|
||||
throw new SiteServiceException(MSG_INVALID_SITE_TYPE, new Object[]{siteType});
|
||||
}
|
||||
|
||||
{
|
||||
// Check that the provided site type is a subtype of TYPE_SITE
|
||||
if (SiteModel.TYPE_SITE.equals(siteType) == false &&
|
||||
dictionaryService.isSubClass(siteType, TYPE_SITE) == false)
|
||||
{
|
||||
throw new SiteServiceException(MSG_INVALID_SITE_TYPE, new Object[]{siteType});
|
||||
}
|
||||
|
||||
// Remove spaces from shortName
|
||||
final String shortName = passedShortName.replaceAll(" ", "");
|
||||
|
||||
// Check to see if we already have a site of this name
|
||||
NodeRef existingSite = getSiteNodeRef(shortName, false);
|
||||
if (existingSite != null || authorityService.authorityExists(getSiteGroup(shortName, true)))
|
||||
{
|
||||
// Throw an exception since we have a duplicate site name
|
||||
throw new SiteServiceException(MSG_UNABLE_TO_CREATE, new Object[]{shortName});
|
||||
}
|
||||
|
||||
// Check that the site name isn't too long
|
||||
// Authorities are limited to 100 characters by the PermissionService
|
||||
// Check to see if we already have a site of this name
|
||||
NodeRef existingSite = getSiteNodeRef(shortName, false);
|
||||
if (existingSite != null || authorityService.authorityExists(getSiteGroup(shortName, true)))
|
||||
{
|
||||
// Throw an exception since we have a duplicate site name
|
||||
throw new SiteServiceException(MSG_UNABLE_TO_CREATE, new Object[]{shortName});
|
||||
}
|
||||
|
||||
// Check that the site name isn't too long
|
||||
// Authorities are limited to 100 characters by the PermissionService
|
||||
int longestPermissionLength = 0;
|
||||
for (String permission : permissionService.getSettablePermissions(siteType))
|
||||
{
|
||||
@@ -488,12 +490,12 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
||||
}
|
||||
int maximumPermisionGroupLength = 99 - longestPermissionLength;
|
||||
|
||||
if (getSiteGroup(shortName, true).length() > maximumPermisionGroupLength)
|
||||
{
|
||||
throw new SiteServiceException(MSG_SITE_SHORT_NAME_TOO_LONG, new Object[] {
|
||||
shortName, maximumPermisionGroupLength - getSiteGroup("", true).length()
|
||||
});
|
||||
}
|
||||
if (getSiteGroup(shortName, true).length() > maximumPermisionGroupLength)
|
||||
{
|
||||
throw new SiteServiceException(MSG_SITE_SHORT_NAME_TOO_LONG, new Object[] {
|
||||
shortName, maximumPermisionGroupLength - getSiteGroup("", true).length()
|
||||
});
|
||||
}
|
||||
|
||||
// Get the site parent node reference
|
||||
final NodeRef siteParent = getSiteParent(shortName);
|
||||
@@ -1133,7 +1135,10 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
||||
|
||||
// Create and return the site information
|
||||
Map<QName, Serializable> customProperties = getSiteCustomProperties(properties);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -1157,13 +1162,13 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
||||
if (visibilityValue == null)
|
||||
{
|
||||
// Examine each permission to see if this is a public site or not
|
||||
Set<AccessPermission> permissions;
|
||||
try {
|
||||
permissions = this.permissionService.getAllSetPermissions(siteNodeRef);
|
||||
} catch (AccessDeniedException ae){
|
||||
// We might not have permission to examine the permissions
|
||||
return visibility;
|
||||
}
|
||||
Set<AccessPermission> permissions;
|
||||
try {
|
||||
permissions = this.permissionService.getAllSetPermissions(siteNodeRef);
|
||||
} catch (AccessDeniedException ae){
|
||||
// We might not have permission to examine the permissions
|
||||
return visibility;
|
||||
}
|
||||
for (AccessPermission permission : permissions)
|
||||
{
|
||||
if (permission.getAuthority().equals(PermissionService.ALL_AUTHORITIES) == true &&
|
||||
@@ -1614,7 +1619,7 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
||||
}
|
||||
if(callback.isDone())
|
||||
{
|
||||
break;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case GROUP:
|
||||
@@ -1647,12 +1652,12 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
||||
else
|
||||
{
|
||||
// No name filter add this group
|
||||
callback.siteMember(authority, permission);
|
||||
callback.siteMember(authority, permission);
|
||||
}
|
||||
|
||||
if(callback.isDone())
|
||||
{
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1678,21 +1683,21 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
||||
if (addUser)
|
||||
{
|
||||
// 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())
|
||||
{
|
||||
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());
|
||||
|
||||
@@ -1712,11 +1717,11 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
||||
SiteMembersCannedQueryParams parameterBean = new SiteMembersCannedQueryParams(shortName, collapseGroups);
|
||||
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);
|
||||
if (roles.size() != 0)
|
||||
{
|
||||
if (roles.size() > 1 && roleComparator != null)
|
||||
{
|
||||
// Need to sort the roles into the most important first.
|
||||
SortedSet<String> sortedRoles = new TreeSet<String>(roleComparator);
|
||||
for (String role : roles)
|
||||
{
|
||||
sortedRoles.add(role);
|
||||
}
|
||||
result = sortedRoles.first();
|
||||
}
|
||||
else
|
||||
{
|
||||
// don't search on precedence or only one result
|
||||
result = roles.get(0);
|
||||
}
|
||||
if (roles.size() > 1 && roleComparator != null)
|
||||
{
|
||||
// Need to sort the roles into the most important first.
|
||||
SortedSet<String> sortedRoles = new TreeSet<String>(roleComparator);
|
||||
for (String role : roles)
|
||||
{
|
||||
sortedRoles.add(role);
|
||||
}
|
||||
result = sortedRoles.first();
|
||||
}
|
||||
else
|
||||
{
|
||||
// don't search on precedence or only one result
|
||||
result = roles.get(0);
|
||||
}
|
||||
}
|
||||
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
|
||||
// permissions
|
||||
if(canAddMember(shortName, authorityName, role))
|
||||
{
|
||||
if(canAddMember(shortName, authorityName, role))
|
||||
{
|
||||
// Check that we are not about to remove the last site manager
|
||||
checkLastManagerRemoval(shortName, authorityName, currentRole);
|
||||
|
||||
@@ -2529,20 +2534,20 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
||||
}
|
||||
|
||||
@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());
|
||||
CannedQuerySortDetails sortDetails = new CannedQuerySortDetails(new Pair<Object, SortOrder>(SiteContainersCannedQueryParams.SortFields.ContainerName, SortOrder.ASCENDING));
|
||||
SiteContainersCannedQueryParams parameterBean = new SiteContainersCannedQueryParams(getSiteNodeRef(shortName));
|
||||
CannedQuerySortDetails sortDetails = new CannedQuerySortDetails(new Pair<Object, SortOrder>(SiteContainersCannedQueryParams.SortFields.ContainerName, SortOrder.ASCENDING));
|
||||
SiteContainersCannedQueryParams parameterBean = new SiteContainersCannedQueryParams(getSiteNodeRef(shortName));
|
||||
CannedQueryParameters params = new CannedQueryParameters(parameterBean, pageDetails, sortDetails, pagingRequest.getRequestTotalCountMax(), pagingRequest.getQueryExecutionId());
|
||||
|
||||
CannedQuery<FileInfo> query = sitesContainersCannedQueryFactory.getCannedQuery(params);
|
||||
|
||||
CannedQueryResults<FileInfo> results = query.execute();
|
||||
CannedQuery<FileInfo> query = sitesContainersCannedQueryFactory.getCannedQuery(params);
|
||||
|
||||
CannedQueryResults<FileInfo> results = query.execute();
|
||||
|
||||
return getPagingResults(pagingRequest, results);
|
||||
return getPagingResults(pagingRequest, results);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2832,11 +2837,11 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
||||
// Check that we are not about to remove the last site manager
|
||||
if (SiteModel.SITE_MANAGER.equals(role) == true)
|
||||
{
|
||||
int siteAuthorities = countAuthoritiesWithRole(shortName, SiteModel.SITE_MANAGER);
|
||||
int siteAuthorities = countAuthoritiesWithRole(shortName, SiteModel.SITE_MANAGER);
|
||||
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;
|
||||
}
|
||||
|
||||
public PagingResults<SiteMembership> listSitesPaged(final String userName, List<Pair<SiteService.SortFields, Boolean>> sortProps, final PagingRequest pagingRequest)
|
||||
{
|
||||
SiteMembershipCannedQueryFactory sitesCannedQueryFactory = (SiteMembershipCannedQueryFactory)cannedQueryRegistry.getNamedObject("sitesCannedQueryFactory");
|
||||
public PagingResults<SiteMembership> listSitesPaged(final String userName, List<Pair<SiteService.SortFields, Boolean>> sortProps, final PagingRequest pagingRequest)
|
||||
{
|
||||
SiteMembershipCannedQueryFactory sitesCannedQueryFactory = (SiteMembershipCannedQueryFactory)cannedQueryRegistry.getNamedObject("sitesCannedQueryFactory");
|
||||
|
||||
CannedQueryPageDetails pageDetails = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems());
|
||||
|
||||
@@ -2882,69 +2887,69 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
|
||||
SitesCannedQueryParams parameterBean = new SitesCannedQueryParams(userName);
|
||||
CannedQueryParameters params = new CannedQueryParameters(parameterBean, pageDetails, sortDetails, pagingRequest.getRequestTotalCountMax(), pagingRequest.getQueryExecutionId());
|
||||
|
||||
CannedQuery<SiteMembership> query = sitesCannedQueryFactory.getCannedQuery(params);
|
||||
|
||||
CannedQueryResults<SiteMembership> results = query.execute();
|
||||
CannedQuery<SiteMembership> query = sitesCannedQueryFactory.getCannedQuery(params);
|
||||
|
||||
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)
|
||||
{
|
||||
List<T> entities = null;
|
||||
if (results.getPageCount() > 0)
|
||||
{
|
||||
entities = results.getPages().get(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
entities = Collections.emptyList();
|
||||
}
|
||||
|
||||
// set total count
|
||||
final Pair<Integer, Integer> totalCount;
|
||||
if (pagingRequest.getRequestTotalCountMax() > 0)
|
||||
{
|
||||
totalCount = results.getTotalResultCount();
|
||||
}
|
||||
else
|
||||
{
|
||||
totalCount = null;
|
||||
}
|
||||
|
||||
final List<T> members = new ArrayList<T>(entities.size());
|
||||
for (T entity : entities)
|
||||
{
|
||||
members.add(entity);
|
||||
}
|
||||
|
||||
return new PagingResults<T>()
|
||||
{
|
||||
@Override
|
||||
public String getQueryExecutionId()
|
||||
{
|
||||
return results.getQueryExecutionId();
|
||||
}
|
||||
private <T extends Object> PagingResults<T> getPagingResults(PagingRequest pagingRequest, final CannedQueryResults<T> results)
|
||||
{
|
||||
List<T> entities = null;
|
||||
if (results.getPageCount() > 0)
|
||||
{
|
||||
entities = results.getPages().get(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
entities = Collections.emptyList();
|
||||
}
|
||||
|
||||
// set total count
|
||||
final Pair<Integer, Integer> totalCount;
|
||||
if (pagingRequest.getRequestTotalCountMax() > 0)
|
||||
{
|
||||
totalCount = results.getTotalResultCount();
|
||||
}
|
||||
else
|
||||
{
|
||||
totalCount = null;
|
||||
}
|
||||
|
||||
final List<T> members = new ArrayList<T>(entities.size());
|
||||
for (T entity : entities)
|
||||
{
|
||||
members.add(entity);
|
||||
}
|
||||
|
||||
return new PagingResults<T>()
|
||||
{
|
||||
@Override
|
||||
public String getQueryExecutionId()
|
||||
{
|
||||
return results.getQueryExecutionId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> getPage()
|
||||
{
|
||||
return members;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMoreItems()
|
||||
{
|
||||
return results.hasMoreItems();
|
||||
}
|
||||
@Override
|
||||
public List<T> getPage()
|
||||
{
|
||||
return members;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMoreItems()
|
||||
{
|
||||
return results.hasMoreItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> getTotalResultCount()
|
||||
{
|
||||
return totalCount;
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public Pair<Integer, Integer> getTotalResultCount()
|
||||
{
|
||||
return totalCount;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* preset.
|
||||
@@ -314,13 +347,28 @@ public class ScriptSiteService extends BaseScopableProcessorExtension
|
||||
* <p>
|
||||
* Returns null if the site does not exist.
|
||||
*
|
||||
* @param shortName short name of the site
|
||||
* @return Site the site, null if does not exist
|
||||
* @param shortName short name of the site
|
||||
* @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;
|
||||
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)
|
||||
{
|
||||
site = new Site(siteInfo, this.serviceRegistry, this.siteService, getScope());
|
||||
|
@@ -19,6 +19,7 @@
|
||||
package org.alfresco.repo.site.script;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -272,7 +273,27 @@ public class Site implements Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves any outstanding updates to the site details.
|
||||
* 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.
|
||||
* <p>
|
||||
* If properties of the site are changed and save is not called, those changes will be lost.
|
||||
*/
|
||||
@@ -280,9 +301,23 @@ public class Site implements Serializable
|
||||
{
|
||||
if (this.isDirty == true)
|
||||
{
|
||||
// Update the site details
|
||||
this.siteService.updateSite(this.siteInfo);
|
||||
|
||||
if (siteService.isSiteAdmin(AuthenticationUtil.getFullyAuthenticatedUser()))
|
||||
{
|
||||
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
|
||||
this.isDirty = false;
|
||||
}
|
||||
@@ -293,8 +328,23 @@ public class Site implements Serializable
|
||||
*/
|
||||
public void deleteSite()
|
||||
{
|
||||
// Delete the site
|
||||
this.siteService.deleteSite(this.siteInfo.getShortName());
|
||||
if (siteService.isSiteAdmin(AuthenticationUtil.getFullyAuthenticatedUser()))
|
||||
{
|
||||
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;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.api.AlfrescoPublicApi;
|
||||
@@ -124,4 +125,32 @@ public interface SiteInfo extends PermissionCheckValue
|
||||
*/
|
||||
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