Skip to content

Commit

Permalink
improved feedback to user when ugrading and patching
Browse files Browse the repository at this point in the history
  • Loading branch information
car031 committed Jul 3, 2023
1 parent b4f3b3c commit 42352c0
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ public interface UpdateServiceAsync {
void getPatchNotes(String patchFileName, AsyncCallback<String[]> callback);

void downloadPatch(String id, String fileName, long fileSize, AsyncCallback<Void> callback);

void loadUpdate(AsyncCallback<String> callback);

void loadPatch(AsyncCallback<String> callback);

void getStatus(String fileName, AsyncCallback<String[]> callback);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -469,34 +474,46 @@ public void onSuccess(String path) {

private void getStatus(GUIPatch patch) {
LD.updatingServer();
UpdateService.Instance.get().getStatus(patch.getFile(), new AsyncCallback<String[]>() {

@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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -318,34 +323,46 @@ private void switchLogView() {

private void getStatus() {
LD.updatingServer();
UpdateService.Instance.get().getStatus(updateFileName, new AsyncCallback<String[]>() {

@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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@

<!-- Compile for firefox only more fastly for developement and hosted mode -->

<set-property name="user.agent" value="gecko1_8" />
<set-property name="user.agent" value="gecko1_8,safari" />
<entry-point class="com.logicaldoc.gui.common.client.Common" />
</module>
4 changes: 2 additions & 2 deletions logicaldoc-i18n/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br/>Please open an elevated shell on the server and run the command:<br/> <b>{0}</b>
updatenotstarted = It seems that the system was unable to start the update.<br/>Please open an elevated shell on the server and run the command:<br/> <b>{0}</b>
Expand All @@ -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
prefillfileds = Pre-fill fields

0 comments on commit 42352c0

Please sign in to comment.