use of org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo in project entando-core by entando.
the class ActivityStreamInfoDOM method unmarshalInfo.
public static ActivityStreamInfo unmarshalInfo(String xml) throws ApsSystemException {
ActivityStreamInfo bodyObject = null;
try {
JAXBContext context = JAXBContext.newInstance(ActivityStreamInfo.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
ByteArrayInputStream is = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8));
bodyObject = (ActivityStreamInfo) unmarshaller.unmarshal(is);
} catch (Throwable t) {
_logger.error("Error unmarshalling activity stream info config. xml: {}", xml, t);
// ApsSystemUtils.logThrowable(t, UnmarshalUtils.class, "unmarshalInfo");
throw new ApsSystemException("Error unmarshalling activity stream info config", t);
}
return bodyObject;
}
use of org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo 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.ActivityStreamInfo 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.ActivityStreamInfo in project entando-core by entando.
the class DataObjectActionHelper method createActivityStreamInfo.
@Override
public ActivityStreamInfo createActivityStreamInfo(DataObject dataobject, 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 != dataobject.getDescription()) ? dataobject.getDescription() : "-");
asi.setObjectTitles(titles);
if (addLink) {
asi.setLinkNamespace("/do/dataobject");
asi.setLinkActionName("edit");
asi.addLinkParameter("dataId", dataobject.getId());
asi.setLinkAuthGroup(dataobject.getMainGroup());
asi.setLinkAuthPermission(Permission.CONTENT_EDITOR);
}
List<String> groupCodes = new ArrayList<String>();
if (null != dataobject.getMainGroup()) {
groupCodes.addAll(dataobject.getGroups());
}
groupCodes.add(dataobject.getMainGroup());
asi.setGroups(groupCodes);
return asi;
}
use of org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo in project entando-core by entando.
the class ContentFinderAction method addActivityStreamInfo.
protected void addActivityStreamInfo(Content content, int strutsAction, boolean addLink) {
ActivityStreamInfo asi = this.getContentActionHelper().createActivityStreamInfo(content, strutsAction, addLink);
super.addActivityStreamInfo(asi);
}
Aggregations