String allFiles = "";
if (log.isDebugEnabled())
log.debug("Pasting from clipboard to " + destinationPath);
Iterator clipboardIterator = cb.getContent().iterator();
CoreEvent evt = NetworkPlaceResourceType.getResourceAccessPasteEvent(this,
fileSystemForm.getLaunchSession(),
request,
fileSystemForm.getPath(),
fileSystemForm.getFullURI(),
null);
while (clipboardIterator.hasNext()) {
String divider = allFiles.equals("") ? "" : ", ";
NetworkPlaceClipboardContent element = (NetworkPlaceClipboardContent) clipboardIterator.next();
try {
VFSResource sourceResource = getResourceForPath(fileSystemForm.getLaunchSession(),
request,
response,
element.getPath());
if (log.isDebugEnabled())
log.debug(" Source. = " + sourceResource
+ " (display name = "
+ sourceResource.getDisplayName()
+ ", mount = "
+ sourceResource.isMount()
+ ")");
VFSResource destinationResource = null;
if (log.isDebugEnabled())
log.debug("Paste");
destinationResource = getResourceForPath(fileSystemForm.getLaunchSession(),
request,
response,
DAVUtilities.concatenatePaths(destinationPath, sourceResource.getDisplayName()));
if (log.isDebugEnabled())
log.debug(" Dest. = " + destinationResource);
if (sourceResource.getFullPath().equals(destinationResource.getFullPath())) {
throw new NetworkPlacesException(NetworkPlacesException.ERR_VFS_CANNOT_PASTE_TO_SOURCE);
}
allFiles = allFiles + divider + sourceResource.getDisplayName();
sourceResource.copy(destinationResource, true, true);
if (sourceResource.isCollection()) {
NetworkPlaceResourceType.addDirectoryAttribute(evt, sourceResource.getFullPath(), directorieCounter);
directorieCounter++;
} else {
NetworkPlaceResourceType.addDirectoryAttribute(evt, sourceResource.getFullPath(), fileCounter);
fileCounter++;
}
NetworkPlaceResourceType.addOperationType(evt, element.deleteOnPaste());
CoreServlet.getServlet().fireCoreEvent(evt);
if (element.deleteOnPaste()) {
if (log.isDebugEnabled())
log.debug(" Deleting source");
sourceResource.delete();
}
msgs.add(Globals.MESSAGE_KEY, new ActionMessage("vfs.paste.from.clipboard", allFiles));
} catch (CoreException e) {
errs.add(Globals.ERROR_KEY, e.getBundleActionMessage());
}
}
// The void entries cannot be removed untill the iterator is
// finished with.
cb.clearClipboard();
this.saveErrors(request, errs);
this.saveMessages(request, msgs);
} catch (Exception e) {
CoreEvent evt = NetworkPlaceResourceType.getResourceAccessPasteEvent(this,
fileSystemForm.getLaunchSession(),
request,
fileSystemForm.getPath(),
fileSystemForm.getFullURI(),
e);