Ready for integration testing with JoinVRE
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/join-vre@113462 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c40e2994be
commit
65f7f5924b
|
@ -1,6 +1,8 @@
|
||||||
package org.gcube.portlets.user.joinvre.client.panels;
|
package org.gcube.portlets.user.joinvre.client.panels;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.gcube.portlets.user.joinvre.client.JoinService;
|
import org.gcube.portlets.user.joinvre.client.JoinService;
|
||||||
import org.gcube.portlets.user.joinvre.client.JoinServiceAsync;
|
import org.gcube.portlets.user.joinvre.client.JoinServiceAsync;
|
||||||
|
|
|
@ -17,20 +17,16 @@ import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||||
import org.gcube.portlets.user.joinvre.client.JoinService;
|
import org.gcube.portlets.user.joinvre.client.JoinService;
|
||||||
import org.gcube.portlets.user.joinvre.shared.UserBelonging;
|
import org.gcube.portlets.user.joinvre.shared.UserBelonging;
|
||||||
import org.gcube.portlets.user.joinvre.shared.VRE;
|
import org.gcube.portlets.user.joinvre.shared.VRE;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||||
import com.liferay.portal.kernel.exception.PortalException;
|
import com.liferay.portal.kernel.exception.PortalException;
|
||||||
import com.liferay.portal.kernel.exception.SystemException;
|
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.servlet.ImageServletTokenUtil;
|
import com.liferay.portal.kernel.servlet.ImageServletTokenUtil;
|
||||||
import com.liferay.portal.kernel.util.WebKeys;
|
import com.liferay.portal.kernel.util.WebKeys;
|
||||||
import com.liferay.portal.model.Group;
|
import com.liferay.portal.model.Group;
|
||||||
import com.liferay.portal.model.Organization;
|
import com.liferay.portal.model.Organization;
|
||||||
import com.liferay.portal.model.User;
|
|
||||||
import com.liferay.portal.security.permission.PermissionChecker;
|
|
||||||
import com.liferay.portal.security.permission.PermissionCheckerFactoryUtil;
|
|
||||||
import com.liferay.portal.security.permission.PermissionThreadLocal;
|
|
||||||
import com.liferay.portal.service.OrganizationLocalServiceUtil;
|
import com.liferay.portal.service.OrganizationLocalServiceUtil;
|
||||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||||
import com.liferay.portal.theme.ThemeDisplay;
|
import com.liferay.portal.theme.ThemeDisplay;
|
||||||
|
@ -42,7 +38,7 @@ import com.liferay.portal.theme.ThemeDisplay;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class JoinServiceImpl extends RemoteServiceServlet implements JoinService {
|
public class JoinServiceImpl extends RemoteServiceServlet implements JoinService {
|
||||||
|
|
||||||
private static final Logger _log = LoggerFactory.getLogger(JoinServiceImpl.class);
|
private static Log _log = LogFactoryUtil.getLog(JoinServiceImpl.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the current ASLSession
|
* the current ASLSession
|
||||||
|
@ -93,7 +89,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isWithinPortal()) {
|
if (isWithinPortal()) {
|
||||||
getPortalOrganizationMappedToVRE();
|
vres = getPortalOrganizationMappedToVRE();
|
||||||
} else {
|
} else {
|
||||||
List<String> devsecCategories = new ArrayList<String>();
|
List<String> devsecCategories = new ArrayList<String>();
|
||||||
devsecCategories.add("Development");
|
devsecCategories.add("Development");
|
||||||
|
@ -107,10 +103,9 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
vres.add(new VRE(3, "devsec", "devsec VRE description", "", "", "/group/devsec", devsecCategories, UserBelonging.NOT_BELONGING, false));
|
vres.add(new VRE(3, "devsec", "devsec VRE description", "", "", "/group/devsec", devsecCategories, UserBelonging.NOT_BELONGING, false));
|
||||||
vres.add(new VRE(4, "devsec", "devsec VRE description", "", "", "/group/devsec", devsecCategories, UserBelonging.NOT_BELONGING, false));
|
vres.add(new VRE(4, "devsec", "devsec VRE description", "", "", "/group/devsec", devsecCategories, UserBelonging.NOT_BELONGING, false));
|
||||||
vres.add(new VRE(5, "devsec", "devsec VRE description", "", "", "/group/devsec", devsecCategories, UserBelonging.NOT_BELONGING, false));
|
vres.add(new VRE(5, "devsec", "devsec VRE description", "", "", "/group/devsec", devsecCategories, UserBelonging.NOT_BELONGING, false));
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
_log.error("Error in server get all contacts ", e);
|
_log.error("Error getting VREs", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ordering VREs by Name
|
// Ordering VREs by Name
|
||||||
|
@ -121,9 +116,9 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
private String getPortalBasicUrl() {
|
private String getPortalBasicUrl() {
|
||||||
HttpServletRequest request = this.getThreadLocalRequest();
|
HttpServletRequest request = this.getThreadLocalRequest();
|
||||||
String protocol = (request.isSecure()) ? "https://" : "http://" ;
|
String protocol = (request.isSecure()) ? "https://" : "http://" ;
|
||||||
String port = (request.getServerPort() == 80) ? "" : String.format(":%i", request.getServerPort());
|
String port = (request.getServerPort() == 80) ? "" : String.format(":%d", request.getServerPort());
|
||||||
String portalBasicUrl = String.format("%s%s%s", protocol, request.getServerName(), port);
|
String portalBasicUrl = String.format("%s%s%s", protocol, request.getServerName(), port);
|
||||||
_log.trace("getPortalBasicUrl : {}", portalBasicUrl);
|
_log.debug(String.format("getPortalBasicUrl : %s", portalBasicUrl));
|
||||||
return portalBasicUrl;
|
return portalBasicUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,6 +169,10 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
}
|
}
|
||||||
|
|
||||||
ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
|
ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
|
||||||
|
String imagePath = "/image";
|
||||||
|
if(themeDisplay!=null){
|
||||||
|
imagePath = themeDisplay.getPathImage();
|
||||||
|
} /*If themeDisplay is null the user is not logged in. Needs to find a way to get it */
|
||||||
|
|
||||||
//for each root sub organizations (VO)
|
//for each root sub organizations (VO)
|
||||||
for (Organization vOrg : rootOrganization.getSuborganizations()) {
|
for (Organization vOrg : rootOrganization.getSuborganizations()) {
|
||||||
|
@ -183,7 +182,8 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
String vreDescription = (vreOrganization.getComments()!=null) ? vreOrganization.getComments() : "";
|
String vreDescription = (vreOrganization.getComments()!=null) ? vreOrganization.getComments() : "";
|
||||||
|
|
||||||
long logoId = vreOrganization.getLogoId();
|
long logoId = vreOrganization.getLogoId();
|
||||||
String vreLogoURL = String.format("%s/organization_logo?img_id=%s&t=%s", themeDisplay.getPathImage(), logoId, ImageServletTokenUtil.getToken(logoId));
|
String vreLogoURL = String.format("%s/organization_logo?img_id=%s&t=%s", imagePath, logoId, ImageServletTokenUtil.getToken(logoId));
|
||||||
|
|
||||||
|
|
||||||
String groupName = String.format("/%s/%s/%s", vOrg.getParentOrganization().getName(), vOrg.getName(), vreName);
|
String groupName = String.format("/%s/%s/%s", vOrg.getParentOrganization().getName(), vOrg.getName(), vreName);
|
||||||
Group vreGroup = vreOrganization.getGroup();
|
Group vreGroup = vreOrganization.getGroup();
|
||||||
|
@ -193,7 +193,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
boolean requireAccessGrant = requireAccessGrant(vreOrganization);
|
boolean requireAccessGrant = requireAccessGrant(vreOrganization);
|
||||||
|
|
||||||
List<String> categories = new ArrayList<String>();
|
List<String> categories = new ArrayList<String>();
|
||||||
_log.debug("VRE preferences : {}", vreOrganization.getPreferences());
|
_log.debug(String.format("VRE preferences : %s", vreOrganization.getPreferences()));
|
||||||
|
|
||||||
vres.add(new VRE(vreID,vreName, vreDescription, vreLogoURL, groupName,friendlyURL, categories, UserBelonging.NOT_BELONGING, requireAccessGrant));
|
vres.add(new VRE(vreID,vreName, vreDescription, vreLogoURL, groupName,friendlyURL, categories, UserBelonging.NOT_BELONGING, requireAccessGrant));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,46 @@
|
||||||
|
|
||||||
package org.gcube.portlets.user.joinvre.server.portlet;
|
package org.gcube.portlets.user.joinvre.server.portlet;
|
||||||
|
|
||||||
import javax.portlet.GenericPortlet;
|
|
||||||
import javax.portlet.ActionRequest;
|
|
||||||
import javax.portlet.RenderRequest;
|
|
||||||
import javax.portlet.ActionResponse;
|
|
||||||
import javax.portlet.RenderResponse;
|
|
||||||
import javax.portlet.PortletException;
|
|
||||||
import java.io.IOException;
|
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.PortletRequestDispatcher;
|
||||||
|
import javax.portlet.PortletSession;
|
||||||
|
import javax.portlet.RenderRequest;
|
||||||
|
import javax.portlet.RenderResponse;
|
||||||
|
|
||||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||||
|
|
||||||
|
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.theme.ThemeDisplay;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
|
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
|
||||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||||
*/
|
*/
|
||||||
public class JoinVREPortlet extends GenericPortlet {
|
public class JoinVREPortlet extends GenericPortlet {
|
||||||
|
|
||||||
|
private static Log _log = LogFactoryUtil.getLog(JoinVREPortlet.class);
|
||||||
|
|
||||||
|
public void doView(RenderRequest request, RenderResponse response)
|
||||||
|
throws PortletException, IOException {
|
||||||
|
_log.info("************************* Rendering JoinVRE Portlet");
|
||||||
|
|
||||||
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
|
|
||||||
System.out.println("************************* JoinVRE Portlet");
|
|
||||||
response.setContentType("text/html");
|
response.setContentType("text/html");
|
||||||
ScopeHelper.setContext(request);
|
try {
|
||||||
PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/JoinVRE_view.jsp");
|
ScopeHelper.setContext(request);
|
||||||
dispatcher.include(request, response);
|
} catch(Exception e){
|
||||||
|
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
|
||||||
|
request.getPortletSession().setAttribute(WebKeys.THEME_DISPLAY, themeDisplay, PortletSession.APPLICATION_SCOPE);
|
||||||
|
_log.error("The following exception is acceptable if the user is not logged.", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/JoinVRE_view.jsp");
|
||||||
|
dispatcher.include(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processAction(ActionRequest request, ActionResponse response)
|
public void processAction(ActionRequest request, ActionResponse response)
|
||||||
|
|
|
@ -70,8 +70,7 @@ public class VRE extends ResearchEnvironment implements Serializable, Comparable
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "VRE [getName()=" + getName()
|
return "VRE {" + getName() + ", "+ getFriendlyURL() + ", uponRequest=" + uponRequest+"}";
|
||||||
+ ", uponRequest=" + uponRequest+"]";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,8 +5,6 @@ log4j.appender.A1.layout=org.apache.log4j.PatternLayout
|
||||||
# Print the date in ISO 8601 format
|
# Print the date in ISO 8601 format
|
||||||
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
|
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
|
||||||
|
|
||||||
# Print only messages of level TRACE or above in the package org.gcube
|
# Print only messages of level ALL or above in the package org.gcube
|
||||||
log4j.logger.org.gcube=TRACE
|
log4j.logger.org.gcube=ALL
|
||||||
log4j.logger.org.gcube.application.framework.core.session=INFO
|
|
||||||
log4j.logger.org.gcube.common.scope.impl.DefaultScopeProvider=ERROR
|
|
||||||
log4j.logger.com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor=ERROR
|
|
||||||
|
|
Loading…
Reference in New Issue