config dinamica
This commit is contained in:
parent
8056e75d52
commit
f997057b83
|
@ -24,7 +24,7 @@ MVN_FINALNAME=$(mvn -q \
|
|||
exec:exec)
|
||||
|
||||
echo "MVN_FINALNAME=${MVN_FINALNAME}"
|
||||
mvn clean package -U
|
||||
mvn clean package
|
||||
|
||||
scp target/$MVN_FINALNAME.war life@$DEST_HOST:/home/life/Portal-Bundle/deploy/$MVN_NAME.war
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ public class CloudComputingConfig {
|
|||
|
||||
public String auth_url = "https://accounts.dev.d4science.org/auth";
|
||||
public String ccp_url = "https://ccp.cloud-dev.d4science.org";
|
||||
// public String cdn_url = "https://cdn.cloud.d4science.org"; //"https://cdn.cloud-dev.d4science.org";
|
||||
// public String cdn_url = "https://cdn.cloud.d4science.org";
|
||||
// //"https://cdn.cloud-dev.d4science.org";
|
||||
public String cdn_url = "https://cdn.cloud-dev.d4science.org";
|
||||
|
||||
}
|
||||
|
|
|
@ -1,25 +1,54 @@
|
|||
package org.gcube.portlets.user.cloudcomputing;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.portlet.PortletException;
|
||||
import javax.portlet.RenderRequest;
|
||||
import javax.portlet.RenderResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
import com.liferay.portal.kernel.exception.SystemException;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
import com.liferay.portal.model.Group;
|
||||
import com.liferay.portal.service.GroupLocalServiceUtil;
|
||||
import com.liferay.portal.util.PortalUtil;
|
||||
import com.liferay.util.bridges.mvc.MVCPortlet;
|
||||
|
||||
public class CloudComputingConfigPortlet extends MVCPortlet {
|
||||
private static com.liferay.portal.kernel.log.Log _log = LogFactoryUtil.getLog(CloudComputingConfigPortlet.class);
|
||||
|
||||
public CloudComputingConfig getConfig() {
|
||||
return new CloudComputingConfig();
|
||||
public CloudComputingConfig getConfig(RenderRequest renderRequest) throws MalformedURLException {
|
||||
|
||||
CloudComputingConfig config = new CloudComputingConfig();
|
||||
|
||||
String currentContext = getCurrentContext(renderRequest);
|
||||
String encodedContext = getEncodedContext(currentContext);
|
||||
config.encoded_context = encodedContext;
|
||||
|
||||
// config.redirect_url = redirect_url;
|
||||
HttpServletRequest httpReq = PortalUtil
|
||||
.getOriginalServletRequest(PortalUtil.getHttpServletRequest(renderRequest));
|
||||
String current_url = PortalUtil.getCurrentURL(renderRequest);
|
||||
// current_url = /group/devvre/cloudcomputing
|
||||
|
||||
String absolute_current_url = PortalUtil.getAbsoluteURL(httpReq, current_url);
|
||||
// absolute_current_url =
|
||||
// https://next.dev.d4science.org/group/devvre/cloudcomputing
|
||||
|
||||
config.redirect_url = absolute_current_url;
|
||||
|
||||
URL base_url = new URL(PortalUtil.getAbsoluteURL(httpReq, "/"));
|
||||
String host = base_url.getHost();
|
||||
config.gateway = host;
|
||||
return config;
|
||||
}
|
||||
|
||||
private String getCurrentContext(RenderRequest request) {
|
||||
protected String getCurrentContext(RenderRequest request) {
|
||||
long groupId = -1;
|
||||
try {
|
||||
groupId = PortalUtil.getScopeGroupId(request);
|
||||
|
@ -30,7 +59,7 @@ public class CloudComputingConfigPortlet extends MVCPortlet {
|
|||
return null;
|
||||
}
|
||||
|
||||
private String getCurrentContext(long groupId) {
|
||||
protected String getCurrentContext(long groupId) {
|
||||
try {
|
||||
PortalContext pContext = PortalContext.getConfiguration();
|
||||
return pContext.getCurrentScope("" + groupId);
|
||||
|
@ -40,6 +69,10 @@ public class CloudComputingConfigPortlet extends MVCPortlet {
|
|||
return null;
|
||||
}
|
||||
|
||||
protected String getEncodedContext(String context) {
|
||||
return context.replace("/", "%2F");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(RenderRequest renderRequest, RenderResponse renderResponse)
|
||||
throws PortletException, IOException {
|
||||
|
@ -52,7 +85,7 @@ public class CloudComputingConfigPortlet extends MVCPortlet {
|
|||
// String redirect_url = "https://sobigdata.d4science.org/group/sobigdatalab";
|
||||
// String url = "https://accounts.d4science.org/auth";
|
||||
|
||||
CloudComputingConfig config = getConfig();
|
||||
CloudComputingConfig config = getConfig(renderRequest);
|
||||
|
||||
renderRequest.setAttribute("encoded_context", config.encoded_context);
|
||||
renderRequest.setAttribute("gateway", config.gateway);
|
||||
|
@ -61,8 +94,50 @@ public class CloudComputingConfigPortlet extends MVCPortlet {
|
|||
renderRequest.setAttribute("ccp_url", config.ccp_url);
|
||||
renderRequest.setAttribute("cdn_url", config.cdn_url);
|
||||
|
||||
String current_url = PortalUtil.getCurrentURL(renderRequest);
|
||||
renderRequest.setAttribute("current_url", current_url);
|
||||
|
||||
String infrastructure = PortalContext.getConfiguration().getInfrastructureName();
|
||||
renderRequest.setAttribute("infrastructure", infrastructure);
|
||||
|
||||
HttpServletRequest httpReq = PortalUtil
|
||||
.getOriginalServletRequest(PortalUtil.getHttpServletRequest(renderRequest));
|
||||
String absolute_current_url = PortalUtil.getAbsoluteURL(httpReq, current_url);
|
||||
renderRequest.setAttribute("absolute_current_url", absolute_current_url);
|
||||
|
||||
String calculated_gateway = absolute_current_url
|
||||
.replace("https://", "")
|
||||
.replace("http://", "")
|
||||
.replace(current_url, "");
|
||||
renderRequest.setAttribute("calculated_gateway", calculated_gateway);
|
||||
|
||||
String base_url = PortalUtil.getAbsoluteURL(httpReq, "/");
|
||||
renderRequest.setAttribute("base_url", base_url);
|
||||
URL a = new URL(base_url);
|
||||
|
||||
renderRequest.setAttribute("host", a.getHost());
|
||||
|
||||
try {
|
||||
Group group = (Group) GroupLocalServiceUtil.getGroup(PortalUtil.getScopeGroupId(renderRequest));
|
||||
String group_url = group.getFriendlyURL();
|
||||
renderRequest.setAttribute("group_url", group_url);
|
||||
renderRequest.setAttribute("group_name", group.getName());
|
||||
|
||||
} catch (PortalException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (SystemException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String completeURL = PortalUtil.getCurrentCompleteURL(httpReq);
|
||||
renderRequest.setAttribute("completeURL", completeURL);
|
||||
|
||||
// User theUser = PortalUtil.getUser(renderRequest);
|
||||
// String currentContext = getCurrentContext(renderRequest);
|
||||
String currentContext = getCurrentContext(renderRequest);
|
||||
renderRequest.setAttribute("current_context", currentContext);
|
||||
|
||||
// ScopeBean bean = new ScopeBean(currentContext);
|
||||
// String context;
|
||||
// String excapedContext;
|
||||
|
|
|
@ -1,12 +1,27 @@
|
|||
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
|
||||
<%@include file="../init.jsp" %>
|
||||
<%
|
||||
|
||||
|
||||
pageContext.setAttribute("current_context", request.getAttribute("current_context"));
|
||||
|
||||
pageContext.setAttribute("encoded_context", request.getAttribute("encoded_context"));
|
||||
pageContext.setAttribute("redirect_url", request.getAttribute("redirect_url"));
|
||||
pageContext.setAttribute("auth_url", request.getAttribute("auth_url"));
|
||||
pageContext.setAttribute("ccp_url",
|
||||
request.getAttribute("ccp_url"));
|
||||
pageContext.setAttribute("cdn_url", request.getAttribute("cdn_url")); %>
|
||||
pageContext.setAttribute("ccp_url", request.getAttribute("ccp_url"));
|
||||
pageContext.setAttribute("cdn_url", request.getAttribute("cdn_url"));
|
||||
|
||||
|
||||
pageContext.setAttribute("current_url", request.getAttribute("current_url"));
|
||||
pageContext.setAttribute("infrastructure", request.getAttribute("infrastructure"));
|
||||
pageContext.setAttribute("absolute_current_url", request.getAttribute("absolute_current_url"));
|
||||
pageContext.setAttribute("calculated_gateway", request.getAttribute("calculated_gateway"));
|
||||
pageContext.setAttribute("base_url", request.getAttribute("base_url"));
|
||||
pageContext.setAttribute("group_url", request.getAttribute("group_url"));
|
||||
pageContext.setAttribute("group_name", request.getAttribute("group_name"));
|
||||
pageContext.setAttribute("host", request.getAttribute("host"));
|
||||
|
||||
%>
|
||||
|
||||
<script src="${cdn_url}/common/js/keycloak.js" type="text/javascript"></script>
|
||||
<script src="${cdn_url}/common/js/bss-min-1.2.6.js"></script>
|
||||
|
@ -25,10 +40,23 @@ pageContext.setAttribute("cdn_url", request.getAttribute("cdn_url")); %>
|
|||
Boot Portlet
|
||||
|
||||
<ul>
|
||||
|
||||
<li> current_context = ${current_context}</li>
|
||||
<li> encoded_context = ${encoded_context}</li>
|
||||
<li> gateway = ${gateway}</li>
|
||||
<li> redirect_url = ${redirect_url}</li>
|
||||
<li> auth_url = ${auth_url}</li>
|
||||
<li> ccp_url = ${ccp_url}</li>
|
||||
<li> cdn_url = ${cdn_url}</li>
|
||||
|
||||
|
||||
<li> current_url = ${current_url}</li>
|
||||
<li> infrastructure = ${infrastructure}</li>
|
||||
<li> absolute_current_url = ${absolute_current_url}</li>
|
||||
<li> calculated_gateway = ${calculated_gateway}</li>
|
||||
|
||||
<li> base_url = ${base_url}</li>
|
||||
<li> group_url = ${group_url}</li>
|
||||
<li> group_name = ${group_name}</li>
|
||||
<li> host = ${host}</li>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue