use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordSearchBean in project entando-core by entando.
the class ActionLoggerTestHelper method createSearchBean.
public ActionLogRecordSearchBean createSearchBean(String username, String actionName, String namespace, String params, Date start, Date end) {
ActionLogRecordSearchBean searchBean = new ActionLogRecordSearchBean();
searchBean.setUsername(username);
searchBean.setActionName(actionName);
searchBean.setNamespace(namespace);
searchBean.setParams(params);
searchBean.setStartCreation(start);
searchBean.setEndCreation(end);
return searchBean;
}
use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordSearchBean in project entando-core by entando.
the class TestActionLogDAO method testActionLogSearch.
public void testActionLogSearch() {
IActionLogRecordSearchBean bean = null;
List<Integer> ids = this._actionLoggerDAO.getActionRecords(bean);
this.compareIds(new Integer[] {}, ids);
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/01/2009 10:00", "dd/MM/yyyy HH:mm"), "params2");
ActionLogRecord record3 = this._helper.createActionRecord(3, "username123", "actionName123", "namespace123", DateConverter.parseDate("02/01/2009 12:00", "dd/MM/yyyy HH:mm"), "params123");
this._helper.addActionRecord(record1);
this._helper.addActionRecord(record2);
this._helper.addActionRecord(record3);
ActionLogRecordSearchBean searchBean = this._helper.createSearchBean(null, "Name", null, null, DateConverter.parseDate("02/01/2009 10:01", "dd/MM/yyyy HH:mm"), DateConverter.parseDate("02/01/2009 14:01", "dd/MM/yyyy HH:mm"));
ids = this._actionLoggerDAO.getActionRecords(searchBean);
this.compareIds(new Integer[] { 3 }, ids);
}
use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordSearchBean in project entando-core by entando.
the class TestActivityStream 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());
ActivityStreamSeachBean activityStreamSeachBean = new ActivityStreamSeachBean();
activityStreamSeachBean.setEndCreation(firstDate);
List<Integer> activityStreamEndDate = this._actionLoggerManager.getActivityStream(activityStreamSeachBean);
assertEquals(1, activityStreamEndDate.size());
activityStreamSeachBean = new ActivityStreamSeachBean();
activityStreamSeachBean.setEndUpdate(dateBeforeSave);
List<Integer> activityStreamDateBeforeSave = this._actionLoggerManager.getActivityStream(activityStreamSeachBean);
assertEquals(0, activityStreamDateBeforeSave.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.setStartUpdate(dateBeforeSave);
activityStreamSeachBean.setEndUpdate(firstDate);
List<Integer> activityStreamBetweenSave = this._actionLoggerManager.getActivityStream(activityStreamSeachBean);
assertEquals(1, activityStreamBetweenSave.size());
activityStreamSeachBean = new ActivityStreamSeachBean();
activityStreamSeachBean.setStartUpdate(dateBeforeSave);
activityStreamSeachBean.setEndUpdate(new Date());
List<Integer> activityStreamBetweenSave2 = this._actionLoggerManager.getActivityStream(activityStreamSeachBean);
assertEquals(2, activityStreamBetweenSave2.size());
} 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.ActionLogRecordSearchBean in project entando-core by entando.
the class TestActivityStream method testLastUpdate.
public void testLastUpdate() throws Throwable {
// "coach" group
Content content = this._contentManager.loadContent("EVN41", false);
String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(content, ApsAdminSystemConstants.ADD);
content.setId(null);
String contentId = null;
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);
ActionLogRecordSearchBean searchBean = this._helper.createSearchBean("admin", null, null, null, null, null);
List<Integer> ids = this._actionLoggerManager.getActionRecords(searchBean);
assertEquals(1, ids.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);
List<Integer> actionRecords = this._actionLoggerManager.getActionRecords(null);
assertNotNull(actionRecords);
assertEquals(2, actionRecords.size());
ActionLogRecord actionRecord = this._actionLoggerManager.getActionRecord(actionRecords.get(1));
UserDetails adminUser = this.getUser("admin", "admin");
Date lastUpdateDate = this._actionLoggerManager.lastUpdateDate(adminUser);
assertEquals(actionRecord.getUpdateDate(), lastUpdateDate);
} 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.ActionLogRecordSearchBean 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));
}
}
Aggregations