RM-4199: changed package structure, removed content2.bin since we don't

use welcome component for rm site, also added some comments and
simplified the validation of the site since we don't need to ad site id
and site visibility for rm site, given that site id is always rm and
site visibility always PUBLIC
This commit is contained in:
Silviu Dinuta
2016-10-19 17:08:03 +03:00
parent db36b0c43f
commit 3a7bda1aed
16 changed files with 63 additions and 155 deletions

View File

@@ -64,22 +64,6 @@
<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>

View File

@@ -1,12 +0,0 @@
<?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

@@ -23,7 +23,7 @@
</property>
</bean>
<bean id="rm.nodes" class="org.alfresco.rest.api.impl.RMNodesImpl" parent="nodes" init-method="init">
<bean id="rm.nodes" class="org.alfresco.rm.rest.api.impl.RMNodesImpl" parent="nodes" init-method="init">
<property name="quickShareLinks" ref="rm.QuickShareLinks"/>
<property name="filePlanService" ref="FilePlanService"/>
<property name="recordsManagementServiceRegistry" ref="RecordsManagementServiceRegistry"/>
@@ -43,34 +43,19 @@
</property>
</bean>
<bean class="org.alfresco.rest.api.FileplanComponentsEntityResource">
<bean class="org.alfresco.rm.rest.api.nodes.FileplanComponentsEntityResource">
<property name="nodes" ref="rm.Nodes" />
</bean>
<bean class="org.alfresco.rest.api.FileplanComponentChildrenRelation">
<bean class="org.alfresco.rm.rest.api.nodes.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"/>
<bean id="rm.sites" class="org.alfresco.rm.rest.api.impl.RMSitesImpl" parent="sites">
<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>
@@ -89,7 +74,7 @@
</property>
</bean>
<bean class="org.alfresco.rest.api.sites.RMSiteEntityResource">
<bean class="org.alfresco.rm.rest.api.sites.RMSiteEntityResource">
<property name="sites" ref="rm.Sites" />
</bean>
</beans>

View File

@@ -1,35 +0,0 @@
/*
* #%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

@@ -24,7 +24,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.api.impl;
package org.alfresco.rm.rest.api.impl;
import org.alfresco.rest.api.Nodes;

View File

@@ -25,7 +25,7 @@
* #L%
*/
package org.alfresco.rest.api.impl;
package org.alfresco.rm.rest.api.impl;
import java.security.InvalidParameterException;
import java.util.HashMap;
@@ -40,15 +40,16 @@ import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.model.Repository;
import org.alfresco.rest.api.model.CategoryNode;
import org.alfresco.rest.api.model.FileplanComponentNode;
import org.alfresco.rest.api.impl.NodesImpl;
import org.alfresco.rest.api.model.Node;
import org.alfresco.rest.api.model.RecordFolderNode;
import org.alfresco.rest.api.model.RecordNode;
import org.alfresco.rest.api.model.UserInfo;
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.rm.rest.api.model.CategoryNode;
import org.alfresco.rm.rest.api.model.FileplanComponentNode;
import org.alfresco.rm.rest.api.model.RecordFolderNode;
import org.alfresco.rm.rest.api.model.RecordNode;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;

View File

@@ -25,12 +25,14 @@
* #L%
*/
package org.alfresco.rest.api.impl;
package org.alfresco.rm.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.impl.SiteImportPackageHandler;
import org.alfresco.rest.api.impl.SitesImpl;
import org.alfresco.rest.api.model.Site;
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
@@ -47,17 +49,17 @@ import org.alfresco.service.cmr.view.Location;
import org.alfresco.service.namespace.QName;
/**
* Centralizes access to site services.
*
* @author Silviu Dinuta
* @since 2.6
*
*/
public class RMSitesImpl extends SitesImpl implements RMSites
public class RMSitesImpl extends SitesImpl
{
private static final int SITE_MAXLEN_ID = 72;
private static final String RM_SITE_ID = "rm";
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) {
@@ -67,7 +69,7 @@ public class RMSitesImpl extends SitesImpl implements RMSites
SiteInfo siteInfo = null;
try
{
siteInfo = siteService.createSite("rm-site-dashboard", site.getId(), site.getTitle(), site.getDescription(), site.getVisibility(), RecordsManagementModel.TYPE_RM_SITE);
siteInfo = siteService.createSite("rm-site-dashboard", RM_SITE_ID, site.getTitle(), site.getDescription(), SiteVisibility.PUBLIC, RecordsManagementModel.TYPE_RM_SITE);
}
catch (SiteServiceException sse)
{
@@ -96,6 +98,13 @@ public class RMSitesImpl extends SitesImpl implements RMSites
return getSite(siteInfo, true);
}
/**
* Copied from SitesImpl since we didn't had access to it.
*
* @param siteInfo
* @param includeRole
* @return
*/
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)
@@ -108,6 +117,12 @@ public class RMSitesImpl extends SitesImpl implements RMSites
return new Site(siteInfo, role);
}
/**
* Copied from SitesImpl since we didn't had access to it
*
* @param siteId
* @param siteNodeRef
*/
private void importSite(final String siteId, final NodeRef siteNodeRef)
{
ImportPackageHandler acpHandler = new SiteImportPackageHandler(siteSurfConfig, siteId);
@@ -151,6 +166,14 @@ public class RMSitesImpl extends SitesImpl implements RMSites
importerService.importView(acpHandler, location, binding, (ImporterProgress)null);
}
/**
* This method is copied from SitesImpl since we could not access it since it is private.
*
* Even if the method it will be protected in core, we still need to override since we don't need to check if the visibility is set since for RM site it is always PUBLIC.
* We also don't need to generate the id from title, or to check the id, since the id is always rm.
* @param site
* @return
*/
private Site validateSite(Site site)
{
// site title - mandatory
@@ -164,38 +187,6 @@ public class RMSitesImpl extends SitesImpl implements RMSites
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)

View File

@@ -24,11 +24,13 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.api.model;
package org.alfresco.rm.rest.api.model;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.rest.api.model.Node;
import org.alfresco.rest.api.model.UserInfo;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;

View File

@@ -25,18 +25,20 @@
* #L%
*/
package org.alfresco.rest.api.model;
package org.alfresco.rm.rest.api.model;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.rest.api.model.Node;
import org.alfresco.rest.api.model.UserInfo;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
/**
* Concrete class carrying general information for a fileplan component node
*
*
* @author Ana Bozianu
* @since 2.6
*/
@@ -71,7 +73,7 @@ public class FileplanComponentNode extends Node
this.properties =node.getProperties();
this.allowableOperations = node.getAllowableOperations();
this.contentInfo = node.getContent();
this.description = node.description;
this.description = node.getDescription();
defineType();
}

View File

@@ -24,11 +24,13 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.api.model;
package org.alfresco.rm.rest.api.model;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.rest.api.model.Node;
import org.alfresco.rest.api.model.UserInfo;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;

View File

@@ -24,11 +24,13 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.api.model;
package org.alfresco.rm.rest.api.model;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.rest.api.model.Node;
import org.alfresco.rest.api.model.UserInfo;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;

View File

@@ -24,11 +24,12 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.api;
package org.alfresco.rm.rest.api.nodes;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.rest.api.Nodes;
import org.alfresco.rest.api.model.Node;
import org.alfresco.rest.framework.resource.RelationshipResource;
import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;

View File

@@ -25,7 +25,7 @@
* #L%
*/
package org.alfresco.rest.api;
package org.alfresco.rm.rest.api.nodes;
import org.alfresco.rest.api.Nodes;
import org.alfresco.rest.api.model.Node;

View File

@@ -32,6 +32,6 @@
* @since 2.6
*/
@WebApi(name="ig", scope=Api.SCOPE.PUBLIC, version=1)
package org.alfresco.rest.api;
package org.alfresco.rm.rest.api.nodes;
import org.alfresco.rest.framework.Api;
import org.alfresco.rest.framework.WebApi;

View File

@@ -25,17 +25,15 @@
* #L%
*/
package org.alfresco.rest.api.sites;
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.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;
/**
@@ -44,10 +42,9 @@ import org.alfresco.rest.framework.resource.parameters.Parameters;
* @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> {
@EntityResource(name = "sites", title = "IG Sites")
public class RMSiteEntityResource implements EntityResourceAction.Delete, EntityResourceAction.Create<Site>
{
private Sites sites;
public void setSites(Sites sites) {
@@ -64,17 +61,5 @@ public class RMSiteEntityResource implements EntityResourceAction.Read<Site>, En
@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

@@ -32,6 +32,6 @@
* @since 2.6
*/
@WebApi(name="ig", scope=Api.SCOPE.PUBLIC, version=1)
package org.alfresco.rest.api.sites;
package org.alfresco.rm.rest.api.sites;
import org.alfresco.rest.framework.Api;
import org.alfresco.rest.framework.WebApi;