From 1040c897413d0811dc742d7834cc314b70f2104e Mon Sep 17 00:00:00 2001 From: Silviu Dinuta Date: Thu, 20 Oct 2016 03:27:52 +0300 Subject: [PATCH] RM-4199: changes to include compliance in body create type, also changed the delete part to only delete rm site --- .../rm-public-rest-context.xml | 2 +- .../org/alfresco/rm/rest/api/RMSites.java | 37 +++++++++ .../rm/rest/api/impl/RMSitesImpl.java | 29 ++++++- .../alfresco/rm/rest/api/model/RMSite.java | 77 +++++++++++++++++++ .../rm/rest/api/model/RMSiteCompliance.java | 43 +++++++++++ .../rest/api/sites/RMSiteEntityResource.java | 19 ++--- 6 files changed, 194 insertions(+), 13 deletions(-) create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/RMSites.java create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/RMSite.java create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/RMSiteCompliance.java diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml index 34b6642daa..48c4b9acc0 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml @@ -62,7 +62,7 @@ - org.alfresco.rest.api.Sites + org.alfresco.rm.rest.api.RMSites diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/RMSites.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/RMSites.java new file mode 100644 index 0000000000..ec231e73be --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/RMSites.java @@ -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 . + * #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); +} diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/RMSitesImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/RMSitesImpl.java index 338d20d161..bd4bc2b140 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/RMSitesImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/RMSitesImpl.java @@ -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; + } + } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/RMSite.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/RMSite.java new file mode 100644 index 0000000000..8e2ed2a847 --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/RMSite.java @@ -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 . + * #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 +"]"; + } + +} diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/RMSiteCompliance.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/RMSiteCompliance.java new file mode 100644 index 0000000000..9cbebdcf31 --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/model/RMSiteCompliance.java @@ -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 . + * #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 +} diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/sites/RMSiteEntityResource.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/sites/RMSiteEntityResource.java index e5bd1342f8..238771170d 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/sites/RMSiteEntityResource.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/sites/RMSiteEntityResource.java @@ -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 +public class RMSiteEntityResource implements EntityResourceAction.Delete, EntityResourceAction.Create { - 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 create(List entity, Parameters parameters) { - List result = new ArrayList<>(1); - result.add(sites.createSite(entity.get(0), parameters)); + public List create(List entity, Parameters parameters) { + List 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); } }