Search in sources :

Example 6 with ActivityStreamInfo

use of org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo in project entando-core by entando.

the class ActionLogDAO method getActionRecord.

@Override
public ActionLogRecord getActionRecord(int id) {
    Connection conn = null;
    PreparedStatement stat = null;
    ResultSet res = null;
    ActionLogRecord actionRecord = null;
    try {
        conn = this.getConnection();
        conn.setAutoCommit(false);
        stat = conn.prepareStatement(GET_ACTION_RECORD);
        stat.setInt(1, id);
        res = stat.executeQuery();
        if (res.next()) {
            actionRecord = new ActionLogRecord();
            actionRecord.setId(id);
            Timestamp actionDate = res.getTimestamp("actiondate");
            actionRecord.setActionDate(new Date(actionDate.getTime()));
            Timestamp updateDate = res.getTimestamp("updatedate");
            actionRecord.setUpdateDate(new Date(updateDate.getTime()));
            actionRecord.setActionName(res.getString("actionname"));
            actionRecord.setNamespace(res.getString("namespace"));
            actionRecord.setParameters(res.getString("parameters"));
            actionRecord.setUsername(res.getString("username"));
            String asiXml = res.getString("activitystreaminfo");
            if (null != asiXml && asiXml.trim().length() > 0) {
                ActivityStreamInfo asi = ActivityStreamInfoDOM.unmarshalInfo(asiXml);
                actionRecord.setActivityStreamInfo(asi);
            }
        }
        conn.commit();
    } catch (Throwable t) {
        this.executeRollback(conn);
        _logger.error("Error loading actionlogger record with id: {}", id, t);
        throw new RuntimeException("Error loading actionlogger record with id: " + id, t);
    } finally {
        closeDaoResources(res, stat, conn);
    }
    return actionRecord;
}
Also used : ActionLogRecord(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecord) ActivityStreamInfo(org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) Timestamp(java.sql.Timestamp) Date(java.util.Date)

Example 7 with ActivityStreamInfo

use of org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo in project entando-core by entando.

the class ActionLogDAO method addActionRecord.

@Override
public void addActionRecord(ActionLogRecord actionRecord) {
    Connection conn = null;
    PreparedStatement stat = null;
    try {
        conn = this.getConnection();
        conn.setAutoCommit(false);
        stat = conn.prepareStatement(ADD_ACTION_RECORD);
        stat.setInt(1, actionRecord.getId());
        stat.setString(2, actionRecord.getUsername());
        Timestamp timestamp = new Timestamp(actionRecord.getActionDate().getTime());
        stat.setTimestamp(3, timestamp);
        stat.setString(4, actionRecord.getNamespace());
        stat.setString(5, actionRecord.getActionName());
        stat.setString(6, actionRecord.getParameters());
        ActivityStreamInfo asi = actionRecord.getActivityStreamInfo();
        if (null != asi) {
            stat.setString(7, ActivityStreamInfoDOM.marshalInfo(asi));
        } else {
            stat.setNull(7, Types.VARCHAR);
        }
        stat.setTimestamp(8, timestamp);
        stat.executeUpdate();
        this.addLogRecordRelations(actionRecord.getId(), asi, conn);
        conn.commit();
    } catch (Throwable t) {
        this.executeRollback(conn);
        _logger.error("Error on insert actionlogger record", t);
        throw new RuntimeException("Error on insert actionlogger record", t);
    } finally {
        closeDaoResources(null, stat, conn);
    }
}
Also used : ActivityStreamInfo(org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) Timestamp(java.sql.Timestamp)

Example 8 with ActivityStreamInfo

use of org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo in project entando-core by entando.

the class ActionLoggerInterceptor method intercept.

@Override
public String intercept(ActionInvocation invocation) throws Exception {
    ActionLogRecord actionRecord = null;
    String result = null;
    try {
        actionRecord = this.buildActionRecord(invocation);
        result = invocation.invoke();
        List<ActivityStreamInfo> asiList = null;
        Object actionObject = invocation.getAction();
        if (actionObject instanceof BaseAction) {
            BaseAction action = (BaseAction) actionObject;
            asiList = action.getActivityStreamInfos();
        }
        if (null == asiList || asiList.isEmpty()) {
            this.getActionLoggerManager().addActionRecord(actionRecord);
        } else {
            for (int i = 0; i < asiList.size(); i++) {
                ActivityStreamInfo asi = asiList.get(i);
                ActionLogRecord clone = this.createClone(actionRecord);
                clone.setActivityStreamInfo(asi);
                this.getActionLoggerManager().addActionRecord(clone);
            }
        }
    } catch (Throwable t) {
        _logger.error("error in intercept", t);
    // ApsSystemUtils.logThrowable(t, this, "intercept");
    }
    return result;
}
Also used : ActionLogRecord(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecord) ActivityStreamInfo(org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo) BaseAction(com.agiletec.apsadmin.system.BaseAction)

Example 9 with ActivityStreamInfo

use of org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo in project entando-core by entando.

the class AbstractContentAction method addActivityStreamInfo.

protected void addActivityStreamInfo(Content content, int strutsAction, boolean addLink) {
    ActivityStreamInfo asi = this.getContentActionHelper().createActivityStreamInfo(content, strutsAction, addLink);
    super.addActivityStreamInfo(asi);
}
Also used : ActivityStreamInfo(org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo)

Example 10 with ActivityStreamInfo

use of org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo in project entando-core by entando.

the class ContentActionHelper method createActivityStreamInfo.

@Override
public ActivityStreamInfo createActivityStreamInfo(Content content, int strutsAction, boolean addLink) {
    ActivityStreamInfo asi = new ActivityStreamInfo();
    asi.setActionType(strutsAction);
    Lang defaultLang = this.getLangManager().getDefaultLang();
    Properties titles = new Properties();
    titles.setProperty(defaultLang.getCode(), (null != content.getDescription()) ? content.getDescription() : "-");
    asi.setObjectTitles(titles);
    if (addLink) {
        asi.setLinkNamespace("/do/jacms/Content");
        asi.setLinkActionName("edit");
        asi.addLinkParameter("contentId", content.getId());
        asi.setLinkAuthGroup(content.getMainGroup());
        asi.setLinkAuthPermission(Permission.CONTENT_EDITOR);
    }
    List<String> groupCodes = new ArrayList<String>();
    if (null != content.getMainGroup()) {
        groupCodes.addAll(content.getGroups());
    }
    groupCodes.add(content.getMainGroup());
    asi.setGroups(groupCodes);
    return asi;
}
Also used : ActivityStreamInfo(org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo) ArrayList(java.util.ArrayList) Lang(com.agiletec.aps.system.services.lang.Lang) Properties(java.util.Properties)

Aggregations

ActivityStreamInfo (org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo)16 Properties (java.util.Properties)4 ActionLogRecord (org.entando.entando.aps.system.services.actionlog.model.ActionLogRecord)4 ArrayList (java.util.ArrayList)3 Lang (com.agiletec.aps.system.services.lang.Lang)2 IPage (com.agiletec.aps.system.services.page.IPage)2 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 Timestamp (java.sql.Timestamp)2 ActionLogRecordSearchBean (org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordSearchBean)2 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)1 UserDetails (com.agiletec.aps.system.services.user.UserDetails)1 BaseAction (com.agiletec.apsadmin.system.BaseAction)1 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ResultSet (java.sql.ResultSet)1 Date (java.util.Date)1 JAXBContext (javax.xml.bind.JAXBContext)1 Unmarshaller (javax.xml.bind.Unmarshaller)1