本文整理汇总了Java中com.liferay.portal.util.PortalUtil.getUser方法的典型用法代码示例。如果您正苦于以下问题:Java PortalUtil.getUser方法的具体用法?Java PortalUtil.getUser怎么用?Java PortalUtil.getUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.liferay.portal.util.PortalUtil
的用法示例。
在下文中一共展示了PortalUtil.getUser方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: log
import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
/**
* This function use message bus for add user's activity
*
* Version: OEP 1.1
*
* History:
* DATE AUTHOR DESCRIPTION
* -------------------------------------------------
* 20-April-2015 ThongDV Create new
* @param action
* @param description
* @param serviceContext
* @throws SystemException
*/
public void log(String action, String description,ServiceContext serviceContext){
try {
User user=PortalUtil.getUser(serviceContext.getRequest());
Message message = new Message();
message.put(UserLogKeys.UserActivityMessageKeys.ACTION, action);
message.put(UserLogKeys.UserActivityMessageKeys.DESCRIPTION, description);
message.put(UserLogKeys.UserActivityMessageKeys.USER_ID, serviceContext.getUserId());
message.put(UserLogKeys.UserActivityMessageKeys.GROUP_ID, serviceContext.getScopeGroupId());
message.put(UserLogKeys.UserActivityMessageKeys.COMPANY_ID, serviceContext.getCompanyId());
message.put(UserLogKeys.UserActivityMessageKeys.EMAIL, user.getEmailAddress());
message.put(UserLogKeys.UserActivityMessageKeys.USER_NAME, user.getScreenName());
message.put(UserLogKeys.UserActivityMessageKeys.CREATE_DATE, new Date());
message.put(UserLogKeys.UserActivityMessageKeys.SITE, serviceContext.getThemeDisplay().getSiteGroupName());
message.put(UserLogKeys.UserActivityMessageKeys.PAGE, ContextUtil.getPage(serviceContext.getThemeDisplay()));
message.put(UserLogKeys.UserActivityMessageKeys.IP, user.getLogin());
message.put(UserLogKeys.UserActivityMessageKeys.SESSION_ID, serviceContext.getRequest().getSession().getId());
message.put(UserLogKeys.UserActivityMessageKeys.URL, serviceContext.getCurrentURL());
message.put(UserLogKeys.UserActivityMessageKeys.USER_AGENT, serviceContext.getUserAgent());
MessageBusUtil.sendMessage(UserLogKeys.DESTINATION, message);
} catch (Exception e) {
log.error(e);
}
}
示例2: run
import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
@Override
public void run(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ActionException {
// TODO Auto-generated method stub
String userAgent = servletRequest.getHeader("User-Agent");
String platform = "Desktop";
if(detectMobile(userAgent.toLowerCase())){
platform = "Smartphone";
}
String extraData = servletRequest.getRemoteAddr()+"###"+userAgent+"###"+platform;
try {
User u = PortalUtil.getUser(servletRequest);
AuditingLogFactory.audit(u.getCompanyId(),0, User.class.getName(), 0, u.getUserId(), AuditConstants.ACCESS, extraData);
} catch (PortalException e1){
// TODO Auto-generated catch block
e1.printStackTrace();
}catch( SystemException e2){
e2.printStackTrace();
}
}
示例3: isUserLoggedIn
import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
@Override
public boolean isUserLoggedIn(HttpServletRequest request) {
try {
return PortalUtil.getUser(request) != null;
} catch (PortalException | SystemException e) {
return false;
}
}
示例4: profileActionUpdateDetails
import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
/**
* This Action sets the "jspPage" parameter to "addApplicationPreambleJSP"
* so that processing is forwarded to add_application.jsp.
*
* @param request
* @param response
* @throws PortalException
* @throws java.lang.Exception
*/
@ProcessAction(name = "profileActionUpdateDetails")
public void profileActionUpdateDetails(ActionRequest request,
ActionResponse response) {
_applicationPortletLog.debug("profileActionUpdateDetails");
response.setRenderParameter("jspPage", profileJSP);
try {
String fname = ParamUtil.getString(request, "fname");
String lname = ParamUtil.getString(request, "lname");
String eaddr = ParamUtil.getString(request, "eaddr");
String tab = ParamUtil.getString(request, "tab");
request.setAttribute("fname", fname);
request.setAttribute("lname", lname);
request.setAttribute("eaddr", eaddr);
request.setAttribute("tab", tab);
if (!isString(fname)) {
request.setAttribute("errorMsg",
"Der Vorname muss angegeben werden!");
} else if (!isString(lname)) {
request.setAttribute("errorMsg",
"Der Nachname muss angegeben werden!");
} else if (!isEmail(eaddr)) {
request.setAttribute("errorMsg",
"Die eMail-Adresse muss angegeben werden!");
} else {
User user = PortalUtil.getUser(request);
user.setFirstName(fname);
user.setLastName(lname);
user.setEmailAddress(eaddr);
UserLocalServiceUtil.updateUser(user);
request.setAttribute("successMsg",
"Die Daten wurden erfolgreich geändert!");
}
} catch (Exception e) {
e.printStackTrace();
request.setAttribute("errorMsg",
"Internal Error: " + e.getMessage());
}
}
示例5: doFilter
import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain)
throws IOException, ServletException
{
// filter only, if filter set enabled
if (m_bIsEnabled) {
HttpServletRequest request = (HttpServletRequest) req;
try
{
User user = PortalUtil.getUser(request);
if (user != null)
{
long userId = user.getUserId();
if ((ADMIN_ROLE_ID < 0)
|| UserLocalServiceUtil.hasRoleUser(ADMIN_ROLE_ID,
userId))
{
chain.doFilter(req, res);
return;
} else
{
userNotFound(req, res, chain);
return;
}
} else
{
userNotFound(req, res, chain);
return;
}
} catch (Exception e)
{
log.error((new StringBuilder(
"Error in SecureURLFilter.doFilter(): \n")).append(
e.getMessage()).toString());
userNotFound(req, res, chain);
return;
}
} else {
chain.doFilter(req, res);
return;
}
}
示例6: getUser
import com.liferay.portal.util.PortalUtil; //导入方法依赖的package包/类
/**
* getUser: returns current Liferay user, typically via call to PortalUtil
* @param request
*/
protected User getUser(HttpServletRequest request) throws SystemException, PortalException {
return PortalUtil.getUser(request);
}