diff --git a/.classpath b/.classpath index c35f92b..eb59e96 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -39,5 +39,5 @@ - + diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 350a0b1..15d5bf4 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,10 +4,7 @@ - - uses - - + uses diff --git a/pom.xml b/pom.xml index 7c275b8..510d171 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.gcube.portlets.user gcube-loggedin war - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT gCube Environment Home Portlet @@ -76,12 +76,7 @@ com.github.gwtbootstrap gwt-bootstrap - - - org.gcube.portal - custom-portal-handler - provided - + org.gcube.common.portal portal-manager @@ -92,16 +87,6 @@ gcube-widgets compile - - org.gcube.portlets.widgets - session-checker - [1.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) - - - org.gcube.applicationsupportlayer - aslcore - provided - org.gcube.dvos usermanagement-core diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/GCubeLoggedin.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/GCubeLoggedin.java index 18db272..252dabe 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/GCubeLoggedin.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/GCubeLoggedin.java @@ -22,6 +22,8 @@ public class GCubeLoggedin implements EntryPoint { * This is the entry point method. */ public void onModuleLoad() { + + main_panel.setWidth("100%"); main_panel.add(AboutView.getLoadingHTML()); // Associate the new panel with the HTML host page. diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.java index efa3111..12a1090 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.java @@ -4,11 +4,9 @@ import org.gcube.portlets.user.gcubeloggedin.client.LoggedinService; import org.gcube.portlets.user.gcubeloggedin.client.LoggedinServiceAsync; import org.gcube.portlets.user.gcubeloggedin.shared.VObject; import org.gcube.portlets.user.gcubewidgets.client.elements.Span; -import org.gcube.portlets.widgets.sessionchecker.client.CheckSession; import com.github.gwtbootstrap.client.ui.AlertBlock; import com.github.gwtbootstrap.client.ui.Button; -import com.github.gwtbootstrap.client.ui.Heading; import com.github.gwtbootstrap.client.ui.Hero; import com.github.gwtbootstrap.client.ui.Image; import com.github.gwtbootstrap.client.ui.constants.AlertType; @@ -54,11 +52,8 @@ public class AboutView extends Composite { public AboutView() { initWidget(uiBinder.createAndBindUi(this)); } - - private String vreDescription; @UiField Image vreImage; - @UiField Heading vreName; @UiField HTML description; @UiField Button seeMore; @UiField Button editButton; @@ -68,7 +63,6 @@ public class AboutView extends Composite { public AboutView(VObject vobj, LoggedinServiceAsync loggedinService) { initWidget(uiBinder.createAndBindUi(this)); this.vreDescription = vobj.getDescription(); - vreName.setText(vobj.getName()); vreImage.setUrl(vobj.getImageURL()); String desc = vreDescription = vobj.getDescription(); if (desc.length() > MAX_CHAR_DESC) { @@ -192,9 +186,7 @@ public class AboutView extends Composite { public void onSuccess(String result) { if (result != null) Location.assign(result); - else - CheckSession.showLogoutDialog(); - + } @Override public void onFailure(Throwable caught) { diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.ui.xml b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.ui.xml index 7029037..e0ecc94 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.ui.xml +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.ui.xml @@ -5,7 +5,6 @@ - Thumbnail label diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/EditDescriptionModal.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/EditDescriptionModal.java index b2e70fe..213b0bf 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/EditDescriptionModal.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/EditDescriptionModal.java @@ -2,7 +2,6 @@ package org.gcube.portlets.user.gcubeloggedin.client.ui; import org.gcube.portlets.user.gcubeloggedin.client.LoggedinService; import org.gcube.portlets.user.gcubeloggedin.client.LoggedinServiceAsync; -import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.Icon; @@ -15,7 +14,6 @@ import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; -import com.google.gwt.user.client.Window.Location; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; @@ -68,16 +66,7 @@ public class EditDescriptionModal extends Composite { text2Edit.setText(""); text2Edit.setVisible(false); loadingContainer.setVisible(true); - ClientScopeHelper.getService().setScope(Location.getHref(), new AsyncCallback() { - @Override - public void onSuccess(Boolean result) { - doSave(vreDescription); - } - @Override - public void onFailure(Throwable caught) { - loadingText.setText("Ops, some problems occurred, please try again in a while or report the problem."); - } - }); + doSave(vreDescription); } private void doSave(String toSave) { diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/LoggedinServiceImpl.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/LoggedinServiceImpl.java index 697359c..0efa406 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/LoggedinServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/LoggedinServiceImpl.java @@ -5,19 +5,17 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.gcube.application.framework.core.session.ASLSession; -import org.gcube.application.framework.core.session.SessionManager; import org.gcube.common.portal.PortalContext; import org.gcube.common.portal.mailing.EmailNotification; -import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portlets.user.gcubeloggedin.client.LoggedinService; import org.gcube.portlets.user.gcubeloggedin.shared.VObject; import org.gcube.portlets.user.gcubeloggedin.shared.VObject.UserBelongingClient; import org.gcube.portlets.user.gcubeloggedin.shared.VREClient; -import org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl; import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.RoleManager; import org.gcube.vomanagement.usermanagement.UserManager; +import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; +import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException; import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager; import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager; import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager; @@ -37,34 +35,22 @@ import com.liferay.portal.service.UserLocalServiceUtil; public class LoggedinServiceImpl extends RemoteServiceServlet implements LoggedinService { private static final Logger _log = LoggerFactory.getLogger(LoggedinServiceImpl.class); - private static final String VRE_MANAGER_ROLE = "VRE-Manager"; - - /** - * the current ASLSession - * @return . - */ - private ASLSession getASLSession() { - String sessionID = this.getThreadLocalRequest().getSession().getId(); - String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE); - if (user == null) { - _log.warn("LOGGEDIN PORTLET: USER IS NULL \n\n SESSION ID READ: " +sessionID ); - user = "test.user"; - _log.warn("session ID= *" + sessionID + "* user= *" + user + "*" ); - - } - - return SessionManager.getInstance().getASLSession(sessionID, user); - - } - + private PortalContext context = PortalContext.getConfiguration(); /** * return the current selected VRE */ public VObject getSelectedRE(String portalURL) { - ASLSession aslSession = getASLSession(); - String friendlyURL = ScopeServiceImpl.extractOrgFriendlyURL(portalURL); - + long currGroupId = context.getCurrentGroupId(getThreadLocalRequest()); + GroupManager gm = new LiferayGroupManager(); + GCubeGroup currGroup = null; + try { + currGroup = gm.getGroup(currGroupId); + } catch (UserManagementSystemException | GroupRetrievalFault e1) { + e1.printStackTrace(); + } + String friendlyURL = currGroup.getFriendlyURL(); + _log.debug("curr group: " + currGroup.getGroupName() + " friendlyURL = " + friendlyURL); if (friendlyURL == null) {//the URL is not a portal URL, we are in devmode. return new VREClient("Test VRE Name", "", "" + "Fishery and Aquaculture Resources Management (FARM) Virtual Organisation The FARM Virtual Organisation is the dynamic group of individuals and/or institutions defined around a set of sharing rules in which resource providers and consumers specify clearly and carefully just what is shared, who is allowed to share, and the conditions under which sharing occurs to serve the needs of the Fisheries and Aquaculture Resources Management. " @@ -79,39 +65,15 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi , "http://placehold.it/300x200", "", UserBelongingClient.BELONGING, false, true, true); } _log.trace("getting Selected Research Environment"); - GroupManager gm = new LiferayGroupManager(); - GCubeGroup currSite = null; - try { - List groups = gm.listGroups(); - for (GCubeGroup g : groups) { - if (g.getFriendlyURL().compareTo(friendlyURL) == 0) { - long groupId = g.getGroupId(); - String scopeToSet = gm.getInfrastructureScope(groupId); - getASLSession().setScope(scopeToSet); - _log.info("GOT Selected Research Environment: " + scopeToSet); - currSite = g; - } - } - } catch (Exception e) { - e.printStackTrace(); - } - - /** - * set the current ORG bean in session - */ - aslSession.setAttribute(ScopeHelper.CURR_ORG, currSite); - - aslSession.setGroupModelInfos(currSite.getGroupName(), currSite.getGroupId()); - - _log.trace("CURRENT ORG SET IN SESSION: " + currSite.getGroupName()); - String name = currSite.getGroupName(); - String logoURL = gm.getGroupLogoURL(currSite.getLogoId()); + + String name = currGroup.getGroupName(); + String logoURL = gm.getGroupLogoURL(currGroup.getLogoId()); String desc = ""; //set the description for the vre - if (currSite.getDescription() != null) - desc = currSite.getDescription(); + if (currGroup.getDescription() != null) + desc = currGroup.getDescription(); return new VREClient(name, "", desc, logoURL, "", UserBelongingClient.BELONGING, false, false, isCurrUserVREManager()); } @@ -120,15 +82,14 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi * @return */ private boolean isCurrUserVREManager() { - ASLSession session = getASLSession(); + long userId; try { - userId = new LiferayUserManager().getUserId(session.getUsername()); - long groupId = new LiferayGroupManager().getGroupIdFromInfrastructureScope(session.getScope()); + userId = context.getCurrentUser(getThreadLocalRequest()).getUserId(); + long groupId = context.getCurrentGroupId(getThreadLocalRequest()); RoleManager rm = new LiferayRoleManager(); - long roleId = rm.getRoleIdByName(VRE_MANAGER_ROLE); + long roleId = rm.getRoleIdByName(GCubeRole.VRE_MANAGER_LABEL); boolean toReturn = rm.hasRole(userId, groupId, roleId); - _log.debug("User " + session.getUsername() + " is " + VRE_MANAGER_ROLE + " for " + session.getScope() + "? -> " + toReturn); return toReturn; } catch (Exception e) { @@ -179,11 +140,9 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi @Override public String saveVREDescription(String toSave) { - try { - String scope = getASLSession().getScope(); - GroupManager gm = new LiferayGroupManager(); - long groupId = gm.getGroupIdFromInfrastructureScope(scope); - return gm.updateGroupDescription(groupId, toSave); + try { + long groupId = context.getCurrentGroupId(getThreadLocalRequest()); + return new LiferayGroupManager().updateGroupDescription(groupId, toSave); } catch (Exception e) { e.printStackTrace(); } @@ -193,30 +152,22 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi public boolean isLeaveButtonAvailable(String portalURL) { if(isWithinPortal()){ - String friendlyURL = ScopeServiceImpl.extractOrgFriendlyURL(portalURL); + long currGroupId = context.getCurrentGroupId(getThreadLocalRequest()); GroupManager gm = new LiferayGroupManager(); - GCubeGroup currSite = null; - try { - List groups = gm.listGroups(); - for (GCubeGroup g : groups) { - if (g.getFriendlyURL().compareTo(friendlyURL) == 0) { - long groupId = g.getGroupId(); - String scopeToSet = gm.getInfrastructureScope(groupId); - getASLSession().setScope(scopeToSet); - _log.info("GOT Selected Research Environment: " + scopeToSet); - currSite = g; - } - } - } catch (Exception e) { - e.printStackTrace(); + GCubeGroup currGroup = null; + try { + currGroup = gm.getGroup(currGroupId); + } catch (UserManagementSystemException | GroupRetrievalFault e1) { + e1.printStackTrace(); } + Boolean isMandatory = false; try{ - isMandatory = (Boolean) gm.readCustomAttr(currSite.getGroupId(), org.gcube.vomanagement.usermanagement.model.CustomAttributeKeys.MANDATORY.getKeyName()); + isMandatory = (Boolean) gm.readCustomAttr(currGroup.getGroupId(), org.gcube.vomanagement.usermanagement.model.CustomAttributeKeys.MANDATORY.getKeyName()); }catch(Exception e){ - _log.error("Unable to evaluate if the leave button can be added for the current group " + currSite.getGroupName(), e); + _log.error("Unable to evaluate if the leave button can be added for the current group " + currGroup.getGroupName(), e); } - _log.debug("Is Leave button available in vre " + currSite.getGroupName() + " ? " + isMandatory); + _log.debug("Is Leave button available in vre " + currGroup.getGroupName() + " ? " + isMandatory); return !isMandatory; }else return true; } @@ -225,14 +176,15 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi */ @Override public String removeUserFromVRE() { - String username = getASLSession().getUsername(); + String username = context.getCurrentUser(getThreadLocalRequest()).getUsername(); + String scope = context.getCurrentScope(getThreadLocalRequest()); if (username.compareTo("test.user") == 0) return null; _log.debug("Going to remove user from the current Group: " + getCurrentGroupID() + ". Username is: " + username); UserManager userM = new LiferayUserManager(); try { userM.dismissUserFromGroup(getCurrentGroupID(), userM.getUserId(username)); - sendUserUnregisteredNotification(username, getASLSession().getScope(), + sendUserUnregisteredNotification(username, scope, PortalContext.getConfiguration().getGatewayURL(getThreadLocalRequest()), PortalContext.getConfiguration().getGatewayName(getThreadLocalRequest())); @@ -249,16 +201,8 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi * @throws Exception * @throws CurrentGroupRetrievalException */ - private long getCurrentGroupID(){ - GroupManager groupM = new LiferayGroupManager(); - ASLSession session = getASLSession(); - _log.debug("The current group NAME is --> " + session.getGroupName()); - try { - return groupM.getGroupId(session.getGroupName()); - } catch (Exception e) { - e.printStackTrace(); - } - return 0; + private long getCurrentGroupID() { + return context.getCurrentGroupId(getThreadLocalRequest()); } /** * diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/portlet/LoggedinPortlet.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/portlet/LoggedinPortlet.java index ea176a0..704345a 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/portlet/LoggedinPortlet.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/portlet/LoggedinPortlet.java @@ -9,8 +9,6 @@ import javax.portlet.PortletRequestDispatcher; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; -import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; - /** * LoggedinPortlet Portlet Class * @author massi @@ -20,9 +18,6 @@ public class LoggedinPortlet extends GenericPortlet { public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { response.setContentType("text/html"); - - ScopeHelper.setContext(request); - PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/LoggedinPortlet_view.jsp"); dispatcher.include(request, response); diff --git a/src/main/resources/org/gcube/portlets/user/gcubeloggedin/GCubeLoggedin.gwt.xml b/src/main/resources/org/gcube/portlets/user/gcubeloggedin/GCubeLoggedin.gwt.xml index 24b6aee..0a062da 100644 --- a/src/main/resources/org/gcube/portlets/user/gcubeloggedin/GCubeLoggedin.gwt.xml +++ b/src/main/resources/org/gcube/portlets/user/gcubeloggedin/GCubeLoggedin.gwt.xml @@ -7,7 +7,6 @@ - /gcubeloggedin/LoggedinServiceImpl - - scopeService - org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl - - - - scopeService - /gcubeloggedin/scopeService - - GCubeLoggedin.html