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:
Alan Davis
2014-03-15 01:43:38 +00:00
parent eac1a27791
commit d8e85072a4
5 changed files with 319 additions and 148 deletions

View File

@@ -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
*

View File

@@ -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;
@@ -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;
}

View File

@@ -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.
@@ -317,10 +350,25 @@ public class ScriptSiteService extends BaseScopableProcessorExtension
* @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());

View File

@@ -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;
@@ -271,6 +272,26 @@ public class Site implements Serializable
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.
* <p>
@@ -279,10 +300,24 @@ public class Site implements Serializable
public void save()
{
if (this.isDirty == true)
{
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;
}
@@ -292,10 +327,25 @@ public class Site implements Serializable
* Deletes the site
*/
public void deleteSite()
{
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());
}
}
/**
* Gets a map of members of the site with their role within the site. This list can

View File

@@ -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);
}