Bug #1829 Reports Manager setting dev mode when session expires to any user

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@121946 82a268e6-3cf1-43bd-a215-b396298e98cf
master
Massimiliano Assante 8 years ago
parent 1ba9552677
commit e92cda5e47

@ -85,6 +85,10 @@
<version>${gwtVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.gwtbootstrap</groupId>
<artifactId>gwt-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>session-checker</artifactId>

@ -117,6 +117,7 @@ public class Presenter {
private UserBean currentUser;
private String currentScope;
private String currentReportsStoreGatewayURL;
private ClientImage selectedImage;
@ -329,9 +330,10 @@ public class Presenter {
public void onFailure(Throwable caught) {}
public void onSuccess(final SessionInfo sessionInfo) {
currentUser = sessionInfo.getUsername();
currentUser = sessionInfo.getUserName();
currentScope = sessionInfo.getScope();
isVME = sessionInfo.isVME();
currentReportsStoreGatewayURL = sessionInfo.getRsgEndpoint();
addTextToolBar(true);
if (sessionInfo.isWorkflowDocument()) {
model.getModelService().getWorkflowDocumentFromDocumentLibrary(new AsyncCallback<Model>() {
@ -382,7 +384,7 @@ public class Presenter {
}
public void showOpenOptions() {
wp.showOpenOptions(isVME);
wp.showOpenOptions(isVME, currentReportsStoreGatewayURL);
}
public void showLoading() {

@ -9,6 +9,8 @@ import org.gcube.portlets.user.reportgenerator.client.uibinder.OpenOptions;
import org.gcube.portlets.user.reportgenerator.client.uibinder.OpenOptionsVME;
import org.gcube.portlets.user.reportgenerator.client.uibinder.ShowLoading;
import com.github.gwtbootstrap.client.ui.AlertBlock;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Widget;
@ -73,9 +75,13 @@ public class WorkspacePanel extends Composite {
//showOpenOptions();
}
public void showOpenOptions(boolean isVME) {
if (isVME)
public void showOpenOptions(boolean isVME, String rsgURL) {
if (isVME) {
AlertBlock connectInfo = new AlertBlock(AlertType.SUCCESS);
connectInfo.setHeading("Succesfully connected to: " + rsgURL);
mainLayout.add(connectInfo);
mainLayout.add(new OpenOptionsVME(presenter));
}
else
mainLayout.add(new OpenOptions(presenter));
}

@ -97,7 +97,7 @@ public class DownloadImageServlet extends HttpServlet {
_log.warn("Found scope null, setting infrastructure scope="+scope2Set);
}
if (user == null) {
user = ReportServiceImpl.getDevUser();
user = ReportServiceImpl.TEST_USER;
ScopeProvider.instance.set(ReportServiceImpl.TEST_SCOPE);
_log.warn("User is null in session, setting dev user = " + user);
}

@ -134,9 +134,6 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
private static final Logger _log = LoggerFactory.getLogger(ReportServiceImpl.class);
public static final String TEST_SCOPE = "/gcube/devsec/devVRE";
//public static final String TEST_SCOPE = "/gcube/devNext/NextNext";
protected static final String IMAGE_SERVICE_URL = "reports/DownloadService";
/**
*
@ -156,7 +153,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
public static final String RSG_WS_ADDRESS = "RSG-WS-ENDPOINT";
private static final String REPORT_IMAGES_FOLDER = "Report Images";
public static final String TEST_USER = "test.user";
public static final String TEST_SCOPE = "/gcube/devsec/devVRE";
/**
* the WF DB Store
@ -186,22 +184,26 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
if (user == null) {
user = getDevUser();
this.getThreadLocalRequest().getSession().setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, user);
SessionManager.getInstance().getASLSession(sessionID, user).setScope(TEST_SCOPE);
String email = user+"@isti.cnr.it";
String fullName = "Massimiliano Assante";
String thumbnailURL = "images/Avatar_default.png";
SessionManager.getInstance().getASLSession(sessionID, user).setUserEmailAddress(email);
SessionManager.getInstance().getASLSession(sessionID, user).setUserAvatarId(thumbnailURL);
SessionManager.getInstance().getASLSession(sessionID, user).setUserFullName(fullName);
user = getDevelopmentUser();
if (user.compareTo(TEST_USER) != 0) {
SessionManager.getInstance().getASLSession(sessionID, user).setScope(TEST_SCOPE);
this.getThreadLocalRequest().getSession().setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, user);
String email = user+"@isti.cnr.it";
String fullName = "Andrea Rossi";
String thumbnailURL = "images/Avatar_default.png";
SessionManager.getInstance().getASLSession(sessionID, user).setUserEmailAddress(email);
SessionManager.getInstance().getASLSession(sessionID, user).setUserAvatarId(thumbnailURL);
SessionManager.getInstance().getASLSession(sessionID, user).setUserFullName(fullName);
}
}
return SessionManager.getInstance().getASLSession(sessionID, user);
}
public static String getDevUser() {
return "massimiliano.assante";
public String getDevelopmentUser() {
String user = TEST_USER;
// user = "andrea.rossi";
return user;
}
/**
*
@ -708,13 +710,15 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
private RSGAccessPoint getRSGWSAddress() {
RSGAccessPoint rsgAp = (RSGAccessPoint) this.getThreadLocalRequest().getSession().getAttribute(RSG_WS_ADDRESS);
_log.trace("getRSGWSAddress: " + rsgAp.getRestUrl());
if (rsgAp != null)
_log.trace("getRSGWSAddress: " + rsgAp.getRestUrl());
return rsgAp;
}
private void setRSGWSAddress(RSGAccessPoint rsgAp) {
this.getThreadLocalRequest().getSession().setAttribute(RSG_WS_ADDRESS, rsgAp);
_log.trace("setting RSG WS address to " + rsgAp.getRestUrl());
if (rsgAp != null)
_log.trace("setting RSG WS address to " + rsgAp.getRestUrl());
}
/**
*
@ -889,8 +893,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
else if (imageItem.getFolderItemType()==FolderItemType.IMAGE_DOCUMENT){
GCubeItem image = (GCubeItem)item;
if (image.getMimeType().equals("image/tiff"))
// image.getProperties().getProperties().get(NodeProperty.THUMBNAIL_DATA); //this is a problem
// else
// image.getProperties().getProperties().get(NodeProperty.THUMBNAIL_DATA); //this is a problem
// else
data = image.getData();
}
if (data != null) {
@ -1312,24 +1316,27 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
*/
public SessionInfo getSessionInfo(String currentHost) {
if (testWorkflow) {
getASLSession().setAttribute(WfDocsLibrary.WORKFLOW_ID_ATTRIBUTE, "1");
getASLSession().setAttribute(WfDocsLibrary.WORKFLOW_GIVEN_NAME, "TEST REPORT");
getASLSession().setAttribute(WfDocsLibrary.WORKFLOW_READONLY_ATTRIBUTE, true);
return new SessionInfo(getUserBean(), getVreName(), true, true, false);
return new SessionInfo(getUserBean(), getVreName(), true, true, false, "");
}
boolean isVME = isReportsStoreGatewayAvailable();
if (getASLSession().getAttribute(WfDocsLibrary.WORKFLOW_ID_ATTRIBUTE) == null) {
_log.debug("WfDocsLibrary.WORKFLOW_ID_ATTRIBUTE is NULL: ");
return new SessionInfo(getUserBean(), getVreName(), false, false, isVME);
String rsgEndpoint = "";
if (getRSGWSAddress() != null)
rsgEndpoint = ((RSGAccessPoint) getRSGWSAddress()).getRestUrl();
return new SessionInfo(getUserBean(), getVreName(), false, false, isVME, rsgEndpoint);
}
else {
_log.debug("FOUND WORKFLOW_ID_ATTRIBUTE ***** ");
//String workflowid = getASLSession().getAttribute(WfDocsLibrary.WORKFLOW_ID_ATTRIBUTE).toString();
Boolean canEdit = ! (Boolean) getASLSession().getAttribute(WfDocsLibrary.WORKFLOW_READONLY_ATTRIBUTE);
return new SessionInfo(getUserBean(), getVreName(), true, canEdit, false);
return new SessionInfo(getUserBean(), getVreName(), true, canEdit, false, "");
}
}
@ -1652,7 +1659,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
}
return rsgReadClient;
}
private RsgWriteClient getRsgSecureClient() {
RSGAccessPoint rsgWsAddr = getRSGWSAddress();
if (rsgWriteClient == null) {

@ -10,29 +10,27 @@ public class SessionInfo implements Serializable {
private Boolean isWorkflowDocument;
private Boolean isEditable;
private Boolean isVME;
private String rsgEndpoint;
public SessionInfo() { }
public SessionInfo(
org.gcube.portlets.user.reportgenerator.shared.UserBean user,
String scope, Boolean isWorkflowDocument, Boolean isEditable,
Boolean isVME) {
public SessionInfo(UserBean user, String scope, Boolean isWorkflowDocument,
Boolean isEditable, Boolean isVME, String rsgEndpoint) {
super();
this.user = user;
this.scope = scope;
this.isWorkflowDocument = isWorkflowDocument;
this.isEditable = isEditable;
this.isVME = isVME;
this.rsgEndpoint = rsgEndpoint;
}
public UserBean getUsername() {
public UserBean getUserName() {
return user;
}
public void UserBean(UserBean userBean) {
this.user = userBean;
public void setUser(UserBean user) {
this.user = user;
}
public String getScope() {
@ -47,7 +45,7 @@ public class SessionInfo implements Serializable {
return isWorkflowDocument;
}
public void setIsWorkflowDocument(Boolean isWorkflowDocument) {
public void setWorkflowDocument(Boolean isWorkflowDocument) {
this.isWorkflowDocument = isWorkflowDocument;
}
@ -55,8 +53,8 @@ public class SessionInfo implements Serializable {
return isEditable;
}
public void setEditable(Boolean canEdit) {
this.isEditable = canEdit;
public void setEditable(Boolean isEditable) {
this.isEditable = isEditable;
}
public Boolean isVME() {
@ -66,6 +64,82 @@ public class SessionInfo implements Serializable {
public void setIsVME(Boolean isVME) {
this.isVME = isVME;
}
public String getRsgEndpoint() {
return rsgEndpoint;
}
public void setRsgEndpoint(String rsgEndpoint) {
this.rsgEndpoint = rsgEndpoint;
}
@Override
public String toString() {
return "SessionInfo [user=" + user + ", scope=" + scope
+ ", isWorkflowDocument=" + isWorkflowDocument
+ ", isEditable=" + isEditable + ", isVME=" + isVME
+ ", rsgEndpoint=" + rsgEndpoint + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((isEditable == null) ? 0 : isEditable.hashCode());
result = prime * result + ((isVME == null) ? 0 : isVME.hashCode());
result = prime
* result
+ ((isWorkflowDocument == null) ? 0 : isWorkflowDocument
.hashCode());
result = prime * result
+ ((rsgEndpoint == null) ? 0 : rsgEndpoint.hashCode());
result = prime * result + ((scope == null) ? 0 : scope.hashCode());
result = prime * result + ((user == null) ? 0 : user.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SessionInfo other = (SessionInfo) obj;
if (isEditable == null) {
if (other.isEditable != null)
return false;
} else if (!isEditable.equals(other.isEditable))
return false;
if (isVME == null) {
if (other.isVME != null)
return false;
} else if (!isVME.equals(other.isVME))
return false;
if (isWorkflowDocument == null) {
if (other.isWorkflowDocument != null)
return false;
} else if (!isWorkflowDocument.equals(other.isWorkflowDocument))
return false;
if (rsgEndpoint == null) {
if (other.rsgEndpoint != null)
return false;
} else if (!rsgEndpoint.equals(other.rsgEndpoint))
return false;
if (scope == null) {
if (other.scope != null)
return false;
} else if (!scope.equals(other.scope))
return false;
if (user == null) {
if (other.user != null)
return false;
} else if (!user.equals(other.user))
return false;
return true;
}
}

@ -13,6 +13,7 @@
<inherits name='org.gcube.portlets.widgets.fileupload.FileUpload' />
<inherits name='org.gcube.portlets.widgets.exporter.Report_exporter_widget' />
<inherits name='org.gcube.portlets.widgets.sessionchecker.SessionChecker' />
<inherits name="com.github.gwtbootstrap.Bootstrap" />
<!-- Specify the app entry point class. -->
<entry-point
class='org.gcube.portlets.user.reportgenerator.client.ReportGenerator' />

@ -0,0 +1,19 @@
package org.gcube.portlets.user.reportgenerator.test;
import static org.junit.Assert.assertTrue;
import org.gcube.portlets.user.reportgenerator.server.servlet.ReportServiceImpl;
import org.junit.Test;
public class TestForDeploy {
@Test
public void testUserIsTestUser() {
ReportServiceImpl serviceImpl = new ReportServiceImpl();
String username = serviceImpl.getDevelopmentUser();
System.out.println("username for deploy is: " + username);
assertTrue(username.compareTo("test.user") == 0);
System.out.println("Test OK!");
}
}