diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..1cb9a59 --- /dev/null +++ b/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..d5b1692 --- /dev/null +++ b/.project @@ -0,0 +1,59 @@ + + + gcube-loggedin + gcube-loggedin project + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + com.google.gdt.eclipse.core.webAppProjectValidator + + + + + com.google.gwt.eclipse.core.gwtProjectValidator + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + com.google.gwt.eclipse.core.gwtNature + + diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope new file mode 100644 index 0000000..ba3c245 --- /dev/null +++ b/.settings/.jsdtscope @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/.settings/com.google.appengine.eclipse.core.prefs b/.settings/com.google.appengine.eclipse.core.prefs new file mode 100644 index 0000000..a60576c --- /dev/null +++ b/.settings/com.google.appengine.eclipse.core.prefs @@ -0,0 +1,3 @@ +#Thu Jun 16 10:18:26 CEST 2011 +eclipse.preferences.version=1 +filesCopiedToWebInfLib= diff --git a/.settings/com.google.gdt.eclipse.core.prefs b/.settings/com.google.gdt.eclipse.core.prefs new file mode 100644 index 0000000..3840a8f --- /dev/null +++ b/.settings/com.google.gdt.eclipse.core.prefs @@ -0,0 +1,6 @@ +#Wed Apr 10 17:20:53 CEST 2013 +eclipse.preferences.version=1 +jarsExcludedFromWebInfLib= +lastWarOutDir=/Users/massi/Documents/workspace/gcube-loggedin/target/gcube-loggedin-2.0.0-SNAPSHOT +warSrcDir=src/main/webapp +warSrcDirIsOutput=false diff --git a/.settings/com.google.gwt.eclipse.core.prefs b/.settings/com.google.gwt.eclipse.core.prefs new file mode 100644 index 0000000..c803c44 --- /dev/null +++ b/.settings/com.google.gwt.eclipse.core.prefs @@ -0,0 +1,5 @@ +#Thu Jun 16 11:14:17 CEST 2011 +eclipse.preferences.version=1 +entryPointModules= +filesCopiedToWebInfLib=gwt-servlet.jar +gwtCompileSettings=PGd3dC1jb21waWxlLXNldHRpbmdzPjxsb2ctbGV2ZWw+SU5GTzwvbG9nLWxldmVsPjxvdXRwdXQtc3R5bGU+T0JGVVNDQVRFRDwvb3V0cHV0LXN0eWxlPjxleHRyYS1hcmdzPjwhW0NEQVRBWy13YXIgc3JjL21haW4vd2ViYXBwXV0+PC9leHRyYS1hcmdzPjx2bS1hcmdzPjwhW0NEQVRBWy1YbXg1MTJtXV0+PC92bS1hcmdzPjxlbnRyeS1wb2ludC1tb2R1bGU+Y29tLmNvbXBhbnkuU29tZU1vZHVsZTwvZW50cnktcG9pbnQtbW9kdWxlPjwvZ3d0LWNvbXBpbGUtc2V0dGluZ3M+ diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..0642009 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,7 @@ +#Wed Apr 10 17:20:53 CEST 2013 +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..36c3062 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +#Wed Apr 10 17:44:47 CEST 2013 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..8428d82 --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,5 @@ +#Wed Apr 10 17:20:53 CEST 2013 +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..7226118 --- /dev/null +++ b/.settings/org.eclipse.wst.common.component @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..7895606 --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.container b/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..3bd5d0a --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/.settings/org.maven.ide.eclipse.prefs b/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 0000000..c74c58e --- /dev/null +++ b/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Thu Sep 02 10:42:12 CEST 2010 +activeProfiles= +eclipse.preferences.version=1 +fullBuildGoals=process-test-resources +includeModules=false +resolveWorkspaceProjects=true +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true +version=1 diff --git a/GCubeLoggedinTest-dev.launch b/GCubeLoggedinTest-dev.launch new file mode 100644 index 0000000..a4ed0fa --- /dev/null +++ b/GCubeLoggedinTest-dev.launch @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/GCubeLoggedinTest-prod.launch b/GCubeLoggedinTest-prod.launch new file mode 100644 index 0000000..9ff0889 --- /dev/null +++ b/GCubeLoggedinTest-prod.launch @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/distro/INSTALL b/distro/INSTALL new file mode 100644 index 0000000..139597f --- /dev/null +++ b/distro/INSTALL @@ -0,0 +1,2 @@ + + diff --git a/distro/LICENSE b/distro/LICENSE new file mode 100644 index 0000000..cdb5851 --- /dev/null +++ b/distro/LICENSE @@ -0,0 +1,7 @@ +gCube System - License +------------------------------------------------------------ + +The gCube/gCore software is licensed as Free Open Source software conveying to the EUPL (http://ec.europa.eu/idabc/eupl). +The software and documentation is provided by its authors/distributors "as is" and no expressed or +implied warranty is given for its use, quality or fitness for a particular case. + diff --git a/distro/MAINTAINERS b/distro/MAINTAINERS new file mode 100644 index 0000000..680cebb --- /dev/null +++ b/distro/MAINTAINERS @@ -0,0 +1,6 @@ +Mantainers +------- + +* Massimiliano Assante (massimiliano.assante@isti.cnr.it), CNR Pisa, + Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo". + diff --git a/distro/README b/distro/README new file mode 100644 index 0000000..6dbb15d --- /dev/null +++ b/distro/README @@ -0,0 +1,53 @@ +The gCube System - Template Creator portlet +------------------------------------------------------------ + +This work is partially funded by the European Commission in the +context of the D4Science project (www.d4science.eu), under the 1st call of FP7 IST priority. + + +Authors +------- + +* Massimiliano Assante (massimiliano.assante@isti.cnr.it), CNR Pisa, + Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo". + + +Version and Release Date +------------------------ + +v. 1.0.0, 15/10/2010 + + +Description +----------- + + + +Download information +-------------------- + +Source code is available from SVN: +http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/Template%20Creator%20Portlet + + +Binaries can be downloaded from: +http://software.d4science.research-infrastructures.eu/ + + +Documentation +------------- + +Documentation is available on-line from the Projects Documentation Wiki: + +https://gcube.wiki.gcube-system.org/gcube/index.php/Main_Page + + + +Licensing +--------- + +This software is licensed under the terms you may find in the file named "LICENSE" in this directory. + + + + diff --git a/distro/changelog.xml b/distro/changelog.xml new file mode 100644 index 0000000..ae3df8e --- /dev/null +++ b/distro/changelog.xml @@ -0,0 +1,7 @@ + + + Mavenized + Redesigned + + \ No newline at end of file diff --git a/distro/descriptor.xml b/distro/descriptor.xml new file mode 100644 index 0000000..4efc827 --- /dev/null +++ b/distro/descriptor.xml @@ -0,0 +1,48 @@ + + servicearchive + + tar.gz + + / + + + ${distroDirectory} + / + true + + README + LICENSE + INSTALL + MAINTAINERS + changelog.xml + + 755 + true + + + target/apidocs + /${artifactId}/doc/api + true + 755 + + + + + ${distroDirectory}/profile.xml + ./ + true + + + target/${build.finalName}.war + /${artifactId} + + + ${distroDirectory}/svnpath.txt + /${artifactId} + true + + + \ No newline at end of file diff --git a/distro/profile.xml b/distro/profile.xml new file mode 100644 index 0000000..51c3b6b --- /dev/null +++ b/distro/profile.xml @@ -0,0 +1,25 @@ + + + + Service + + ${description} + PortletUser + ${artifactId} + ${version} + + + ${artifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + + + target/${build.finalName}.war + + + + + diff --git a/distro/svnpath.txt b/distro/svnpath.txt new file mode 100644 index 0000000..edacb04 --- /dev/null +++ b/distro/svnpath.txt @@ -0,0 +1 @@ +${scm.url} \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..31eb07f --- /dev/null +++ b/pom.xml @@ -0,0 +1,234 @@ + + + + 4.0.0 + + maven-parent + org.gcube.tools + 1.0.0 + + + + org.gcube.portlets.user + gcube-loggedin + war + 2.0.0-SNAPSHOT + + gCube Loggedin Portlet + + gCube Loggedin. + + + scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId} + scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId} + http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId} + + + + 2.4.0 + distro + + 1.6 + 1.6 + ${project.build.directory}/${project.build.finalName} + + UTF-8 + UTF-8 + + + + + + + xerces + xercesImpl + 2.9.1 + provided + + + com.google.gwt + gwt-user + ${gwtVersion} + provided + + + com.google.gwt + gwt-servlet + ${gwtVersion} + provided + + + org.gcube.core + gcf + [1.5.0-SNAPSHOT, 2.0.0-SNAPSHOT) + provided + + + org.gcube.portal + custom-portal-handler + [1.2.0-SNAPSHOT, 2.0.0-SNAPSHOT) + provided + + + org.gcube.portlets.user + gcube-widgets + [1.4.0-SNAPSHOT, 2.0.0-SNAPSHOT) + provided + + + org.gcube.applicationsupportlayer + aslcore + [3.2.0-SNAPSHOT, 4.0.0-SNAPSHOT) + provided + + + com.liferay.portal + portal-service + 6.0.6 + provided + + + javax.portlet + portlet-api + 2.0 + provided + + + org.slf4j + slf4j-log4j12 + 1.6.4 + runtime + + + org.slf4j + slf4j-api + 1.6.4 + runtime + + + junit + junit + 4.7 + provided + + + javax.validation + validation-api + 1.0.0.GA + test + + + javax.validation + validation-api + 1.0.0.GA + sources + test + + + + + + ${webappDirectory}/WEB-INF/classes + + + + + + org.codehaus.mojo + gwt-maven-plugin + 2.4.0 + + + + compile + + + + + + + Messages.html + ${webappDirectory} + + + + + + org.apache.maven.plugins + maven-war-plugin + 2.1.1 + + + compile + + exploded + + + + + ${webappDirectory} + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2 + + + ${distroDirectory}/descriptor.xml + + + + + servicearchive + install + + single + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + + copy-profile + install + + copy-resources + + + target + + + ${distroDirectory} + true + + profile.xml + + + + + + + + + + + + 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 new file mode 100644 index 0000000..e1fc831 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/GCubeLoggedin.java @@ -0,0 +1,158 @@ +package org.gcube.portlets.user.gcubeloggedin.client; + +import org.gcube.portlets.user.gcubeloggedin.shared.VObject; + +import com.google.gwt.core.client.EntryPoint; +import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.rpc.ServiceDefTarget; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.HasHorizontalAlignment; +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.google.gwt.user.client.ui.Image; +import com.google.gwt.user.client.ui.RootPanel; +import com.google.gwt.user.client.ui.VerticalPanel; + +/** + * Entry point classes define onModuleLoad(). + */ +public class GCubeLoggedin implements EntryPoint { + + + /** + * Create a remote service proxy to talk to the server-side Greeting service. + */ + private final LoggedinServiceAsync loggedinService = GWT.create(LoggedinService.class); + private ServiceDefTarget endpoint = (ServiceDefTarget) loggedinService; + private VerticalPanel main_panel = new VerticalPanel(); + /** + * This is the entry point method. + */ + public void onModuleLoad() { + main_panel.setWidth("100%"); + + endpoint.setServiceEntryPoint(GWT.getModuleBaseURL()+"LoggedinServiceImpl"); + main_panel.add(new HTML("



Loading Environment please wait ...



" + getLoadingHTML() + "

" )); + + // Associate the new panel with the HTML host page. + RootPanel.get("LoggedinDiv").add(main_panel); + + loggedinService.getSelectedRE(new AsyncCallback() { + + public void onFailure(Throwable caught) { + } + + public void onSuccess(VObject result) { + main_panel.clear(); + main_panel.add(getShowLoadedEnvPanel(result)); + } + + }); + + //TEST + //main_panel.add(getShowLoadedEnvPanel(new VObject("ciccio", "ciccio", "dddd", "", "", null))); + } + + /** + * + * @param vobj + * @return + */ + private VerticalPanel getShowLoadedEnvPanel(VObject vobj) { + + VerticalPanel toReturn = new VerticalPanel(); + HorizontalPanel header = new HorizontalPanel(); + + HTML scope; + if (vobj == null) + scope = new HTML("Layout Loaded, could not read Enviroment Description", true); + else + scope = new HTML("" + vobj.getGroupName() + "", true); + header.add(scope); + + /** + * listener to go back and select another VRE/VO + */ + ClickHandler listener = new ClickHandler() { + public void onClick(ClickEvent event) { + main_panel.clear(); + main_panel.add(new HTML("



Loading Environment please wait ...



" + getLoadingHTML() + "

" )); + + loggedinService.getDefaultCommunityURL(new AsyncCallback() { + public void onFailure(Throwable arg0) { + Window.alert("We're sorry we couldn't reach the server, try again later ... " + arg0.getMessage()); + } + public void onSuccess(String url) { + Window.open(url, "_self", ""); + } + }); + + } + }; + HorizontalPanel topper = new HorizontalPanel(); + topper.getElement().getStyle().setMarginTop(20, Unit.PX); + topper.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); + topper.setWidth("100%"); + Button selectAnotherTop = new Button("Change Environment"); + selectAnotherTop.setWidth("150px"); + selectAnotherTop.addClickHandler(listener); + + topper.add(selectAnotherTop); + + HorizontalPanel body = new HorizontalPanel(); + + VerticalPanel leftPanel = new VerticalPanel(); + VerticalPanel rightPanel = new VerticalPanel(); + + if (vobj != null) { + leftPanel.add(new Image(vobj.getImageURL())); + rightPanel.setWidth("100%"); + leftPanel.add(topper); + HTML desc = new HTML(vobj.getDescription()); + desc.setStyleName("description"); + rightPanel.add(desc); + rightPanel.setWidth("100%"); + } + leftPanel.getElement().getStyle().setMarginRight(10, Unit.PX); + leftPanel.setStyleName("framed"); + rightPanel.getElement().getStyle().setPaddingLeft(10, Unit.PX); + rightPanel.setStyleName("framed"); + + + HorizontalPanel bottom = new HorizontalPanel(); + bottom.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); + bottom.setWidth("100%"); + Button selectAnother = new Button("Change Environment"); + selectAnother.addClickHandler(listener); + //bottom.add(selectAnother); + rightPanel.add(new HTML("
")); + rightPanel.add(bottom); + + body.add(leftPanel); + body.add(rightPanel); + + toReturn.add(body); + return toReturn; + + } + + + /** + * + * @return + */ + private String getLoadingHTML() { + return + "
"+ + ""+ + ""+ + "
"+ + ""+ + "
" ; + } +} diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinService.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinService.java new file mode 100644 index 0000000..3f33b03 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinService.java @@ -0,0 +1,18 @@ +package org.gcube.portlets.user.gcubeloggedin.client; + +import org.gcube.portlets.user.gcubeloggedin.shared.VObject; + +import com.google.gwt.user.client.rpc.RemoteService; +import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; + +/** + * The client side stub for the RPC service. + */ +@RemoteServiceRelativePath("LoggedinServiceImpl") +public interface LoggedinService extends RemoteService { + + VObject getSelectedRE(); + + String getDefaultCommunityURL(); + +} diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinServiceAsync.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinServiceAsync.java new file mode 100644 index 0000000..8e9daff --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinServiceAsync.java @@ -0,0 +1,17 @@ +package org.gcube.portlets.user.gcubeloggedin.client; + +import org.gcube.portlets.user.gcubeloggedin.shared.VObject; + +import com.google.gwt.user.client.rpc.AsyncCallback; + +/** + * The async counterpart of GreetingService. + */ +public interface LoggedinServiceAsync { + + + void getSelectedRE(AsyncCallback callback); + + + void getDefaultCommunityURL(AsyncCallback callback); +} diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/UIConstants.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/UIConstants.java new file mode 100644 index 0000000..710c586 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/UIConstants.java @@ -0,0 +1,9 @@ +package org.gcube.portlets.user.gcubeloggedin.client; + +import com.google.gwt.core.client.GWT; + +public class UIConstants { + + public static final String LOADING_IMAGE = GWT.getModuleBaseURL() + "../images/loading-bar.gif"; + +} 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 new file mode 100644 index 0000000..6d0f6c4 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/LoggedinServiceImpl.java @@ -0,0 +1,214 @@ +package org.gcube.portlets.user.gcubeloggedin.server; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.gcube.application.framework.core.session.ASLSession; +import org.gcube.application.framework.core.session.SessionManager; +import org.gcube.common.core.utils.logging.GCUBEClientLog; +import org.gcube.common.core.utils.logging.GCUBELog; +import org.gcube.portal.custom.communitymanager.OrganizationsUtil; +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 com.google.gwt.user.server.rpc.RemoteServiceServlet; +import com.liferay.portal.kernel.exception.PortalException; +import com.liferay.portal.kernel.exception.SystemException; +import com.liferay.portal.kernel.language.LanguageUtil; +import com.liferay.portal.kernel.servlet.ImageServletTokenUtil; +import com.liferay.portal.kernel.util.WebKeys; +import com.liferay.portal.model.Group; +import com.liferay.portal.model.Layout; +import com.liferay.portal.model.LayoutTypePortlet; +import com.liferay.portal.model.Organization; +import com.liferay.portal.service.GroupLocalServiceUtil; +import com.liferay.portal.theme.ThemeDisplay; + +/** + * The server side implementation of the RPC service. + */ +@SuppressWarnings("serial") +public class LoggedinServiceImpl extends RemoteServiceServlet implements LoggedinService { + + private static GCUBEClientLog _log = new GCUBEClientLog(LoggedinServiceImpl.class); + private boolean isDeployed = true; + /** + * 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 + "*" ); + isDeployed = false; + } + + return SessionManager.getInstance().getASLSession(sessionID, user); + + } + /** + * return the current selected VRE + */ + + public VObject getSelectedRE() { + ASLSession aslSession = getASLSession(); + if (! isDeployed) { + return new VREClient("Test", "", "" + + "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. This VO is conceived to support various application scenarios arising in the FARM Community including the production of Fisheries and Aquaculture Country Profiles, the management of catch statistics including harmonisation, the dynamic generation of biodiversity maps and species distribution maps. This Virtual Organisation currently consists of:
  • approximately 13 gCube nodes, i.e. machines dedicated to run the gCube system;
  • approximately 89 running instances, i.e. running gCube services supporting the operation of the infrastructure;
  • approximately 25 collections, i.e. set of D4Science Information Objects including Earth images, AquaMaps, Graphs on catch statistics;
  • approximately 66 metadata collections, i.e. set of Metadata Objects describing the Information Objects through various features and schemas;
  • approximately 58 other resources including transformation programs, index types, etc.
" + + "", "", "", UserBelongingClient.BELONGING); + } + _log.trace("getting Selected Research Environment"); + HttpSession session = this.getThreadLocalRequest().getSession(); + ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY); + Organization currOrg = (Organization) session.getAttribute("CURR_RE_NAME"); + + /** + * set the current ORG bean in session + */ + aslSession.setAttribute(ScopeHelper.CURR_ORG, currOrg); + + aslSession.setGroupModelInfos(currOrg.getName(), currOrg.getOrganizationId()); + + _log.trace("CURRENT ORG SET IN SESSION: " + currOrg.getName()); + + + String name = currOrg.getName(); + long logoId = currOrg.getLogoId(); + String logoURL = themeDisplay.getPathImage()+"/organization_logo?img_id="+ logoId +"&t" + ImageServletTokenUtil.getToken(logoId); + String desc = ""; + //set the description for the vre + if (currOrg.getComments() != null) + desc = currOrg.getComments(); + VREClient vre = new VREClient(name, "", desc, logoURL, "", UserBelongingClient.BELONGING); + setVREBelonginApplication(vre); + return vre; + } + + + /** + * recursive method which list the portlets belonging to the current VO/VRE whole layout + * + * @param layouts + * @param themeDisplay + * @param belongingPortletNames + * @throws SystemException + */ + private void findLayoutPortlets(List layouts, ThemeDisplay themeDisplay, List belongingPortletNames ) throws SystemException { + if (layouts == null) + return; + for (Layout curLayout : layouts) { + LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet)curLayout.getLayoutType(); + List actualPortletList = layoutTypePortlet.getPortletIds(); + for (String portletID : actualPortletList) { + String pname = LanguageUtil.get(themeDisplay.getLocale(), portletID); + //adding the portlet name cutting the not need part e.g. WorkspacePortlet_WAR_WorkspacePortlet + if (pname.indexOf("WAR") > 0) { + pname = pname.substring(0, pname.indexOf("WAR")-1); + } + belongingPortletNames.add(pname); + } + findLayoutPortlets(curLayout.getChildren(), themeDisplay, belongingPortletNames); + } + } + + /** + * TODO: Look which portlets are in the current VRE layout and create a List of names with them + * @param vre + */ + private void setVREBelonginApplication(VREClient vre) { + + List belongingPortletNames = new ArrayList(); + ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY); + + _log.debug("Reading Layouts..."); + + List layouts = themeDisplay.getLayouts(); + try { + findLayoutPortlets(layouts, themeDisplay, belongingPortletNames); + } catch (SystemException e) { + e.printStackTrace(); + } + Collections.sort(belongingPortletNames); + _log.debug("AvailablePortlets STORE IN SESSION \n" + belongingPortletNames.toString()); + getASLSession().setAttribute("availablePortlets", belongingPortletNames); + } + + /** + * The Default Community is a community where all portal user belong to + * @return the default community URL + * @throws SystemException + * @throws PortalException + */ + public String getDefaultCommunityURL() { + //get the portles to look for from the property file + Properties props = new Properties(); + String comName = ""; + + try { + String propertyfile = this.getServletContext().getRealPath("")+"/config/resources.properties"; + File propsFile = new File(propertyfile); + FileInputStream fis = new FileInputStream(propsFile); + props.load( fis); + comName = props.getProperty("defaultcommunity"); + } + //catch exception in case properties file does not exist + catch(IOException e) { + _log.error("/config/resources.properties not found, Returning \"Data e-Infrastructure gateway\" as default Community"); + } + + String toReturn = ""; + _log.trace("Default Community Read from config file: " + comName); + Group myPlace = null; + try { + myPlace = GroupLocalServiceUtil.getGroup(OrganizationsUtil.getCompany().getCompanyId(), comName); + + if(myPlace.isCommunity()) { + ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY); + toReturn = myPlace.getPathFriendlyURL(true, themeDisplay) + myPlace.getFriendlyURL(); + } + } catch (PortalException e) { + e.printStackTrace(); + } catch (SystemException e) { + e.printStackTrace(); + } + toReturn = getPortalBasicUrl()+toReturn; + _log.trace("RETURNING Default Community URL: " + toReturn); + return toReturn; + } + + + /** + * + * @return the portal basic url, e.g. http://www.foo.com + */ + private String getPortalBasicUrl() { + HttpServletRequest request = this.getThreadLocalRequest(); + String toReturn = ""; + //protocol + String protocol = (request.isSecure()) ? "https://" : "http://" ; + toReturn += protocol; + //server name + toReturn += request.getServerName(); + //port + toReturn += (request.getServerPort() == 80) ? "" : ":"+request.getServerPort() ; + + request.getQueryString(); + + _log.trace("\n getPortalBasicUrl: " +toReturn + "queryString: " + request.getQueryString()); + return toReturn; + } +} 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 new file mode 100644 index 0000000..feff5af --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/portlet/LoggedinPortlet.java @@ -0,0 +1,54 @@ + +package org.gcube.portlets.user.gcubeloggedin.server.portlet; + +import java.io.IOException; + +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.GenericPortlet; +import javax.portlet.PortletException; +import javax.portlet.PortletRequestDispatcher; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; + +import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; + +import com.liferay.portal.kernel.exception.PortalException; +import com.liferay.portal.kernel.exception.SystemException; +import com.liferay.portal.model.Organization; + +/** + * LoggedinPortlet Portlet Class + * @author massi + */ +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); + + } + + /** + * + * @param currentGroup + * @return true id the organization is a VO + * @throws SystemException . + * @throws PortalException . + */ + private boolean isVO(Organization currentOrg) throws PortalException, SystemException { + return (currentOrg.getParentOrganization().getParentOrganization() == null); + } + + + public void processAction(ActionRequest request, ActionResponse response) + throws PortletException, IOException { + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/UserBelonging.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/UserBelonging.java new file mode 100644 index 0000000..d9f341e --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/UserBelonging.java @@ -0,0 +1,5 @@ +package org.gcube.portlets.user.gcubeloggedin.shared; + +public enum UserBelonging { BELONGING, NOT_BELONGING, PENDING + +} diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VOClient.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VOClient.java new file mode 100644 index 0000000..68d7dbc --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VOClient.java @@ -0,0 +1,65 @@ +package org.gcube.portlets.user.gcubeloggedin.shared; + +import java.io.Serializable; +import java.util.List; + +/** + * + * @author massi + * + */ +public class VOClient extends VObject implements Comparable, Serializable { + + /** + * + */ + private static final long serialVersionUID = -8851330991617092921L; + private boolean isRoot; + private List vres; + + public VOClient() { } + + public VOClient( + String name, + String groupName, + String description, + String imageURL, + String friendlyURL, + UserBelongingClient userBelonging) { + super(name, groupName, description, imageURL, friendlyURL, userBelonging); + // TODO Auto-generated constructor stub + } + + public VOClient( + String name, + String groupName, + String description, + String imageURL, + String friendlyURL, + UserBelongingClient userBelonging, + boolean isRoot, List vres) { + super(name, groupName, description, imageURL, friendlyURL, userBelonging); + this.isRoot = isRoot; + this.vres = vres; + } + + public boolean isRoot() { + return isRoot; + } + + public void setRoot(boolean isRoot) { + this.isRoot = isRoot; + } + + public List getVres() { + return vres; + } + + public void setVres(List vres) { + this.vres = vres; + } + + public int compareTo(VOClient voToCompare) { + return (this.vres.size() >= voToCompare.getVres().size()) ? 1 : -1; + } +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VObject.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VObject.java new file mode 100644 index 0000000..de09d3c --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VObject.java @@ -0,0 +1,79 @@ +package org.gcube.portlets.user.gcubeloggedin.shared; + +import java.io.Serializable; + + +public class VObject implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 59621631728865981L; + + public enum UserBelongingClient { + BELONGING, NOT_BELONGING, PENDING + } + + private String name; + private String groupName; + private String description; + private String imageURL; + private String friendlyURL; + + + private UserBelongingClient userBelonging; + public VObject() { + super(); + // TODO Auto-generated constructor stub + } + + public VObject(String name, String groupName, String description, String imageURL, String friendlyURL, + UserBelongingClient userBelonging) { + super(); + this.name = name; + this.groupName = groupName; + this.description = description; + this.imageURL = imageURL; + this.friendlyURL = friendlyURL; + this.userBelonging = userBelonging; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public String getImageURL() { + return imageURL; + } + public void setImageURL(String imageURL) { + this.imageURL = imageURL; + } + public UserBelongingClient getUserBelonging() { + return userBelonging; + } + public void setUserBelonging(UserBelongingClient userBelonging) { + this.userBelonging = userBelonging; + } + public String getGroupName() { + return groupName; + } + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public String getFriendlyURL() { + return friendlyURL; + } + + public void setFriendlyURL(String friendlyURL) { + this.friendlyURL = friendlyURL; + } + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VREClient.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VREClient.java new file mode 100644 index 0000000..005cc69 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/shared/VREClient.java @@ -0,0 +1,27 @@ +package org.gcube.portlets.user.gcubeloggedin.shared; + +/** + * + * @author massi + * + */ +public class VREClient extends VObject { + + /** + * + */ + private static final long serialVersionUID = -4608871177709997781L; + + public VREClient() { + super(); + // TODO Auto-generated constructor stub + } + + public VREClient(String name, String groupName, String description, String imageURL, String friendlyURL, + UserBelongingClient userBelonging) { + super(name, groupName, description, imageURL, friendlyURL, userBelonging); + // TODO Auto-generated constructor stub + } + + +} \ No newline at end of file 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 new file mode 100644 index 0000000..b76ab5a --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/gcubeloggedin/GCubeLoggedin.gwt.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/GCubeLoggedin.css b/src/main/webapp/GCubeLoggedin.css new file mode 100644 index 0000000..bb68e22 --- /dev/null +++ b/src/main/webapp/GCubeLoggedin.css @@ -0,0 +1,56 @@ +/** Add css rules here for your application. */ +#LoggedinDiv { + margin-right: 10px; +} + +table { + border-collapse: separate !important; + border-spacing: 0; +} + +.framed { + margin: 0 0 10px; + padding: 10px; + margin: 0px 5px; + + background: #FFF url(images/vre_bg_gray.png) repeat-x left bottom; + + border-radius: 6px !important; + -moz-border-radius: 6px !important; + -webkit-border-radius: 6px !important; + + border: 1px solid #DBDBDB; +} + +/** Example rules used by the template application (remove for your app) */ +h1 { + font-size: 2em; + font-weight: bold; + color: #777777; + margin: 40px 0px 70px; + text-align: center; +} + +.description { + line-height: 18px; + font-family: Tahoma,Helvetica,Arial,sans-serif; + font-size: 10pt; + color: rgb(51, 51, 51); + text-align: justify; +} + +/** Most GWT widgets already have a style name defined */ +.gwt-DialogBox { + width: 400px; +} + +.dialogVPanel { + margin: 5px; +} + +.serverResponseLabelError { + color: red; +} + + + diff --git a/src/main/webapp/GCubeLoggedin.html b/src/main/webapp/GCubeLoggedin.html new file mode 100644 index 0000000..94b9f0e --- /dev/null +++ b/src/main/webapp/GCubeLoggedin.html @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + Web Application Starter Project + + + + + + + + + + + + + + + +
+ + + diff --git a/src/main/webapp/WEB-INF/jsp/LoggedinPortlet_error.jsp b/src/main/webapp/WEB-INF/jsp/LoggedinPortlet_error.jsp new file mode 100644 index 0000000..b1d7dab --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/LoggedinPortlet_error.jsp @@ -0,0 +1,13 @@ +<%@page contentType="text/html"%> +<%@page pageEncoding="UTF-8"%> + +<%-- Uncomment below lines to add portlet taglibs to jsp +<%@ page import="javax.portlet.*"%> +<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%> + + +--%> + + + OPS! WE believe this is not an Organization, THIS PORTLET IS MEANT TO WORK WITHIN ORGANIZATION PAGES + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/jsp/LoggedinPortlet_help.jsp b/src/main/webapp/WEB-INF/jsp/LoggedinPortlet_help.jsp new file mode 100644 index 0000000..39ed5a1 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/LoggedinPortlet_help.jsp @@ -0,0 +1,13 @@ +<%@page contentType="text/html"%> +<%@page pageEncoding="UTF-8"%> + +<%-- Uncomment below lines to add portlet taglibs to jsp +<%@ page import="javax.portlet.*"%> +<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%> + + +--%> + + + HELP MODE + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/jsp/LoggedinPortlet_view.jsp b/src/main/webapp/WEB-INF/jsp/LoggedinPortlet_view.jsp new file mode 100644 index 0000000..167a8c1 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/LoggedinPortlet_view.jsp @@ -0,0 +1,11 @@ +<%@page contentType="text/html"%> +<%@page pageEncoding="UTF-8"%> + +<%-- Uncomment below lines to add portlet taglibs to jsp +<%@ page import="javax.portlet.*"%> +<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%> + + +--%> + +
\ No newline at end of file diff --git a/src/main/webapp/WEB-INF/liferay-display.xml b/src/main/webapp/WEB-INF/liferay-display.xml new file mode 100644 index 0000000..92d5131 --- /dev/null +++ b/src/main/webapp/WEB-INF/liferay-display.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/main/webapp/WEB-INF/liferay-plugin-package.properties b/src/main/webapp/WEB-INF/liferay-plugin-package.properties new file mode 100644 index 0000000..5ab21a9 --- /dev/null +++ b/src/main/webapp/WEB-INF/liferay-plugin-package.properties @@ -0,0 +1,9 @@ +name=Environment Home +module-group-id=liferay +module-incremental-version=1 +tags= +short-description= +change-log= +page-url=http://www.d4science.eu +author=D4Science EU +licenses= \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/liferay-portlet.xml b/src/main/webapp/WEB-INF/liferay-portlet.xml new file mode 100644 index 0000000..3f358fb --- /dev/null +++ b/src/main/webapp/WEB-INF/liferay-portlet.xml @@ -0,0 +1,17 @@ + + + + + + Loggedin + false + false + false + + /GCubeLoggedin.css + + + administrator + Administrator + + diff --git a/src/main/webapp/WEB-INF/portlet.xml b/src/main/webapp/WEB-INF/portlet.xml new file mode 100644 index 0000000..9afe0e6 --- /dev/null +++ b/src/main/webapp/WEB-INF/portlet.xml @@ -0,0 +1,25 @@ + + + + + Loggedin + Environment Home + org.gcube.portlets.user.gcubeloggedin.server.portlet.LoggedinPortlet + + view-jsp + /WEB-INF/jsp/LoginPortlet_view.jsp + + 0 + + text/html + + + Environment Home + Environment Home + Environment Home + + + administrator + + + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..751d5d9 --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + + + + + LoggedinServiceImpl + org.gcube.portlets.user.gcubeloggedin.server.LoggedinServiceImpl + + + + LoggedinServiceImpl + /gcubeloggedin/LoggedinServiceImpl + + + + + GCubeLoggedin.html + + + diff --git a/src/main/webapp/config/resources.properties b/src/main/webapp/config/resources.properties new file mode 100644 index 0000000..c579842 --- /dev/null +++ b/src/main/webapp/config/resources.properties @@ -0,0 +1 @@ +defaultcommunity=Data e-Infrastructure gateway diff --git a/src/main/webapp/images/loading-bar.gif b/src/main/webapp/images/loading-bar.gif new file mode 100644 index 0000000..4267f29 Binary files /dev/null and b/src/main/webapp/images/loading-bar.gif differ diff --git a/src/main/webapp/images/text-bg.gif b/src/main/webapp/images/text-bg.gif new file mode 100644 index 0000000..4179607 Binary files /dev/null and b/src/main/webapp/images/text-bg.gif differ diff --git a/src/main/webapp/images/vre_bg.png b/src/main/webapp/images/vre_bg.png new file mode 100644 index 0000000..ab9ca8c Binary files /dev/null and b/src/main/webapp/images/vre_bg.png differ diff --git a/src/main/webapp/images/vre_bg_gray.png b/src/main/webapp/images/vre_bg_gray.png new file mode 100644 index 0000000..31cb923 Binary files /dev/null and b/src/main/webapp/images/vre_bg_gray.png differ diff --git a/src/test/resources/org/gcube/portlets/user/gcubeloggedin/GCubeLoggedinJUnit.gwt.xml b/src/test/resources/org/gcube/portlets/user/gcubeloggedin/GCubeLoggedinJUnit.gwt.xml new file mode 100644 index 0000000..d7eb33c --- /dev/null +++ b/src/test/resources/org/gcube/portlets/user/gcubeloggedin/GCubeLoggedinJUnit.gwt.xml @@ -0,0 +1,9 @@ + + + + + + + + +