This is an automated email from the ASF dual-hosted git repository.

ikamga pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-notifications.git

commit 286c3143ba086cd0862ba5ced403fc7c0571a659
Author: Ebenezer Graham <[email protected]>
AuthorDate: Thu Jun 6 16:23:04 2019 +0400

    Refactoring API Naming Conventions
---
 .../api/v1/client/NotificationManager.java         | 32 ++++----
 .../cn/notification/EmailApiDocumentation.java     |  6 +-
 .../cn/notification/SmsApiDocumentation.java       |  7 +-
 .../fineract/cn/notification/TestEmailService.java |  6 +-
 ...stener.java => ConfigurationEventListener.java} |  6 +-
 .../cn/notification/service/ServiceConstants.java  | 12 +--
 .../internal/config/NotificationConfiguration.java | 27 -------
 .../internal/identity/CustomerPermittedClient.java | 46 -----------
 .../identity/NotificationAuthentication.java       | 89 ----------------------
 .../service/internal/service/EmailService.java     |  4 +-
 .../internal/service/NotificationService.java      | 10 ---
 .../service/internal/service/SMSService.java       |  7 +-
 .../service/rest/EmailServiceRestController.java   | 57 +++++++-------
 .../service/rest/SMSServiceRestController.java     | 12 ++-
 .../service/rest/TemplateRestController.java       |  5 +-
 service/src/main/resources/application.yml         | 17 -----
 16 files changed, 72 insertions(+), 271 deletions(-)

diff --git 
a/api/src/main/java/org/apache/fineract/cn/notification/api/v1/client/NotificationManager.java
 
b/api/src/main/java/org/apache/fineract/cn/notification/api/v1/client/NotificationManager.java
index 1123f86..6e9b0f4 100644
--- 
a/api/src/main/java/org/apache/fineract/cn/notification/api/v1/client/NotificationManager.java
+++ 
b/api/src/main/java/org/apache/fineract/cn/notification/api/v1/client/NotificationManager.java
@@ -31,51 +31,56 @@ import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 
+import java.util.List;
+
 @SuppressWarnings("unused")
 @FeignClient(value = "notification-v1", path = "/notification/v1", 
configuration = CustomFeignClientsConfiguration.class)
 public interface NotificationManager {
        
        @RequestMapping(
-                       value = "/configuration/sms/active",
+                       value = "/configuration/sms",
                        method = RequestMethod.GET,
                        produces = MediaType.ALL_VALUE,
                        consumes = MediaType.APPLICATION_JSON_VALUE)
-       SMSConfiguration findAllActiveSMSConfigurationEntities();
+       List<SMSConfiguration> findAllSMSConfigurations();
        
        @RequestMapping(
-                       value = "/configuration/email/active",
+                       value = "/configuration/email",
                        method = RequestMethod.GET,
                        produces = MediaType.ALL_VALUE,
                        consumes = MediaType.APPLICATION_JSON_VALUE)
-       EmailConfiguration findAllActiveEmailConfigurationEntities();
+       List<EmailConfiguration> findAllEmailConfigurations();
        
        @RequestMapping(
-                       value = "/configuration/sms/create",
+                       value = "/configuration/sms",
                        method = RequestMethod.POST,
                        produces = MediaType.APPLICATION_JSON_VALUE,
                        consumes = MediaType.APPLICATION_JSON_VALUE
        )
        @ThrowsExceptions({
-                       @ThrowsException(status = HttpStatus.NOT_FOUND, 
exception = ConfigurationNotFoundException.class)
+                       @ThrowsException(status = HttpStatus.CONFLICT, 
exception = ConfigurationAlreadyExistException.class)
        })
        String createSMSConfiguration(final SMSConfiguration smsConfiguration);
        
        @RequestMapping(
-                       value = "/configuration/email/create",
+                       value = "/configuration/email",
                        method = RequestMethod.POST,
                        produces = MediaType.APPLICATION_JSON_VALUE,
                        consumes = MediaType.APPLICATION_JSON_VALUE
        )
+       @ThrowsExceptions({
+                       @ThrowsException(status = HttpStatus.CONFLICT, 
exception = ConfigurationAlreadyExistException.class)
+       })
        String createEmailConfiguration(final EmailConfiguration 
emailConfiguration);
        
        @RequestMapping(
-                       value = "/template/create",
+                       value = "/template",
                        method = RequestMethod.POST,
                        produces = MediaType.APPLICATION_JSON_VALUE,
                        consumes = MediaType.APPLICATION_JSON_VALUE
        )
        @ThrowsExceptions({
-                       @ThrowsException(status = 
HttpStatus.UNPROCESSABLE_ENTITY, exception = 
TemplateAlreadyExistException.class)
+                       @ThrowsException(status = HttpStatus.CONFLICT, 
exception = TemplateAlreadyExistException.class)
        })
        String createTemplate(final Template template);
        
@@ -95,32 +100,31 @@ public interface NotificationManager {
        )
        EmailConfiguration 
findEmailConfigurationByIdentifier(@PathVariable("identifier") final String 
identifier);
        
-       @RequestMapping(value = "/configuration/sms/update",
+       @RequestMapping(value = "/configuration/sms",
                        method = RequestMethod.PUT,
                        consumes = MediaType.APPLICATION_JSON_VALUE,
                        produces = MediaType.APPLICATION_JSON_VALUE
        )
        void updateSMSConfiguration(final SMSConfiguration smsConfiguration);
        
-       @RequestMapping(value = "/configuration/email/update",
+       @RequestMapping(value = "/configuration/email",
                        method = RequestMethod.PUT,
                        consumes = MediaType.APPLICATION_JSON_VALUE,
                        produces = MediaType.APPLICATION_JSON_VALUE
        )
        void updateEmailConfiguration(final EmailConfiguration 
emailConfiguration);
        
-       @RequestMapping(value = "/configuration/sms/delete/{identifier}",
+       @RequestMapping(value = "/configuration/sms/{identifier}",
                        method = RequestMethod.DELETE,
                        consumes = MediaType.APPLICATION_JSON_VALUE,
                        produces = MediaType.APPLICATION_JSON_VALUE
        )
        void deleteSMSConfiguration(@PathVariable("identifier") final String 
identifier);
        
-       @RequestMapping(value = "/configuration/email/delete/{identifier}",
+       @RequestMapping(value = "/configuration/email/{identifier}",
                        method = RequestMethod.DELETE,
                        consumes = MediaType.APPLICATION_JSON_VALUE,
                        produces = MediaType.APPLICATION_JSON_VALUE
        )
        void deleteEmailConfiguration(@PathVariable("identifier") final String 
identifier);
-       
 }
diff --git 
a/component-test/src/main/java/org/apache/fineract/cn/notification/EmailApiDocumentation.java
 
b/component-test/src/main/java/org/apache/fineract/cn/notification/EmailApiDocumentation.java
index 3aa0e48..dfd6f35 100644
--- 
a/component-test/src/main/java/org/apache/fineract/cn/notification/EmailApiDocumentation.java
+++ 
b/component-test/src/main/java/org/apache/fineract/cn/notification/EmailApiDocumentation.java
@@ -71,7 +71,7 @@ public class EmailApiDocumentation extends 
AbstractNotificationTest {
   public void documentCreateEmailConfiguration() throws Exception {
     final EmailConfiguration emailConfiguration = 
DomainObjectGenerator.emailConfiguration();
 
-    this.mockMvc.perform(post("/configuration/email/create")
+    this.mockMvc.perform(post("/configuration/email")
             .accept(MediaType.APPLICATION_JSON_VALUE)
             .contentType(MediaType.APPLICATION_JSON_VALUE)
             .content(gson.toJson(emailConfiguration)))
@@ -149,7 +149,7 @@ public class EmailApiDocumentation extends 
AbstractNotificationTest {
     
     
super.eventRecorder.wait(NotificationEventConstants.UPDATE_EMAIL_CONFIGURATION, 
newRandomConfiguration.getIdentifier());
     
-    this.mockMvc.perform(put("/configuration/sms/update")
+    this.mockMvc.perform(put("/configuration/sms")
         .accept(MediaType.APPLICATION_JSON_VALUE)
         .contentType(MediaType.APPLICATION_JSON_VALUE)
         .content(gson.toJson(newRandomConfiguration)))
@@ -180,7 +180,7 @@ public class EmailApiDocumentation extends 
AbstractNotificationTest {
     notificationManager.createEmailConfiguration(randomConfiguration);
     
super.eventRecorder.wait(NotificationEventConstants.DELETE_EMAIL_CONFIGURATION, 
randomConfiguration.getIdentifier());
     
-    this.mockMvc.perform(delete("/configuration/email/delete/" + 
randomConfiguration.getIdentifier())
+    this.mockMvc.perform(delete("/configuration/email/" + 
randomConfiguration.getIdentifier())
         .accept(MediaType.APPLICATION_JSON_VALUE)
         .contentType(MediaType.APPLICATION_JSON_VALUE))
         .andExpect(status().isOk())
diff --git 
a/component-test/src/main/java/org/apache/fineract/cn/notification/SmsApiDocumentation.java
 
b/component-test/src/main/java/org/apache/fineract/cn/notification/SmsApiDocumentation.java
index 7566309..8e651aa 100644
--- 
a/component-test/src/main/java/org/apache/fineract/cn/notification/SmsApiDocumentation.java
+++ 
b/component-test/src/main/java/org/apache/fineract/cn/notification/SmsApiDocumentation.java
@@ -73,7 +73,7 @@ public class SmsApiDocumentation extends 
AbstractNotificationTest {
   public void documentCreateSMSConfiguration() throws Exception {
     final SMSConfiguration randomSMSConfiguration = 
DomainObjectGenerator.smsConfiguration();
   
-    this.mockMvc.perform(post("/configuration/sms/create")
+    this.mockMvc.perform(post("/configuration/sms")
         .accept(MediaType.APPLICATION_JSON_VALUE)
         .contentType(MediaType.APPLICATION_JSON_VALUE)
         .content(gson.toJson(randomSMSConfiguration)))
@@ -135,7 +135,7 @@ public class SmsApiDocumentation extends 
AbstractNotificationTest {
     
     notificationManager.updateSMSConfiguration(randomSMSConfiguration);
     
-    this.mockMvc.perform(put("/configuration/sms/update")
+    this.mockMvc.perform(put("/configuration/sms")
         .accept(MediaType.APPLICATION_JSON_VALUE)
         .contentType(MediaType.APPLICATION_JSON_VALUE)
         .content(gson.toJson(randomSMSConfiguration)))
@@ -160,8 +160,7 @@ public class SmsApiDocumentation extends 
AbstractNotificationTest {
     
     
super.eventRecorder.wait(NotificationEventConstants.POST_SMS_CONFIGURATION, 
randomSMSConfiguration.getIdentifier());
     
-    System.out.println(randomSMSConfiguration.getIdentifier());
-    this.mockMvc.perform(delete("/configuration/sms/delete/" + 
randomSMSConfiguration.getIdentifier())
+    this.mockMvc.perform(delete("/configuration/sms/" + 
randomSMSConfiguration.getIdentifier())
         .accept(MediaType.APPLICATION_JSON_VALUE)
         .contentType(MediaType.APPLICATION_JSON_VALUE))
         .andExpect(status().isOk())
diff --git 
a/component-test/src/main/java/org/apache/fineract/cn/notification/TestEmailService.java
 
b/component-test/src/main/java/org/apache/fineract/cn/notification/TestEmailService.java
index bfeb5b7..e4cd844 100644
--- 
a/component-test/src/main/java/org/apache/fineract/cn/notification/TestEmailService.java
+++ 
b/component-test/src/main/java/org/apache/fineract/cn/notification/TestEmailService.java
@@ -25,7 +25,6 @@ import org.apache.fineract.cn.customer.api.v1.domain.Customer;
 import 
org.apache.fineract.cn.notification.api.v1.client.ConfigurationNotFoundException;
 import org.apache.fineract.cn.notification.api.v1.domain.EmailConfiguration;
 import 
org.apache.fineract.cn.notification.api.v1.events.NotificationEventConstants;
-import 
org.apache.fineract.cn.notification.service.internal.importer.TemplateImporter;
 import 
org.apache.fineract.cn.notification.service.internal.service.EmailService;
 import org.apache.fineract.cn.notification.util.DomainObjectGenerator;
 import org.junit.Assert;
@@ -33,7 +32,6 @@ import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import java.io.IOException;
-import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -105,7 +103,7 @@ public class TestEmailService extends 
AbstractNotificationTest {
                
Assert.assertTrue(this.eventRecorder.wait(NotificationEventConstants.POST_EMAIL_CONFIGURATION,
 emailConfiguration.getIdentifier()));
                
                EmailConfiguration sampleRetrieved = 
notificationManager.findEmailConfigurationByIdentifier(emailConfiguration.getIdentifier());
-               
Assert.assertEquals(sampleRetrieved.getIdentifier(),emailConfiguration.getIdentifier());
+               Assert.assertEquals(sampleRetrieved,emailConfiguration);
        }
        
        @Test
@@ -117,7 +115,7 @@ public class TestEmailService extends 
AbstractNotificationTest {
        }
        
        @Test
-       public void shouldFindActiveGateway() {
+       public void shouldFindDefaultGateway() {
                this.logger.info("Find Active Gateway");
                
Assert.assertNotNull(this.emailService.getDefaultEmailConfigurationEntity());
        }
diff --git 
a/component-test/src/main/java/org/apache/fineract/cn/notification/listener/EventListener.java
 
b/component-test/src/main/java/org/apache/fineract/cn/notification/listener/ConfigurationEventListener.java
similarity index 97%
rename from 
component-test/src/main/java/org/apache/fineract/cn/notification/listener/EventListener.java
rename to 
component-test/src/main/java/org/apache/fineract/cn/notification/listener/ConfigurationEventListener.java
index 8db258b..b4b5491 100644
--- 
a/component-test/src/main/java/org/apache/fineract/cn/notification/listener/EventListener.java
+++ 
b/component-test/src/main/java/org/apache/fineract/cn/notification/listener/ConfigurationEventListener.java
@@ -49,13 +49,13 @@ import org.springframework.stereotype.Component;
 
 @SuppressWarnings("unused")
 @Component
-public class EventListener {
+public class ConfigurationEventListener {
        private final EventRecorder eventRecorder;
        private final Logger logger;
        
        @Autowired
-       public EventListener(final EventRecorder eventRecorder,
-                            @Qualifier(ServiceConstants.LOGGER_NAME) final 
Logger logger) {
+       public ConfigurationEventListener(final EventRecorder eventRecorder,
+                                         
@Qualifier(ServiceConstants.LOGGER_NAME) final Logger logger) {
                this.logger = logger;
                this.eventRecorder = eventRecorder;
        }
diff --git 
a/service/src/main/java/org/apache/fineract/cn/notification/service/ServiceConstants.java
 
b/service/src/main/java/org/apache/fineract/cn/notification/service/ServiceConstants.java
index 50816ad..d76e07e 100644
--- 
a/service/src/main/java/org/apache/fineract/cn/notification/service/ServiceConstants.java
+++ 
b/service/src/main/java/org/apache/fineract/cn/notification/service/ServiceConstants.java
@@ -21,21 +21,11 @@ package org.apache.fineract.cn.notification.service;
 public interface ServiceConstants {
        String LOGGER_NAME = "notification-logger";
        
-       String CUSTOMER_SERVICE_NAME ="customer-v1";
-       String ACCOUNT_SERVICE_NAME ="account-v1";
-       String PORTFOLIO_SERVICE_NAME ="porfolio-v1";
-       
        String MAIL_TRANSPORT_PROTOCOL_PROPERTY = "mail.transport.protocol";
-       String MAIL_TRANSPORT_PROTOCOL_VALUE = "smtp";
        String MAIL_SMTP_AUTH_PROPERTY = "mail.smtp.auth";
-       String MAIL_SMTP_AUTH_VALUE = "true";
        String MAIL_SMTP_STARTTLS_ENABLE_PROPERTY = "mail.smtp.starttls.enable";
-       String MAIL_SMTP_STARTTLS_ENABLE_VALUE = "true";
+       String MAIL_SMTP_TIMEOUT_PROPERTY = "";
        
        String GOOGLE_MAIL_SERVER = "smtp.gmail.com";
        String YAHOO_MAIL_SERVER = "smtp.mail.yahoo.com";
-       
-       String MAIL_SMTP_TIMEOUT_PROPERTY = "";
-       String MAIL_SMTP_TIMEOUT_VALUE = "";
-       
 }
diff --git 
a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/config/NotificationConfiguration.java
 
b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/config/NotificationConfiguration.java
index ba70234..f237dff 100644
--- 
a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/config/NotificationConfiguration.java
+++ 
b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/config/NotificationConfiguration.java
@@ -18,22 +18,17 @@
  */
 package org.apache.fineract.cn.notification.service.internal.config;
 
-import org.apache.activemq.command.ActiveMQTopic;
 import org.apache.activemq.jms.pool.PooledConnectionFactory;
-import org.apache.activemq.spring.ActiveMQConnectionFactory;
 import org.apache.fineract.cn.anubis.config.EnableAnubis;
 import org.apache.fineract.cn.async.config.EnableAsync;
 import org.apache.fineract.cn.cassandra.config.EnableCassandra;
 import org.apache.fineract.cn.command.config.EnableCommandProcessing;
 import org.apache.fineract.cn.customer.api.v1.client.CustomerManager;
 import org.apache.fineract.cn.identity.api.v1.client.IdentityManager;
-import org.apache.fineract.cn.lang.ApplicationName;
 import org.apache.fineract.cn.lang.config.EnableServiceException;
 import org.apache.fineract.cn.lang.config.EnableTenantContext;
 import org.apache.fineract.cn.mariadb.config.EnableMariaDB;
 import org.apache.fineract.cn.notification.service.ServiceConstants;
-import 
org.apache.fineract.cn.notification.service.internal.identity.CustomerPermittedClient;
-import 
org.apache.fineract.cn.permittedfeignclient.config.EnablePermissionRequestingFeignClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -71,12 +66,10 @@ import java.nio.charset.StandardCharsets;
 @EnableServiceException
 @EnableJms
 @EnableConfigurationProperties
-@EnablePermissionRequestingFeignClient(feignClasses = 
{CustomerPermittedClient.class})
 @EnableFeignClients(
                clients = {
                                CustomerManager.class,
                                IdentityManager.class,
-                               CustomerPermittedClient.class
                }
 )
 @ComponentScan({
@@ -85,7 +78,6 @@ import java.nio.charset.StandardCharsets;
                "org.apache.fineract.cn.notification.service.internal",
                
"org.apache.fineract.cn.notification.service.internal.repository",
                
"org.apache.fineract.cn.notification.service.internal.command.handler",
-               "org.apache.fineract.cn.notification.service.internal.identity",
                "org.apache.fineract.cn.notification.service.internal.config",
 }
 )
@@ -108,15 +100,6 @@ public class NotificationConfiguration extends 
WebMvcConfigurerAdapter {
        }
        
        @Bean
-       public PooledConnectionFactory pooledConnectionFactory() {
-               PooledConnectionFactory pooledConnectionFactory = new 
PooledConnectionFactory();
-               ActiveMQConnectionFactory activeMQConnectionFactory = new 
ActiveMQConnectionFactory();
-               
activeMQConnectionFactory.setBrokerURL(this.environment.getProperty("activemq.brokerUrl","vm://localhost?broker.persistent=false"));
-               
pooledConnectionFactory.setConnectionFactory(activeMQConnectionFactory);
-               return pooledConnectionFactory;
-       }
-       
-       @Bean
        public JmsListenerContainerFactory 
jmsListenerContainerFactory(PooledConnectionFactory jmsFactory) {
                final DefaultJmsListenerContainerFactory factory = new 
DefaultJmsListenerContainerFactory();
                factory.setConnectionFactory(jmsFactory);
@@ -130,16 +113,6 @@ public class NotificationConfiguration extends 
WebMvcConfigurerAdapter {
        }
        
        @Bean
-       public JmsTemplate jmsTemplate(ApplicationName applicationName, 
PooledConnectionFactory jmsFactory) {
-               ActiveMQTopic activeMQTopic = new 
ActiveMQTopic(applicationName.toString());
-               JmsTemplate jmsTemplate = new JmsTemplate();
-               jmsTemplate.setPubSubDomain(true);
-               jmsTemplate.setConnectionFactory(jmsFactory);
-               jmsTemplate.setDefaultDestination(activeMQTopic);
-               return jmsTemplate;
-       }
-       
-       @Bean
        public SpringTemplateEngine springTemplateEngine() {
                SpringTemplateEngine templateEngine = new 
SpringTemplateEngine();
                templateEngine.addTemplateResolver(htmlTemplateResolver());
diff --git 
a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/identity/CustomerPermittedClient.java
 
b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/identity/CustomerPermittedClient.java
deleted file mode 100644
index 375d152..0000000
--- 
a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/identity/CustomerPermittedClient.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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://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.cn.notification.service.internal.identity;
-
-import org.apache.fineract.cn.anubis.annotation.Permittable;
-import org.apache.fineract.cn.api.annotation.ThrowsException;
-import org.apache.fineract.cn.customer.api.v1.client.CustomerNotFoundException;
-import org.apache.fineract.cn.customer.api.v1.domain.Customer;
-import org.apache.fineract.cn.permittedfeignclient.annotation.EndpointSet;
-import 
org.apache.fineract.cn.permittedfeignclient.annotation.PermittedFeignClientsConfiguration;
-import org.springframework.cloud.netflix.feign.FeignClient;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-@EndpointSet(identifier = "notification__v1__customer__v1")
-@FeignClient(name="customer-v1", path="/customer/v1", configuration = 
PermittedFeignClientsConfiguration.class)
-public interface CustomerPermittedClient {
-       @RequestMapping(
-                       value = "/customers/{identifier}",
-                       method = RequestMethod.GET,
-                       produces = MediaType.ALL_VALUE,
-                       consumes = MediaType.APPLICATION_JSON_VALUE
-       )
-       @ThrowsException(status = HttpStatus.NOT_FOUND, exception = 
CustomerNotFoundException.class)
-       @Permittable(groupId = 
org.apache.fineract.cn.customer.PermittableGroupIds.CUSTOMER)
-       Customer findCustomer(@PathVariable("identifier") final String 
identifier);
-}
\ No newline at end of file
diff --git 
a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/identity/NotificationAuthentication.java
 
b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/identity/NotificationAuthentication.java
deleted file mode 100644
index b3c357b..0000000
--- 
a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/identity/NotificationAuthentication.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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://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.cn.notification.service.internal.identity;
-
-import org.apache.fineract.cn.api.context.AutoUserContext;
-import org.apache.fineract.cn.api.util.InvalidTokenException;
-import org.apache.fineract.cn.api.util.UserContextHolder;
-import org.apache.fineract.cn.customer.api.v1.client.CustomerManager;
-import org.apache.fineract.cn.customer.api.v1.client.CustomerNotFoundException;
-import org.apache.fineract.cn.customer.api.v1.domain.Customer;
-import org.apache.fineract.cn.identity.api.v1.client.IdentityManager;
-import org.apache.fineract.cn.identity.api.v1.domain.Authentication;
-import org.apache.fineract.cn.lang.AutoTenantContext;
-import org.apache.fineract.cn.lang.TenantContextHolder;
-import org.apache.fineract.cn.notification.service.ServiceConstants;
-import 
org.apache.fineract.cn.notification.service.internal.config.NotificationProperties;
-import 
org.apache.fineract.cn.permittedfeignclient.service.ApplicationAccessTokenService;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Component;
-import org.springframework.util.Base64Utils;
-
-import java.util.Optional;
-
-@Component
-public class NotificationAuthentication {
-       private final ApplicationAccessTokenService 
applicationAccessTokenService;
-       private Logger logger;
-       private CustomerPermittedClient customerPermittedClient;
-       private NotificationProperties notificationProperties;
-       private IdentityManager identityManager;
-       
-       
-       @Autowired
-       public NotificationAuthentication(final NotificationProperties 
notificationPropertities,
-                                         final IdentityManager identityManager,
-                                                     final 
CustomerPermittedClient customerPermittedClient,
-                                         
@SuppressWarnings("SpringJavaAutowiringInspection")final 
ApplicationAccessTokenService applicationAccessTokenService,
-                                         
@Qualifier(ServiceConstants.LOGGER_NAME) final Logger logger) {
-               this.logger = logger;
-               this.customerPermittedClient = customerPermittedClient;
-               this.notificationProperties = notificationPropertities;
-               this.applicationAccessTokenService = 
applicationAccessTokenService;
-               this.identityManager = identityManager;
-       }
-       
-       public Optional<Customer> getCustomer(String tenantIdentifier, String 
customerId) {
-                       try (final AutoTenantContext ignored = new 
AutoTenantContext(tenantIdentifier)) {
-                               final String accessToken = 
applicationAccessTokenService.getAccessToken(notificationProperties.getUser(), 
tenantIdentifier);
-                               logger.debug("Access token: {}", accessToken);
-                               try (final AutoUserContext ignored2 = new 
AutoUserContext(notificationProperties.getUser(), accessToken)) {
-                                       try {
-                                               logger.debug("Getting Customer 
{}", customerId);
-                                               return 
Optional.of(this.customerPermittedClient.findCustomer(customerId));
-                                       } catch (final InvalidTokenException e) 
{
-                                               logger.error("Failed to get 
customer with id {}, in tenant {} because notification does not have permission 
to access identity.", customerId, tenantIdentifier, e);
-                                       }
-                               }
-                               return Optional.empty();
-                       }
-       }
-       
-       public void authenticate(String tenant) {
-               TenantContextHolder.clear();
-               TenantContextHolder.setIdentifier(tenant);
-               
-               final Authentication authentication =
-                               
this.identityManager.login(notificationProperties.getUser(), 
Base64Utils.encodeToString(notificationProperties.getPassword().getBytes()));
-               UserContextHolder.clear();
-               
UserContextHolder.setAccessToken(notificationProperties.getUser(), 
authentication.getAccessToken());
-       }
-}
diff --git 
a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/EmailService.java
 
b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/EmailService.java
index e77563a..9290e91 100644
--- 
a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/EmailService.java
+++ 
b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/EmailService.java
@@ -123,7 +123,7 @@ public class EmailService {
                        mail.setTo(to);
                        mail.setSubject(subject);
                        mail.setText(message);
-                       this.mailSender.send(mail);
+                       //this.mailSender.send(mail);
                        return to;
                } catch (MailException exception) {
                        logger.debug("Caused by:" + 
exception.getCause().toString());
@@ -146,7 +146,7 @@ public class EmailService {
                        messageHelper.setText(content, true);
                };
                try {
-                       this.mailSender.send(messagePreparator);
+                       //this.mailSender.send(messagePreparator);
                        return to;
                } catch (MailException e) {
                        logger.error("Failed to send Formatted email{}", 
e.getMessage());
diff --git 
a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/NotificationService.java
 
b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/NotificationService.java
index 2b51e8c..50bc1f9 100644
--- 
a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/NotificationService.java
+++ 
b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/NotificationService.java
@@ -21,8 +21,6 @@ package 
org.apache.fineract.cn.notification.service.internal.service;
 import org.apache.fineract.cn.customer.api.v1.domain.Customer;
 import org.apache.fineract.cn.notification.api.v1.domain.Template;
 import org.apache.fineract.cn.notification.service.ServiceConstants;
-import 
org.apache.fineract.cn.notification.service.internal.identity.CustomerPermittedClient;
-import 
org.apache.fineract.cn.notification.service.internal.identity.NotificationAuthentication;
 import 
org.apache.fineract.cn.notification.service.internal.service.externalServiceClients.CustomerService;
 import org.slf4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -39,10 +37,8 @@ public class NotificationService {
        private final EmailService emailService;
        private final TemplateService templateService;
        
-       private final NotificationAuthentication notificationAuthentication;
        private final CustomerService customerService;
        private final Logger logger;
-       private final CustomerPermittedClient customerPermittedClient;
        
        @Autowired
        
@@ -50,8 +46,6 @@ public class NotificationService {
                                   final SMSService smsService,
                                   final EmailService emailService,
                                   final TemplateService templateService,
-                                  final NotificationAuthentication 
notificationAuthentication,
-                                  final CustomerPermittedClient 
customerPermittedClient,
                                   @Qualifier(ServiceConstants.LOGGER_NAME) 
final Logger logger
        ) {
                super();
@@ -59,14 +53,10 @@ public class NotificationService {
                this.smsService = smsService;
                this.emailService = emailService;
                this.templateService = templateService;
-               this.notificationAuthentication = notificationAuthentication;
-               this.customerPermittedClient = customerPermittedClient;
                this.logger = logger;
        }
        
        public Optional<Customer> findCustomer(final String customerIdentifier, 
String tenant) {
-               notificationAuthentication.authenticate(tenant);
-               //return 
notificationAuthentication.getCustomer(tenant,customerIdentifier);
                return customerService.findCustomer(customerIdentifier);
        }
        
diff --git 
a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/SMSService.java
 
b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/SMSService.java
index 7fe8587..76ce3a0 100644
--- 
a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/SMSService.java
+++ 
b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/SMSService.java
@@ -32,6 +32,7 @@ import 
org.apache.fineract.cn.notification.api.v1.events.NotificationEventConsta
 import org.apache.fineract.cn.notification.service.ServiceConstants;
 import 
org.apache.fineract.cn.notification.service.internal.mapper.SMSConfigurationMapper;
 import 
org.apache.fineract.cn.notification.service.internal.repository.SMSGatewayConfigurationRepository;
+import org.hibernate.mapping.Map;
 import org.slf4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -111,7 +112,9 @@ public class SMSService {
                                new PhoneNumber(receiver),
                                new PhoneNumber(this.senderNumber),
                                template);
-               Message message = messageCreator.create();
-               return message.getTo();
+               //Message message = messageCreator.create();
+               
+               System.out.println("\n\n\nsent");
+               return "";//message;
        }
 }
diff --git 
a/service/src/main/java/org/apache/fineract/cn/notification/service/rest/EmailServiceRestController.java
 
b/service/src/main/java/org/apache/fineract/cn/notification/service/rest/EmailServiceRestController.java
index d1859a2..620ecf4 100644
--- 
a/service/src/main/java/org/apache/fineract/cn/notification/service/rest/EmailServiceRestController.java
+++ 
b/service/src/main/java/org/apache/fineract/cn/notification/service/rest/EmailServiceRestController.java
@@ -58,41 +58,14 @@ public class EmailServiceRestController {
        }
        
        @Permittable(value = AcceptedTokenType.TENANT, groupId = 
PermittableGroupIds.SELF_MANAGEMENT)
-       @RequestMapping(value = "/update",
-                       method = RequestMethod.PUT,
-                       consumes = MediaType.APPLICATION_JSON_VALUE,
-                       produces = MediaType.APPLICATION_JSON_VALUE
-       )
-       public
-       @ResponseBody
-       ResponseEntity<Void> updateEmailConfiguration(@RequestBody @Valid final 
EmailConfiguration emailConfiguration) {
-               this.commandGateway.process(new 
UpdateEmailConfigurationCommand(emailConfiguration));
-               return ResponseEntity.accepted().build();
-       }
-       
-       @Permittable(value = AcceptedTokenType.TENANT, groupId = 
PermittableGroupIds.SELF_MANAGEMENT)
-       @RequestMapping(value = "/delete/{identifier}",
-                       method = RequestMethod.DELETE,
-                       consumes = MediaType.APPLICATION_JSON_VALUE,
-                       produces = MediaType.APPLICATION_JSON_VALUE
-       )
-       public
-       @ResponseBody
-       ResponseEntity<Void> deleteEmailConfiguration(@PathVariable @Valid 
final String identifier) {
-               this.commandGateway.process(new 
DeleteEmailConfigurationCommand(identifier));
-               return ResponseEntity.ok().build();
-       }
-       
-       @Permittable(value = AcceptedTokenType.TENANT, groupId = 
PermittableGroupIds.SELF_MANAGEMENT)
        @RequestMapping(
-                       value = "/active",
                        method = RequestMethod.GET,
                        consumes = MediaType.ALL_VALUE,
                        produces = MediaType.APPLICATION_JSON_VALUE
        )
        public
        @ResponseBody
-       List<EmailConfiguration> findAllActiveEmailConfigurationEntities() {
+       List<EmailConfiguration> findAllEmailConfigurationEntities() {
                return this.emailService.findAllEmailConfigurationEntities();
        }
        
@@ -113,7 +86,6 @@ public class EmailServiceRestController {
        
        @Permittable(value = AcceptedTokenType.TENANT, groupId = 
PermittableGroupIds.SELF_MANAGEMENT)
        @RequestMapping(
-                       value = "/create",
                        method = RequestMethod.POST,
                        consumes = MediaType.APPLICATION_JSON_VALUE,
                        produces = MediaType.APPLICATION_JSON_VALUE
@@ -128,4 +100,31 @@ public class EmailServiceRestController {
                this.commandGateway.process(new 
CreateEmailConfigurationCommand(emailConfiguration));
                return new ResponseEntity<>(HttpStatus.CREATED);
        }
+       
+       @Permittable(value = AcceptedTokenType.TENANT, groupId = 
PermittableGroupIds.SELF_MANAGEMENT)
+       @RequestMapping(
+                       method = RequestMethod.PUT,
+                       consumes = MediaType.APPLICATION_JSON_VALUE,
+                       produces = MediaType.APPLICATION_JSON_VALUE
+       )
+       public
+       @ResponseBody
+       ResponseEntity<Void> updateEmailConfiguration(@RequestBody @Valid final 
EmailConfiguration emailConfiguration) {
+               this.commandGateway.process(new 
UpdateEmailConfigurationCommand(emailConfiguration));
+               return ResponseEntity.accepted().build();
+       }
+       
+       @Permittable(value = AcceptedTokenType.TENANT, groupId = 
PermittableGroupIds.SELF_MANAGEMENT)
+       @RequestMapping(
+                       value = "/{identifier}",
+                       method = RequestMethod.DELETE,
+                       consumes = MediaType.APPLICATION_JSON_VALUE,
+                       produces = MediaType.APPLICATION_JSON_VALUE
+       )
+       public
+       @ResponseBody
+       ResponseEntity<Void> deleteEmailConfiguration(@PathVariable @Valid 
final String identifier) {
+               this.commandGateway.process(new 
DeleteEmailConfigurationCommand(identifier));
+               return ResponseEntity.ok().build();
+       }
 }
diff --git 
a/service/src/main/java/org/apache/fineract/cn/notification/service/rest/SMSServiceRestController.java
 
b/service/src/main/java/org/apache/fineract/cn/notification/service/rest/SMSServiceRestController.java
index 26106bc..2f8033d 100644
--- 
a/service/src/main/java/org/apache/fineract/cn/notification/service/rest/SMSServiceRestController.java
+++ 
b/service/src/main/java/org/apache/fineract/cn/notification/service/rest/SMSServiceRestController.java
@@ -40,7 +40,7 @@ import java.util.List;
 
 @SuppressWarnings("unused")
 @RestController
-@RequestMapping("/configuration/sms/")
+@RequestMapping("/configuration/sms")
 public class SMSServiceRestController {
        
        private final Logger logger;
@@ -59,14 +59,13 @@ public class SMSServiceRestController {
        
        @Permittable(value = AcceptedTokenType.TENANT, groupId = 
PermittableGroupIds.SELF_MANAGEMENT)
        @RequestMapping(
-                       value = "/active",
                        method = RequestMethod.GET,
                        consumes = MediaType.ALL_VALUE,
                        produces = MediaType.APPLICATION_JSON_VALUE
        )
        public
        @ResponseBody
-       List<SMSConfiguration> findAllActiveSMSConfigurationEntities() {
+       List<SMSConfiguration> findAllSMSConfigurationEntities() {
                return this.smsService.findAllSMSConfigurationEntities();
        }
        
@@ -87,14 +86,13 @@ public class SMSServiceRestController {
        
        @Permittable(value = AcceptedTokenType.TENANT, groupId = 
PermittableGroupIds.SELF_MANAGEMENT)
        @RequestMapping(
-                       value = "/create",
                        method = RequestMethod.POST,
                        consumes = MediaType.APPLICATION_JSON_VALUE,
                        produces = MediaType.APPLICATION_JSON_VALUE
        )
        public
        @ResponseBody
-       ResponseEntity<Void> createSMSConfiguration(@RequestBody @Valid final 
SMSConfiguration smsConfiguration) throws InterruptedException {
+       ResponseEntity<Void> createSMSConfiguration(@RequestBody @Valid final 
SMSConfiguration smsConfiguration) {
                if 
(this.smsService.smsConfigurationExists(smsConfiguration.getIdentifier())) {
                        throw ServiceException.conflict("Configuration {0} 
already exists.", smsConfiguration.getIdentifier());
                }
@@ -104,7 +102,7 @@ public class SMSServiceRestController {
        }
        
        @Permittable(value = AcceptedTokenType.TENANT, groupId = 
PermittableGroupIds.SELF_MANAGEMENT)
-       @RequestMapping(value = "/update",
+       @RequestMapping(
                        method = RequestMethod.PUT,
                        consumes = MediaType.APPLICATION_JSON_VALUE,
                        produces = MediaType.APPLICATION_JSON_VALUE
@@ -117,7 +115,7 @@ public class SMSServiceRestController {
        }
        
        @Permittable(value = AcceptedTokenType.TENANT, groupId = 
PermittableGroupIds.SELF_MANAGEMENT)
-       @RequestMapping(value = "/delete/{identifier}",
+       @RequestMapping(value = "/{identifier}",
                        method = RequestMethod.DELETE,
                        consumes = MediaType.APPLICATION_JSON_VALUE,
                        produces = MediaType.APPLICATION_JSON_VALUE
diff --git 
a/service/src/main/java/org/apache/fineract/cn/notification/service/rest/TemplateRestController.java
 
b/service/src/main/java/org/apache/fineract/cn/notification/service/rest/TemplateRestController.java
index aed08f2..1c7d26c 100644
--- 
a/service/src/main/java/org/apache/fineract/cn/notification/service/rest/TemplateRestController.java
+++ 
b/service/src/main/java/org/apache/fineract/cn/notification/service/rest/TemplateRestController.java
@@ -79,7 +79,6 @@ public class TemplateRestController {
        
        @Permittable(value = AcceptedTokenType.TENANT, groupId = 
PermittableGroupIds.SELF_MANAGEMENT)
        @RequestMapping(
-                       value = "/create",
                        method = RequestMethod.POST,
                        consumes = MediaType.APPLICATION_JSON_VALUE,
                        produces = MediaType.APPLICATION_JSON_VALUE
@@ -96,7 +95,7 @@ public class TemplateRestController {
        }
        
        @Permittable(value = AcceptedTokenType.TENANT, groupId = 
PermittableGroupIds.SELF_MANAGEMENT)
-       @RequestMapping(value = "/update",
+       @RequestMapping(
                        method = RequestMethod.PUT,
                        consumes = MediaType.APPLICATION_JSON_VALUE,
                        produces = MediaType.APPLICATION_JSON_VALUE
@@ -109,7 +108,7 @@ public class TemplateRestController {
        }
        
        @Permittable(value = AcceptedTokenType.TENANT, groupId = 
PermittableGroupIds.SELF_MANAGEMENT)
-       @RequestMapping(value = "/delete/{identifier}",
+       @RequestMapping(value = "/{identifier}",
                        method = RequestMethod.DELETE,
                        consumes = MediaType.APPLICATION_JSON_VALUE,
                        produces = MediaType.APPLICATION_JSON_VALUE
diff --git a/service/src/main/resources/application.yml 
b/service/src/main/resources/application.yml
index 23054cf..2f79479 100644
--- a/service/src/main/resources/application.yml
+++ b/service/src/main/resources/application.yml
@@ -23,19 +23,6 @@ spring:
       enabled: false
     config:
       enabled: false
-    mail:
-      host: smtp.gmail.com
-      port: 587
-      username:
-      password:
-      properties:
-        debug: true
-        mail:
-          smtp:
-            auth: true
-            starttls:
-              enable: true
-
 
 
 eureka:
@@ -85,7 +72,3 @@ flyway:
 notification:
   user: operator
   password: init1@l
-
-activemq:
-  brokerUrl: vm://localhost?broker.persistent=false
-  concurrency: 1-1

Reply via email to