. Addition of Email Templates folder (in Data Dictionary) to Bootstrap spaces.xml

. New patch to apply Email Templates folder to older schemas

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2515 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-03-03 17:39:32 +00:00
parent e667abaac6
commit d8b2e56aa3
9 changed files with 369 additions and 69 deletions

View File

@@ -2,75 +2,82 @@
xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0"
xmlns:app="http://www.alfresco.org/model/application/1.0"> xmlns:app="http://www.alfresco.org/model/application/1.0">
<!-- NOTE: all replaced properties referenced from repository.properties file must also be <!-- NOTE: all replaced properties referenced from repository.properties file must also be
mapped in the bootstrap-context.xml spacesBootstrap/configuration section --> mapped in the bootstrap-context.xml spacesBootstrap/configuration section -->
<cm:folder view:childName="${spaces.company_home.childname}"> <cm:folder view:childName="${spaces.company_home.childname}">
<view:acl view:inherit="false"> <view:acl view:inherit="false">
<view:ace view:access="ALLOWED"> <view:ace view:access="ALLOWED">
<view:authority>GROUP_EVERYONE</view:authority> <view:authority>GROUP_EVERYONE</view:authority>
<view:permission>Consumer</view:permission> <view:permission>Consumer</view:permission>
</view:ace> </view:ace>
</view:acl> </view:acl>
<app:uifacets /> <app:uifacets />
<cm:name>${spaces.company_home.name}</cm:name> <cm:name>${spaces.company_home.name}</cm:name>
<app:icon>space-icon-default</app:icon> <app:icon>space-icon-default</app:icon>
<cm:title>${spaces.company_home.name}</cm:title> <cm:title>${spaces.company_home.name}</cm:title>
<cm:description>${spaces.company_home.description}</cm:description> <cm:description>${spaces.company_home.description}</cm:description>
<cm:contains> <cm:contains>
<cm:folder view:childName="${spaces.dictionary.childname}"> <cm:folder view:childName="${spaces.dictionary.childname}">
<app:uifacets /> <app:uifacets />
<cm:name>${spaces.dictionary.name}</cm:name> <cm:name>${spaces.dictionary.name}</cm:name>
<app:icon>space-icon-default</app:icon> <app:icon>space-icon-default</app:icon>
<cm:title>${spaces.dictionary.name}</cm:title> <cm:title>${spaces.dictionary.name}</cm:title>
<cm:description>${spaces.dictionary.description}</cm:description> <cm:description>${spaces.dictionary.description}</cm:description>
<cm:contains> <cm:contains>
<cm:folder view:childName="${spaces.templates.childname}"> <cm:folder view:childName="${spaces.templates.childname}">
<app:uifacets /> <app:uifacets />
<cm:name>${spaces.templates.name}</cm:name> <cm:name>${spaces.templates.name}</cm:name>
<app:icon>space-icon-default</app:icon> <app:icon>space-icon-default</app:icon>
<cm:title>${spaces.templates.name}</cm:title> <cm:title>${spaces.templates.name}</cm:title>
<cm:description>${spaces.templates.description}</cm:description> <cm:description>${spaces.templates.description}</cm:description>
</cm:folder> </cm:folder>
<cm:folder view:childName="${spaces.templates.content.childname}"> <cm:folder view:childName="${spaces.templates.content.childname}">
<app:uifacets /> <app:uifacets />
<cm:name>${spaces.templates.content.name}</cm:name> <cm:name>${spaces.templates.content.name}</cm:name>
<app:icon>space-icon-default</app:icon> <app:icon>space-icon-default</app:icon>
<cm:title>${spaces.templates.content.name}</cm:title> <cm:title>${spaces.templates.content.name}</cm:title>
<cm:description>${spaces.templates.content.description}</cm:description> <cm:description>${spaces.templates.content.description}</cm:description>
</cm:folder> </cm:folder>
<cm:folder view:childName="${spaces.savedsearches.childname}"> <cm:folder view:childName="${spaces.templates.email.childname}">
<view:acl view:inherit="false"> <app:uifacets />
<view:ace view:access="ALLOWED"> <cm:name>${spaces.templates.email.name}</cm:name>
<view:authority>GROUP_EVERYONE</view:authority> <app:icon>space-icon-default</app:icon>
<view:permission>Contributor</view:permission> <cm:title>${spaces.templates.email.name}</cm:title>
</view:ace> <cm:description>${spaces.templates.email.description}</cm:description>
</view:acl> </cm:folder>
<app:uifacets /> <cm:folder view:childName="${spaces.savedsearches.childname}">
<cm:name>${spaces.savedsearches.name}</cm:name> <view:acl view:inherit="false">
<app:icon>space-icon-default</app:icon> <view:ace view:access="ALLOWED">
<cm:title>${spaces.savedsearches.name}</cm:title>
<cm:description>${spaces.savedsearches.description}</cm:description>
</cm:folder>
</cm:contains>
</cm:folder>
<cm:folder view:childName="${spaces.guest_home.childname}">
<view:acl view:inherit="false">
<view:ace view:access="ALLOWED">
<view:authority>guest</view:authority>
<view:permission>Consumer</view:permission>
</view:ace>
<view:ace view:access="ALLOWED">
<view:authority>GROUP_EVERYONE</view:authority> <view:authority>GROUP_EVERYONE</view:authority>
<view:permission>Consumer</view:permission> <view:permission>Contributor</view:permission>
</view:ace> </view:ace>
</view:acl> </view:acl>
<app:uifacets /> <app:uifacets />
<cm:name>${spaces.guest_home.name}</cm:name> <cm:name>${spaces.savedsearches.name}</cm:name>
<app:icon>space-icon-default</app:icon> <app:icon>space-icon-default</app:icon>
<cm:title>${spaces.guest_home.name}</cm:title> <cm:title>${spaces.savedsearches.name}</cm:title>
<cm:description>${spaces.guest_home.description}</cm:description> <cm:description>${spaces.savedsearches.description}</cm:description>
</cm:folder>
</cm:contains>
</cm:folder> </cm:folder>
</cm:contains> <cm:folder view:childName="${spaces.guest_home.childname}">
</cm:folder> <view:acl view:inherit="false">
<view:ace view:access="ALLOWED">
<view:authority>guest</view:authority>
<view:permission>Consumer</view:permission>
</view:ace>
<view:ace view:access="ALLOWED">
<view:authority>GROUP_EVERYONE</view:authority>
<view:permission>Consumer</view:permission>
</view:ace>
</view:acl>
<app:uifacets />
<cm:name>${spaces.guest_home.name}</cm:name>
<app:icon>space-icon-default</app:icon>
<cm:title>${spaces.guest_home.name}</cm:title>
<cm:description>${spaces.guest_home.description}</cm:description>
</cm:folder>
</cm:contains>
</cm:folder>
</view:view> </view:view>

View File

@@ -741,6 +741,7 @@
<prop key="spaces.dictionary.childname">${spaces.dictionary.childname}</prop> <prop key="spaces.dictionary.childname">${spaces.dictionary.childname}</prop>
<prop key="spaces.templates.childname">${spaces.templates.childname}</prop> <prop key="spaces.templates.childname">${spaces.templates.childname}</prop>
<prop key="spaces.templates.content.childname">${spaces.templates.content.childname}</prop> <prop key="spaces.templates.content.childname">${spaces.templates.content.childname}</prop>
<prop key="spaces.templates.email.childname">${spaces.templates.email.childname}</prop>
<prop key="spaces.savedsearches.childname">${spaces.savedsearches.childname}</prop> <prop key="spaces.savedsearches.childname">${spaces.savedsearches.childname}</prop>
</props> </props>
</property> </property>

View File

@@ -12,6 +12,9 @@ spaces.templates.description=Space templates
spaces.templates.content.name=Presentation Templates spaces.templates.content.name=Presentation Templates
spaces.templates.content.description=Presentation templates spaces.templates.content.description=Presentation templates
spaces.templates.email.name=Email Templates
spaces.templates.email.description=Email templates
spaces.savedsearches.name=Saved Searches spaces.savedsearches.name=Saved Searches
spaces.savedsearches.description=Saved Searches spaces.savedsearches.description=Saved Searches

View File

@@ -43,3 +43,7 @@ patch.contentPermission.result=Created the following permission reference names:
patch.forumsIcons.description=Updates forums icon references patch.forumsIcons.description=Updates forums icon references
patch.forumsIcons.result=Updated {0} icon references patch.forumsIcons.result=Updated {0} icon references
patch.emailTemplatesFolder.description=Ensures the existence of the 'Email Templates' folder.
patch.emailTemplatesFolder.result.exists=The email templates folder already exists: {0}
patch.emailTemplatesFolder.result.created=The email templates folder was successfully created: {0}

View File

@@ -19,6 +19,7 @@
<value>/${spaces.company_home.childname}/${spaces.dictionary.childname}</value> <value>/${spaces.company_home.childname}/${spaces.dictionary.childname}</value>
<value>/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.childname}</value> <value>/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.childname}</value>
<value>/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.content.childname}</value> <value>/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.content.childname}</value>
<value>/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.email.childname}</value>
</list> </list>
</property> </property>
</bean> </bean>

View File

@@ -296,5 +296,16 @@
<ref bean="searchService" /> <ref bean="searchService" />
</property> </property>
</bean> </bean>
<bean id="patch.emailTemplatesFolder" class="org.alfresco.repo.admin.patch.impl.EmailTemplatesFolderPatch" parent="patch.savedSearches.Base" >
<property name="id"><value>patch.emailTemplatesFolder</value></property>
<property name="description"><value>patch.emailTemplatesFolder.description</value></property>
<property name="fixesFromSchema"><value>0</value></property>
<property name="fixesToSchema"><value>8</value></property>
<property name="targetSchema"><value>9</value></property>
<!-- helper beans for execution -->
<property name="messageSource">
<ref bean="bootstrapSpacesMessageSource" />
</property>
</bean>
</beans> </beans>

View File

@@ -88,6 +88,7 @@ spaces.guest_home.childname=app:guest_home
spaces.dictionary.childname=app:dictionary spaces.dictionary.childname=app:dictionary
spaces.templates.childname=app:space_templates spaces.templates.childname=app:space_templates
spaces.templates.content.childname=app:content_templates spaces.templates.content.childname=app:content_templates
spaces.templates.email.childname=app:email_templates
spaces.savedsearches.childname=app:saved_searches spaces.savedsearches.childname=app:saved_searches
# Folders for storing people # Folders for storing people

View File

@@ -15,4 +15,4 @@ version.edition=Community Network
# Schema number # Schema number
version.schema=8 version.schema=9

View File

@@ -0,0 +1,272 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.admin.patch.impl;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.admin.patch.AbstractPatch;
import org.alfresco.repo.importer.ImporterBootstrap;
import org.alfresco.service.cmr.admin.PatchException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.springframework.context.MessageSource;
/**
* Ensures that the <b>email templates</b> folder is present.
* <p>
* This uses the bootstrap importer to get the paths to look for. If not present,
* the required structures are created.
* <p>
* This class should be replaced with a more generic <code>ImporterPatch</code>
* that can do conditional importing into given locations.
* <p>
* JIRA: {@link http://www.alfresco.org/jira/browse/AR-342 AR-342}
*
* @author Kevin Roast
*/
public class EmailTemplatesFolderPatch extends AbstractPatch
{
private static final String MSG_EXISTS = "patch.emailTemplatesFolder.result.exists";
private static final String MSG_CREATED = "patch.emailTemplatesFolder.result.created";
public static final String PROPERTY_COMPANY_HOME_CHILDNAME = "spaces.company_home.childname";
public static final String PROPERTY_DICTIONARY_CHILDNAME = "spaces.dictionary.childname";
public static final String PROPERTY_EMAIL_TEMPLATES_FOLDER_CHILDNAME = "spaces.templates.email.childname";
private static final String PROPERTY_EMAIL_TEMPLATES_FOLDER_NAME = "spaces.templates.email.name";
private static final String PROPERTY_EMAIL_TEMPLATES_FOLDER_DESCRIPTION = "spaces.templates.email.description";
private static final String PROPERTY_ICON = "space-icon-default";
private ImporterBootstrap importerBootstrap;
private NamespaceService namespaceService;
private SearchService searchService;
private NodeService nodeService;
private MessageSource messageSource;
protected NodeRef dictionaryNodeRef;
protected Properties configuration;
protected NodeRef emailTemplatesFolderNodeRef;
public void setImporterBootstrap(ImporterBootstrap importerBootstrap)
{
this.importerBootstrap = importerBootstrap;
}
public void setNamespaceService(NamespaceService namespaceService)
{
this.namespaceService = namespaceService;
}
public void setSearchService(SearchService searchService)
{
this.searchService = searchService;
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setMessageSource(MessageSource messageSource)
{
this.messageSource = messageSource;
}
/**
* Ensure that required common properties have been set
*/
protected void checkCommonProperties() throws Exception
{
if (importerBootstrap == null)
{
throw new PatchException("'importerBootstrap' property has not been set");
}
else if (namespaceService == null)
{
throw new PatchException("'namespaceService' property has not been set");
}
else if (searchService == null)
{
throw new PatchException("'searchService' property has not been set");
}
else if (nodeService == null)
{
throw new PatchException("'nodeService' property has not been set");
}
}
/**
* Extracts pertinent references and properties that are common to execution
* of this and derived patches.
*/
protected void setUp() throws Exception
{
// get the node store that we must work against
StoreRef storeRef = importerBootstrap.getStoreRef();
if (storeRef == null)
{
throw new PatchException("Bootstrap store has not been set");
}
NodeRef storeRootNodeRef = nodeService.getRootNode(storeRef);
this.configuration = importerBootstrap.getConfiguration();
// get the association names that form the path
String companyHomeChildName = configuration.getProperty(PROPERTY_COMPANY_HOME_CHILDNAME);
if (companyHomeChildName == null || companyHomeChildName.length() == 0)
{
throw new PatchException("Bootstrap property '" + PROPERTY_COMPANY_HOME_CHILDNAME + "' is not present");
}
String dictionaryChildName = configuration.getProperty(PROPERTY_DICTIONARY_CHILDNAME);
if (dictionaryChildName == null || dictionaryChildName.length() == 0)
{
throw new PatchException("Bootstrap property '" + PROPERTY_DICTIONARY_CHILDNAME + "' is not present");
}
String emailTemplatesChildName = configuration.getProperty(PROPERTY_EMAIL_TEMPLATES_FOLDER_CHILDNAME);
if (emailTemplatesChildName == null || emailTemplatesChildName.length() == 0)
{
throw new PatchException("Bootstrap property '" + PROPERTY_EMAIL_TEMPLATES_FOLDER_CHILDNAME + "' is not present");
}
// build the search string to get the dictionary node
StringBuilder sb = new StringBuilder(128);
sb.append("/").append(companyHomeChildName)
.append("/").append(dictionaryChildName);
String xpath = sb.toString();
// get the dictionary node
List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef, xpath, null, namespaceService, false);
if (nodeRefs.size() == 0)
{
throw new PatchException("XPath didn't return any results: \n" +
" root: " + storeRootNodeRef + "\n" +
" xpath: " + xpath);
}
else if (nodeRefs.size() > 1)
{
throw new PatchException("XPath returned too many results: \n" +
" root: " + storeRootNodeRef + "\n" +
" xpath: " + xpath + "\n" +
" results: " + nodeRefs);
}
this.dictionaryNodeRef = nodeRefs.get(0);
// Now we have the optional part. Check for the existence of the email templates folder
xpath = emailTemplatesChildName;
nodeRefs = searchService.selectNodes(dictionaryNodeRef, xpath, null, namespaceService, false);
if (nodeRefs.size() > 1)
{
throw new PatchException("XPath returned too many results: \n" +
" dictionary node: " + dictionaryNodeRef + "\n" +
" xpath: " + xpath + "\n" +
" results: " + nodeRefs);
}
else if (nodeRefs.size() == 0)
{
// the node does not exist
this.emailTemplatesFolderNodeRef = null;
}
else
{
// we have the email templates folder noderef
this.emailTemplatesFolderNodeRef = nodeRefs.get(0);
}
}
@Override
protected String applyInternal() throws Exception
{
// common properties must be set before we can continue
checkCommonProperties();
if (messageSource == null)
{
throw new PatchException("'messageSource' property has not been set");
}
setUp();
// create the folder if needed - output a message to describe the result
String msg = null;
if (emailTemplatesFolderNodeRef == null)
{
createFolder();
msg = I18NUtil.getMessage(MSG_CREATED, emailTemplatesFolderNodeRef);
}
else
{
msg = I18NUtil.getMessage(MSG_EXISTS, emailTemplatesFolderNodeRef);
}
return msg;
}
private void createFolder()
{
// get required properties
String emailTemplatesChildName = configuration.getProperty(PROPERTY_EMAIL_TEMPLATES_FOLDER_CHILDNAME);
if (emailTemplatesChildName == null)
{
throw new PatchException("Bootstrap property '" + PROPERTY_EMAIL_TEMPLATES_FOLDER_CHILDNAME + "' is not present");
}
String emailTemplatesName = messageSource.getMessage(
PROPERTY_EMAIL_TEMPLATES_FOLDER_NAME,
null,
I18NUtil.getLocale());
if (emailTemplatesName == null || emailTemplatesName.length() == 0)
{
throw new PatchException("Bootstrap property '" + PROPERTY_EMAIL_TEMPLATES_FOLDER_NAME + "' is not present");
}
String emailTemplatesDescription = messageSource.getMessage(
PROPERTY_EMAIL_TEMPLATES_FOLDER_DESCRIPTION,
null,
I18NUtil.getLocale());
if (emailTemplatesDescription == null || emailTemplatesDescription.length() == 0)
{
throw new PatchException("Bootstrap property '" + PROPERTY_EMAIL_TEMPLATES_FOLDER_DESCRIPTION + "' is not present");
}
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(7);
properties.put(ContentModel.PROP_NAME, emailTemplatesName);
properties.put(ContentModel.PROP_TITLE, emailTemplatesName);
properties.put(ContentModel.PROP_DESCRIPTION, emailTemplatesDescription);
properties.put(ContentModel.PROP_ICON, PROPERTY_ICON);
// create the node
ChildAssociationRef childAssocRef = nodeService.createNode(
dictionaryNodeRef,
ContentModel.ASSOC_CONTAINS,
QName.resolveToQName(namespaceService, emailTemplatesChildName),
ContentModel.TYPE_FOLDER,
properties);
emailTemplatesFolderNodeRef = childAssocRef.getChildRef();
// add the required aspects
nodeService.addAspect(emailTemplatesFolderNodeRef, ContentModel.ASPECT_UIFACETS, null);
}
}