minor fix when in devMode
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portal/portal-manager@134772 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a262793eff
commit
41919aad9a
|
@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.liferay.portal.model.Company;
|
import com.liferay.portal.model.Company;
|
||||||
import com.liferay.portal.service.CompanyLocalServiceUtil;
|
import com.liferay.portal.service.CompanyLocalServiceUtil;
|
||||||
|
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||||
import com.liferay.util.Encryptor;
|
import com.liferay.util.Encryptor;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -48,15 +49,20 @@ public class ContextUserUtil {
|
||||||
return getUserFromHeader(httpServletRequest);
|
return getUserFromHeader(httpServletRequest);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_log.debug("Something wrong with cookies, returning current user from http header");
|
if (isWithinPortal()) {
|
||||||
return getUserFromHeader(httpServletRequest);
|
_log.debug("Something wrong with cookies, returning current user from http header");
|
||||||
|
return getUserFromHeader(httpServletRequest);
|
||||||
|
} else { //you must be in dev
|
||||||
|
_log.debug("DEV MODE Intercepted ...");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_log.warn("Cookies are not present, returning current user from http header");
|
_log.warn("Cookies are not present, returning current user from http header");
|
||||||
return getUserFromHeader(httpServletRequest);
|
return getUserFromHeader(httpServletRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long getUserFromHeader(HttpServletRequest httpServletRequest) {
|
private static long getUserFromHeader(HttpServletRequest httpServletRequest) {
|
||||||
String userHeaderIdString = httpServletRequest.getHeader(PortalContext.USER_ID_ATTR_NAME);
|
String userHeaderIdString = httpServletRequest.getHeader(PortalContext.USER_ID_ATTR_NAME);
|
||||||
long userIdToReturn = -1;
|
long userIdToReturn = -1;
|
||||||
|
@ -80,4 +86,18 @@ public class ContextUserUtil {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return true if you're running into the portal, false if in development
|
||||||
|
*/
|
||||||
|
private static boolean isWithinPortal() {
|
||||||
|
try {
|
||||||
|
UserLocalServiceUtil.getService();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
_log.trace("Development Mode ON");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -608,7 +608,7 @@ public class PortalContext {
|
||||||
/**
|
/**
|
||||||
* for development purposes only
|
* for development purposes only
|
||||||
*/
|
*/
|
||||||
private static GCubeUser readUserFromPropertyFile() {
|
protected static GCubeUser readUserFromPropertyFile() {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
try {
|
try {
|
||||||
StringBuilder sb = new StringBuilder(getGCubeDevHome());
|
StringBuilder sb = new StringBuilder(getGCubeDevHome());
|
||||||
|
|
Loading…
Reference in New Issue