List of usage examples for com.liferay.portal.kernel.audit AuditMessage AuditMessage
public AuditMessage(String eventType, long companyId, long userId, String userName, String className, String classPK, String message, JSONObject additionalInfoJSONObject)
From source file:com.liferay.filesystemaccess.audit.AuditMessageBuilder.java
License:Open Source License
public static AuditMessage buildAuditMessage(String eventType, String className, long classPK, List<Attribute> attributes) { long companyId = CompanyThreadLocal.getCompanyId(); long userId = 0; if (PrincipalThreadLocal.getName() != null) { userId = GetterUtil.getLong(PrincipalThreadLocal.getName()); }/* ww w . jav a 2 s . c o m*/ AuditRequestThreadLocal auditRequestThreadLocal = AuditRequestThreadLocal.getAuditThreadLocal(); long realUserId = auditRequestThreadLocal.getRealUserId(); String realUserName = PortalUtil.getUserName(realUserId, StringPool.BLANK); JSONObject additionalInfo = JSONFactoryUtil.createJSONObject(); if ((realUserId > 0) && (userId != realUserId)) { additionalInfo.put("doAsUserId", String.valueOf(userId)); additionalInfo.put("doAsUserName", PortalUtil.getUserName(userId, StringPool.BLANK)); } if (attributes != null) { additionalInfo.put("attributes", _getAttributesJSON(attributes)); } return new AuditMessage(eventType, companyId, realUserId, realUserName, className, String.valueOf(classPK), null, additionalInfo); }
From source file:com.liferay.portlet.documentlibrary.util.AuditMessageBuilder.java
License:Open Source License
public static AuditMessage buildAuditMessage(String eventType, String className, long classPK, List<Attribute> attributes) { long companyId = CompanyThreadLocal.getCompanyId(); long userId = 0; if (PrincipalThreadLocal.getName() != null) { userId = GetterUtil.getLong(PrincipalThreadLocal.getName()); }/*from w w w . j a v a 2 s .c o m*/ AuditRequestThreadLocal auditRequestThreadLocal = AuditRequestThreadLocal.getAuditThreadLocal(); long realUserId = auditRequestThreadLocal.getRealUserId(); String realUserName = PortalUtil.getUserName(realUserId, StringPool.BLANK); JSONObject additionalInfo = JSONFactoryUtil.createJSONObject(); if ((realUserId > 0) && (userId != realUserId)) { additionalInfo.put("doAsUserId", String.valueOf(userId)); additionalInfo.put("doAsUserName", PortalUtil.getUserName(userId, StringPool.BLANK)); } if (attributes != null) { additionalInfo.put("attributes", _getAttributesJSON(attributes)); } return new AuditMessage(eventType, companyId, realUserId, realUserName, className, String.valueOf(classPK), null, additionalInfo); }