private void copyObjects() {
try {
final S3Object[] sourceObjects = getSelectedObjects();
CopyObjectsDialog dialog = new CopyObjectsDialog(ownerFrame,
"Copy or Move Objects", skinsFactory,
sourceObjects, bucketTableModel.getBuckets());
dialog.setVisible(true);
if (dialog.isCopyActionApproved()) {
final String currentBucketName = getCurrentSelectedBucket().getName();
final String destinationBucketName = dialog.getDestinationBucketName();
final String[] sourceObjectKeys = dialog.getSourceObjectKeys();
final S3Object[] destinationObjects = dialog.getDestinationObjects();
final boolean isDeleteAfterCopy = dialog.isMoveOptionSelected();
final boolean retainAcls = dialog.isCopyOriginalAccessControlLists();
dialog.dispose();
if (!destinationBucketName.equals(currentBucketName)) {
cachedBuckets.remove(destinationBucketName);
}
runInBackgroundThread(new Runnable() {
public void run() {
if (retainAcls) {
// Retain ACL settings from original objects.
if (!s3ServiceMulti.getObjectACLs(
getCurrentSelectedBucket(), sourceObjects))
{
return;
}
for (int i = 0; i < sourceObjects.length; i++) {
destinationObjects[i].setAcl(
sourceObjects[i].getAcl());
}
}
// Copy objects. Metadata is retained, not replaced.
s3ServiceMulti.copyObjects(currentBucketName, destinationBucketName,
sourceObjectKeys, destinationObjects, false);
if (isDeleteAfterCopy) {
final S3Object[] sourceObjects = new S3Object[sourceObjectKeys.length];
for (int i = 0; i < sourceObjectKeys.length; i++) {
sourceObjects[i] = new S3Object(sourceObjectKeys[i]);
}
s3ServiceMulti.deleteObjects(getCurrentSelectedBucket(), sourceObjects);
}
if (destinationBucketName.equals(currentBucketName) || isDeleteAfterCopy) {
// Refesh object listing for current bucket if the bucket's contents
// have changed.
listObjects();
}
}
});
} else {
dialog.dispose();
}
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
stopProgressDialog();