REPO-1348: initial check-in for "update site" API implementation.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@131224 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Matt Ward
2016-10-06 11:17:16 +00:00
parent fe279c2eb6
commit 8d91423894
6 changed files with 340 additions and 1 deletions

View File

@@ -1137,6 +1137,41 @@ public class SitesImpl implements Sites
return getSite(siteInfo, true);
}
@Override
public Site updateSite(String siteId, Site update, Parameters parameters)
{
if (logger.isDebugEnabled())
{
logger.debug("Updating site, ID: "+siteId+", site data: "+update+", parameters: "+parameters);
}
SiteInfo siteInfo = validateSite(siteId);
if (siteInfo == null)
{
// site does not exist
throw new EntityNotFoundException(siteId);
}
// Although this method will not update the site ID even if it is provided, we sanity
// check that no attempt is being made to alter it.
if (update.getId() != null && (!update.getId().equals(siteId)))
{
throw new InvalidArgumentException("Site updates cannot change the site ID");
}
siteInfo.setTitle(update.getTitle());
siteInfo.setDescription(update.getDescription());
siteInfo.setVisibility(update.getVisibility());
// Validate the new details
validateSite(new Site(siteInfo, null));
// Perform the actual update.
siteService.updateSite(siteInfo);
return getSite(siteId);
}
private Site validateSite(Site site)
{
// site title - mandatory