001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.audit;
016    
017    import com.liferay.portal.kernel.audit.AuditMessage;
018    import com.liferay.portal.kernel.audit.AuditMessageFactory;
019    import com.liferay.portal.kernel.json.JSONException;
020    import com.liferay.portal.kernel.json.JSONObject;
021    import com.liferay.portal.kernel.security.pacl.DoPrivileged;
022    
023    import java.util.Date;
024    
025    /**
026     * @author Amos Fong
027     */
028    @DoPrivileged
029    public class AuditMessageFactoryImpl implements AuditMessageFactory {
030    
031            @Override
032            public AuditMessage getAuditMessage(String message) throws JSONException {
033                    return new AuditMessage(message);
034            }
035    
036            @Override
037            public AuditMessage getAuditMessage(
038                    String eventType, long companyId, long userId, String userName) {
039    
040                    return new AuditMessage(eventType, companyId, userId, userName);
041            }
042    
043            @Override
044            public AuditMessage getAuditMessage(
045                    String eventType, long companyId, long userId, String userName,
046                    String className, String classPK) {
047    
048                    return new AuditMessage(
049                            eventType, companyId, userId, userName, className, classPK);
050            }
051    
052            @Override
053            public AuditMessage getAuditMessage(
054                    String eventType, long companyId, long userId, String userName,
055                    String className, String classPK, String message) {
056    
057                    return new AuditMessage(
058                            eventType, companyId, userId, userName, className, classPK,
059                            message);
060            }
061    
062            @Override
063            public AuditMessage getAuditMessage(
064                    String eventType, long companyId, long userId, String userName,
065                    String className, String classPK, String message, Date timestamp,
066                    JSONObject additionalInfo) {
067    
068                    return new AuditMessage(
069                            eventType, companyId, userId, userName, className, classPK, message,
070                            timestamp, additionalInfo);
071            }
072    
073            @Override
074            public AuditMessage getAuditMessage(
075                    String eventType, long companyId, long userId, String userName,
076                    String className, String classPK, String message,
077                    JSONObject additionalInfo) {
078    
079                    return new AuditMessage(
080                            eventType, companyId, userId, userName, className, classPK, message,
081                            additionalInfo);
082            }
083    
084    }