mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
57143: Merged V4.2-BUG-FIX (4.2.1) to HEAD-BUG-FIX (Cloud/4.3) 56926: Merged V4.1-BUG-FIX (4.1.7) to V4.2-BUG-FIX (4.2.1) 56869: MNT-9543: Folder path on IMAP does work when configured with outlook Call isNodeInSitesLibrary() and getPathFromSites() on behalf of SystemUser to avoid AccessDeniedException in case when repository folder from another site was mapped to user's IMAP folder git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@61768 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -31,16 +31,13 @@ import javax.mail.MessagingException;
|
|||||||
import javax.mail.Session;
|
import javax.mail.Session;
|
||||||
import javax.mail.internet.MimeMessage;
|
import javax.mail.internet.MimeMessage;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
|
||||||
import org.alfresco.repo.imap.ImapService.EmailBodyFormat;
|
import org.alfresco.repo.imap.ImapService.EmailBodyFormat;
|
||||||
import org.alfresco.repo.site.SiteModel;
|
|
||||||
import org.alfresco.repo.template.TemplateNode;
|
import org.alfresco.repo.template.TemplateNode;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.model.FileInfo;
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
@@ -193,7 +190,7 @@ public abstract class AbstractMimeMessage extends MimeMessage
|
|||||||
model.put("alfTicket", new String(serviceRegistry.getAuthenticationService().getCurrentTicket()));
|
model.put("alfTicket", new String(serviceRegistry.getAuthenticationService().getCurrentTicket()));
|
||||||
if (isMessageInSitesLibrary)
|
if (isMessageInSitesLibrary)
|
||||||
{
|
{
|
||||||
String pathFromSites = getPathFromSites(parent);
|
String pathFromSites = imapService.getPathFromSites(parent);
|
||||||
StringBuilder parsedPath = new StringBuilder();
|
StringBuilder parsedPath = new StringBuilder();
|
||||||
String[] pathParts = pathFromSites.split("/");
|
String[] pathParts = pathFromSites.split("/");
|
||||||
if (pathParts.length > 2)
|
if (pathParts.length > 2)
|
||||||
@@ -216,21 +213,6 @@ public abstract class AbstractMimeMessage extends MimeMessage
|
|||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPathFromSites(NodeRef ref)
|
|
||||||
{
|
|
||||||
NodeService nodeService = serviceRegistry.getNodeService();
|
|
||||||
String name = ((String) nodeService.getProperty(ref, ContentModel.PROP_NAME)).toLowerCase();
|
|
||||||
if (nodeService.getType(ref).equals(SiteModel.TYPE_SITE))
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NodeRef parent = nodeService.getPrimaryParent(ref).getParentRef();
|
|
||||||
return getPathFromSites(parent) + "/" + name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updateMessageID() throws MessagingException
|
protected void updateMessageID() throws MessagingException
|
||||||
{
|
{
|
||||||
setHeader("Message-ID", "<" + this.messageFileInfo.getNodeRef().getId() + DEFAULT_SUFFIX + ">");
|
setHeader("Message-ID", "<" + this.messageFileInfo.getNodeRef().getId() + DEFAULT_SUFFIX + ">");
|
||||||
|
@@ -333,4 +333,10 @@ public interface ImapService
|
|||||||
this.search = search;
|
this.search = search;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param nodeRef
|
||||||
|
* @return path for node relatively to site root
|
||||||
|
*/
|
||||||
|
public String getPathFromSites(NodeRef nodeRef);
|
||||||
}
|
}
|
||||||
|
@@ -1902,31 +1902,40 @@ public class ImapServiceImpl implements ImapService, OnRestoreNodePolicy, OnCrea
|
|||||||
/**
|
/**
|
||||||
* Return true if provided nodeRef is in Sites/.../documentlibrary
|
* Return true if provided nodeRef is in Sites/.../documentlibrary
|
||||||
*/
|
*/
|
||||||
public boolean isNodeInSitesLibrary(NodeRef nodeRef)
|
public boolean isNodeInSitesLibrary(final NodeRef inputNodeRef)
|
||||||
{
|
{
|
||||||
boolean isInDocLibrary = false;
|
return doAsSystem(new RunAsWork<Boolean>()
|
||||||
NodeRef parent = nodeService.getPrimaryParent(nodeRef).getParentRef();
|
|
||||||
while (parent != null && !nodeService.getType(parent).equals(SiteModel.TYPE_SITE))
|
|
||||||
{
|
{
|
||||||
String parentName = (String) nodeService.getProperty(parent, ContentModel.PROP_NAME);
|
@Override
|
||||||
if (parentName.equalsIgnoreCase("documentlibrary"))
|
public Boolean doWork() throws Exception
|
||||||
{
|
{
|
||||||
isInDocLibrary = true;
|
NodeRef nodeRef = inputNodeRef;
|
||||||
|
boolean isInDocLibrary = false;
|
||||||
|
NodeRef parent = nodeService.getPrimaryParent(nodeRef).getParentRef();
|
||||||
|
while (parent != null && !nodeService.getType(parent).equals(SiteModel.TYPE_SITE))
|
||||||
|
{
|
||||||
|
String parentName = (String) nodeService.getProperty(parent, ContentModel.PROP_NAME);
|
||||||
|
if (parentName.equalsIgnoreCase("documentlibrary"))
|
||||||
|
{
|
||||||
|
isInDocLibrary = true;
|
||||||
|
}
|
||||||
|
nodeRef = parent;
|
||||||
|
if (nodeService.getPrimaryParent(nodeRef) != null)
|
||||||
|
{
|
||||||
|
parent = nodeService.getPrimaryParent(nodeRef).getParentRef();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (parent == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return nodeService.getType(parent).equals(SiteModel.TYPE_SITE) && isInDocLibrary;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
nodeRef = parent;
|
});
|
||||||
if (nodeService.getPrimaryParent(nodeRef) != null)
|
|
||||||
{
|
|
||||||
parent = nodeService.getPrimaryParent(nodeRef).getParentRef();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (parent == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return nodeService.getType(parent).equals(SiteModel.TYPE_SITE) && isInDocLibrary;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNamespaceService(NamespaceService namespaceService)
|
public void setNamespaceService(NamespaceService namespaceService)
|
||||||
@@ -2008,4 +2017,27 @@ public class ImapServiceImpl implements ImapService, OnRestoreNodePolicy, OnCrea
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPathFromSites(final NodeRef ref)
|
||||||
|
{
|
||||||
|
return doAsSystem(new RunAsWork<String>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public String doWork() throws Exception
|
||||||
|
{
|
||||||
|
String name = ((String) nodeService.getProperty(ref, ContentModel.PROP_NAME)).toLowerCase();
|
||||||
|
if (nodeService.getType(ref).equals(SiteModel.TYPE_SITE))
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NodeRef parent = nodeService.getPrimaryParent(ref).getParentRef();
|
||||||
|
return getPathFromSites(parent) + "/" + name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user