mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-11463: Dutch - Localised Templates
* Dutch email templates added * Patch added git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32715 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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 workflow notification templates patch
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class AddDutchEmailTemplatesPatch extends GenericEMailTemplateUpdatePatch
|
||||
{
|
||||
private static final String[] LOCALES = new String[] {"nl"};
|
||||
private static final String[] PATHS = new String[]
|
||||
{
|
||||
"alfresco/templates/activities-email-templates/",
|
||||
"alfresco/bootstrap/notification/",
|
||||
"alfresco/templates/notify_email_templates/",
|
||||
"alfresco/templates/new-user-templates/",
|
||||
"alfresco/templates/invite-email-templates/",
|
||||
"alfresco/templates/following-email-templates/"
|
||||
};
|
||||
private static final String[] BASE_FILES = new String[]
|
||||
{
|
||||
"activities-email.ftl",
|
||||
"wf-email.html.ftl",
|
||||
"notify.htm",
|
||||
"new-user-email.html",
|
||||
"invite-email.html.ftl",
|
||||
"following-email.html.ftl"
|
||||
};
|
||||
private static final String[] XPATHS = new String[]
|
||||
{
|
||||
"/app:company_home/app:dictionary/app:email_templates/cm:activities/cm:activities-email.ftl",
|
||||
"/app:company_home/app:dictionary/app:email_templates/cm:workflownotification/cm:invite-email.html.ftl",
|
||||
"/app:company_home/app:dictionary/app:email_templates/app:notify_email_templates/cm:notify_user_email.html.ftl",
|
||||
"/app:company_home/app:dictionary/app:email_templates/cm:invite/cm:new-user-email.html.ftl",
|
||||
"/app:company_home/app:dictionary/app:email_templates/cm:invite/cm:invite-email.html.ftl",
|
||||
"/app:company_home/app:dictionary/app:email_templates/app:following/cm:following-email.html.ftl"
|
||||
};
|
||||
|
||||
private int currentIndex = 0;
|
||||
|
||||
private Repository repository;
|
||||
|
||||
public void setRepository(Repository repository)
|
||||
{
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPath()
|
||||
{
|
||||
return PATHS[currentIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBaseFileName()
|
||||
{
|
||||
return BASE_FILES[currentIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getLocales()
|
||||
{
|
||||
return LOCALES;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NodeRef getBaseTemplate()
|
||||
{
|
||||
List<NodeRef> refs = searchService.selectNodes(
|
||||
repository.getRootHome(),
|
||||
XPATHS[currentIndex],
|
||||
null,
|
||||
namespaceService,
|
||||
false);
|
||||
if (refs.size() != 1)
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage("patch.addDutchEmailTemplatesPatch.error"));
|
||||
}
|
||||
return refs.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.admin.patch.AbstractPatch#applyInternal()
|
||||
*/
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
while (currentIndex < BASE_FILES.length)
|
||||
{
|
||||
updateTemplates();
|
||||
currentIndex ++;
|
||||
}
|
||||
|
||||
return I18NUtil.getMessage("patch.addDutchEmailTemplatesPatch.result");
|
||||
}
|
||||
}
|
@@ -24,45 +24,76 @@ import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Helper generic patch useful when updating email templates.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public abstract class GenericEMailTemplateUpdatePatch extends AbstractPatch
|
||||
{
|
||||
protected static final String[] LOCALES = new String[] {"de", "es", "fr", "it", "ja"};
|
||||
|
||||
protected ContentService contentService;
|
||||
/** Content service */
|
||||
protected ContentService contentService;
|
||||
|
||||
/** File folder service */
|
||||
protected FileFolderService fileFolderService;
|
||||
|
||||
/** Indicates whether to update the base file or not */
|
||||
private boolean updateBaseFile = true;
|
||||
|
||||
/** Indicates whether to create a sibling if it's missing (rather than just update) */
|
||||
private boolean createSiblingIfMissing = true;
|
||||
|
||||
/**
|
||||
* @param contentService content service
|
||||
*/
|
||||
public void setContentService(ContentService contentService)
|
||||
{
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileFolderService file folder service
|
||||
*/
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param createSiblingIfMissing
|
||||
*/
|
||||
public void setCreateSiblingIfMissing(boolean createSiblingIfMissing)
|
||||
{
|
||||
this.createSiblingIfMissing = createSiblingIfMissing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param updateBaseFile
|
||||
*/
|
||||
public void setUpdateBaseFile(boolean updateBaseFile)
|
||||
{
|
||||
this.updateBaseFile = updateBaseFile;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected void updateTemplates() throws Exception
|
||||
{
|
||||
NodeRef baseTemplate = getBaseTemplate();
|
||||
if (nodeService.exists(baseTemplate) == true)
|
||||
{
|
||||
updateContent(baseTemplate, getPath(), getBaseFileName());
|
||||
if (updateBaseFile == true)
|
||||
{
|
||||
updateContent(baseTemplate, getPath(), getBaseFileName(), false);
|
||||
}
|
||||
|
||||
for (String siblingFile : getSiblingFiles())
|
||||
{
|
||||
@@ -77,15 +108,12 @@ public abstract class GenericEMailTemplateUpdatePatch extends AbstractPatch
|
||||
|
||||
protected abstract String getBaseFileName();
|
||||
|
||||
protected String[] getLocales()
|
||||
{
|
||||
return LOCALES;
|
||||
}
|
||||
protected abstract String[] getLocales();
|
||||
|
||||
protected List<String> getSiblingFiles()
|
||||
{
|
||||
List<String> siblingFiles = new ArrayList<String>(LOCALES.length);
|
||||
for (String locale : LOCALES)
|
||||
List<String> siblingFiles = new ArrayList<String>(getLocales().length);
|
||||
for (String locale : getLocales())
|
||||
{
|
||||
siblingFiles.add(makeSiblingFileName(getBaseFileName(), locale));
|
||||
}
|
||||
@@ -111,17 +139,17 @@ public abstract class GenericEMailTemplateUpdatePatch extends AbstractPatch
|
||||
NodeRef sibling = fileFolderService.searchSimple(parent, fileName);
|
||||
if (sibling != null)
|
||||
{
|
||||
updateContent(sibling, path, fileName);
|
||||
updateContent(sibling, path, fileName, false);
|
||||
}
|
||||
else if (createSiblingIfMissing == true)
|
||||
{
|
||||
sibling = fileFolderService.create(parent, fileName, ContentModel.TYPE_CONTENT).getNodeRef();
|
||||
updateContent(sibling, path, fileName);
|
||||
updateContent(sibling, path, fileName, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateContent(NodeRef nodeRef, String path, String fileName)
|
||||
private void updateContent(NodeRef nodeRef, String path, String fileName, boolean newFile)
|
||||
{
|
||||
// Make versionable
|
||||
nodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, null);
|
||||
@@ -131,6 +159,11 @@ public abstract class GenericEMailTemplateUpdatePatch extends AbstractPatch
|
||||
if (is != null)
|
||||
{
|
||||
ContentWriter contentWriter = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
|
||||
if (newFile == true)
|
||||
{
|
||||
contentWriter.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
contentWriter.setEncoding("UTF-8");
|
||||
}
|
||||
contentWriter.putContent(is);
|
||||
}
|
||||
}
|
||||
|
@@ -34,6 +34,8 @@ public class UpdateFollowingEmailTemplatesPatch extends GenericEMailTemplateUpda
|
||||
{
|
||||
private Repository repository;
|
||||
|
||||
protected static final String[] LOCALES = new String[] {"de", "es", "fr", "it", "ja"};
|
||||
|
||||
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";
|
||||
@@ -55,6 +57,12 @@ public class UpdateFollowingEmailTemplatesPatch extends GenericEMailTemplateUpda
|
||||
return BASE_FILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getLocales()
|
||||
{
|
||||
return LOCALES;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NodeRef getBaseTemplate()
|
||||
{
|
||||
|
@@ -29,6 +29,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
*/
|
||||
public class UpdateWorkflowNotificationTemplatesPatch extends GenericEMailTemplateUpdatePatch
|
||||
{
|
||||
private static final String[] LOCALES = new String[] {"de", "es", "fr", "it", "ja"};
|
||||
private static final String PATH = "alfresco/bootstrap/notification/";
|
||||
private static final String BASE_FILE = "wf-email.html.ftl";
|
||||
|
||||
@@ -44,6 +45,12 @@ public class UpdateWorkflowNotificationTemplatesPatch extends GenericEMailTempla
|
||||
return BASE_FILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getLocales()
|
||||
{
|
||||
return LOCALES;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NodeRef getBaseTemplate()
|
||||
{
|
||||
|
Reference in New Issue
Block a user