// skip
return;
}
// Remember children of orginal source
ObjectNode sourceNode =
structureHelper.retrieve(token, sourceUri, false);
Enumeration sourceNodeChildren = sourceNode.enumerateChildren();
ObjectNode destinationNode = null;
// now let the client redirect
if (copyRedirector != null) { // TODO: dump re-directing
CopyRoute copyRoute = new CopyRoute(sourceUri, destinationUri);
copyRoute = copyRedirector.getRedirectedCopyRoute(copyRoute);
sourceUri = copyRoute.getSourceUri();
destinationUri = copyRoute.getDestinationUri();
sourceNode = structureHelper.retrieve(token, sourceUri, false);
// note that childrenList is *not* re-assigned. This might be a bug ...
}
// notify CopyListener
if (copyListener != null) {
copyListener.beforeCopy(sourceUri, destinationUri, isRootOfCopy );
}
// delete target if it is the root of the copied tree
if (isRootOfCopy && parameters.isDeleteCreate()) {
try {
// We make sure the object we want to overwrite exists
structureHelper.retrieve(token, destinationUri);
if (parameters.getParameter(PARENT_BINDINGS) != null) {
Map parentBindings = (Map)parameters.getParameter(PARENT_BINDINGS);
Iterator i = parentBindings.entrySet().iterator();
while (i.hasNext()) {
Map.Entry me = (Map.Entry)i.next();
String uriToDelete = (String)me.getKey()+"/"+(String)me.getValue();
delete(token, uriToDelete, deleteRedirector, deleteListener);
}
}
else {
delete(token, destinationUri, deleteRedirector, deleteListener);
}
} catch(ObjectNotFoundException onf) {
// Silent catch, the target doesn't exist
} catch(DeleteMacroException s) {
Enumeration en = s.enumerateExceptions();
if (en.hasMoreElements()) {
throw (SlideException)en.nextElement();
}
}
}
boolean destinationExists = destinationExists(token, destinationUri);
// Creating the copy
if (parameters.isDeleteCreate() || !destinationExists) {
try {
Map alreadyCopied = (Map)parameters.getParameter( ALREADY_COPIED );
if (alreadyCopied.containsKey(sourceNode.getUuri())) {
// If a COPY request would cause a new resource to be created
// as a copy of an existing resource, and that COPY request
// has already created a copy of that existing resource,
// the COPY request instead creates another binding to the
// previous copy, instead of creating a new resource.
UriHandler destinationUh = new UriHandler(destinationUri);
UriHandler destinationParentUh = destinationUh.getParent();
String segment = destinationUh.getLastSegment();
destinationNode = structureHelper.retrieve( token, (String)alreadyCopied.get(sourceNode.getUuri()) );
ObjectNode destinationParentNode = structureHelper.retrieve( token, destinationParentUh.toString() );
structureHelper.addBinding( token, destinationParentNode, segment, destinationNode );
}
else {
structureHelper.create(token, sourceNode.copyObject(),
destinationUri);