use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content 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 com.agiletec.plugins.jacms.aps.system.services.content.model.Content 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 com.agiletec.plugins.jacms.aps.system.services.content.model.Content 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 com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class AbstractTestContentAttribute method deleteTestContent.
protected void deleteTestContent() throws Throwable {
EntitySearchFilter filter = new EntitySearchFilter(IContentManager.CONTENT_DESCR_FILTER_KEY, false, TEST_CONTENT_DESCRIPTION, false);
EntitySearchFilter[] filters = { filter };
List<String> groupCodes = new ArrayList<String>();
groupCodes.add(Group.ADMINS_GROUP_NAME);
List<String> contentIds = this.getContentManager().loadWorkContentsId(filters, groupCodes);
for (int i = 0; i < contentIds.size(); i++) {
String contentId = (String) contentIds.get(i);
Content content = this.getContentManager().loadContent(contentId, false);
this.getContentManager().deleteContent(content);
}
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class TestSaveBooleanAttributes method testSaveThreeStateAttribute.
public void testSaveThreeStateAttribute() throws Throwable {
try {
String contentOnSessionMarker = this.executeCreateNewContent();
Content content = this.getContentOnEdit(contentOnSessionMarker);
ThreeStateAttribute attribute = (ThreeStateAttribute) content.getAttribute("ThreeState");
assertNull(attribute.getBooleanValue());
assertFalse(attribute.getValue());
this.initSaveContentAction(contentOnSessionMarker);
contentOnSessionMarker = this.executeSaveAndReloadContent(contentOnSessionMarker);
content = this.getContentOnEdit(contentOnSessionMarker);
attribute = (ThreeStateAttribute) content.getAttribute("ThreeState");
assertNull(attribute.getBooleanValue());
assertFalse(attribute.getValue());
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter("ThreeState:ThreeState", "false");
contentOnSessionMarker = this.executeSaveAndReloadContent(contentOnSessionMarker);
content = this.getContentOnEdit(contentOnSessionMarker);
attribute = (ThreeStateAttribute) content.getAttribute("ThreeState");
assertNotNull(attribute.getBooleanValue());
assertFalse(attribute.getValue());
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter("ThreeState:ThreeState", "true");
contentOnSessionMarker = this.executeSaveAndReloadContent(contentOnSessionMarker);
content = this.getContentOnEdit(contentOnSessionMarker);
attribute = (ThreeStateAttribute) content.getAttribute("ThreeState");
assertNotNull(attribute.getBooleanValue());
assertTrue(attribute.getValue());
} catch (Throwable t) {
throw t;
} finally {
this.deleteTestContent();
}
}
Aggregations