Refining portlet design

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/join-vre@113443 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2015-03-04 14:51:15 +00:00
parent 584979bc23
commit 72243756d8
2 changed files with 58 additions and 4 deletions

View File

@ -8,6 +8,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
@ -19,10 +21,15 @@ 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.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.service.OrganizationLocalServiceUtil;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.theme.ThemeDisplay;
/**
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
@ -82,7 +89,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
try {
if (isWithinPortal()) {
getPortalOrganizationMappedToVRE();
} else {
List<String> devsecCategories = new ArrayList<String>();
devsecCategories.add("Development");
@ -107,7 +114,30 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
return vres;
}
public ArrayList<VRE> getPortalOrganizationMappedToVRE() throws SystemException{
private String getPortalBasicUrl() {
HttpServletRequest request = this.getThreadLocalRequest();
String protocol = (request.isSecure()) ? "https://" : "http://" ;
String port = (request.getServerPort() == 80) ? "" : String.format(":%i", request.getServerPort());
String portalBasicUrl = String.format("%s%s%s", protocol, request.getServerName(), port);
_log.trace("getPortalBasicUrl : {}", portalBasicUrl);
return portalBasicUrl;
}
private static final String REQUEST_BASED_GROUP = "Requestbasedgroup";
public boolean requireAccessGrant(Organization organization){
if (organization.getExpandoBridge().getAttribute(REQUEST_BASED_GROUP) == null || organization.getExpandoBridge().getAttribute(REQUEST_BASED_GROUP).equals("")) {
_log.trace("Attribute {} not initialized. In this case by default Access Grant is permitted", REQUEST_BASED_GROUP);
return true;
} else {
String attributeValue = (String) organization.getExpandoBridge().getAttribute(REQUEST_BASED_GROUP);
return (attributeValue.compareTo("true") == 0);
}
}
public ArrayList<VRE> getPortalOrganizationMappedToVRE() throws SystemException, PortalException{
List<VRE> vres = new ArrayList<VRE>();
List<Organization> organizations = OrganizationLocalServiceUtil.getOrganizations(0, OrganizationLocalServiceUtil.getOrganizationsCount());
Organization rootOrganization = null;
@ -125,10 +155,28 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
return new ArrayList<VRE>();
}
ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
//for each root sub organizations (VO)
for (Organization vOrg : rootOrganization.getSuborganizations()) {
for (Organization vre : vOrg.getSuborganizations()) {
for (Organization vreOrganization : vOrg.getSuborganizations()) {
long vreID = vreOrganization.getOrganizationId();
String vreName = vreOrganization.getName();
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 groupName = String.format("/%s/%s/%s", vOrg.getParentOrganization().getName(), vOrg.getName(), vreName);
Group vreGroup = vreOrganization.getGroup();
String friendlyURL = vreGroup.getPathFriendlyURL(true, themeDisplay) + vreGroup.getFriendlyURL();
friendlyURL = String.format("%s%s", getPortalBasicUrl(), friendlyURL);
boolean requireAccessGrant = requireAccessGrant(vreOrganization);
List<String> categories = new ArrayList<String>();
vres.add(new VRE(vreID,vreName, vreDescription, vreLogoURL, groupName,friendlyURL, categories, UserBelonging.NOT_BELONGING, requireAccessGrant));
}
}

View File

@ -1,6 +1,5 @@
.framed {
width: 146px;
height: 240px;
padding: 10px;
margin: 5px 5px 0 0;
background: #FFF;
@ -10,6 +9,13 @@
border: 1px solid #9b9b9b;
}
.framed:hover {
box-shadow: 5px 5px 10px 2px #9b9b9b;
box-shadow: 5px 5px 10px 2px #9b9b9b;
-webkit-box-shadow: 5px 5px 10px 2px #9b9b9b;
-moz-box-shadow: 5px 5px 10px 2px #9b9b9b;
}
.vreImageDetails {
width: 150px;
}