From 51fb7e23c91e16ecd3930e5858aefdb90abb5063 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Mon, 3 Oct 2016 17:41:29 +0000 Subject: [PATCH] >Added support for invite-only closed groups git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/join-vre@132509 82a268e6-3cf1-43bd-a215-b396298e98cf --- .settings/org.eclipse.wst.common.component | 3 - distro/changelog.xml | 3 +- .../client/responsive/ResponsivePanel.java | 17 ++-- .../user/joinvre/client/ui/RedirectPanel.java | 51 ---------- .../user/joinvre/client/ui/VreThumbnail.java | 50 +++++----- .../user/joinvre/server/JoinServiceImpl.java | 96 ++++++++----------- .../portlets/user/joinvre/shared/VRE.java | 62 ++++-------- .../joinvre/shared/VRECustomAttributes.java | 86 ----------------- .../joinvre/shared/VreMembershipType.java | 7 ++ 9 files changed, 106 insertions(+), 269 deletions(-) delete mode 100644 src/main/java/org/gcube/portlets/user/joinvre/client/ui/RedirectPanel.java delete mode 100644 src/main/java/org/gcube/portlets/user/joinvre/shared/VRECustomAttributes.java create mode 100644 src/main/java/org/gcube/portlets/user/joinvre/shared/VreMembershipType.java diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 1b65ee8..2ff775f 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,9 +4,6 @@ - - uses - diff --git a/distro/changelog.xml b/distro/changelog.xml index 3d85df2..5496609 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,6 +1,7 @@ + date="2016-10-03"> + Added support for invite-only closed groups Fix for Bug #4877 Email Notification sent multiple times sometimes Logo VRE was not updated in the portlet due to liferay versioning of Document Library diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/responsive/ResponsivePanel.java b/src/main/java/org/gcube/portlets/user/joinvre/client/responsive/ResponsivePanel.java index 0dda9b4..860a683 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/responsive/ResponsivePanel.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/responsive/ResponsivePanel.java @@ -76,20 +76,25 @@ public class ResponsivePanel extends Composite { } public void requestMembership(VRE vre) { - if (vre.isUponRequest()) { + switch (vre.getMembershipType()) { + case RESTRICTED: RequestMembershipDialog modal = new RequestMembershipDialog(this, vre); modal.show(); - } else { - AccessVREDialog modal = new AccessVREDialog(vre); - modal.show(); + break; + case OPEN: + AccessVREDialog accessModal = new AccessVREDialog(vre); + accessModal.show(); + break; + default: + break; } } - + public void showInviteDialog(VRE vre, String inviteId) { AccessViaInviteDialog modal = new AccessViaInviteDialog(vre, inviteId); modal.show(); } - + public void setPending(VRE toSet) { for (VreThumbnail thumb : myThumbnails) { if (thumb.getMyVre().getinfraScope().compareTo(toSet.getinfraScope()) == 0) { diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/RedirectPanel.java b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/RedirectPanel.java deleted file mode 100644 index 0fdd490..0000000 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/RedirectPanel.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.gcube.portlets.user.joinvre.client.ui; - -import org.gcube.portlets.user.joinvre.shared.VRE; - -import com.github.gwtbootstrap.client.ui.Button; -import com.github.gwtbootstrap.client.ui.Modal; -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.uibinder.client.UiBinder; -import com.google.gwt.uibinder.client.UiField; -import com.google.gwt.uibinder.client.UiHandler; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.HTML; -import com.google.gwt.user.client.ui.Widget; - -public class RedirectPanel extends Composite { - private static InfoPanelUiBinder uiBinder = GWT.create(InfoPanelUiBinder.class); - - interface InfoPanelUiBinder extends UiBinder { - } - - @UiField Modal m; - @UiField HTML description; - @UiField Button close; - @UiField Button link; - private VRE vre; - - public RedirectPanel(VRE toDisplay) { - initWidget(uiBinder.createAndBindUi(this)); - vre = toDisplay; - } - - public void show() { - m.setTitle("Infrastructure Gateway notice for " + vre.getName()); - description.setHTML("Dear user,
" + vre.getName() + " is not hosted in this Gateway, "+ - "if you wish to enter or to request access, please click to the link below. We will redirect you to the D4Science Gateway hosting it."); - link.setHref(vre.getUrl()); - link.setTarget("_blank"); - link.setText("Take me to " + vre.getName()); - link.setBlock(true); - link.getElement().getStyle().setMarginTop(25, Unit.PX); - link.getElement().getStyle().setMarginBottom(15, Unit.PX); - m.show(); - } - - @UiHandler("close") - void handleClick(ClickEvent e) { - m.hide(); - } -} diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/VreThumbnail.java b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/VreThumbnail.java index f8e6d85..588aa69 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/VreThumbnail.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/VreThumbnail.java @@ -44,7 +44,8 @@ public class VreThumbnail extends Composite { if (name.length() > 22) name = name.substring(0, 17) + "..."; vreName.setText(name); - if (vre.isUponRequest()) { + switch (vre.getMembershipType()) { + case RESTRICTED: joinButton.setType(ButtonType.DEFAULT); joinButton.setText("Request Access"); if (vre.getUserBelonging() == UserBelonging.PENDING) { @@ -56,36 +57,37 @@ public class VreThumbnail extends Composite { joinButton.setType(ButtonType.SUCCESS); joinButton.setText("Access Granted"); } - } else { + break; + case OPEN: joinButton.setText("Enter this VRE"); - } + break; + default: + joinButton.setEnabled(false); + joinButton.setText("Private"); + break; + } vreImage.setUrl(vre.getImageURL()); } @UiHandler("joinButton") void handleClick(ClickEvent e) { if (myVre.getUserBelonging() != UserBelonging.PENDING) { - if (myVre.isExternal()) { - RedirectPanel modal = new RedirectPanel(myVre); - modal.show(); - } - else { - joinService.joinVRE(myVre.getId(), new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { - String errorDescription = "Error while trying to join to" - + myVre.getName() + " VRE. Please Try again later. " - + "If the problem persist please contact us at www.gcube-system.org"; - Window.alert(errorDescription); - } + joinService.joinVRE(myVre.getId(), new AsyncCallback() { + @Override + public void onFailure(Throwable caught) { + String errorDescription = "Error while trying to join to" + + myVre.getName() + " VRE. Please Try again later. " + + "If the problem persist please contact us at www.gcube-system.org"; + Window.alert(errorDescription); + } - @Override - public void onSuccess(String siteLandingPagePath) { - Location.assign(siteLandingPagePath +"/explore?"+JoinVRE.GET_OID_PARAMETER+"="+myVre.getId()); - } - }); - } + @Override + public void onSuccess(String siteLandingPagePath) { + Location.assign(siteLandingPagePath +"/explore?"+JoinVRE.GET_OID_PARAMETER+"="+myVre.getId()); + } + }); } + } @@ -94,13 +96,13 @@ public class VreThumbnail extends Composite { InfoPanel modal = new InfoPanel(myVre); modal.show(); } - + public void setPending() { joinButton.setText("Waiting approval"); joinButton.setType(ButtonType.WARNING); joinButton.setEnabled(false); } - + public VRE getMyVre() { return myVre; } diff --git a/src/main/java/org/gcube/portlets/user/joinvre/server/JoinServiceImpl.java b/src/main/java/org/gcube/portlets/user/joinvre/server/JoinServiceImpl.java index 2274553..a64a636 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/server/JoinServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/server/JoinServiceImpl.java @@ -22,7 +22,7 @@ import org.gcube.portlets.user.joinvre.client.JoinService; import org.gcube.portlets.user.joinvre.shared.UserBelonging; import org.gcube.portlets.user.joinvre.shared.VRE; import org.gcube.portlets.user.joinvre.shared.VRECategory; -import org.gcube.portlets.user.joinvre.shared.VRECustomAttributes; +import org.gcube.portlets.user.joinvre.shared.VreMembershipType; import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.UserManager; import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; @@ -35,6 +35,7 @@ import org.gcube.vomanagement.usermanagement.model.CustomAttributeKeys; import org.gcube.vomanagement.usermanagement.model.GCubeGroup; import org.gcube.vomanagement.usermanagement.model.GCubeMembershipRequest; import org.gcube.vomanagement.usermanagement.model.GCubeUser; +import org.gcube.vomanagement.usermanagement.model.GroupMembershipType; import org.gcube.vomanagement.usermanagement.model.MembershipRequestStatus; import org.gcube.vomanagement.usermanagement.model.VirtualGroup; @@ -44,7 +45,6 @@ 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.StringBundler; import com.liferay.portal.model.Group; import com.liferay.portal.model.VirtualHost; import com.liferay.portal.security.auth.PrincipalThreadLocal; @@ -56,7 +56,6 @@ import com.liferay.portal.service.LayoutSetLocalServiceUtil; import com.liferay.portal.service.UserLocalServiceUtil; import com.liferay.portal.service.VirtualHostLocalServiceUtil; import com.liferay.portal.util.PortalUtil; -import com.liferay.portal.webserver.WebServerServletTokenUtil; /** * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it @@ -88,7 +87,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService */ public String getDevelopmentUser() { String user = TEST_USER; - // user = "andrea.rossi"; +// user = "andrea.rossi"; return user; } @@ -136,30 +135,6 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService return toReturn; } - - - public VRECustomAttributes getVRECustomAttr(GCubeGroup group) throws PortalException, SystemException { - VRECustomAttributes toReturn = new VRECustomAttributes(); - - try { - GroupManager gm = new LiferayGroupManager(); - toReturn.setUponRequest(group.isRequestBasedGroup()); - _log.debug(group.getGroupName() + " getVRECustomAttr group.isRequestBasedGroup?" + group.isRequestBasedGroup()); - Boolean attributeValue = (Boolean) gm.readCustomAttr(group.getGroupId(), CustomAttributeKeys.IS_EXTERNAL.getKeyName()); - toReturn.setExternal(attributeValue); - if (attributeValue) { //we read the custom attr URL if and only if the VRE is External, in the other case is useless - String url = (String) gm.readCustomAttr(group.getGroupId(), CustomAttributeKeys.URL.getKeyName()); - toReturn.setUrlIfAny(url); - } - - } catch (Exception e) { - _log.error("Something went wrong when trying to read VRE Custom Attr, " + e); - return toReturn; - } - _log.trace("RETURNING VRECustomAttributes:\n" + toReturn.toString()); - return toReturn; - } - /** * * @return the Virtual groups with their VREs in the order estabilished in the LR Control Panel @@ -207,13 +182,6 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService String groupName = gm.getInfrastructureScope(vreOrganization.getGroupId()); String friendlyURL = GCubePortalConstants.PREFIX_GROUP_URL+vreOrganization.getFriendlyURL(); - - VRECustomAttributes attrs = getVRECustomAttr(vreOrganization); - - boolean requireAccessGrant = attrs.isUponRequest(); - boolean isExternal = attrs.isExternal(); - String urlIfAny = attrs.getUrlIfAny(); - String catName = gm.getVirtualGroup(vreID).getName(); VRECategory toLookFor = null; @@ -224,7 +192,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService if (toLookFor != null) { ArrayList toUpdate = toReturn.get(toLookFor); UserBelonging belongs = UserBelonging.NOT_BELONGING; - VRE toAdd = new VRE(vreID,vreName, vreDescription, vreLogoURL, groupName, friendlyURL, belongs, requireAccessGrant, isExternal, urlIfAny); + VRE toAdd = new VRE(vreID,vreName, vreDescription, vreLogoURL, groupName, friendlyURL, belongs, getVREMembershipType(vreOrganization.getMembershipType())); if (session.getUsername().compareTo(TEST_USER) != 0) { GCubeUser currUser = new LiferayUserManager().getUserByUsername(session.getUsername()); //check if the user belongs to it @@ -272,7 +240,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService + "
  • cluster occurrence data;" + "
  • estimate similarities among habitats." + "" - + "", "", "http://placehold.it/200x200", "/group/devsec", UserBelonging.NOT_BELONGING, false)); + + "", "", "http://placehold.it/200x200", "/group/devsec", UserBelonging.NOT_BELONGING)); vres.add(new VRE(0, "Scalable Data", "" + "

    Scalable Data Mining

    " + "The Scalable Data Mining is a VRE designed to apply Data Mining techniques to biological data. The algorithms are executed in a distributed fashion on the e-Infrastructure nodes or on local multi-core machines. Scalability is thus meant as distributed data processing but even as services dynamically provided to the users. The system is scalable in the number of users and in the size of the data to process. Statistical data processing can be applied to perform Niche Modelling or Ecological Modelling experiments. Other applications can use general purpose techniques like Bayesian models. Time series of observations can be managed as well, in order to classify trends, catch anomaly patterns and perform simulations. The idea under the distributed computation for data mining techniques is to overcome common limitations that can happen when using statistical algorithms: " @@ -286,25 +254,24 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService + "
  • cluster occurrence data;" + "
  • estimate similarities among habitats." + "" - + "", "", "http://placehold.it/200x200", "/group/devsec", UserBelonging.NOT_BELONGING, true)); + + "", "", "http://placehold.it/200x200", "/group/devsec", UserBelonging.NOT_BELONGING)); toReturn.put(devsecCategory, vres); devsecCategory = new VRECategory(2, "Sailing", "Sailing prod desc"); vres = new ArrayList(); - vres.add(new VRE(1, "PerformanceEvaluationInAquaculture", "devVRE VRE description", "http://placehold.it/200x100", "http://placehold.it/200x100", "/group/devVRE", UserBelonging.NOT_BELONGING, false, true, "http://i-marine.d4science.org")); - vres.add(new VRE(2, "devmode", "devmode VRE description", "http://placehold.it/200x100", "https://placeholdit.imgix.net/~text?txtsize=19&txt=200%C3%97100&w=200&h=100", "/group/devmode", UserBelonging.NOT_BELONGING, true)); - vres.add(new VRE(1, "StrategicInvestmentAnalysis", "devVRE VRE description", "", "https://placeholdit.imgix.net/~text?txtsize=19&txt=200%C3%97100&w=200&h=100", "/group/devVRE", UserBelonging.NOT_BELONGING, false)); - vres.add(new VRE(2, "devmode2", "devmode VRE description", "http://placehold.it/200x100", "", "/group/devmode", UserBelonging.NOT_BELONGING, true)); - vres.add(new VRE(1, "devVR3E", "devVRE VRE description", "http://placehold.it/200x200", "aaaa", "/group/devVRE", UserBelonging.NOT_BELONGING, false)); - vres.add(new VRE(2, "devmode3", "devmode VRE description", "http://placehold.it/200x200", "", "/group/devmode", UserBelonging.NOT_BELONGING, true)); - vres.add(new VRE(1, "devVRE4", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false)); - vres.add(new VRE(2, "devmode4", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true)); - vres.add(new VRE(1, "devVRE5", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false)); - vres.add(new VRE(2, "devmode5", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true)); - vres.add(new VRE(1, "devVRE6", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false)); - vres.add(new VRE(2, "devmode6", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true)); - vres.add(new VRE(1, "devVRE7", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false)); - vres.add(new VRE(2, "devmod76", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true)); + vres.add(new VRE(2, "devmode", "devmode VRE description", "http://placehold.it/200x100", "https://placeholdit.imgix.net/~text?txtsize=19&txt=200%C3%97100&w=200&h=100", "/group/devmode", UserBelonging.NOT_BELONGING, VreMembershipType.PRIVATE)); + vres.add(new VRE(1, "StrategicInvestmentAnalysis", "devVRE VRE description", "", "https://placeholdit.imgix.net/~text?txtsize=19&txt=200%C3%97100&w=200&h=100", "/group/devVRE", UserBelonging.NOT_BELONGING, VreMembershipType.OPEN)); + vres.add(new VRE(2, "devmode2", "devmode VRE description", "http://placehold.it/200x100", "", "/group/devmode", UserBelonging.NOT_BELONGING, VreMembershipType.OPEN)); + vres.add(new VRE(1, "devVR3E", "devVRE VRE description", "http://placehold.it/200x200", "aaaa", "/group/devVRE", UserBelonging.NOT_BELONGING, VreMembershipType.PRIVATE)); + vres.add(new VRE(2, "devmode3", "devmode VRE description", "http://placehold.it/200x200", "", "/group/devmode", UserBelonging.NOT_BELONGING, VreMembershipType.PRIVATE)); + vres.add(new VRE(1, "devVRE4", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, VreMembershipType.PRIVATE)); + vres.add(new VRE(2, "devmode4", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, VreMembershipType.PRIVATE)); + vres.add(new VRE(1, "devVRE5", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, VreMembershipType.PRIVATE)); + vres.add(new VRE(2, "devmode5", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, VreMembershipType.PRIVATE)); + vres.add(new VRE(1, "devVRE6", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, VreMembershipType.PRIVATE)); + vres.add(new VRE(2, "devmode6", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, VreMembershipType.PRIVATE)); + vres.add(new VRE(1, "devVRE7", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, VreMembershipType.PRIVATE)); + vres.add(new VRE(2, "devmod76", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING)); toReturn.put(devsecCategory, vres); return toReturn; } @@ -326,11 +293,10 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService String vreLogoURL = gm.getGroupLogoURL(logoId); String infraScope = gm.getInfrastructureScope(selectedVRE.getGroupId()); String friendlyURL = GCubePortalConstants.PREFIX_GROUP_URL+selectedVRE.getFriendlyURL(); - VRECustomAttributes attrs = getVRECustomAttr(selectedVRE); - boolean requireAccessGrant = attrs.isUponRequest(); - boolean isExternal = attrs.isExternal(); - String urlIfAny = attrs.getUrlIfAny(); + + + GCubeUser currUser = um.getUserByUsername(session.getUsername()); //check if the user belongs to it UserBelonging belongEnum = UserBelonging.NOT_BELONGING; @@ -339,12 +305,28 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService else if (checkPending(session.getUsername(), selectedVRE.getGroupId())) belongEnum = UserBelonging.PENDING; //return the selected VRE for this user - toReturn = new VRE(groupId, vreName, vreDescription, vreLogoURL, infraScope, friendlyURL, belongEnum, requireAccessGrant, isExternal, urlIfAny); + toReturn = new VRE(groupId, vreName, vreDescription, vreLogoURL, infraScope, friendlyURL, belongEnum, getVREMembershipType(selectedVRE.getMembershipType())); } catch (Exception e) { _log.error("Something wrong happened while trying to getSite by id, probably the group id is wrong. " + e.getMessage()); } return toReturn; } + + /** + * + * @param type + * @return the correspondent mapping to the gcube model + */ + private VreMembershipType getVREMembershipType(GroupMembershipType type) { + switch (type) { + case RESTRICTED: + return VreMembershipType.RESTRICTED; + case OPEN: + return VreMembershipType.OPEN; + default: + return VreMembershipType.PRIVATE; + } + } /** * * @param screenName diff --git a/src/main/java/org/gcube/portlets/user/joinvre/shared/VRE.java b/src/main/java/org/gcube/portlets/user/joinvre/shared/VRE.java index 100360e..116c53d 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/shared/VRE.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/shared/VRE.java @@ -9,51 +9,47 @@ import java.io.Serializable; @SuppressWarnings("serial") public class VRE extends ResearchEnvironment implements Serializable, Comparable { - protected boolean uponRequest; + protected VreMembershipType membershipType; protected long id; - protected boolean isExternal; - protected String url; + public VRE() { super(); } - + + public VRE(long id, String vreName, String description, String imageURL, + String infraScope, String friendlyURL, UserBelonging userBelonging) { + super(vreName, description, imageURL, infraScope, friendlyURL, userBelonging); + this.membershipType = VreMembershipType.RESTRICTED; + this.id = id; + } /** + * * @param id * @param vreName * @param description * @param imageURL - * @param groupName + * @param infraScope * @param friendlyURL - * @param categories * @param userBelonging - * @param uponRequest + * @param membershipType */ public VRE(long id, String vreName, String description, String imageURL, - String infraScope, String friendlyURL, UserBelonging userBelonging, boolean uponRequest) { + String infraScope, String friendlyURL, UserBelonging userBelonging, VreMembershipType membershipType) { super(vreName, description, imageURL, infraScope, friendlyURL, userBelonging); - this.uponRequest = uponRequest; + this.membershipType = membershipType; this.id = id; - isExternal = false; - url = ""; } - public VRE(long id, String vreName, String description, String imageURL, - String infraScope, String friendlyURL, UserBelonging userBelonging, boolean uponRequest, boolean isExternal, String url) { - super(vreName, description, imageURL, infraScope, friendlyURL, userBelonging); - this.uponRequest = uponRequest; - this.id = id; - this.isExternal = isExternal; - this.url = url; - } - public boolean isUponRequest() { - return uponRequest; + public VreMembershipType getMembershipType() { + return membershipType; } - public void setUponRequest(boolean uponRequest) { - this.uponRequest = uponRequest; + + public void setMembershipType(VreMembershipType membershipType) { + this.membershipType = membershipType; } - + public long getId() { return id; } @@ -61,26 +57,10 @@ public class VRE extends ResearchEnvironment implements Serializable, Comparable public void setId(long id) { this.id = id; } - - public boolean isExternal() { - return isExternal; - } - - public void setExternal(boolean isExternal) { - this.isExternal = isExternal; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } @Override public String toString() { - return "VRE {" + getName() + ", "+ getFriendlyURL() + ", uponRequest=" + uponRequest+"}"; + return "VRE [membershipType=" + membershipType + ", id=" + id + ", name=" + this.getName() + "]"; } @Override diff --git a/src/main/java/org/gcube/portlets/user/joinvre/shared/VRECustomAttributes.java b/src/main/java/org/gcube/portlets/user/joinvre/shared/VRECustomAttributes.java deleted file mode 100644 index 949fc73..0000000 --- a/src/main/java/org/gcube/portlets/user/joinvre/shared/VRECustomAttributes.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.gcube.portlets.user.joinvre.shared; - -public class VRECustomAttributes { - - private boolean isUponRequest; - private boolean isExternal; - private String urlIfAny; - - public VRECustomAttributes() { - super(); - this.isUponRequest = false; - this.isExternal = false; - this.urlIfAny = ""; - } - - public VRECustomAttributes(boolean isUponRequest, boolean isExternal, - String urlIfAny) { - super(); - this.isUponRequest = isUponRequest; - this.isExternal = isExternal; - this.urlIfAny = urlIfAny; - } - - public boolean isUponRequest() { - return isUponRequest; - } - - public void setUponRequest(boolean isUponRequest) { - this.isUponRequest = isUponRequest; - } - - public boolean isExternal() { - return isExternal; - } - - public void setExternal(boolean isExternal) { - this.isExternal = isExternal; - } - - public String getUrlIfAny() { - return urlIfAny; - } - - public void setUrlIfAny(String urlIfAny) { - this.urlIfAny = urlIfAny; - } - - @Override - public String toString() { - return "VRECustomAttributes [isUponRequest=" + isUponRequest - + ", isExternal=" + isExternal + ", urlIfAny=" + urlIfAny + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (isExternal ? 1231 : 1237); - result = prime * result + (isUponRequest ? 1231 : 1237); - result = prime * result - + ((urlIfAny == null) ? 0 : urlIfAny.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - VRECustomAttributes other = (VRECustomAttributes) obj; - if (isExternal != other.isExternal) - return false; - if (isUponRequest != other.isUponRequest) - return false; - if (urlIfAny == null) { - if (other.urlIfAny != null) - return false; - } else if (!urlIfAny.equals(other.urlIfAny)) - return false; - return true; - } - -} diff --git a/src/main/java/org/gcube/portlets/user/joinvre/shared/VreMembershipType.java b/src/main/java/org/gcube/portlets/user/joinvre/shared/VreMembershipType.java new file mode 100644 index 0000000..d38646e --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/joinvre/shared/VreMembershipType.java @@ -0,0 +1,7 @@ +package org.gcube.portlets.user.joinvre.shared; + +public enum VreMembershipType { + OPEN, + RESTRICTED, + PRIVATE; +}