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:
Luca Frosini 2015-03-05 14:10:23 +00:00
parent c40e2994be
commit 65f7f5924b
5 changed files with 51 additions and 35 deletions

View File

@ -1,6 +1,8 @@
package org.gcube.portlets.user.joinvre.client.panels;
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.JoinServiceAsync;

View File

@ -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.shared.UserBelonging;
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.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.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.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.UserLocalServiceUtil;
import com.liferay.portal.theme.ThemeDisplay;
@ -42,7 +38,7 @@ import com.liferay.portal.theme.ThemeDisplay;
@SuppressWarnings("serial")
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
@ -93,7 +89,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
try {
if (isWithinPortal()) {
getPortalOrganizationMappedToVRE();
vres = getPortalOrganizationMappedToVRE();
} else {
List<String> devsecCategories = new ArrayList<String>();
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(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));
}
} catch (Exception e) {
_log.error("Error in server get all contacts ", e);
_log.error("Error getting VREs", e);
}
// Ordering VREs by Name
@ -121,9 +116,9 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
private String getPortalBasicUrl() {
HttpServletRequest request = this.getThreadLocalRequest();
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);
_log.trace("getPortalBasicUrl : {}", portalBasicUrl);
_log.debug(String.format("getPortalBasicUrl : %s", portalBasicUrl));
return portalBasicUrl;
}
@ -174,6 +169,10 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
}
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 (Organization vOrg : rootOrganization.getSuborganizations()) {
@ -183,7 +182,8 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
String vreDescription = (vreOrganization.getComments()!=null) ? vreOrganization.getComments() : "";
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);
Group vreGroup = vreOrganization.getGroup();
@ -193,7 +193,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
boolean requireAccessGrant = requireAccessGrant(vreOrganization);
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));
}

View File

@ -1,29 +1,46 @@
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 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 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 Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*/
public class JoinVREPortlet extends GenericPortlet {
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
System.out.println("************************* JoinVRE Portlet");
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");
response.setContentType("text/html");
ScopeHelper.setContext(request);
PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/JoinVRE_view.jsp");
dispatcher.include(request, response);
try {
ScopeHelper.setContext(request);
} 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)

View File

@ -70,8 +70,7 @@ public class VRE extends ResearchEnvironment implements Serializable, Comparable
@Override
public String toString() {
return "VRE [getName()=" + getName()
+ ", uponRequest=" + uponRequest+"]";
return "VRE {" + getName() + ", "+ getFriendlyURL() + ", uponRequest=" + uponRequest+"}";
}
@Override

View File

@ -5,8 +5,6 @@ log4j.appender.A1.layout=org.apache.log4j.PatternLayout
# Print the date in ISO 8601 format
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
# Print only messages of level TRACE or above in the package org.gcube
log4j.logger.org.gcube=TRACE
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
# Print only messages of level ALL or above in the package org.gcube
log4j.logger.org.gcube=ALL