Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private List<UserNotificationData> handleAdd(String from, String siteId, String
if (groupIds.isEmpty() || groupsUsers.contains(to)) {
if (!from.equals(to) && !securityService.isSuperUser(to)) {
String url = assignmentService.getDeepLink(siteId, assignmentId, to);
bhEvents.add(new UserNotificationData(from, to, siteId, title, url, AssignmentConstants.TOOL_ID));
bhEvents.add(new UserNotificationData(from, to, siteId, title, url, AssignmentConstants.TOOL_ID, false, null));
}
}
}
Expand Down Expand Up @@ -164,7 +164,7 @@ private List<UserNotificationData> handleUpdateAccess(String from, String ref, S
String to = u.getId();
if (!from.equals(to) && !securityService.isSuperUser(to)) {
String url = assignmentService.getDeepLink(siteId, assignmentId, to);
bhEvents.add(new UserNotificationData(from, to, siteId, title, url, AssignmentConstants.TOOL_ID));
bhEvents.add(new UserNotificationData(from, to, siteId, title, url, AssignmentConstants.TOOL_ID, false, null));
}
}
} else {
Expand All @@ -178,7 +178,7 @@ private List<UserNotificationData> handleUpdateAccess(String from, String ref, S
String to = u.getId();
if (!from.equals(to) && !securityService.isSuperUser(to)) {
String url = assignmentService.getDeepLink(siteId, assignmentId, to);
bhEvents.add(new UserNotificationData(from, to, siteId, title, url, AssignmentConstants.TOOL_ID));
bhEvents.add(new UserNotificationData(from, to, siteId, title, url, AssignmentConstants.TOOL_ID, false, null));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public Optional<List<UserNotificationData>> handleEvent(Event e) {
try {
String url = assignmentService.getDeepLink(siteId, assignment.getId(), to.getSubmitter());
if (StringUtils.isNotBlank(url)) {
bhEvents.add(new UserNotificationData(from, to.getSubmitter(), siteId, title, url, AssignmentConstants.TOOL_ID));
bhEvents.add(new UserNotificationData(from, to.getSubmitter(), siteId, title, url, AssignmentConstants.TOOL_ID, false, null));
}
} catch(Exception exc) {
log.error("Error retrieving deep link for assignment {} and user {} on site {}", assignment.getId(), to.getSubmitter(), siteId, exc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public Optional<List<UserNotificationData>> handleEvent(Event e) {

// First, send an alert to the post author
if (!commentCreator.equals(postCreator)) {
bhEvents.add(new UserNotificationData(commentCreator, postCreator, siteId, siteTitle, url, CommonsConstants.TOOL_ID));
bhEvents.add(new UserNotificationData(commentCreator, postCreator, siteId, siteTitle, url, CommonsConstants.TOOL_ID, false, null));
}

List<String> sentAlready = new ArrayList<>();
Expand All @@ -107,7 +107,7 @@ public Optional<List<UserNotificationData>> handleEvent(Event e) {
}

if (!sentAlready.contains(to)) {
bhEvents.add(new UserNotificationData(commentCreator, to, siteId, siteTitle, url, CommonsConstants.TOOL_ID));
bhEvents.add(new UserNotificationData(commentCreator, to, siteId, siteTitle, url, CommonsConstants.TOOL_ID, false, null));
sentAlready.add(to);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2255,6 +2255,10 @@
# DEFAULT: false
# announcement.notification.email.to.matches.from=true

# Controls how long a MOTD user notification lives, in hours, before being cleaned up
# DEFAULT: 24
# announcement.motd.notification.ttlhours=1

## BASICLTI PROVIDER

# Enable the Provider
Expand Down Expand Up @@ -5765,3 +5769,7 @@
# on a production system. If there is no PNP base URL, this value has no effect.
# lti.pnp.use_email=false
# DEFAULT: false

# Configure the thread pool size for the scheduling service.
# DEFAULT: 4
# schedulingservice.poolsize=2
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Set;

import org.sakaiproject.user.api.User;
import org.sakaiproject.messaging.api.UserNotificationData;
import org.sakaiproject.messaging.api.model.UserNotification;

/**
Expand Down Expand Up @@ -62,7 +63,7 @@ public interface UserMessagingService {
/**
* @return the list of notifications for the current user
*/
public List<UserNotification> getNotifications();
public List<UserNotificationTransferBean> getNotifications();

/**
* Register a handler for broadcast messages. The first registered handler that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@
*/
package org.sakaiproject.messaging.api;

import java.time.Duration;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Data;

@AllArgsConstructor @Getter
@AllArgsConstructor
@NoArgsConstructor
@Data
public class UserNotificationData {

private String from;
Expand All @@ -27,4 +32,6 @@ public class UserNotificationData {
private String title;
private String url;
private String commonToolId;
private boolean broadcast;
private Duration ttl;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Copyright (c) 2003-2019 The Apereo Foundation
*
* Licensed under the Educational Community License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://opensource.org/licenses/ecl2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sakaiproject.messaging.api;

import org.sakaiproject.messaging.api.model.UserNotification;

import java.time.Instant;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Data;

public class UserNotificationTransferBean {

public String from;
public String to;
public String event;
public String ref;
public String title;
public String siteId;
public String url;
public Instant eventDate;
public boolean viewed;
public String tool;
public boolean broadcast;

public String fromDisplayName;
public String siteTitle;
public String formattedEventDate;

public static UserNotificationTransferBean of(UserNotification un) {

UserNotificationTransferBean bean = new UserNotificationTransferBean();
bean.from = un.getFromUser();
bean.to = un.getToUser();
bean.event = un.getEvent();
bean.ref = un.getRef();
bean.title = un.getTitle();
bean.siteId = un.getSiteId();
bean.url = un.getUrl();
bean.eventDate = un.getEventDate();
bean.viewed = un.getViewed();
bean.tool = un.getTool();
bean.broadcast = un.getBroadcast();
return bean;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import javax.persistence.Index;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.sakaiproject.springframework.data.PersistableEntity;

Expand Down Expand Up @@ -68,13 +67,17 @@ public class UserNotification implements PersistableEntity<Long> {
@Column(name="SITE_ID", length = 99)
private String siteId;

@Column(name="URL", length = 2048, nullable = false)
@Column(name="URL", length = 2048)
private String url;

@Column(name="EVENT_DATE", nullable = false)
@Type(type = "org.hibernate.type.InstantType")
private Instant eventDate;

@Column(name="END_DATE")
@Type(type = "org.hibernate.type.InstantType")
private Instant endDate;

@Column(name="DEFERRED", nullable = false)
private Boolean deferred = Boolean.FALSE;

Expand All @@ -84,12 +87,6 @@ public class UserNotification implements PersistableEntity<Long> {
@Column(name = "TOOL", length = 99)
private String tool;

@Transient
private String fromDisplayName;

@Transient
private String formattedEventDate;

@Transient
private String siteTitle;
@Column(name = "BROADCAST")
private Boolean broadcast = Boolean.FALSE;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
public interface UserNotificationRepository extends SpringCrudRepository<UserNotification, Long> {

List<UserNotification> findByToUser(String toUser);
List<UserNotification> findByBroadcast(boolean broadcast);
int deleteByToUserAndDeferred(String userId, boolean deferred);
int deleteExpiredNotifications();
int setAllNotificationsViewed(String userId, String siteId, String toolId);
int setDeferredBySiteId(String siteId, boolean deferred);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Copyright (c) 2003-2017 The Apereo Foundation
*
* Licensed under the Educational Community License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://opensource.org/licenses/ecl2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sakaiproject.scheduling.api;

import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

/**
* A facade for Java's ScheduledExecutorService. The number of threads in the pool can be configured
* using the property <code>schedulingservice.poolsize"</code>
*/
public interface SchedulingService {

/**
* Schedule the Runnable to be executed after delay units, that is delay number of time units.
*
* @param command The command to run
* @param delay The time, in units, to wait until execution of command
* @param unit The type of time unit to use.
*/
ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit);

/**
* Schedule the Runnable to be executed after initialDelay units and then every delay units
* thereafter.
*
* @param command The command to run
* @param initialDelay The time, in units, to wait until execution of command
* @param delay The time, in units, to wait between each further execution of command
* @param unit The type of time unit to use.
*/
ScheduledFuture<?> scheduleWithFixedDelay(Runnable command,
long initialDelay,
long delay,
TimeUnit unit);
}


Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.sakaiproject.entity.api.EntityManager;
import org.sakaiproject.event.api.EventTrackingService;
import org.sakaiproject.messaging.api.MicrosoftMessagingService;
import org.sakaiproject.scheduling.api.SchedulingService;
import org.sakaiproject.time.api.TimeService;
import org.sakaiproject.user.api.UserDirectoryService;
import org.sakaiproject.tool.api.SessionManager;
Expand All @@ -49,6 +50,14 @@ protected SqlService sqlService()
return null;
}

/**
* @return the SchedulingService collaborator.
*/
protected SchedulingService schedulingService()
{
return null;
}

/**
* @return the ServerConfigurationService collaborator.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
import java.util.Observer;
import java.util.Set;
import java.util.Vector;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import org.apache.commons.lang3.StringUtils;
Expand All @@ -62,6 +60,7 @@
import org.sakaiproject.javax.PagingPosition;
import org.sakaiproject.memory.api.Cache;
import org.sakaiproject.memory.api.MemoryService;
import org.sakaiproject.scheduling.api.SchedulingService;
import org.sakaiproject.site.api.SiteService;
import org.sakaiproject.user.api.UserNotDefinedException;
import org.sakaiproject.util.BaseDbFlatStorage;
Expand Down Expand Up @@ -126,6 +125,9 @@ public abstract class DbAuthzGroupService extends BaseAuthzGroupService implemen
protected boolean m_promoteUsersToProvided = true;
protected boolean m_promoteUsersToProvidedRole = false;
private MemoryService m_memoryService;

protected abstract SchedulingService schedulingService();

// KNL-600 CACHING for the realm role groups
private Cache m_realmRoleGRCache;

Expand All @@ -151,9 +153,6 @@ public abstract class DbAuthzGroupService extends BaseAuthzGroupService implemen
*/
private long refreshMaxTime = 15;

/** Executor used to schedule processing */
private ScheduledExecutorService refreshScheduler;

/** Queue of authzgroups to refresh used by refreshAuthzGroupTask */
private Map<String, AuthzGroup> refreshQueue;

Expand Down Expand Up @@ -289,8 +288,7 @@ public void init()

refreshQueue = Collections.synchronizedMap(new LinkedHashMap<>());

refreshScheduler = Executors.newSingleThreadScheduledExecutor();
refreshScheduler.scheduleWithFixedDelay(
schedulingService().scheduleWithFixedDelay(
new RefreshAuthzGroupTask(),
120, // minimally wait 2 mins for sakai to start
refreshTaskInterval, // delay before running again
Expand Down Expand Up @@ -325,8 +323,6 @@ private long initConfig(String propkey, String scsValue, long currentValue) {
*/
public void destroy()
{
refreshScheduler.shutdown();

// done with event watching
eventTrackingService().deleteObserver(this);

Expand Down
Loading
Loading