Skip to content

Commit

Permalink
S2U-8 5.1.1.4 Tests & Quizzes: Tracking and reporting of delivery tim…
Browse files Browse the repository at this point in the history
…es for questions - fix
  • Loading branch information
JuanDavid102 authored and fadesta102 committed Feb 19, 2024
1 parent e9a1e7a commit 5e06079
Show file tree
Hide file tree
Showing 19 changed files with 208 additions and 193 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,55 +15,78 @@
*/
package org.sakaiproject.messaging.impl;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import javax.annotation.Resource;

import org.apache.ignite.IgniteMessaging;
import org.sakaiproject.ignite.EagerIgniteSpringBean;
import org.apache.ignite.IgniteSpringBean;
import org.apache.ignite.lang.IgniteBiPredicate;
import org.sakaiproject.messaging.api.MicrosoftMessage;
import org.sakaiproject.messaging.api.MicrosoftMessageListener;
import org.sakaiproject.messaging.api.MicrosoftMessagingService;

import lombok.AllArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class MicrosoftMessagingServiceImpl implements MicrosoftMessagingService {

@Resource
private EagerIgniteSpringBean ignite;

private IgniteMessaging messaging;

@Setter private IgniteSpringBean ignite;
private ExecutorService executor;
private IgniteMessaging messaging;

public void init() {
log.info("Initializing Microsoft Messaging Service");
private List<MessageTopic> messageTopics;

executor = Executors.newFixedThreadPool(20);
public MicrosoftMessagingServiceImpl() {
messageTopics = Collections.emptyList();
}

public void init() {
executor = Executors.newFixedThreadPool(10);
messaging = ignite.message(ignite.cluster().forLocal());
}

public void destroy() {
executor.shutdownNow();
messageTopics.forEach(t -> messaging.stopLocalListen(t.topic, t.predicate));
executor.shutdown();
}

public void listen(MicrosoftMessage.Topic topic, MicrosoftMessageListener listener) {
messaging.localListen(topic, (nodeId, message) -> {
executor.execute(() -> {
listener.read((MicrosoftMessage)message);
});
return true;
});
if (topic != null && listener != null) {
MessageTopic messageTopic = new MessageTopic(topic, (nodeId, message) -> {
executor.execute(() -> listener.read((MicrosoftMessage) message));
return true;
});

List<MessageTopic> updatedTopics = new ArrayList<>(messageTopics);
messaging.localListen(messageTopic.topic, messageTopic.predicate);
updatedTopics.add(messageTopic);
messageTopics = Collections.unmodifiableList(updatedTopics);
} else {
log.warn("Unable to register listener for topic [{}]", topic);
}
}

public void send(MicrosoftMessage.Topic topic, MicrosoftMessage msg) {
try {
messaging.send(topic, msg);
} catch(Exception e) {
log.error("Error sending MicrosoftMessage");
}
if (topic != null && msg != null) {
try {
messaging.send(topic, msg);
} catch (Exception e) {
log.warn("Could not send message for topic [{}], message [{}], {}", topic, msg, e.toString());
}
} else {
log.debug("skip sending message for topic [{}], {}", topic, msg);
}
}

@AllArgsConstructor
private class MessageTopic {
private MicrosoftMessage.Topic topic;
private IgniteBiPredicate<UUID, ?> predicate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

<bean id="org.sakaiproject.messaging.api.MicrosoftMessagingService"
class="org.sakaiproject.messaging.impl.MicrosoftMessagingServiceImpl"
init-method="init">
init-method="init"
destroy-method="destroy">
<property name="ignite" ref="org.sakaiproject.ignite.SakaiIgnite"/>
</bean>

<bean id="org.sakaiproject.springframework.orm.hibernate.impl.AdditionalHibernateMappings.bullhorns"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,14 @@
.form-control {
@include border-radius(0 $button-radius 0 0);
}
.form-control-center {
@include border-radius(0);
}
}

p.input-group-addon.input-group-addon-right {
@include border-radius(0 $button-radius 0 0);
}
&:last-of-type {
.input-group-addon {
@include border-radius(0 0 $button-radius $button-radius);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ public class MicrosoftAuthorizationServiceImpl implements MicrosoftAuthorization
private static final String CACHE_NAME = MicrosoftAuthorizationServiceImpl.class.getName() + "_cache";
private static final String CACHE_TOKENS = "key::tokens";

public void init() {
log.info("Initializing MicrosoftAuthorization Service");
}

private Cache getCache() {
if(cache == null) {
cache = cacheManager.getCache(CACHE_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,49 +136,33 @@
@Transactional
public class MicrosoftCommonServiceImpl implements MicrosoftCommonService {

private GraphServiceClient graphClient = null;

@Setter
MicrosoftConfigRepository microsoftConfigRepository;

@Setter
MicrosoftLoggingRepository microsoftLoggingRepository;

@Autowired
MicrosoftMessagingService microsoftMessagingService;

@Autowired
MicrosoftAuthorizationService microsoftAuthorizationService;

@Autowired
private SakaiProxy sakaiProxy;

@Setter
private FunctionManager functionManager;

@Setter
private CacheManager cacheManager;
private Cache cache = null;

private static final String CACHE_NAME = MicrosoftCommonServiceImpl.class.getName() + "_cache";
private static final String CACHE_TEAMS = "key::teams";
private static final String CACHE_CHANNELS = "key::channels::";
private static final String CACHE_RECORDINGS = "key::recordings::";
private static final String CACHE_DRIVE_ITEMS = "key::driveitems::";
private static final String CACHE_DRIVE_ITEMS_USER = "key::driveitems-user::";
private static final String CACHE_DRIVE_ITEMS_GROUP = "key::driveitems-group::";

private static final String PERMISSION_READ = "read";
private static final String PERMISSION_WRITE = "write";
private static final String LINK_TYPE_EDIT = "edit";
private static final String LINK_TYPE_VIEW = "view";
private static final String LINK_SCOPE_USERS = "users";

private String lock = "LOCK";


@Setter private CacheManager cacheManager;
@Setter private FunctionManager functionManager;
@Setter private MicrosoftAuthorizationService microsoftAuthorizationService;
@Setter private MicrosoftConfigRepository microsoftConfigRepository;
@Setter private MicrosoftLoggingRepository microsoftLoggingRepository;
@Setter private MicrosoftMessagingService microsoftMessagingService;
@Setter private SakaiProxy sakaiProxy;

private Cache cache = null;
private GraphServiceClient graphClient = null;
final private Object lock = new Object();

public void init() {
log.info("Initializing MicrosoftCommonService Service");

// register functions
functionManager.registerFunction(PERM_VIEW_ALL_CHANNELS, true);
functionManager.registerFunction(PERM_CREATE_FILES, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ public class MicrosoftConfigurationServiceImpl implements MicrosoftConfiguration
@Setter
MicrosoftConfigRepository microsoftConfigRepository;

public void init() {
log.info("Initializing MicrosoftConfigurationService Service");
}

//------------------------------ CREDENTIALS -------------------------------------------------------
public MicrosoftCredentials getCredentials() {
return microsoftConfigRepository.getCredentials();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ public class MicrosoftLoggingServiceImpl implements MicrosoftLoggingService {
@Setter
MicrosoftLoggingRepository microsoftLoggingRepository;

public void init() {
log.info("Initializing MicrosoftLoggingService Service");
}

@Override
public void saveLog(MicrosoftLog log) {
microsoftLoggingRepository.save(log);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import org.sakaiproject.tool.api.Session;
import org.sakaiproject.tool.api.SessionManager;
import org.sakaiproject.user.api.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import lombok.Setter;
Expand All @@ -69,38 +68,21 @@
@Transactional
public class MicrosoftSynchronizationServiceImpl implements MicrosoftSynchronizationService {

@Setter
MicrosoftSiteSynchronizationRepository microsoftSiteSynchronizationRepository;

@Setter
MicrosoftGroupSynchronizationRepository microsoftGroupSynchronizationRepository;

@Setter
MicrosoftConfigRepository microsoftConfigRepository;

@Setter
MicrosoftLoggingRepository microsoftLoggingRepository;

@Autowired
private MicrosoftCommonService microsoftCommonService;

@Autowired
private SakaiProxy sakaiProxy;

@Autowired
private SessionManager sessionManager;

@Autowired
private MicrosoftMessagingService microsoftMessagingService;
@Setter private MicrosoftCommonService microsoftCommonService;
@Setter private MicrosoftConfigRepository microsoftConfigRepository;
@Setter private MicrosoftGroupSynchronizationRepository microsoftGroupSynchronizationRepository;
@Setter private MicrosoftLoggingRepository microsoftLoggingRepository;
@Setter private MicrosoftMessagingService microsoftMessagingService;
@Setter private MicrosoftSiteSynchronizationRepository microsoftSiteSynchronizationRepository;
@Setter private SakaiProxy sakaiProxy;
@Setter private SessionManager sessionManager;

//used in hooks. Sometimes we need to stop listening some events
private Set<String> disabledGroupListeners = ConcurrentHashMap.newKeySet();
//used in hooks to synchronize. "add users to group" must happen after "create group"
private ConcurrentHashMap<String, Object> newGroupLock = new ConcurrentHashMap<>();

public void init() {
log.info("Initializing MicrosoftSynchService Service");

microsoftMessagingService.listen(MicrosoftMessage.Topic.CREATE_ELEMENT, message -> {
printMessage(MicrosoftMessage.Topic.CREATE_ELEMENT, message);
elementCreated(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,43 +67,18 @@
@Transactional
public class SakaiProxyImpl implements SakaiProxy {

@Autowired
private SecurityService securityService;

@Autowired
private SiteService siteService;

@Autowired
private ToolManager toolManager;

@Autowired
private UserDirectoryService userDirectoryService;

@Autowired
private SessionManager sessionManager;

@Autowired
private PreferencesService preferencesService;

@Autowired
private CalendarService calendarService;

@Autowired
private TimeService timeService;

@Setter
private UserTimeService userTimeService;

@Autowired
private EmailService emailService;

@Autowired
private ServerConfigurationService serverConfigurationService;
@Setter private CalendarService calendarService;
@Setter private EmailService emailService;
@Setter private PreferencesService preferencesService;
@Setter private SecurityService securityService;
@Setter private ServerConfigurationService serverConfigurationService;
@Setter private SessionManager sessionManager;
@Setter private SiteService siteService;
@Setter private TimeService timeService;
@Setter private ToolManager toolManager;
@Setter private UserDirectoryService userDirectoryService;
@Setter private UserTimeService userTimeService;

public void init() {
log.info("Initializing Sakai Proxy");
}

// ------------------------------------------ SECURITY ----------------------------------------------------
@Override
public boolean isAdmin() {
Expand Down
Loading

0 comments on commit 5e06079

Please sign in to comment.