mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-4199: changes to include compliance in body create type, also changed
the delete part to only delete rm site
This commit is contained in:
@@ -62,7 +62,7 @@
|
||||
|
||||
<bean id="rm.Sites" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="proxyInterfaces">
|
||||
<value>org.alfresco.rest.api.Sites</value>
|
||||
<value>org.alfresco.rm.rest.api.RMSites</value>
|
||||
</property>
|
||||
<property name="target">
|
||||
<ref bean="rm.sites" />
|
||||
|
@@ -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 org.alfresco.rm.rest.api;
|
||||
|
||||
import org.alfresco.rest.api.Sites;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.model.RMSite;
|
||||
|
||||
public interface RMSites extends Sites
|
||||
{
|
||||
RMSite createRMSite(RMSite site, Parameters parameters);
|
||||
}
|
@@ -28,6 +28,7 @@
|
||||
package org.alfresco.rm.rest.api.impl;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.site.SiteServiceException;
|
||||
@@ -37,6 +38,9 @@ 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.rm.rest.api.RMSites;
|
||||
import org.alfresco.rm.rest.api.model.RMSite;
|
||||
import org.alfresco.rm.rest.api.model.RMSiteCompliance;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
@@ -55,21 +59,31 @@ import org.alfresco.service.namespace.QName;
|
||||
* @since 2.6
|
||||
*
|
||||
*/
|
||||
public class RMSitesImpl extends SitesImpl
|
||||
public class RMSitesImpl extends SitesImpl implements RMSites
|
||||
{
|
||||
private static final String RM_SITE_ID = "rm";
|
||||
private static final int SITE_MAXLEN_TITLE = 256;
|
||||
private static final int SITE_MAXLEN_DESCRIPTION = 512;
|
||||
|
||||
public RMSite createRMSite(RMSite rmSite, Parameters parameters)
|
||||
{
|
||||
RMSiteCompliance compliance = rmSite.getCompliance();
|
||||
if(compliance == null)
|
||||
{
|
||||
compliance = RMSiteCompliance.STANDARD;
|
||||
}
|
||||
Site site = createSite(rmSite, parameters);
|
||||
return new RMSite(site, compliance);
|
||||
}
|
||||
|
||||
@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", RM_SITE_ID, site.getTitle(), site.getDescription(), SiteVisibility.PUBLIC, RecordsManagementModel.TYPE_RM_SITE);
|
||||
siteInfo = siteService.createSite("rm-site-dashboard", RM_SITE_ID, site.getTitle(), site.getDescription(), SiteVisibility.PUBLIC, getRMSiteType((RMSite) site));
|
||||
}
|
||||
catch (SiteServiceException sse)
|
||||
{
|
||||
@@ -202,4 +216,13 @@ public class RMSitesImpl extends SitesImpl
|
||||
|
||||
return site;
|
||||
}
|
||||
|
||||
private QName getRMSiteType(RMSite rmSite) {
|
||||
RMSiteCompliance compliance = rmSite.getCompliance();
|
||||
if (compliance == null || compliance.equals(RMSiteCompliance.STANDARD)) {
|
||||
return RecordsManagementModel.TYPE_RM_SITE;
|
||||
} else {
|
||||
return DOD5015Model.TYPE_DOD_5015_SITE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* #%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.rm.rest.api.model;
|
||||
|
||||
import org.alfresco.rest.api.model.Site;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Silviu Dinuta
|
||||
*
|
||||
*/
|
||||
public class RMSite extends Site
|
||||
{
|
||||
private RMSiteCompliance compliance;
|
||||
|
||||
public RMSiteCompliance getCompliance() {
|
||||
return compliance;
|
||||
}
|
||||
|
||||
public void setCompliance(RMSiteCompliance compliance) {
|
||||
this.compliance = compliance;
|
||||
}
|
||||
|
||||
public RMSite() {
|
||||
super();
|
||||
}
|
||||
|
||||
public RMSite(Site site, RMSiteCompliance compliance)
|
||||
{
|
||||
this.id = site.getId();
|
||||
this.guid = site.getGuid();
|
||||
this.title = site.getTitle();
|
||||
this.description = site.getDescription();
|
||||
this.visibility = site.getVisibility();
|
||||
this.role = getRole();
|
||||
this.compliance = compliance;
|
||||
}
|
||||
|
||||
public RMSite(SiteInfo siteInfo, String role, RMSiteCompliance compliance) {
|
||||
super(siteInfo, role);
|
||||
this.compliance = compliance;
|
||||
}
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "RMSite [id=" + id + ", guid=" + guid + ", title="
|
||||
+ title + ", description=" + description + ", visibility="
|
||||
+ visibility + ", role=" + role + ", compliance="+ compliance +"]";
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* #%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.rm.rest.api.model;
|
||||
|
||||
import org.alfresco.api.AlfrescoPublicApi;
|
||||
|
||||
/**
|
||||
* Enumeration representing rm site compliance
|
||||
*
|
||||
* @author Silviu Dinuta
|
||||
*
|
||||
*/
|
||||
@AlfrescoPublicApi
|
||||
public enum RMSiteCompliance
|
||||
{
|
||||
STANDARD,
|
||||
DOD5015
|
||||
}
|
@@ -30,11 +30,11 @@ package org.alfresco.rm.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.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.RMSites;
|
||||
import org.alfresco.rm.rest.api.model.RMSite;
|
||||
|
||||
/**
|
||||
* RM Site operations
|
||||
@@ -44,23 +44,24 @@ import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
*
|
||||
*/
|
||||
@EntityResource(name = "sites", title = "IG Sites")
|
||||
public class RMSiteEntityResource implements EntityResourceAction.Delete, EntityResourceAction.Create<Site>
|
||||
public class RMSiteEntityResource implements EntityResourceAction.Delete, EntityResourceAction.Create<RMSite>
|
||||
{
|
||||
private Sites sites;
|
||||
private static final String RM_SITE_ID = "rm";
|
||||
private RMSites sites;
|
||||
|
||||
public void setSites(Sites sites) {
|
||||
public void setSites(RMSites 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));
|
||||
public List<RMSite> create(List<RMSite> entity, Parameters parameters) {
|
||||
List<RMSite> result = new ArrayList<>(1);
|
||||
result.add(sites.createRMSite(entity.get(0), parameters));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String id, Parameters parameters) {
|
||||
sites.deleteSite(id, parameters);
|
||||
sites.deleteSite(RM_SITE_ID, parameters);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user