-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add PUT route * Add PUT to notification service * Change startTime and endTime to long
- Loading branch information
1 parent
5b0bd32
commit 92bf949
Showing
10 changed files
with
87 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/java/teammates/ui/request/NotificationCreateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package teammates.ui.request; | ||
|
||
/** | ||
* The request for creating a notification. | ||
*/ | ||
public class NotificationCreateRequest extends NotificationBasicRequest { | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/teammates/ui/request/NotificationUpdateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package teammates.ui.request; | ||
|
||
/** | ||
* The request for updating a notification. | ||
*/ | ||
public class NotificationUpdateRequest extends NotificationBasicRequest { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/teammates/ui/webapi/UpdateNotificationAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package teammates.ui.webapi; | ||
|
||
import java.time.Instant; | ||
|
||
import teammates.common.datatransfer.attributes.NotificationAttributes; | ||
import teammates.common.datatransfer.attributes.NotificationAttributes.UpdateOptions; | ||
import teammates.common.exception.EntityDoesNotExistException; | ||
import teammates.common.exception.InvalidParametersException; | ||
import teammates.common.util.Const; | ||
import teammates.ui.output.NotificationData; | ||
import teammates.ui.request.InvalidHttpRequestBodyException; | ||
import teammates.ui.request.NotificationUpdateRequest; | ||
|
||
/** | ||
* Action: Updates a new notification banner. | ||
*/ | ||
public class UpdateNotificationAction extends AdminOnlyAction { | ||
|
||
@Override | ||
public JsonResult execute() throws InvalidHttpRequestBodyException { | ||
String notificationId = getNonNullRequestParamValue(Const.ParamsNames.NOTIFICATION_ID); | ||
NotificationUpdateRequest notificationRequest = getAndValidateRequestBody(NotificationUpdateRequest.class); | ||
|
||
Instant startTime = Instant.ofEpochMilli(notificationRequest.getStartTimestamp()); | ||
Instant endTime = Instant.ofEpochMilli(notificationRequest.getEndTimestamp()); | ||
|
||
UpdateOptions newNotification = NotificationAttributes.updateOptionsBuilder(notificationId) | ||
.withStartTime(startTime) | ||
.withEndTime(endTime) | ||
.withType(notificationRequest.getNotificationType()) | ||
.withTargetUser(notificationRequest.getTargetUser()) | ||
.withTitle(notificationRequest.getTitle()) | ||
.withMessage(notificationRequest.getMessage()) | ||
.build(); | ||
|
||
try { | ||
return new JsonResult(new NotificationData(logic.updateNotification(newNotification))); | ||
} catch (InvalidParametersException e) { | ||
throw new InvalidHttpRequestBodyException(e); | ||
} catch (EntityDoesNotExistException ednee) { | ||
throw new EntityNotFoundException(ednee); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters