diff --git a/.classpath b/.classpath index 6b52563..cd156eb 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -34,10 +34,10 @@ - + - + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index b257af7..6e80039 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,8 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.8 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.7 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 2ff775f..39a2d62 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,6 +4,12 @@ + + uses + + + uses + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index c57a49e..15eea05 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -2,7 +2,7 @@ - + diff --git a/pom.xml b/pom.xml index 7123284..89f8155 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.gcube.portlets.user join-vre war - 3.3.0-SNAPSHOT + 3.4.0-SNAPSHOT gCube Join VRE Portlet Display the available VRE to Join @@ -23,9 +23,9 @@ - 2.7.0 + 2.8.1 distro - 1.7 + 1.8 1.8 ${project.build.directory}/${project.build.finalName} 6.2.5 @@ -62,10 +62,9 @@ [1.0.0-SNAPSHOT,) - com.google.gwt - gwt-dev - ${gwtVersion} - provided + org.gcube.portal + terms-of-use-library + [1.0.0-SNAPSHOT,) com.google @@ -93,7 +92,7 @@ org.gcube.core common-scope-maps - provided + runtime org.gcube.dvos diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinService.java b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinService.java index ff1e0fa..4291c32 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinService.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinService.java @@ -29,5 +29,7 @@ public interface JoinService extends RemoteService { String isExistingInvite(long siteId); - UserInfo readInvite(String inviteId); + String getTermsOfUse(long siteId); + + UserInfo readInvite(String inviteId, long siteId); } diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinServiceAsync.java b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinServiceAsync.java index 40690bb..4a2618e 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinServiceAsync.java @@ -28,5 +28,7 @@ public interface JoinServiceAsync { void isExistingInvite(long siteId, AsyncCallback callback); - void readInvite(String inviteId, AsyncCallback callback); + void readInvite(String inviteId, long siteId, AsyncCallback callback); + + void getTermsOfUse(long siteId, AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/AccessVREDialog.java b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/AccessVREDialog.java index aeff180..15f69e0 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/AccessVREDialog.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/AccessVREDialog.java @@ -9,13 +9,16 @@ import com.github.gwtbootstrap.client.ui.HelpBlock; import com.github.gwtbootstrap.client.ui.Icon; import com.github.gwtbootstrap.client.ui.Modal; import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Element; import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; 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.Window.Location; import com.google.gwt.user.client.rpc.AsyncCallback; 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 AccessVREDialog extends Composite { @@ -30,25 +33,59 @@ public class AccessVREDialog extends Composite { @UiField Button close; @UiField Button confirmRequest; @UiField HelpBlock helpBlock; + @UiField HelpBlock touGatewayBlock; @UiField Icon loading; - + @UiField HTML touText; + VRE myVRE = null; public AccessVREDialog(final VRE vre) { initWidget(uiBinder.createAndBindUi(this)); this.myVRE = vre; - - String text = "You are about to enter the " + vre.getName() + ", please confirm your request."; - helpBlock.setText(text); - String buttonText = "Confirm Request"; - confirmRequest.setText(buttonText); } public void show() { - String headerText = "Join VRE request for " + myVRE.getName(); - m.setTitle(headerText); - m.show(); + joinService.getTermsOfUse(this.myVRE.getId(), new AsyncCallback() { + @Override + public void onFailure(Throwable caught) { + m.setTitle("Ops, an error occurred please check your connection and try again"); + confirmRequest.setText("Try again"); + confirmRequest.addClickHandler(new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + Location.reload(); + } + }); + m.show(); + } + @Override + public void onSuccess(String result) { + if (result == null) { //no terms of use + String headerText = "Join VRE request for " + myVRE.getName(); + String text = "You are about to enter " + myVRE.getName() + ", please confirm your request."; + m.setTitle(headerText); + helpBlock.setHTML(text); + touGatewayBlock.setVisible(true); + String buttonText = "Confirm Request"; + confirmRequest.setText(buttonText); + } + else {// terms of use exist + String headerText = "Terms of Use for " + myVRE.getName(); + String text = "By using " + myVRE.getName() + " VRE services, you are agreeing to these terms. Please read them carefully:"; + m.setTitle(headerText); + helpBlock.setHTML(text); + String buttonText = "Accept Terms of Use"; + confirmRequest.setText(buttonText); + m.addStyleName("modal-custom"); + ((Element)m.getElement().getChildNodes().getItem(1)).addClassName("modal-body-custom"); + touText.setHTML(result); + } + + m.show(); + } + }); + } - + @UiHandler("close") void handleClick(ClickEvent e) { m.hide(); @@ -59,12 +96,12 @@ public class AccessVREDialog extends Composite { loading.setVisible(true); confirmRequest.setEnabled(false); joinService.registerUser(myVRE.getinfraScope(), myVRE.getId(), IS_INVITATION, new AsyncCallback() { - + @Override public void onSuccess(Boolean result) { Location.assign(myVRE.getFriendlyURL()); } - + @Override public void onFailure(Throwable caught) { confirmRequest.removeFromParent(); diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/AccessVREDialog.ui.xml b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/AccessVREDialog.ui.xml index 7517cb7..3bf81c5 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/AccessVREDialog.ui.xml +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/AccessVREDialog.ui.xml @@ -8,15 +8,15 @@ - + By entering this VRE you agree to the terms indicated in the Terms of Use of this gateway. - + Confirm Request - Close + Cancel diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/AccessViaInviteDialog.java b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/AccessViaInviteDialog.java index a280576..820af63 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/AccessViaInviteDialog.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/AccessViaInviteDialog.java @@ -12,6 +12,7 @@ import com.github.gwtbootstrap.client.ui.Image; import com.github.gwtbootstrap.client.ui.Modal; import com.github.gwtbootstrap.client.ui.constants.ButtonType; import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Element; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; @@ -19,6 +20,7 @@ import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Window.Location; import com.google.gwt.user.client.rpc.AsyncCallback; 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 AccessViaInviteDialog extends Composite { @@ -27,11 +29,13 @@ public class AccessViaInviteDialog extends Composite { private static AccessViaInviteDialogUiBinder uiBinder = GWT.create(AccessViaInviteDialogUiBinder.class); interface AccessViaInviteDialogUiBinder extends - UiBinder { + UiBinder { } @UiField Modal m; @UiField Button close; @UiField Button confirmRequest; + @UiField HelpBlock touGatewayBlock; + @UiField HTML touText; @UiField HelpBlock helpBlock; @UiField Icon loading; @UiField Image avatarImage; @@ -44,18 +48,36 @@ public class AccessViaInviteDialog extends Composite { helpBlock.setText(text); String buttonText = "Accept invite"; confirmRequest.setText(buttonText); - - joinService.readInvite(inviteId, new AsyncCallback() { + + joinService.readInvite(inviteId, vre.getId(), new AsyncCallback() { @Override public void onSuccess(UserInfo invitingUser) { - helpBlock.setText("You have been invited by " +invitingUser.getFullName() + ", to accept the invite, please click on the accept invite button below."); - avatarImage.setUrl(invitingUser.getAvatarId()); - avatarImage.setVisible(true); - confirmRequest.setType(ButtonType.PRIMARY); - confirmRequest.setEnabled(true); loading.removeFromParent(); + if (invitingUser.getAccountURL() == null) { //no terms of use + helpBlock.setText("You have been invited by " +invitingUser.getFullName() + ", to accept the invite, please click on the accept invite button below."); + avatarImage.setUrl(invitingUser.getAvatarId()); + avatarImage.setVisible(true); + touGatewayBlock.setVisible(true); + confirmRequest.setType(ButtonType.PRIMARY); + confirmRequest.setEnabled(true); + } else { + helpBlock.setText("You have been invited by " +invitingUser.getFullName() + ", to accept the invite, please click on the accept invite button below."); + avatarImage.setUrl(invitingUser.getAvatarId()); + avatarImage.setVisible(true); + String headerText = "Terms of Use for " + myVRE.getName(); + String text = "By using " + myVRE.getName() + " VRE services, you are agreeing to these terms. Please read them carefully:"; + m.setTitle(headerText); + touGatewayBlock.setHTML(text); + String buttonText = "Accept Terms of Use"; + confirmRequest.setText(buttonText); + confirmRequest.setType(ButtonType.PRIMARY); + confirmRequest.setEnabled(true); + m.addStyleName("modal-custom"); + ((Element)m.getElement().getChildNodes().getItem(1)).addClassName("modal-body-custom"); + touText.setHTML(invitingUser.getAccountURL()); + } } - + @Override public void onFailure(Throwable caught) { loading.removeFromParent(); @@ -79,12 +101,12 @@ public class AccessViaInviteDialog extends Composite { loading.setVisible(true); confirmRequest.setEnabled(false); joinService.registerUser(myVRE.getinfraScope(), myVRE.getId(), IS_INVITATION, new AsyncCallback() { - + @Override public void onSuccess(Boolean result) { Location.assign(myVRE.getFriendlyURL()); } - + @Override public void onFailure(Throwable caught) { confirmRequest.removeFromParent(); diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/AccessViaInviteDialog.ui.xml b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/AccessViaInviteDialog.ui.xml index 3b0b697..1ebc8df 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/AccessViaInviteDialog.ui.xml +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/AccessViaInviteDialog.ui.xml @@ -1,19 +1,33 @@ + + .circleImage { + border-radius: 100px; + -webkit-border-radius: 100px; + -moz-border-radius: 100px; + } + .alignCenter { + width: 100%; + text-align: center; + } + - - -
 
+ + + + By entering this VRE you agree to the terms indicated in the Terms of Use of this gateway. + 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 9037a9e..2f3aec4 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 @@ -15,6 +15,10 @@ import org.gcube.portal.databook.server.DatabookStore; import org.gcube.portal.databook.shared.Invite; import org.gcube.portal.databook.shared.InviteStatus; import org.gcube.portal.databook.shared.UserInfo; +import org.gcube.portal.tou.TermsOfUse; +import org.gcube.portal.tou.TermsOfUseImpl; +import org.gcube.portal.tou.exceptions.ToUNotFoundException; +import org.gcube.portal.tou.model.ToU; import org.gcube.portlets.user.joinvre.client.JoinService; import org.gcube.portlets.user.joinvre.shared.UserBelonging; import org.gcube.portlets.user.joinvre.shared.VRE; @@ -40,6 +44,7 @@ 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.Group; import com.liferay.portal.model.VirtualHost; import com.liferay.portal.service.GroupLocalServiceUtil; @@ -49,7 +54,7 @@ import com.liferay.portal.service.VirtualHostLocalServiceUtil; import com.liferay.portal.util.PortalUtil; /** - * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it + * @author Massimiliano Assante, CNR_ISTI */ @SuppressWarnings("serial") public class JoinServiceImpl extends RemoteServiceServlet implements JoinService { @@ -78,6 +83,47 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService } return ""; } + + @Override + public UserInfo readInvite(final String inviteId, final long siteId) { + initStore(); + try { + Invite invite = store.readInvite(inviteId); + GCubeUser inviter = new LiferayUserManager().getUserByUsername(invite.getSenderUserId()); + return new UserInfo( + inviter.getUsername(), + inviter.getFullname(), + inviter.getUserAvatarURL(), + "", + getTermsOfUse(siteId), // we use accountURL for the terms of use in this case + true, false, null); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + /** + * check if a terms of use exists for the given Site (VRE), returns null is non existent + * @return a String containing the ToU to accept or null if no ToU exists + */ + @Override + public String getTermsOfUse(long siteId) { + + TermsOfUse tou = new TermsOfUseImpl(); + try { + long groupId = new LiferayGroupManager().getGroup(siteId).getGroupId(); + ToU terms = tou.getToUGroup(groupId); + return terms.getContent(); + } + catch (ToUNotFoundException ex) { + _log.debug("Terms of Use not found for this VRE id " + siteId); + return null; + } + catch (Exception e) { + _log.error("An error occurred while trying to fetch the ToU for VRE id " + siteId); + return null; + } + } /** * * @param session the Asl Session @@ -244,8 +290,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService @Override public VRE getSelectedVRE(Long groupId) { - _log.debug("*getting Selected Research Environment from referral, site id = " + groupId); - + _log.debug("*getting Selected Research Environment from referral, site id = " + groupId); VRE toReturn = null; try { GroupManager gm = new LiferayGroupManager(); @@ -373,6 +418,8 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService LoginServiceUtil.notifyUserSelfRegistration(currUser.getUsername(), scope, getThreadLocalRequest()); _log.info("notifyUserSelfRegistration sent"); } + new TermsOfUseImpl().hasAcceptedToU(currUser.getUsername(), groupId); + _log.info("hasAcceptedToU OK for " + currUser.getUsername()); } catch (Exception e) { e.printStackTrace(); @@ -410,23 +457,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService _log.debug("checking if invite exists for " + email + " on " +infraScope); return store.isExistingInvite(infraScope, email); } - - @Override - public UserInfo readInvite(String inviteId) { - initStore(); - try { - Invite invite = store.readInvite(inviteId); - GCubeUser inviter = new LiferayUserManager().getUserByUsername(invite.getSenderUserId()); - return new UserInfo( - inviter.getUsername(), - inviter.getFullname(), - inviter.getUserAvatarURL(), - "", "", true, false, null); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } + /** @@ -454,4 +485,5 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService } return null; } + } diff --git a/src/main/resources/org/gcube/portlets/user/joinvre/JoinVRE.gwt.xml b/src/main/resources/org/gcube/portlets/user/joinvre/JoinVRE.gwt.xml index 973f3dd..101151f 100644 --- a/src/main/resources/org/gcube/portlets/user/joinvre/JoinVRE.gwt.xml +++ b/src/main/resources/org/gcube/portlets/user/joinvre/JoinVRE.gwt.xml @@ -1,18 +1,17 @@ - + - + - diff --git a/src/main/webapp/JoinVRE.css b/src/main/webapp/JoinVRE.css deleted file mode 100644 index 804f150..0000000 --- a/src/main/webapp/JoinVRE.css +++ /dev/null @@ -1,5 +0,0 @@ -@media only screen and (min-width: 800px) { - .aui .row-fluid .span3 { - width: 19% !important; - } -} \ No newline at end of file diff --git a/src/main/webapp/JoinVRE.html b/src/main/webapp/JoinVRE.html index 09d9ab0..b8f9253 100644 --- a/src/main/webapp/JoinVRE.html +++ b/src/main/webapp/JoinVRE.html @@ -9,14 +9,12 @@ - - - - - Join VRE Project - + + + + diff --git a/src/main/webapp/WEB-INF/jsp/JoinVRE_view.jsp b/src/main/webapp/WEB-INF/jsp/JoinVRE_view.jsp index 18be2e2..5c1fbf2 100644 --- a/src/main/webapp/WEB-INF/jsp/JoinVRE_view.jsp +++ b/src/main/webapp/WEB-INF/jsp/JoinVRE_view.jsp @@ -7,8 +7,8 @@ --%> - - + + - +
diff --git a/src/main/webapp/WEB-INF/liferay-plugin-package.properties b/src/main/webapp/WEB-INF/liferay-plugin-package.properties index f7ae7bc..39e6246 100644 --- a/src/main/webapp/WEB-INF/liferay-plugin-package.properties +++ b/src/main/webapp/WEB-INF/liferay-plugin-package.properties @@ -1,6 +1,6 @@ name=joinvre module-group-id=liferay -module-incremental-version=2 +module-incremental-version=3 tags= short-description= change-log= diff --git a/src/main/webapp/WEB-INF/liferay-portlet.xml b/src/main/webapp/WEB-INF/liferay-portlet.xml index bae710f..8c2a0f9 100644 --- a/src/main/webapp/WEB-INF/liferay-portlet.xml +++ b/src/main/webapp/WEB-INF/liferay-portlet.xml @@ -13,6 +13,7 @@ false false - /JoinVRE.css + /explore.css + join-vre-wrapper diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 39fa442..4c9269c 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -13,7 +13,7 @@ JoinVRE - /JoinVRE/JoinService + /explore/JoinService diff --git a/src/main/webapp/explore.css b/src/main/webapp/explore.css new file mode 100644 index 0000000..85c5175 --- /dev/null +++ b/src/main/webapp/explore.css @@ -0,0 +1,55 @@ +body { + border: 5px solid white; +} + +@media only screen and (min-width: 800px) { + .aui .row-fluid .span3 { + width: 19% !important; + } +} + +@media screen and (min-width: 1024px) { + .modal-custom { + width: 75% !important; + margin-left: -38% !important; + } + .modal-body-custom { + height: 500px !important; + } + .modal-header-custom>.close { + font-size: 40px; + } +} + +@media screen and (min-width: 800px) and (max-width: 1024px) { + .modal-custom { + width: 85% !important; + margin-left: -42% !important; + } + .modal-body-custom { + height: 450px !important; + } +} + +@media screen and (min-width: 600px) and (max-width: 800px) { + .modal-body-custom { + height: 350px !important; + } +} + +@media screen and (min-width: 300px) and (max-width: 600px) { + .modal-body-custom { + height: 300px !important; + } +} + +.modal-custom { + min-width: 300px !important; + top: 3% !important; +} + +.modal-body-custom { + max-height: 50% !important; +} + +