CID-1114591 Replace duplicated functionality with a call to super like the other state classes
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9cfab9b8 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9cfab9b8 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9cfab9b8 Branch: refs/heads/master Commit: 9cfab9b8156087f275947a9a957f32fc6f5a2355 Parents: 90df7cf Author: Hugo Trippaers <htrippa...@schubergphilis.com> Authored: Fri Sep 19 14:42:20 2014 +0200 Committer: Hugo Trippaers <htrippa...@schubergphilis.com> Committed: Fri Sep 19 14:42:20 2014 +0200 ---------------------------------------------------------------------- .../storage/download/DownloadActiveState.java | 46 +++++++++----------- 1 file changed, 21 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9cfab9b8/server/src/com/cloud/storage/download/DownloadActiveState.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/download/DownloadActiveState.java b/server/src/com/cloud/storage/download/DownloadActiveState.java index 59709f2..9a22eb8 100644 --- a/server/src/com/cloud/storage/download/DownloadActiveState.java +++ b/server/src/com/cloud/storage/download/DownloadActiveState.java @@ -35,39 +35,35 @@ public abstract class DownloadActiveState extends DownloadState { s_logger.trace("handleAnswer, answer status=" + answer.getDownloadStatus() + ", curr state=" + getName()); } switch (answer.getDownloadStatus()) { - case DOWNLOAD_IN_PROGRESS: - getDownloadListener().scheduleStatusCheck(RequestType.GET_STATUS); - return Status.DOWNLOAD_IN_PROGRESS.toString(); - case DOWNLOADED: - getDownloadListener().cancelTimeoutTask(); - return Status.DOWNLOADED.toString(); - case NOT_DOWNLOADED: - getDownloadListener().scheduleStatusCheck(RequestType.GET_STATUS); - return Status.NOT_DOWNLOADED.toString(); - case DOWNLOAD_ERROR: - getDownloadListener().cancelStatusTask(); - getDownloadListener().cancelTimeoutTask(); - return Status.DOWNLOAD_ERROR.toString(); - case UNKNOWN: - getDownloadListener().cancelStatusTask(); - getDownloadListener().cancelTimeoutTask(); - return Status.DOWNLOAD_ERROR.toString(); - default: - return null; + case DOWNLOAD_IN_PROGRESS: + getDownloadListener().scheduleStatusCheck(RequestType.GET_STATUS); + return Status.DOWNLOAD_IN_PROGRESS.toString(); + case DOWNLOADED: + getDownloadListener().cancelTimeoutTask(); + return Status.DOWNLOADED.toString(); + case NOT_DOWNLOADED: + getDownloadListener().scheduleStatusCheck(RequestType.GET_STATUS); + return Status.NOT_DOWNLOADED.toString(); + case DOWNLOAD_ERROR: + getDownloadListener().cancelStatusTask(); + getDownloadListener().cancelTimeoutTask(); + return Status.DOWNLOAD_ERROR.toString(); + case UNKNOWN: + getDownloadListener().cancelStatusTask(); + getDownloadListener().cancelTimeoutTask(); + return Status.DOWNLOAD_ERROR.toString(); + default: + return null; } } @Override public void onEntry(String prevState, DownloadEvent event, Object evtObj) { - if (s_logger.isTraceEnabled()) { - getDownloadListener().log("onEntry, prev state= " + prevState + ", curr state=" + getName() + ", event=" + event, Level.TRACE); - } + super.onEntry(prevState, event, evtObj); if (event == DownloadEvent.DOWNLOAD_ANSWER) { - getDownloadListener().callback((DownloadAnswer)evtObj); getDownloadListener().setLastUpdated(); } - } @Override @@ -79,7 +75,7 @@ public abstract class DownloadActiveState extends DownloadState { if (s_logger.isTraceEnabled()) { getDownloadListener().log("handleTimeout, updateMs=" + updateMs + ", curr state= " + getName(), Level.TRACE); } - String newState = this.getName(); + String newState = getName(); if (updateMs > 5 * DownloadListener.STATUS_POLL_INTERVAL) { newState = Status.DOWNLOAD_ERROR.toString(); getDownloadListener().log("timeout: transitioning to download error state, currstate=" + getName(), Level.DEBUG);