Minor adjustment to the Transfer Service JS API so that the transfer operation returns a ScriptNode rather than a NodeRef.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19248 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Brian Remmington
2010-03-12 11:21:10 +00:00
parent 91bc36f401
commit 731bd448bb
3 changed files with 11 additions and 16 deletions

View File

@@ -30,8 +30,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.transfer.TransferDefinition;
import org.alfresco.service.cmr.transfer.TransferService;
import org.alfresco.service.cmr.transfer.TransferTarget;
import org.mozilla.javascript.NativeArray;
import org.mozilla.javascript.Scriptable;
/**
* Java Script Transfer Service. Adapts the Java Transfer Service to
@@ -118,7 +116,8 @@ public class ScriptTransferService extends BaseScopableProcessorExtension
* @param nodes the nodes to transfer - Java Script Array of either ScriptNodes, NodeRef or String
* @return node ref of transfer report.
*/
public NodeRef transfer(String targetName, Object nodesToTransfer)
@SuppressWarnings("unchecked")
public ScriptNode transfer(String targetName, Object nodesToTransfer)
{
Object nodesObject = valueConverter.convertValueForJava(nodesToTransfer);
@@ -158,9 +157,9 @@ public class ScriptTransferService extends BaseScopableProcessorExtension
}
toTransfer.setNodes(nodeCollection);
NodeRef retVal = transferService.transfer(targetName, toTransfer);
NodeRef reportNode = transferService.transfer(targetName, toTransfer);
return retVal;
return new ScriptNode(reportNode, serviceRegistry, getScope());
}
public void setServiceRegistry(ServiceRegistry serviceRegistry)

View File

@@ -24,7 +24,6 @@ import java.util.Map;
import java.util.Set;
import org.alfresco.repo.jscript.ClasspathScriptLocation;
import org.alfresco.repo.transfer.TransferServiceImpl;
import org.alfresco.repo.transfer.TransferTargetImpl;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.ScriptLocation;
@@ -50,19 +49,16 @@ public class ScriptTransferServiceTest extends BaseAlfrescoSpringTest
// String GUEST_HOME_XPATH_QUERY = "/{http://www.alfresco.org/model/application/1.0}company_home/{http://www.alfresco.org/model/application/1.0}guest_home";
private ScriptService scriptService;
private TransferService transferService;
private TransferService transferServiceImpl;
private ScriptTransferService scriptTransferService;
@SuppressWarnings("deprecation")
protected void onSetUpInTransaction() throws Exception
{
super.onSetUpInTransaction();
// Get the required services
this.scriptService = (ScriptService)this.applicationContext.getBean("ScriptService");
this.transferService = (TransferService)this.applicationContext.getBean("TransferService");
this.transferServiceImpl = (TransferServiceImpl)this.applicationContext.getBean("transferService");
this.scriptTransferService = (ScriptTransferService)this.applicationContext.getBean("transferServiceScript");
}
@@ -71,8 +67,6 @@ public class ScriptTransferServiceTest extends BaseAlfrescoSpringTest
public void testJSAPI() throws Exception
{
String name = "testTransferJSAPI";
/**
* Prepare some dummy data for tests
*/

View File

@@ -109,7 +109,7 @@ public interface TransferService
public void transferAsync(String targetName, TransferDefinition definition, TransferCallback... callbacks) throws TransferException;
/**
* Verify a target is available and that the configured credentials correctly identify an admin user.
* Verify a target is available and that the configured credentials are valid.
* @throws TransferException
*/
public void verify(TransferTarget target) throws TransferException;
@@ -128,7 +128,8 @@ public interface TransferService
* @param password,
* @return the newly create transfer target.
*/
public TransferTarget createAndSaveTransferTarget(String name, String title, String description, String endpointProtocol, String endpointHost, int endpointPort, String endpointPath, String username, char[] password) throws TransferException;
public TransferTarget createAndSaveTransferTarget(String name, String title, String description, String endpointProtocol,
String endpointHost, int endpointPort, String endpointPath, String username, char[] password) throws TransferException;
/**
* Creates an in memory transfer target. Before it is used it must be populated with the following values and
@@ -217,9 +218,10 @@ public interface TransferService
* Calling this method for a transfer that does not exist, possibly because it has already finished, has no
* effect and will not throw an exception.
*
* The transfer handle is returned by a TransferEventBegin event callback.
* The transfer identifier can be obtained from the TransferEventBegin event that is passed to registered callbacks when
* transfer starts.
*
* @param transferId the unique identifier for the instance of the transfer to cancel.
* @param transferId the unique identifier of the transfer to cancel.
*
* @see TransferEventBegin;
*/