show error message when there is a connection problem issue

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/message-conversations@154652 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2017-09-27 12:43:48 +00:00
parent 652d1d5acc
commit 740bb2b707
4 changed files with 102 additions and 86 deletions

View File

@ -3,8 +3,6 @@ package org.gcube.portets.user.message_conversations.client;
import org.gcube.portets.user.message_conversations.client.ui.ApplicationView; import org.gcube.portets.user.message_conversations.client.ui.ApplicationView;
import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.RootPanel;
/** /**
@ -13,28 +11,14 @@ import com.google.gwt.user.client.ui.RootPanel;
public class MessageConversations implements EntryPoint { public class MessageConversations implements EntryPoint {
public static final String DIV_CONTAINER_ID = "create-users-container"; public static final String DIV_CONTAINER_ID = "create-users-container";
public static final String ARTIFACT_ID = "messages"; public static final String ARTIFACT_ID = "messages";
/**
* Create a remote service proxy to talk to the server-side Greeting service.
*/
private final MessageServiceAsync convService = GWT.create(MessageService.class);
private ApplicationView ap; private ApplicationView ap;
/** /**
* This is the entry point method. * This is the entry point method.
*/ */
public void onModuleLoad() { public void onModuleLoad() {
((ServiceDefTarget) convService).setServiceEntryPoint(Utils.getServiceEntryPoint());
ap = new ApplicationView(); ap = new ApplicationView();
RootPanel.get(DIV_CONTAINER_ID).add(ap); RootPanel.get(DIV_CONTAINER_ID).add(ap);
ap.readUserMessages(false);
} }
} }

View File

@ -115,6 +115,7 @@ public class ApplicationView extends Composite {
forward.setTooltip("Forward"); forward.setTooltip("Forward");
forward.setTooltipPosition(Position.LEFT); forward.setTooltipPosition(Position.LEFT);
} }
readUserMessages(false);
} }
/** /**
@ -140,12 +141,18 @@ public class ApplicationView extends Composite {
messageLoader.setVisible(false); messageLoader.setVisible(false);
} }
} else { } else {
RootPanel.get("create-users-container").add(new HTML("It is impossible to read your messages at this time. " showErrorOccurred();
+ "This could be a server error, please try to reload the page"));
} }
} }
}); });
} }
private void showErrorOccurred() {
messagesCollection.clear();
messagesLoader.setVisible(false);
messageLoader.setVisible(false);
hideSidePanel();
writeErrorMessage();
}
/** /**
* *
* @param messages * @param messages
@ -375,4 +382,20 @@ public class ApplicationView extends Composite {
totalMessages++; totalMessages++;
updateBadge(false); updateBadge(false);
} }
private void writeErrorMessage() {
MessagesResources images = GWT.create(MessagesResources.class);
List<MessageUserModel> recipients = Arrays.asList(new MessageUserModel(0, "you", "You", ""));
@SuppressWarnings("deprecation")
MessageUserModel sender = new MessageUserModel(0, "jarvis", "D4Science Team", images.d4scienceTeam().getURL(), "", "");
ConvMessage welcomeMessage = new ConvMessage("0", "An error occurred!", sender, recipients , new Date(), MessagesResources.ERROR_MESSAGE, true, false);
FAB.setVisible(false);
displayMessage.showMessage(welcomeMessage);
welcomeMessage.setContent(MessagesResources.ERROR_MESSAGE.substring(0, 102)+ " ...");
MessageItem item = new MessageItem(welcomeMessage, messagesCollection, this, false);
item.hideMessageMenu();
messagesCollection.add(item);
totalMessages++;
updateBadge(false);
}
} }

View File

@ -8,6 +8,9 @@ public interface MessagesResources extends ClientBundle {
"Also, you can easily attach very large files to your messages from Workspace." + "Also, you can easily attach very large files to your messages from Workspace." +
"\n\nThis message will automatically be deleted as soon you'll receive another one."; "\n\nThis message will automatically be deleted as soon you'll receive another one.";
public static final String ERROR_MESSAGE = "We are very sorry, it is impossible to read your messages at the moment.\n\nThis could be either a networking problem or an error on the server."
+ " Please try to reload this page, if the error persists report the issue.";
@Source("group.png") @Source("group.png")
ImageResource group(); ImageResource group();

View File

@ -121,9 +121,14 @@ public class ConvServiceImpl extends RemoteServiceServlet implements MessageServ
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
List<WorkspaceMessage> listMessages = null;
List<WorkspaceMessage> listMessages = (sent) ? try {
listMessages = (sent) ?
workspace.getWorkspaceMessageManager().getSentMessages() : workspace.getWorkspaceMessageManager().getReceivedMessages(); workspace.getWorkspaceMessageManager().getSentMessages() : workspace.getWorkspaceMessageManager().getReceivedMessages();
} catch (Exception e) {
_log.error("Could not read messages of " + user.getFullname());
return null;
}
_log.debug("Got messages of " + user.getFullname() + " how many? " + listMessages.size()); _log.debug("Got messages of " + user.getFullname() + " how many? " + listMessages.size());
//the messages are returned from the oldest to the new one, so we reverse them //the messages are returned from the oldest to the new one, so we reverse them
Collections.reverse(listMessages); Collections.reverse(listMessages);
@ -188,6 +193,7 @@ public class ConvServiceImpl extends RemoteServiceServlet implements MessageServ
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return null;
} }
_log.trace("get All Messages Received "); _log.trace("get All Messages Received ");
return toReturn; return toReturn;