Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] APIM Portal Notifications #12438

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
48d2a01
Implement Notification insertion logic for workflows
HelaniUdara Jan 17, 2024
50ece22
Implement Publisher Notification backend with APIs
HelaniUdara Feb 19, 2024
ee1f885
Change existing test cases to suppress sendPortalNotifications()
HelaniUdara Feb 28, 2024
d346348
Implement Developer Notification backend with APIs
HelaniUdara Feb 29, 2024
21eb9c5
Add new column to store portal to display and change existing code ac…
HelaniUdara Mar 15, 2024
390ca5d
Complete getAllUsersBelongToGroup and getSubscribersOfApi functions
HelaniUdara Mar 21, 2024
4a89dfb
Set the total notification count
HelaniUdara Mar 26, 2024
c6cf38b
Implement method to get the unread notification count
HelaniUdara Mar 28, 2024
99db48b
Stop duplicating the subscriber
HelaniUdara Mar 28, 2024
f58c242
Add license headers, format code, remove unwanted spaces and imports
HelaniUdara Apr 26, 2024
43cdcac
Modify to try with resources and replace logs with exception handling…
HelaniUdara Apr 28, 2024
71951be
Replace reusable string values with constant values
HelaniUdara Apr 28, 2024
8586d19
Change deleteNotification method name to deleteNotificationById
HelaniUdara Apr 29, 2024
977288e
Add unit tests
HelaniUdara Apr 30, 2024
0cbb090
Handle APIManagement Exception within the sendPortalNotifications method
HelaniUdara Apr 30, 2024
011879e
Modify based on review comments
HelaniUdara Apr 30, 2024
9f0da3b
Modify code
HelaniUdara May 1, 2024
e30488c
Add Notification tables to all types of DBs
HelaniUdara May 2, 2024
898d5d6
Update the code
HelaniUdara May 2, 2024
26b4cd4
Update the code
HelaniUdara May 13, 2024
80024b0
Modify the code
HelaniUdara May 13, 2024
e79744a
Format the code
HelaniUdara May 13, 2024
b7ef050
Update
HelaniUdara May 14, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import org.wso2.carbon.apimgt.api.model.Identifier;
import org.wso2.carbon.apimgt.api.model.KeyManagerApplicationInfo;
import org.wso2.carbon.apimgt.api.model.Monetization;
import org.wso2.carbon.apimgt.api.model.NotificationList;
import org.wso2.carbon.apimgt.api.model.Notification;
import org.wso2.carbon.apimgt.api.model.OAuthApplicationInfo;
import org.wso2.carbon.apimgt.api.model.ResourceFile;
import org.wso2.carbon.apimgt.api.model.Scope;
Expand Down Expand Up @@ -869,4 +871,64 @@ boolean isKeyManagerByNameAllowedForUser(String keyManagerName, String organizat
* @throws APIManagementException
*/
boolean removalKeys(Application application, String keyMappingId, String xWSO2Tenant) throws APIManagementException;

/**
* Method to get notifications for the given user
*
* @param username username of the logged in user
* @param organization organization of the logged in user
* @param portalToDisplay the portal user needs to see the notifications
* @param sortOrder sort order of the notifications
* @param limit limit of the notifications
* @param offset offset of the notifications
* @return NotificationList
*/
NotificationList getNotifications(String username, String organization, String portalToDisplay, String sortOrder,
Integer limit, Integer offset) throws APIManagementException;

/**
* Method to mark all notifications as read
*
* @param username username of the logged in user
* @param organization organization of the logged in user
* @param portalToDisplay the portal user needs to update the notifications
* @return updated NotificationList
*/
NotificationList markAllNotificationsAsRead(String username, String organization, String portalToDisplay)
throws APIManagementException;

/**
* Method to mark a notification as read
*
* @param username username of the logged in user
* @param organization organization of the logged in user
* @param notificationId id of the notification that needs to update the mark as read status
* @param portalToDisplay the portal user needs to update the notification
* @return updated Notification
*/
Notification markNotificationAsReadById(String username, String organization, String notificationId,
String portalToDisplay) throws APIManagementException;

/**
* Method to delete a notification by notification id
*
* @param username username of the logged in user
* @param organization organization of the logged in user
* @param notificationId id of the notification that needs to delete
* @param portalToDisplay the portal user needs to delete the notification
* @return true after successful deletion
*/
boolean deleteNotificationById(String username, String organization, String notificationId, String portalToDisplay)
throws APIManagementException;

/**
* Method to delete the notifications of a given user
*
* @param username username of the logged in user
* @param organization organization of the logged in user
* @param portalToDisplay the portal user needs to delete the notifications
* @return true after successful deletion
*/
boolean deleteAllNotifications(String username, String organization, String portalToDisplay)
throws APIManagementException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -1908,4 +1908,65 @@ boolean isPolicyMetadataExists(String gatewayPolicyMappingId)
* @throws APIManagementException
*/
int getPolicyUsageByPolicyUUIDInGatewayPolicies(String commonPolicyUUID) throws APIManagementException;

/**
* Method to get notifications for the given user
*
* @param username username of the logged in user
* @param organization organization of the logged in user
* @param portalToDisplay the portal user needs to see the notifications
* @param sortOrder sort order of the notifications
* @param limit limit of the notifications
* @param offset offset of the notifications
* @return NotificationList
*/
NotificationList getNotifications(String username, String organization, String portalToDisplay, String sortOrder,
Integer limit, Integer offset) throws APIManagementException;

/**
* Method to delete the notifications of a given user
*
* @param username username of the logged in user
* @param organization organization of the logged in user
* @param portalToDisplay the portal user needs to delete the notifications
* @return true after successful deletion
*/
boolean deleteAllNotifications(String username, String organization, String portalToDisplay)
throws APIManagementException;

/**
* Method to mark a notification as read
*
* @param username username of the logged in user
* @param organization organization of the logged in user
* @param notificationId id of the notification that needs to update the mark as read status
* @param portalToDisplay the portal user needs to update the notification
* @return updated Notification
*/
Notification markNotificationAsReadById(String username, String organization, String notificationId,
String portalToDisplay) throws APIManagementException;

/**
* Method to delete a notification by notification id
*
* @param username username of the logged in user
* @param organization organization of the logged in user
* @param notificationId id of the notification that needs to delete
* @param portalToDisplay the portal user needs to delete the notification
* @return true after successful deletion
*/
boolean deleteNotificationById(String username, String organization, String notificationId, String portalToDisplay)
throws APIManagementException;

/**
* Method to mark all notifications as read
*
* @param username username of the logged in user
* @param organization organization of the logged in user
* @param portalToDisplay the portal user needs to update the notifications
* @return updated NotificationList
*/
NotificationList markAllNotificationsAsRead(String username, String organization, String portalToDisplay)
throws APIManagementException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 LLC. licenses this file to you under the Apache 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://www.apache.org/licenses/LICENSE-2.0
*
* 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.wso2.carbon.apimgt.api.model;

public class Notification {
private String notificationId;
private String notificationType;
private String comments;
private String createdTime;
private Boolean isRead;

public String getNotificationId() {
return notificationId;
}

public void setNotificationId(String notificationId) {
this.notificationId = notificationId;
}

public String getNotificationType() {
return notificationType;
}

public void setNotificationType(String notificationType) {
this.notificationType = notificationType;
}

public String getComments() {
return comments;
}

public void setComments(String comments) {
this.comments = comments;
}

public String getCreatedTime() {
return createdTime;
}

public void setCreatedTime(String createdTime) {
this.createdTime = createdTime;
}

public Boolean getIsRead() {
return isRead;
}

public void setIsRead(Boolean read) {
this.isRead = read;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 LLC. licenses this file to you under the Apache 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://www.apache.org/licenses/LICENSE-2.0
*
* 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.wso2.carbon.apimgt.api.model;

import java.util.ArrayList;
import java.util.List;

public class NotificationList {

private Integer count = null;
private List<Notification> list = new ArrayList<Notification>();
private Pagination pagination = null;

private Integer unreadCount = null;

public Integer getCount() {
return count;
}

public void setCount(Integer count) {
this.count = count;
}

public List<Notification> getList() {
return list;
}

public void setList(List<Notification> list) {
this.list = list;
}

public Pagination getPagination() {
return pagination;
}

public void setPagination(Pagination pagination) {
this.pagination = pagination;
}

public Integer getUnreadCount() { return unreadCount; }

public void setUnreadCount(Integer unreadCount) { this.unreadCount = unreadCount; }

}
Original file line number Diff line number Diff line change
Expand Up @@ -1729,6 +1729,8 @@ private ConfigParameters() {
public static final String DEPLOY_AS_A_PROTOTYPE = "Deploy as a Prototype";
public static final String REPUBLISH = "Re-Publish";

public static final String RETIRE = "Retire";

public static final String API_SPEC_TYPE_REST = "api_spec";
public static final String API_SPEC_TYPE_GRAPHQL = "sdl_schema";
public static final String API_SPEC_TYPE_ASYNC = "async_spec";
Expand Down Expand Up @@ -3153,4 +3155,24 @@ public static class APILogHandler {

//Property for enabling tenant aware sub claims when invoking APIs with API key
public static final String ENABLE_TENANT_AWARE_SUB_CLAIM= "enable.tenant.aware.subclaim";

public static class PortalNotifications {
public static final String ACTION = "action";
public static final String ACTION_META = "Action";
public static final String API_NAME = "apiName";
public static final String API_VERSION = "apiVersion";
public static final String API_CONTEXT = "apiContext";
public static final String API_CONTEXT_META = "ApiContext";
public static final String API_PROVIDER = "ApiProvider";
public static final String APPLICATION_NAME = "applicationName";
public static final String REQUESTED_TIER = "requestedTier";
public static final String REVISION_ID = "revisionId";
public static final String COMMENT = "comment";
public static final String STATUS_APPROVED = "approved";
public static final String STATUS_REJECTED = "rejected";
public static final String PUBLISHER_PORTAL = "publisher";
public static final String DEV_PORTAL = "devportal";
public static final String DEFAULT_CLAIM = "http://wso2.org/claims/organization";
public static final String APPROVED = "APPROVED";
}
}
Loading