objOnImageStore.processEvent(Event.OperationSuccessed, answer);
objOnImageStore.processEvent(Event.CopyingRequested);
CopyCommand cmd = new CopyCommand(objOnImageStore.getTO(), destData.getTO(), _copyvolumewait, _mgmtServer.getExecuteInSequence());
EndPoint ep = selector.select(objOnImageStore, destData);
answer = ep.sendMessage(cmd);
if (answer == null || !answer.getResult()) {
if (answer != null) {
s_logger.debug("copy to primary store failed: " + answer.getDetails());
}
objOnImageStore.processEvent(Event.OperationFailed);
imageStore.delete(objOnImageStore);
return answer;
}
objOnImageStore.processEvent(Event.OperationSuccessed);
imageStore.delete(objOnImageStore);
return answer;
} else {
DataObject cacheData = cacheMgr.createCacheObject(srcData, destScope);
CopyCommand cmd = new CopyCommand(cacheData.getTO(), destData.getTO(), _copyvolumewait, _mgmtServer.getExecuteInSequence());
EndPoint ep = selector.select(cacheData, destData);
Answer answer = ep.sendMessage(cmd);
// delete volume on cache store
if (cacheData != null) {
cacheMgr.deleteCacheObject(cacheData);