moved leave VRE option here
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/gcube-loggedin@132202 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4698fd11ef
commit
c77039ade7
16
.classpath
16
.classpath
|
@ -1,19 +1,27 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" output="target/gcube-loggedin-3.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
<classpathentry kind="src" output="target/gcube-loggedin-3.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry including="**/*.java" kind="src" output="src/main/webapp/WEB-INF/classes" path="src/main/resources"/>
|
<classpathentry excluding="**" kind="src" output="target/gcube-loggedin-3.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
|
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||||
|
@ -31,5 +39,5 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/gcube-loggedin-3.0.0-SNAPSHOT/WEB-INF/classes"/>
|
<classpathentry kind="output" path="target/gcube-loggedin-3.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
1
.project
1
.project
|
@ -55,5 +55,6 @@
|
||||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||||
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
|
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
|
||||||
<nature>com.google.gwt.eclipse.core.gwtNature</nature>
|
<nature>com.google.gwt.eclipse.core.gwtNature</nature>
|
||||||
|
<nature>com.liferay.ide.core.liferayNature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||||
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||||
<dependent-module archiveName="gcube-widgets-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
|
<dependent-module archiveName="gcube-widgets-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
|
||||||
<dependency-type>uses</dependency-type>
|
<dependency-type>uses</dependency-type>
|
||||||
</dependent-module>
|
</dependent-module>
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -13,7 +13,7 @@
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>gcube-loggedin</artifactId>
|
<artifactId>gcube-loggedin</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>3.0.0-SNAPSHOT</version>
|
<version>3.1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<name>gCube Environment Home Portlet</name>
|
<name>gCube Environment Home Portlet</name>
|
||||||
<description>
|
<description>
|
||||||
|
|
|
@ -13,4 +13,7 @@ public interface LoggedinService extends RemoteService {
|
||||||
VObject getSelectedRE(String portalURL);
|
VObject getSelectedRE(String portalURL);
|
||||||
|
|
||||||
String saveVREDescription(String toSave);
|
String saveVREDescription(String toSave);
|
||||||
|
|
||||||
|
boolean isLeaveButtonAvailable(String currentUrl);
|
||||||
|
String removeUserFromVRE();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,4 +11,7 @@ public interface LoggedinServiceAsync {
|
||||||
void getSelectedRE(String portalURL, AsyncCallback<VObject> callback);
|
void getSelectedRE(String portalURL, AsyncCallback<VObject> callback);
|
||||||
|
|
||||||
void saveVREDescription(String toSave, AsyncCallback<String> callback);
|
void saveVREDescription(String toSave, AsyncCallback<String> callback);
|
||||||
|
void isLeaveButtonAvailable(String currentUrl,
|
||||||
|
AsyncCallback<Boolean> callback);
|
||||||
|
void removeUserFromVRE(AsyncCallback<String> callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,32 @@
|
||||||
package org.gcube.portlets.user.gcubeloggedin.client.ui;
|
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.gcubeloggedin.client.LoggedinServiceAsync;
|
||||||
import org.gcube.portlets.user.gcubeloggedin.shared.VObject;
|
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.Button;
|
||||||
import com.github.gwtbootstrap.client.ui.Heading;
|
import com.github.gwtbootstrap.client.ui.Heading;
|
||||||
import com.github.gwtbootstrap.client.ui.Hero;
|
import com.github.gwtbootstrap.client.ui.Hero;
|
||||||
import com.github.gwtbootstrap.client.ui.Image;
|
import com.github.gwtbootstrap.client.ui.Image;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.uibinder.client.UiBinder;
|
import com.google.gwt.uibinder.client.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
import com.google.gwt.uibinder.client.UiHandler;
|
import com.google.gwt.uibinder.client.UiHandler;
|
||||||
|
import com.google.gwt.user.client.Window;
|
||||||
|
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.Composite;
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
|
import com.google.gwt.user.client.ui.HasAlignment;
|
||||||
|
import com.google.gwt.user.client.ui.InlineHTML;
|
||||||
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
public class AboutView extends Composite {
|
public class AboutView extends Composite {
|
||||||
|
@ -21,7 +34,17 @@ public class AboutView extends Composite {
|
||||||
private static int MAX_CHAR_DESC = 400;
|
private static int MAX_CHAR_DESC = 400;
|
||||||
private static String SEE_LESS = "See less";
|
private static String SEE_LESS = "See less";
|
||||||
private static String SEE_MORE = "See more";
|
private static String SEE_MORE = "See more";
|
||||||
|
private Button leaveVreButton = new Button("Leave Group");
|
||||||
|
private AlertBlock alertBlockOnLeave = new AlertBlock();
|
||||||
|
// more options label to show the other ones (if present)
|
||||||
|
final Button showMoreOptions = new Button("Other options ...");
|
||||||
|
private static final String leaveAlertMessage = "Are you sure you want to leave this group? "
|
||||||
|
+ "By leaving this group you will no longer receive updates and lose the workspace folder related to the group.";
|
||||||
|
|
||||||
|
// panel for leave group option
|
||||||
|
private VerticalPanel leaveVREOption = new VerticalPanel();
|
||||||
|
|
||||||
|
private final LoggedinServiceAsync service = GWT.create(LoggedinService.class);
|
||||||
private static AboutViewUiBinder uiBinder = GWT
|
private static AboutViewUiBinder uiBinder = GWT
|
||||||
.create(AboutViewUiBinder.class);
|
.create(AboutViewUiBinder.class);
|
||||||
|
|
||||||
|
@ -32,6 +55,7 @@ public class AboutView extends Composite {
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String vreDescription;
|
private String vreDescription;
|
||||||
@UiField Image vreImage;
|
@UiField Image vreImage;
|
||||||
@UiField Heading vreName;
|
@UiField Heading vreName;
|
||||||
|
@ -60,6 +84,41 @@ public class AboutView extends Composite {
|
||||||
editButton.setVisible(true);
|
editButton.setVisible(true);
|
||||||
}
|
}
|
||||||
mod = new EditDescriptionModal(vobj.getName(), vobj.getDescription());
|
mod = new EditDescriptionModal(vobj.getName(), vobj.getDescription());
|
||||||
|
|
||||||
|
service.isLeaveButtonAvailable(Location.getHref(), new AsyncCallback<Boolean>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Boolean result) {
|
||||||
|
leaveVREOption.clear();
|
||||||
|
leaveVREOption.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
|
||||||
|
if(result)
|
||||||
|
addLeaveVREButton();
|
||||||
|
showMoreOptions.setVisible(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
leaveVREOption.clear();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
showMoreOptions.setType(ButtonType.LINK);
|
||||||
|
// handler
|
||||||
|
showMoreOptions.addClickHandler(new ClickHandler() {
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
// hide the button itself
|
||||||
|
showMoreOptions.setVisible(false);
|
||||||
|
// show other options
|
||||||
|
leaveVREOption.setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mainPanel.add(showMoreOptions);
|
||||||
|
mainPanel.add(leaveVREOption);
|
||||||
|
|
||||||
|
// hide options but askManagersOption
|
||||||
|
leaveVREOption.setVisible(false);
|
||||||
}
|
}
|
||||||
boolean open = false;
|
boolean open = false;
|
||||||
@UiHandler("seeMore")
|
@UiHandler("seeMore")
|
||||||
|
@ -80,7 +139,71 @@ public class AboutView extends Composite {
|
||||||
void onEditButton(ClickEvent e) {
|
void onEditButton(ClickEvent e) {
|
||||||
mod.show();
|
mod.show();
|
||||||
}
|
}
|
||||||
|
private void addLeaveVREButton(){
|
||||||
|
|
||||||
|
// add leave VRE button
|
||||||
|
leaveVreButton.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
|
||||||
|
// show alert block
|
||||||
|
alertBlockOnLeave.setVisible(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add Cancel and Confirm Leave buttons
|
||||||
|
Span cancel = new Span("Cancel");
|
||||||
|
Span confirmLeave = new Span("Confirm Leave");
|
||||||
|
cancel.setStyleName("cancel-leave-button");
|
||||||
|
confirmLeave.setStyleName("cancel-leave-button");
|
||||||
|
|
||||||
|
// add to main panel
|
||||||
|
alertBlockOnLeave.setHTML(leaveAlertMessage + "<br><br>");
|
||||||
|
alertBlockOnLeave.add(cancel);
|
||||||
|
alertBlockOnLeave.add(new InlineHTML(" or "));
|
||||||
|
alertBlockOnLeave.add(confirmLeave);
|
||||||
|
alertBlockOnLeave.setType(AlertType.WARNING);
|
||||||
|
alertBlockOnLeave.setHeading("WARNING!");
|
||||||
|
alertBlockOnLeave.setClose(false);
|
||||||
|
alertBlockOnLeave.setVisible(false);
|
||||||
|
leaveVREOption.add(alertBlockOnLeave);
|
||||||
|
leaveVREOption.add(leaveVreButton);
|
||||||
|
|
||||||
|
// add handlers
|
||||||
|
cancel.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
|
||||||
|
// just hide alertBlock
|
||||||
|
alertBlockOnLeave.setVisible(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
confirmLeave.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event){
|
||||||
|
service.removeUserFromVRE(new AsyncCallback<String>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String result) {
|
||||||
|
if (result != null)
|
||||||
|
Location.assign(result);
|
||||||
|
else
|
||||||
|
CheckSession.showLogoutDialog();
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
Window.alert("We're sorry we couldn't reach the server, try again later ... " + caught.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package org.gcube.portlets.user.gcubeloggedin.server;
|
package org.gcube.portlets.user.gcubeloggedin.server;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
import org.gcube.application.framework.core.session.ASLSession;
|
||||||
import org.gcube.application.framework.core.session.SessionManager;
|
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.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||||
import org.gcube.portlets.user.gcubeloggedin.client.LoggedinService;
|
import org.gcube.portlets.user.gcubeloggedin.client.LoggedinService;
|
||||||
import org.gcube.portlets.user.gcubeloggedin.shared.VObject;
|
import org.gcube.portlets.user.gcubeloggedin.shared.VObject;
|
||||||
|
@ -17,9 +18,6 @@ import org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl;
|
||||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||||
import org.gcube.vomanagement.usermanagement.RoleManager;
|
import org.gcube.vomanagement.usermanagement.RoleManager;
|
||||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
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.exception.UserRetrievalFault;
|
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||||
|
@ -30,6 +28,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||||
|
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The server side implementation of the RPC service.
|
* The server side implementation of the RPC service.
|
||||||
|
@ -106,9 +105,9 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
||||||
|
|
||||||
_log.trace("CURRENT ORG SET IN SESSION: " + currSite.getGroupName());
|
_log.trace("CURRENT ORG SET IN SESSION: " + currSite.getGroupName());
|
||||||
|
|
||||||
long nowInMillis = new Date().getTime();
|
|
||||||
String name = currSite.getGroupName();
|
String name = currSite.getGroupName();
|
||||||
String logoURL = "/image/layout_set_logo?img_id="+currSite.getLogoId()+"&t="+nowInMillis;
|
String logoURL = gm.getGroupLogoURL(currSite.getLogoId());
|
||||||
String desc = "";
|
String desc = "";
|
||||||
//set the description for the vre
|
//set the description for the vre
|
||||||
if (currSite.getDescription() != null)
|
if (currSite.getDescription() != null)
|
||||||
|
@ -190,6 +189,127 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public boolean isLeaveButtonAvailable(String portalURL) {
|
||||||
|
|
||||||
|
if(isWithinPortal()){
|
||||||
|
String friendlyURL = ScopeServiceImpl.extractOrgFriendlyURL(portalURL);
|
||||||
|
GroupManager gm = new LiferayGroupManager();
|
||||||
|
GCubeGroup currSite = null;
|
||||||
|
try {
|
||||||
|
List<GCubeGroup> 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();
|
||||||
|
}
|
||||||
|
Boolean isMandatory = false;
|
||||||
|
try{
|
||||||
|
isMandatory = (Boolean) gm.readCustomAttr(currSite.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.debug("Is Leave button available in vre " + currSite.getGroupName() + " ? " + isMandatory);
|
||||||
|
return !isMandatory;
|
||||||
|
}else return true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*@return the redirect url if everything goes ok, null otherwise
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String removeUserFromVRE() {
|
||||||
|
String username = getASLSession().getUsername();
|
||||||
|
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(),
|
||||||
|
PortalContext.getConfiguration().getGatewayURL(getThreadLocalRequest()),
|
||||||
|
PortalContext.getConfiguration().getGatewayName(getThreadLocalRequest()));
|
||||||
|
return "/";
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the current group ID
|
||||||
|
*
|
||||||
|
* @return the current group ID or null if an exception is thrown
|
||||||
|
* @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;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return true if you're running into the portal, false if in development
|
||||||
|
*/
|
||||||
|
private boolean isWithinPortal() {
|
||||||
|
try {
|
||||||
|
UserLocalServiceUtil.getService();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (com.liferay.portal.kernel.bean.BeanLocatorException ex) {
|
||||||
|
_log.trace("Development Mode ON");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param scope .
|
||||||
|
* @param optionalMessage .
|
||||||
|
*/
|
||||||
|
public void sendUserUnregisteredNotification(String username, String scope, String portalbasicurl, String gatewayName) {
|
||||||
|
ArrayList<String> adminEmails = getAdministratorsEmails(scope);
|
||||||
|
UserManager um = new LiferayUserManager();
|
||||||
|
GCubeUser currUser = null;
|
||||||
|
try {
|
||||||
|
currUser = um.getUserByUsername(username);
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
String name = currUser.getFirstName();
|
||||||
|
String lastname = currUser.getLastName();
|
||||||
|
|
||||||
|
StringBuffer body = new StringBuffer();
|
||||||
|
body.append("<p>Dear manager of "+ scope +",<br />this email message was automatically generated by " + portalbasicurl +" to inform you that ");
|
||||||
|
body.append("</p>");
|
||||||
|
body.append("<p>");
|
||||||
|
body.append("<b>"+name + " " + lastname +"</b> has left the following environment: ");
|
||||||
|
body.append("<br /><br />");
|
||||||
|
body.append("<b>" + scope+"</b>");
|
||||||
|
body.append("<br />");
|
||||||
|
body.append("<br />");
|
||||||
|
body.append("<b>Username: </b>" + username);
|
||||||
|
body.append("<br />");
|
||||||
|
body.append("<b>e-mail: </b>" + currUser.getEmail());
|
||||||
|
body.append("</p>");
|
||||||
|
|
||||||
|
String[] allMails = new String[adminEmails.size()];
|
||||||
|
|
||||||
|
adminEmails.toArray(allMails);
|
||||||
|
|
||||||
|
EmailNotification mailToAdmin = new EmailNotification(allMails , "Unregistration from VRE", body.toString(), getThreadLocalRequest());
|
||||||
|
|
||||||
|
mailToAdmin.sendEmail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
|
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
|
||||||
<portlet>
|
<portlet>
|
||||||
<portlet-name>Loggedin</portlet-name>
|
<portlet-name>Loggedin</portlet-name>
|
||||||
<display-name>Environment Home</display-name>
|
<display-name>About</display-name>
|
||||||
<portlet-class>org.gcube.portlets.user.gcubeloggedin.server.portlet.LoggedinPortlet</portlet-class>
|
<portlet-class>org.gcube.portlets.user.gcubeloggedin.server.portlet.LoggedinPortlet</portlet-class>
|
||||||
<init-param>
|
<init-param>
|
||||||
<name>view-jsp</name>
|
<name>view-jsp</name>
|
||||||
|
@ -14,9 +14,9 @@
|
||||||
<mime-type>text/html</mime-type>
|
<mime-type>text/html</mime-type>
|
||||||
</supports>
|
</supports>
|
||||||
<portlet-info>
|
<portlet-info>
|
||||||
<title>Environment Home</title>
|
<title>About</title>
|
||||||
<short-title>Environment Home</short-title>
|
<short-title>About</short-title>
|
||||||
<keywords>Environment Home</keywords>
|
<keywords>Environment Home About</keywords>
|
||||||
</portlet-info>
|
</portlet-info>
|
||||||
<security-role-ref>
|
<security-role-ref>
|
||||||
<role-name>administrator</role-name>
|
<role-name>administrator</role-name>
|
||||||
|
|
Loading…
Reference in New Issue