session expired handled

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace@81049 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2013-09-04 13:30:28 +00:00
parent 681ffe072d
commit e249b15053
2 changed files with 49 additions and 16 deletions

View File

@ -66,6 +66,7 @@ import org.gcube.portlets.user.workspace.client.event.SearchTextEvent;
import org.gcube.portlets.user.workspace.client.event.SearchTextEventHandler;
import org.gcube.portlets.user.workspace.client.event.SendMessageEvent;
import org.gcube.portlets.user.workspace.client.event.SendMessageEventHandler;
import org.gcube.portlets.user.workspace.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.workspace.client.event.WebDavUrlEvent;
import org.gcube.portlets.user.workspace.client.event.WebDavUrlEventHandler;
import org.gcube.portlets.user.workspace.client.interfaces.EventsTypeEnum;
@ -80,6 +81,7 @@ import org.gcube.portlets.user.workspace.client.view.panels.GxtItemsPanel;
import org.gcube.portlets.user.workspace.client.view.windows.DialogGetInfo;
import org.gcube.portlets.user.workspace.client.view.windows.InfoDisplay;
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert;
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
import org.gcube.portlets.user.wsmail.client.forms.MailForm;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
@ -106,6 +108,7 @@ public class AppController implements SubscriberInterface {
private AppControllerExplorer appContrExplorer = null;
private String rootIdentifier = null;
// public static boolean isSearchActive = false;
private HasWidgets rootPanel;
@ -130,7 +133,8 @@ public class AppController implements SubscriberInterface {
EventsTypeEnum.SELECTED_MESSAGE,
EventsTypeEnum.CREATE_NEW_MESSAGE,
EventsTypeEnum.REPLY_FORWARD_MESSAGE,
EventsTypeEnum.FILE_DOWNLAD_EVENT
EventsTypeEnum.FILE_DOWNLAD_EVENT,
EventsTypeEnum.SESSION_EXPIRED
});
bind();
}
@ -512,6 +516,12 @@ public class AppController implements SubscriberInterface {
@Override
public void onFailure(Throwable caught) {
if(caught instanceof SessionExpiredException){
eventBus.fireEvent(new SessionExpiredEvent());
return;
}
new MessageBoxAlert("Error", caught.getMessage(), null);
wsPortlet.getGridGroupContainer().unmask();
@ -806,6 +816,8 @@ public class AppController implements SubscriberInterface {
*/
public void go(final HasWidgets rootPanel) {
this.rootPanel = rootPanel;
final String searchParameter = Window.Location.getParameter(ConstantsPortlet.GET_SEARCH_PARAMETER);
final String itemIdParameter = Window.Location.getParameter(ConstantsPortlet.GET_ITEMID_PARAMETER);
final String operationParameter = Window.Location.getParameter(ConstantsPortlet.GET_OPEARATION_PARAMETER);
@ -868,9 +880,7 @@ public class AppController implements SubscriberInterface {
initPortlet(rootPanel, instanceWithGrouping, searchingForItemId, searchParameter, itemIdParameter, operationParameter);
else{
//SESSION IS EXPIRED
rootPanel.add(showProblems());
getMainPanel().setHeight(350);
viewSessionExpiredPanel();
}
}
@ -914,17 +924,6 @@ public class AppController implements SubscriberInterface {
// }
}
private LayoutContainer showProblems() {
LayoutContainer errorPanel = new LayoutContainer();
errorPanel.setLayout(new FitLayout());
errorPanel.add(new HTML("<div class=\"nofeed-message\">" +
"Ops! There were problems while retrieving your workspace!" +
"<br> Your session expired, please try to <a href=\"/c/portal/logout\">login again</a> "));
return errorPanel;
}
private void initPortlet(final HasWidgets rootPanel, final boolean instanceWithGrouping, boolean isSearchForItemId, final String searchParameter, final String itemIdParameter, final String operationParameter){
rootPanel.add(wsPortlet.getBorderLayoutContainer());
@ -1025,6 +1024,12 @@ public class AppController implements SubscriberInterface {
@Override
public void onFailure(Throwable caught) {
if(caught instanceof SessionExpiredException){
eventBus.fireEvent(new SessionExpiredEvent());
return;
}
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting items for grid. " +ConstantsExplorer.TRY_AGAIN, null);
// System.out.println(caught);
// caught.printStackTrace();
@ -1281,4 +1286,30 @@ public class AppController implements SubscriberInterface {
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.interfaces.SubscriberInterface#sessionExpired()
*/
@Override
public void viewSessionExpiredPanel() {
if(this.rootPanel!=null){
rootPanel.clear();
rootPanel.add(showProblems());
getMainPanel().setHeight(350);
}
}
private LayoutContainer showProblems() {
LayoutContainer errorPanel = new LayoutContainer();
errorPanel.setLayout(new FitLayout());
errorPanel.add(new HTML("<div class=\"nofeed-message\">" +
"Ops! There were problems while retrieving your workspace!" +
"<br> Your session expired, please try to <a href=\"/c/portal/logout\">login again</a> "));
return errorPanel;
}
}

View File

@ -40,6 +40,8 @@ public class WorkspacePortlet extends GenericPortlet{
ScopeHelper.setContext(request, ScopeHelper.USERNAME_ATTRIBUTE);
// request.setAttribute("fromportlet","true");
// Invoke the JSP to render
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(VIEW_JSP);
rd.include(request,response);