mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
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:
@@ -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>
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user