mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-11426 : IMAP subsystem is dependent on search
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31907 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -111,6 +111,12 @@
|
|||||||
<property name="policyFilter">
|
<property name="policyFilter">
|
||||||
<ref bean="policyBehaviourFilter"/>
|
<ref bean="policyBehaviourFilter"/>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="namespaceService">
|
||||||
|
<ref bean="namespaceService"/>
|
||||||
|
</property>
|
||||||
|
<property name="searchService">
|
||||||
|
<ref bean="SearchService"/>
|
||||||
|
</property>
|
||||||
<property name="imapConfigMountPoints">
|
<property name="imapConfigMountPoints">
|
||||||
<ref bean="imap.config.server.mountPoints" />
|
<ref bean="imap.config.server.mountPoints" />
|
||||||
</property>
|
</property>
|
||||||
|
@@ -46,7 +46,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|||||||
import javax.mail.Flags;
|
import javax.mail.Flags;
|
||||||
import javax.mail.MessagingException;
|
import javax.mail.MessagingException;
|
||||||
import javax.mail.Flags.Flag;
|
import javax.mail.Flags.Flag;
|
||||||
import javax.mail.MessagingException;
|
|
||||||
import javax.mail.Multipart;
|
import javax.mail.Multipart;
|
||||||
import javax.mail.Part;
|
import javax.mail.Part;
|
||||||
import javax.mail.internet.ContentType;
|
import javax.mail.internet.ContentType;
|
||||||
@@ -92,7 +91,6 @@ import org.alfresco.service.cmr.repository.MimetypeService;
|
|||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
import org.alfresco.service.cmr.search.ResultSet;
|
|
||||||
import org.alfresco.service.cmr.search.SearchService;
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
import org.alfresco.service.cmr.security.AccessStatus;
|
import org.alfresco.service.cmr.security.AccessStatus;
|
||||||
import org.alfresco.service.cmr.security.PermissionService;
|
import org.alfresco.service.cmr.security.PermissionService;
|
||||||
@@ -140,6 +138,8 @@ public class ImapServiceImpl implements ImapService, OnCreateChildAssociationPol
|
|||||||
private ServiceRegistry serviceRegistry;
|
private ServiceRegistry serviceRegistry;
|
||||||
private BehaviourFilter policyBehaviourFilter;
|
private BehaviourFilter policyBehaviourFilter;
|
||||||
private MimetypeService mimetypeService;
|
private MimetypeService mimetypeService;
|
||||||
|
private NamespaceService namespaceService;
|
||||||
|
private SearchService searchService;
|
||||||
|
|
||||||
// Note that this cache need not be cluster synchronized, as it is keyed by the cluster-safe change token
|
// Note that this cache need not be cluster synchronized, as it is keyed by the cluster-safe change token
|
||||||
private Map<Pair<String, String>, FolderStatus> folderCache;
|
private Map<Pair<String, String>, FolderStatus> folderCache;
|
||||||
@@ -150,8 +150,6 @@ public class ImapServiceImpl implements ImapService, OnCreateChildAssociationPol
|
|||||||
private RepositoryFolderConfigBean[] ignoreExtractionFoldersBeans;
|
private RepositoryFolderConfigBean[] ignoreExtractionFoldersBeans;
|
||||||
private RepositoryFolderConfigBean imapHomeConfigBean;
|
private RepositoryFolderConfigBean imapHomeConfigBean;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private NodeRef imapHomeNodeRef;
|
private NodeRef imapHomeNodeRef;
|
||||||
private Set<NodeRef> ignoreExtractionFolders;
|
private Set<NodeRef> ignoreExtractionFolders;
|
||||||
|
|
||||||
@@ -361,6 +359,8 @@ public class ImapServiceImpl implements ImapService, OnCreateChildAssociationPol
|
|||||||
PropertyCheck.mandatory(this, "repositoryTemplatePath", repositoryTemplatePath);
|
PropertyCheck.mandatory(this, "repositoryTemplatePath", repositoryTemplatePath);
|
||||||
PropertyCheck.mandatory(this, "policyBehaviourFilter", policyBehaviourFilter);
|
PropertyCheck.mandatory(this, "policyBehaviourFilter", policyBehaviourFilter);
|
||||||
PropertyCheck.mandatory(this, "mimetypeService", mimetypeService);
|
PropertyCheck.mandatory(this, "mimetypeService", mimetypeService);
|
||||||
|
PropertyCheck.mandatory(this, "namespaceService", namespaceService);
|
||||||
|
PropertyCheck.mandatory(this, "searchService", getSearchService());
|
||||||
this.folderCache = new MaxSizeMap<Pair<String,String>, FolderStatus>(folderCacheSize, false);
|
this.folderCache = new MaxSizeMap<Pair<String,String>, FolderStatus>(folderCacheSize, false);
|
||||||
|
|
||||||
// be sure that a default e-mail is correct
|
// be sure that a default e-mail is correct
|
||||||
@@ -394,9 +394,6 @@ public class ImapServiceImpl implements ImapService, OnCreateChildAssociationPol
|
|||||||
{
|
{
|
||||||
bindBehaviour();
|
bindBehaviour();
|
||||||
|
|
||||||
final NamespaceService namespaceService = serviceRegistry.getNamespaceService();
|
|
||||||
final SearchService searchService = serviceRegistry.getSearchService();
|
|
||||||
|
|
||||||
// Get NodeRefs for folders to ignore
|
// Get NodeRefs for folders to ignore
|
||||||
this.ignoreExtractionFolders = new HashSet<NodeRef>(ignoreExtractionFoldersBeans.length * 2);
|
this.ignoreExtractionFolders = new HashSet<NodeRef>(ignoreExtractionFoldersBeans.length * 2);
|
||||||
|
|
||||||
@@ -561,7 +558,7 @@ public class ImapServiceImpl implements ImapService, OnCreateChildAssociationPol
|
|||||||
ImapConfigMountPointsBean imapConfigMountPoint = this.imapConfigMountPoints.get(rootPath);
|
ImapConfigMountPointsBean imapConfigMountPoint = this.imapConfigMountPoints.get(rootPath);
|
||||||
if (imapConfigMountPoint != null)
|
if (imapConfigMountPoint != null)
|
||||||
{
|
{
|
||||||
root = imapConfigMountPoint.getFolderPath(serviceRegistry.getNamespaceService(), nodeService, serviceRegistry.getSearchService(), fileFolderService);
|
root = imapConfigMountPoint.getFolderPath(serviceRegistry.getNamespaceService(), nodeService, searchService, fileFolderService);
|
||||||
pathElements = Arrays.asList(mailboxName.substring(index + 1).split(
|
pathElements = Arrays.asList(mailboxName.substring(index + 1).split(
|
||||||
String.valueOf(AlfrescoImapConst.HIERARCHY_DELIMITER)));
|
String.valueOf(AlfrescoImapConst.HIERARCHY_DELIMITER)));
|
||||||
viewMode = imapConfigMountPoint.getMode();
|
viewMode = imapConfigMountPoint.getMode();
|
||||||
@@ -1109,8 +1106,6 @@ public class ImapServiceImpl implements ImapService, OnCreateChildAssociationPol
|
|||||||
*/
|
*/
|
||||||
private NodeRef getMountPoint(String rootFolder)
|
private NodeRef getMountPoint(String rootFolder)
|
||||||
{
|
{
|
||||||
final NamespaceService namespaceService = serviceRegistry.getNamespaceService();
|
|
||||||
final SearchService searchService = serviceRegistry.getSearchService();
|
|
||||||
final ImapConfigMountPointsBean config = imapConfigMountPoints.get(rootFolder);
|
final ImapConfigMountPointsBean config = imapConfigMountPoints.get(rootFolder);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -1395,8 +1390,11 @@ public class ImapServiceImpl implements ImapService, OnCreateChildAssociationPol
|
|||||||
logger.debug("[getDefaultEmailBodyTemplate] Query: " + query);
|
logger.debug("[getDefaultEmailBodyTemplate] Query: " + query);
|
||||||
}
|
}
|
||||||
StoreRef storeRef = new StoreRef(storePath);
|
StoreRef storeRef = new StoreRef(storePath);
|
||||||
ResultSet resultSet = serviceRegistry.getSearchService().query(storeRef, "xpath", query);
|
|
||||||
if (resultSet == null || resultSet.length() == 0)
|
NodeRef rootNode = nodeService.getRootNode(storeRef);
|
||||||
|
|
||||||
|
List<NodeRef> templates = searchService.selectNodes(rootNode, query, null, namespaceService, true);
|
||||||
|
if (templates == null || templates.size() == 0)
|
||||||
{
|
{
|
||||||
if(logger.isDebugEnabled())
|
if(logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
@@ -1404,18 +1402,29 @@ public class ImapServiceImpl implements ImapService, OnCreateChildAssociationPol
|
|||||||
}
|
}
|
||||||
throw new AlfrescoRuntimeException(String.format("[getDefaultEmailBodyTemplate] IMAP message template '%1$s' does not exist in the path '%2$s'.", templateName, repositoryTemplatePath));
|
throw new AlfrescoRuntimeException(String.format("[getDefaultEmailBodyTemplate] IMAP message template '%1$s' does not exist in the path '%2$s'.", templateName, repositoryTemplatePath));
|
||||||
}
|
}
|
||||||
final NodeRef defaultLocaleTemplate = resultSet.getNodeRef(0);
|
final NodeRef defaultLocaleTemplate = templates.get(0);
|
||||||
|
|
||||||
|
// ResultSet resultSet = serviceRegistry.getSearchService().query(storeRef, "xpath", query);
|
||||||
|
// if (resultSet == null || resultSet.length() == 0)
|
||||||
|
// {
|
||||||
|
// if(logger.isDebugEnabled())
|
||||||
|
// {
|
||||||
|
// logger.debug("template not found:" + templateName);
|
||||||
|
// }
|
||||||
|
// throw new AlfrescoRuntimeException(String.format("[getDefaultEmailBodyTemplate] IMAP message template '%1$s' does not exist in the path '%2$s'.", templateName, repositoryTemplatePath));
|
||||||
|
// }
|
||||||
|
// final NodeRef defaultLocaleTemplate = resultSet.getNodeRef(0);
|
||||||
|
//
|
||||||
NodeRef localisedSibling = serviceRegistry.getFileFolderService().getLocalizedSibling(defaultLocaleTemplate);
|
NodeRef localisedSibling = serviceRegistry.getFileFolderService().getLocalizedSibling(defaultLocaleTemplate);
|
||||||
|
//
|
||||||
result = localisedSibling.toString();
|
result = localisedSibling.toString();
|
||||||
|
//
|
||||||
resultSet.close();
|
// resultSet.close();
|
||||||
}
|
}
|
||||||
// We are catching all exceptions. E.g. search service can possibly throw an exceptions on malformed queries.
|
// We are catching all exceptions. E.g. search service can possibly throw an exceptions on malformed queries.
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
logger.error("[getDefaultEmailBodyTemplate]", e);
|
logger.error("ImapServiceImpl [getDefaultEmailBodyTemplate]", e);
|
||||||
}
|
}
|
||||||
defaultBodyTemplates.put(onetype, result);
|
defaultBodyTemplates.put(onetype, result);
|
||||||
}
|
}
|
||||||
@@ -1867,6 +1876,26 @@ public class ImapServiceImpl implements ImapService, OnCreateChildAssociationPol
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setNamespaceService(NamespaceService namespaceService)
|
||||||
|
{
|
||||||
|
this.namespaceService = namespaceService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespaceService getNamespaceService()
|
||||||
|
{
|
||||||
|
return namespaceService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSearchService(SearchService searchService)
|
||||||
|
{
|
||||||
|
this.searchService = searchService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SearchService getSearchService()
|
||||||
|
{
|
||||||
|
return searchService;
|
||||||
|
}
|
||||||
|
|
||||||
static class CacheItem
|
static class CacheItem
|
||||||
{
|
{
|
||||||
private Date modified;
|
private Date modified;
|
||||||
|
Reference in New Issue
Block a user