RM-4199: create rm site rest api impl

This commit is contained in:
Silviu Dinuta
2016-10-18 12:21:42 +03:00
parent 995448081e
commit ee07a75d67
13 changed files with 692 additions and 0 deletions

View File

@@ -0,0 +1,210 @@
<?xml version="1.0" encoding="UTF-8"?>
<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0">
<cm:folder xmlns="" xmlns:twitter="http://www.alfresco.org/model/publishing/twitter/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:facebook="http://www.alfresco.org/model/publishing/facebook/1.0" xmlns:youtube="http://www.alfresco.org/model/publishing/youtube/1.0" xmlns:st="http://www.alfresco.org/model/site/1.0" xmlns:custom="custom.model" xmlns:exif="http://www.alfresco.org/model/exif/1.0" xmlns:alfcmis="http://www.alfresco.org/model/cmis/1.0/alfcmis" xmlns:pub="http://www.alfresco.org/model/publishing/1.0" xmlns:inwf="http://www.alfresco.org/model/workflow/invite/nominated/1.0" xmlns:suwf="http://www.alfresco.org/model/workflow/signup/selfsignup/1.0" xmlns:flickr="http://www.alfresco.org/model/publishing/flickr/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns:imap="http://www.alfresco.org/model/imap/1.0" xmlns:stcp="http://www.alfresco.org/model/sitecustomproperty/1.0" xmlns:ver2="http://www.alfresco.org/model/versionstore/2.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:imwf="http://www.alfresco.org/model/workflow/invite/moderated/1.0" xmlns:cmisext="http://www.alfresco.org/model/cmis/1.0/cs01ext" xmlns:wf="http://www.alfresco.org/model/workflow/1.0" xmlns:trx="http://www.alfresco.org/model/transfer/1.0" xmlns:rn="http://www.alfresco.org/model/rendition/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:lnk="http://www.alfresco.org/model/linksmodel/1.0" xmlns:webdav="http://www.alfresco.org/model/webdav/1.0" xmlns:pubwf="http://www.alfresco.org/model/publishingworkflow/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:cmiscustom="http://www.alfresco.org/model/cmis/custom" xmlns:emailserver="http://www.alfresco.org/model/emailserver/1.0" xmlns:ia="http://www.alfresco.org/model/calendar" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:dl="http://www.alfresco.org/model/datalist/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:module="http://www.alfresco.org/system/modules/1.0" xmlns:blg="http://www.alfresco.org/model/blogintegration/1.0" xmlns:linkedin="http://www.alfresco.org/model/publishing/linkedin/1.0" xmlns:alf="http://www.alfresco.org" xmlns:cmis="http://www.alfresco.org/model/cmis/1.0/cs01" xmlns:bpm="http://www.alfresco.org/model/bpm/1.0" xmlns:reg="http://www.alfresco.org/system/registry/1.0" xmlns:cloud="http://www.alfresco.org/model/cloud/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" view:childName="cm:surf-config">
<view:aspects>
<sys:localized></sys:localized>
<sys:referenceable></sys:referenceable>
<cm:auditable></cm:auditable>
</view:aspects>
<view:acl></view:acl>
<view:properties>
<cm:name>surf-config</cm:name>
<sys:store-identifier>SpacesStore</sys:store-identifier>
<sys:locale>en_US_</sys:locale>
<sys:store-protocol>workspace</sys:store-protocol>
<cm:isIndexed>false</cm:isIndexed>
</view:properties>
<view:associations>
<cm:contains>
<cm:folder view:childName="cm:components">
<view:aspects>
<sys:localized></sys:localized>
<sys:referenceable></sys:referenceable>
<cm:auditable></cm:auditable>
</view:aspects>
<view:acl></view:acl>
<view:properties>
<cm:name>components</cm:name>
<sys:store-identifier>SpacesStore</sys:store-identifier>
<sys:locale>en_US_</sys:locale>
<sys:store-protocol>workspace</sys:store-protocol>
<cm:isIndexed>false</cm:isIndexed>
</view:properties>
<view:associations>
<cm:contains>
<cm:content view:childName="cm:page.title.site~${siteId}~dashboard.xml">
<view:aspects>
<sys:localized></sys:localized>
<sys:referenceable></sys:referenceable>
<cm:auditable></cm:auditable>
</view:aspects>
<view:acl></view:acl>
<view:properties>
<cm:name>page.title.site~${siteId}~dashboard.xml</cm:name>
<sys:store-identifier>SpacesStore</sys:store-identifier>
<sys:locale>en_US_</sys:locale>
<cm:content>contentUrl=surf-config/content0.bin|mimetype=application/octet-stream|size=260|encoding=UTF-8|locale=en_US_</cm:content>
<sys:store-protocol>workspace</sys:store-protocol>
<cm:isIndexed>false</cm:isIndexed>
</view:properties>
</cm:content>
<cm:content view:childName="cm:page.navigation.site~${siteId}~dashboard.xml">
<view:aspects>
<sys:localized></sys:localized>
<sys:referenceable></sys:referenceable>
<cm:auditable></cm:auditable>
</view:aspects>
<view:acl></view:acl>
<view:properties>
<cm:name>page.navigation.site~${siteId}~dashboard.xml</cm:name>
<sys:store-identifier>SpacesStore</sys:store-identifier>
<sys:locale>en_US_</sys:locale>
<cm:content>contentUrl=surf-config/content1.bin|mimetype=application/octet-stream|size=280|encoding=UTF-8|locale=en_US_</cm:content>
<sys:store-protocol>workspace</sys:store-protocol>
<cm:isIndexed>false</cm:isIndexed>
</view:properties>
</cm:content>
<cm:content view:childName="cm:page.full-width-dashlet.site~${siteId}~dashboard.xml">
<view:aspects>
<sys:localized></sys:localized>
<sys:referenceable></sys:referenceable>
<cm:auditable></cm:auditable>
</view:aspects>
<view:acl></view:acl>
<view:properties>
<cm:name>page.full-width-dashlet.site~${siteId}~dashboard.xml</cm:name>
<sys:store-identifier>SpacesStore</sys:store-identifier>
<sys:locale>en_US_</sys:locale>
<cm:content>contentUrl=surf-config/content2.bin|mimetype=application/octet-stream|size=356|encoding=UTF-8|locale=en_US_</cm:content>
<sys:store-protocol>workspace</sys:store-protocol>
<cm:isIndexed>false</cm:isIndexed>
</view:properties>
</cm:content>
<cm:content view:childName="cm:page.component-1-1.site~${siteId}~dashboard.xml">
<view:aspects>
<sys:localized></sys:localized>
<sys:referenceable></sys:referenceable>
<cm:auditable></cm:auditable>
</view:aspects>
<view:acl></view:acl>
<view:properties>
<cm:name>page.component-1-1.site~${siteId}~dashboard.xml</cm:name>
<sys:store-identifier>SpacesStore</sys:store-identifier>
<sys:locale>en_US_</sys:locale>
<cm:content>contentUrl=surf-config/content3.bin|mimetype=application/octet-stream|size=326|encoding=UTF-8|locale=en_US_</cm:content>
<sys:store-protocol>workspace</sys:store-protocol>
<cm:isIndexed>false</cm:isIndexed>
</view:properties>
</cm:content>
<cm:content view:childName="cm:page.component-2-1.site~${siteId}~dashboard.xml">
<view:aspects>
<sys:localized></sys:localized>
<sys:referenceable></sys:referenceable>
<cm:auditable></cm:auditable>
</view:aspects>
<view:acl></view:acl>
<view:properties>
<cm:name>page.component-2-1.site~${siteId}~dashboard.xml</cm:name>
<sys:store-identifier>SpacesStore</sys:store-identifier>
<sys:locale>en_US_</sys:locale>
<cm:content>contentUrl=surf-config/content4.bin|mimetype=application/octet-stream|size=270|encoding=UTF-8|locale=en_US_</cm:content>
<sys:store-protocol>workspace</sys:store-protocol>
<cm:isIndexed>false</cm:isIndexed>
</view:properties>
</cm:content>
<cm:content view:childName="cm:page.component-2-2.site~${siteId}~dashboard.xml">
<view:aspects>
<sys:localized></sys:localized>
<sys:referenceable></sys:referenceable>
<cm:auditable></cm:auditable>
</view:aspects>
<view:acl></view:acl>
<view:properties>
<cm:name>page.component-2-2.site~${siteId}~dashboard.xml</cm:name>
<sys:store-identifier>SpacesStore</sys:store-identifier>
<sys:locale>en_US_</sys:locale>
<cm:content>contentUrl=surf-config/content5.bin|mimetype=application/octet-stream|size=272|encoding=UTF-8|locale=en_US_</cm:content>
<sys:store-protocol>workspace</sys:store-protocol>
<cm:isIndexed>false</cm:isIndexed>
</view:properties>
</cm:content>
</cm:contains>
</view:associations>
</cm:folder>
<cm:folder view:childName="cm:pages">
<view:aspects>
<sys:localized></sys:localized>
<sys:referenceable></sys:referenceable>
<cm:auditable></cm:auditable>
</view:aspects>
<view:acl></view:acl>
<view:properties>
<cm:name>pages</cm:name>
<sys:store-identifier>SpacesStore</sys:store-identifier>
<sys:locale>en_US_</sys:locale>
<sys:store-protocol>workspace</sys:store-protocol>
<cm:isIndexed>false</cm:isIndexed>
</view:properties>
<view:associations>
<cm:contains>
<cm:folder view:childName="cm:site">
<view:aspects>
<sys:localized></sys:localized>
<sys:referenceable></sys:referenceable>
<cm:auditable></cm:auditable>
</view:aspects>
<view:acl></view:acl>
<view:properties>
<cm:name>site</cm:name>
<sys:store-identifier>SpacesStore</sys:store-identifier>
<sys:locale>en_US_</sys:locale>
<sys:store-protocol>workspace</sys:store-protocol>
<cm:isIndexed>false</cm:isIndexed>
</view:properties>
<view:associations>
<cm:contains>
<cm:folder view:childName="cm:${siteId}">
<view:aspects>
<sys:localized></sys:localized>
<sys:referenceable></sys:referenceable>
<cm:auditable></cm:auditable>
</view:aspects>
<view:acl></view:acl>
<view:properties>
<cm:name>${siteId}</cm:name>
<sys:store-identifier>SpacesStore</sys:store-identifier>
<sys:locale>en_US_</sys:locale>
<sys:store-protocol>workspace</sys:store-protocol>
<cm:isIndexed>false</cm:isIndexed>
</view:properties>
<view:associations>
<cm:contains>
<cm:content view:childName="cm:dashboard.xml">
<view:aspects>
<sys:localized></sys:localized>
<sys:referenceable></sys:referenceable>
<cm:auditable></cm:auditable>
</view:aspects>
<view:acl></view:acl>
<view:properties>
<cm:name>dashboard.xml</cm:name>
<sys:store-identifier>SpacesStore</sys:store-identifier>
<sys:locale>en_US_</sys:locale>
<cm:content>contentUrl=surf-config/content6.bin|mimetype=application/octet-stream|size=481|encoding=UTF-8|locale=en_US_</cm:content>
<sys:store-protocol>workspace</sys:store-protocol>
<cm:isIndexed>false</cm:isIndexed>
</view:properties>
</cm:content>
</cm:contains>
</view:associations>
</cm:folder>
</cm:contains>
</view:associations>
</cm:folder>
</cm:contains>
</view:associations>
</cm:folder>
</cm:contains>
</view:associations>
</cm:folder>
</view:view>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<component>
<guid>page.title.site~${siteId}~dashboard</guid>
<scope>page</scope>
<region-id>title</region-id>
<source-id>site/${siteId}/dashboard</source-id>
<url>/components/title/collaboration-title</url>
</component>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<component>
<guid>page.navigation.site~${siteId}~dashboard</guid>
<scope>page</scope>
<region-id>navigation</region-id>
<source-id>site/${siteId}/dashboard</source-id>
<url>/components/navigation/collaboration-navigation</url>
</component>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<component>
<guid>page.full-width-dashlet.site~${siteId}~dashboard</guid>
<scope>page</scope>
<region-id>full-width-dashlet</region-id>
<source-id>site/${siteId}/dashboard</source-id>
<url>/components/dashlets/dynamic-welcome</url>
<properties>
<dashboardType>site</dashboardType>
</properties>
</component>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<component>
<guid>page.component-1-1.site~${siteId}~dashboard</guid>
<scope>page</scope>
<region-id>component-1-1</region-id>
<source-id>site/${siteId}/dashboard</source-id>
<url>/components/dashlets/colleagues</url>
<properties>
<height>504</height>
</properties>
</component>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<component>
<guid>page.component-2-1.site~${siteId}~dashboard</guid>
<scope>page</scope>
<region-id>component-2-1</region-id>
<source-id>site/${siteId}/dashboard</source-id>
<url>/components/dashlets/docsummary</url>
</component>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<component>
<guid>page.component-2-2.site~${siteId}~dashboard</guid>
<scope>page</scope>
<region-id>component-2-2</region-id>
<source-id>site/${siteId}/dashboard</source-id>
<url>/components/dashlets/activityfeed</url>
</component>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<page>
<title>Records Management Site Dashboard</title>
<title-id>page.rmSiteDashboard.title</title-id>
<description>Records Management site's dashboard page</description>
<description-id>page.rmSiteDashboard.description</description-id>
<template-instance>dashboard-2-columns-wide-right</template-instance>
<authentication>user</authentication>
<properties>
<sitePages>[{"pageId":"documentlibrary"}, {"pageId":"rm-search"}]</sitePages>
<pageMetadata>{"documentlibrary":{"titleId":"page.rmDocumentLibrary.title", "descriptionId":"page.rmDocumentLibrary.description", "type":"dod5015"}}</pageMetadata>
</properties>
</page>

View File

@@ -50,4 +50,46 @@
<bean class="org.alfresco.rest.api.FileplanComponentChildrenRelation">
<property name="nodes" ref="rm.Nodes" />
</bean>
<!-- extended sites bean definition -->
<bean id="rm.sites" class="org.alfresco.rest.api.impl.RMSitesImpl" parent="sites">
<property name="dictionaryService" ref="DictionaryService" />
<property name="nodes" ref="Nodes" />
<property name="people" ref="people" />
<property name="nodeService" ref="NodeService" />
<property name="siteService" ref="SiteService" />
<property name="favouritesService" ref="FavouritesService" />
<property name="preferenceService" ref="PreferenceService" />
<property name="importerService" ref="importerComponent"/>
<property name="siteSurfConfig" ref="rm.siteSurfConfig" />
<property name="permissionService" ref="PermissionService" />
<property name="siteServiceImpl" ref="siteService" />
</bean>
<!--bean class="org.alfresco.util.BeanExtender">
<property name="beanName" value="sites" />
<property name="extendingBeanName" value="rm.sites" />
</bean-->
<bean id="rm.siteSurfConfig" class="org.alfresco.rest.api.impl.SiteSurfConfig">
<property name="configPath" value="alfresco/module/org_alfresco_module_rm/bootstrap/site"/>
</bean>
<bean id="rm.Sites" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>org.alfresco.rest.api.Sites</value>
</property>
<property name="target">
<ref bean="rm.sites" />
</property>
<property name="interceptorNames">
<list>
<idref bean="legacyExceptionInterceptor" />
</list>
</property>
</bean>
<bean class="org.alfresco.rest.api.sites.RMSiteEntityResource">
<property name="sites" ref="rm.Sites" />
</bean>
</beans>

View File

@@ -0,0 +1,35 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.api.impl;
import org.alfresco.rest.api.Sites;
public interface RMSites extends Sites
{
}

View File

@@ -0,0 +1,214 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.api.impl;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.site.SiteServiceException;
import org.alfresco.rest.api.model.Site;
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.cmr.site.SiteVisibility;
import org.alfresco.service.cmr.view.ImportPackageHandler;
import org.alfresco.service.cmr.view.ImporterBinding;
import org.alfresco.service.cmr.view.ImporterContentCache;
import org.alfresco.service.cmr.view.ImporterProgress;
import org.alfresco.service.cmr.view.Location;
import org.alfresco.service.namespace.QName;
/**
*
* @author Silviu Dinuta
* @since 2.6
*
*/
public class RMSitesImpl extends SitesImpl implements RMSites
{
private static final int SITE_MAXLEN_ID = 72;
private static final int SITE_MAXLEN_TITLE = 256;
private static final int SITE_MAXLEN_DESCRIPTION = 512;
private static final String SITE_ID_VALID_CHARS_PARTIAL_REGEX = "A-Za-z0-9\\-";
@Override
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 = siteService.createSite("rm-site-dashboard", site.getId(), site.getTitle(), site.getDescription(), site.getVisibility(), RecordsManagementModel.TYPE_RM_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();
// import default/fixed preset Share surf config
importSite(siteId, siteNodeRef);
// pre-create doclib
siteService.createContainer(siteId, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null);
String personId = AuthenticationUtil.getFullyAuthenticatedUser();
favouritesService.addFavourite(personId, siteNodeRef); // ignore result
return getSite(siteInfo, true);
}
private Site getSite(SiteInfo siteInfo, boolean includeRole)
{
// set the site id to the short name (to deal with case sensitivity issues with using the siteId from the url)
String siteId = siteInfo.getShortName();
String role = null;
if(includeRole)
{
role = getSiteRole(siteId);
}
return new Site(siteInfo, role);
}
private void importSite(final String siteId, final NodeRef siteNodeRef)
{
ImportPackageHandler acpHandler = new SiteImportPackageHandler(siteSurfConfig, siteId);
Location location = new Location(siteNodeRef);
ImporterBinding binding = new ImporterBinding()
{
@Override
public String getValue(String key)
{
if (key.equals("siteId"))
{
return siteId;
}
return null;
}
@Override
public UUID_BINDING getUUIDBinding()
{
return UUID_BINDING.CREATE_NEW;
}
@Override
public QName[] getExcludedClasses()
{
return null;
}
@Override
public boolean allowReferenceWithinTransaction()
{
return false;
}
@Override
public ImporterContentCache getImportConentCache()
{
return null;
}
};
importerService.importView(acpHandler, location, binding, (ImporterProgress)null);
}
private Site validateSite(Site site)
{
// site title - mandatory
String siteTitle = site.getTitle();
if ((siteTitle == null) || siteTitle.isEmpty())
{
throw new InvalidArgumentException("Site title is expected: "+siteTitle);
}
else if (siteTitle.length() > SITE_MAXLEN_TITLE)
{
throw new InvalidArgumentException("Site title exceeds max length of "+SITE_MAXLEN_TITLE+" characters");
}
SiteVisibility siteVisibility = site.getVisibility();
if (siteVisibility == null)
{
throw new InvalidArgumentException("Site visibility is expected: "+siteTitle+" (eg. PUBLIC, PRIVATE, MODERATED)");
}
String siteId = site.getId();
if (siteId == null)
{
// generate a site id from title (similar to Share create site dialog)
siteId = siteTitle.
trim(). // trim leading & trailing whitespace
replaceAll("[^"+SITE_ID_VALID_CHARS_PARTIAL_REGEX+" ]",""). // remove special characters (except spaces)
replaceAll(" +", " "). // collapse multiple spaces to single space
replace(" ","-"). // replaces spaces with dashs
toLowerCase(); // lowercase :-)
}
else
{
if (! siteId.matches("^["+SITE_ID_VALID_CHARS_PARTIAL_REGEX+"]+"))
{
throw new InvalidArgumentException("Invalid site id - should consist of alphanumeric/dash characters");
}
}
if (siteId.length() > SITE_MAXLEN_ID)
{
throw new InvalidArgumentException("Site id exceeds max length of "+SITE_MAXLEN_ID+ "characters");
}
site.setId(siteId);
String siteDescription = site.getDescription();
if (siteDescription == null)
{
// workaround: to avoid Share error (eg. in My Sites dashlet / freemarker template)
site.setDescription("");
}
if ((siteDescription != null) && (siteDescription.length() > SITE_MAXLEN_DESCRIPTION))
{
throw new InvalidArgumentException("Site description exceeds max length of "+SITE_MAXLEN_DESCRIPTION+" characters");
}
return site;
}
}

View File

@@ -0,0 +1,80 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.api.sites;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.rest.api.Sites;
import org.alfresco.rest.api.model.Site;
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
import org.alfresco.rest.framework.resource.EntityResource;
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Parameters;
/**
*
* @author Silviu Dinuta
* @since 2.6
*
*/
@EntityResource(name = "ig-sites", title = "IG Sites")
public class RMSiteEntityResource implements EntityResourceAction.Read<Site>, EntityResourceAction.ReadById<Site>,
EntityResourceAction.Delete, EntityResourceAction.Create<Site> {
private Sites sites;
public void setSites(Sites sites) {
this.sites = sites;
}
@Override
public List<Site> create(List<Site> entity, Parameters parameters) {
List<Site> result = new ArrayList<>(1);
result.add(sites.createSite(entity.get(0), parameters));
return result;
}
@Override
public void delete(String id, Parameters parameters) {
sites.deleteSite(id, parameters);
}
@Override
public Site readById(String id, Parameters parameters) throws EntityNotFoundException {
return sites.getSite(id);
}
@Override
public CollectionWithPagingInfo<Site> readAll(Parameters params) {
return sites.getSites(params);
}
}

View File

@@ -0,0 +1,37 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/**
* Package info that defines the Information Governance sites REST API
*
* @author Silviu Dinuta
* @since 2.6
*/
@WebApi(name="ig", scope=Api.SCOPE.PUBLIC, version=1)
package org.alfresco.rest.api.sites;
import org.alfresco.rest.framework.Api;
import org.alfresco.rest.framework.WebApi;