MOB-820: IMAP as configurable subsystem + MOB-817: NFS RPC user mappings + MOB-816: File server domain and global ACL mappings

- JLAN changes: revert previous changes and make AccessControl constructors public

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14353 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2009-05-18 15:42:47 +00:00
parent b58bd8a5ea
commit 4634d889c8
29 changed files with 1235 additions and 595 deletions

View File

@@ -33,7 +33,7 @@ import java.util.StringTokenizer;
import org.alfresco.model.ContentModel;
import org.alfresco.model.ImapModel;
import org.alfresco.repo.imap.config.ImapConfigElement.ImapConfig;
import org.alfresco.repo.imap.config.ImapConfigBean;
import org.alfresco.repo.imap.exception.AlfrescoImapFolderException;
import org.alfresco.repo.model.filefolder.FileFolderServiceImpl;
import org.alfresco.service.ServiceRegistry;
@@ -139,7 +139,7 @@ public class AlfrescoImapHostManager implements ImapHostManager
Collection<MailFolder> result = new LinkedList<MailFolder>();
Map<String, NodeRef> mountPoints = imapHelper.getMountPoints();
Map<String, ImapConfig> imapConfigs = imapHelper.getImapConfigs();
Map<String, ImapConfigBean> imapConfigs = imapHelper.getImapConfig();
NodeRef mountPoint;

View File

@@ -29,8 +29,10 @@ import static org.alfresco.repo.imap.AlfrescoImapConst.CLASSPATH_TEXT_PLAIN_TEMP
import static org.alfresco.repo.imap.AlfrescoImapConst.DICTIONARY_TEMPLATE_PREFIX;
import java.io.Serializable;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -38,18 +40,13 @@ import java.util.Map;
import javax.mail.Flags;
import javax.mail.Flags.Flag;
import org.alfresco.config.Config;
import org.alfresco.config.ConfigService;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.model.ImapModel;
import org.alfresco.repo.admin.patch.PatchInfo;
import org.alfresco.repo.admin.patch.PatchService;
import org.alfresco.repo.imap.config.ImapConfigElement;
import org.alfresco.repo.imap.config.ImapConfigElement.ImapConfig;
import org.alfresco.repo.imap.config.ImapConfigBean;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.repo.template.TemplateNode;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.dictionary.DictionaryService;
@@ -64,6 +61,8 @@ import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.AbstractLifecycleBean;
@@ -72,8 +71,9 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationEvent;
/**
* Helper class to access repository services by IMAP components. Also contains a common helper methods to search and manage IMAP content and other usefull methods. Configured as
* {@code <bean id="imapHelper" class="org.alfresco.repo.imap.ImapHelper">} in the {@code imap-server-context.xml} file.
* Helper class to access repository services by IMAP components. Also contains a common helper methods to search and
* manage IMAP content and other usefull methods. Configured as {@code <bean id="imapHelper"
* class="org.alfresco.repo.imap.ImapHelper">} in the {@code imap-server-context.xml} file.
*
* @author Dmitry Vaserin
*/
@@ -89,7 +89,6 @@ import org.springframework.context.ApplicationEvent;
private TemplateService templateService;
private NamespaceService namespaceService;
private PermissionService permissionService;
private ConfigService configService;
private DictionaryService dictionaryService;
private PreferenceService preferenceService;
private SiteService siteService;
@@ -111,6 +110,8 @@ import org.springframework.context.ApplicationEvent;
private final static Map<QName, Flags.Flag> qNameToFlag;
private final static Map<Flags.Flag, QName> flagToQname;
private Map<String, ImapConfigBean> imapConfigBeans = Collections.emptyMap();
static
{
qNameToFlag = new HashMap<QName, Flags.Flag>();
@@ -370,7 +371,7 @@ import org.springframework.context.ApplicationEvent;
rootFolder = mailboxName;
}
Map<String, ImapConfig> imapConfigs = getImapConfigs();
Map<String, ImapConfigBean> imapConfigs = getImapConfig();
if (imapConfigs.keySet().contains(rootFolder))
{
Map<String, NodeRef> mountPoints = getMountPoints();
@@ -620,10 +621,10 @@ import org.springframework.context.ApplicationEvent;
*/
public Map<String, NodeRef> getMountPoints()
{
Map<String, ImapConfig> imapConfigs = getImapConfigs();
Map<String, ImapConfigBean> imapConfigs = getImapConfig();
Map<String, NodeRef> mountPoints = new HashMap<String, NodeRef>();
for (ImapConfig config : imapConfigs.values())
for (ImapConfigBean config : imapConfigs.values())
{
// Get node reference
StoreRef store = new StoreRef(config.getStore());
@@ -642,16 +643,23 @@ import org.springframework.context.ApplicationEvent;
return mountPoints;
}
public void setImapConfigBeans(ImapConfigBean[] imapConfigBeans)
{
this.imapConfigBeans = new LinkedHashMap<String, ImapConfigBean>(imapConfigBeans.length * 2);
for (ImapConfigBean bean : imapConfigBeans)
{
this.imapConfigBeans.put(bean.getName(), bean);
}
}
/**
* Return map of imap configs. Name of config == key in the map
*
* @return map of imap configs.
*/
public Map<String, ImapConfig> getImapConfigs()
public Map<String, ImapConfigBean> getImapConfig()
{
Config imapConfig = configService.getConfig("imapConfig");
ImapConfigElement imapConfigElement = (ImapConfigElement) imapConfig.getConfigElement(ImapConfigElement.CONFIG_ELEMENT_ID);
return imapConfigElement.getImapConfigs();
return this.imapConfigBeans;
}
/**
@@ -672,7 +680,7 @@ import org.springframework.context.ApplicationEvent;
{
rootFolder = mailboxName;
}
Map<String, ImapConfig> imapConfigs = getImapConfigs();
Map<String, ImapConfigBean> imapConfigs = getImapConfig();
if (imapConfigs.keySet().contains(rootFolder))
{
return imapConfigs.get(rootFolder).getMode();
@@ -701,7 +709,7 @@ import org.springframework.context.ApplicationEvent;
{
rootFolder = mailboxName;
}
Map<String, ImapConfig> imapConfigs = getImapConfigs();
Map<String, ImapConfigBean> imapConfigs = getImapConfig();
if (imapConfigs.keySet().contains(rootFolder))
{
return rootFolder;
@@ -734,7 +742,7 @@ import org.springframework.context.ApplicationEvent;
{
rootFolder = mailPath;
}
Map<String, ImapConfig> imapConfigs = getImapConfigs();
Map<String, ImapConfigBean> imapConfigs = getImapConfig();
if (imapConfigs.keySet().contains(rootFolder))
{
Map<String, NodeRef> mountPoints = getMountPoints();
@@ -933,16 +941,6 @@ import org.springframework.context.ApplicationEvent;
this.permissionService = permissionService;
}
public ConfigService getConfigService()
{
return configService;
}
public void setConfigService(ConfigService configService)
{
this.configService = configService;
}
public DictionaryService getDictionaryService()
{
return dictionaryService;

View File

@@ -0,0 +1,129 @@
/*
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.repo.imap.config;
import org.springframework.beans.factory.BeanNameAware;
/**
* Provides the parameters for an IMAP mount point (a mapping from an Alfresco node path to an IMAP folder name).
*/
public class ImapConfigBean implements BeanNameAware
{
/** The IMAP folder name. */
private String name;
/** The mode (virtual or archive). */
private String mode;
/** The Alfresco store name. */
private String store;
/** The path within the store to the root node. */
private String rootPath;
/**
* Gets the IMAP folder name.
*
* @return the IMAP folder name
*/
public String getName()
{
return this.name;
}
/*
* (non-Javadoc)
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
*/
public void setBeanName(String name)
{
this.name = name;
}
/**
* Gets the mode.
*
* @return the mode (virtual or archive)
*/
public String getMode()
{
return this.mode;
}
/**
* Sets the mode.
*
* @param mode
* the new mode (virtual or archive)
*/
public void setMode(String mode)
{
this.mode = mode;
}
/**
* Gets the Alfresco store name.
*
* @return the Alfresco store name
*/
public String getStore()
{
return this.store;
}
/**
* Sets the Alfresco store name.
*
* @param store
* the Alfresco store name
*/
public void setStore(String store)
{
this.store = store;
}
/**
* Gets the path within the store to the root node.
*
* @return the path within the store to the root node
*/
public String getRootPath()
{
return this.rootPath;
}
/**
* Sets the path within the store to the root node.
*
* @param rootPath
* the path within the store to the root node
*/
public void setRootPath(String rootPath)
{
this.rootPath = rootPath;
}
}

View File

@@ -1,143 +0,0 @@
/*
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.repo.imap.config;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;
import org.alfresco.config.ConfigElement;
import org.alfresco.config.element.ConfigElementAdapter;
public class ImapConfigElement extends ConfigElementAdapter
{
private static final long serialVersionUID = -6911139959296875159L;
public static final String CONFIG_ELEMENT_ID = "imapConfig";
private Map<String, ImapConfig> imapConfigs = new LinkedHashMap<String, ImapConfig>(8, 10f);
public ImapConfigElement()
{
super(CONFIG_ELEMENT_ID);
}
public ImapConfigElement(String name)
{
super(name);
}
@Override
public ConfigElement combine(ConfigElement configElement)
{
ImapConfigElement combined = new ImapConfigElement();
// add all the imapConfigs from this element
for (ImapConfig imapConfig : getImapConfigs().values())
{
combined.addImapConfig(imapConfig);
}
// add all the imapConfigs from the given element
for (ImapConfig imapConfig : ((ImapConfigElement) configElement).getImapConfigs().values())
{
combined.addImapConfig(imapConfig);
}
return combined;
}
public Map<String, ImapConfig> getImapConfigs()
{
return imapConfigs;
}
public ImapConfig getImapConfig(String name)
{
return imapConfigs.get(name);
}
void addImapConfig(ImapConfig imapConfig)
{
imapConfigs.put(imapConfig.getName(), imapConfig);
}
public static class ImapConfig implements Serializable
{
private static final long serialVersionUID = 424330549937129149L;
private String name;
private String mode;
private String store;
private String rootPath;
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getMode()
{
return mode;
}
public void setMode(String mode)
{
this.mode = mode;
}
public String getStore()
{
return store;
}
public void setStore(String store)
{
this.store = store;
}
public String getRootPath()
{
return rootPath;
}
public void setRootPath(String rootPath)
{
this.rootPath = rootPath;
}
public static long getSerialVersionUID()
{
return serialVersionUID;
}
}
}

View File

@@ -1,81 +0,0 @@
/*
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.repo.imap.config;
import java.util.Iterator;
import org.alfresco.config.ConfigElement;
import org.alfresco.config.ConfigException;
import org.alfresco.config.xml.elementreader.ConfigElementReader;
import org.alfresco.repo.imap.config.ImapConfigElement.ImapConfig;
import org.dom4j.Element;
public class ImapElementReader implements ConfigElementReader
{
private static final String ELEMENT_IMAP_CONFIG = "imapConfig";
private static final String ELEMENT_IMAP = "imap";
private static final String ELEMENT_STORE = "store";
private static final String ELEMENT_ROOTPATH = "rootPath";
private static final String ATTR_NAME = "name";
private static final String ATTR_MODE = "mode";
public ConfigElement parse(Element element)
{
ImapConfigElement configElement = null;
if (element != null)
{
String elementName = element.getName();
if (elementName.equals(ELEMENT_IMAP_CONFIG) == false)
{
throw new ConfigException("ImapElementReader can parse '" + ELEMENT_IMAP_CONFIG + "' elements only, the element passed is '" + elementName + "'");
}
configElement = new ImapConfigElement();
for (Iterator<Element> items = element.elementIterator(ELEMENT_IMAP); items.hasNext();)
{
Element item = items.next();
String name = item.attributeValue(ATTR_NAME);
String mode = item.attributeValue(ATTR_MODE);
String store = item.element(ELEMENT_STORE).getStringValue();
String rootPath = item.element(ELEMENT_ROOTPATH).getStringValue();
ImapConfig imapConfig = new ImapConfig();
imapConfig.setName(name);
imapConfig.setMode(mode);
imapConfig.setStore(store);
imapConfig.setRootPath(rootPath);
configElement.addImapConfig(imapConfig);
}
}
return configElement;
}
}