diff --git a/source/java/org/alfresco/repo/avm/AVMServiceTest.java b/source/java/org/alfresco/repo/avm/AVMServiceTest.java index 6840049145..e34ecf48a2 100644 --- a/source/java/org/alfresco/repo/avm/AVMServiceTest.java +++ b/source/java/org/alfresco/repo/avm/AVMServiceTest.java @@ -2049,7 +2049,7 @@ public class AVMServiceTest extends AVMServiceTestBase /** * Test the undo list action. * - * @deprecated see org.alfresco.wcm.actions.WCMSandboxRevertListAction or org.alfresco.wcm.SandboxService.revertList + * @deprecated see org.alfresco.wcm.actions.WCMSandboxUndoAction or org.alfresco.wcm.SandboxService.revertList */ public void testUndoListAction() throws Exception { diff --git a/source/java/org/alfresco/repo/content/TenantRoutingFileContentStore.java b/source/java/org/alfresco/repo/content/TenantRoutingFileContentStore.java index ff575f2eef..9ca9d94285 100755 --- a/source/java/org/alfresco/repo/content/TenantRoutingFileContentStore.java +++ b/source/java/org/alfresco/repo/content/TenantRoutingFileContentStore.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2007 Alfresco Software Limited. + * 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 @@ -27,9 +27,9 @@ package org.alfresco.repo.content; import java.io.File; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.alfresco.repo.content.filestore.FileContentStore; import org.alfresco.repo.security.authentication.AuthenticationUtil; @@ -48,13 +48,14 @@ import org.springframework.context.ConfigurableApplicationContext; */ public class TenantRoutingFileContentStore extends AbstractRoutingContentStore implements TenantDeployer, ApplicationContextAware { - Map tenantFileStores = new HashMap(); + // cache of tenant file stores + Map tenantFileStores = new ConcurrentHashMap(); private String defaultRootDirectory; private TenantService tenantService; private ApplicationContext applicationContext; - - + + public void setDefaultRootDir(String defaultRootDirectory) { this.defaultRootDirectory = defaultRootDirectory; @@ -75,11 +76,13 @@ public class TenantRoutingFileContentStore extends AbstractRoutingContentStore i this.applicationContext = applicationContext; } + @Override protected ContentStore selectWriteStore(ContentContext ctx) { return getTenantFileStore(tenantService.getCurrentUserDomain()); } + @Override public List getAllStores() { if (tenantService.isEnabled()) @@ -101,7 +104,13 @@ public class TenantRoutingFileContentStore extends AbstractRoutingContentStore i private ContentStore getTenantFileStore(String tenantDomain) { - return tenantFileStores.get(tenantDomain); + ContentStore cs = tenantFileStores.get(tenantDomain); + if (cs == null) + { + init(); + cs = tenantFileStores.get(tenantDomain); + } + return cs; } private void putTenantFileStore(String tenantDomain, FileContentStore fileStore) @@ -113,7 +122,7 @@ public class TenantRoutingFileContentStore extends AbstractRoutingContentStore i { tenantFileStores.remove(tenantDomain); } - + public void init() { String tenantDomain = TenantService.DEFAULT_DOMAIN; @@ -128,7 +137,7 @@ public class TenantRoutingFileContentStore extends AbstractRoutingContentStore i } tenantDomain = tenant.getTenantDomain(); } - + putTenantFileStore(tenantDomain, new FileContentStore((ConfigurableApplicationContext) this.applicationContext, new File(rootDir))); } diff --git a/source/java/org/alfresco/repo/dictionary/DictionaryDAOImpl.java b/source/java/org/alfresco/repo/dictionary/DictionaryDAOImpl.java index dd85ed1b9c..b7218cfd11 100644 --- a/source/java/org/alfresco/repo/dictionary/DictionaryDAOImpl.java +++ b/source/java/org/alfresco/repo/dictionary/DictionaryDAOImpl.java @@ -551,6 +551,11 @@ public class DictionaryDAOImpl implements DictionaryDAO return type; } } + + if (logger.isWarnEnabled()) + { + logger.warn("Type not found: "+typeName); + } return null; } diff --git a/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneIndexerImpl.java b/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneIndexerImpl.java index 6354bf7f92..82f21d7d40 100644 --- a/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneIndexerImpl.java +++ b/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneIndexerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2007 Alfresco Software Limited. + * 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 @@ -56,10 +56,11 @@ import org.alfresco.repo.search.impl.lucene.analysis.MLTokenDuplicator; import org.alfresco.repo.search.impl.lucene.analysis.VerbatimAnalyser; import org.alfresco.repo.search.impl.lucene.fts.FTSIndexerAware; import org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexer; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.tenant.TenantService; import org.alfresco.service.cmr.dictionary.AspectDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.PropertyDefinition; import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.cmr.repository.ChildAssociationRef; @@ -92,11 +93,11 @@ import org.apache.lucene.index.TermDocs; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.Hits; import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.Query; import org.apache.lucene.search.Searcher; import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.BooleanClause.Occur; + /** * The implementation of the lucene based indexer. Supports basic transactional behaviour if used on its own. * @@ -571,7 +572,26 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp } } - public List createDocuments(String stringNodeRef, boolean isNew, boolean indexAllProperties, boolean includeDirectoryDocuments) + public List createDocuments(final String stringNodeRef, final boolean isNew, final boolean indexAllProperties, final boolean includeDirectoryDocuments) + { + if (tenantService.isEnabled() && ((AuthenticationUtil.getRunAsUser() == null) || (AuthenticationUtil.isRunAsUserTheSystemUser()))) + { + // ETHREEOH-2014 - dictionary access should be in context of tenant (eg. full reindex with MT dynamic models) + return AuthenticationUtil.runAs(new RunAsWork>() + { + public List doWork() + { + return createDocumentsImpl(stringNodeRef, isNew, indexAllProperties, includeDirectoryDocuments); + } + }, tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantService.getDomain(new NodeRef(stringNodeRef).getStoreRef().getIdentifier()))); + } + else + { + return createDocumentsImpl(stringNodeRef, isNew, indexAllProperties, includeDirectoryDocuments); + } + } + + private List createDocumentsImpl(String stringNodeRef, boolean isNew, boolean indexAllProperties, boolean includeDirectoryDocuments) { NodeRef nodeRef = new NodeRef(stringNodeRef); @@ -639,7 +659,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp else // not a root node { - Counter counter = nodeCounts.get(qNameRef); + Counter counter = nodeCounts.get(tenantService.getBaseName(qNameRef)); // If we have something in a container with root aspect we will // not find it diff --git a/source/java/org/alfresco/repo/search/impl/lucene/LuceneResultSet.java b/source/java/org/alfresco/repo/search/impl/lucene/LuceneResultSet.java index 09df3d9c1d..77cf2e7951 100644 --- a/source/java/org/alfresco/repo/search/impl/lucene/LuceneResultSet.java +++ b/source/java/org/alfresco/repo/search/impl/lucene/LuceneResultSet.java @@ -238,7 +238,7 @@ public class LuceneResultSet extends AbstractResultSet public ChildAssociationRef getChildAssocRef(int n) { - return getRow(n).getChildAssocRef(); + return tenantService.getBaseName(getRow(n).getChildAssocRef()); } public ResultSetMetaData getResultSetMetaData() @@ -255,4 +255,10 @@ public class LuceneResultSet extends AbstractResultSet { throw new UnsupportedOperationException(); } + + public TenantService getTenantService() + { + return tenantService; + } + } diff --git a/source/java/org/alfresco/repo/search/impl/lucene/LuceneResultSetRow.java b/source/java/org/alfresco/repo/search/impl/lucene/LuceneResultSetRow.java index b0c157a488..1d9ec25bed 100644 --- a/source/java/org/alfresco/repo/search/impl/lucene/LuceneResultSetRow.java +++ b/source/java/org/alfresco/repo/search/impl/lucene/LuceneResultSetRow.java @@ -29,6 +29,7 @@ import java.util.Map; import org.alfresco.model.ContentModel; import org.alfresco.repo.search.AbstractResultSetRow; +import org.alfresco.repo.tenant.TenantService; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; @@ -47,6 +48,8 @@ public class LuceneResultSetRow extends AbstractResultSetRow * The current document - cached so we do not get it for each value */ private Document document; + + private TenantService tenantService; /** * Wrap a position in a lucene Hits class with node support @@ -57,6 +60,8 @@ public class LuceneResultSetRow extends AbstractResultSetRow public LuceneResultSetRow(LuceneResultSet resultSet, int index) { super(resultSet, index); + + tenantService = resultSet.getTenantService(); } /** @@ -119,6 +124,7 @@ public class LuceneResultSetRow extends AbstractResultSetRow } } + @Override public ChildAssociationRef getChildAssocRef() { Field field = getDocument().getField("PRIMARYPARENT"); @@ -128,7 +134,7 @@ public class LuceneResultSetRow extends AbstractResultSetRow primaryParent = field.stringValue(); } NodeRef childNodeRef = getNodeRef(); - NodeRef parentNodeRef = primaryParent == null ? null : new NodeRef(primaryParent); + NodeRef parentNodeRef = primaryParent == null ? null : tenantService.getBaseName(new NodeRef(primaryParent)); return new ChildAssociationRef(getPrimaryAssocTypeQName(), parentNodeRef, getQName(), childNodeRef); } diff --git a/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngine.java b/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngine.java index 96cebe3126..cacc2f7288 100644 --- a/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngine.java +++ b/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngine.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2007 Alfresco Software Limited. + * 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 @@ -1096,13 +1096,7 @@ public class JBPMEngine extends BPMEngine Token token = getWorkflowToken(graphSession, pathId); TaskMgmtSession taskSession = context.getTaskMgmtSession(); List tasks = taskSession.findTaskInstancesByToken(token.getId()); - List workflowTasks = new ArrayList(tasks.size()); - for (TaskInstance task : tasks) - { - WorkflowTask workflowTask = createWorkflowTask(task); - workflowTasks.add(workflowTask); - } - return workflowTasks; + return getWorkflowTasks(tasks); } }); } @@ -1181,14 +1175,7 @@ public class JBPMEngine extends BPMEngine tasks = findCompletedTaskInstances(context, authority); } - // convert tasks to appropriate service response format - List workflowTasks = new ArrayList(tasks.size()); - for (TaskInstance task : tasks) - { - WorkflowTask workflowTask = createWorkflowTask(task); - workflowTasks.add(workflowTask); - } - return workflowTasks; + return getWorkflowTasks(tasks); } /** @@ -1239,13 +1226,7 @@ public class JBPMEngine extends BPMEngine // retrieve pooled tasks for all flattened authorities TaskMgmtSession taskSession = context.getTaskMgmtSession(); List tasks = taskSession.findPooledTaskInstances(authorities); - List workflowTasks = new ArrayList(tasks.size()); - for (TaskInstance task : tasks) - { - WorkflowTask workflowTask = createWorkflowTask(task); - workflowTasks.add(workflowTask); - } - return workflowTasks; + return getWorkflowTasks(tasks); } }); } @@ -1276,28 +1257,7 @@ public class JBPMEngine extends BPMEngine Criteria criteria = createTaskQueryCriteria(session, query); List tasks = criteria.list(); - - // convert tasks to appropriate service response format - List workflowTasks = new ArrayList(tasks.size()); - for (TaskInstance task : tasks) - { - if (tenantService.isEnabled()) - { - try - { - tenantService.checkDomain(task.getTask().getProcessDefinition().getName()); - } - catch (RuntimeException re) - { - // deliberately skip this one - due to domain mismatch - continue; - } - } - - WorkflowTask workflowTask = createWorkflowTask(task); - workflowTasks.add(workflowTask); - } - return workflowTasks; + return getWorkflowTasks(tasks); } }); } @@ -1306,6 +1266,31 @@ public class JBPMEngine extends BPMEngine throw new WorkflowException("Failed to query tasks", e); } } + + protected List getWorkflowTasks(List tasks) + { + // convert tasks to appropriate service response format + List workflowTasks = new ArrayList(tasks.size()); + for (TaskInstance task : tasks) + { + if (tenantService.isEnabled()) + { + try + { + tenantService.checkDomain(task.getTask().getProcessDefinition().getName()); + } + catch (RuntimeException re) + { + // deliberately skip this one - due to domain mismatch - eg. when querying by group authority + continue; + } + } + + WorkflowTask workflowTask = createWorkflowTask(task); + workflowTasks.add(workflowTask); + } + return workflowTasks; + } /** * Construct a JBPM Hibernate query based on the Task Query provided diff --git a/source/java/org/alfresco/wcm/actions/WCMSandboxRevertListAction.java b/source/java/org/alfresco/wcm/actions/WCMSandboxRevertListAction.java deleted file mode 100644 index e79acf1e03..0000000000 --- a/source/java/org/alfresco/wcm/actions/WCMSandboxRevertListAction.java +++ /dev/null @@ -1,94 +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.wcm.actions; - -import java.util.List; - -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.wcm.sandbox.SandboxService; - -/** - * WCM Revert List example action (supercedes AVMUndoSandboxListAction) - * - * Undo (ie. throw away) list of changed assets in a user sandbox. - * - * The actionedUponNodeRef is a dummy and can be null. - * - * @author janv - */ -public class WCMSandboxRevertListAction extends ActionExecuterAbstractBase -{ - public static final String NAME = "wcm-revert-list"; - - public static final String PARAM_PATH_LIST = "path-list"; // list of paths (relative to sandbox store) - public static final String PARAM_SANDBOX_ID = "sandbox-id"; // sandbox store id - - /** - * The WCM SandboxService - */ - private SandboxService sbService; - - public void setSandboxService(SandboxService sbService) - { - this.sbService = sbService; - } - - /* (non-Javadoc) - * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) - */ - @SuppressWarnings("unchecked") - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - String sbStoreId = (String)action.getParameterValue(PARAM_SANDBOX_ID); - List relativePaths = (List)action.getParameterValue(PARAM_PATH_LIST); - - sbService.revertList(sbStoreId, relativePaths); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) - */ - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add( - new ParameterDefinitionImpl(PARAM_PATH_LIST, - DataTypeDefinition.ANY, - true, - getParamDisplayLabel(PARAM_PATH_LIST))); - - paramList.add( - new ParameterDefinitionImpl(PARAM_SANDBOX_ID, - DataTypeDefinition.TEXT, - true, - getParamDisplayLabel(PARAM_SANDBOX_ID))); - } -}