values = transferService.getTransferTargets();
ScriptTransferTarget[] retVal = new ScriptTransferTarget[values.size()];
int i = 0;
for(TransferTarget value : values)
{
retVal[i++] = new ScriptTransferTarget(value);
}
return retVal;
}
public ScriptTransferTarget getTransferTarget(String name)
{
TransferTarget value = transferService.getTransferTarget(name);
if(value != null)
{
return new ScriptTransferTarget(value);
}
return null;
}
/**
* Transfer a set of nodes, with no callback.
*
* Nodes are to be locked read only on target.
*
* @param targetName the name of the target to transfer to
* @param nodes the nodes to transfer - Java Script Array of either ScriptNodes, NodeRef or String
* @return node ref of transfer report.
*/
@SuppressWarnings("unchecked")
public ScriptNode transferReadOnly(String targetName, Object nodesToTransfer)
{
Object nodesObject = valueConverter.convertValueForJava(nodesToTransfer);
TransferDefinition toTransfer = new TransferDefinition();
toTransfer.setReadOnly(true);
toTransfer.setExcludedAspects(excludedAspects);
Collection nodeCollection = new ArrayList();
if(nodesObject instanceof Collection)
{
for(Object value : (Collection)nodesObject)
{
if(value instanceof NodeRef)
{
nodeCollection.add((NodeRef)value);
}
else if (value instanceof String)
{
nodeCollection.add(new NodeRef((String)value));
}
else
{
throw new IllegalArgumentException("transfer: unknown type in collection: " + value.getClass().getName());
}
}
}
else if(nodesObject instanceof NodeRef)
{
nodeCollection.add((NodeRef)nodesObject);
}
else if (nodesObject instanceof String)
{
nodeCollection.add(new NodeRef((String)nodesObject));
}
else
{
throw new IllegalArgumentException("transfer: unexpected type for nodes :" + nodesObject.getClass().getName());
}
toTransfer.setNodes(nodeCollection);
NodeRef reportNode = transferService.transfer(targetName, toTransfer);
return new ScriptNode(reportNode, serviceRegistry, getScope());
}
/**
* Transfer a set of nodes, with no callback
*
* Nodes are not locked on the target.
*
* @param targetName the name of the target to transfer to
* @param nodes the nodes to transfer - Java Script Array of either ScriptNodes, NodeRef or String
* @return node ref of transfer report.
*/
@SuppressWarnings("unchecked")
public ScriptNode transfer(String targetName, Object nodesToTransfer)
{
Object nodesObject = valueConverter.convertValueForJava(nodesToTransfer);
TransferDefinition toTransfer = new TransferDefinition();
toTransfer.setExcludedAspects(excludedAspects);
Collection nodeCollection = new ArrayList();
if(nodesObject instanceof Collection)
{
for(Object value : (Collection)nodesObject)
{
if(value instanceof NodeRef)
{
nodeCollection.add((NodeRef)value);
}
else if (value instanceof String)
{
nodeCollection.add(new NodeRef((String)value));
}
else
{
throw new IllegalArgumentException("transfer: unknown type in collection: " + value.getClass().getName());
}
}
}
else if(nodesObject instanceof NodeRef)
{
nodeCollection.add((NodeRef)nodesObject);
}
else if (nodesObject instanceof String)
{
nodeCollection.add(new NodeRef((String)nodesObject));
}
else
{
throw new IllegalArgumentException("transfer: unexpected type for nodes :" + nodesObject.getClass().getName());
}
toTransfer.setNodes(nodeCollection);
NodeRef reportNode = transferService.transfer(targetName, toTransfer);
return new ScriptNode(reportNode, serviceRegistry, getScope());
}
/**
* Remove a set of nodes, with no callback
*
* Nodes are not locked on the target.
*
* @param targetName the name of the target to transfer to
* @param nodes the nodes to transfer - Java Script Array of either ScriptNodes, NodeRef or String
* @return node ref of transfer report.
*/
@SuppressWarnings("unchecked")
public ScriptNode remove(String targetName, Object nodesToRemove)
{
Object nodesObject = valueConverter.convertValueForJava(nodesToRemove);
TransferDefinition toTransfer = new TransferDefinition();
toTransfer.setExcludedAspects(excludedAspects);
Collection nodeCollection = new ArrayList();
if(nodesObject instanceof Collection)
{
for(Object value : (Collection)nodesObject)
{
if(value instanceof NodeRef)
{
nodeCollection.add((NodeRef)value);
}
else if (value instanceof String)
{
nodeCollection.add(new NodeRef((String)value));
}
else
{
throw new IllegalArgumentException("transfer: unknown type in collection: " + value.getClass().getName());
}
}
}
else if(nodesObject instanceof NodeRef)
{
nodeCollection.add((NodeRef)nodesObject);
}
else if (nodesObject instanceof String)
{
nodeCollection.add(new NodeRef((String)nodesObject));
}
else
{
throw new IllegalArgumentException("transfer: unexpected type for nodes :" + nodesObject.getClass().getName());
}
toTransfer.setNodesToRemove(nodeCollection);
NodeRef reportNode = transferService.transfer(targetName, toTransfer);
return new ScriptNode(reportNode, serviceRegistry, getScope());
}
public void setServiceRegistry(ServiceRegistry serviceRegistry)
{
this.serviceRegistry = serviceRegistry;
}
public ServiceRegistry getServiceRegistry()
{
return serviceRegistry;
}
public void setExcludedAspects(String[] excludedAspects)
{
for (String aspect : excludedAspects)
{
this.excludedAspects.add(QName.createQName(aspect));
}
}
}