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>
</type>
<type name="trx:transferLock">
<title>Transfer Lock</title>
<description>Node type used to represent the transfer lock node
@@ -182,6 +185,24 @@
</properties>
</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">
<title>Nodes with this aspect are related to a particular transfer.
</title>

View File

@@ -54,6 +54,7 @@
<bean id="transferTransmitter" class="org.alfresco.repo.transfer.HttpClientTransmitterImpl"
init-method="init">
<property name="contentService" ref="ContentService" />
<property name="nodeService" ref="nodeService" />
</bean>
<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.LogFactory;
import com.sun.star.uno.RuntimeException;
/**
* {@inheritDoc JobLockService}
*

View File

@@ -31,12 +31,18 @@ import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ContentData;
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.TransferProgress;
import org.alfresco.service.cmr.transfer.TransferTarget;
@@ -95,6 +101,7 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
private ContentService contentService;
private NodeService nodeService;
public HttpClientTransmitterImpl()
{
@@ -246,14 +253,27 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
beginRequest.setPath(target.getEndpointPath() + "/begin");
try
{
beginRequest.setRequestBody( new NameValuePair[] {
NameValuePair[] nameValuePair = new NameValuePair[] {
new NameValuePair(TransferCommons.PARAM_FROM_REPOSITORYID, fromRepositoryId),
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_MINOR, fromVersion.getVersionMinor()),
new NameValuePair(TransferCommons.PARAM_VERSION_REVISION, fromVersion.getVersionRevision()),
new NameValuePair(TransferCommons.PARAM_VERSION_EDITION, fromVersion.getEdition())
});
new NameValuePair(TransferCommons.PARAM_VERSION_REVISION, fromVersion.getVersionRevision())
};
//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);
@@ -742,4 +762,25 @@ public class HttpClientTransmitterImpl implements TransferTransmitter
{
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>() {
@Override
public Void execute() throws Throwable
{
TransferProgress progress = getProgressMonitor().getProgress(transferId);
@@ -1676,4 +1676,9 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
// needs to be serverDescriptor to pick up versionEdition
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";
/**
* File Root File Transfer
*/
public final static String PARAM_ROOT_FILE_TRANSFER = "rootFileTransfer";
/**
* 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 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
*/
@@ -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 ASSOC_TRANSFER_ORPHAN = QName.createQName(TRANSFER_MODEL_1_0_URI, "orphan");
}

View File

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