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;
}
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);
}
}
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;
}
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);
}
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;
}
Aggregations