use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.
the class NewRepositoryEventAdapter method toSocial.
@Override
public SocialActivitiesEvent toSocial(Object object) {
NewRepositoryEvent event = (NewRepositoryEvent) object;
SocialUser socialUser = null;
try {
socialUser = socialUserRepositoryAPI.findSocialUser(loggedUser.getIdentifier());
} catch (ContextNotActiveException e) {
// clean repository
socialUser = new SocialUser("system");
}
String additionalInfo = "Created";
return new SocialActivitiesEvent(socialUser, ExtendedTypes.NEW_REPOSITORY_EVENT, new Date()).withAdicionalInfo(additionalInfo).withLink(event.getNewRepository().getAlias(), event.getNewRepository().getUri()).withDescription("");
}
use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.
the class ResourceUpdatedEventAdapter method toSocial.
@Override
public SocialActivitiesEvent toSocial(Object object) {
ResourceUpdatedEvent event = (ResourceUpdatedEvent) object;
SocialUser socialUser = socialUserRepositoryAPI.findSocialUser(event.getSessionInfo().getIdentity().getIdentifier());
String additionalInfo = "Edited";
String description = getCommitDescription(event);
return new SocialActivitiesEvent(socialUser, HomePageTypes.RESOURCE_UPDATE_EVENT.name(), new Date()).withLink(event.getPath().getFileName(), event.getPath().toURI()).withAdicionalInfo(additionalInfo).withDescription(description);
}
use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.
the class SocialEventModuleConstraintTest method hasNoRestrictionsTest.
@Test
public void hasNoRestrictionsTest() throws Exception {
final WorkspaceProject project = mock(WorkspaceProject.class);
Repository repository = mock(Repository.class);
doReturn(repository).when(project).getRepository();
when(authorizationManager.authorize(repository, user)).thenReturn(true);
eventProject = project;
final SocialActivitiesEvent vfsEvent = new SocialActivitiesEvent(socialUser, "type", new Date());
final SocialActivitiesEvent moduleEvent = new SocialActivitiesEvent(socialUser, OrganizationalUnitEventType.NEW_ORGANIZATIONAL_UNIT, new Date()).withLink("otherName", "otherName", SocialActivitiesEvent.LINK_TYPE.CUSTOM);
socialEventModuleConstraint.init();
assertFalse(socialEventModuleConstraint.hasRestrictions(vfsEvent));
assertFalse(socialEventModuleConstraint.hasRestrictions(moduleEvent));
}
use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.
the class SocialEventModuleConstraintTest method ifThereIsNoLoggedUserInScopeShouldNotHaveRestrictions.
@Test
public void ifThereIsNoLoggedUserInScopeShouldNotHaveRestrictions() throws Exception {
when(userCDIContextHelper.thereIsALoggedUserInScope()).thenReturn(false);
final SocialActivitiesEvent restrictedEvent = new SocialActivitiesEvent(socialUser, OrganizationalUnitEventType.NEW_ORGANIZATIONAL_UNIT, new Date()).withLink("otherName", "otherName");
socialEventModuleConstraint.init();
assertFalse(socialEventModuleConstraint.hasRestrictions(restrictedEvent));
}
use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.
the class SocialEventModuleConstraintTest method hasNoRestrictionsForOtherSocialEventsTest.
@Test
public void hasNoRestrictionsForOtherSocialEventsTest() throws Exception {
final WorkspaceProject project = mock(WorkspaceProject.class);
eventProject = project;
final SocialActivitiesEvent customEventOtherType = new SocialActivitiesEvent(socialUser, "type", new Date()).withLink("link", "link", SocialActivitiesEvent.LINK_TYPE.CUSTOM);
assertFalse(socialEventModuleConstraint.hasRestrictions(customEventOtherType));
}
Aggregations