Merge BRANCHES/DEV/BRIAN/FSTR to HEAD:

28906: File Transfer Receiver SPRINT1
 29365: Initial check in
 29378: Configuration properties can now be located in "filetransferreceiver.properties" separated from spring configuration files.
 29417: Delete, first check in
 29450: Now multiple distinct contents can be send over in one transfer.
 29516: 
 29517: 
 29531: Manage cases like /F1/F2/F3 ... becoming /F3/F2/F1
 29550: FTR:
    - Tidied project classpath
    - Removed incorrect reference to OpenOffice RuntimeException in JobLockServiceImpl
    - Removed references to StringOutputStream



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29643 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Brian Remmington
2011-08-09 21:02:03 +00:00
parent 62cfc60ce9
commit 153e2f8d33
10 changed files with 412 additions and 327 deletions

View File

@@ -96,6 +96,9 @@
</properties> </properties>
</type> </type>
<type name="trx:transferLock"> <type name="trx:transferLock">
<title>Transfer Lock</title> <title>Transfer Lock</title>
<description>Node type used to represent the transfer lock node <description>Node type used to represent the transfer lock node
@@ -182,6 +185,24 @@
</properties> </properties>
</aspect> </aspect>
<aspect name="trx:fileTransferTarget">
<title>File Transfer Target</title>
<description>Aspect used to model a receiving root for file transfer</description>
<associations>
<association name="trx:rootFileTransfer">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:folder</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</aspect>
<aspect name="trx:transferRelated"> <aspect name="trx:transferRelated">
<title>Nodes with this aspect are related to a particular transfer. <title>Nodes with this aspect are related to a particular transfer.
</title> </title>

View File

@@ -54,6 +54,7 @@
<bean id="transferTransmitter" class="org.alfresco.repo.transfer.HttpClientTransmitterImpl" <bean id="transferTransmitter" class="org.alfresco.repo.transfer.HttpClientTransmitterImpl"
init-method="init"> init-method="init">
<property name="contentService" ref="ContentService" /> <property name="contentService" ref="ContentService" />
<property name="nodeService" ref="nodeService" />
</bean> </bean>
<bean id="transferVersionChecker" class="org.alfresco.repo.transfer.TransferVersionCheckerImpl"> <bean id="transferVersionChecker" class="org.alfresco.repo.transfer.TransferVersionCheckerImpl">

View File

@@ -37,8 +37,6 @@ import org.alfresco.util.VmShutdownListener;
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 com.sun.star.uno.RuntimeException;
/** /**
* {@inheritDoc JobLockService} * {@inheritDoc JobLockService}
* *

View File

@@ -31,12 +31,18 @@ import java.nio.ByteBuffer;
import java.nio.channels.Channels; import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel; import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel; import java.nio.channels.WritableByteChannel;
import java.util.ArrayList;
import java.util.Collections;
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.TreeMap;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.transfer.TransferException; import org.alfresco.service.cmr.transfer.TransferException;
import org.alfresco.service.cmr.transfer.TransferProgress; import org.alfresco.service.cmr.transfer.TransferProgress;
import org.alfresco.service.cmr.transfer.TransferTarget; import org.alfresco.service.cmr.transfer.TransferTarget;
@@ -95,6 +101,7 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
private ContentService contentService; private ContentService contentService;
private NodeService nodeService;
public HttpClientTransmitterImpl() public HttpClientTransmitterImpl()
{ {
@@ -246,14 +253,27 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
beginRequest.setPath(target.getEndpointPath() + "/begin"); beginRequest.setPath(target.getEndpointPath() + "/begin");
try try
{ {
beginRequest.setRequestBody( new NameValuePair[] { NameValuePair[] nameValuePair = new NameValuePair[] {
new NameValuePair(TransferCommons.PARAM_FROM_REPOSITORYID, fromRepositoryId), new NameValuePair(TransferCommons.PARAM_FROM_REPOSITORYID, fromRepositoryId),
new NameValuePair(TransferCommons.PARAM_ALLOW_TRANSFER_TO_SELF, "false"), new NameValuePair(TransferCommons.PARAM_ALLOW_TRANSFER_TO_SELF, "false"),
new NameValuePair(TransferCommons.PARAM_VERSION_EDITION, fromVersion.getEdition()),
new NameValuePair(TransferCommons.PARAM_VERSION_MAJOR, fromVersion.getVersionMajor()), new NameValuePair(TransferCommons.PARAM_VERSION_MAJOR, fromVersion.getVersionMajor()),
new NameValuePair(TransferCommons.PARAM_VERSION_MINOR, fromVersion.getVersionMinor()), new NameValuePair(TransferCommons.PARAM_VERSION_MINOR, fromVersion.getVersionMinor()),
new NameValuePair(TransferCommons.PARAM_VERSION_REVISION, fromVersion.getVersionRevision()), new NameValuePair(TransferCommons.PARAM_VERSION_REVISION, fromVersion.getVersionRevision())
new NameValuePair(TransferCommons.PARAM_VERSION_EDITION, fromVersion.getEdition()) };
});
//add the parameter defining the root of the transfer on the file system if exist
NodeRef transferRootNode = this.getFileTransferRootNodeRef(target.getNodeRef());
if (transferRootNode != null)
{
//add the parameter
ArrayList<NameValuePair> nameValuePairArrayList= new ArrayList<NameValuePair>(nameValuePair.length + 1);
Collections.addAll(nameValuePairArrayList,nameValuePair);
nameValuePairArrayList.add(new NameValuePair(TransferCommons.PARAM_ROOT_FILE_TRANSFER, transferRootNode.toString()));
nameValuePair = nameValuePairArrayList.toArray(new NameValuePair[0]);
}
beginRequest.setRequestBody(nameValuePair);
int responseStatus = httpClient.executeMethod(hostConfig, beginRequest, httpState); int responseStatus = httpClient.executeMethod(hostConfig, beginRequest, httpState);
@@ -742,4 +762,25 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
{ {
this.jsonErrorSerializer = jsonErrorSerializer; this.jsonErrorSerializer = jsonErrorSerializer;
} }
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
private NodeRef getFileTransferRootNodeRef(NodeRef transferNodeRef)
{
//testing if transferring to file system
if(!nodeService.hasAspect(transferNodeRef, TransferModel.ASPECT_FILE_TRANSFER_TARGET))
return null;
//get association
List<AssociationRef> assocs = nodeService.getTargetAssocs(transferNodeRef, TransferModel.ASSOC_ROOT_FILE_TRANSFER);
if(assocs.size() == 0 || assocs.size() > 1)
return null;
return assocs.get(0).getTargetRef();
}
} }

View File

@@ -558,7 +558,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
*/ */
final RetryingTransactionCallback<Void> timeoutCB = new RetryingTransactionCallback<Void>() { final RetryingTransactionCallback<Void> timeoutCB = new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable public Void execute() throws Throwable
{ {
TransferProgress progress = getProgressMonitor().getProgress(transferId); TransferProgress progress = getProgressMonitor().getProgress(transferId);
@@ -1676,4 +1676,9 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
// needs to be serverDescriptor to pick up versionEdition // needs to be serverDescriptor to pick up versionEdition
return new TransferVersionImpl(d); return new TransferVersionImpl(d);
} }
public void setFileTransferRootNodeFileFileSystem(String rootFileSystem)
{
//just ignore, no relevant for transferring on file system
}
} }

View File

@@ -67,6 +67,12 @@ public class TransferCommons
*/ */
public final static String PARAM_VERSION_EDITION = "versionEdition"; public final static String PARAM_VERSION_EDITION = "versionEdition";
/**
* File Root File Transfer
*/
public final static String PARAM_ROOT_FILE_TRANSFER = "rootFileTransfer";
/** /**
* Mapping between contentUrl and part name. * Mapping between contentUrl and part name.
* *

View File

@@ -47,6 +47,12 @@ public interface TransferModel
static final QName ASPECT_ALIEN = QName.createQName(TRANSFER_MODEL_1_0_URI, "alien"); static final QName ASPECT_ALIEN = QName.createQName(TRANSFER_MODEL_1_0_URI, "alien");
static final QName PROP_INVADED_BY = QName.createQName(TRANSFER_MODEL_1_0_URI, "invadedBy"); static final QName PROP_INVADED_BY = QName.createQName(TRANSFER_MODEL_1_0_URI, "invadedBy");
/**
* Aspect : fileTransferTarget
*/
static final QName ASPECT_FILE_TRANSFER_TARGET = QName.createQName(TRANSFER_MODEL_1_0_URI, "fileTransferTarget");
static final QName ASSOC_ROOT_FILE_TRANSFER = QName.createQName(TRANSFER_MODEL_1_0_URI, "rootFileTransfer");
/* /*
* Type : Transfer Group * Type : Transfer Group
*/ */
@@ -92,4 +98,5 @@ public interface TransferModel
static final QName TYPE_TEMP_TRANSFER_STORE = QName.createQName(TRANSFER_MODEL_1_0_URI, "tempTransferStore"); static final QName TYPE_TEMP_TRANSFER_STORE = QName.createQName(TRANSFER_MODEL_1_0_URI, "tempTransferStore");
static final QName ASSOC_TRANSFER_ORPHAN = QName.createQName(TRANSFER_MODEL_1_0_URI, "orphan"); static final QName ASSOC_TRANSFER_ORPHAN = QName.createQName(TRANSFER_MODEL_1_0_URI, "orphan");
} }

View File

@@ -142,4 +142,10 @@ public interface TransferReceiver
* @param transferId * @param transferId
*/ */
InputStream getTransferReport(String transferId); InputStream getTransferReport(String transferId);
/**
* set the root node for the file system receiver
* @param rootFileSystem
*/
void setFileTransferRootNodeFileFileSystem(String rootFileSystem);
} }