diff --git a/logicaldoc-gui/src/main/java/com/logicaldoc/gui/common/client/util/Util.java b/logicaldoc-gui/src/main/java/com/logicaldoc/gui/common/client/util/Util.java index c308b725d..a61d6c9b3 100644 --- a/logicaldoc-gui/src/main/java/com/logicaldoc/gui/common/client/util/Util.java +++ b/logicaldoc-gui/src/main/java/com/logicaldoc/gui/common/client/util/Util.java @@ -1090,6 +1090,7 @@ public void onResponseReceived(Request request, Response response) { public void run() { LD.clearPrompt(); CookiesManager.removeSid(); + Util.uninstallCloseWindowAlert(); ApplicationRestarting.get(I18N.message("applicationisupagainpleaseclose")).show(); } }; diff --git a/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/services/UpdateService.java b/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/services/UpdateService.java index 848200e22..21c782a0b 100644 --- a/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/services/UpdateService.java +++ b/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/services/UpdateService.java @@ -106,17 +106,6 @@ public interface UpdateService extends RemoteService { */ public String loadPatch() throws ServerException; - /** - * Retrieves the processing status for the specified update/patch file - * - * @param fileName the file to check - * - * @return first string is the processing status: null, running, processed; - * the second string is the log, the third string is the relevant - * command that should be executed - */ - public String[] getStatus(String fileName); - public static class Instance { private static UpdateServiceAsync inst; diff --git a/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/services/UpdateServiceAsync.java b/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/services/UpdateServiceAsync.java index 125a09fb1..cbef7caac 100644 --- a/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/services/UpdateServiceAsync.java +++ b/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/services/UpdateServiceAsync.java @@ -23,10 +23,8 @@ public interface UpdateServiceAsync { void getPatchNotes(String patchFileName, AsyncCallback callback); void downloadPatch(String id, String fileName, long fileSize, AsyncCallback callback); - + void loadUpdate(AsyncCallback callback); - + void loadPatch(AsyncCallback callback); - - void getStatus(String fileName, AsyncCallback callback); } \ No newline at end of file diff --git a/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/system/update/PatchPanel.java b/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/system/update/PatchPanel.java index 957a9bba6..d97d82129 100644 --- a/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/system/update/PatchPanel.java +++ b/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/system/update/PatchPanel.java @@ -4,6 +4,11 @@ import java.util.Date; import java.util.List; +import com.google.gwt.http.client.Request; +import com.google.gwt.http.client.RequestBuilder; +import com.google.gwt.http.client.RequestCallback; +import com.google.gwt.http.client.RequestException; +import com.google.gwt.http.client.Response; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; import com.logicaldoc.gui.common.client.Feature; @@ -469,34 +474,46 @@ public void onSuccess(String path) { private void getStatus(GUIPatch patch) { LD.updatingServer(); - UpdateService.Instance.get().getStatus(patch.getFile(), new AsyncCallback() { - @Override - public void onFailure(Throwable caugtht) { - scheduleGetStatus(patch); - } + RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, + Util.contextPath() + "updatestatus?fileName=" + patch.getFile()); - @Override - public void onSuccess(String[] status) { - log.setValue(status[1]); - - Date now = new Date(); - long elapsedTime = now.getTime() - lastConfirmed.getTime(); - - String statusLabel = status[0]; - - if ("processed".equals(statusLabel)) { - LD.clearPrompt(); - ok.setDisabled(patch.isRestart()); - GuiLog.info(I18N.message("patchinstalled")); - } else if (!"running".equals(statusLabel) && elapsedTime > MAX_WAIT_TIME) { - LD.clearPrompt(); - ApplicationRestarting.get(I18N.message("patchnotstarted", status[2])).show(); - } else { - scheduleGetStatus(patch); + try { + builder.sendRequest(null, new RequestCallback() { + public void onError(Request request, Throwable exception) { + // Nothing to do } - } - }); + + public void onResponseReceived(Request request, Response response) { + if (response != null && response.getStatusCode() < 400) { + String[] tokens = response.getText().split("\\|"); + String statusLabel = tokens[0]; + String command = tokens[1]; + String logContent = tokens[2]; + + log.setValue(logContent); + + Date now = new Date(); + long elapsedTime = now.getTime() - lastConfirmed.getTime(); + + if ("processed".equals(statusLabel)) { + LD.clearPrompt(); + ok.setDisabled(patch.isRestart()); + GuiLog.info(I18N.message("patchinstalled")); + if(patch.isRestart()) + Util.waitForUpAndRunning(Session.get().getTenantName(), I18N.getLocale()); + } else if (!"running".equals(statusLabel) && elapsedTime > MAX_WAIT_TIME) { + LD.clearPrompt(); + ApplicationRestarting.get(I18N.message("patchnotstarted", command)).show(); + } else { + scheduleGetStatus(patch); + } + } + } + }); + } catch (RequestException e) { + // Nothing to do + } } private void scheduleGetStatus(GUIPatch patch) { diff --git a/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/system/update/UpdatePanel.java b/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/system/update/UpdatePanel.java index 36f57e5dc..cede64db1 100644 --- a/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/system/update/UpdatePanel.java +++ b/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/system/update/UpdatePanel.java @@ -2,6 +2,11 @@ import java.util.Date; +import com.google.gwt.http.client.Request; +import com.google.gwt.http.client.RequestBuilder; +import com.google.gwt.http.client.RequestCallback; +import com.google.gwt.http.client.RequestException; +import com.google.gwt.http.client.Response; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; import com.logicaldoc.gui.common.client.Feature; @@ -318,34 +323,46 @@ private void switchLogView() { private void getStatus() { LD.updatingServer(); - UpdateService.Instance.get().getStatus(updateFileName, new AsyncCallback() { - @Override - public void onFailure(Throwable caugtht) { - scheduleGetStatus(); - } - - @Override - public void onSuccess(String[] status) { - log.setValue(status[1]); - - Date now = new Date(); - long elapsedTime = now.getTime() - lastConfirmed.getTime(); + RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, + Util.contextPath() + "updatestatus?fileName=" + updateFileName); - String statusLabel = status[0]; + try { + builder.sendRequest(null, new RequestCallback() { + public void onError(Request request, Throwable exception) { + // Nothing to do + } - if ("processed".equals(statusLabel)) { - LD.clearPrompt(); - ok.setDisabled(false); - GuiLog.info(I18N.message("updateinstalled")); - } else if (!"running".equals(statusLabel) && elapsedTime > MAX_WAIT_TIME) { - LD.clearPrompt(); - ApplicationRestarting.get(I18N.message("updatenotstarted", status[2])).show(); - } else { - scheduleGetStatus(); + public void onResponseReceived(Request request, Response response) { + if (response != null && response.getStatusCode() < 400) { + String[] tokens = response.getText().split("\\|"); + String statusLabel = tokens[0]; + String command = tokens[1]; + String logContent = tokens[2]; + + log.setValue(logContent); + + Date now = new Date(); + long elapsedTime = now.getTime() - lastConfirmed.getTime(); + + if ("processed".equals(statusLabel)) { + LD.clearPrompt(); + ok.setDisabled(false); + Util.uninstallCloseWindowAlert(); + GuiLog.info(I18N.message("updateinstalled")); + Util.waitForUpAndRunning(Session.get().getTenantName(), I18N.getLocale()); + } else if (!"running".equals(statusLabel) && elapsedTime > MAX_WAIT_TIME) { + LD.clearPrompt(); + ApplicationRestarting.get(I18N.message("updatenotstarted", command)).show(); + } else { + scheduleGetStatus(); + } + } } - } - }); + }); + } catch (RequestException e) { + // Nothing to do + } } private void scheduleGetStatus() { diff --git a/logicaldoc-gui/src/main/resources/com/logicaldoc/gui/common/Common.gwt.xml b/logicaldoc-gui/src/main/resources/com/logicaldoc/gui/common/Common.gwt.xml index b9fc165e0..4f7e83d04 100644 --- a/logicaldoc-gui/src/main/resources/com/logicaldoc/gui/common/Common.gwt.xml +++ b/logicaldoc-gui/src/main/resources/com/logicaldoc/gui/common/Common.gwt.xml @@ -14,6 +14,6 @@ - + \ No newline at end of file diff --git a/logicaldoc-i18n/src/main/resources/i18n/messages.properties b/logicaldoc-i18n/src/main/resources/i18n/messages.properties index 6bdd497e3..3eeadc6ce 100644 --- a/logicaldoc-i18n/src/main/resources/i18n/messages.properties +++ b/logicaldoc-i18n/src/main/resources/i18n/messages.properties @@ -2925,7 +2925,7 @@ uploadpatch = Upload Patch notpatch = This is not a valid patch notpatchforcurrentrel = This patch does not apply to current release patchinstalled = The patch has been installed -systemupdating = The system is updating, please wait. +systemupdating = The system is updating, please wait systembeingupdated = The system is being updated patchnotstarted = It seems that the system was unable to start the patch.
Please open an elevated shell on the server and run the command:
{0} updatenotstarted = It seems that the system was unable to start the update.
Please open an elevated shell on the server and run the command:
{0} @@ -2947,4 +2947,4 @@ responderemail = Responder email getlink = Get link prefilledfields = Pre-filled fields prefilledfieldshint = You may pre-fill some fields to help the responders -prefillfileds = Pre-fill fields \ No newline at end of file +prefillfileds = Pre-fill fields \ No newline at end of file