diff --git a/config/alfresco/import-export-context.xml b/config/alfresco/import-export-context.xml index 011b6f82bd..b44132ee40 100644 --- a/config/alfresco/import-export-context.xml +++ b/config/alfresco/import-export-context.xml @@ -529,7 +529,7 @@ /${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.email.childname} - alfresco/templates/following-email-templates.acp + alfresco/templates/following-email-templates.xml alfresco/messages/bootstrap-spaces diff --git a/config/alfresco/messages/patch-service.properties b/config/alfresco/messages/patch-service.properties index 6eb8c6c011..f64f5553db 100644 --- a/config/alfresco/messages/patch-service.properties +++ b/config/alfresco/messages/patch-service.properties @@ -442,3 +442,7 @@ patch.sitesSpacePermissions.result.none=Permissions corrections not required. patch.updateWorkflowNotificationTemplates.description=Patch to update the workflow notification templates. patch.updateWorkflowNotificationTemplates.result=Workflow Notification Templates successfully updated. + +patch.updateFollowingEmailTemplatesPatch.description=Patch to update the following notification email templates. +patch.updateFollowingEmailTemplatesPatch.result=Following notification email templates successfully updated. +patch.updateFollowingEmailTemplatesPatch.error=Error retrieving base template when trying to patch the following email templates. diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml index 2fcdbed064..68eea657de 100644 --- a/config/alfresco/patch/patch-services-context.xml +++ b/config/alfresco/patch/patch-services-context.xml @@ -2486,7 +2486,7 @@ /${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.email.childname} - alfresco/templates/following-email-templates.acp + alfresco/templates/following-email-templates.xml alfresco/messages/bootstrap-spaces @@ -2890,7 +2890,7 @@ - + patch.updateMimetypes4 patch.updateMimetypes4.description @@ -2961,4 +2961,17 @@ + + patch.updateFollowingEmailTemplatesPatch + patch.updateFollowingEmailTemplatesPatch.description + 0 + 5021 + 5022 + true + true + + + + + diff --git a/config/alfresco/templates/following-email-templates.xml b/config/alfresco/templates/following-email-templates.xml new file mode 100644 index 0000000000..224e560691 --- /dev/null +++ b/config/alfresco/templates/following-email-templates.xml @@ -0,0 +1,105 @@ + + + + + + ${spaces.templates.email.following.name} + ${spaces.templates.email.following.name} + ${spaces.templates.email.following.description} + + + + + + + + + + + + true + following-email.html.ftl + following-email.html.ftl + ${email.templates.email_template_for_following_notifications} - ${version.default} + contentUrl=classpath:alfresco/templates/following-email-templates/following-email.html.ftl|mimetype=text/plain|size=3688|encoding=UTF-8 + + + + + + + + + + + true + following-email.html_de.ftl + following-email.html_de.ftl + ${email.templates.email_template_for_following_notifications} - ${version.default} + contentUrl=classpath:alfresco/templates/following-email-templates/following-email.html_de.ftl|mimetype=text/plain|size=3688|encoding=UTF-8 + + + + + + + + + + + true + following-email.html_es.ftl + following-email.html_es.ftl + ${email.templates.email_template_for_following_notifications} - ${version.default} + contentUrl=classpath:alfresco/templates/following-email-templates/following-email.html_es.ftl|mimetype=text/plain|size=3688|encoding=UTF-8 + + + + + + + + + + + true + following-email.html_fr.ftl + following-email.html_fr.ftl + ${email.templates.email_template_for_following_notifications} - ${version.default} + contentUrl=classpath:alfresco/templates/following-email-templates/following-email.html_fr.ftl|mimetype=text/plain|size=3688|encoding=UTF-8 + + + + + + + + + + + true + following-email.html_it.ftl + following-email.html_it.ftl + ${email.templates.email_template_for_following_notifications} - ${version.default} + contentUrl=classpath:alfresco/templates/following-email-templates/following-email.html_it.ftl|mimetype=text/plain|size=3688|encoding=UTF-8 + + + + + + + + + + + true + following-email.html_ja.ftl + following-email.html_ja.ftl + ${email.templates.email_template_for_following_notifications} - ${version.default} + contentUrl=classpath:alfresco/templates/following-email-templates/following-email.html_ja.ftl|mimetype=text/plain|size=3688|encoding=UTF-8 + + + + + + diff --git a/config/alfresco/templates/following-email-templates/following-email.html.ftl b/config/alfresco/templates/following-email-templates/following-email.html.ftl new file mode 100644 index 0000000000..5230ca278d --- /dev/null +++ b/config/alfresco/templates/following-email-templates/following-email.html.ftl @@ -0,0 +1,76 @@ + + <#assign followerFullName>${followerFirstName} ${followerLastName}#assign> + <#assign followerLink>${(followerFullName?trim)?html}#assign> + + + + + + + + + + + + + + + + + + + + + + + + + + ${followerLink} is now following you. + + + <#if followerJobTitle??>${followerJobTitle?html}#if> + + + <#if followingCount > 0>${followingCount} Following. #if>${followerCount} Followers. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/alfresco/templates/following-email-templates/following-email.html_de.ftl b/config/alfresco/templates/following-email-templates/following-email.html_de.ftl new file mode 100644 index 0000000000..76a6873e0b --- /dev/null +++ b/config/alfresco/templates/following-email-templates/following-email.html_de.ftl @@ -0,0 +1,76 @@ + + <#assign followerFullName>${followerFirstName} ${followerLastName}#assign> + <#assign followerLink>${(followerFullName?trim)?html}#assign> + + + + + + + + + + + + + + + + + + + + + + + + + + ${followerLink} folgt Ihnen. + + + <#if followerJobTitle??>${followerJobTitle?html}#if> + + + <#if followingCount > 0>Sie folgen ${followingCount} Mitarbeitern. #if>Ihnen folgen ${followerCount} Mitarbeiter. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/alfresco/templates/following-email-templates/following-email.html_es.ftl b/config/alfresco/templates/following-email-templates/following-email.html_es.ftl new file mode 100644 index 0000000000..6eec084e39 --- /dev/null +++ b/config/alfresco/templates/following-email-templates/following-email.html_es.ftl @@ -0,0 +1,76 @@ + + <#assign followerFullName>${followerFirstName} ${followerLastName}#assign> + <#assign followerLink>${(followerFullName?trim)?html}#assign> + + + + + + + + + + + + + + + + + + + + + + + + + + ${followerLink} est siguindole ahora. + + + <#if followerJobTitle??>${followerJobTitle?html}#if> + + + <#if followingCount > 0>Est siguiendo a ${followingCount}. #if>Tiene ${followerCount} seguidores. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/alfresco/templates/following-email-templates/following-email.html_fr.ftl b/config/alfresco/templates/following-email-templates/following-email.html_fr.ftl new file mode 100644 index 0000000000..318221d679 --- /dev/null +++ b/config/alfresco/templates/following-email-templates/following-email.html_fr.ftl @@ -0,0 +1,76 @@ + + <#assign followerFullName>${followerFirstName} ${followerLastName}#assign> + <#assign followerLink>${(followerFullName?trim)?html}#assign> + + + + + + + + + + + + + + + + + + + + + + + + + + ${followerLink} vous suit actuellement. + + + <#if followerJobTitle??>${followerJobTitle?html}#if> + + + <#if followingCount > 0>${followingCount} suivis en cours. #if>${followerCount} suiveurs. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/alfresco/templates/following-email-templates/following-email.html_it.ftl b/config/alfresco/templates/following-email-templates/following-email.html_it.ftl new file mode 100644 index 0000000000..5230ca278d --- /dev/null +++ b/config/alfresco/templates/following-email-templates/following-email.html_it.ftl @@ -0,0 +1,76 @@ + + <#assign followerFullName>${followerFirstName} ${followerLastName}#assign> + <#assign followerLink>${(followerFullName?trim)?html}#assign> + + + + + + + + + + + + + + + + + + + + + + + + + + ${followerLink} is now following you. + + + <#if followerJobTitle??>${followerJobTitle?html}#if> + + + <#if followingCount > 0>${followingCount} Following. #if>${followerCount} Followers. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/alfresco/templates/following-email-templates/following-email.html_ja.ftl b/config/alfresco/templates/following-email-templates/following-email.html_ja.ftl new file mode 100644 index 0000000000..c7dda7907a --- /dev/null +++ b/config/alfresco/templates/following-email-templates/following-email.html_ja.ftl @@ -0,0 +1,76 @@ + + <#assign followerFullName>${followerFirstName} ${followerLastName}#assign> + <#assign followerLink>${(followerFullName?trim)?html}#assign> + + + + + + + + + + + + + + + + + + + + + + + + + + ${followerLink} はあなたをフォーロー中です. + + + <#if followerJobTitle??>${followerJobTitle?html}#if> + + + <#if followingCount > 0>${followingCount} 人がフォローしてます. #if>${followerCount} 人のフォローワー. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/alfresco/version.properties b/config/alfresco/version.properties index 5e488231e5..166724e79b 100644 --- a/config/alfresco/version.properties +++ b/config/alfresco/version.properties @@ -19,4 +19,4 @@ version.build=@build-number@ # Schema number -version.schema=5021 +version.schema=5022 diff --git a/source/java/org/alfresco/repo/action/evaluator/compare/DatePropertyValueComparator.java b/source/java/org/alfresco/repo/action/evaluator/compare/DatePropertyValueComparator.java index d306b53212..7acab54068 100644 --- a/source/java/org/alfresco/repo/action/evaluator/compare/DatePropertyValueComparator.java +++ b/source/java/org/alfresco/repo/action/evaluator/compare/DatePropertyValueComparator.java @@ -42,8 +42,7 @@ public class DatePropertyValueComparator implements PropertyValueComparator /** * @see org.alfresco.repo.action.evaluator.compare.PropertyValueComparator#compare(java.io.Serializable, java.io.Serializable, org.alfresco.repo.action.evaluator.compare.ComparePropertyValueOperation) */ - public boolean compare(Serializable propertyValue, - Serializable compareValue, ComparePropertyValueOperation operation) + public boolean compare(Serializable propertyValue, Serializable compareValue, ComparePropertyValueOperation operation) { boolean result = false; @@ -94,7 +93,8 @@ public class DatePropertyValueComparator implements PropertyValueComparator return result; } - private Date getDate(Serializable value) { + private Date getDate(Serializable value) + { if(value instanceof Date) { return (Date) value; diff --git a/source/java/org/alfresco/repo/admin/patch/impl/GenericEMailTemplateUpdatePatch.java b/source/java/org/alfresco/repo/admin/patch/impl/GenericEMailTemplateUpdatePatch.java new file mode 100644 index 0000000000..5e54adfd3a --- /dev/null +++ b/source/java/org/alfresco/repo/admin/patch/impl/GenericEMailTemplateUpdatePatch.java @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2005-2011 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * 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 . + */ +package org.alfresco.repo.admin.patch.impl; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.model.ContentModel; +import org.alfresco.repo.admin.patch.AbstractPatch; +import org.alfresco.service.cmr.model.FileFolderService; +import org.alfresco.service.cmr.repository.ContentService; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * @author Roy Wetherall + */ +public abstract class GenericEMailTemplateUpdatePatch extends AbstractPatch +{ + protected static final String[] LOCALES = new String[] {"de", "es", "fr", "it", "ja"}; + + protected ContentService contentService; + + protected FileFolderService fileFolderService; + + private boolean createSiblingIfMissing = true; + + public void setContentService(ContentService contentService) + { + this.contentService = contentService; + } + + public void setFileFolderService(FileFolderService fileFolderService) + { + this.fileFolderService = fileFolderService; + } + + public void setCreateSiblingIfMissing(boolean createSiblingIfMissing) + { + this.createSiblingIfMissing = createSiblingIfMissing; + } + + protected void updateTemplates() throws Exception + { + NodeRef baseTemplate = getBaseTemplate(); + if (nodeService.exists(baseTemplate) == true) + { + updateContent(baseTemplate, getPath(), getBaseFileName()); + + for (String siblingFile : getSiblingFiles()) + { + updateSiblingContent(baseTemplate, getPath(), siblingFile); + } + } + } + + protected abstract NodeRef getBaseTemplate(); + + protected abstract String getPath(); + + protected abstract String getBaseFileName(); + + protected String[] getLocales() + { + return LOCALES; + } + + protected List getSiblingFiles() + { + List siblingFiles = new ArrayList(LOCALES.length); + for (String locale : LOCALES) + { + siblingFiles.add(makeSiblingFileName(getBaseFileName(), locale)); + } + return siblingFiles; + } + + private String makeSiblingFileName(String baseFileName, String locale) + { + int index = baseFileName.lastIndexOf("."); + StringBuilder builder = new StringBuilder(); + builder.append(baseFileName.substring(0, index)) + .append("_") + .append(locale) + .append(baseFileName.substring(index)); + return builder.toString(); + } + + private void updateSiblingContent(NodeRef nodeRef, String path, String fileName) + { + NodeRef parent = nodeService.getPrimaryParent(nodeRef).getParentRef(); + if (parent != null) + { + NodeRef sibling = fileFolderService.searchSimple(parent, fileName); + if (sibling != null) + { + updateContent(sibling, path, fileName); + } + else if (createSiblingIfMissing == true) + { + sibling = fileFolderService.create(parent, fileName, ContentModel.TYPE_CONTENT).getNodeRef(); + updateContent(sibling, path, fileName); + } + } + } + + private void updateContent(NodeRef nodeRef, String path, String fileName) + { + // Make versionable + nodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, null); + + // Update content + InputStream is = this.getClass().getClassLoader().getResourceAsStream(path + fileName); + if (is != null) + { + ContentWriter contentWriter = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true); + contentWriter.putContent(is); + } + } + +} diff --git a/source/java/org/alfresco/repo/admin/patch/impl/UpdateFollowingEmailTemplatesPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/UpdateFollowingEmailTemplatesPatch.java new file mode 100644 index 0000000000..c6ac0166ec --- /dev/null +++ b/source/java/org/alfresco/repo/admin/patch/impl/UpdateFollowingEmailTemplatesPatch.java @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2005-2011 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * 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 . + */ +package org.alfresco.repo.admin.patch.impl; + +import java.util.List; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.repo.model.Repository; +import org.alfresco.service.cmr.repository.NodeRef; +import org.springframework.extensions.surf.util.I18NUtil; + +/** + * Update following email templates patch + * + * @author Roy Wetherall + */ +public class UpdateFollowingEmailTemplatesPatch extends GenericEMailTemplateUpdatePatch +{ + private Repository repository; + + private static final String PATH = "alfresco/templates/following-email-templates/"; + private static final String BASE_FILE = "following-email.html.ftl"; + private static final String XPATH = "/app:company_home/app:dictionary/app:email_templates/app:following/cm:following-email.html.ftl"; + + public void setRepository(Repository repository) + { + this.repository = repository; + } + + @Override + protected String getPath() + { + return PATH; + } + + @Override + protected String getBaseFileName() + { + return BASE_FILE; + } + + @Override + protected NodeRef getBaseTemplate() + { + List refs = searchService.selectNodes( + repository.getRootHome(), + XPATH, + null, + namespaceService, + false); + if (refs.size() != 1) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage("patch.updateFollowingEmailTemplatesPatch.error")); + } + return refs.get(0); + } + + /** + * @see org.alfresco.repo.admin.patch.AbstractPatch#applyInternal() + */ + @Override + protected String applyInternal() throws Exception + { + updateTemplates(); + return I18NUtil.getMessage("patch.updateFollowingEmailTemplatesPatch.result"); + } +} diff --git a/source/java/org/alfresco/repo/admin/patch/impl/UpdateWorkflowNotificationTemplatesPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/UpdateWorkflowNotificationTemplatesPatch.java index cd38c5023f..d0a4a42e62 100644 --- a/source/java/org/alfresco/repo/admin/patch/impl/UpdateWorkflowNotificationTemplatesPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/impl/UpdateWorkflowNotificationTemplatesPatch.java @@ -18,14 +18,7 @@ */ package org.alfresco.repo.admin.patch.impl; -import java.io.InputStream; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.admin.patch.AbstractPatch; import org.alfresco.repo.workflow.WorkflowNotificationUtils; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.NodeRef; import org.springframework.extensions.surf.util.I18NUtil; @@ -34,75 +27,36 @@ import org.springframework.extensions.surf.util.I18NUtil; * * @author Roy Wetherall */ -public class UpdateWorkflowNotificationTemplatesPatch extends AbstractPatch +public class UpdateWorkflowNotificationTemplatesPatch extends GenericEMailTemplateUpdatePatch { - private ContentService contentService; - - private FileFolderService fileFolderService; - private static final String PATH = "alfresco/bootstrap/notification/"; private static final String BASE_FILE = "wf-email.html.ftl"; - private static final String DE_FILE = "wf-email.html_de.ftl"; - private static final String ES_FILE = "wf-email.html_es.ftl"; - private static final String FR_FILE = "wf-email.html_fr.ftl"; - private static final String IT_FILE = "wf-email.html_it.ftl"; - private static final String JA_FILE = "wf-email.html_ja.ftl"; - public void setContentService(ContentService contentService) + @Override + protected String getPath() { - this.contentService = contentService; + return PATH; } - public void setFileFolderService(FileFolderService fileFolderService) + @Override + protected String getBaseFileName() { - this.fileFolderService = fileFolderService; + return BASE_FILE; } - + + @Override + protected NodeRef getBaseTemplate() + { + return WorkflowNotificationUtils.WF_ASSIGNED_TEMPLATE; + } + /** * @see org.alfresco.repo.admin.patch.AbstractPatch#applyInternal() */ @Override protected String applyInternal() throws Exception - { - NodeRef baseTemplate = WorkflowNotificationUtils.WF_ASSIGNED_TEMPLATE; - if (nodeService.exists(baseTemplate) == true) - { - updateContent(baseTemplate, PATH, BASE_FILE); - updateSiblingContent(baseTemplate, PATH, DE_FILE); - updateSiblingContent(baseTemplate, PATH, ES_FILE); - updateSiblingContent(baseTemplate, PATH, FR_FILE); - updateSiblingContent(baseTemplate, PATH, IT_FILE); - updateSiblingContent(baseTemplate, PATH, JA_FILE); - } - + { + updateTemplates(); return I18NUtil.getMessage("patch.updateWorkflowNotificationTemplates.result"); } - - private void updateSiblingContent(NodeRef nodeRef, String path, String fileName) - { - NodeRef parent = nodeService.getPrimaryParent(nodeRef).getParentRef(); - if (parent != null) - { - NodeRef sibling = fileFolderService.searchSimple(parent, fileName); - if (sibling != null) - { - updateContent(sibling, path, fileName); - } - } - } - - private void updateContent(NodeRef nodeRef, String path, String fileName) - { - // Make versionable - nodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, null); - - // Update content - InputStream is = this.getClass().getClassLoader().getResourceAsStream(path + fileName); - if (is != null) - { - ContentWriter contentWriter = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true); - contentWriter.putContent(is); - } - } - }