diff --git a/config/alfresco/application-context.xml b/config/alfresco/application-context.xml index 93b3f13c58..e44a9415df 100644 --- a/config/alfresco/application-context.xml +++ b/config/alfresco/application-context.xml @@ -5,6 +5,12 @@ + + + + + + diff --git a/config/alfresco/tenant-single-context.xml b/config/alfresco/tenant-single-context.xml new file mode 100644 index 0000000000..af6d58b828 --- /dev/null +++ b/config/alfresco/tenant-single-context.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/source/java/org/alfresco/repo/tenant/SingleTServiceImpl.java b/source/java/org/alfresco/repo/tenant/SingleTServiceImpl.java new file mode 100644 index 0000000000..e729fe4e41 --- /dev/null +++ b/source/java/org/alfresco/repo/tenant/SingleTServiceImpl.java @@ -0,0 +1,160 @@ +/* + * Copyright (C) 2005-2007 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.tenant; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.search.SearchService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; + +/** + * Empty Tenant Service implementation (for Single-Tenant / Single-Instance) + */ + +public class SingleTServiceImpl implements TenantService +{ + public NodeRef getName(NodeRef nodeRef) + { + return nodeRef; + } + + public NodeRef getName(NodeRef inNodeRef, NodeRef nodeRef) + { + return nodeRef; + } + + public StoreRef getName(StoreRef storeRef) + { + return storeRef; + } + + public StoreRef getName(String username, StoreRef storeRef) + { + return storeRef; + } + + public QName getName(NodeRef inNodeRef, QName name) + { + return name; + } + + public String getName(String name) + { + return name; + } + + public QName getBaseName(QName name, boolean forceForNonTenant) + { + return name; + } + + public NodeRef getBaseName(NodeRef nodeRef) + { + return nodeRef; + } + + public StoreRef getBaseName(StoreRef storeRef) + { + return storeRef; + } + + public String getBaseName(String name) + { + return name; + } + + + public String getBaseName(String name, boolean forceForNonTenant) + { + return name; + } + + public String getBaseNameUser(String name) + { + return name; + } + + public void checkDomainUser(String username) + { + // NOOP + } + + public void checkDomain(String name) + { + // NOOP + } + + public NodeRef getRootNode(NodeService nodeService, SearchService searchService, NamespaceService namespaceService, String rootPath, NodeRef rootNodeRef) + { + return rootNodeRef; + } + + public NodeRef getCompanyHomeNode(NodeService nodeService, String username, StoreRef storeRef) + { + return null; + } + + public boolean isTenantUser() + { + return false; + } + + public boolean isTenantUser(String username) + { + return false; + } + + public boolean isTenantName(String name) + { + return false; + } + + public String getCurrentUserDomain() + { + return ""; + } + + public String getDomain(String name) + { + return ""; + } + + public String getDomainUser(String baseUsername, String tenantDomain) + { + return baseUsername; + } + + public Tenant getTenant(String tenantDomain) + { + return null; + } + + public boolean isEnabled() + { + return false; + } +} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/tenant/Tenant.java b/source/java/org/alfresco/repo/tenant/Tenant.java new file mode 100644 index 0000000000..f8f6285f25 --- /dev/null +++ b/source/java/org/alfresco/repo/tenant/Tenant.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2005-2007 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.tenant; + +/** + * Tenant + * + */ +public class Tenant +{ + private String tenantDomain; + + private boolean enabled = false; + + private String rootContentStoreDir = null; // if configured - can be null + + + public Tenant(String tenantDomain, boolean enabled, String rootContentStoreDir) + { + this.tenantDomain = tenantDomain; + this.enabled = enabled; + this.rootContentStoreDir = rootContentStoreDir; + } + + public String getTenantDomain() + { + return tenantDomain; + } + + public boolean isEnabled() + { + return enabled; + } + + public String getRootContentStoreDir() + { + return rootContentStoreDir; + } +} diff --git a/source/java/org/alfresco/repo/tenant/TenantService.java b/source/java/org/alfresco/repo/tenant/TenantService.java new file mode 100644 index 0000000000..412c9d24e5 --- /dev/null +++ b/source/java/org/alfresco/repo/tenant/TenantService.java @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2005-2007 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.tenant; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.search.SearchService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; + + +/** + * Tenant Service interface. + *

+ * This interface provides methods to support either Single-Tenant or Multi-Tenant implementations. + * + */ +public interface TenantService +{ + public static final String SEPARATOR = "@"; + + public static final String ADMIN_BASENAME = "admin"; + + public NodeRef getName(NodeRef nodeRef); + + public NodeRef getName(NodeRef inNodeRef, NodeRef nodeRef); + + public StoreRef getName(StoreRef storeRef); + + public StoreRef getName(String username, StoreRef storeRef); + + public QName getName(NodeRef inNodeRef, QName name); + + public String getName(String name); + + public QName getBaseName(QName name, boolean forceIfNonTenant); + + public NodeRef getBaseName(NodeRef nodeRef); + + public StoreRef getBaseName(StoreRef storeRef); + + public String getBaseName(String name); + + public String getBaseName(String name, boolean forceIfNonTenant); + + public String getBaseNameUser(String name); + + public void checkDomainUser(String username); + + public void checkDomain(String name); + + public NodeRef getRootNode(NodeService nodeService, SearchService searchService, NamespaceService namespaceService, String rootPath, NodeRef rootNodeRef); + + public NodeRef getCompanyHomeNode(NodeService nodeService, String username, StoreRef storeRef); + + public boolean isTenantUser(); + + public boolean isTenantUser(String username); + + public boolean isTenantName(String name); + + public String getCurrentUserDomain(); + + public String getDomain(String name); + + public String getDomainUser(String baseUsername, String tenantDomain); + + public Tenant getTenant(String tenantDomain); + + public boolean isEnabled(); +}