config not cached, problem switching between instances

This commit is contained in:
Alfredo Oliviero 2024-07-17 16:52:17 +02:00
parent df51d73f77
commit dd4d9aa900
1 changed files with 35 additions and 36 deletions

View File

@ -23,7 +23,7 @@ import com.liferay.util.bridges.mvc.MVCPortlet;
public class CC_Portlet extends MVCPortlet {
private static com.liferay.portal.kernel.log.Log _log = LogFactoryUtil.getLog(CC_Portlet.class);
private CC_Config configuration = null;
// private CC_Config configuration = null;
public final static String IS_AUTH_RESOURCE_NAME = "IAM";
public final static String IS_AUTH_CATEGORY = "Service";
@ -36,52 +36,51 @@ public class CC_Portlet extends MVCPortlet {
public CC_Config getConfig(RenderRequest renderRequest)
throws MalformedURLException, ServerException {
if (configuration == null) {
try {
CC_Config config = new CC_Config();
try {
CC_Config config = new CC_Config();
String currentContext = getCurrentContext(renderRequest);
String encodedContext = getEncodedContext(currentContext);
config.encoded_context = encodedContext;
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
// 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
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;
config.redirect_url = absolute_current_url;
URL base_url = new URL(PortalUtil.getAbsoluteURL(httpReq, "/"));
String host = base_url.getHost();
config.gateway = host;
URL base_url = new URL(PortalUtil.getAbsoluteURL(httpReq, "/"));
String host = base_url.getHost();
config.gateway = host;
IsClient isclient = IsClientFactory.getSingleton();
IsClient isclient = IsClientFactory.getSingleton();
IsServerConfig auth_config = isclient.serviceConfigFromIS(IS_AUTH_RESOURCE_NAME,
IS_AUTH_CATEGORY, IS_AUTH_ENTRYPOINT);
config.auth_url = auth_config.getServerUrl();
IsServerConfig auth_config = isclient.serviceConfigFromIS(IS_AUTH_RESOURCE_NAME,
IS_AUTH_CATEGORY, IS_AUTH_ENTRYPOINT);
config.auth_url = auth_config.getServerUrl();
IsServerConfig ccp_config = isclient.serviceConfigFromIS(IS_CCP_RESOURCE_NAME,
IS_CCP_CATEGORY, IS_CCP_ENTRYPOINT);
config.ccp_url = ccp_config.getServerUrl();
IsServerConfig ccp_config = isclient.serviceConfigFromIS(IS_CCP_RESOURCE_NAME,
IS_CCP_CATEGORY, IS_CCP_ENTRYPOINT);
config.ccp_url = ccp_config.getServerUrl();
IsServerConfig cdn_config = isclient.serviceConfigFromIS(IS_CCP_RESOURCE_NAME,
IS_CCP_CATEGORY, IS_CDN_ENTRYPOINT);
config.cdn_url = cdn_config.getServerUrl();
IsServerConfig cdn_config = isclient.serviceConfigFromIS(IS_CCP_RESOURCE_NAME,
IS_CCP_CATEGORY, IS_CDN_ENTRYPOINT);
config.cdn_url = cdn_config.getServerUrl();
configuration = config;
} catch (Exception e) {
e.printStackTrace();
_log.error("cannot obtain configuration", e);
return null;
}
return config;
// configuration = config;
} catch (Exception e) {
e.printStackTrace();
_log.error("cannot obtain configuration", e);
return null;
}
return configuration;
}
protected static String getCurrentContext(RenderRequest request) {