use of org.olat.basesecurity.BaseSecurity in project OpenOLAT by OpenOLAT.
the class CatalogTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
id1 = JunitTestHelper.createAndPersistIdentityAsUser("rest-catalog-one");
JunitTestHelper.createAndPersistIdentityAsUser("rest-catalog-two");
BaseSecurity securityManager = BaseSecurityManager.getInstance();
admin = securityManager.findIdentityByName("administrator");
// create a catalog
root1 = catalogManager.getRootCatalogEntries().get(0);
entry1 = catalogManager.createCatalogEntry();
entry1.setType(CatalogEntry.TYPE_NODE);
entry1.setName("Entry-1");
entry1.setDescription("Entry-description-1");
entry1.setOwnerGroup(securityManager.createAndPersistSecurityGroup());
catalogManager.addCatalogEntry(root1, entry1);
DBFactory.getInstance().intermediateCommit();
entry1 = catalogManager.loadCatalogEntry(entry1);
securityManager.addIdentityToSecurityGroup(admin, entry1.getOwnerGroup());
subEntry11 = catalogManager.createCatalogEntry();
subEntry11.setType(CatalogEntry.TYPE_NODE);
subEntry11.setName("Sub-entry-11");
subEntry11.setDescription("Sub-entry-description-11");
catalogManager.addCatalogEntry(entry1, subEntry11);
subEntry12 = catalogManager.createCatalogEntry();
subEntry12.setType(CatalogEntry.TYPE_NODE);
subEntry12.setName("Sub-entry-12");
subEntry12.setDescription("Sub-entry-description-12");
catalogManager.addCatalogEntry(entry1, subEntry12);
entry2 = catalogManager.createCatalogEntry();
entry2.setType(CatalogEntry.TYPE_NODE);
entry2.setName("Entry-2");
entry2.setDescription("Entry-description-2");
catalogManager.addCatalogEntry(root1, entry2);
entryToMove1 = catalogManager.createCatalogEntry();
entryToMove1.setType(CatalogEntry.TYPE_NODE);
entryToMove1.setName("Entry-1-to-move");
entryToMove1.setDescription("Entry-description-1-to-move");
catalogManager.addCatalogEntry(root1, entryToMove1);
entryToMove2 = catalogManager.createCatalogEntry();
entryToMove2.setType(CatalogEntry.TYPE_NODE);
entryToMove2.setName("Entry-2-to-move");
entryToMove2.setDescription("Entry-description-2-to-move");
catalogManager.addCatalogEntry(root1, entryToMove2);
subEntry13move = catalogManager.createCatalogEntry();
subEntry13move.setType(CatalogEntry.TYPE_NODE);
subEntry13move.setName("Sub-entry-13-move target");
subEntry13move.setDescription("Sub-entry-description-13-move target");
catalogManager.addCatalogEntry(root1, subEntry13move);
DBFactory.getInstance().intermediateCommit();
}
use of org.olat.basesecurity.BaseSecurity in project OpenOLAT by OpenOLAT.
the class NotificationsWebService method subscribe.
@PUT
@Path("subscribers")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response subscribe(PublisherVO publisherVO, @Context HttpServletRequest request) {
if (!isAdmin(request)) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
NotificationsManager notificationsMgr = NotificationsManager.getInstance();
BaseSecurity securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
SubscriptionContext subscriptionContext = new SubscriptionContext(publisherVO.getResName(), publisherVO.getResId(), publisherVO.getSubidentifier());
PublisherData publisherData = new PublisherData(publisherVO.getType(), publisherVO.getData(), publisherVO.getBusinessPath());
List<UserVO> userVoes = publisherVO.getUsers();
List<Long> identityKeys = new ArrayList<>();
for (UserVO userVo : userVoes) {
identityKeys.add(userVo.getKey());
}
List<Identity> identities = securityManager.loadIdentityByKeys(identityKeys);
notificationsMgr.subscribe(identities, subscriptionContext, publisherData);
return Response.ok().build();
}
use of org.olat.basesecurity.BaseSecurity in project OpenOLAT by OpenOLAT.
the class DENManager method removeDateInUserCalendar.
/**
* Removes this event in all calendars of enrolled users
* @param oldEvent
*/
private void removeDateInUserCalendar(KalendarEvent oldEvent) {
String[] participants = oldEvent.getParticipants();
// no users to update, cancel
if (participants == null)
return;
BaseSecurity manager = BaseSecurityManager.getInstance();
CalendarManager calManager = CoreSpringFactory.getImpl(CalendarManager.class);
for (String participant : participants) {
Identity identity = manager.findIdentityByName(participant);
if (identity != null) {
Kalendar userCal = calManager.getPersonalCalendar(identity).getKalendar();
List<KalendarEvent> userEvents = new ArrayList<>();
userEvents.addAll(userCal.getEvents());
for (KalendarEvent userEvent : userEvents) {
String sourceNodeId = userEvent.getSourceNodeId();
if (sourceNodeId != null && sourceNodeId.equals(oldEvent.getSourceNodeId())) {
calManager.removeEventFrom(userCal, userEvent);
}
}
}
}
}
use of org.olat.basesecurity.BaseSecurity in project OpenOLAT by OpenOLAT.
the class DENManager method getSelectedEventParticipants.
/**
* Little helper method, that gives you all participants of the selected events in the list
* @param dataList
* @param selection BitSet
* @return list of Identities
*/
protected List<Identity> getSelectedEventParticipants(List<KalendarEvent> dataList, BitSet selection) {
List<Identity> identities = new ArrayList<Identity>();
BaseSecurity manager = BaseSecurityManager.getInstance();
for (int i = 0; i < dataList.size(); i++) {
if (selection.get(i)) {
String[] parts = dataList.get(i).getParticipants();
if (parts != null) {
for (String participant : parts) {
Identity identity = manager.findIdentityByName(participant);
if (identity != null) {
identities.add(identity);
}
}
}
}
}
return identities;
}
use of org.olat.basesecurity.BaseSecurity in project OpenOLAT by OpenOLAT.
the class DENManager method addDateInUserCalendar.
/**
* Add this event in the calendar of an enrolled user
* @param newEvent
*/
private void addDateInUserCalendar(KalendarEvent newEvent) {
String[] participants = newEvent.getParticipants();
// no users to update, cancel
if (participants == null)
return;
BaseSecurity manager = BaseSecurityManager.getInstance();
CalendarManager calManager = CoreSpringFactory.getImpl(CalendarManager.class);
for (String participant : participants) {
Identity identity = manager.findIdentityByName(participant);
if (identity != null) {
Kalendar userCal = calManager.getPersonalCalendar(identity).getKalendar();
List<KalendarEvent> userEvents = new ArrayList<>();
userEvents.addAll(userCal.getEvents());
String eventId = CodeHelper.getGlobalForeverUniqueID();
KalendarEvent userNewEvent = new KalendarEvent(eventId, null, newEvent.getSubject(), newEvent.getBegin(), newEvent.getEnd());
userNewEvent.setLocation(newEvent.getLocation());
userNewEvent.setSourceNodeId(newEvent.getSourceNodeId());
userNewEvent.setClassification(KalendarEvent.CLASS_PRIVATE);
List<KalendarEventLink> kalendarEventLinks = userNewEvent.getKalendarEventLinks();
kalendarEventLinks.clear();
kalendarEventLinks.addAll(newEvent.getKalendarEventLinks());
calManager.addEventTo(userCal, userNewEvent);
}
}
}
Aggregations