diff --git a/config/alfresco/web-client-application-context.xml b/config/alfresco/web-client-application-context.xml
index e51a3f83ec..75b67afa7c 100644
--- a/config/alfresco/web-client-application-context.xml
+++ b/config/alfresco/web-client-application-context.xml
@@ -24,6 +24,7 @@
classpath:alfresco/extension/web-client-config-custom.xml
jar:*!/META-INF/web-client-config-custom.xml
workspace://SpacesStore/${spaces.company_home.childname}/${spaces.dictionary.childname}/app:webclient_extension/cm:web-client-config-custom.xml
+ workspace://SpacesStore/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.imapConfig.childname}/cm:imap-config.xml
diff --git a/config/alfresco/web-client-config.xml b/config/alfresco/web-client-config.xml
index f85fb9cabd..4c3f1b5574 100644
--- a/config/alfresco/web-client-config.xml
+++ b/config/alfresco/web-client-config.xml
@@ -19,6 +19,7 @@
+
diff --git a/source/java/org/alfresco/web/bean/users/CreateUserWizard.java b/source/java/org/alfresco/web/bean/users/CreateUserWizard.java
index ebf004e56e..2b4c7b9206 100644
--- a/source/java/org/alfresco/web/bean/users/CreateUserWizard.java
+++ b/source/java/org/alfresco/web/bean/users/CreateUserWizard.java
@@ -40,6 +40,8 @@ import javax.faces.validator.ValidatorException;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
+import org.alfresco.repo.imap.AlfrescoImapConst;
+import org.alfresco.repo.imap.ImapHelper;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -50,6 +52,7 @@ import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.usage.ContentUsageService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
+import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.util.Pair;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.context.UIContextService;
@@ -114,7 +117,9 @@ public class CreateUserWizard extends BaseWizardBean
/** OwnableService bean reference */
transient private OwnableService ownableService;
-
+
+ transient private ImapHelper imapHelper;
+
/** ContentUsageService bean reference */
transient private ContentUsageService contentUsageService;
@@ -165,6 +170,21 @@ public class CreateUserWizard extends BaseWizardBean
return personService;
}
+ public ImapHelper getImapHelper()
+ {
+ if (imapHelper == null)
+ {
+ imapHelper = (ImapHelper) ApplicationContextHelper.getApplicationContext().getBean("imapHelper");
+ }
+
+ return imapHelper;
+ }
+
+ public void setImapHelper(ImapHelper imapHelper)
+ {
+ this.imapHelper = imapHelper;
+ }
+
/**
* @param tenantService The tenantService to set.
*/
@@ -772,6 +792,29 @@ public class CreateUserWizard extends BaseWizardBean
getPermissionService().setInheritParentPermissions(homeSpaceRef, false);
}
+ private void createImapHome()
+ {
+ NodeRef imapRoot = imapHelper.getImapRootNodeRef();
+ NodeRef imapUserHome = null;
+
+ // search IMAP user home
+ imapUserHome = this.getFileFolderService().searchSimple(imapRoot, userName);
+ if (imapUserHome == null)
+ {
+ // create IMAP user home
+ imapUserHome = this.getFileFolderService().create(imapRoot, userName, ContentModel.TYPE_FOLDER).getNodeRef();
+ }
+
+ // search INBOX
+ NodeRef inbox = this.getFileFolderService().searchSimple(imapUserHome, AlfrescoImapConst.INBOX_NAME);
+ if (inbox == null)
+ {
+ // create IMAP user home
+ inbox = this.getFileFolderService().create(imapUserHome, AlfrescoImapConst.INBOX_NAME, ContentModel.TYPE_FOLDER).getNodeRef();
+ }
+ setupHomeSpacePermissions(imapUserHome);
+ }
+
/**
* @return default permission string to set for other users for a new Home Space
*/
@@ -831,6 +874,12 @@ public class CreateUserWizard extends BaseWizardBean
// default to Company Home
homeSpaceNodeRef = getCompanyHomeSpace();
}
+ // Create IMAP user Home
+ if (imapHelper.isPatchApplied())
+ {
+ createImapHome();
+ }
+
props.put(ContentModel.PROP_HOMEFOLDER, homeSpaceNodeRef);
props.put(ContentModel.PROP_EMAIL, this.email);
props.put(ContentModel.PROP_ORGID, this.companyId);
diff --git a/source/java/org/alfresco/web/bean/wizard/NewUserWizard.java b/source/java/org/alfresco/web/bean/wizard/NewUserWizard.java
index 91553e8884..c31e64c0c3 100644
--- a/source/java/org/alfresco/web/bean/wizard/NewUserWizard.java
+++ b/source/java/org/alfresco/web/bean/wizard/NewUserWizard.java
@@ -43,6 +43,8 @@ import javax.transaction.UserTransaction;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
+import org.alfresco.repo.imap.AlfrescoImapConst;
+import org.alfresco.repo.imap.ImapHelper;
import org.alfresco.repo.security.authentication.AuthenticationException;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
@@ -54,6 +56,7 @@ import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
+import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.context.UIContextService;
import org.alfresco.web.bean.repository.Node;
@@ -120,11 +123,14 @@ public class NewUserWizard extends AbstractWizardBean
/** action context */
private Node person = null;
- /** ref to the company home space folder */
- private NodeRef companyHomeSpaceRef = null;
+ /** ImapHelper bean reference */
+ transient private ImapHelper imapHelper;
/** ref to the default home location */
private NodeRef defaultHomeSpaceRef;
+
+ /** ref to the company home space folder */
+ private NodeRef companyHomeSpaceRef = null;
/**
@@ -308,12 +314,27 @@ public class NewUserWizard extends AbstractWizardBean
}
}
- /**
- * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepTitle()
- */
- public String getStepTitle()
- {
- String stepTitle = null;
+ public ImapHelper getImapHelper()
+ {
+ if (imapHelper == null)
+ {
+ imapHelper = (ImapHelper) ApplicationContextHelper.getApplicationContext().getBean("imapHelper");
+ }
+
+ return imapHelper;
+ }
+
+ public void setImapHelper(ImapHelper imapHelper)
+ {
+ this.imapHelper = imapHelper;
+ }
+
+ /**
+ * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepTitle()
+ */
+ public String getStepTitle()
+ {
+ String stepTitle = null;
switch (this.currentStep)
{
@@ -603,6 +624,11 @@ public class NewUserWizard extends AbstractWizardBean
// create the ACEGI Authentication instance for the new user
this.getAuthenticationService().createAuthentication(this.userName, this.password.toCharArray());
+ // create IMAP home for this user
+ if (imapHelper.isPatchApplied())
+ {
+ createImapHome();
+ }
if (logger.isDebugEnabled()) logger.debug("Created User Authentication instance for username: " + this.userName);
}
@@ -1086,6 +1112,32 @@ public class NewUserWizard extends AbstractWizardBean
return config.getHomeSpacePermission();
}
+ private void createImapHome()
+ {
+ NodeRef imapRoot = imapHelper.getImapRootNodeRef();
+ NodeRef imapUserHome = null;
+ NodeRef inbox = null;
+
+ // search IMAP user home
+ imapUserHome = this.getFileFolderService().searchSimple(imapRoot, userName);
+ if (imapUserHome == null)
+ {
+ // create IMAP user home
+ imapUserHome = this.getFileFolderService().create(imapRoot, userName, ContentModel.TYPE_FOLDER).getNodeRef();
+ }
+
+ // search INBOX
+ inbox = this.getFileFolderService().searchSimple(imapUserHome, AlfrescoImapConst.INBOX_NAME);
+ if (inbox == null)
+ {
+ // create IMAP user home
+ inbox = this.getFileFolderService().create(imapUserHome, AlfrescoImapConst.INBOX_NAME, ContentModel.TYPE_FOLDER).getNodeRef();
+ }
+ setupHomeSpacePermissions(imapUserHome);
+
+ }
+
+
private void invalidateUserList()
{
UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml
index 1dbdcc7368..11582453d0 100644
--- a/source/web/WEB-INF/faces-config-beans.xml
+++ b/source/web/WEB-INF/faces-config-beans.xml
@@ -1193,6 +1193,10 @@
tenantService
#{tenantService}
+
+ imapHelper
+ #{imapHelper}
+
@@ -4960,6 +4964,10 @@
contentUsageService
#{ContentUsageService}
+
+ imapHelper
+ #{imapHelper}
+