From 3e539fb5ca688ac0a0e7c3fe61ad4fb98bf7ec5e Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Fri, 15 Feb 2013 11:51:01 +0000 Subject: [PATCH] bug fixed: open report and open report template git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@69322 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/AppControllerExplorer.java | 101 +++++++++++------- .../client/resources/icons/mime/folder.png | Bin 315 -> 527 bytes .../client/resources/icons/mime/folder2.png | Bin 527 -> 315 bytes .../client/rpc/GWTWorkspaceService.java | 2 +- .../client/rpc/GWTWorkspaceServiceAsync.java | 4 +- .../server/GWTWorkspaceServiceImpl.java | 68 ++++++------ .../server/portletClassName.properties | 30 +++++- .../user/workspace/server/util/Util.java | 47 ++++---- 8 files changed, 149 insertions(+), 103 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java index 2edb9b8..1e5f52c 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java @@ -119,6 +119,7 @@ import com.extjs.gxt.ui.client.widget.Info; import com.google.gwt.core.client.GWT; import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.HandlerManager; +import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.HasWidgets; @@ -205,23 +206,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt @Override public void onCreateSharedFolder(CreateSharedFolderEvent createSharedFolderEvent) { - -// rpcWorkspaceService.readFromApplicationProfile("aaa", "bbb", new AsyncCallback() { -// -// @Override -// public void onFailure(Throwable caught) { -// // TODO Auto-generated method stub -// -// } -// -// @Override -// public void onSuccess(Void result) { -// // TODO Auto-generated method stub -// -// } -// }); - - final FileModel sourceFileModel = createSharedFolderEvent.getFileSourceModel(); //IF ITEM IS SHAREABLE @@ -1212,28 +1196,51 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt // System.out.println("id " +openReportsEvent.getSourceFileModel().getIdentifier()); // System.out.println("name " +openReportsEvent.getSourceFileModel().getName()); - rpcWorkspaceService.setValueInSession(ConstantsExplorer.IDREPORT, openReportsEvent.getSourceFileModel().getIdentifier(), new AsyncCallback() { + + + rpcWorkspaceService.getURLFromApplicationProfile(ConstantsExplorer.IDREPORT, openReportsEvent.getSourceFileModel().getIdentifier(), new AsyncCallback() { @Override public void onFailure(Throwable caught) { -// Log.error("Error setting session attribute idreport",caught); - new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " setting session attribute idreport", null); + new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting application profile - attribute idreport", null); } @Override - public void onSuccess(Void result) { - String currentUrl = portalURL(); - int last = currentUrl.lastIndexOf("/"); - String reportUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.REPORTGENERATION; + public void onSuccess(String url) { + + String reportUrl = url; +// int last = currentUrl.lastIndexOf("/"); +// String reportUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.REPORTGENERATION; // Log.trace("Url: "+reportUrl); - System.out.println("currentUrl " +currentUrl); +// System.out.println("currentUrl " +currentUrl); System.out.println("reportUrl " +reportUrl); new WindowOpenUrl(reportUrl, "_self", ""); } - }); + +// rpcWorkspaceService.setValueInSession(ConstantsExplorer.IDREPORT, openReportsEvent.getSourceFileModel().getIdentifier(), new AsyncCallback() { +// +// @Override +// public void onFailure(Throwable caught) { +// new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " setting session attribute idreport", null); +// +// } +// +// @Override +// public void onSuccess(Void result) { +// String currentUrl = portalURL(); +// int last = currentUrl.lastIndexOf("/"); +// String reportUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.REPORTGENERATION; +//// Log.trace("Url: "+reportUrl); +// System.out.println("currentUrl " +currentUrl); +// System.out.println("reportUrl " +reportUrl); +// new WindowOpenUrl(reportUrl, "_self", ""); +// +// } +// +// }); } private void doClickOpenReportTemplate(OpenReportsEvent openReportTemplateEvent) { @@ -1242,28 +1249,50 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt // System.out.println("id " +openReportTemplateEvent.getSourceFileModel().getIdentifier()); // System.out.println("name " +openReportTemplateEvent.getSourceFileModel().getName()); - rpcWorkspaceService.setValueInSession(ConstantsExplorer.IDTEMPLATE, openReportTemplateEvent.getSourceFileModel().getIdentifier(), new AsyncCallback() { + rpcWorkspaceService.getURLFromApplicationProfile(ConstantsExplorer.IDTEMPLATE, openReportTemplateEvent.getSourceFileModel().getIdentifier(), new AsyncCallback() { @Override public void onFailure(Throwable caught) { -// Log.error("Error setting session attribute idtemplate",caught); - new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR +" setting session attribute idtemplate", null); + new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting application profile - attribute idreport", null); } @Override - public void onSuccess(Void result) { - String currentUrl = portalURL(); - int last = currentUrl.lastIndexOf("/"); - String templateUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.TEMPLATECREATION; + public void onSuccess(String url) { + + String templateUrl = url; +// int last = currentUrl.lastIndexOf("/"); +// String templateUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.TEMPLATECREATION; // Log.trace("Url: "+templateUrl); - System.out.println("currentUrl " +currentUrl); - System.out.println("reportUrl " +templateUrl); +// System.out.println("currentUrl " +currentUrl); +// System.out.println("reportUrl " +templateUrl); new WindowOpenUrl(templateUrl, "_self", ""); } - }); + +// rpcWorkspaceService.setValueInSession(ConstantsExplorer.IDTEMPLATE, openReportTemplateEvent.getSourceFileModel().getIdentifier(), new AsyncCallback() { +// +// @Override +// public void onFailure(Throwable caught) { +//// Log.error("Error setting session attribute idtemplate",caught); +// new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR +" setting session attribute idtemplate", null); +// +// } +// +// @Override +// public void onSuccess(Void result) { +// String currentUrl = portalURL(); +// int last = currentUrl.lastIndexOf("/"); +// String templateUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.TEMPLATECREATION; +//// Log.trace("Url: "+templateUrl); +// System.out.println("currentUrl " +currentUrl); +// System.out.println("reportUrl " +templateUrl); +// new WindowOpenUrl(templateUrl, "_self", ""); +// +// } +// +// }); } }); diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/mime/folder.png b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/mime/folder.png index 5a118b6d9c560131c7dd2ff4e1d7e5e7f3d4c49e..6d493f1be73aeb68aa012b12ff1f7d38b23befcb 100644 GIT binary patch delta 501 zcmV0s))k? zVOZKGL#alw5M0HBnK}CK*}TO&%fB<6fZq`Z#n6!>&qly--Lflbs z?#}Xw$iIH7tOK?63puk3g_Dmc{C=}+bb0{^-GoBh*#FKo+SqHftmdrIL9En7^czE@ z*hEM@6fRIa*?&@5FW}9N-2Ir-v8Lz{WgW4sj!34Apj5_kTEo&;4X;xr+inq)V#@3V z@WSr4&ahE75!V>j`NR)=qNo~(=6@ihPz3wQ4NS*#_6Cca+3s3KgD7c;@`+(S=SPy!~@RNMd3kH5gud&~xHL8t5hR rbC!_dG4A{+jUDz9GIZp$$LjkH2b*o3VlwF000000NkvXXu0mjfArAFv delta 288 zcmV+*0pI?Q1iJ!|B!2=)L_t(|+GAv(5HJEU7Z3*mF*_FdPe8mLi2vd=fSrw@?a(HM zN&z7tj|nRJAA;}RWnl1%WXJ;YW?<3#A8de#Aj6y&rx}v5ng0JD14HL@hQIGW0bTG9 zss&2F|G@BL-e!gbMqxgNIgi)iFaYQxPBVxk-t;7d5H#>wUY0000k-t;7d5H#>wUY00000s))k? zVOZKGL#alw5M0HBnK}CK*}TO&%fB<6fZq`Z#n6!>&qly--Lflbs z?#}Xw$iIH7tOK?63puk3g_Dmc{C=}+bb0{^-GoBh*#FKo+SqHftmdrIL9En7^czE@ z*hEM@6fRIa*?&@5FW}9N-2Ir-v8Lz{WgW4sj!34Apj5_kTEo&;4X;xr+inq)V#@3V z@WSr4&ahE75!V>j`NR)=qNo~(=6@ihPz3wQ4NS*#_6Cca+3s3KgD7c;@`+(S=SPy!~@RNMd3kH5gud&~xHL8t5hR rbC!_dG4A{+jUDz9GIZp$$LjkH2b*o3VlwF000000NkvXXu0mjfArAFv diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java index c2f47a1..8c1136a 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java @@ -112,7 +112,7 @@ public interface GWTWorkspaceService extends RemoteService{ public List getListParentsByItemIdentifier(String itemIdentifier) throws Exception; - void readFromApplicationProfile(String name, String value) throws Exception; + public String getURLFromApplicationProfile(String name, String value) throws Exception; // public ArrayList> getChildrenListsByParentsIdentifier(String itemIdentifier) throws Exception; diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java index a21532b..3cd63be 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java @@ -117,8 +117,8 @@ public interface GWTWorkspaceServiceAsync { void getListParentsByItemIdentifier(String itemIdentifier, AsyncCallback> callback); - void readFromApplicationProfile(String name, String value, - AsyncCallback callback); + void getURLFromApplicationProfile(String name, String value, + AsyncCallback callback); // void getListParentsByItemIdentifier(String itemIdentifier,AsyncCallback> callback); diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java index 92880d8..5669f41 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java @@ -1,8 +1,5 @@ package org.gcube.portlets.user.workspace.server; -import java.io.BufferedInputStream; -import java.io.FileInputStream; -import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Collections; @@ -10,9 +7,8 @@ import java.util.List; import java.util.Properties; import java.util.concurrent.TimeUnit; -import javax.servlet.ServletContext; - import org.gcube.application.framework.core.session.ASLSession; +import org.gcube.applicationsupportlayer.social.SocialPortalBridge; import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.utils.logging.GCUBEClientLog; import org.gcube.portlets.user.homelibrary.home.exceptions.HomeNotFoundException; @@ -47,7 +43,6 @@ import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem; import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer; import org.gcube.portlets.user.workspace.server.util.AllScope; import org.gcube.portlets.user.workspace.server.util.Util; -import org.gcube.portlets.user.workspace.shared.FieldVerifier; import com.google.gwt.user.server.rpc.RemoteServiceServlet; @@ -82,7 +77,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } protected boolean isTestMode(){ - return Util.isTestMode(Util.getAslSession(this.getThreadLocalRequest().getSession())); + return Util.withoutPortal; } @Override @@ -755,43 +750,42 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } @Override - public void readFromApplicationProfile(String name, String value) throws Exception { + public String getURLFromApplicationProfile(String property, String value) throws Exception { + + String urlPortlet = ""; + String appId = ""; try{ ASLSession session = Util.getAslSession(this.getThreadLocalRequest().getSession()); Properties prop = new Properties(); - try { - - InputStream in = (InputStream) FieldVerifier.class.getResourceAsStream("portletClassName.properties"); - - // load a properties file from class path, inside static method - prop.load(in); - - // get the property value and print it out - System.out.println(prop.getProperty("idreport")); - System.out.println(prop.getProperty("idtemplate")); + InputStream in = (InputStream) GWTWorkspaceServiceImpl.class.getResourceAsStream("portletClassName.properties"); + + // load a properties file + prop.load(in); + + // get the property value - the application Id + appId = prop.getProperty(property); + + //print it out + System.out.println(prop.getProperty(property)); + + //set property in ASL session + setValueInSession(property,value); - } catch (IOException ex) { - ex.printStackTrace(); - } - - -// SocialPortalBridge spb = new SocialPortalBridge(session,) -// -// ASLSession session = Util.getAslSession(this.getThreadLocalRequest().getSession()); -// session.setAttribute(name, value); -// workspaceLogger.trace("set value in session with name: "+name+", value: "+value); -// workspaceLogger.debug("WS Session Id = " + session.getExternalSessionID()); -//// System.out.println("set value in session with name: "+name+", value: "+value); + SocialPortalBridge spb = new SocialPortalBridge(session,appId); + urlPortlet = spb.getApplicationProfile().getUrl(); + } catch (Exception e) { - workspaceLogger.error("setValueInSession", e); - throw new Exception(e.getMessage()); + workspaceLogger.error("getURLFromApplicationProfile", e); + throw new Exception("Sorry, an error occurred in retrieve application profile, try again"); } + + return urlPortlet; } @Override @@ -820,7 +814,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT Workspace workspace = getWorkspace(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - logger.info("get all scope"); + logger.trace("get all scope"); // WorkspaceItem parent = workspace.getItem(parentFileModel.getIdentifier()); //get item from workspace // workspace.getAllScope(); @@ -849,7 +843,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT Workspace workspace = getWorkspace(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - logger.info("get all contacts"); + logger.trace("get all contacts"); // WorkspaceItem parent = workspace.getItem(parentFileModel.getIdentifier()); //get item from workspace // workspace.getAllScope(); @@ -858,7 +852,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT if(isTestMode()){ - System.out.println("WORKSPACE PORTLET IS IN TEST MODE - RETURN TEST USERS"); + logger.warn("WORKSPACE PORTLET IS IN TEST MODE - RETURN TEST USERS"); List listContactsModel = new ArrayList(); // //TEST USERS listContactsModel.add(new InfoContactModel("Federico.Test", "Federico.Test", "Federico de Faveri")); @@ -866,6 +860,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT listContactsModel.add(new InfoContactModel("Fabio.Test", "Fabio.Test", "Fabio Sinibaldi")); listContactsModel.add(new InfoContactModel(Util.TEST_USER, Util.TEST_USER, Util.TEST_USER)); listContactsModel.add(new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante")); + listContactsModel.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa")); return listContactsModel; } @@ -1057,8 +1052,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT Workspace workspace = getWorkspace(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - - + List listFBC = workspace.getFolderBulkCreatorManager().getActiveFolderBulkCreators(); GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/portletClassName.properties b/src/main/java/org/gcube/portlets/user/workspace/server/portletClassName.properties index 8bedf28..50dce81 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/portletClassName.properties +++ b/src/main/java/org/gcube/portlets/user/workspace/server/portletClassName.properties @@ -1,2 +1,28 @@ -idtemplate=template -idreport=report \ No newline at end of file +# Property files +# +# author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it +# created 02/2013 +# +# Property = key value +# +# property - is the type of Folder Item set in HL +# value - (see property (2)) +# + +REPORT_TEMPLATE = idtemplate +REPORT = idreport + + + + +# Property = gCube App URL +# +# property (2) - is the key that must be set in ASL Session with value OID (OID is the "object id" of the object that must be open) +# value - is the AppId the must be read from Application Profile to retrieve the url application (gCube Apps) that must open the object wih OID + +# Ex. idtemplate = "12345" - "12345" is the value (OID set in ASL session at run-time) , that must be read from Report Application to +# open directly the object +# + +idtemplate=org.gcube.portlets.user.reportgenerator.server.servlet.ReportServiceImpl +idreport=org.gcube.portlets.user.templates.server.TemplateServiceImpl \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/util/Util.java b/src/main/java/org/gcube/portlets/user/workspace/server/util/Util.java index 2435809..0d243fe 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/util/Util.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/util/Util.java @@ -11,6 +11,7 @@ import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager; import org.gcube.applicationsupportlayer.social.NotificationsManager; import org.gcube.common.core.utils.logging.GCUBEClientLog; import org.gcube.common.core.utils.logging.GCUBELog; +import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portlets.user.homelibrary.home.HomeLibrary; import org.gcube.portlets.user.homelibrary.home.exceptions.HomeNotFoundException; import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException; @@ -26,7 +27,7 @@ import org.gcube.portlets.user.workspace.server.notifications.NotificationsProdu */ public class Util { - public static final String USERNAME_ATTRIBUTE = "username"; + public static final String USERNAME_ATTRIBUTE = ScopeHelper.USERNAME_ATTRIBUTE; public static final String FOLDERIMPORTER_ATTRIBUTE = "FOLDER_IMPORTER"; public static final String METADATACONVERTER_ATTRIBUTE = "METADATA_CONVERTER"; public static final String WORKSPACE_EVENT_COLLECTOR_ATTRIBUTE = "EVENT_COLLECTOR"; @@ -44,46 +45,42 @@ public class Util { // public static final String TEST_USER = "federico.defaveri"; // public static final String TEST_USER = "massimiliano.assante"; // public static final String TEST_USER = "pasquale.pagano"; - public static final String TEST_USER = "francesco.mangiacrapa"; - public static final String TEST_USER_FULL_NAME = "Francesco Mangiacrapa"; + public static final String TEST_USER = "test.user"; + public static final String TEST_USER_FULL_NAME = "Test User"; public static GCUBEClientLog defaultLogger = new GCUBEClientLog("WorkspacePortlet"); + public static boolean withoutPortal = false; public static ASLSession getAslSession(HttpSession httpSession) { String sessionID = httpSession.getId(); String user = (String) httpSession.getAttribute(USERNAME_ATTRIBUTE); - + ASLSession session; + if (user == null) { - defaultLogger.error("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND"); - System.out.println("http session id "+sessionID); //for test only - httpSession.setAttribute(USERNAME_ATTRIBUTE, TEST_USER); - ASLSession session = SessionManager.getInstance().getASLSession(sessionID, TEST_USER); - session.setScope(TEST_SCOPE); - session.setUserAvatarId(TEST_USER + "Avatar"); - session.setUserFullName(TEST_USER_FULL_NAME); +// httpSession.setAttribute(USERNAME_ATTRIBUTE, TEST_USER); + session = SessionManager.getInstance().getASLSession(sessionID, TEST_USER); + if(!withoutPortal){ //TEMPORARY SOLUTION + defaultLogger.error("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND"); + session.setScope(TEST_SCOPE); + session.setUserAvatarId(TEST_USER + "Avatar"); + session.setUserFullName(TEST_USER_FULL_NAME); + } - session.setAttribute(WS_RUN_IN_TEST_MODE, true); - - return session; + withoutPortal = true; + + }else{ + + session = SessionManager.getInstance().getASLSession(sessionID, user); + withoutPortal = false; } - ASLSession session = SessionManager.getInstance().getASLSession(sessionID, user); - session.setAttribute(WS_RUN_IN_TEST_MODE, false); + return session; } - public static boolean isTestMode(ASLSession session){ - - Boolean test = (Boolean) session.getAttribute(WS_RUN_IN_TEST_MODE); - - if(test == null || test==true) - return true; - - return false; - } public static Workspace getWorkspace(final HttpSession httpSession) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException {