use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecord in project entando-core by entando.
the class TestActivityStream method testSaveNewContent_1.
// ----------------------------------------------
public void testSaveNewContent_1() throws Throwable {
Content content = this._contentManager.loadContent("ART1", false);
String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(content, ApsAdminSystemConstants.ADD);
content.setId(null);
String contentId = null;
try {
this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, content);
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.setUserOnSession("admin");
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
contentId = content.getId();
assertNotNull(this._contentManager.loadContent(contentId, false));
super.waitThreads(IActionLogManager.LOG_APPENDER_THREAD_NAME_PREFIX);
ActionLogRecordSearchBean searchBean = this._helper.createSearchBean("admin", null, null, null, null, null);
List<Integer> ids = this._actionLoggerManager.getActionRecords(searchBean);
assertEquals(1, ids.size());
UserDetails currentUser = (UserDetails) super.getRequest().getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
List<Integer> activityStream = this._actionLoggerManager.getActivityStream(currentUser);
assertEquals(activityStream.size(), ids.size());
assertEquals(activityStream.get(0), ids.get(0));
ActionLogRecord record = this._actionLoggerManager.getActionRecord(ids.get(0));
assertEquals("/do/jacms/Content", record.getNamespace());
assertEquals("save", record.getActionName());
ActivityStreamInfo asi = record.getActivityStreamInfo();
assertNotNull(asi);
assertEquals(1, asi.getActionType());
assertEquals(Permission.CONTENT_EDITOR, asi.getLinkAuthPermission());
assertEquals(content.getMainGroup(), asi.getLinkAuthGroup());
assertEquals("edit", asi.getLinkActionName());
assertEquals("/do/jacms/Content", asi.getLinkNamespace());
// assertEquals(1, asi.getLinkParameters().size());
Properties parameters = asi.getLinkParameters();
assertEquals(1, parameters.size());
assertEquals(contentId, parameters.getProperty("contentId"));
} catch (Throwable t) {
throw t;
} finally {
this._contentManager.deleteContent(content);
assertNull(this._contentManager.loadContent(contentId, false));
}
}
use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecord in project entando-core by entando.
the class TestActivityStream method testLogAddPage.
public void testLogAddPage() throws Throwable {
String pageCode = "activity_stream_test_test";
try {
this.addPage(pageCode);
super.waitThreads(IActionLogManager.LOG_APPENDER_THREAD_NAME_PREFIX);
ActionLogRecordSearchBean searchBean = this._helper.createSearchBean("admin", null, null, null, null, null);
List<Integer> ids = this._actionLoggerManager.getActionRecords(searchBean);
assertEquals(1, ids.size());
ActionLogRecord record = this._actionLoggerManager.getActionRecord(ids.get(0));
assertEquals("/do/Page", record.getNamespace());
assertEquals("save", record.getActionName());
ActivityStreamInfo asi = record.getActivityStreamInfo();
assertNotNull(asi);
assertEquals(1, asi.getActionType());
assertEquals("edit", asi.getLinkActionName());
assertEquals("/do/Page", asi.getLinkNamespace());
Properties parameters = asi.getLinkParameters();
assertEquals(1, parameters.size());
assertEquals(pageCode, parameters.getProperty("selectedNode"));
} catch (Throwable t) {
throw t;
} finally {
this._pageManager.deletePage(pageCode);
}
}
use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecord in project entando-core by entando.
the class TestActivityStreamAction method testActivityStreamSearchBean.
public void testActivityStreamSearchBean() throws Throwable {
// "coach" group
Content content = this._contentManager.loadContent("EVN41", false);
String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(content, ApsAdminSystemConstants.ADD);
content.setId(null);
String contentId = null;
Date dateBeforeSave = new Date();
Thread.sleep(1000);
try {
this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, content);
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.setUserOnSession("admin");
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
contentId = content.getId();
assertNotNull(this._contentManager.loadContent(contentId, false));
super.waitThreads(IActionLogManager.LOG_APPENDER_THREAD_NAME_PREFIX);
Date firstDate = new Date();
ActionLogRecordSearchBean searchBean = this._helper.createSearchBean("admin", null, null, null, null, null);
List<Integer> ids = this._actionLoggerManager.getActionRecords(searchBean);
assertEquals(1, ids.size());
ActionLogRecord firstRecord = this._actionLoggerManager.getActionRecord(ids.get(0));
ActivityStreamSeachBean activityStreamSeachBean = new ActivityStreamSeachBean();
activityStreamSeachBean.setEndUpdate(firstDate);
List<Integer> activityStreamEndDate = this._actionLoggerManager.getActivityStream(activityStreamSeachBean);
assertEquals(1, activityStreamEndDate.size());
Thread.sleep(1000);
this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, content);
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.setUserOnSession("admin");
result = this.executeAction();
assertEquals(Action.SUCCESS, result);
contentId = content.getId();
assertNotNull(this._contentManager.loadContent(contentId, false));
super.waitThreads(IActionLogManager.LOG_APPENDER_THREAD_NAME_PREFIX);
activityStreamSeachBean = new ActivityStreamSeachBean();
activityStreamSeachBean.setEndUpdate(new Date());
List<Integer> activityStreamBetweenSave2 = this._actionLoggerManager.getActivityStream(activityStreamSeachBean);
assertEquals(2, activityStreamBetweenSave2.size());
String firstDateString = DateConverter.getFormattedDate(firstDate, ApsAdminSystemConstants.CALENDAR_TIMESTAMP_PATTERN);
this.initActivityStreamAction("/do/ActivityStream", "update", firstDateString);
this.setUserOnSession("admin");
result = this.executeAction();
assertEquals(Action.SUCCESS, result);
ActivityStreamAction activityStreamAction = (ActivityStreamAction) this.getAction();
List<Integer> update = activityStreamAction.getActionRecordIds();
assertEquals(1, update.size());
ActionLogRecord updateRecord = this._actionLoggerManager.getActionRecord(update.get(0));
String actionRecordDate = DateConverter.getFormattedDate(updateRecord.getActionDate(), ApsAdminSystemConstants.CALENDAR_TIMESTAMP_PATTERN);
this.initActivityStreamAction("/do/ActivityStream", "viewMore", actionRecordDate);
this.setUserOnSession("admin");
result = this.executeAction();
assertEquals(Action.SUCCESS, result);
activityStreamAction = (ActivityStreamAction) this.getAction();
List<Integer> viewMore = activityStreamAction.getActionRecordIds();
assertEquals(1, viewMore.size());
assertEquals(firstRecord.getId(), viewMore.get(0).intValue());
} catch (Throwable t) {
throw t;
} finally {
this._contentManager.deleteContent(content);
assertNull(this._contentManager.loadContent(contentId, false));
}
}
use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecord in project entando-core by entando.
the class TestSocialActivityStreamDAO method testAddGetDeleteActionRecord.
public void testAddGetDeleteActionRecord() {
ActionLogRecord record1 = this._helper.createActionRecord(1, "username1", "actionName1", "namespace1", DateConverter.parseDate("01/01/2009 00:00", "dd/MM/yyyy HH:mm"), "params1");
ActionLogRecord record2 = this._helper.createActionRecord(2, "username2", "actionName2", "namespace2", DateConverter.parseDate("01/02/2009 00:00", "dd/MM/yyyy HH:mm"), "params2");
this._actionLoggerDAO.addActionRecord(record1);
this._actionLoggerDAO.addActionRecord(record2);
ActionLogRecord addedRecord1 = this._actionLoggerDAO.getActionRecord(record1.getId());
this.compareActionRecords(record1, addedRecord1);
ActionLogRecord addedRecord2 = this._actionLoggerDAO.getActionRecord(record2.getId());
this.compareActionRecords(record2, addedRecord2);
this._actionLoggerDAO.deleteActionRecord(record1.getId());
assertNull(this._actionLoggerDAO.getActionRecord(record1.getId()));
this._actionLoggerDAO.deleteActionRecord(record2.getId());
assertNull(this._actionLoggerDAO.getActionRecord(record2.getId()));
}
use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecord 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;
}
Aggregations