mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-2025: where noderefs are cached in the transfer service (both transmitter and receiver) have made them multi-tenant aware.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19631 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -16,6 +16,9 @@
|
|||||||
<property name="transactionService">
|
<property name="transactionService">
|
||||||
<ref bean="TransactionService" />
|
<ref bean="TransactionService" />
|
||||||
</property>
|
</property>
|
||||||
|
<property name="tenantService">
|
||||||
|
<ref bean="tenantService" />
|
||||||
|
</property>
|
||||||
<property name="transferSpaceQuery">
|
<property name="transferSpaceQuery">
|
||||||
<value>/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.transfers.childname}/${spaces.transfer_groups.childname}</value>
|
<value>/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.transfers.childname}/${spaces.transfer_groups.childname}</value>
|
||||||
</property>
|
</property>
|
||||||
@@ -54,6 +57,7 @@
|
|||||||
<property name="searchService" ref="SearchService" />
|
<property name="searchService" ref="SearchService" />
|
||||||
<property name="transactionService" ref="TransactionService" />
|
<property name="transactionService" ref="TransactionService" />
|
||||||
<property name="actionService" ref="ActionService" />
|
<property name="actionService" ref="ActionService" />
|
||||||
|
<property name="tenantService" ref="tenantService" />
|
||||||
|
|
||||||
<property name="transferLockFolderPath">
|
<property name="transferLockFolderPath">
|
||||||
<value>/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.transfers.childname}</value>
|
<value>/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.transfers.childname}</value>
|
||||||
|
@@ -29,6 +29,7 @@ import java.util.Date;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import javax.xml.parsers.SAXParser;
|
import javax.xml.parsers.SAXParser;
|
||||||
import javax.xml.parsers.SAXParserFactory;
|
import javax.xml.parsers.SAXParserFactory;
|
||||||
@@ -37,6 +38,7 @@ import org.alfresco.model.ContentModel;
|
|||||||
import org.alfresco.repo.policy.BehaviourFilter;
|
import org.alfresco.repo.policy.BehaviourFilter;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||||
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;
|
||||||
@@ -59,9 +61,9 @@ import org.alfresco.service.namespace.NamespaceService;
|
|||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
|
import org.alfresco.util.PropertyCheck;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.alfresco.util.PropertyCheck;
|
|
||||||
import org.springframework.util.FileCopyUtils;
|
import org.springframework.util.FileCopyUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -139,11 +141,12 @@ public class RepoTransferReceiverImpl implements TransferReceiver
|
|||||||
private BehaviourFilter behaviourFilter;
|
private BehaviourFilter behaviourFilter;
|
||||||
private TransferProgressMonitor progressMonitor;
|
private TransferProgressMonitor progressMonitor;
|
||||||
private ActionService actionService;
|
private ActionService actionService;
|
||||||
|
private TenantService tenantService;
|
||||||
|
|
||||||
private NodeRef transferLockFolder;
|
private Map<String,NodeRef> transferLockFolderMap = new ConcurrentHashMap<String, NodeRef>();
|
||||||
private NodeRef transferTempFolder;
|
private Map<String,NodeRef> transferTempFolderMap = new ConcurrentHashMap<String, NodeRef>();
|
||||||
private NodeRef inboundTransferRecordsFolder;
|
private Map<String,NodeRef> inboundTransferRecordsFolderMap = new ConcurrentHashMap<String, NodeRef>();
|
||||||
|
|
||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
PropertyCheck.mandatory(this, "nodeService", nodeService);
|
PropertyCheck.mandatory(this, "nodeService", nodeService);
|
||||||
@@ -185,26 +188,23 @@ public class RepoTransferReceiverImpl implements TransferReceiver
|
|||||||
|
|
||||||
private NodeRef getLockFolder()
|
private NodeRef getLockFolder()
|
||||||
{
|
{
|
||||||
|
String tenantDomain = tenantService.getUserDomain(AuthenticationUtil.getRunAsUser());
|
||||||
|
NodeRef transferLockFolder = transferLockFolderMap.get(tenantDomain);
|
||||||
|
|
||||||
// Have we already resolved the node that is the parent of the lock node?
|
// Have we already resolved the node that is the parent of the lock node?
|
||||||
// If not then do so.
|
// If not then do so.
|
||||||
if (transferLockFolder == null)
|
if (transferLockFolder == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
ResultSet rs = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH,
|
||||||
|
transferLockFolderPath);
|
||||||
|
if (rs.length() > 0)
|
||||||
{
|
{
|
||||||
if (transferLockFolder == null)
|
transferLockFolder = rs.getNodeRef(0);
|
||||||
{
|
transferLockFolderMap.put(tenantDomain, transferLockFolder);
|
||||||
ResultSet rs = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE,
|
}
|
||||||
SearchService.LANGUAGE_XPATH, transferLockFolderPath);
|
else
|
||||||
if (rs.length() > 0)
|
{
|
||||||
{
|
throw new TransferException(MSG_TRANSFER_LOCK_FOLDER_NOT_FOUND, new Object[] { transferLockFolderPath });
|
||||||
transferLockFolder = rs.getNodeRef(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new TransferException(MSG_TRANSFER_LOCK_FOLDER_NOT_FOUND,
|
|
||||||
new Object[] { transferLockFolderPath });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return transferLockFolder;
|
return transferLockFolder;
|
||||||
@@ -213,26 +213,24 @@ public class RepoTransferReceiverImpl implements TransferReceiver
|
|||||||
|
|
||||||
public NodeRef getTempFolder(String transferId)
|
public NodeRef getTempFolder(String transferId)
|
||||||
{
|
{
|
||||||
|
String tenantDomain = tenantService.getUserDomain(AuthenticationUtil.getRunAsUser());
|
||||||
|
NodeRef transferTempFolder = transferTempFolderMap.get(tenantDomain);
|
||||||
|
|
||||||
// Have we already resolved the node that is the temp folder?
|
// Have we already resolved the node that is the temp folder?
|
||||||
// If not then do so.
|
// If not then do so.
|
||||||
if (transferTempFolder == null)
|
if (transferTempFolder == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
ResultSet rs = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH,
|
||||||
|
transferTempFolderPath);
|
||||||
|
if (rs.length() > 0)
|
||||||
{
|
{
|
||||||
if (transferTempFolder == null)
|
transferTempFolder = rs.getNodeRef(0);
|
||||||
{
|
transferTempFolderMap.put(tenantDomain, transferTempFolder);
|
||||||
ResultSet rs = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE,
|
}
|
||||||
SearchService.LANGUAGE_XPATH, transferTempFolderPath);
|
else
|
||||||
if (rs.length() > 0)
|
{
|
||||||
{
|
throw new TransferException(MSG_TRANSFER_TEMP_FOLDER_NOT_FOUND, new Object[] { transferId,
|
||||||
transferTempFolder = rs.getNodeRef(0);
|
transferTempFolderPath });
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new TransferException(MSG_TRANSFER_TEMP_FOLDER_NOT_FOUND, new Object[] { transferId,
|
|
||||||
transferTempFolderPath });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,29 +317,27 @@ public class RepoTransferReceiverImpl implements TransferReceiver
|
|||||||
*/
|
*/
|
||||||
private NodeRef createTransferRecord()
|
private NodeRef createTransferRecord()
|
||||||
{
|
{
|
||||||
log.debug("->createTransferRecord");
|
String tenantDomain = tenantService.getUserDomain(AuthenticationUtil.getRunAsUser());
|
||||||
|
NodeRef inboundTransferRecordsFolder = inboundTransferRecordsFolderMap.get(tenantDomain);
|
||||||
|
|
||||||
if (inboundTransferRecordsFolder == null)
|
if (inboundTransferRecordsFolder == null)
|
||||||
{
|
{
|
||||||
synchronized (this)
|
log.debug("Trying to find transfer records folder: " + inboundTransferRecordsPath);
|
||||||
|
ResultSet rs = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH,
|
||||||
|
inboundTransferRecordsPath);
|
||||||
|
if (rs.length() > 0)
|
||||||
{
|
{
|
||||||
if (inboundTransferRecordsFolder == null)
|
inboundTransferRecordsFolder = rs.getNodeRef(0);
|
||||||
{
|
inboundTransferRecordsFolderMap.put(tenantDomain, inboundTransferRecordsFolder);
|
||||||
log.debug("Trying to find transfer records folder: " + inboundTransferRecordsPath);
|
log.debug("Found inbound transfer records folder: " + inboundTransferRecordsFolder);
|
||||||
ResultSet rs = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE,
|
}
|
||||||
SearchService.LANGUAGE_XPATH, inboundTransferRecordsPath);
|
else
|
||||||
if (rs.length() > 0)
|
{
|
||||||
{
|
throw new TransferException(MSG_INBOUND_TRANSFER_FOLDER_NOT_FOUND,
|
||||||
inboundTransferRecordsFolder = rs.getNodeRef(0);
|
new Object[] { inboundTransferRecordsPath });
|
||||||
log.debug("Found inbound transfer records folder: " + inboundTransferRecordsFolder);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new TransferException(MSG_INBOUND_TRANSFER_FOLDER_NOT_FOUND,
|
|
||||||
new Object[] { inboundTransferRecordsPath });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSSZ");
|
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSSZ");
|
||||||
String timeNow = format.format(new Date());
|
String timeNow = format.format(new Date());
|
||||||
QName recordName = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, timeNow);
|
QName recordName = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, timeNow);
|
||||||
@@ -720,6 +716,11 @@ public class RepoTransferReceiverImpl implements TransferReceiver
|
|||||||
this.transactionService = transactionService;
|
this.transactionService = transactionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTenantService(TenantService tenantService)
|
||||||
|
{
|
||||||
|
this.tenantService = tenantService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param transferLockFolderPath
|
* @param transferLockFolderPath
|
||||||
* the transferLockFolderPath to set
|
* the transferLockFolderPath to set
|
||||||
|
@@ -34,6 +34,8 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import javax.transaction.UserTransaction;
|
import javax.transaction.UserTransaction;
|
||||||
import javax.xml.parsers.SAXParser;
|
import javax.xml.parsers.SAXParser;
|
||||||
@@ -41,6 +43,8 @@ import javax.xml.parsers.SAXParserFactory;
|
|||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
import org.alfresco.repo.transfer.manifest.TransferManifestDeletedNode;
|
import org.alfresco.repo.transfer.manifest.TransferManifestDeletedNode;
|
||||||
import org.alfresco.repo.transfer.manifest.TransferManifestHeader;
|
import org.alfresco.repo.transfer.manifest.TransferManifestHeader;
|
||||||
@@ -91,7 +95,7 @@ public class TransferServiceImpl implements TransferService
|
|||||||
/**
|
/**
|
||||||
* The synchronised list of transfers in progress.
|
* The synchronised list of transfers in progress.
|
||||||
*/
|
*/
|
||||||
private Map<String, TransferStatus> transferMonitoring = Collections.synchronizedMap(new HashMap<String,TransferStatus>());
|
private Map<String, TransferStatus> transferMonitoring = Collections.synchronizedMap(new TreeMap<String,TransferStatus>());
|
||||||
|
|
||||||
private static Log logger = LogFactory.getLog(TransferServiceImpl.class);
|
private static Log logger = LogFactory.getLog(TransferServiceImpl.class);
|
||||||
|
|
||||||
@@ -116,6 +120,7 @@ public class TransferServiceImpl implements TransferService
|
|||||||
private ActionService actionService;
|
private ActionService actionService;
|
||||||
private TransferManifestNodeFactory transferManifestNodeFactory;
|
private TransferManifestNodeFactory transferManifestNodeFactory;
|
||||||
private TransferReporter transferReporter;
|
private TransferReporter transferReporter;
|
||||||
|
private TenantService tenantService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How long to delay while polling for commit status.
|
* How long to delay while polling for commit status.
|
||||||
@@ -861,6 +866,11 @@ public class TransferServiceImpl implements TransferService
|
|||||||
return searchService;
|
return searchService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTenantService(TenantService tenantService)
|
||||||
|
{
|
||||||
|
this.tenantService = tenantService;
|
||||||
|
}
|
||||||
|
|
||||||
public void setTransferSpaceQuery(String transferSpaceQuery)
|
public void setTransferSpaceQuery(String transferSpaceQuery)
|
||||||
{
|
{
|
||||||
this.transferSpaceQuery = transferSpaceQuery;
|
this.transferSpaceQuery = transferSpaceQuery;
|
||||||
@@ -891,9 +901,11 @@ public class TransferServiceImpl implements TransferService
|
|||||||
this.transmitter = transmitter;
|
this.transmitter = transmitter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private NodeRef transferHome;
|
private Map<String,NodeRef> transferHomeMap = new ConcurrentHashMap<String, NodeRef>();
|
||||||
protected NodeRef getTransferHome()
|
protected NodeRef getTransferHome()
|
||||||
{
|
{
|
||||||
|
String tenantDomain = tenantService.getUserDomain(AuthenticationUtil.getRunAsUser());
|
||||||
|
NodeRef transferHome = transferHomeMap.get(tenantDomain);
|
||||||
if(transferHome == null)
|
if(transferHome == null)
|
||||||
{
|
{
|
||||||
String query = transferSpaceQuery;
|
String query = transferSpaceQuery;
|
||||||
@@ -909,6 +921,7 @@ public class TransferServiceImpl implements TransferService
|
|||||||
if (result.getNodeRefs().size() != 0)
|
if (result.getNodeRefs().size() != 0)
|
||||||
{
|
{
|
||||||
transferHome = result.getNodeRef(0);
|
transferHome = result.getNodeRef(0);
|
||||||
|
transferHomeMap.put(tenantDomain, transferHome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return transferHome;
|
return transferHome;
|
||||||
|
@@ -34,7 +34,7 @@ public class TransferTargetImpl implements TransferTarget
|
|||||||
private String endpointProtocol;
|
private String endpointProtocol;
|
||||||
private String endpointHost;
|
private String endpointHost;
|
||||||
private int endpointPort;
|
private int endpointPort;
|
||||||
private String endpointPath;
|
private String endpointPath = "/alfresco/service/api/transfer";
|
||||||
private String username;
|
private String username;
|
||||||
private char[] password;
|
private char[] password;
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
@@ -124,12 +124,14 @@ public interface TransferTarget
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The location of the transfer service on the target endpoint host
|
* The location of the transfer service on the target endpoint host
|
||||||
|
* Defaults to "/alfresco/service/api/transfer", and this shouldn't typically need to change
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String getEndpointPath();
|
String getEndpointPath();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The location of the transfer service on the target endpoint host
|
* The location of the transfer service on the target endpoint host
|
||||||
|
* Defaults to "/alfresco/service/api/transfer", and this shouldn't typically need to change
|
||||||
*/
|
*/
|
||||||
void setEndpointPath(String path);
|
void setEndpointPath(String path);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user