MT Share - initial checkpoint

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13459 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2009-03-03 22:25:50 +00:00
parent 8f1fe3f3df
commit b5dbd53461
26 changed files with 6240 additions and 4935 deletions

View File

@@ -1,173 +1,173 @@
/*
* Copyright (C) 2005-2008 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;
/*
* 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.tenant;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Set;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.Path;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.EqualsHelper;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
/**
* Interceptor to translate Node
*
* @since 3.0
* @author Derek Hulley
* @author janv
*/
public class MultiTNodeServiceInterceptor extends DelegatingIntroductionInterceptor//implements NodeService
{
private static final long serialVersionUID = -5462852271914961462L;
private static Log logger = LogFactory.getLog(MultiTNodeServiceInterceptor.class);
private static ThreadLocal<Boolean> ignoreMT = new ThreadLocal<Boolean>();
private TenantService tenantService;
/**
* Change the filtering behaviour of this interceptor on the current thread.
* Use this to switch off the filtering and pass references in and out as they
* are found.
*
* @param ignoreMT <tt>true</tt> if the current thread is able to handle
* MultiTenant-enabled references.
* @return <tt>true</tt> if the current transaction is MT aware
*/
public static boolean setIgnoreMT(boolean ignoreMT)
{
boolean wasIgnoreMT = isIgnoreMT();
MultiTNodeServiceInterceptor.ignoreMT.set(Boolean.valueOf(ignoreMT));
return wasIgnoreMT;
}
/**
* @return Returns <tt>true</tt> if the current thread has marked itself
* as being able to handle MultiTenant references.
*/
static public boolean isIgnoreMT()
{
if (ignoreMT.get() == null)
{
return false;
}
else
{
return ignoreMT.get();
}
}
public void setTenantService(TenantService tenantService)
{
this.tenantService = tenantService;
}
@SuppressWarnings("unchecked")
public Object invoke(MethodInvocation invocation) throws Throwable
{
import org.alfresco.util.EqualsHelper;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
/**
* Interceptor to translate Node
*
* @since 3.0
* @author Derek Hulley
* @author janv
*/
public class MultiTNodeServiceInterceptor extends DelegatingIntroductionInterceptor//implements NodeService
{
private static final long serialVersionUID = -5462852271914961462L;
private static Log logger = LogFactory.getLog(MultiTNodeServiceInterceptor.class);
private static ThreadLocal<Boolean> ignoreMT = new ThreadLocal<Boolean>();
private TenantService tenantService;
/**
* Change the filtering behaviour of this interceptor on the current thread.
* Use this to switch off the filtering and pass references in and out as they
* are found.
*
* @param ignoreMT <tt>true</tt> if the current thread is able to handle
* MultiTenant-enabled references.
* @return <tt>true</tt> if the current transaction is MT aware
*/
public static boolean setIgnoreMT(boolean ignoreMT)
{
boolean wasIgnoreMT = isIgnoreMT();
MultiTNodeServiceInterceptor.ignoreMT.set(Boolean.valueOf(ignoreMT));
return wasIgnoreMT;
}
/**
* @return Returns <tt>true</tt> if the current thread has marked itself
* as being able to handle MultiTenant references.
*/
static public boolean isIgnoreMT()
{
if (ignoreMT.get() == null)
{
return false;
}
else
{
return ignoreMT.get();
}
}
public void setTenantService(TenantService tenantService)
{
this.tenantService = tenantService;
}
@SuppressWarnings("unchecked")
public Object invoke(MethodInvocation invocation) throws Throwable
{
// See if we can shortcut (for super 'System' only)
if (AuthenticationUtil.getSystemUserName().equals(AuthenticationUtil.getRunAsUser()) || !AuthenticationUtil.isMtEnabled())
{
return invocation.proceed();
}
String methodName = invocation.getMethod().getName();
if (logger.isDebugEnabled())
{
logger.debug("Intercepting method " + methodName);
}
Object[] args = invocation.getArguments();
// Convert each of the arguments to the underlying (full) reference.
for (int i = 0; i < args.length; i++)
{
Object arg = args[i];
Object newArg = arg;
if (arg == null)
{
// No conversion possible
}
if (arg instanceof StoreRef)
{
StoreRef ref = (StoreRef) arg;
newArg = tenantService.getName(ref);
}
else if (arg instanceof NodeRef)
{
NodeRef ref = (NodeRef) arg;
newArg = tenantService.getName(ref);
}
else if (arg instanceof ChildAssociationRef)
{
ChildAssociationRef ref = (ChildAssociationRef) arg;
newArg = tenantService.getName(ref);
}
else if (arg instanceof AssociationRef)
{
AssociationRef ref = (AssociationRef) arg;
newArg = tenantService.getName(ref);
}
if (logger.isDebugEnabled())
{
if (!EqualsHelper.nullSafeEquals(newArg, arg))
{
logger.debug(
"Argument converted: \n" +
" Before: " + arg + "\n" +
" After: " + newArg);
}
}
// Substitute the new value
args[i] = newArg;
}
// Make the call
Object ret = invocation.proceed();
{
return invocation.proceed();
}
String methodName = invocation.getMethod().getName();
if (logger.isDebugEnabled())
{
logger.debug("Intercepting method " + methodName);
}
Object[] args = invocation.getArguments();
// Convert each of the arguments to the underlying (full) reference.
for (int i = 0; i < args.length; i++)
{
Object arg = args[i];
Object newArg = arg;
if (arg == null)
{
// No conversion possible
}
if (arg instanceof StoreRef)
{
StoreRef ref = (StoreRef) arg;
newArg = tenantService.getName(ref);
}
else if (arg instanceof NodeRef)
{
NodeRef ref = (NodeRef) arg;
newArg = tenantService.getName(ref);
}
else if (arg instanceof ChildAssociationRef)
{
ChildAssociationRef ref = (ChildAssociationRef) arg;
newArg = tenantService.getName(ref);
}
else if (arg instanceof AssociationRef)
{
AssociationRef ref = (AssociationRef) arg;
newArg = tenantService.getName(ref);
}
if (logger.isDebugEnabled())
{
if (!EqualsHelper.nullSafeEquals(newArg, arg))
{
logger.debug(
"Argument converted: \n" +
" Before: " + arg + "\n" +
" After: " + newArg);
}
}
// Substitute the new value
args[i] = newArg;
}
// Make the call
Object ret = invocation.proceed();
if (methodName.equals("getProperty"))
{
{
if (ret != null)
{
// Convert the outbound value
@@ -213,135 +213,135 @@ public class MultiTNodeServiceInterceptor extends DelegatingIntroductionIntercep
}
else if (methodName.equals("getStores"))
{
if ((ret == null) || (! (ret instanceof List)))
{
return null;
}
List<StoreRef> rawValues = (List<StoreRef>)ret;
final List<StoreRef> convertedValues = new ArrayList<StoreRef>(rawValues.size());
for (StoreRef ref : rawValues)
{
StoreRef storeRef = ref;
try
{
if (tenantService.isEnabled())
{
// MT: return tenant stores only (although for super System return all stores - as used by
// ConfigurationChecker, IndexRecovery, IndexBackup etc)
if ((ret == null) || (! (ret instanceof List)))
{
return null;
}
List<StoreRef> rawValues = (List<StoreRef>)ret;
final List<StoreRef> convertedValues = new ArrayList<StoreRef>(rawValues.size());
for (StoreRef ref : rawValues)
{
StoreRef storeRef = ref;
try
{
if (tenantService.isEnabled() && (! storeRef.getProtocol().equals(StoreRef.PROTOCOL_AVM)))
{
// MT: return tenant stores only (although for super System return all stores - as used by
// ConfigurationChecker, IndexRecovery, IndexBackup etc)
if (!AuthenticationUtil.isRunAsUserTheSystemUser())
{
tenantService.checkDomain(storeRef.getIdentifier());
storeRef = tenantService.getBaseName(storeRef);
}
}
convertedValues.add(storeRef);
}
catch (RuntimeException re)
{
// deliberately ignore - stores in different domain will not be listed
}
}
return convertedValues;
}
else
{
// Convert the outbound value
ret = convertOutboundValue(ret);
}
// done
return ret;
}
/**
* Convert outbound collection to spoofed (no tenant prefix) values.
*/
private Collection<Object> convertOutboundValues(Collection<Object> rawValues)
{
/*
* Return types can be Lists or Sets, so cater for both.
*/
final Collection<Object> convertedValues;
if (rawValues instanceof List)
{
convertedValues = new ArrayList<Object>(rawValues.size());
}
else if (rawValues instanceof Set)
{
convertedValues = new HashSet<Object>(rawValues.size(), 1.0F);
}
else
{
throw new IllegalArgumentException("Interceptor can only handle List and Set return types.");
}
for (Object rawValue : rawValues)
{
Object convertedValue = convertOutboundValue(rawValue);
convertedValues.add(convertedValue);
}
// Done
return convertedValues;
}
/**
* Convert outbound single value to spoofed (no tenant prefix) value.
*/
@SuppressWarnings("unchecked")
private Object convertOutboundValue(Object rawValue)
{
if (rawValue == null)
{
return null;
}
// Deal with collections
Object value = rawValue;
if (rawValue instanceof Collection)
{
value = convertOutboundValues((Collection<Object>)rawValue);
}
else if (rawValue instanceof StoreRef)
{
StoreRef ref = (StoreRef) rawValue;
{
tenantService.checkDomain(storeRef.getIdentifier());
storeRef = tenantService.getBaseName(storeRef);
}
}
convertedValues.add(storeRef);
}
catch (RuntimeException re)
{
// deliberately ignore - stores in different domain will not be listed
}
}
return convertedValues;
}
else
{
// Convert the outbound value
ret = convertOutboundValue(ret);
}
// done
return ret;
}
/**
* Convert outbound collection to spoofed (no tenant prefix) values.
*/
private Collection<Object> convertOutboundValues(Collection<Object> rawValues)
{
/*
* Return types can be Lists or Sets, so cater for both.
*/
final Collection<Object> convertedValues;
if (rawValues instanceof List)
{
convertedValues = new ArrayList<Object>(rawValues.size());
}
else if (rawValues instanceof Set)
{
convertedValues = new HashSet<Object>(rawValues.size(), 1.0F);
}
else
{
throw new IllegalArgumentException("Interceptor can only handle List and Set return types.");
}
for (Object rawValue : rawValues)
{
Object convertedValue = convertOutboundValue(rawValue);
convertedValues.add(convertedValue);
}
// Done
return convertedValues;
}
/**
* Convert outbound single value to spoofed (no tenant prefix) value.
*/
@SuppressWarnings("unchecked")
private Object convertOutboundValue(Object rawValue)
{
if (rawValue == null)
{
return null;
}
// Deal with collections
Object value = rawValue;
if (rawValue instanceof Collection)
{
value = convertOutboundValues((Collection<Object>)rawValue);
}
else if (rawValue instanceof StoreRef)
{
StoreRef ref = (StoreRef) rawValue;
value = tenantService.getBaseName(ref);
}
else if (rawValue instanceof NodeRef)
{
NodeRef ref = (NodeRef) rawValue;
value = tenantService.getBaseName(ref);
}
else if (rawValue instanceof ChildAssociationRef)
{
ChildAssociationRef ref = (ChildAssociationRef) rawValue;
}
else if (rawValue instanceof NodeRef)
{
NodeRef ref = (NodeRef) rawValue;
value = tenantService.getBaseName(ref);
}
else if (rawValue instanceof AssociationRef)
{
AssociationRef ref = (AssociationRef) rawValue;
}
else if (rawValue instanceof ChildAssociationRef)
{
ChildAssociationRef ref = (ChildAssociationRef) rawValue;
value = tenantService.getBaseName(ref);
}
else if (rawValue instanceof Path)
{
Path ref = (Path)rawValue;
Path outboundPath = new Path();
Iterator<Path.Element> itr = ref.iterator();
while (itr.hasNext())
{
Path.Element pathElement = itr.next();
if (pathElement instanceof Path.ChildAssocElement)
{
pathElement = new Path.ChildAssocElement(tenantService.getBaseName(((Path.ChildAssocElement)pathElement).getRef()));
}
outboundPath.append(pathElement);
}
value = outboundPath;
}
// Done
return value;
}
}
}
else if (rawValue instanceof AssociationRef)
{
AssociationRef ref = (AssociationRef) rawValue;
value = tenantService.getBaseName(ref);
}
else if (rawValue instanceof Path)
{
Path ref = (Path)rawValue;
Path outboundPath = new Path();
Iterator<Path.Element> itr = ref.iterator();
while (itr.hasNext())
{
Path.Element pathElement = itr.next();
if (pathElement instanceof Path.ChildAssocElement)
{
pathElement = new Path.ChildAssocElement(tenantService.getBaseName(((Path.ChildAssocElement)pathElement).getRef()));
}
outboundPath.append(pathElement);
}
value = outboundPath;
}
// Done
return value;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,223 +1,231 @@
/*
* Copyright (C) 2005-2008 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 java.io.File;
import java.util.Collections;
import java.util.List;
import org.apache.commons.logging.Log;
/**
* Empty Tenant Deployer Service implementation (for Single-Tenant / Single-Instance)
*/
public class SingleTAdminServiceImpl implements TenantAdminService
{
/**
* NO-OP
*/
public void startTenants()
{
}
/**
* NO-OP
*/
public void stopTenants()
{
}
/**
* @return Returns <tt>false</tt> always
*/
public boolean isEnabled()
{
return false;
}
/**
* NO-OP
*/
public void initialiseTenants()
{
}
/**
* NO-OP
*/
public void deployTenants(final TenantDeployer deployer, Log logger)
{
}
/**
* NO-OP
*/
public void undeployTenants(final TenantDeployer deployer, Log logger)
{
}
/**
* NO-OP
*/
public void register(TenantDeployer tenantDeployer)
{
}
/**
* NO-OP
*/
public void unregister(TenantDeployer tenantDeployer)
{
}
/**
* @return Returns an empty list always
*/
public List<Tenant> getAllTenants()
{
return Collections.emptyList();
}
/**
* @return Returns {@link TenantService#DEFAULT_DOMAIN} always
*/
public String getCurrentUserDomain()
{
return TenantService.DEFAULT_DOMAIN;
}
/**
* @return Returns {@link TenantService#DEFAULT_DOMAIN} always
*/
public String getUserDomain(String username)
{
return TenantService.DEFAULT_DOMAIN;
}
/**
* @return Returns the given <tt>username</tt> always
*/
public String getBaseNameUser(String username)
{
return username;
}
/**
* @return Returns the given <tt>baseUserName</tt> always
*/
public String getDomainUser(String baseUsername, String tenantDomain)
{
return baseUsername;
}
/**
* @return Returns {@link TenantService#DEFAULT_DOMAIN} always
*/
public String getDomain(String name)
{
return TenantService.DEFAULT_DOMAIN;
}
/**
* @throws UnsupportedOperationException always
*/
public void createTenant(String tenantDomain, char[] adminRawPassword, String rootContentStoreDir)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/**
* @throws UnsupportedOperationException always
*/
public void createTenant(String tenantDomain, char[] adminRawPassword)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/**
* @throws UnsupportedOperationException always
*/
public void deleteTenant(String tenantDomain)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/**
* @throws UnsupportedOperationException always
*/
public void disableTenant(String tenantDomain)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/**
* @throws UnsupportedOperationException always
*/
public void enableTenant(String tenantDomain)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/**
* @throws UnsupportedOperationException always
*/
public boolean existsTenant(String tenantDomain)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/**
* @throws UnsupportedOperationException always
*/
public void exportTenant(String tenantDomain, File directoryDestination)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/**
* @throws UnsupportedOperationException always
*/
public Tenant getTenant(String tenantDomain)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/**
* @throws UnsupportedOperationException always
*/
public void importTenant(String tenantDomain, File directorySource, String rootContentStoreDir)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/**
* @throws UnsupportedOperationException always
*/
public boolean isEnabledTenant(String tenantDomain)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/*
* 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.tenant;
import java.io.File;
import java.util.Collections;
import java.util.List;
import org.alfresco.repo.workflow.WorkflowDeployer;
import org.apache.commons.logging.Log;
/**
* Empty Tenant Deployer Service implementation (for Single-Tenant / Single-Instance)
*/
public class SingleTAdminServiceImpl implements TenantAdminService
{
/**
* NO-OP
*/
public void startTenants()
{
}
/**
* NO-OP
*/
public void stopTenants()
{
}
/**
* @return Returns <tt>false</tt> always
*/
public boolean isEnabled()
{
return false;
}
/**
* NO-OP
*/
public void initialiseTenants()
{
}
/**
* NO-OP
*/
public void deployTenants(final TenantDeployer deployer, Log logger)
{
}
/**
* NO-OP
*/
public void undeployTenants(final TenantDeployer deployer, Log logger)
{
}
/**
* NO-OP
*/
public void register(TenantDeployer tenantDeployer)
{
}
/**
* NO-OP
*/
public void unregister(TenantDeployer tenantDeployer)
{
}
/**
* NO-OP
*/
public void register(WorkflowDeployer workflowDeployer)
{
}
/**
* @return Returns an empty list always
*/
public List<Tenant> getAllTenants()
{
return Collections.emptyList();
}
/**
* @return Returns {@link TenantService#DEFAULT_DOMAIN} always
*/
public String getCurrentUserDomain()
{
return TenantService.DEFAULT_DOMAIN;
}
/**
* @return Returns {@link TenantService#DEFAULT_DOMAIN} always
*/
public String getUserDomain(String username)
{
return TenantService.DEFAULT_DOMAIN;
}
/**
* @return Returns the given <tt>username</tt> always
*/
public String getBaseNameUser(String username)
{
return username;
}
/**
* @return Returns the given <tt>baseUserName</tt> always
*/
public String getDomainUser(String baseUsername, String tenantDomain)
{
return baseUsername;
}
/**
* @return Returns {@link TenantService#DEFAULT_DOMAIN} always
*/
public String getDomain(String name)
{
return TenantService.DEFAULT_DOMAIN;
}
/**
* @throws UnsupportedOperationException always
*/
public void createTenant(String tenantDomain, char[] adminRawPassword, String rootContentStoreDir)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/**
* @throws UnsupportedOperationException always
*/
public void createTenant(String tenantDomain, char[] adminRawPassword)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/**
* @throws UnsupportedOperationException always
*/
public void deleteTenant(String tenantDomain)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/**
* @throws UnsupportedOperationException always
*/
public void disableTenant(String tenantDomain)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/**
* @throws UnsupportedOperationException always
*/
public void enableTenant(String tenantDomain)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/**
* @throws UnsupportedOperationException always
*/
public boolean existsTenant(String tenantDomain)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/**
* @throws UnsupportedOperationException always
*/
public void exportTenant(String tenantDomain, File directoryDestination)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/**
* @throws UnsupportedOperationException always
*/
public Tenant getTenant(String tenantDomain)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/**
* @throws UnsupportedOperationException always
*/
public void importTenant(String tenantDomain, File directorySource, String rootContentStoreDir)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
/**
* @throws UnsupportedOperationException always
*/
public boolean isEnabledTenant(String tenantDomain)
{
throw new UnsupportedOperationException("Single tenant mode is active.");
}
}

View File

@@ -1,182 +1,187 @@
/*
* 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.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
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 ChildAssociationRef getName(ChildAssociationRef childAssocRef)
{
return childAssocRef;
}
public AssociationRef getName(AssociationRef assocRef)
{
return assocRef;
}
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 ChildAssociationRef getBaseName(ChildAssociationRef childAssocRef)
{
return childAssocRef;
}
public AssociationRef getBaseName(AssociationRef assocRef)
{
return assocRef;
}
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 boolean isTenantUser()
{
return false;
}
public boolean isTenantUser(String username)
{
return false;
}
public boolean isTenantName(String name)
{
return false;
}
public String getUserDomain(String username)
{
return DEFAULT_DOMAIN;
}
public String getCurrentUserDomain()
{
return DEFAULT_DOMAIN;
}
public String getDomain(String name)
{
return DEFAULT_DOMAIN;
}
public String getDomainUser(String baseUsername, String tenantDomain)
{
return baseUsername;
}
public Tenant getTenant(String tenantDomain)
{
return null;
}
public boolean isEnabled()
{
return false;
}
/*
* 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.tenant;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
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 ChildAssociationRef getName(ChildAssociationRef childAssocRef)
{
return childAssocRef;
}
public AssociationRef getName(AssociationRef assocRef)
{
return assocRef;
}
public StoreRef getName(String username, StoreRef storeRef)
{
return storeRef;
}
public QName getName(QName name)
{
return name;
}
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 ChildAssociationRef getBaseName(ChildAssociationRef childAssocRef)
{
return childAssocRef;
}
public AssociationRef getBaseName(AssociationRef assocRef)
{
return assocRef;
}
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 boolean isTenantUser()
{
return false;
}
public boolean isTenantUser(String username)
{
return false;
}
public boolean isTenantName(String name)
{
return false;
}
public String getUserDomain(String username)
{
return DEFAULT_DOMAIN;
}
public String getCurrentUserDomain()
{
return DEFAULT_DOMAIN;
}
public String getDomain(String name)
{
return DEFAULT_DOMAIN;
}
public String getDomainUser(String baseUsername, String tenantDomain)
{
return baseUsername;
}
public Tenant getTenant(String tenantDomain)
{
return null;
}
public boolean isEnabled()
{
return false;
}
}

View File

@@ -1,83 +1,90 @@
/*
* Copyright (C) 2005-2008 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 java.io.File;
import java.util.List;
import org.apache.commons.logging.Log;
/**
* Tenant Admin Service interface.
* <p>
* This interface provides administrative methods to provision and administer tenants.
*
*/
public interface TenantAdminService extends TenantUserService
{
public void startTenants();
public void stopTenants();
/*
* Deployer methods
*/
public void deployTenants(final TenantDeployer deployer, Log logger);
public void undeployTenants(final TenantDeployer deployer, Log logger);
public void register(TenantDeployer tenantDeployer);
public void unregister(TenantDeployer tenantDeployer);
public List<Tenant> getAllTenants();
/*
* Deployer methods
*/
public void createTenant(String tenantDomain, char[] adminRawPassword);
public void createTenant(String tenantDomain, char[] adminRawPassword, String rootContentStoreDir);
public void exportTenant(String tenantDomain, File directoryDestination);
public void importTenant(String tenantDomain, File directorySource, String rootContentStoreDir);
public boolean existsTenant(String tenantDomain);
public void deleteTenant(String tenantDomain);
public void enableTenant(String tenantDomain);
public void disableTenant(String tenantDomain);
public Tenant getTenant(String tenantDomain);
public boolean isEnabledTenant(String tenantDomain);
}
/*
* 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.tenant;
import java.io.File;
import java.util.List;
import org.alfresco.repo.workflow.WorkflowDeployer;
import org.apache.commons.logging.Log;
/**
* Tenant Admin Service interface.
* <p>
* This interface provides administrative methods to provision and administer tenants.
*
*/
public interface TenantAdminService extends TenantUserService
{
public void startTenants();
public void stopTenants();
/*
* Tenant Deployer methods
*/
public void deployTenants(final TenantDeployer deployer, Log logger);
public void undeployTenants(final TenantDeployer deployer, Log logger);
public void register(TenantDeployer tenantDeployer);
public void unregister(TenantDeployer tenantDeployer);
public List<Tenant> getAllTenants();
/*
* Workflow Deployer methods
*/
public void register(WorkflowDeployer workflowDeployer);
/*
* Admin methods
*/
public void createTenant(String tenantDomain, char[] adminRawPassword);
public void createTenant(String tenantDomain, char[] adminRawPassword, String rootContentStoreDir);
public void exportTenant(String tenantDomain, File directoryDestination);
public void importTenant(String tenantDomain, File directorySource, String rootContentStoreDir);
public boolean existsTenant(String tenantDomain);
public void deleteTenant(String tenantDomain);
public void enableTenant(String tenantDomain);
public void disableTenant(String tenantDomain);
public Tenant getTenant(String tenantDomain);
public boolean isEnabledTenant(String tenantDomain);
}

View File

@@ -1,141 +1,146 @@
/*
* Copyright (C) 2005-2008 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.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
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.
* <p>
* This interface provides methods to support either ST or MT implementations.
*
*/
public interface TenantService extends TenantUserService
{
public static final String SEPARATOR = "@";
public static final String DEFAULT_DOMAIN = "";
public static final String ADMIN_BASENAME = "admin";
/**
* @return the reference <b>with</b> the tenant-specific ID attached
*/
public NodeRef getName(NodeRef nodeRef);
/**
* @return the reference <b>with</b> the tenant-specific ID attached
*/
public NodeRef getName(NodeRef inNodeRef, NodeRef nodeRef);
/**
* @return the reference <b>with</b> the tenant-specific ID attached
*/
public StoreRef getName(StoreRef storeRef);
/**
* @return the reference <b>with</b> the tenant-specific ID attached
*/
public ChildAssociationRef getName(ChildAssociationRef childAssocRef);
/**
* @return the reference <b>with</b> the tenant-specific ID attached
*/
public AssociationRef getName(AssociationRef assocRef);
/**
* @return the reference <b>with</b> the tenant-specific ID attached
*/
public StoreRef getName(String username, StoreRef storeRef);
/**
* @return the reference <b>with</b> the tenant-specific ID attached
*/
public QName getName(NodeRef inNodeRef, QName name);
/**
* @return the reference <b>with</b> the tenant-specific ID attached
*/
public String getName(String name);
/**
* @return the reference <b>without</b> the tenant-specific ID attached
*/
public QName getBaseName(QName name, boolean forceIfNonTenant);
/**
* @return the reference <b>without</b> the tenant-specific ID attached
*/
public NodeRef getBaseName(NodeRef nodeRef);
/**
* @return the reference <b>without</b> the tenant-specific ID attached
*/
public StoreRef getBaseName(StoreRef storeRef);
/**
* @return the reference <b>without</b> the tenant-specific ID attached
*/
public ChildAssociationRef getBaseName(ChildAssociationRef childAssocRef);
/**
* @return the reference <b>without</b> the tenant-specific ID attached
*/
public AssociationRef getBaseName(AssociationRef assocRef);
/**
* @return the reference <b>without</b> the tenant-specific ID attached
*/
public String getBaseName(String name);
/**
* @return the reference <b>without</b> the tenant-specific ID attached
*/
public String getBaseName(String name, boolean forceIfNonTenant);
public void checkDomainUser(String username);
public void checkDomain(String name);
public NodeRef getRootNode(NodeService nodeService, SearchService searchService, NamespaceService namespaceService, String rootPath, NodeRef rootNodeRef);
public boolean isTenantUser();
public boolean isTenantUser(String username);
public boolean isTenantName(String name);
public String getUserDomain(String username);
public Tenant getTenant(String tenantDomain);
}
/*
* 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.tenant;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
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.
* <p>
* This interface provides methods to support either ST or MT implementations.
*
*/
public interface TenantService extends TenantUserService
{
public static final String SEPARATOR = "@";
public static final String DEFAULT_DOMAIN = "";
public static final String ADMIN_BASENAME = "admin";
/**
* @return the reference <b>with</b> the tenant-specific ID attached
*/
public NodeRef getName(NodeRef nodeRef);
/**
* @return the reference <b>with</b> the tenant-specific ID attached
*/
public NodeRef getName(NodeRef inNodeRef, NodeRef nodeRef);
/**
* @return the reference <b>with</b> the tenant-specific ID attached
*/
public StoreRef getName(StoreRef storeRef);
/**
* @return the reference <b>with</b> the tenant-specific ID attached
*/
public ChildAssociationRef getName(ChildAssociationRef childAssocRef);
/**
* @return the reference <b>with</b> the tenant-specific ID attached
*/
public AssociationRef getName(AssociationRef assocRef);
/**
* @return the reference <b>with</b> the tenant-specific ID attached
*/
public StoreRef getName(String username, StoreRef storeRef);
/**
* @return the reference <b>with</b> the tenant-specific ID attached
*/
public QName getName(QName name);
/**
* @return the reference <b>with</b> the tenant-specific ID attached
*/
public QName getName(NodeRef inNodeRef, QName name);
/**
* @return the reference <b>with</b> the tenant-specific ID attached
*/
public String getName(String name);
/**
* @return the reference <b>without</b> the tenant-specific ID attached
*/
public QName getBaseName(QName name, boolean forceIfNonTenant);
/**
* @return the reference <b>without</b> the tenant-specific ID attached
*/
public NodeRef getBaseName(NodeRef nodeRef);
/**
* @return the reference <b>without</b> the tenant-specific ID attached
*/
public StoreRef getBaseName(StoreRef storeRef);
/**
* @return the reference <b>without</b> the tenant-specific ID attached
*/
public ChildAssociationRef getBaseName(ChildAssociationRef childAssocRef);
/**
* @return the reference <b>without</b> the tenant-specific ID attached
*/
public AssociationRef getBaseName(AssociationRef assocRef);
/**
* @return the reference <b>without</b> the tenant-specific ID attached
*/
public String getBaseName(String name);
/**
* @return the reference <b>without</b> the tenant-specific ID attached
*/
public String getBaseName(String name, boolean forceIfNonTenant);
public void checkDomainUser(String username);
public void checkDomain(String name);
public NodeRef getRootNode(NodeService nodeService, SearchService searchService, NamespaceService namespaceService, String rootPath, NodeRef rootNodeRef);
public boolean isTenantUser();
public boolean isTenantUser(String username);
public boolean isTenantName(String name);
public String getUserDomain(String username);
public Tenant getTenant(String tenantDomain);
}