Search in sources :

Example 1 with FeedControl

use of org.alfresco.service.cmr.activities.FeedControl in project alfresco-repository by Alfresco.

the class Activity method getFeedControls.

/*
    * Manage User Feed Controls
    */
/**
 * For current user, get feed controls
 *
 * @return JavaScript array of user feed controls
 */
public Scriptable getFeedControls() {
    List<FeedControl> feedControls = activityService.getFeedControls();
    Object[] results = new Object[feedControls.size()];
    int i = 0;
    for (FeedControl fc : feedControls) {
        results[i] = new FeedControl(this.tenantService.getBaseName(fc.getSiteId()), fc.getAppToolId());
        i++;
    }
    return Context.getCurrentContext().newArray(getScope(), results);
}
Also used : FeedControl(org.alfresco.service.cmr.activities.FeedControl)

Example 2 with FeedControl

use of org.alfresco.service.cmr.activities.FeedControl in project alfresco-repository by Alfresco.

the class ActivityServiceImpl method getFeedControlsImpl.

private List<FeedControl> getFeedControlsImpl(String userId) {
    ParameterCheck.mandatoryString("userId", userId);
    if (!userNamesAreCaseSensitive) {
        userId = userId.toLowerCase();
    }
    try {
        List<FeedControlEntity> feedControlDaos = feedControlDAO.selectFeedControls(userId);
        if (logger.isDebugEnabled()) {
            logger.debug("Selecting feed controls for userId: " + userId);
        }
        List<FeedControl> feedControls = new ArrayList<FeedControl>(feedControlDaos.size());
        for (FeedControlEntity feedControlDao : feedControlDaos) {
            FeedControl feedCtrl = feedControlDao.getFeedControl();
            feedControls.add(feedCtrl);
            if (logger.isDebugEnabled()) {
                logger.debug("Found feed control for userId: " + userId + ",\n appToolId : " + feedCtrl.getAppToolId() + ",\n siteId: " + feedCtrl.getSiteId());
            }
        }
        return feedControls;
    } catch (SQLException e) {
        AlfrescoRuntimeException are = new AlfrescoRuntimeException("Failed to get feed controls: " + e, e);
        logger.error(are);
        throw are;
    }
}
Also used : FeedControlEntity(org.alfresco.repo.domain.activities.FeedControlEntity) SQLException(java.sql.SQLException) FeedControl(org.alfresco.service.cmr.activities.FeedControl) ArrayList(java.util.ArrayList) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

Example 3 with FeedControl

use of org.alfresco.service.cmr.activities.FeedControl in project alfresco-repository by Alfresco.

the class ActivityServiceImplTest method testFeedControls.

public void testFeedControls() throws Exception {
    List<FeedControl> feedControls = activityService.getFeedControls(USER_UN);
    assertNotNull(feedControls);
    assertTrue(feedControls.isEmpty());
    if (!authenticationService.authenticationExists(USER_UN)) {
        authenticationService.createAuthentication(USER_UN, USER_PW.toCharArray());
    }
    authenticationService.clearCurrentSecurityContext();
    authenticationService.authenticate(USER_UN, USER_PW.toCharArray());
    feedControls = activityService.getFeedControls();
    assertNotNull(feedControls);
    assertTrue(feedControls.isEmpty());
    assertFalse(activityService.existsFeedControl(new FeedControl("mySite1", "appTool1")));
    activityService.setFeedControl(new FeedControl("mySite1", null));
    activityService.setFeedControl(new FeedControl("mySite1", "appTool1"));
    activityService.setFeedControl(new FeedControl(null, "appTool2"));
    feedControls = activityService.getFeedControls();
    assertEquals(3, feedControls.size());
    feedControls = activityService.getFeedControls(USER_UN);
    assertEquals(3, feedControls.size());
    assertTrue(activityService.existsFeedControl(new FeedControl("mySite1", "appTool1")));
    activityService.unsetFeedControl(new FeedControl("mySite1", "appTool1"));
    assertFalse(activityService.existsFeedControl(new FeedControl("mySite1", "appTool1")));
    feedControls = activityService.getFeedControls();
    assertEquals(2, feedControls.size());
    activityService.unsetFeedControl(new FeedControl("mySite1", null));
    activityService.unsetFeedControl(new FeedControl(null, "appTool2"));
    feedControls = activityService.getFeedControls();
    assertEquals(0, feedControls.size());
}
Also used : FeedControl(org.alfresco.service.cmr.activities.FeedControl)

Aggregations

FeedControl (org.alfresco.service.cmr.activities.FeedControl)3 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)1 FeedControlEntity (org.alfresco.repo.domain.activities.FeedControlEntity)1