Search in sources :

Example 1 with SiteServiceException

use of org.alfresco.repo.site.SiteServiceException in project alfresco-remote-api by Alfresco.

the class SitesImpl method createSite.

/**
 * Create default/fixed preset (Share) site - with DocLib container/component
 *
 * @param site
 * @return
 */
public Site createSite(Site site, Parameters parameters) {
    // note: if site id is null then will be generated from the site title
    site = validateSite(site);
    SiteInfo siteInfo = null;
    try {
        siteInfo = createSite(site);
    } catch (SiteServiceException sse) {
        if (sse.getMsgId().equals("site_service.unable_to_create")) {
            throw new ConstraintViolatedException(sse.getMessage());
        } else {
            throw sse;
        }
    }
    String siteId = siteInfo.getShortName();
    NodeRef siteNodeRef = siteInfo.getNodeRef();
    // default false (if not provided)
    boolean skipShareSurfConfig = Boolean.valueOf(parameters.getParameter(PARAM_SKIP_SURF_CONFIGURATION));
    if (skipShareSurfConfig == false) {
        // import default/fixed preset Share surf config
        importSite(siteId, siteNodeRef);
    }
    // pre-create doclib
    siteService.createContainer(siteId, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null);
    // default false (if not provided)
    boolean skipAddToFavorites = Boolean.valueOf(parameters.getParameter(PARAM_SKIP_ADDTOFAVORITES));
    if (skipAddToFavorites == false) {
        String personId = AuthenticationUtil.getFullyAuthenticatedUser();
        // ignore result
        favouritesService.addFavourite(personId, siteNodeRef);
    }
    return getSite(siteInfo, true);
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) NodeRef(org.alfresco.service.cmr.repository.NodeRef) SiteServiceException(org.alfresco.repo.site.SiteServiceException) FilterPropString(org.alfresco.repo.node.getchildren.FilterPropString) ConstraintViolatedException(org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException)

Aggregations

FilterPropString (org.alfresco.repo.node.getchildren.FilterPropString)1 SiteServiceException (org.alfresco.repo.site.SiteServiceException)1 ConstraintViolatedException (org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 SiteInfo (org.alfresco.service.cmr.site.SiteInfo)1