Merged DEV/BELARUS/HEAD-2010_02_10 to HEAD

19151: SAIL-298: Implemented subsystem changes.
      - We didn't remove the cifs.serverName property because it is independent of host/port/context/protocol.
   Applied following corrections
      - Removed the email 'chain'. OutboundSMTP and InboundSMTP are separate subsystems and don't need to be chained
      - Added the ability for multiple Spring-initialized subsystems to share the same category
      - No need to expose mailService outside of the OutboundSMTP subsystem as far as I can tell
      - GlobalDeskTopActionConfigBean doesn't need dependencies and no longer exposes the webpath property
      - Fixed construction of contexts in ContentDiskDriver.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19266 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2010-03-12 18:41:09 +00:00
parent 8f0ad2d96f
commit a2c2e215a8
29 changed files with 548 additions and 271 deletions

View File

@@ -414,37 +414,15 @@
</property>
</bean>
<bean id="mail" class="org.alfresco.repo.action.executer.MailActionExecuter" parent="action-executer">
<property name="mailService">
<ref bean="mailService"></ref>
<!-- Import mail action executor from the OutboundSMTP subsystem -->
<bean id="mail" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
<property name="sourceApplicationContextFactory">
<ref bean="OutboundSMTP" />
</property>
<property name="templateService">
<ref bean="templateService"></ref>
</property>
<property name="personService">
<ref bean="personService"></ref>
</property>
<property name="authenticationService">
<ref bean="authenticationService"></ref>
</property>
<property name="nodeService">
<ref bean="nodeService"></ref>
</property>
<property name="authorityService">
<ref bean="authorityService"></ref>
</property>
<!-- The service registry is needed as TemplateNodes are used -->
<property name="serviceRegistry">
<ref bean="ServiceRegistry"></ref>
</property>
<property name="headerEncoding">
<value>${mail.header}</value>
</property>
<property name="fromAddress">
<value>${mail.from.default}</value>
</property>
<property name="repoRemoteUrl">
<value>${repo.remote.url}</value>
<property name="interfaces">
<list>
<value>org.alfresco.repo.action.executer.ActionExecuter</value>
</list>
</property>
</bean>

View File

@@ -16,7 +16,6 @@
<import resource="classpath:alfresco/scheduler-core-context.xml" />
<import resource="classpath:alfresco/network-authentication-context.xml" />
<import resource="classpath:alfresco/network-protocol-context.xml" />
<import resource="classpath:alfresco/emailserver/email-service-context.xml" />
<import resource="classpath:alfresco/content-services-context.xml" />
<import resource="classpath:alfresco/mt/st-admin-context.xml"/>
<import resource="classpath:alfresco/dao/dao-context.xml" />

View File

@@ -469,6 +469,42 @@
</property>
</bean>
<!-- Outbound Email subsystem -->
<bean id="OutboundSMTP" class="org.alfresco.repo.management.subsystems.ChildApplicationContextFactory" parent="abstractPropertyBackedBean">
<property name="category">
<value>email</value>
</property>
<property name="typeName">
<value>OutboundSMTP</value>
</property>
<property name="instancePath">
<list>
<value>outbound</value>
</list>
</property>
<property name="autoStart">
<value>true</value>
</property>
</bean>
<!-- Inbound Email subsystem -->
<bean id="InboundSMTP" class="org.alfresco.repo.management.subsystems.ChildApplicationContextFactory" parent="abstractPropertyBackedBean">
<property name="category">
<value>email</value>
</property>
<property name="typeName">
<value>InboundSMTP</value>
</property>
<property name="instancePath">
<list>
<value>inbound</value>
</list>
</property>
<property name="autoStart">
<value>true</value>
</property>
</bean>
<!-- Start the quartz scheduler -->
<bean id="schedulerStarter" class="org.alfresco.util.SchedulerStarterBean" >
@@ -529,28 +565,6 @@
<property name="JBPMTemplate" ref="jbpm_template" />
</bean>
<!-- Email Server -->
<bean id="emailServer" class="org.alfresco.email.server.impl.subetha.SubethaEmailServer">
<property name="enabled">
<value>${email.server.enabled}</value>
</property>
<property name="domain">
<value>${email.server.domain}</value>
</property>
<property name="port">
<value>${email.server.port}</value>
</property>
<property name="blockedSenders">
<value>${email.server.blocked.senders}</value>
</property>
<property name="allowedSenders">
<value>${email.server.allowed.senders}</value>
</property>
<property name="emailService">
<ref bean="EmailService" />
</property>
</bean>
<!-- Start Auditing -->
<bean id="Audit" class="org.alfresco.repo.audit.model.AuditModelRegistryImpl" parent="abstractPropertyBackedBean">
<property name="searchPath">

View File

@@ -432,34 +432,6 @@
</bean>
<!-- -->
<!-- MAIL SERVICE -->
<!-- -->
<bean id="mailService" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host">
<value>${mail.host}</value>
</property>
<property name="port">
<value>${mail.port}</value>
</property>
<property name="username">
<value>${mail.username}</value>
</property>
<property name="password">
<value>${mail.password}</value>
</property>
<property name="defaultEncoding">
<value>${mail.encoding}</value>
</property>
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">${mail.smtp.auth}</prop>
<prop key="mail.smtp.timeout">${mail.smtp.timeout}</prop>
</props>
</property>
</bean>
<!-- -->
<!-- Property Component -->
<!-- -->

View File

@@ -59,6 +59,7 @@
<property name="permissionService"><ref bean="permissionService"/></property>
<property name="authenticationContext"><ref bean="authenticationContext"/></property>
<property name="authenticationService"><ref bean="authenticationService"/></property>
<property name="sysAdminParams"><ref bean="sysAdminParams"/></property>
<property name="fileFolderService"><ref bean="FileFolderService" /></property>
<property name="serviceRegistry"><ref bean="ServiceRegistry"/></property>
<property name="stateReaper"><ref bean="fileStateReaper"/></property>

View File

@@ -257,19 +257,6 @@ audit.cmischangelog.enabled=true
# alfresco/audit/*.xml will be used.
audit.useNewConfig=false
# Email configuration
mail.host=
mail.port=25
mail.username=anonymous
mail.password=
# Set this value to UTF-8 or similar for encoding of email messages as required
mail.encoding=UTF-8
# Set this value to 7bit or similar for Asian encoding of email headers as required
mail.header=
mail.from.default=alfresco@alfresco.org
mail.smtp.auth=false
mail.smtp.timeout=30000
# System Configuration
system.store=system://system
system.descriptor.childname=sys:descriptor
@@ -421,7 +408,6 @@ nfs.user.mappings.default.gid=0
# IMAP
imap.server.enabled=false
imap.server.port=143
imap.server.host=localhost
imap.server.attachments.extraction.enabled=true
# Default IMAP mount points

View File

@@ -13,17 +13,29 @@
</property>
</bean>
<bean id="emailServerConfigurationProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders">
<value>true</value>
<!-- Email Server -->
<bean id="emailServer" class="org.alfresco.email.server.impl.subetha.SubethaEmailServer">
<property name="enabled">
<value>${email.server.enabled}</value>
</property>
<property name="locations">
<list>
<value>classpath:alfresco/emailserver/email-server.properties</value>
</list>
<property name="domain">
<value>${email.server.domain}</value>
</property>
<property name="port">
<value>${email.server.port}</value>
</property>
<property name="blockedSenders">
<value>${email.server.blocked.senders}</value>
</property>
<property name="allowedSenders">
<value>${email.server.allowed.senders}</value>
</property>
<property name="emailService">
<ref bean="EmailService" />
</property>
</bean>
<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
<property name="service">
<ref bean="emailService"/>

View File

@@ -4,10 +4,10 @@
#
email.inbound.unknownUser=anonymous
email.inbound.enabled=false
email.inbound.enabled=true
email.server.enabled=false
email.server.enabled=true
email.server.port=25
email.server.domain=alfresco.com
email.server.allowed.senders=
email.server.allowed.senders=.*
email.server.blocked.senders=

View File

@@ -0,0 +1,84 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<!-- -->
<!-- MAIL SERVICE -->
<!-- -->
<bean id="mailService" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host">
<value>${mail.host}</value>
</property>
<property name="port">
<value>${mail.port}</value>
</property>
<property name="protocol">
<value>${mail.protocol}</value>
</property>
<property name="username">
<value>${mail.username}</value>
</property>
<property name="password">
<value>${mail.password}</value>
</property>
<property name="defaultEncoding">
<value>${mail.encoding}</value>
</property>
<property name="javaMailProperties">
<props>
<prop key="mail.smtps.auth">${mail.smtps.auth}</prop>
<prop key="mail.smtps.starttls.enable">${mail.smtps.starttls.enable}</prop>
</props>
</property>
</bean>
<bean id="mail" class="org.alfresco.repo.action.executer.MailActionExecuter" parent="action-executer">
<property name="mailService">
<ref bean="mailService"></ref>
</property>
<property name="templateService">
<ref bean="templateService"></ref>
</property>
<property name="personService">
<ref bean="personService"></ref>
</property>
<property name="authenticationService">
<ref bean="authenticationService"></ref>
</property>
<property name="nodeService">
<ref bean="nodeService"></ref>
</property>
<property name="authorityService">
<ref bean="authorityService"></ref>
</property>
<property name="serviceRegistry">
<ref bean="ServiceRegistry"></ref>
</property>
<property name="headerEncoding">
<value>${mail.header}</value>
</property>
<property name="fromAddress">
<value>${mail.from.default}</value>
</property>
<property name="repoRemoteUrl">
<value>${repo.remote.url}</value>
</property>
<property name="sendTestMessage">
<value>${mail.testmessage.send}</value>
</property>
<property name="testMessageTo">
<value>${mail.testmessage.to}</value>
</property>
<property name="testMessageSubject">
<value>${mail.testmessage.subject}</value>
</property>
<property name="testMessageText">
<value>${mail.testmessage.text}</value>
</property>
</bean>
</beans>

View File

@@ -0,0 +1,14 @@
mail.host=smtp.alfresco.com
mail.port=25
mail.username=anonymous
mail.password=
mail.encoding=UTF-8
mail.from.default=alfresco@demo.alfresco.org
mail.smtp.auth=false
mail.protocol=smtp
#use these properties to send test message during start of subsystem
mail.testmessage.send=false
mail.testmessage.to=
mail.testmessage.subject=Outbound SMTP
mail.testmessage.text=The Outbound SMTP email subsystem is working.

View File

@@ -298,6 +298,9 @@
<list>
<!-- Alfresco repository access shared filesystem -->
<bean class="org.alfresco.filesys.repo.ContentContext">
<property name="sysAdminParams">
<ref bean="sysAdminParams" />
</property>
<property name="deviceName">
<value>${filesystem.name}</value>
</property>
@@ -311,9 +314,6 @@
<property name="URLFileName">
<value>__Alfresco.url</value>
</property>
<property name="URLPrefix">
<value>${cifs.urlfile.prefix}</value>
</property>
<!-- Mark locked files as offline -->
<property name="offlineFiles">
<value>true</value>
@@ -333,9 +333,6 @@
<property name="path">
<value>alfresco/desktop/Alfresco.exe</value>
</property>
<property name="webpath">
<value>${cifs.urlfile.prefix}</value>
</property>
</bean>
</property>
<property name="desktopActionList">

View File

@@ -29,8 +29,6 @@ cifs.WINS.autoDetectEnabled=true
cifs.WINS.primary=1.2.3.4
cifs.WINS.secondary=5.6.7.8
cifs.urlfile.prefix=http://${localname}:8080/alfresco/
# CIFS session debug flags (also enable org.alfresco.fileserver=debug logging level)
# Comma delimeted list of levels :-
# NETBIOS, STATE, RXDATA, TXDATA, DUMPDATA, NEGOTIATE, TREE, SEARCH, INFO, FILE, FILEIO, TRANSACT

View File

@@ -13,8 +13,8 @@
</bean>
<bean id="imapServer" class="org.alfresco.repo.imap.AlfrescoImapServer">
<property name="host">
<value>${imap.server.host}</value>
<property name="sysAdminParams">
<ref bean="sysAdminParams" />
</property>
<property name="port">
<value>${imap.server.port}</value>
@@ -98,6 +98,9 @@
<bean id="imapService" class="org.alfresco.repo.imap.ImapServiceImpl" init-method="init">
<property name="sysAdminParams">
<ref bean="sysAdminParams" />
</property>
<property name="fileFolderService">
<ref bean="FileFolderService"/>
</property>
@@ -118,10 +121,7 @@
<ref bean="imap.config.home" />
</property>
<property name="defaultFromAddress">
<value>${mail.from.default}</value>
</property>
<property name="webApplicationContextUrl">
<value>${web.application.context.url}</value>
<value>${imap.mail.from.default}</value>
</property>
<property name="repositoryTemplatePath">
<value>${spaces.store}/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.imapConfig.childname}/${spaces.imap_templates.childname}</value>

View File

@@ -1,9 +1,8 @@
imap.server.enabled=false
imap.server.host=localhost
imap.server.port=143
imap.mail.from.default=alfresco@demo.alfresco.org
imap.config.home.store=${spaces.store}
imap.config.home.rootPath=/${spaces.company_home.childname}
imap.config.home.folderPath=Imap Home
#imap.server.web.application.context.url=http://localhost:8080/alfresco

View File

@@ -13,6 +13,31 @@
<property name="allowWrite">
<value>${server.transaction.allow-writes}</value>
</property>
<property name="alfrescoContext">
<value>${alfresco.context}</value>
</property>
<property name="alfrescoHost">
<value>${alfresco.host}</value>
</property>
<property name="alfrescoPort">
<value>${alfresco.port}</value>
</property>
<property name="alfrescoProtocol">
<value>${alfresco.protocol}</value>
</property>
<property name="shareContext">
<value>${share.context}</value>
</property>
<property name="shareHost">
<value>${share.host}</value>
</property>
<property name="sharePort">
<value>${share.port}</value>
</property>
<property name="shareProtocol">
<value>${share.protocol}</value>
</property>
</bean>
</beans>

View File

@@ -1,3 +1,12 @@
server.maxusers=-1
server.allowedusers=
server.transaction.allow-writes=true
alfresco.context=alfresco
alfresco.host=${localname}
alfresco.port=8080
alfresco.protocol=http
share.context=share
share.host=${localname}
share.port=8080
share.protocol=http

View File

@@ -18,7 +18,6 @@
*/
package org.alfresco.filesys.alfresco;
import java.net.InetAddress;
import java.util.Enumeration;
import java.util.List;
import java.util.StringTokenizer;
@@ -32,7 +31,7 @@ import org.alfresco.jlan.server.filesys.DiskInterface;
import org.alfresco.jlan.server.filesys.FileSystem;
import org.alfresco.jlan.server.filesys.SrvDiskInfo;
import org.alfresco.jlan.server.filesys.pseudo.PseudoFileInterface;
import org.alfresco.repo.admin.SysAdminParams;
/**
* Alfresco Filesystem Context Class
@@ -43,9 +42,7 @@ import org.alfresco.jlan.server.filesys.pseudo.PseudoFileInterface;
*/
public abstract class AlfrescoContext extends DiskDeviceContext
{
// Token name to substitute current servers DNS name or TCP/IP address into the webapp URL
private static final String TokenLocalName = "${localname}";
private SysAdminParams sysAdminParams;
// Debug levels
@@ -68,7 +65,6 @@ public abstract class AlfrescoContext extends DiskDeviceContext
// URL pseudo file web path prefix (server/port/webapp) and link file name
private String m_urlPathPrefix;
private String m_urlFileName;
// Pseudo file interface
@@ -103,6 +99,15 @@ public abstract class AlfrescoContext extends DiskDeviceContext
FileSystem.CaseSensitiveSearch);
}
public void setSysAdminParams(SysAdminParams sysAdminParams)
{
this.sysAdminParams = sysAdminParams;
}
public SysAdminParams getSysAdminParams()
{
return sysAdminParams;
}
public void setDisableChangeNotification(boolean disableChangeNotification)
{
@@ -303,7 +308,7 @@ public abstract class AlfrescoContext extends DiskDeviceContext
*/
public final boolean hasURLFile()
{
if ( m_urlPathPrefix != null && m_urlFileName != null)
if (m_urlFileName != null)
return true;
return false;
}
@@ -315,7 +320,7 @@ public abstract class AlfrescoContext extends DiskDeviceContext
*/
public final String getURLPrefix()
{
return m_urlPathPrefix;
return sysAdminParams.getAlfrescoProtocol() + "://" + sysAdminParams.getAlfrescoHost() + ":" + sysAdminParams.getAlfrescoPort() + "/" + sysAdminParams.getAlfrescoContext() + "/";
}
/**
@@ -328,58 +333,6 @@ public abstract class AlfrescoContext extends DiskDeviceContext
return m_urlFileName;
}
/**
* Set the URL path prefix
*
* @param urlPrefix String
*/
public final void setURLPrefix(String urlPrefix)
{
m_urlPathPrefix = urlPrefix;
if ( urlPrefix != null)
{
// Make sure the web prefix has a trailing slash
if ( !urlPrefix.endsWith("/"))
urlPrefix = urlPrefix + "/";
// Check if the URL path name contains the local name token
int pos = urlPrefix.indexOf(TokenLocalName);
if (pos != -1)
{
// Get the local server name
String srvName = "localhost";
try
{
srvName = InetAddress.getLocalHost().getHostName();
}
catch ( Exception ex)
{
}
// Rebuild the host name substituting the token with the local server name
StringBuilder hostStr = new StringBuilder();
hostStr.append( urlPrefix.substring(0, pos));
hostStr.append(srvName);
pos += TokenLocalName.length();
if (pos < urlPrefix.length())
hostStr.append( urlPrefix.substring(pos));
m_urlPathPrefix = hostStr.toString();
}
enabledPseudoFileInterface();
}
}
/**
* Set the URL pseudo file name
*

View File

@@ -21,17 +21,17 @@ package org.alfresco.filesys.alfresco;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import org.springframework.extensions.config.ConfigElement;
import org.alfresco.jlan.server.filesys.DiskSharedDevice;
import org.alfresco.jlan.server.filesys.pseudo.LocalPseudoFile;
import org.alfresco.jlan.server.filesys.pseudo.PseudoFile;
import org.alfresco.repo.admin.SysAdminParams;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.util.ResourceFinder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.io.Resource;
import org.springframework.extensions.config.ConfigElement;
/**
* Desktop Action Class
@@ -86,10 +86,6 @@ public abstract class DesktopAction {
public static final int StsCommandLine = 8;
public static final int StsAuthTicket = 9;
// Token name to substitute current servers DNS name or TCP/IP address into the webapp URL
private static final String TokenLocalName = "${localname}";
// Action name
private String m_name;
@@ -443,44 +439,19 @@ public abstract class DesktopAction {
// Check if the webapp URL has been specified
SysAdminParams sysAdminParams = m_filesysContext.getSysAdminParams();
if (m_webappURL == null || m_webappURL.length() == 0)
{
m_webappURL = m_filesysContext.getGlobalDesktopActionConfig().getWebpath();
m_webappURL = m_filesysContext.getURLPrefix();
}
if ( m_webappURL != null && m_webappURL.length() > 0)
else
{
// Check if the path name contains the local name token
m_webappURL = sysAdminParams.subsituteHost(m_webappURL);
if ( !m_webappURL.endsWith("/"))
{
m_webappURL = m_webappURL + "/";
int pos = m_webappURL.indexOf(TokenLocalName);
if (pos != -1)
{
// Get the local server name
String srvName = "localhost";
try
{
srvName = InetAddress.getLocalHost().getHostName();
}
catch ( Exception ex)
{
}
// Rebuild the host name substituting the token with the local server name
StringBuilder hostStr = new StringBuilder();
hostStr.append(m_webappURL.substring(0, pos));
hostStr.append(srvName);
pos += TokenLocalName.length();
if (pos < m_webappURL.length())
hostStr.append(m_webappURL.substring(pos));
m_webappURL = hostStr.toString();
}
}

View File

@@ -18,6 +18,7 @@
*/
package org.alfresco.filesys.config;
// TODO: Auto-generated Javadoc
/**
* The Class GlobalDesktopActionConfigBean.
@@ -26,13 +27,9 @@ package org.alfresco.filesys.config;
*/
public class GlobalDesktopActionConfigBean
{
/** The no confirm. */
private boolean noConfirm;
/** The webpath. */
private String webpath;
/** The path. */
private String path;
@@ -60,27 +57,6 @@ public class GlobalDesktopActionConfigBean
this.noConfirm = noConfirm;
}
/**
* Gets the webpath.
*
* @return the webpath
*/
public String getWebpath()
{
return webpath;
}
/**
* Sets the webpath.
*
* @param webpath
* the new webpath
*/
public void setWebpath(String webpath)
{
this.webpath = webpath;
}
/**
* Gets the path.
*

View File

@@ -26,7 +26,6 @@ import java.util.List;
import javax.transaction.UserTransaction;
import org.springframework.extensions.config.ConfigElement;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.filesys.alfresco.AlfrescoContext;
import org.alfresco.filesys.alfresco.AlfrescoDiskDriver;
@@ -66,12 +65,12 @@ import org.alfresco.jlan.smb.server.SMBServer;
import org.alfresco.jlan.smb.server.SMBSrvSession;
import org.alfresco.jlan.util.WildCard;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.admin.SysAdminParams;
import org.alfresco.repo.node.archive.NodeArchiveService;
import org.alfresco.repo.security.authentication.AuthenticationContext;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.lock.NodeLockedException;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentIOException;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
@@ -87,6 +86,7 @@ import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.NamespaceService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.config.ConfigElement;
/**
* Content repository filesystem driver class
@@ -121,6 +121,7 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
private AuthenticationContext authContext;
private AuthenticationService authService;
private SysAdminParams sysAdminParams;
// Node monitor factory
@@ -297,6 +298,17 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
this.authService = authService;
}
/**
* Sets the sys admin params.
*
* @param sysAdminParams
* the sys admin params
*/
public void setSysAdminParams(SysAdminParams sysAdminParams)
{
this.sysAdminParams = sysAdminParams;
}
/**
* Set the file folder service
*
@@ -375,6 +387,7 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
context.setDeviceName(shareName);
context.setStoreName(storeValue);
context.setRootPath(rootPath);
context.setSysAdminParams(this.sysAdminParams);
// Check if a relative path has been specified
@@ -403,12 +416,10 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
// Get the pseudo file name and web prefix path
ConfigElement pseudoName = urlFileElem.getChild( "filename");
ConfigElement webPath = urlFileElem.getChild( "webpath");
if ( pseudoName != null && webPath != null)
if ( pseudoName != null)
{
context.setURLFileName(pseudoName.getValue());
context.setURLPrefix(webPath.getValue());
}
}

View File

@@ -134,6 +134,11 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
*/
private String repoRemoteUrl = null;
private boolean sendTestMessage = false;
private String testMessageTo = null;
private String testMessageSubject = "Test message";
private String testMessageText = "This is a test message.";
/**
* Test mode prevents email messages from being sent.
* It is used when unit testing when we don't actually want to send out email messages.
@@ -224,6 +229,43 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
this.repoRemoteUrl = repoRemoteUrl;
}
public void setTestMessageTo(String testMessageTo)
{
this.testMessageTo = testMessageTo;
}
public void setTestMessageSubject(String testMessageSubject)
{
this.testMessageSubject = testMessageSubject;
}
public void setTestMessageText(String testMessageText)
{
this.testMessageText = testMessageText;
}
public void setSendTestMessage(boolean sendTestMessage)
{
this.sendTestMessage = sendTestMessage;
}
@Override
public void init()
{
super.init();
if (sendTestMessage)
{
Map<String, Serializable> params = new HashMap<String, Serializable>();
params.put(PARAM_TO, testMessageTo);
params.put(PARAM_SUBJECT, testMessageSubject);
params.put(PARAM_TEXT, testMessageText);
Action ruleAction = serviceRegistry.getActionService().createAction(NAME, params);
executeImpl(ruleAction, null);
}
}
/**
* Initialise bean
*/
@@ -363,7 +405,12 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
// set the from address
NodeRef person = personService.getPerson(authService.getCurrentUserName());
String fromActualUser = (String)nodeService.getProperty(person, ContentModel.PROP_EMAIL);
String fromActualUser = null;
if (person != null)
{
fromActualUser = (String) nodeService.getProperty(person, ContentModel.PROP_EMAIL);
}
if( fromActualUser != null && fromActualUser.length() != 0)
{
message.setFrom(fromActualUser);

View File

@@ -48,4 +48,69 @@ public interface SysAdminParams
* @return the the maximum number of users who are allowed to log in
*/
public int getMaxUsers();
/**
* Gets Alfresco context.
*
* @return Alfresco context
*/
public String getAlfrescoContext();
/**
* Gets Alfresco host.
*
* @return Alfresco host
*/
public String getAlfrescoHost();
/**
* Gets Alfresco port.
*
* @return Alfresco port
*/
public int getAlfrescoPort();
/**
* Gets Alfresco protocole.
*
* @return Alfresco protocole
*/
public String getAlfrescoProtocol();
/**
* Gets Share context.
*
* @return Share context
*/
public String getShareContext();
/**
* Gets Share host.
*
* @return Share host
*/
public String getShareHost();
/**
* Gets Share port.
*
* @return Share port
*/
public int getSharePort();
/**
* Gets Share protocol.
*
* @return Share protocol
*/
public String getShareProtocol();
/**
* Expands the special ${localname} token within a host name using the resolved DNS name for the local host.
*
* @param hostName
* the host name
* @return the string
*/
public String subsituteHost(String hostName);
}

View File

@@ -18,6 +18,7 @@
*/
package org.alfresco.repo.admin;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
@@ -33,6 +34,12 @@ import org.springframework.context.ApplicationContextAware;
*/
public class SysAdminParamsImpl implements SysAdminParams, ApplicationContextAware, InitializingBean
{
/** Token name to substitute current servers DNS name or TCP/IP address into a host name **/
private static final String TOKEN_LOCAL_NAME = "${localname}";
/** The local server name to which the above token will expand. */
private final String localName;
/** The application context, to get license component, if installed. */
private ApplicationContext ctx;
@@ -45,6 +52,45 @@ public class SysAdminParamsImpl implements SysAdminParams, ApplicationContextAwa
/** The allow write. */
private boolean allowWrite = true;
/** Alfresco context. */
private String alfrescoContext = "alfresco";
/** Alfresco host. */
private String alfrescoHost = "localhost";
/** Alfresco port. */
private int alfrescoPort = 8080;
/** Alfresco protocol. */
private String alfrescoProtocol = "http";
/** Share context. */
private String shareContext = "alfresco";
/** Share host. */
private String shareHost = "localhost";
/** Share port. */
private int sharePort = 8080;
/** Share protocol. */
private String shareProtocol = "http";
public SysAdminParamsImpl()
{
// Establish the name of the local server so we can use it in token substitutions
String srvName = "localhost";
try
{
srvName = InetAddress.getLocalHost().getHostName();
}
catch (Exception ex)
{
srvName = "localhost";
}
localName = srvName;
}
/*
* (non-Javadoc)
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.
@@ -146,4 +192,95 @@ public class SysAdminParamsImpl implements SysAdminParams, ApplicationContextAwa
return this.allowWrite;
}
public String getAlfrescoContext()
{
return alfrescoContext;
}
public void setAlfrescoContext(String alfrescoContext)
{
this.alfrescoContext = alfrescoContext;
}
public String getAlfrescoHost()
{
return alfrescoHost;
}
public void setAlfrescoHost(String alfrescoHost)
{
this.alfrescoHost = subsituteHost(alfrescoHost);
}
public int getAlfrescoPort()
{
return alfrescoPort;
}
public void setAlfrescoPort(int alfrescoPort)
{
this.alfrescoPort = alfrescoPort;
}
public String getAlfrescoProtocol()
{
return alfrescoProtocol;
}
public void setAlfrescoProtocol(String alfrescoProtocol)
{
this.alfrescoProtocol = alfrescoProtocol;
}
public String getShareContext()
{
return shareContext;
}
public void setShareContext(String shareContext)
{
this.shareContext = shareContext;
}
public String getShareHost()
{
return shareHost;
}
public void setShareHost(String shareHost)
{
this.shareHost = subsituteHost(shareHost);
}
public int getSharePort()
{
return sharePort;
}
public void setSharePort(int sharePort)
{
this.sharePort = sharePort;
}
public String getShareProtocol()
{
return shareProtocol;
}
public void setShareProtocol(String shareProtocol)
{
this.shareProtocol = shareProtocol;
}
/**
* Expands the special ${localname} token within a host name using the resolved DNS name for the local host.
*
* @param hostName
* the host name
* @return the string
*/
public String subsituteHost(String hostName)
{
return hostName.replace(TOKEN_LOCAL_NAME, localName);
}
}

View File

@@ -19,6 +19,7 @@
package org.alfresco.repo.imap;
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
import org.alfresco.repo.admin.SysAdminParams;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationEvent;
@@ -38,15 +39,21 @@ public class AlfrescoImapServer extends AbstractLifecycleBean
private static Log logger = LogFactory.getLog(AlfrescoImapServer.class);
private ImapServer serverImpl;
private SysAdminParams sysAdminParams;
private int port = 143;
private String host = "localhost";
private ImapHostManager imapHostManager;
private UserManager imapUserManager;
private boolean imapServerEnabled;
public void setSysAdminParams(SysAdminParams sysAdminParams)
{
this.sysAdminParams = sysAdminParams;
}
public void setImapServerEnabled(boolean imapServerEnabled)
{
this.imapServerEnabled = imapServerEnabled;
@@ -57,11 +64,6 @@ public class AlfrescoImapServer extends AbstractLifecycleBean
this.port = port;
}
public void setHost(String host)
{
this.host = host;
}
public void setImapHostManager(ImapHostManager imapHostManager)
{
this.imapHostManager = imapHostManager;
@@ -88,11 +90,13 @@ public class AlfrescoImapServer extends AbstractLifecycleBean
return imapUserManager;
}
};
serverImpl = new ImapServer(new ServerSetup(port, host, ServerSetup.PROTOCOL_IMAP), imapManagers);
String currentHost = sysAdminParams.getAlfrescoHost();
serverImpl = new ImapServer(new ServerSetup(port, currentHost, ServerSetup.PROTOCOL_IMAP), imapManagers);
serverImpl.startService(null);
if (logger.isInfoEnabled())
{
logger.info("IMAP service started on host:port " + this.host + ":" + this.port + ".");
logger.info("IMAP service started on host:port " + currentHost + ":" + this.port + ".");
}
}
else

View File

@@ -36,6 +36,7 @@ import org.alfresco.error.AlfrescoRuntimeException;
import org.springframework.extensions.surf.util.I18NUtil;
import org.alfresco.model.ContentModel;
import org.alfresco.model.ImapModel;
import org.alfresco.repo.admin.SysAdminParams;
import org.alfresco.repo.imap.AlfrescoImapConst.ImapViewMode;
import org.alfresco.repo.imap.config.ImapConfigMountPointsBean;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
@@ -76,6 +77,7 @@ public class ImapServiceImpl implements ImapService
private static final String ERROR_MAILBOX_NAME_IS_MANDATORY = "imap.server.error.mailbox_name_is_mandatory";
private static final String ERROR_CANNOT_GET_A_FOLDER = "imap.server.error.cannot_get_a_folder";
private SysAdminParams sysAdminParams;
private FileFolderService fileFolderService;
private NodeService nodeService;
private ServiceRegistry serviceRegistry;
@@ -88,7 +90,6 @@ public class ImapServiceImpl implements ImapService
private Set<NodeRef> ignoreExtractionFolders;
private String defaultFromAddress;
private String webApplicationContextUrl = "http://localhost:8080/alfresco";
private String repositoryTemplatePath;
private boolean extractAttachmentsEnabled = true;
@@ -154,6 +155,11 @@ public class ImapServiceImpl implements ImapService
}
}
public void setSysAdminParams(SysAdminParams sysAdminParams)
{
this.sysAdminParams = sysAdminParams;
}
public FileFolderService getFileFolderService()
{
return fileFolderService;
@@ -201,12 +207,7 @@ public class ImapServiceImpl implements ImapService
public String getWebApplicationContextUrl()
{
return webApplicationContextUrl;
}
public void setWebApplicationContextUrl(String webApplicationContextUrl)
{
this.webApplicationContextUrl = webApplicationContextUrl;
return sysAdminParams.getAlfrescoProtocol() + "://" + sysAdminParams.getAlfrescoHost() + ":" + sysAdminParams.getAlfrescoPort() + "/" + sysAdminParams.getAlfrescoContext();
}
public String getRepositoryTemplatePath()

View File

@@ -62,6 +62,9 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
/** The category (first part of the ID). */
private String category;
/** The bean name if we have been initialized by Spring. */
private String beanName;
/** The hierarchical instance path within the category (second part of the ID). */
private List<String> instancePath = Collections.singletonList(AbstractPropertyBackedBean.DEFAULT_INSTANCE_NAME);
@@ -120,7 +123,18 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
*/
public void setBeanName(String name)
{
this.category = name;
this.beanName = name;
}
/**
* Sets the category (first part of the ID).
*
* @param category
* the category
*/
public void setCategory(String category)
{
this.category = category;
}
/**
@@ -214,10 +228,20 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
*/
public void afterPropertiesSet() throws Exception
{
// Default the category to the bean name
if (this.category == null)
{
if (this.beanName == null)
{
throw new IllegalStateException("Category not provided");
}
this.category = this.beanName;
}
// Derive the unique ID from the category and instance path
List<String> path = getInstancePath();
this.id = new ArrayList<String>(path.size() + 1);
this.id.add(getCategory());
this.id.add(this.category);
this.id.addAll(getInstancePath());
init();

View File

@@ -178,7 +178,7 @@ public class ChildApplicationContextFactory extends AbstractPropertyBackedBean i
setApplicationContext(parent);
setRegistry(registry);
setPropertyDefaults(propertyDefaults);
setBeanName(category);
setCategory(category);
setTypeName(typeName);
setInstancePath(instancePath);

View File

@@ -87,7 +87,7 @@ public class CompositeDataBean extends AbstractPropertyBackedBean
setApplicationContext(parent);
setRegistry(registry);
setPropertyDefaults(propertyDefaults);
setBeanName(category);
setCategory(category);
setInstancePath(instancePath);
this.owner = owner;
this.type = type;