forked from apache/fineract
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Notification Module Added Notification Module Added Notification Module Added license file for jar analyzer Added entry into LICENSE_RELEASE file Added gradle wrapper
- Loading branch information
Showing
51 changed files
with
2,810 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,6 @@ repos | |
.settings | ||
.gradle | ||
*.log | ||
.idea | ||
!gradle/wrapper/gradle-wrapper.jar | ||
/gradle |
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
57 changes: 57 additions & 0 deletions
57
...er/src/integrationTest/java/org/apache/fineract/integrationtests/NotificationApiTest.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,57 @@ | ||
package org.apache.fineract.integrationtests; | ||
|
||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF 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:https://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. | ||
*/ | ||
|
||
|
||
import com.jayway.restassured.builder.RequestSpecBuilder; | ||
import com.jayway.restassured.builder.ResponseSpecBuilder; | ||
import com.jayway.restassured.http.ContentType; | ||
import com.jayway.restassured.specification.RequestSpecification; | ||
import com.jayway.restassured.specification.ResponseSpecification; | ||
import org.apache.fineract.integrationtests.common.NotificationHelper; | ||
import org.apache.fineract.integrationtests.common.Utils; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.util.HashMap; | ||
|
||
public class NotificationApiTest { | ||
|
||
private ResponseSpecification responseSpec; | ||
private RequestSpecification requestSpec; | ||
|
||
@Before | ||
public void setUp() { | ||
Utils.initializeRESTAssured(); | ||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); | ||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); | ||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); | ||
} | ||
|
||
@Test | ||
@SuppressWarnings("unchecked") | ||
public void testNotificationRetrieval() { | ||
HashMap<String, Object> response = (HashMap<String, Object>) NotificationHelper.getNotifications(this.requestSpec, | ||
this.responseSpec, ""); | ||
System.out.println("Response : " + response.toString()); | ||
Assert.assertNotNull(response); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
.../integrationTest/java/org/apache/fineract/integrationtests/common/NotificationHelper.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,43 @@ | ||
package org.apache.fineract.integrationtests.common; | ||
|
||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF 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:https://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. | ||
*/ | ||
|
||
import com.jayway.restassured.specification.RequestSpecification; | ||
import com.jayway.restassured.specification.ResponseSpecification; | ||
|
||
public class NotificationHelper { | ||
|
||
private final RequestSpecification requestSpec; | ||
private final ResponseSpecification responseSpec; | ||
|
||
private static final String NOTIFICATION_API_URL = "/fineract-provider/api/v1/notifications?" + Utils.TENANT_IDENTIFIER; | ||
|
||
public NotificationHelper(RequestSpecification requestSpec, ResponseSpecification responseSpec) { | ||
this.requestSpec = requestSpec; | ||
this.responseSpec = responseSpec; | ||
} | ||
|
||
public static Object getNotifications(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, | ||
final String jsonReturn) { | ||
final String GET_NOTIFICATIONS_URL = NOTIFICATION_API_URL; | ||
System.out.println("-----------------------------GET NOTIFICATIONS-----------------------------------"); | ||
return Utils.performServerGet(requestSpec, responseSpec, GET_NOTIFICATIONS_URL, ""); | ||
} | ||
} |
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
89 changes: 89 additions & 0 deletions
89
...-provider/src/main/java/org/apache/fineract/notification/api/NotificationApiResource.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,89 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF 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:https://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.apache.fineract.notification.api; | ||
|
||
|
||
import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper; | ||
import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; | ||
import org.apache.fineract.infrastructure.core.serialization.ToApiJsonSerializer; | ||
import org.apache.fineract.infrastructure.core.service.Page; | ||
import org.apache.fineract.infrastructure.core.service.SearchParameters; | ||
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; | ||
import org.apache.fineract.notification.data.NotificationData; | ||
import org.apache.fineract.notification.service.NotificationReadPlatformService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Scope; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.ws.rs.*; | ||
import javax.ws.rs.core.Context; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.UriInfo; | ||
|
||
@Path("/notifications") | ||
@Component | ||
@Scope("singleton") | ||
public class NotificationApiResource { | ||
|
||
private final PlatformSecurityContext context; | ||
private final NotificationReadPlatformService notificationReadPlatformService; | ||
private final ApiRequestParameterHelper apiRequestParameterHelper; | ||
private final ToApiJsonSerializer<NotificationData> toApiJsonSerializer; | ||
|
||
@Autowired | ||
public NotificationApiResource(PlatformSecurityContext context, | ||
NotificationReadPlatformService notificationReadPlatformService, | ||
ApiRequestParameterHelper apiRequestParameterHelper, | ||
ToApiJsonSerializer<NotificationData> toApiJsonSerializer) { | ||
this.context = context; | ||
this.notificationReadPlatformService = notificationReadPlatformService; | ||
this.apiRequestParameterHelper = apiRequestParameterHelper; | ||
this.toApiJsonSerializer = toApiJsonSerializer; | ||
} | ||
|
||
@GET | ||
@Consumes({MediaType.APPLICATION_JSON}) | ||
@Produces({MediaType.APPLICATION_JSON}) | ||
public String getAllNotifications(@Context final UriInfo uriInfo, @QueryParam("orderBy") final String orderBy, | ||
@QueryParam("limit") final Integer limit, | ||
@QueryParam("offset") final Integer offset, | ||
@QueryParam("sortOrder") final String sortOrder, | ||
@QueryParam("isRead") final boolean isRead) { | ||
|
||
this.context.authenticatedUser(); | ||
final Page<NotificationData> notificationData; | ||
final SearchParameters searchParameters = SearchParameters.forPagination(offset, limit, orderBy, sortOrder); | ||
if (!isRead) { | ||
notificationData = this.notificationReadPlatformService.getAllUnreadNotifications(searchParameters); | ||
} else { | ||
notificationData = this.notificationReadPlatformService.getAllNotifications(searchParameters); | ||
} | ||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper | ||
.process(uriInfo.getQueryParameters()); | ||
return this.toApiJsonSerializer.serialize(settings, notificationData); | ||
} | ||
|
||
@PUT | ||
@Consumes({MediaType.APPLICATION_JSON}) | ||
@Produces({MediaType.APPLICATION_JSON}) | ||
public void update() { | ||
this.context.authenticatedUser(); | ||
this.notificationReadPlatformService.updateNotificationReadStatus(); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...src/main/java/org/apache/fineract/notification/cache/CacheNotificationResponseHeader.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,50 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF 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:https://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.apache.fineract.notification.cache; | ||
|
||
|
||
public class CacheNotificationResponseHeader { | ||
|
||
private boolean hasNotifications; | ||
private Long lastFetch; | ||
|
||
public CacheNotificationResponseHeader() { | ||
} | ||
|
||
public CacheNotificationResponseHeader(boolean hasNotifications, Long lastFetch) { | ||
this.hasNotifications = hasNotifications; | ||
this.lastFetch = lastFetch; | ||
} | ||
|
||
public boolean hasNotifications() { | ||
return hasNotifications; | ||
} | ||
|
||
public void setHasNotifications(boolean hasNotifications) { | ||
this.hasNotifications = hasNotifications; | ||
} | ||
|
||
public Long getLastFetch() { | ||
return lastFetch; | ||
} | ||
|
||
public void setLastFetch(Long lastFetch) { | ||
this.lastFetch = lastFetch; | ||
} | ||
} |
Oops, something went wrong.