Search in sources :

Example 1 with ActivityStreamInfo

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;
}
Also used : ActivityStreamInfo(org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo) ByteArrayInputStream(java.io.ByteArrayInputStream) JAXBContext(javax.xml.bind.JAXBContext) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 2 with ActivityStreamInfo

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));
    }
}
Also used : ActionLogRecord(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecord) UserDetails(com.agiletec.aps.system.services.user.UserDetails) ActivityStreamInfo(org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ActionLogRecordSearchBean(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordSearchBean) Properties(java.util.Properties)

Example 3 with ActivityStreamInfo

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);
    }
}
Also used : ActionLogRecord(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecord) ActivityStreamInfo(org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo) ActionLogRecordSearchBean(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordSearchBean) Properties(java.util.Properties)

Example 4 with ActivityStreamInfo

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;
}
Also used : ActivityStreamInfo(org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo) ArrayList(java.util.ArrayList) Lang(com.agiletec.aps.system.services.lang.Lang) Properties(java.util.Properties)

Example 5 with ActivityStreamInfo

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);
}
Also used : ActivityStreamInfo(org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo)

Aggregations

ActivityStreamInfo (org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo)16 Properties (java.util.Properties)4 ActionLogRecord (org.entando.entando.aps.system.services.actionlog.model.ActionLogRecord)4 ArrayList (java.util.ArrayList)3 Lang (com.agiletec.aps.system.services.lang.Lang)2 IPage (com.agiletec.aps.system.services.page.IPage)2 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 Timestamp (java.sql.Timestamp)2 ActionLogRecordSearchBean (org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordSearchBean)2 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)1 UserDetails (com.agiletec.aps.system.services.user.UserDetails)1 BaseAction (com.agiletec.apsadmin.system.BaseAction)1 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ResultSet (java.sql.ResultSet)1 Date (java.util.Date)1 JAXBContext (javax.xml.bind.JAXBContext)1 Unmarshaller (javax.xml.bind.Unmarshaller)1