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

@@ -45,6 +45,7 @@ public interface Sites
Site getSite(String siteId);
void deleteSite(String siteId, Parameters parameters);
Site createSite(Site site, Parameters parameters);
Site updateSite(String siteId, Site site, Parameters parameters);
/**
* people/<personId>/sites/<siteId>

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

View File

@@ -51,7 +51,7 @@ import java.util.List;
@EntityResource(name="sites", title = "Sites")
public class SiteEntityResource implements EntityResourceAction.Read<Site>,
EntityResourceAction.ReadById<Site>, EntityResourceAction.Delete,
EntityResourceAction.Create<Site>, InitializingBean
EntityResourceAction.Create<Site>, EntityResourceAction.Update<Site>, InitializingBean
{
private Sites sites;
@@ -117,4 +117,20 @@ public class SiteEntityResource implements EntityResourceAction.Read<Site>,
result.add(sites.createSite(entity.get(0), parameters));
return result;
}
/**
* Update the given site. Not all fields are used,
* only those as defined in the Open API spec.
*
* @param siteId The site ID (aka short name)
* @param site Details to use for the update
* @param parameters
* @return Updated Site
*/
@Override
@WebApiDescription(title="Update site", description="Update the Share site")
public Site update(String siteId, Site site, Parameters parameters)
{
return sites.updateSite(siteId, site, parameters);
}
}