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);
}
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;
}
}
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());
}
Aggregations