diff --git a/config/alfresco/transfer-service-context.xml b/config/alfresco/transfer-service-context.xml
index f7420e745e..f106b85de3 100644
--- a/config/alfresco/transfer-service-context.xml
+++ b/config/alfresco/transfer-service-context.xml
@@ -16,6 +16,9 @@
+
+
+
/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.transfers.childname}/${spaces.transfer_groups.childname}
@@ -54,6 +57,7 @@
+
/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.transfers.childname}
diff --git a/source/java/org/alfresco/repo/transfer/RepoTransferReceiverImpl.java b/source/java/org/alfresco/repo/transfer/RepoTransferReceiverImpl.java
index c2335e021e..24bcf0e6be 100644
--- a/source/java/org/alfresco/repo/transfer/RepoTransferReceiverImpl.java
+++ b/source/java/org/alfresco/repo/transfer/RepoTransferReceiverImpl.java
@@ -29,6 +29,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
@@ -37,6 +38,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
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.RetryingTransactionHelper;
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.RegexQNamePattern;
import org.alfresco.service.transaction.TransactionService;
+import org.alfresco.util.PropertyCheck;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.alfresco.util.PropertyCheck;
import org.springframework.util.FileCopyUtils;
/**
@@ -139,11 +141,12 @@ public class RepoTransferReceiverImpl implements TransferReceiver
private BehaviourFilter behaviourFilter;
private TransferProgressMonitor progressMonitor;
private ActionService actionService;
+ private TenantService tenantService;
- private NodeRef transferLockFolder;
- private NodeRef transferTempFolder;
- private NodeRef inboundTransferRecordsFolder;
-
+ private Map transferLockFolderMap = new ConcurrentHashMap();
+ private Map transferTempFolderMap = new ConcurrentHashMap();
+ private Map inboundTransferRecordsFolderMap = new ConcurrentHashMap();
+
public void init()
{
PropertyCheck.mandatory(this, "nodeService", nodeService);
@@ -185,26 +188,23 @@ public class RepoTransferReceiverImpl implements TransferReceiver
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?
// If not then do so.
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)
- {
- ResultSet rs = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE,
- SearchService.LANGUAGE_XPATH, transferLockFolderPath);
- if (rs.length() > 0)
- {
- transferLockFolder = rs.getNodeRef(0);
- }
- else
- {
- throw new TransferException(MSG_TRANSFER_LOCK_FOLDER_NOT_FOUND,
- new Object[] { transferLockFolderPath });
- }
- }
+ transferLockFolder = rs.getNodeRef(0);
+ transferLockFolderMap.put(tenantDomain, transferLockFolder);
+ }
+ else
+ {
+ throw new TransferException(MSG_TRANSFER_LOCK_FOLDER_NOT_FOUND, new Object[] { transferLockFolderPath });
}
}
return transferLockFolder;
@@ -213,26 +213,24 @@ public class RepoTransferReceiverImpl implements TransferReceiver
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?
// If not then do so.
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)
- {
- ResultSet rs = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE,
- SearchService.LANGUAGE_XPATH, transferTempFolderPath);
- if (rs.length() > 0)
- {
- transferTempFolder = rs.getNodeRef(0);
- }
- else
- {
- throw new TransferException(MSG_TRANSFER_TEMP_FOLDER_NOT_FOUND, new Object[] { transferId,
- transferTempFolderPath });
- }
- }
+ transferTempFolder = rs.getNodeRef(0);
+ transferTempFolderMap.put(tenantDomain, transferTempFolder);
+ }
+ 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()
{
- log.debug("->createTransferRecord");
+ String tenantDomain = tenantService.getUserDomain(AuthenticationUtil.getRunAsUser());
+ NodeRef inboundTransferRecordsFolder = inboundTransferRecordsFolderMap.get(tenantDomain);
+
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)
- {
- 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)
- {
- inboundTransferRecordsFolder = rs.getNodeRef(0);
- log.debug("Found inbound transfer records folder: " + inboundTransferRecordsFolder);
- }
- else
- {
- throw new TransferException(MSG_INBOUND_TRANSFER_FOLDER_NOT_FOUND,
- new Object[] { inboundTransferRecordsPath });
- }
- }
+ inboundTransferRecordsFolder = rs.getNodeRef(0);
+ inboundTransferRecordsFolderMap.put(tenantDomain, inboundTransferRecordsFolder);
+ 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");
String timeNow = format.format(new Date());
QName recordName = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, timeNow);
@@ -720,6 +716,11 @@ public class RepoTransferReceiverImpl implements TransferReceiver
this.transactionService = transactionService;
}
+ public void setTenantService(TenantService tenantService)
+ {
+ this.tenantService = tenantService;
+ }
+
/**
* @param transferLockFolderPath
* the transferLockFolderPath to set
diff --git a/source/java/org/alfresco/repo/transfer/TransferServiceImpl.java b/source/java/org/alfresco/repo/transfer/TransferServiceImpl.java
index 6a3b6695d0..381636d4f7 100644
--- a/source/java/org/alfresco/repo/transfer/TransferServiceImpl.java
+++ b/source/java/org/alfresco/repo/transfer/TransferServiceImpl.java
@@ -34,6 +34,8 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.TreeMap;
+import java.util.concurrent.ConcurrentHashMap;
import javax.transaction.UserTransaction;
import javax.xml.parsers.SAXParser;
@@ -41,6 +43,8 @@ import javax.xml.parsers.SAXParserFactory;
import org.alfresco.error.AlfrescoRuntimeException;
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.transfer.manifest.TransferManifestDeletedNode;
import org.alfresco.repo.transfer.manifest.TransferManifestHeader;
@@ -91,7 +95,7 @@ public class TransferServiceImpl implements TransferService
/**
* The synchronised list of transfers in progress.
*/
- private Map transferMonitoring = Collections.synchronizedMap(new HashMap());
+ private Map transferMonitoring = Collections.synchronizedMap(new TreeMap());
private static Log logger = LogFactory.getLog(TransferServiceImpl.class);
@@ -116,6 +120,7 @@ public class TransferServiceImpl implements TransferService
private ActionService actionService;
private TransferManifestNodeFactory transferManifestNodeFactory;
private TransferReporter transferReporter;
+ private TenantService tenantService;
/**
* How long to delay while polling for commit status.
@@ -861,6 +866,11 @@ public class TransferServiceImpl implements TransferService
return searchService;
}
+ public void setTenantService(TenantService tenantService)
+ {
+ this.tenantService = tenantService;
+ }
+
public void setTransferSpaceQuery(String transferSpaceQuery)
{
this.transferSpaceQuery = transferSpaceQuery;
@@ -891,9 +901,11 @@ public class TransferServiceImpl implements TransferService
this.transmitter = transmitter;
}
- private NodeRef transferHome;
+ private Map transferHomeMap = new ConcurrentHashMap();
protected NodeRef getTransferHome()
{
+ String tenantDomain = tenantService.getUserDomain(AuthenticationUtil.getRunAsUser());
+ NodeRef transferHome = transferHomeMap.get(tenantDomain);
if(transferHome == null)
{
String query = transferSpaceQuery;
@@ -909,6 +921,7 @@ public class TransferServiceImpl implements TransferService
if (result.getNodeRefs().size() != 0)
{
transferHome = result.getNodeRef(0);
+ transferHomeMap.put(tenantDomain, transferHome);
}
}
return transferHome;
diff --git a/source/java/org/alfresco/repo/transfer/TransferTargetImpl.java b/source/java/org/alfresco/repo/transfer/TransferTargetImpl.java
index 800e7e719b..ecbc0c96c5 100644
--- a/source/java/org/alfresco/repo/transfer/TransferTargetImpl.java
+++ b/source/java/org/alfresco/repo/transfer/TransferTargetImpl.java
@@ -34,7 +34,7 @@ public class TransferTargetImpl implements TransferTarget
private String endpointProtocol;
private String endpointHost;
private int endpointPort;
- private String endpointPath;
+ private String endpointPath = "/alfresco/service/api/transfer";
private String username;
private char[] password;
private boolean enabled;
diff --git a/source/java/org/alfresco/service/cmr/transfer/TransferTarget.java b/source/java/org/alfresco/service/cmr/transfer/TransferTarget.java
index c004c0525c..14c44a5164 100644
--- a/source/java/org/alfresco/service/cmr/transfer/TransferTarget.java
+++ b/source/java/org/alfresco/service/cmr/transfer/TransferTarget.java
@@ -124,12 +124,14 @@ public interface TransferTarget
/**
* 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
*/
String getEndpointPath();
/**
* 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);