diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..f51e4e5 --- /dev/null +++ b/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..9969891 --- /dev/null +++ b/.project @@ -0,0 +1,59 @@ + + + my-vres + my-vres 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..75427c9 --- /dev/null +++ b/.settings/com.google.gdt.eclipse.core.prefs @@ -0,0 +1,6 @@ +#Sun Dec 23 11:33:33 CET 2012 +eclipse.preferences.version=1 +jarsExcludedFromWebInfLib= +lastWarOutDir=/Users/massi/Documents/workspace/my-vres/target/my-vres-1.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..9821b3d --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,7 @@ +#Sun Dec 23 11:10:00 CET 2012 +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..ad26666 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +#Thu Sep 02 10:42:20 CEST 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +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.5 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..ab3e7c3 --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,5 @@ +#Sun Dec 23 11:09:59 CET 2012 +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..ac73cc9 --- /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..18c1b9a --- /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..dae95d4 --- /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/MyVREsTest-dev.launch b/MyVREsTest-dev.launch new file mode 100644 index 0000000..1b3374b --- /dev/null +++ b/MyVREsTest-dev.launch @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/MyVREsTest-prod.launch b/MyVREsTest-prod.launch new file mode 100644 index 0000000..c94de96 --- /dev/null +++ b/MyVREsTest-prod.launch @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..9e44bbd --- /dev/null +++ b/pom.xml @@ -0,0 +1,138 @@ + + + + + 4.0.0 + org.gcube.portlet.user + my-vres + war + 1.0.0-SNAPSHOT + My VREs Portlet + + + + 2.4.0 + + ${project.build.directory}/${project.build.finalName} + UTF-8 + + + + + com.google.gwt + gwt-user + ${gwtVersion} + + provided + + + + xerces + xercesImpl + 2.9.1 + provided + + + org.gcube.portlets.user + gcube-widgets + 1.4.0-SNAPSHOT + provided + + + org.gcube.portal + custom-portal-handler + 1.2.0-SNAPSHOT + provided + + + com.liferay.portal + portal-service + 6.0.6 + provided + + + javax.portlet + portlet-api + 2.0 + provided + + + junit + junit + 4.7 + test + + + 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 + test + + + + + + MyVREs.html + ${webappDirectory} + org.gcube.portlet.user.my_vres.client.Messages + + + + + org.apache.maven.plugins + maven-war-plugin + 2.1.1 + + + compile + + exploded + + + + + ${webappDirectory} + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.5 + 1.5 + + + + + + diff --git a/src/main/java/org/gcube/portlet/user/my_vres/client/Header.ui.xml b/src/main/java/org/gcube/portlet/user/my_vres/client/Header.ui.xml new file mode 100644 index 0000000..1d61461 --- /dev/null +++ b/src/main/java/org/gcube/portlet/user/my_vres/client/Header.ui.xml @@ -0,0 +1,10 @@ + + + + +
+ My Virtual Research Environments +
+
+
\ No newline at end of file diff --git a/src/main/java/org/gcube/portlet/user/my_vres/client/MyVREs.java b/src/main/java/org/gcube/portlet/user/my_vres/client/MyVREs.java new file mode 100644 index 0000000..7a19654 --- /dev/null +++ b/src/main/java/org/gcube/portlet/user/my_vres/client/MyVREs.java @@ -0,0 +1,18 @@ +package org.gcube.portlet.user.my_vres.client; + +import com.google.gwt.core.client.EntryPoint; +import com.google.gwt.user.client.ui.RootPanel; + +/** + * Entry point classes define onModuleLoad(). + */ +public class MyVREs implements EntryPoint { + + /** + * This is the entry point method. + */ + public void onModuleLoad() { + RootPanel.get("myVREsDIV").add(new VresPanel()); + + } +} diff --git a/src/main/java/org/gcube/portlet/user/my_vres/client/MyVREsService.java b/src/main/java/org/gcube/portlet/user/my_vres/client/MyVREsService.java new file mode 100644 index 0000000..2eb6ae6 --- /dev/null +++ b/src/main/java/org/gcube/portlet/user/my_vres/client/MyVREsService.java @@ -0,0 +1,20 @@ +package org.gcube.portlet.user.my_vres.client; + +import java.util.ArrayList; + +import org.gcube.portlet.user.my_vres.shared.VO; + + + +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("greet") +public interface MyVREsService extends RemoteService { + ArrayList getInfrastructureVOs(); + + void loadLayout(String scope, String URL); +} diff --git a/src/main/java/org/gcube/portlet/user/my_vres/client/MyVREsServiceAsync.java b/src/main/java/org/gcube/portlet/user/my_vres/client/MyVREsServiceAsync.java new file mode 100644 index 0000000..f339e18 --- /dev/null +++ b/src/main/java/org/gcube/portlet/user/my_vres/client/MyVREsServiceAsync.java @@ -0,0 +1,14 @@ +package org.gcube.portlet.user.my_vres.client; + +import java.util.ArrayList; + +import org.gcube.portlet.user.my_vres.shared.VO; + +import com.google.gwt.user.client.rpc.AsyncCallback; + +public interface MyVREsServiceAsync { + void getInfrastructureVOs(AsyncCallback> callback); + + void loadLayout(String scope, String URL, AsyncCallback callback); + +} diff --git a/src/main/java/org/gcube/portlet/user/my_vres/client/NoVresPanel.java b/src/main/java/org/gcube/portlet/user/my_vres/client/NoVresPanel.java new file mode 100644 index 0000000..094f7e4 --- /dev/null +++ b/src/main/java/org/gcube/portlet/user/my_vres/client/NoVresPanel.java @@ -0,0 +1,23 @@ +package org.gcube.portlet.user.my_vres.client; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.Widget; + +public class NoVresPanel extends Composite { + + private static NoVresPanelUiBinder uiBinder = GWT + .create(NoVresPanelUiBinder.class); + + interface NoVresPanelUiBinder extends UiBinder { + } + + public NoVresPanel() { + initWidget(uiBinder.createAndBindUi(this)); + } + + public NoVresPanel(String firstName) { + initWidget(uiBinder.createAndBindUi(this)); + } +} diff --git a/src/main/java/org/gcube/portlet/user/my_vres/client/NoVresPanel.ui.xml b/src/main/java/org/gcube/portlet/user/my_vres/client/NoVresPanel.ui.xml new file mode 100644 index 0000000..10558a7 --- /dev/null +++ b/src/main/java/org/gcube/portlet/user/my_vres/client/NoVresPanel.ui.xml @@ -0,0 +1,12 @@ + + + +
+ You are not subscribed to any Virtual Research Environment, + begin by + joining one.

+ Find out the Virtual Research Environments available in the infrastructure! +
+
+
\ No newline at end of file diff --git a/src/main/java/org/gcube/portlet/user/my_vres/client/VresPanel.java b/src/main/java/org/gcube/portlet/user/my_vres/client/VresPanel.java new file mode 100644 index 0000000..8a18bb6 --- /dev/null +++ b/src/main/java/org/gcube/portlet/user/my_vres/client/VresPanel.java @@ -0,0 +1,257 @@ +package org.gcube.portlet.user.my_vres.client; + + +import java.util.ArrayList; +import java.util.Date; + +import org.gcube.portlet.user.my_vres.client.widgets.BulletList; +import org.gcube.portlet.user.my_vres.client.widgets.ClickableVRE; +import org.gcube.portlet.user.my_vres.client.widgets.ListItem; +import org.gcube.portlet.user.my_vres.shared.UserBelonging; +import org.gcube.portlet.user.my_vres.shared.VO; +import org.gcube.portlet.user.my_vres.shared.VRE; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.user.client.Cookies; +import com.google.gwt.user.client.Timer; +import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.FlowPanel; +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.VerticalPanel; +/** + * + * @author Massimiliano Assante - ISTI CNR + * @version 1.1 Dec 2012 + * + */ +public class VresPanel extends Composite { + /** + * Create a remote service proxy to talk to the server-side service + */ + private final MyVREsServiceAsync myVREsService = GWT.create(MyVREsService.class); + + private static String VO = "Virtual Organizations"; + private static String VRE = "Virtual Research Environments"; + public static final String COOKIE_NAME = "gCube-EnvironmentViewRestore"; + public static final int COOKIE_MONTHS_EXPIRY_TIME = 6; //6 Months + private HTML switcher = new HTML(); + private FlowPanel flowPanel; + private VerticalPanel mainPanel = new VerticalPanel(); + private HorizontalPanel changeViewPanel = new HorizontalPanel(); + private HorizontalPanel imagesPanel = new HorizontalPanel(); + private Timer t = null; + + private ArrayList cachedVOs = null; + + private boolean isIconView = true; + boolean hasVres = false; + + public VresPanel() { + super(); + + mainPanel.setWidth("100%"); + mainPanel.setStyleName("mainPanel"); + this.flowPanel = new FlowPanel(); + flowPanel.setWidth("100%"); + flowPanel.setStyleName("flowPanel"); + + changeViewPanel.setWidth("95%"); + changeViewPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); + changeViewPanel.add(imagesPanel); + initWidget(mainPanel); + + switcher.setStyleName("imageLink"); + imagesPanel.add(switcher); + + switcher.setStyleName("switcher"); + switcher.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent event) { + if (isIconView) + showListView(); + else + showIconView(); + } + }); + + setLastStateUsingCookie(); + } + + private void loadVREs() { + myVREsService.getInfrastructureVOs(new AsyncCallback>() { + public void onSuccess(ArrayList result) { + cachedVOs = result; + if (isIconView) + showIconView(); + else + showListView(); + } + public void onFailure(Throwable caught) { + flowPanel.add(new HTML("Could not fetch personal VREs: " + caught.getMessage())); + } + }); + } + + private void showListView() { + mainPanel.clear(); + mainPanel.add(changeViewPanel); + HTML voTitle = new HTML(VO); + voTitle.setStyleName("listPanel-title"); + + BulletList voList = new BulletList(); + voList.setStyleName("list"); + boolean showVOs = false; + for (VO vo: cachedVOs) { + if (! vo.isRoot() && vo.getUserBelonging() == UserBelonging.BELONGING) { + voList.add(addVo(vo)); + showVOs = true; + } + } + if (showVOs){ + mainPanel.add(voTitle); + mainPanel.add(voList); + } + HTML vreTitle = new HTML(VRE); + vreTitle.setStyleName("listPanel-title"); + + BulletList vreList = new BulletList(); + vreList.setStyleName("list"); + boolean showVREs = false; + for (VO vo: cachedVOs) { + for (VRE vre : vo.getVres()) { + vreList.add(addVRE(vre)); + showVREs = true; + } + } + if (showVREs) { + mainPanel.add(vreTitle); + mainPanel.add(vreList); + } + Cookies.setCookie(COOKIE_NAME, "1", getExpiryDate()); + isIconView = false; + setSwitcherText(); + } + + private void showIconView() { + mainPanel.clear(); + flowPanel.clear(); + mainPanel.add(changeViewPanel); + mainPanel.add(flowPanel); + for (VO vo: cachedVOs) { + for (VRE vre : vo.getVres()) { + ClickableVRE vreButton = new ClickableVRE(vre, myVREsService); + flowPanel.add(vreButton); + hasVres = true; + } + } + if (!hasVres) { + mainPanel.add(new NoVresPanel()); + imagesPanel.clear(); + } + Cookies.setCookie(COOKIE_NAME, "0", getExpiryDate()); + isIconView = true; + setSwitcherText(); + } + + + private ListItem addVo(final VO vo) { + final ListItem li = new ListItem(); + li.setStyleName("list-item item-vo "); + li.setText(vo.getName()); + li.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent event) { + showLoading(li); + String scope = vo.getGroupName(); + myVREsService.loadLayout(scope, vo.getFriendlyURL(), new AsyncCallback() { + public void onFailure(Throwable arg0) { + Window.open( vo.getFriendlyURL(), "_self", ""); + } + public void onSuccess(Void arg0) { + Window.open( vo.getFriendlyURL(), "_self", ""); + } + }); + } + }); + return li; + } + + private ListItem addVRE(final VRE vre) { + final ListItem li = new ListItem(); + li.setStyleName("list-item item-vre "); + li.setText(vre.getName()); + li.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent event) { + showLoading(li); + String scope = vre.getGroupName(); + myVREsService.loadLayout(scope, vre.getFriendlyURL(), new AsyncCallback() { + public void onFailure(Throwable arg0) { + Window.open( vre.getFriendlyURL(), "_self", ""); + } + public void onSuccess(Void arg0) { + Window.open( vre.getFriendlyURL(), "_self", ""); + } + }); + } + }); + return li; + } + + + private void showLoading(final ListItem li) { + li.setText("Loading ."); + t = new Timer() { + @Override + public void run() { + li.setText(li.getText() + " ."); + t.schedule(250); + if (li.getText().length() > 50) + t.cancel(); + } + }; + t.schedule(250); + } + + private void setSwitcherText() { + if (isIconView) + switcher.setHTML("SHOW LIST"); + else + switcher.setHTML("SHOW TILES"); + } + + + /** + * + * @return + */ + @SuppressWarnings("deprecation") + public Date getExpiryDate() { + Date expiryDate = new Date(); + int month = expiryDate.getMonth(); + month += COOKIE_MONTHS_EXPIRY_TIME ; + expiryDate.setMonth(month); + return expiryDate; + } + /** + * + */ + private void setLastStateUsingCookie() { + Date expiryDate = getExpiryDate(); + + if (Cookies.getCookie(COOKIE_NAME) == null) { + Cookies.setCookie(COOKIE_NAME, "0", expiryDate); + } + else { + String lastIconsState = Cookies.getCookie(COOKIE_NAME); + if (lastIconsState.compareTo("1") == 0) + isIconView = false; + else + isIconView = true; + } + loadVREs(); + } +} diff --git a/src/main/java/org/gcube/portlet/user/my_vres/client/widgets/BulletList.java b/src/main/java/org/gcube/portlet/user/my_vres/client/widgets/BulletList.java new file mode 100644 index 0000000..8126c59 --- /dev/null +++ b/src/main/java/org/gcube/portlet/user/my_vres/client/widgets/BulletList.java @@ -0,0 +1,25 @@ +package org.gcube.portlet.user.my_vres.client.widgets; + +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.ui.ComplexPanel; +import com.google.gwt.user.client.ui.Widget; +/** + * + * @author Massimiliano Assante, ISTI-CNR + * @version 0.1 Dec 2012 + * + */ +public class BulletList extends ComplexPanel { + public BulletList() { + setElement(DOM.createElement("ul")); + } + + public void add(Widget w) { + super.add(w, getElement()); + } + + public void insert(Widget w, int beforeIndex) { + super.insert(w, getElement(), beforeIndex, true); + } +} + diff --git a/src/main/java/org/gcube/portlet/user/my_vres/client/widgets/ClickableVRE.java b/src/main/java/org/gcube/portlet/user/my_vres/client/widgets/ClickableVRE.java new file mode 100644 index 0000000..68869e2 --- /dev/null +++ b/src/main/java/org/gcube/portlet/user/my_vres/client/widgets/ClickableVRE.java @@ -0,0 +1,72 @@ +package org.gcube.portlet.user.my_vres.client.widgets; + +import org.gcube.portlet.user.my_vres.client.MyVREsServiceAsync; +import org.gcube.portlet.user.my_vres.shared.VRE; + +import com.google.gwt.core.client.GWT; +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.ui.HTML; +import com.google.gwt.user.client.ui.Image; + +/** + * + * @author Massimiliano Assante - ISTI CNR + * @version 1.0 Jun 2012 + * + */ +public class ClickableVRE extends HTML { + + private final static int WIDTH = 115; + private final static int HEIGHT = 120; + + private String name; + private String imageUrl; + private int imageWidth = 0; + + public static final String LOADING_IMAGE = GWT.getModuleBaseURL() + "../images/loading.gif"; + Image img = new Image(LOADING_IMAGE); + + public ClickableVRE() { + super(); + } + + public ClickableVRE(final VRE vre, final MyVREsServiceAsync service) { + super.setPixelSize(WIDTH, HEIGHT); + setPixelSize(WIDTH, HEIGHT); + imageWidth = WIDTH - 20; + name = vre.getName(); + imageUrl = vre.getImageURL(); + this.setTitle("Enter this VRE"); + int imageHeight = 95; + String html = "
" + name + "
"; + html += "
" + + "" + + "
"; + setHTML(html); + setStyleName("vreButton"); + + addClickHandler(new ClickHandler() { + public void onClick(ClickEvent event) { + showLoading(); + String scope = vre.getGroupName(); + service.loadLayout(scope, vre.getFriendlyURL(), new AsyncCallback() { + public void onFailure(Throwable arg0) { + Window.open( vre.getFriendlyURL(), "_self", ""); + } + public void onSuccess(Void arg0) { + Window.open( vre.getFriendlyURL(), "_self", ""); + } + }); + + } + }); + } + + public void showLoading() { + String html = "
"; + setHTML(html); + } +} diff --git a/src/main/java/org/gcube/portlet/user/my_vres/client/widgets/ListItem.java b/src/main/java/org/gcube/portlet/user/my_vres/client/widgets/ListItem.java new file mode 100644 index 0000000..7827b13 --- /dev/null +++ b/src/main/java/org/gcube/portlet/user/my_vres/client/widgets/ListItem.java @@ -0,0 +1,61 @@ +package org.gcube.portlet.user.my_vres.client.widgets; + +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.dom.client.KeyDownEvent; +import com.google.gwt.event.dom.client.KeyDownHandler; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.ui.ComplexPanel; +import com.google.gwt.user.client.ui.Widget; + +/** + * + * @author Massimiliano Assante, ISTI-CNR + * @version 0.1 Sep 2012 + * + */ +public class ListItem extends ComplexPanel { + HandlerRegistration clickHandler; + + public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) { + return addDomHandler(handler, KeyDownEvent.getType()); + } + + public HandlerRegistration addClickHandler(ClickHandler handler) { + return addDomHandler(handler, ClickEvent.getType()); + } + public String getHTML() { + return DOM.getInnerHTML(getElement()); + } + + public void setHTML(String html) { + DOM.setInnerHTML(getElement(), (html == null) ? "" : html); + } + + public ListItem() { + setElement(DOM.createElement("li")); + } + + public void setId(String id) { + DOM.setElementAttribute(getElement(), "id", id); + } + + public void add(Widget w) { + super.add(w, getElement()); + } + + public void insert(Widget w, int beforeIndex) { + super.insert(w, getElement(), beforeIndex, true); + } + + public String getText() { + return DOM.getInnerText(getElement()); + } + + public void setText(String text) { + DOM.setInnerText(getElement(), (text == null) ? "" : text); + } + + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlet/user/my_vres/server/MyVREsServiceImpl.java b/src/main/java/org/gcube/portlet/user/my_vres/server/MyVREsServiceImpl.java new file mode 100644 index 0000000..450ae0a --- /dev/null +++ b/src/main/java/org/gcube/portlet/user/my_vres/server/MyVREsServiceImpl.java @@ -0,0 +1,353 @@ +package org.gcube.portlet.user.my_vres.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.GCUBELog; +import org.gcube.portal.custom.communitymanager.OrganizationsUtil; +import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; +import org.gcube.portlet.user.my_vres.client.MyVREsService; +import org.gcube.portlet.user.my_vres.shared.UserBelonging; +import org.gcube.portlet.user.my_vres.shared.VO; +import org.gcube.portlet.user.my_vres.shared.VRE; + +import com.google.gwt.user.server.rpc.RemoteServiceServlet; +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.Organization; +import com.liferay.portal.model.User; +import com.liferay.portal.service.OrganizationLocalServiceUtil; +import com.liferay.portal.theme.ThemeDisplay; + +/** + * The server side implementation of the RPC service. + * @author Massimiliano Assante - ISTI CNR + * @version 1.0 Jun 2012 + */ +@SuppressWarnings("serial") +public class MyVREsServiceImpl extends RemoteServiceServlet implements MyVREsService { + + private static GCUBELog _log = new GCUBELog(MyVREsServiceImpl.class); + /** + * + */ + public static final String CACHED_VOS = "CACHED_VRES"; + /** + * + */ + public static final String ROOT_ORG = "rootorganization"; + + private VO rootVO = new VO(); + + private boolean withinPortal = false; + + /** + * the current ASLSession + * @return the session + */ + private ASLSession getASLSession() { + String sessionID = this.getThreadLocalRequest().getSession().getId(); + String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE); + if (user == null) { + _log.warn("USER IS NULL setting test.user"); + user = "test.user"; + } + else { + _log.info("LIFERAY PORTAL DETECTED user=" + user); + withinPortal = true; + } + return SessionManager.getInstance().getASLSession(sessionID, user); + } + + /** + * first method called by the UI + */ + public ArrayList getInfrastructureVOs() { + getASLSession(); + //_log.trace("getInfrastructureVOs method called"); + if (!withinPortal) + return getFakeVOs(); + //return new ArrayList(); + else + try { + String username = getASLSession().getUsername(); + User currUser = OrganizationsUtil.validateUser(username); + + List organizations = OrganizationLocalServiceUtil.getOrganizations(0, OrganizationLocalServiceUtil.getOrganizationsCount()); + + ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY); + + Organization rootOrganization = null; + for (Organization organization : organizations) { + if (organization.getName().equals( getRootOrganizationName() ) ) { + rootOrganization = organization; + break; + } + } + try { + //_log.info("root: " + rootOrganization.getName() ); + } + catch (NullPointerException e) { + _log.error("Cannot find root organziation, please check gcube-data.properties file in $CATALINA_HOME/conf folder, unless your installing the Bundle"); + return new ArrayList(); + } + // Create the list of the Infrastructure VOs + List infrastructureVOs = new ArrayList(); + + //create and check the root VO + rootVO = new VO(); + rootVO.setName(rootOrganization.getName()); + rootVO.setGroupName("/"+rootOrganization.getName()); + rootVO.setRoot(true); + + Group orgGroup = rootOrganization.getGroup(); + String friendlyURL = orgGroup.getPathFriendlyURL(true, themeDisplay) + orgGroup.getFriendlyURL(); + + rootVO.setFriendlyURL(getPortalBasicUrl()+friendlyURL); + long logoId = rootOrganization.getLogoId(); + String logoURL = themeDisplay.getPathImage()+"/organization_logo?img_id="+ logoId +"&t" + ImageServletTokenUtil.getToken(logoId); + rootVO.setImageURL(logoURL); + + + if (rootOrganization.getComments() != null) + rootVO.setDescription(rootOrganization.getComments()); + + + //for each root sub organizations (VO) + for (Organization vOrg : rootOrganization.getSuborganizations()) { + + //_log.debug("SKIP GCUBE APPS " + vOrg.getName() ); + + //_log.debug("FOUND VO: " + vOrg.getName() ); + //create the VO + VO voToAdd = new VO(); + voToAdd.setName(vOrg.getName()); + voToAdd.setGroupName("/"+vOrg.getParentOrganization().getName()+"/"+vOrg.getName()); + voToAdd.setRoot(false); + + for (Organization vre : vOrg.getSuborganizations()) { + VRE vreToAdd = new VRE(); + vreToAdd.setName(vre.getName()); + vreToAdd.setGroupName("/"+vOrg.getParentOrganization().getName()+"/"+vOrg.getName()+"/"+vre.getName()); + + logoId = vre.getLogoId(); + logoURL = themeDisplay.getPathImage()+"/organization_logo?img_id="+ logoId +"&t" + ImageServletTokenUtil.getToken(logoId); + vreToAdd.setImageURL(logoURL); + + String vreUrl = vre.getGroup().getPathFriendlyURL(true, themeDisplay) + vre.getGroup().getFriendlyURL(); + vreToAdd.setFriendlyURL(getPortalBasicUrl()+vreUrl); + + //set the description for the vre + if (vre.getComments() != null) { + vreToAdd.setDescription(vre.getComments()); + } + + //check if the user belongs to it + if (currUser.getOrganizations().contains(vre)) { + vreToAdd.setUserBelonging(UserBelonging.BELONGING); + voToAdd.addVRE(vreToAdd); + } + } + + + + Group group = vOrg.getGroup(); + String url = group.getPathFriendlyURL(true, themeDisplay) + group.getFriendlyURL(); + voToAdd.setFriendlyURL(getPortalBasicUrl() + url); + + //set the description for the vre + if (vOrg.getComments() != null) voToAdd.setDescription(vOrg.getComments()); + //check if the user belongs to it + if (currUser.getOrganizations().contains(vOrg)) { + voToAdd.setUserBelonging(UserBelonging.BELONGING); + } + else + voToAdd.setUserBelonging(UserBelonging.NOT_BELONGING); + infrastructureVOs.add(voToAdd); + } + + + ArrayList toReturn = new ArrayList(); + + + for (VO vo : infrastructureVOs) { + for (VRE vre : vo.getVres()) { + //_log.debug("VRE FOUND.... " + vre.getName()); + } + toReturn.add(vo); + } + //sort the VOs + Collections.sort(toReturn, Collections.reverseOrder()); + + //set the root vo as FIRST + toReturn.add(0, rootVO); + + ArrayList toStoreInSession = toReturn; + //_log.debug("SETTING INFRASTRUCTURE VOS in ASLSession"); + getASLSession().setAttribute(CACHED_VOS, toStoreInSession); + + return toReturn; + + } + catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + + /** + * + * @param scope + */ + public void loadLayout(String scope, String URL) { + _log.trace("Calling Load Layout..."); + HttpSession session = this.getThreadLocalRequest().getSession(); + ASLSession mysession = getASLSession(); + mysession.setAttribute("loadlayout", "true"); + session.setAttribute("loadLayout", "true"); + session.setAttribute("selectedVRE", scope); + mysession.logUserLogin(scope); + mysession.setScope(scope); + + _log.trace("User login logged to: " + scope); + } + + /** + * read the root VO name from a property file and retuns it + */ + protected static String getRootOrganizationName() { + //get the portles to look for from the property file + Properties props = new Properties(); + String toReturn = "gcube"; + + try { + String propertyfile = OrganizationsUtil.getTomcatFolder()+"conf/gcube-data.properties"; + File propsFile = new File(propertyfile); + FileInputStream fis = new FileInputStream(propsFile); + props.load( fis); + toReturn = props.getProperty(ROOT_ORG); + } + //catch exception in case properties file does not exist + catch(IOException e) { + toReturn = "gcube"; + _log.error("gcube-data.properties file not found under $CATALINA_HOME/conf dir, returning default VO Name " + toReturn); + return toReturn; + } + _log.debug("Returning Root VO Name: " + 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() ; + // _log.trace("getPortalBasicUrl: " +toReturn + "queryString: " + request.getQueryString()); + return toReturn; + } + + + /** + * simply returns fake VOS for debugging purpose + * @return + */ + protected static ArrayList getFakeVOs() { + VO rootVO = new VO(); + rootVO.setRoot(true); + rootVO.setName("/d4science.research-infrastructures.eu/"); + rootVO.setDescription("This is the description for the ROOT VO"); + rootVO.setImageURL("http://portal.d4science.research-infrastructures.eu/vologin/html/RedGrid.jpg"); + rootVO.setUserBelonging(UserBelonging.BELONGING); + + + /***************************************/ + + VO emVO = new VO(); + emVO.setRoot(false); + emVO.setGroupName("/d4science.research-infrastructures.eu/EM/"); + emVO.setName("EM VO"); + emVO.setDescription("EM and AEM 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."); + emVO.setImageURL("http://portal.d4science.research-infrastructures.eu/vologin/html/RedGrid.jpg"); + + emVO.setUserBelonging(UserBelonging.NOT_BELONGING); + // + // + VRE cool_EM_VRE = new VRE(); + cool_EM_VRE.setName("COOL EM VRE"); + cool_EM_VRE.setGroupName("/d4science.research-infrastructures.eu/EM/COOLEMVRE"); + cool_EM_VRE.setDescription("cool_EM_VRE VRE Description
"+ + "This Virtual Research Environment is for cool authors, managers and researchers who produce reports containing cool data."); + cool_EM_VRE.setImageURL("http://portal.d4science.research-infrastructures.eu/vologin/html/gcm-preview.jpg"); + cool_EM_VRE.setUserBelonging(UserBelonging.BELONGING); + emVO.addVRE(cool_EM_VRE); + + VRE cool_EM_VRE2 = new VRE(); + cool_EM_VRE2.setName("COOL VRE 2"); + cool_EM_VRE2.setGroupName("/d4science.research-infrastructures.eu/EM/COOLEMVRE2"); + cool_EM_VRE2.setDescription("Cool VRE Description
"+ + "This Virtual Research Environment is for cool authors, managers and researchers who produce reports containing cool data."); + + cool_EM_VRE2.setImageURL("https://newportal.i-marine.d4science.org/image/organization_logo?img_id=13302&t1339191699773"); + cool_EM_VRE2.setUserBelonging(UserBelonging.NOT_BELONGING); + + VRE cool_EM_VRE3 = new VRE(); + cool_EM_VRE3.setName("COOL EM VRE TRE"); + cool_EM_VRE3.setGroupName("/d4science.research-infrastructures.eu/EM/COOlVRE3"); + cool_EM_VRE3.setDescription("Cool VRE Description
"+ + "This Virtual Research Environment is for cool authors, managers and researchers who produce reports containing cool data."); + + cool_EM_VRE3.setImageURL("https://newportal.i-marine.d4science.org/image/organization_logo?img_id=13302&t1339191699773"); + cool_EM_VRE3.setUserBelonging(UserBelonging.BELONGING); + + VRE demo = new VRE(); + demo.setName("Demo"); + demo.setGroupName("/d4science.research-infrastructures.eu/EM/Demo"); + demo.setDescription("Cool VRE Description
"+ + "This Virtual Research Environment is for cool authors, managers and researchers who produce reports containing cool data."); + + demo.setImageURL("http://portal.d4science.research-infrastructures.eu/vologin/html/RedGrid.jpg"); + demo.setUserBelonging(UserBelonging.BELONGING); + + VRE vreGCM = new VRE(); + vreGCM.setName("GCM"); + vreGCM.setGroupName("/d4science.research-infrastructures.eu/EM/GCM"); + vreGCM.setDescription("Global Ocean Chlorophyll Monitoring (GCM) Virtual Research Environment
" + + "The phytoplankton plays a similar role to terrestrial green plants in the photosynthetic process and are credited with removing as much carbon dioxide from the atmosphere as their earthbound counterparts, making it important to monitor and model plankton into calculations of future climate change."); + vreGCM.setImageURL("https://newportal.i-marine.d4science.org/image/organization_logo?img_id=13302&t1339191699773"); + vreGCM.setUserBelonging(UserBelonging.BELONGING); + + + emVO.addVRE(cool_EM_VRE); + emVO.addVRE(cool_EM_VRE2); + emVO.addVRE(cool_EM_VRE3); + emVO.addVRE(demo); + emVO.addVRE(vreGCM); + + ArrayList toReturn = new ArrayList(); + toReturn.add(rootVO); + toReturn.add(emVO); + toReturn.add(emVO); + return toReturn; + } +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlet/user/my_vres/server/portlet/MyVREsPortlet.java b/src/main/java/org/gcube/portlet/user/my_vres/server/portlet/MyVREsPortlet.java new file mode 100644 index 0000000..29ba942 --- /dev/null +++ b/src/main/java/org/gcube/portlet/user/my_vres/server/portlet/MyVREsPortlet.java @@ -0,0 +1,85 @@ +package org.gcube.portlet.user.my_vres.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.PortletSession; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; + +import com.liferay.portal.kernel.exception.PortalException; +import com.liferay.portal.kernel.exception.SystemException; +import com.liferay.portal.kernel.log.Log; +import com.liferay.portal.kernel.log.LogFactoryUtil; +import com.liferay.portal.kernel.util.WebKeys; +import com.liferay.portal.model.User; +import com.liferay.portal.service.UserLocalServiceUtil; +import com.liferay.portal.theme.ThemeDisplay; + +/** + * MyVREsPortlet Portlet Class + * @author Massimiliano Assante - ISTI CNR + * @version 1.0 Jun 2012 + */ +public class MyVREsPortlet extends GenericPortlet { + + private static Log _log = LogFactoryUtil.getLog(MyVREsPortlet.class); + + protected String viewJSP; + public void init() throws PortletException { + viewJSP = "/WEB-INF/jsp/MyVREs_view.jsp"; + } + + public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { + long userid = Long.parseLong(renderRequest.getRemoteUser()); + + ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); + renderRequest.getPortletSession().setAttribute(WebKeys.THEME_DISPLAY, themeDisplay, PortletSession.APPLICATION_SCOPE); + + + User user = null; + try { + user = UserLocalServiceUtil.getUser(userid); + + } catch (SystemException e) { + e.printStackTrace(); + } catch (PortalException e) { + e.printStackTrace(); + } + + + //get the username + String username = user.getScreenName(); + + //Set the username to the portlet session, so that it can be accessed through the servlet + renderRequest.getPortletSession().setAttribute("username", username, PortletSession.APPLICATION_SCOPE); + renderRequest.getPortletSession().setAttribute("user", username, PortletSession.APPLICATION_SCOPE); + + include(viewJSP, renderRequest, renderResponse); + } + + protected void include(String path, RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { + PortletRequestDispatcher portletRequestDispatcher = getPortletContext().getRequestDispatcher(path); + + if (portletRequestDispatcher == null) { + _log.error(path + " is not a valid include"); + } + else { + portletRequestDispatcher.include(renderRequest, renderResponse); + } + } + /** + * + */ + public void processAction(ActionRequest request, ActionResponse response) + throws PortletException, IOException { + } + +} diff --git a/src/main/java/org/gcube/portlet/user/my_vres/shared/ResearchEnvironment.java b/src/main/java/org/gcube/portlet/user/my_vres/shared/ResearchEnvironment.java new file mode 100644 index 0000000..b25ed4f --- /dev/null +++ b/src/main/java/org/gcube/portlet/user/my_vres/shared/ResearchEnvironment.java @@ -0,0 +1,87 @@ +package org.gcube.portlet.user.my_vres.shared; + +import java.io.Serializable; +/** + * + * @author Massimiliano Assante ISTI-CNR + * + * @version 2.0 Jan 10th 2012 + */ +@SuppressWarnings("serial") +public class ResearchEnvironment implements Serializable{ + private String name; + + private String description; + + private String imageURL; + + private String groupName; + + private String friendlyURL; + + private UserBelonging userBelonging; + + public ResearchEnvironment() { + super(); + } + + public ResearchEnvironment(String name, String description, + String imageURL, String groupName, String friendlyURL, + UserBelonging userBelonging) { + super(); + this.name = name; + this.description = description; + this.imageURL = imageURL; + this.groupName = groupName; + 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 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; + } + + public UserBelonging getUserBelonging() { + return userBelonging; + } + + public void setUserBelonging(UserBelonging userBelonging) { + this.userBelonging = userBelonging; + } +} diff --git a/src/main/java/org/gcube/portlet/user/my_vres/shared/UserBelonging.java b/src/main/java/org/gcube/portlet/user/my_vres/shared/UserBelonging.java new file mode 100644 index 0000000..8d73a69 --- /dev/null +++ b/src/main/java/org/gcube/portlet/user/my_vres/shared/UserBelonging.java @@ -0,0 +1,5 @@ +package org.gcube.portlet.user.my_vres.shared; + +public enum UserBelonging { BELONGING, NOT_BELONGING, PENDING + +} diff --git a/src/main/java/org/gcube/portlet/user/my_vres/shared/VO.java b/src/main/java/org/gcube/portlet/user/my_vres/shared/VO.java new file mode 100644 index 0000000..439c6f3 --- /dev/null +++ b/src/main/java/org/gcube/portlet/user/my_vres/shared/VO.java @@ -0,0 +1,70 @@ +package org.gcube.portlet.user.my_vres.shared; + +import java.io.Serializable; +import java.util.ArrayList; +/** + * + * @author Massimiliano Assante ISTI-CNR + * + * @version 2.0 Jan 10th 2012 + */ +@SuppressWarnings("serial") +public class VO extends ResearchEnvironment implements Comparable, Serializable{ + + private boolean isRoot; + + private ArrayList vres = new ArrayList(); + /** + * + */ + public VO() { + super(); + } + /** + * + * @param voName . + * @param description . + * @param imageURL . + * @param vomsGroupName . + * @param friendlyURL . + * @param userBelonging . + * @param isRoot . + * @param vres . + */ + public VO(String voName, String description, String imageURL, + String vomsGroupName, String friendlyURL, + UserBelonging userBelonging, boolean isRoot, ArrayList vres) { + super(voName, description, imageURL, vomsGroupName, friendlyURL, userBelonging); + this.isRoot = isRoot; + this.vres = vres; + } + + public boolean isRoot() { + return isRoot; + } + public void setRoot(boolean isRoot) { + this.isRoot = isRoot; + } + public ArrayList getVres() { + return vres; + } + public void setVres(ArrayList vres) { + this.vres = vres; + } + /** + * + * @param toAdd + */ + public void addVRE(VRE toAdd) { + if (vres == null) + vres = new ArrayList(); + vres.add(toAdd); + } + /** + * compare the number of vres + */ + public int compareTo(VO voToCompare) { + return (this.vres.size() >= voToCompare.getVres().size()) ? 1 : -1; + } + +} diff --git a/src/main/java/org/gcube/portlet/user/my_vres/shared/VRE.java b/src/main/java/org/gcube/portlet/user/my_vres/shared/VRE.java new file mode 100644 index 0000000..db3f028 --- /dev/null +++ b/src/main/java/org/gcube/portlet/user/my_vres/shared/VRE.java @@ -0,0 +1,30 @@ +package org.gcube.portlet.user.my_vres.shared; + +import java.io.Serializable; + +@SuppressWarnings("serial") +public class VRE extends ResearchEnvironment implements Serializable { + + /** + * + */ + public VRE() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * + * @param vreName + * @param description + * @param imageURL + * @param vomsGroupName + * @param friendlyURL + * @param userBelonging + */ + public VRE(String vreName, String description, String imageURL, + String vomsGroupName, String friendlyURL, + UserBelonging userBelonging) { + super(vreName, description, imageURL, vomsGroupName, friendlyURL, userBelonging); + } +} diff --git a/src/main/resources/org/gcube/portlet/user/my_vres/MyVREs.gwt.xml b/src/main/resources/org/gcube/portlet/user/my_vres/MyVREs.gwt.xml new file mode 100644 index 0000000..d1839e7 --- /dev/null +++ b/src/main/resources/org/gcube/portlet/user/my_vres/MyVREs.gwt.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/MyVREs.css b/src/main/webapp/MyVREs.css new file mode 100644 index 0000000..1bb21b7 --- /dev/null +++ b/src/main/webapp/MyVREs.css @@ -0,0 +1,157 @@ +@import url(http://fonts.googleapis.com/css?family=Architects+Daughter); + +div.vreButton { + float: left; +} + +a.vrelink,a.vrelink:active,a.vrelink:visited { + cursor: pointer; + cursor: hand; + text-decoration: none; + color: #15C; +} + +a.vrelink:hover { + opacity: 0.8; + text-decoration: underline; +} + +.gwt-Button { + margin: 0px; + padding: 0px; +} + +.mainPanel { + margin-bottom: 15px; + margin-left: 10px; +} + +.flowPanel { + margin-left: 5px; +} + +.important { + font-weight: bold; +} + +.NoVresStyle { + line-height: 25px; + font-family: 'Architects Daughter', Arial, Verdana, sans-serif; + font-size: 15px; + padding-left: 0px; +} + +.listPanel { + margin-right: 10px; + margin-top: 5px; + padding: 5px; +} + +.switcher { + color: #999; + font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; + font-size: 8px; + font-variant:small-caps; + font-weight: bold; +} + +.switcher:hover { + opacity: 0.8; + cursor: pointer; + cursor: hand; +} + +.listPanel-title { + color: #999; + font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; + font-size: 12px; + font-variant:small-caps; + font-weight: bold; +} + +.list { + list-style-type: none; + margin-bottom: 10px; + margin-top: 5px; + margin-left: 0px; + padding-bottom: 0px; + padding-left: 5px; + padding-right: 0px; + padding-top: 0px; +} + +.list-item { + color: #444; + font-family: 'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial, + sans-serif; + font-size: 15px; + margin-top: 5px; + line-height: 14px; + padding-left: 20px; + background-color: transparent; + background-repeat: no-repeat; +} + +.item-vre { + background-image: url("images/vres.png"); +} + +.item-vo { + background-image: url("images/vos.png"); +} + +.list-item:hover { + cursor: pointer; + cursor: hand; + color: #336699; + text-decoration: none; + transition: color .25s ease-in-out; + -moz-transition: color .25s ease-in-out; + -webkit-transition: color .25s ease-in-out; +} + + +.vreButton { + background: transparent; + margin-right: 10px; + margin-top: 5px; + padding: 5px; + -moz-border-radius: 6px; + -webkit-border-radius: 6px; + border-radius: 6px; + background-color: #FFF; + border: 1px solid #DBDBDB; + cursor: pointer; + cursor: hand; +} + +.vreCaption { + font-family: Arial, Helvetica, sans-serif; + color: #39C; + display: block; + font-size: 9px; + font-weight: bold; + margin-bottom: 3px; + text-align: left; + padding-left: 1px; + border-bottom: 4px solid #39C; +} + +.vreButton[disabled]:hover,.vreButton[disabled]:active,.vreButton[disabled] + { + color: #CCC; + border-color: #BBB; + cursor: default; + opacity: 1.0; +} + +.vreButton:hover { + border-color: #39C; + color: #222; + opacity: 0.8; +} + +.vreButton:active { + background: #fff; + border: 1px solid #DBDBDB; +} \ No newline at end of file diff --git a/src/main/webapp/MyVREs.html b/src/main/webapp/MyVREs.html new file mode 100644 index 0000000..e58701b --- /dev/null +++ b/src/main/webapp/MyVREs.html @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + Web Application Starter Project + + + + + + + + + + + + + + + +
+ + diff --git a/src/main/webapp/WEB-INF/jsp/MyVREs_view.jsp b/src/main/webapp/WEB-INF/jsp/MyVREs_view.jsp new file mode 100644 index 0000000..b9b9891 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/MyVREs_view.jsp @@ -0,0 +1,16 @@ +<%@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"%> + + +--%> + + + +
+
+ + 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..ab597c9 --- /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..85637ed --- /dev/null +++ b/src/main/webapp/WEB-INF/liferay-plugin-package.properties @@ -0,0 +1,9 @@ +name=MyVREs +module-group-id=liferay +module-incremental-version=1 +tags= +short-description= +change-log= +page-url=http://www.d4science.org +author=D4Science Org. +licenses=EUPL \ 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..1ed850d --- /dev/null +++ b/src/main/webapp/WEB-INF/liferay-portlet.xml @@ -0,0 +1,17 @@ + + + + + + MyVREs + false + false + false + + /MyVREs.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..d606c6d --- /dev/null +++ b/src/main/webapp/WEB-INF/portlet.xml @@ -0,0 +1,21 @@ + + + + + MyVREs + gCube MyVREs Login Portlet + org.gcube.portlet.user.my_vres.server.portlet.MyVREsPortlet + 0 + + text/html + + + My Virtual Research Environments + gCube MyVREs Login + gCube MyVREs Login + + + 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..3a115eb --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,40 @@ + + + + greetServlet + org.gcube.portlet.user.my_vres.server.MyVREsServiceImpl + + + + greetServlet + /myvres/greet + + + jUnitHostImpl + com.google.gwt.junit.server.JUnitHostImpl + + + + jUnitHostImpl + /myvres/junithost/* + + + + greetServlet + /org.gcube.portlet.user.my_vres.MyVREsJUnit/myvres/greet + + + + jUnitHostImpl + /org.gcube.portlet.user.my_vres.MyVREsJUnit/junithost/* + + + + + MyVREs.html + + + 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/loading.gif b/src/main/webapp/images/loading.gif new file mode 100644 index 0000000..f4a8d80 Binary files /dev/null and b/src/main/webapp/images/loading.gif differ diff --git a/src/main/webapp/images/portlet_bg.png b/src/main/webapp/images/portlet_bg.png new file mode 100644 index 0000000..c3a3266 Binary files /dev/null and b/src/main/webapp/images/portlet_bg.png differ diff --git a/src/main/webapp/images/sampleImage.jpeg b/src/main/webapp/images/sampleImage.jpeg new file mode 100644 index 0000000..93db3cc Binary files /dev/null and b/src/main/webapp/images/sampleImage.jpeg differ diff --git a/src/main/webapp/images/vos.png b/src/main/webapp/images/vos.png new file mode 100644 index 0000000..ceb28a4 Binary files /dev/null and b/src/main/webapp/images/vos.png differ diff --git a/src/main/webapp/images/vres.png b/src/main/webapp/images/vres.png new file mode 100644 index 0000000..7d1303a Binary files /dev/null and b/src/main/webapp/images/vres.png differ diff --git a/src/test/java/org/gcube/portlet/user/my_vres/client/GwtTestMyVREs.java b/src/test/java/org/gcube/portlet/user/my_vres/client/GwtTestMyVREs.java new file mode 100644 index 0000000..8472337 --- /dev/null +++ b/src/test/java/org/gcube/portlet/user/my_vres/client/GwtTestMyVREs.java @@ -0,0 +1,74 @@ +package org.gcube.portlet.user.my_vres.client; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.junit.client.GWTTestCase; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.rpc.ServiceDefTarget; + +/** + * GWT JUnit integration tests must extend GWTTestCase. + * Using "GwtTest*" naming pattern exclude them from running with + * surefire during the test phase. + * + * If you run the tests using the Maven command line, you will have to + * navigate with your browser to a specific url given by Maven. + * See http://mojo.codehaus.org/gwt-maven-plugin/user-guide/testing.html + * for details. + */ +public class GwtTestMyVREs extends GWTTestCase { + + /** + * Must refer to a valid module that sources this class. + */ + public String getModuleName() { + return "org.gcube.portlet.user.my_vres.MyVREsJUnit"; + } + + /** + * Tests the FieldVerifier. + */ + public void testFieldVerifier() { +// assertFalse(FieldVerifier.isValidName(null)); +// assertFalse(FieldVerifier.isValidName("")); +// assertFalse(FieldVerifier.isValidName("a")); +// assertFalse(FieldVerifier.isValidName("ab")); +// assertFalse(FieldVerifier.isValidName("abc")); +// assertTrue(FieldVerifier.isValidName("abcd")); + } + + /** + * This test will send a request to the server using the greetServer method in + * MyVREsService and verify the response. + */ + public void testGreetingService() { + // Create the service that we will test. + MyVREsServiceAsync greetingService = GWT.create(MyVREsService.class); + ServiceDefTarget target = (ServiceDefTarget) greetingService; + target.setServiceEntryPoint(GWT.getModuleBaseURL() + "MyVREs/greet"); + + // Since RPC calls are asynchronous, we will need to wait for a response + // after this test method returns. This line tells the test runner to wait + // up to 10 seconds before timing out. + delayTestFinish(10000); + + // Send a request to the server. +// greetingService.greetServer("GWT User", new AsyncCallback() { +// public void onFailure(Throwable caught) { +// // The request resulted in an unexpected error. +// fail("Request failure: " + caught.getMessage()); +// } +// +// public void onSuccess(String result) { +// // Verify that the response is correct. +// assertTrue(result.startsWith("Hello, GWT User!")); +// +// // Now that we have received a response, we need to tell the test runner +// // that the test is complete. You must call finishTest() after an +// // asynchronous test finishes successfully, or the test will time out. +// finishTest(); +// } +// }); + } + + +} diff --git a/src/test/resources/org/gcube/portlet/user/my_vres/MyVREsJUnit.gwt.xml b/src/test/resources/org/gcube/portlet/user/my_vres/MyVREsJUnit.gwt.xml new file mode 100644 index 0000000..ea58e19 --- /dev/null +++ b/src/test/resources/org/gcube/portlet/user/my_vres/MyVREsJUnit.gwt.xml @@ -0,0 +1,9 @@ + + + + + + + + +