diff --git a/.gitignore b/.gitignore index 2dc27ec0..aec0e7e5 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ target *.iws *.ipr .idea +log +dep-sanbox/log + diff --git a/dep-sandbox/README.md b/dep-sandbox/README.md index 72ef644e..06544ce2 100644 --- a/dep-sandbox/README.md +++ b/dep-sandbox/README.md @@ -120,7 +120,7 @@ Please use header key as "sandbox" and value as username to invoke below given r - Manage Numbers -This servivce is used to define user specific number for sandbox usage. +This service is used to define user specific number for sandbox usage. Request : @@ -849,17 +849,27 @@ http://:/{v1}/credit/{msisdn}/refund Request Body : ``` { - "refundRequest":{ - "amount":0, - "clientCorrelator":"clientCorrelator", - "reasonForRefund":"reasonForRefund", - "merchantIdentification":"merchantIdentification", - "serverTransactionReference":"serverTransactionReference", - "receiptRequest":{ - "notifyURL":"notifyURL", - "callbackData":"callbackData" - } - } + "refundRequest": { + "clientCorrelator":"54321", + "msisdn": "tel:+12345678901", + "originalServerReferenceCode": "ABC-123", + "reasonForRefund": "adjustment", + "refundAmount": 1, + "paymentAmount": { + "chargingInformation": { + "amount": "10", + "currency": "USD", + "description": "Alien Invaders Game" + }, + "chargingMetaData": { + "onBehalfOf": "Example Games Inc", + "purchaseCategoryCode": "Game", + "channel": "WAP", + "tax": "0" + } + }, + "referenceCode": "REF-12345" + } } ``` @@ -867,18 +877,31 @@ Response : ``` { "refundResponse": { - "amount": 0, - "serverTransactionReference": "serverTransactionReference", - "clientCorrelator": "clientCorrelator", - "reasonForRefund": "reasonForRefund", - "merchantIdentification": "merchantIdentification", - "receiptResponse": { - "notifyURL": "notifyURL", - "callbackData": "callbackData", - "resourceURL": "http://:/{v1}/credit/{msisdn}/refund" - } + "clientCorrelator": "54321", + "endUserID": "tel:+12345678901", + "originalServerReferenceCode": "ABC-123", + "reasonForRefund": "adjustment", + "refundAmount": 1, + "paymentAmount": { + "chargingInformation": { + "amount": "10", + "currency": "USD", + "description": "Alien Invaders Game" + }, + "chargingMetaData": { + "onBehalfOf": "Example Games Inc", + "purchaseCategoryCode": "Game", + "channel": "WAP", + "tax": "0" + } + }, + "referenceCode": "REF-12345", + "resourceURL": "", + "transactionOperationStatus": "Refunded", + "serverReferanceCode": "000014" } } + ``` @@ -1178,3 +1201,619 @@ Response : 200 OK will be returned if the service is successfully added for the msisdn. Unless 400 Bad Request will be returned +###6.6 Payment Service + +####6.6.1 Introduction + +Payment service will provide the Service providers a list of payment services available for the given MSISDN and based on the services available service provider can make/refund payment. Basically Payment API supports 3 operations. + +- Charge a User - Charge a subscriber for a service provided by your Web application. +- Refund a User - Refund a end user +- List Transactions - Return all the transactions of the end user for the calling application + +####6.6.2 API features with postman testing + +- Charge - Charge a subscriber for a service provided by your application + +Request : + +Type - POST + +Request URI: +``` +http://:/payment/v1_3/transaction/{endUserId}/amount +``` + +Request Body : +``` +{ + "amountTransaction":{ + “clientCorrelator”: ”123456:AIN12345”, + "endUserId":"tel:+00123456789", + "paymentAmount":{ + "chargingInformation":{ + "amount":"10.00", + "currency":"LKR", + "description":"Alien Invaders Game" + }, + "chargingMetaData":{ + "onBehalfOf":"Example Games Inc", + "purchaseCategoryCode":"Game", + "channel":"WAP", + "taxAmount":"0" + } + }, + "referenceCode":"REF-12345", + "transactionOperationStatus":"Charged" + } +} + +``` + +Response : + +``` +{ + "amountTransaction":{ + "clientCorrelator":"123456:AIN12345", + "endUserId":"tel:+94773524308", + "paymentAmount":{ + "chargingInformation":{ + "amount":"10.00", + "currency":"USD", + "description":"Alien Invaders Game" + }, + "totalAmountCharged":"10.00", + "chargingMetaData":{ + "onBehalfOf":"Example Games Inc", + "purchaseCategoryCode":"Game", + "channel":"WAP", + "taxAmount":"0" + } + }, + "referenceCode":"REF-12345", + "serverReferenceCode":"PAYMENT_REF000057", + "resourceURL":"http://localhost:8181/payment/v1_3/tel:+94773524308/transactions/amount/78999", + "transactionOperationStatus":"Charged" + } +} + + +``` + +- Refund - Refund an end user + +Request : + +Type - POST + +Request URI: +``` +http://:/payment/v1_3/transaction/{endUserId}/amount + +``` +Request Body : +``` + +{ + "amountTransaction":{ + "clientCorrelator":"123456:AIN12345", + "endUserId":"tel:+94773524308", + "paymentAmount":{ + "chargingInformation":{ + "amount":"10", + "currency":"USD", + "description":"Alien Invaders Game" + }, + "chargingMetaData":{ + "onBehalfOf":"Example Games Inc", + "purchaseCategoryCode":"Game", + "channel":"WAP", + "taxAmount":"0" + } + }, + "referenceCode":"REF-1234", + "originalServerReferenceCode":"PAYMENT_REF000057", + "transactionOperationStatus":"Refunded" + } +} + +``` + +Response : + +``` + +{ + "amountTransaction": { + "clientCorrelator": "123456:AIN12345", + "endUserId": "tel:+94773524308", + "originalServerReferenceCode": "PAYMENT_REF000057", + "paymentAmount": { + "chargingInformation": { + "amount": "10", + "currency": "USD", + "description": "Alien Invaders Game" + }, + "totalAmountRefunded": "10.0", + "chargingMetaData": { + "onBehalfOf": "Example Games Inc", + "purchaseCategoryCode": "Game", + "channel": "WAP", + "taxAmount": "0" + } + }, + "referenceCode": "REF-1234", + "resourceURL": "http://localhost:8181/payment/v1_3/tel:+94773524308/transactions/amount/00060", + "transactionOperationStatus": "Refunded" + } +} + +``` + +Response : +200 OK will be returned if the service is successfully added for the msisdn. +Unless 400 Bad Request will be returned + +- List Transactions - Return all the transactions of the end user for the calling application +Maximum no of returned results is 20 + +Request : + +Type - GET + +Request URI- +``` +http://:/payment/v1_3/{endUserId}/transactions + +``` + +Response : + + +``` + +{ + "paymentTransactionList":{ + "amountTransaction":[ + { + "endUserId":" tel:+00123456789", + "paymentAmount":{ + "chargingInformation":{ + "amount":"9", + "currency":"USD", + "description":"Alien Invaders" + } + }, + "referenceCode":"REF-ASM600-239238", + "serverReferenceCode":"tx-a3c0e4e006da40a8a5b5-045972478cc3", + "resourceURL":, + "transactionOperationStatus":"Charged" + }, + { + "endUserId":" tel:+00123456789", + "paymentAmount":{ + "chargingInformation":{ + "amount":"6", + "currency":"USD", + "description":" Snakes Alive " + } + }, + "referenceCode":"REF-ASM600-2392344", + "serverReferenceCode":"tx-a3c0e4e006da60a8a5b5-044972478cc3", + "resourceURL":“”, + "transactionOperationStatus":"Charged" + } + ], + "resourceURL":”” + } +} + +``` + +###6.7 SMS Service + +####6.7.1 Introduction + +SMS service will provide the Service providers a list of SMS services. Basically SMS API supports 7 operations. + +- Send SMS - Used to send an SMS from a Web Application (to one or more mobile terminals). +- Query the delivery status of a SMS - Query the delivery status of an SMS which has been sent from your Web application. +- Subscribe to SMS delivery notifications - Start subscribing to delivery status notifications for all your sent SMS. +- Stop the subscription to delivery notifications - Stop subscribing to delivery status notifications for all your sent SMS. +- Receiving SMS - Retrieve SMS sent to your Web application. +- Subscribe to notifications of messages sent to your application - Subscribe to notifications for SMS messages sent to your Web application. +- Stop the subscription to message notifications - Stop subscribing to notifications for SMS messages sent to your Web application. + +####6.6.2 API features with postman testing + + + +- Send SMS - Used to send an SMS from a Web Application (to one or more mobile terminals). + +Request : + +Type - POST + +Request URI: +``` +http://:/smsmessaging/v1_2/outbound/{Short Code}/requests +``` + +Request Body : + +``` +{ + "outboundSMSMessageRequest":{ + "address":[ + "tel:+94770000976", + "tel:+94770000977" + ], + "senderAddress":"tel:12345678", + "outboundSMSTextMessage":{ + "message":"Hello World" + }, + "clientCorrelator":"123456:AIN12345", + "receiptRequest":{ + "notifyURL":"http://application.example.com/notiications/DeliveryInfoNotication", + "callbackData":"some-data-useful-to-the-requester" + }, + "senderName":"ACME Inc." + } +} +``` + +Response : + +``` +{ + "outboundSMSMessageRequest":{ + "address":[ + "tel:+94770000976", + "tel:+94770000977" + ], + "deliveryInfoList":{ + "deliveryInfo":[ + { + "address":"tel:+94770000976", + "deliveryStatus":"MessageWaiting" + }, + { + "address":"tel:+94770000977", + "deliveryStatus":"MessageWaiting" + } + ], + "resourceURL":"/tel:+12345678 /requests/600022/deliveryInfos " + }, + "senderAddress":"tel:12345678", + "outboundSMSTextMessage":{ + "message":"Hello World" + }, + "clientCorrelator":"123456: AIN12345", + "receiptRequest":{ + "notifyURL":"http://application.example.com/notifications/DeliveryInfoNotification", + "callbackData":"some-data-useful-to-the-requester" + }, + "senderName":"ACME Inc.", + "resourceURL":"/tel:+12345678/requests/abc123 " + } +} +``` + + +Response : +201 CREATED will be returned if the service is successful. +Unless 400 Bad Request will be returned + + +- Query the delivery status of a SMS - Query the delivery status of an SMS which has been sent from your Web application. + +Request : + +Type - GET + +Request URI: +``` +http://:/smsmessaging/v1_2/outbound/{senderAddress}/requests/{requestId}/deliveryInfos +``` + + +Response : + +``` +{ + "deliveryInfoList":{ + "deliveryInfo":[ + { + "address":"tel:+94770000976", + "deliveryStatus":"MessageWaiting" + }, + { + "address":"tel:+94770000977", + "deliveryStatus":"MessageWaiting" + } + ], + "resourceURL":"/tel%3A%2B12345678/requests/abc123/deliveryInfos" + } +} +``` + + +Response : +200 OK will be returned if the service is successful. +Unless 400 Bad Request will be returned + + +- Subscribe to SMS delivery notifications - Start subscribing to delivery status notifications for all your sent SMS. + +Request : + +Type - POST + +Request URI: +``` +http://:/smsmessaging/v1_2/outbound/{Short Code}/subscriptions +``` + +Request Body : + +``` +{ + "deliveryReceiptSubscription":{ + "callbackReference":{ + "callbackData":"some-data-useful-to-the-requester ", + "notifyURL":" http://www.yoururl.here/notifications/DeliveryInfoNotification" + }, + "filterCriteria":"some-meaningful-filter-string" + } +} +``` + +Response : + +``` +{ + "deliveryReceiptSubscription":{ + "callbackReference":{ + "callbackData":" some-data-useful-to-the-requester ", + "notifyURL":" http://www.yoururl.here/notifications/DeliveryInfoNotification" + }, + "filterCriteria":"some-meaningful-filter-string", + "resourceURL":"https: ///outbound/subscription/sub789" + } +} +``` + +Response : +200 OK will be returned if the service is successful. +Unless 400 Bad Request will be returned + + + +- Stop the subscription to delivery notifications - Stop subscribing to delivery status notifications for all your sent SMS. + +Request : + +Type - DELETE + +Request URI: +``` +http://:/smsmessaging/v1_2/outbound/{senderAddress}/subscription/{subscriptionID} +``` + + +Response : +204 DELETED will be returned if the service is successful. +Unless 400 Bad Request will be returned + + + +- Receiving SMS - Retrieve SMS sent to your Web application. + +Request : + +Type - GET + +Request URI: +``` +http://:/smsmessaging/v1_2/inbound/registrations/{registrationId}/messages?maxBatchSize=2 +``` + +Response : + +``` +{ + "inboundSMSMessageList":{ + "inboundSMSMessage":[ + { + "dateTime":"2009-11-19T12:00:00", + "destinationAddress":"3456", + "messageId":"msg1", + "message":"Come on Barca!", + "resourceURL":"/3456/messages/msg1", + "senderAddress":"+947725123456" + }, + { + "dateTime":"2009-11-19T12:00:00", + "destinationAddress":"3456", + "messageId":"msg2", + "message":"Great goal by Messi", + "resourceURL":"/3456/messages/msg2", + "senderAddress":"+12345678012" + } + ], + "numberOfMessagesInThisBatch":"2", + "resourceURL":"/3456/messages", + "totalNumberOfPendingMessages":"20" + } +} +``` +Response : +200 OK will be returned if the service is successful. +Unless 400 Bad Request will be returned + + +- Subscribe to notifications of messages sent to your application - Subscribe to notifications for SMS messages sent to your Web application. + +Request : + +Type - POST + +Request URI: +``` +http://:/smsmessaging/v1_2//inbound/subscriptions +``` + +Request Body : + +``` +{ + "subscription":{ + "callbackReference":{ + "callbackData":"doSomething()", + "notifyURL":"http://www.yoururl.here/notifications/DeliveryInfoNotification" + }, + "criteria":"Vote", + "destinationAddress":"3456", + "notificationFormat":"JSON", + "clientCorrelator":"123456:AIN12345" + } +} +``` + +Response : + +``` +{ + "subscription":{ + "callbackReference":{ + "callbackData":"doSomething()", + "notifyURL":"http://www.yoururl.here/noti:cations/DeliveryInfoNoti:cation" + }, + "criteria":"Vote", + "destinationAddress":"3456", + "noti:cationFormat":"JSON", + "clientCorrelator":"123456:AIN12345", + "resourceURL":"/sub678" + } +} +``` + +Response : +201 CREATED will be returned if the service is successful. +Unless 400 Bad Request will be returned + + +- Stop the subscription to message notifications - Stop subscribing to notifications for SMS messages sent to your Web application. + +Request : + +Type - DELETE + +Request URI: +``` +http://:/smsmessaging/v1_2/inbound/subscriptions/{subscriptionID} +``` + +Response : +204 DELETED will be returned if the service is successful. +Unless 400 Bad Request will be returned + + +###6.8 USSD Service + +####6.8.1 Introduction + +USSD service will provide the Service providers a list of USSD services. Basically USSD API supports 1 operations. + +- Initiating Mobile Terminated USSD (NI USSD/ MT) - Initiates a USSD session with the intended end user. This request would pop up a USSD menu on the end users device. + + +####6.8.2 API features with postman testing + + +- Initiating Mobile Terminated USSD (NI USSD/ MT) - Initiates a USSD session with the intended end user. This request would pop up a USSD menu on the end users device. + +Request : + +Type - POST + +Request URI: +``` +http://://ussd/v1/outbound/{msisdn} +``` + +Request Body : + +``` +{ + "outboundUSSDMessageRequest":{ + "address":"tel:+123456789", + "shortCode":"tel:1234", + "keyword":"123", + "outboundUSSDMessage":"Login to service?\n1. Ok\n2. Cancel", + "clientCorrelator":"123456:AIN12345", + "responseRequest":{ + "notifyURL":"http://ussd.response.receive.url ", + "callbackData":"some-data-useful-to-the-requester" + }, + "ussdAction":"mtinit" + } +} +``` + +Response : + +``` +{ + "outboundUSSDMessageRequest":{ + "address":" tel:+123456789", + "keyword":"123", + "shortCode":"tel:1721", + "outboundUSSDMessage":" Login to service?\n1. Ok\n2. Cancel ", + "clientCorrelator":"123456:AIN12345", + "responseRequest":{ + "notifyURL":"http://ussd.response.receive.url ", + "callbackData":"some-data-useful-to-the-requester" + }, + "ussdAction":"mtinit", + "deliveryStatus":"SENT" + } +} +``` + + +Response : +201 CREATED will be returned if the service is successful. +Unless 400 Bad Request will be returned + + + +##7 Supported API Versions + +###7.1 Payment Service + +####7.1.1 Introduction + +Payment service will provide the Service providers a list of payment services available for the given MSISDN and based on the services available service provider can make/refund payment. Basically Payment API supports 2 operations. + +- Charge a User - Charge a subscriber for a service provided by your Web application + +Request : + +Type - POST + +Request URI: +``` +http://:/payment/v0_8/transaction/{endUserId}/amount +``` + +- Refund a User - Refund a end user + +Request : + +Type - POST + +Request URI: +``` +http://:/payment/v0_8/transaction/{endUserId}/amount diff --git a/dep-sandbox/dbscript/dep-sandbox.sql~ b/dep-sandbox/dbscript/dep-sandbox.sql~ deleted file mode 100644 index e3872244..00000000 --- a/dep-sandbox/dbscript/dep-sandbox.sql~ +++ /dev/null @@ -1,931 +0,0 @@ -CREATE DATABASE IF NOT EXISTS `dev2_mife_sandbox_hub` /*!40100 DEFAULT CHARACTER SET latin1 */; -USE `dev2_mife_sandbox_hub`; --- MySQL dump 10.13 Distrib 5.7.15, for Linux (x86_64) --- --- Host: localhost Database: dev2_mife_sandbox_hub --- ------------------------------------------------------ --- Server version 5.7.13-0ubuntu0.16.04.2 - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `charge_amount_request` --- - -DROP TABLE IF EXISTS `charge_amount_request`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `charge_amount_request` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `effect_date` date DEFAULT NULL, - `amount` double DEFAULT NULL, - `channel` varchar(255) DEFAULT NULL, - `client_correlator` varchar(255) DEFAULT NULL, - `code` varchar(255) DEFAULT NULL, - `currency` varchar(255) DEFAULT NULL, - `description` varchar(255) DEFAULT NULL, - `end_user_id` varchar(255) DEFAULT NULL, - `notify_url` varchar(255) DEFAULT NULL, - `on_behalf_of` varchar(255) DEFAULT NULL, - `purchase_cat_code` varchar(255) DEFAULT NULL, - `reference_code` varchar(255) DEFAULT NULL, - `tax_amount` double DEFAULT NULL, - `tran_oper_status` varchar(255) DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - `callback_data` varchar(255) DEFAULT NULL, - `mandate_id` varchar(255) DEFAULT NULL, - `notification_format` varchar(255) DEFAULT NULL, - `product_id` varchar(255) DEFAULT NULL, - `reference_sequence` int(11) DEFAULT NULL, - `original_server_reference_code` varchar(255) DEFAULT NULL, - `service_id` varchar(255) DEFAULT NULL, - `total_amount_charged` double DEFAULT NULL, - `amount_reserved` double DEFAULT NULL, - `transaction_id` varchar(255) DEFAULT NULL, - `payment_transaction_type` int(11) DEFAULT NULL, - `refund_status` int(11) DEFAULT '0', - PRIMARY KEY (`id`), - UNIQUE KEY `UK_haok1xtx5f32qy18r9yt06p31` (`client_correlator`), - KEY `FKB48C1E939E083448` (`user_id`), - CONSTRAINT `FKB48C1E939E083448` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `charge_amount_request` --- - -LOCK TABLES `charge_amount_request` WRITE; -/*!40000 ALTER TABLE `charge_amount_request` DISABLE KEYS */; -INSERT INTO `charge_amount_request` VALUES (1,'2016-04-27',10,'SMS','54321',NULL,'USD','Alien Invaders Game','tel:+94773524308',NULL,NULL,'Game','REF-12345',0.15,'Charged',1,NULL,NULL,NULL,NULL,0,NULL,NULL,10.15,0,'paytran-1',1,0),(2,'2016-05-02',10,'SMS','4027901',NULL,'USD','Alien Invaders Game','tel:+94123123123',NULL,NULL,'Game','REF-12345',0.15,'Charged',5,NULL,NULL,NULL,NULL,0,NULL,NULL,10.15,0,'paytran-2',1,0),(3,'2016-05-02',10,'SMS','5024530',NULL,'USD','Alien Invaders Game','tel:+94123123123',NULL,NULL,'Game','REF-12345',0.15,'Charged',5,NULL,NULL,NULL,NULL,0,NULL,NULL,10.15,0,'paytran-3',1,0),(4,'2016-05-02',10,'SMS','2067403',NULL,'USD','Alien Invaders Game','tel:+94123123123',NULL,NULL,'Game','REF-12345',0.15,'Charged',5,NULL,NULL,NULL,NULL,0,NULL,NULL,10.15,0,'paytran-4',1,0),(5,'2016-05-02',10,'SMS','3646144',NULL,'USD','Alien Invaders Game','tel:+94123123123',NULL,NULL,'Game','REF-12345',0.15,'Charged',5,NULL,NULL,NULL,NULL,0,NULL,NULL,10.15,0,'paytran-5',1,0),(6,'2016-05-02',10,'SMS','7069465',NULL,'USD','Alien Invaders Game','tel:+94123123123',NULL,NULL,'Game','REF-12345',0.15,'Charged',5,NULL,NULL,NULL,NULL,0,NULL,NULL,10.15,0,'paytran-6',1,0),(7,'2016-05-02',10,'SMS','3687508',NULL,'USD','Alien Invaders Game','tel:+94123123123',NULL,NULL,'Game','REF-12345',0.15,'Charged',5,NULL,NULL,NULL,NULL,0,NULL,NULL,10.15,0,'paytran-7',1,0),(8,'2016-05-02',10,'SMS','0987581',NULL,'USD','Alien Invaders Game','tel:+94123123123',NULL,NULL,'Game','REF-12345',0.15,'Charged',5,NULL,NULL,NULL,NULL,0,NULL,NULL,10.15,0,'paytran-8',1,1),(9,'2016-05-02',10,'SMS','3641564','ABC','USD','Alien Invaders Game','tel:+94123123123','http://localhost:8080/mifeapiserver/callback.jsp','Example Games Inc','Game','REF-12345',0.15,'Refunded',5,'54321','0000','54321','0000',0,'src-8','0000',0,0,'paytran-9',6,0),(10,'2016-05-02',10,'SMS','9317007',NULL,'USD','Alien Invaders Game','tel:+94123123123',NULL,NULL,'Game','REF-12345',0.15,'Charged',5,NULL,NULL,NULL,NULL,0,NULL,NULL,10.15,0,'paytran-10',1,0); -/*!40000 ALTER TABLE `charge_amount_request` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `locationparam` --- - -DROP TABLE IF EXISTS `locationparam`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `locationparam` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `altitude` varchar(255) DEFAULT NULL, - `latitude` varchar(255) DEFAULT NULL, - `longitude` varchar(255) DEFAULT NULL, - `loc_ret_status` varchar(255) DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `user_id` (`user_id`), - CONSTRAINT `locationparam_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `locationparam` --- - -LOCK TABLES `locationparam` WRITE; -/*!40000 ALTER TABLE `locationparam` DISABLE KEYS */; -INSERT INTO `locationparam` VALUES (1,'2341','45244444','135131','Retrieved',1); -/*!40000 ALTER TABLE `locationparam` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `locationtransactionlog` --- - -DROP TABLE IF EXISTS `locationtransactionlog`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `locationtransactionlog` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `address` varchar(255) DEFAULT NULL, - `requested_accuracy` double DEFAULT NULL, - `tran_oper_status` varchar(255) DEFAULT NULL, - `effect_date` date DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `user_id` (`user_id`), - CONSTRAINT `locationtransactionlog_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `locationtransactionlog` --- - -LOCK TABLES `locationtransactionlog` WRITE; -/*!40000 ALTER TABLE `locationtransactionlog` DISABLE KEYS */; -INSERT INTO `locationtransactionlog` VALUES (1,'tel:+94773524308',1000,'Retrieved','2016-04-27',1),(2,'tel:+94773524308',1000,'Retrieved','2016-04-27',1),(3,'tel:+94773524308',1000,'Retrieved','2016-04-27',1),(4,'tel:+94773524308',1000,'Retrieved','2016-08-24',1),(5,'tel:+94773524308',1000,'Retrieved','2016-08-24',1),(6,'tel:+94773524308',1000,'Retrieved','2016-08-24',1),(7,'tel:+94773524308',1000,'Retrieved','2016-08-24',1),(8,'tel:+94773524308',1000,'Retrieved','2016-08-24',1),(9,'tel:+94773524308',1000,'Retrieved','2016-08-24',1),(10,'tel:+94773524308',1000,'Retrieved','2016-08-24',1),(11,'tel:+94773524308',1000,'Retrieved','2016-08-24',1),(12,'tel:+94773524308',1000,'Retrieved','2016-08-24',4),(13,'tel:+94773524308',1000,'Retrieved','2016-08-24',4),(14,'tel:+94773524308',1000,'Retrieved','2016-08-24',1),(15,'tel:+94773524308',1000,'Retrieved','2016-08-29',1),(16,'tel:+94773524308',1000,'Retrieved','2016-08-29',1),(17,'tel:+94773524308',1000,'Retrieved','2016-08-30',1),(18,'tel:+94773524308',1000,'Retrieved','2016-08-30',1),(19,'tel:+94773524308',1000,'Retrieved','2016-08-30',1),(20,'tel:+94773524308',1000,'Retrieved','2016-08-31',1),(21,'tel:+94773524308',1000,'Retrieved','2016-08-31',1),(22,'tel:+94773524308',1000,'Retrieved','2016-08-31',1),(23,'tel:+94773524308',1000,'Retrieved','2016-09-08',1),(24,'tel:+94773524308',1000,'Retrieved','2016-09-08',1); -/*!40000 ALTER TABLE `locationtransactionlog` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `mobileidapiencoderequest` --- - -DROP TABLE IF EXISTS `mobileidapiencoderequest`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `mobileidapiencoderequest` ( - `mobIdApiId` int(11) NOT NULL AUTO_INCREMENT, - `consumerkey` varchar(255) DEFAULT NULL, - `consumersecret` varchar(255) DEFAULT NULL, - `authcode` varchar(255) DEFAULT NULL, - `granttype` varchar(45) DEFAULT NULL, - `username` varchar(45) DEFAULT NULL, - `password` varchar(45) DEFAULT NULL, - `scope` varchar(45) DEFAULT NULL, - `user` varchar(45) DEFAULT NULL, - `refreshToken` varchar(45) DEFAULT NULL, - `accessToken` varchar(45) DEFAULT NULL, - PRIMARY KEY (`mobIdApiId`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `mobileidapiencoderequest` --- - -LOCK TABLES `mobileidapiencoderequest` WRITE; -/*!40000 ALTER TABLE `mobileidapiencoderequest` DISABLE KEYS */; -/*!40000 ALTER TABLE `mobileidapiencoderequest` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `numbers` --- - -DROP TABLE IF EXISTS `numbers`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `numbers` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `number` varchar(255) DEFAULT NULL, - `num_balance` double DEFAULT NULL, - `reserved_amount` double NOT NULL DEFAULT '0', - `num_description` varchar(255) DEFAULT NULL, - `num_status` int(11) DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `FK88C28E4A9E083448` (`user_id`), - CONSTRAINT `FK88C28E4A9E083448` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `numbers` --- - -LOCK TABLES `numbers` WRITE; -/*!40000 ALTER TABLE `numbers` DISABLE KEYS */; -INSERT INTO `numbers` VALUES (1,'94773524308',989.85,0,'test number',1,1),(2,'94123123123',1000,0,'testAuxenta',1,5),(3,'945915648',1000,0,'dfaf',1,1); -/*!40000 ALTER TABLE `numbers` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `payment_gen` --- - -DROP TABLE IF EXISTS `payment_gen`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `payment_gen` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `delivery_status` varchar(255) DEFAULT NULL, - `max_pay_amount` varchar(255) DEFAULT NULL, - `max_tx_perday` varchar(255) DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `FKA4347D979E083448` (`user_id`), - CONSTRAINT `FKA4347D979E083448` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `payment_gen` --- - -LOCK TABLES `payment_gen` WRITE; -/*!40000 ALTER TABLE `payment_gen` DISABLE KEYS */; -/*!40000 ALTER TABLE `payment_gen` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `payment_transaction` --- - -DROP TABLE IF EXISTS `payment_transaction`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `payment_transaction` ( - `transaction_id` varchar(255) NOT NULL, - `effect_date` date DEFAULT NULL, - `amount` double DEFAULT NULL, - `currency` varchar(50) DEFAULT NULL, - `end_user_id` varchar(255) DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - PRIMARY KEY (`transaction_id`), - KEY `FKB154785395263845` (`user_id`), - CONSTRAINT `FKB48C1E55465448` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `payment_transaction` --- - -LOCK TABLES `payment_transaction` WRITE; -/*!40000 ALTER TABLE `payment_transaction` DISABLE KEYS */; -/*!40000 ALTER TABLE `payment_transaction` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `paymentparam` --- - -DROP TABLE IF EXISTS `paymentparam`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `paymentparam` ( - `ID` int(11) NOT NULL AUTO_INCREMENT, - `created` varchar(255) DEFAULT NULL, - `created_date` datetime DEFAULT NULL, - `lastupdated` varchar(255) DEFAULT NULL, - `lastupdated_date` datetime DEFAULT NULL, - `maxamt` double(11,2) DEFAULT NULL, - `maxtrn` int(11) DEFAULT NULL, - `paystatus` varchar(255) DEFAULT NULL, - `userid` int(11) DEFAULT NULL, - PRIMARY KEY (`ID`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `paymentparam` --- - -LOCK TABLES `paymentparam` WRITE; -/*!40000 ALTER TABLE `paymentparam` DISABLE KEYS */; -INSERT INTO `paymentparam` VALUES (1,NULL,NULL,NULL,NULL,100000000.00,1000,'Charged',1),(2,NULL,NULL,NULL,NULL,15000.00,1000,'Processing',2),(3,NULL,NULL,NULL,NULL,15000.00,1000,'Processing',3),(4,NULL,NULL,NULL,NULL,15000.00,1000,'Processing',4),(5,NULL,NULL,NULL,NULL,10.00,1000,'Charged',5); -/*!40000 ALTER TABLE `paymentparam` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sbtprmsisdnservicessmap` --- - -DROP TABLE IF EXISTS `sbtprmsisdnservicessmap`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sbtprmsisdnservicessmap` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `numbersid` int(11) NOT NULL, - `servicesid` int(11) NOT NULL, - PRIMARY KEY (`id`), - KEY `fk01sbtprmsisdnservicessmap` (`numbersid`), - KEY `fk02sbtprmsisdnservicessmap` (`servicesid`), - CONSTRAINT `fk01sbtprmsisdnservicessmap` FOREIGN KEY (`numbersid`) REFERENCES `numbers` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT `fk02sbtprmsisdnservicessmap` FOREIGN KEY (`servicesid`) REFERENCES `sbxprservices` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sbtprmsisdnservicessmap` --- - -LOCK TABLES `sbtprmsisdnservicessmap` WRITE; -/*!40000 ALTER TABLE `sbtprmsisdnservicessmap` DISABLE KEYS */; -INSERT INTO `sbtprmsisdnservicessmap` VALUES (1,1,1),(2,1,2),(3,2,1),(4,1,3),(5,2,2),(6,2,3); -/*!40000 ALTER TABLE `sbtprmsisdnservicessmap` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sbtprprovisionedservices` --- - -DROP TABLE IF EXISTS `sbtprprovisionedservices`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sbtprprovisionedservices` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `msisdnservicesmapid` int(11) DEFAULT NULL, - `clientcorrelator` varchar(100) DEFAULT NULL, - `clientreferencecode` varchar(45) DEFAULT NULL, - `notifyurl` varchar(255) DEFAULT NULL, - `callbackdata` varchar(45) DEFAULT NULL, - `statusid` int(11) DEFAULT NULL, - `createddate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - KEY `fk01sbtprsbtprprovisionedservices` (`statusid`), - KEY `fk02sbtprsbtprprovisionedservices` (`msisdnservicesmapid`), - CONSTRAINT `fk01sbtprsbtprprovisionedservices` FOREIGN KEY (`statusid`) REFERENCES `sbxstatus` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT `fk02sbtprsbtprprovisionedservices` FOREIGN KEY (`msisdnservicesmapid`) REFERENCES `sbtprmsisdnservicessmap` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sbtprprovisionedservices` --- - -LOCK TABLES `sbtprprovisionedservices` WRITE; -/*!40000 ALTER TABLE `sbtprprovisionedservices` DISABLE KEYS */; -INSERT INTO `sbtprprovisionedservices` VALUES (1,1,'12345','REF12345','http://application.com/notifyURL','',1,'0000-00-00 00:00:00'),(2,2,'1211','afs','afsfas',NULL,1,'2016-09-13 17:49:12'),(3,3,'',NULL,NULL,NULL,1,'2016-09-13 17:53:07'),(4,4,NULL,NULL,NULL,NULL,1,'2016-09-13 17:53:39'),(5,1,NULL,NULL,NULL,NULL,3,'2016-09-13 17:54:58'),(6,6,NULL,NULL,NULL,NULL,2,'2016-09-13 17:54:58'); -/*!40000 ALTER TABLE `sbtprprovisionedservices` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sbtprspexpectmessage` --- - -DROP TABLE IF EXISTS `sbtprspexpectmessage`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sbtprspexpectmessage` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `numberid` int(11) NOT NULL, - `messageid` int(11) NOT NULL, - `requesttype` varchar(50) DEFAULT NULL, - `servicesid` int(11) NOT NULL, - PRIMARY KEY (`id`), - KEY `fk01sbtprspexpectmessage` (`numberid`), - KEY `fk02sbtprspexpectmessage` (`messageid`), - KEY `fk03sbtprspexpectmessage` (`servicesid`), - CONSTRAINT `fk01sbtprspexpectmessage` FOREIGN KEY (`numberid`) REFERENCES `numbers` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT `fk02sbtprspexpectmessage` FOREIGN KEY (`messageid`) REFERENCES `sbxresponsemessage` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT `fk03sbtprspexpectmessage` FOREIGN KEY (`servicesid`) REFERENCES `sbxprservices` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sbtprspexpectmessage` --- - -LOCK TABLES `sbtprspexpectmessage` WRITE; -/*!40000 ALTER TABLE `sbtprspexpectmessage` DISABLE KEYS */; -INSERT INTO `sbtprspexpectmessage` VALUES (1,1,1,'PROVISION',1),(2,1,1,'DELETE',1); -/*!40000 ALTER TABLE `sbtprspexpectmessage` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sbxapitypes` --- - -DROP TABLE IF EXISTS `sbxapitypes`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sbxapitypes` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `apiname` varchar(50) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sbxapitypes` --- - -LOCK TABLES `sbxapitypes` WRITE; -/*!40000 ALTER TABLE `sbxapitypes` DISABLE KEYS */; -INSERT INTO `sbxapitypes` VALUES (1,'LOCATION'),(2,'SMS'),(3,'USSD'),(4,'PAYMENT'),(5,'CREDIT'),(6,'WALLET'),(7,'PROVISION'); -/*!40000 ALTER TABLE `sbxapitypes` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sbxprrequesstlog` --- - -DROP TABLE IF EXISTS `sbxprrequesstlog`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sbxprrequesstlog` ( - `provision_request_log_id` int(11) NOT NULL AUTO_INCREMENT, - `requesttype` varchar(50) NOT NULL, - `msisdn` varchar(50) NOT NULL, - `userid` int(11) NOT NULL, - `clientcorrelator` varchar(255) DEFAULT NULL, - `clientreferencecode` varchar(255) DEFAULT NULL, - `notifyurl` varchar(255) DEFAULT NULL, - `callbackdata` varchar(255) DEFAULT NULL, - `timestamp` date DEFAULT NULL, - PRIMARY KEY (`provision_request_log_id`) -) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sbxprrequesstlog` --- - -LOCK TABLES `sbxprrequesstlog` WRITE; -/*!40000 ALTER TABLE `sbxprrequesstlog` DISABLE KEYS */; -INSERT INTO `sbxprrequesstlog` VALUES (1,'QUERY_APPLICABLE','+9471123',1,NULL,NULL,NULL,NULL,'2016-09-07'),(2,'QUERY_APPLICABLE','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-07'),(3,'QUERY_APPLICABLE','el:+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-07'),(4,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(7,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(8,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(9,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(10,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(11,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(12,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(16,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(17,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(18,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(19,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(20,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(21,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(32,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(33,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(34,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(35,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(36,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(37,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(38,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(39,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(40,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(41,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(42,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(43,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(44,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(46,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(47,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(49,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(50,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(51,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(53,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(54,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(55,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(56,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(57,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(58,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(59,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(60,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(61,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(62,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(63,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(64,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(65,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(66,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(67,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(68,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(69,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(70,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(71,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(72,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(73,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(74,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(75,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(76,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(77,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(78,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(79,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(80,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(81,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(82,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(83,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(84,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(85,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(86,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(87,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(88,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-14'),(89,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-15'),(90,'LIST_ACTIVE_PROVISIONED_SERVICES','+94773524308',1,NULL,NULL,NULL,NULL,'2016-09-15'); -/*!40000 ALTER TABLE `sbxprrequesstlog` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sbxprservices` --- - -DROP TABLE IF EXISTS `sbxprservices`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sbxprservices` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `code` varchar(45) NOT NULL, - `name` varchar(45) NOT NULL, - `type` varchar(45) DEFAULT NULL, - `description` varchar(150) DEFAULT NULL, - `charge` float DEFAULT NULL, - `tag` varchar(45) DEFAULT NULL, - `value` varchar(45) DEFAULT NULL, - `userid` int(11) NOT NULL, -CONSTRAINT `pksbxprservices` PRIMARY KEY (`id`), -CONSTRAINT `fk01sbxprservice` FOREIGN KEY (`userid`) REFERENCES `user` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sbxprservices` --- - -LOCK TABLES `sbxprservices` WRITE; -/*!40000 ALTER TABLE `sbxprservices` DISABLE KEYS */; -INSERT INTO `sbxprservices` VALUES (1,'SRV0001','ROAM5G','ROAMING','ServiceDescription',10,'count','25',0),(2,'SRV0002','FBDATA','DATA','ServiceDescription',0,'limit','1000',0),(3,'SRV0003','VoIP','VOICE',NULL,NULL,NULL,NULL,0); -/*!40000 ALTER TABLE `sbxprservices` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sbxresponsemessage` --- - -DROP TABLE IF EXISTS `sbxresponsemessage`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sbxresponsemessage` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `categoryid` int(11) DEFAULT NULL, - `message` text, - `apitypeid` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `fk01sbxresponsemessage` (`categoryid`), - KEY `fk02sbxresponsemessage` (`apitypeid`), - CONSTRAINT `fk01sbxresponsemessage` FOREIGN KEY (`categoryid`) REFERENCES `sbxresponsemessagecategory` (`id`), - CONSTRAINT `fk02sbxresponsemessage` FOREIGN KEY (`apitypeid`) REFERENCES `sbxapitypes` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sbxresponsemessage` --- - -LOCK TABLES `sbxresponsemessage` WRITE; -/*!40000 ALTER TABLE `sbxresponsemessage` DISABLE KEYS */; -INSERT INTO `sbxresponsemessage` VALUES (1,1,'Service Not Available',7); -/*!40000 ALTER TABLE `sbxresponsemessage` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sbxresponsemessagecategory` --- - -DROP TABLE IF EXISTS `sbxresponsemessagecategory`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sbxresponsemessagecategory` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `category` varchar(50) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sbxresponsemessagecategory` --- - -LOCK TABLES `sbxresponsemessagecategory` WRITE; -/*!40000 ALTER TABLE `sbxresponsemessagecategory` DISABLE KEYS */; -INSERT INTO `sbxresponsemessagecategory` VALUES (1,'General Error'),(2,'Service Error'),(3,'Policy Error'); -/*!40000 ALTER TABLE `sbxresponsemessagecategory` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sbxstatus` --- - -DROP TABLE IF EXISTS `sbxstatus`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sbxstatus` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `status` varchar(45) DEFAULT NULL, - `code` varchar(40) DEFAULT NULL, - `description` varchar(100) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sbxstatus` --- - -LOCK TABLES `sbxstatus` WRITE; -/*!40000 ALTER TABLE `sbxstatus` DISABLE KEYS */; -INSERT INTO `sbxstatus` VALUES (1,'Pending','PRV_PROVISION_PENDING','Provision Transaction is pendign with subsystem'),(2,'Failed','PRV_PROVISION_FAILED','Provisioning failed due to subsystem error'),(3,'Success','PRV_PROVISION_SUCCESS','Successfully provisioned'),(4,'NotActive','PRV_DELETE_NOT_ACTIVE','Service not provisioned for user'),(5,'AlreadyActive','PRV_PROVISION_ALREADY_ACTIVE','Service already active'),(6,'Pending','PRV_DELETE_PENDING','Delete Transaction is pending with subsystem'),(7,'Failed','PRV_DELETE_FAILED','Removal failed due to subsystem error'),(8,'Success','PRV_DELETE_SUCCESS','Successfully removed'); -/*!40000 ALTER TABLE `sbxstatus` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `send_sms_to_application` --- - -DROP TABLE IF EXISTS `send_sms_to_application`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `send_sms_to_application` ( - `sms_id` int(11) NOT NULL AUTO_INCREMENT, - `effect_date` date DEFAULT NULL, - `destination_address` varchar(255) DEFAULT NULL, - `message` varchar(255) DEFAULT NULL, - `sender_address` varchar(255) DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - PRIMARY KEY (`sms_id`), - KEY `FKEBE4BF499E083448` (`user_id`), - CONSTRAINT `FKEBE4BF499E083448` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `send_sms_to_application` --- - -LOCK TABLES `send_sms_to_application` WRITE; -/*!40000 ALTER TABLE `send_sms_to_application` DISABLE KEYS */; -INSERT INTO `send_sms_to_application` VALUES (1,'2016-08-24','7555','Hello World','94773524308',1),(2,'2016-08-24','7555','Hello World','94773524308',1),(3,'2016-08-30','7555','Hello World','94773524308',1),(4,'2016-08-30','7555','Hello World','94773524308',1); -/*!40000 ALTER TABLE `send_sms_to_application` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sender_address` --- - -DROP TABLE IF EXISTS `sender_address`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sender_address` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(255) DEFAULT NULL, - `shortcode` varchar(255) DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `FKB79857EA9E083448` (`user_id`), - CONSTRAINT `FKB79857EA9E083448` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sender_address` --- - -LOCK TABLES `sender_address` WRITE; -/*!40000 ALTER TABLE `sender_address` DISABLE KEYS */; -INSERT INTO `sender_address` VALUES (1,'test number','7555',1); -/*!40000 ALTER TABLE `sender_address` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sms` --- - -DROP TABLE IF EXISTS `sms`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sms` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `deliveryStatus` varchar(255) DEFAULT NULL, - `maxNotifications` varchar(255) DEFAULT NULL, - `notificationDelay` varchar(255) DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `FK1BD599E083448` (`user_id`), - CONSTRAINT `FK1BD599E083448` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sms` --- - -LOCK TABLES `sms` WRITE; -/*!40000 ALTER TABLE `sms` DISABLE KEYS */; -/*!40000 ALTER TABLE `sms` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sms_delivery_status` --- - -DROP TABLE IF EXISTS `sms_delivery_status`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sms_delivery_status` ( - `transaction_id` varchar(255) NOT NULL, - `sender_address` varchar(255) DEFAULT NULL, - `delivery_status` varchar(255) DEFAULT NULL, - `effect_date` date DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - PRIMARY KEY (`transaction_id`), - KEY `FK_sycg0sik20gocmm2v5oqwh2o8` (`user_id`), - CONSTRAINT `FK_sycg0sik20gocmm2v5oqwh2o8` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sms_delivery_status` --- - -LOCK TABLES `sms_delivery_status` WRITE; -/*!40000 ALTER TABLE `sms_delivery_status` DISABLE KEYS */; -INSERT INTO `sms_delivery_status` VALUES ('smstran-1','tel:7555','DeliveredToTerminal','2016-08-24',1),('smstran-12','tel:7555','DeliveredToTerminal','2016-08-30',1),('smstran-13','tel:7555','DeliveredToTerminal','2016-08-30',1),('smstran-14','tel:7555','DeliveredToTerminal','2016-08-30',1),('smstran-15','tel:7555','DeliveredToTerminal','2016-08-30',1),('smstran-16','tel:7555','DeliveredToTerminal','2016-08-30',1),('smstran-17','tel:7555','DeliveredToTerminal','2016-08-30',1),('smstran-4','tel:7555','DeliveredToTerminal','2016-08-24',1),('smstran-6','tel:7555','DeliveredToTerminal','2016-08-24',1),('smstran-8','tel:7555','DeliveredToTerminal','2016-08-30',1); -/*!40000 ALTER TABLE `sms_delivery_status` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sms_delivery_subscription` --- - -DROP TABLE IF EXISTS `sms_delivery_subscription`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sms_delivery_subscription` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `user_id` int(11) DEFAULT NULL, - `sender_address` varchar(225) DEFAULT NULL, - `sub_status` int(11) NOT NULL DEFAULT '0', - `notify_url` varchar(225) DEFAULT NULL, - `filter` varchar(225) DEFAULT NULL, - `callbackdata` varchar(225) DEFAULT NULL, - `clientcorrelator` varchar(225) DEFAULT NULL, - `request` longtext, - PRIMARY KEY (`id`), - KEY `FK_adwhr1k8dr8pdh9osopmeg6b6` (`user_id`), - CONSTRAINT `FK_adwhr1k8dr8pdh9osopmeg6b6` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sms_delivery_subscription` --- - -LOCK TABLES `sms_delivery_subscription` WRITE; -/*!40000 ALTER TABLE `sms_delivery_subscription` DISABLE KEYS */; -/*!40000 ALTER TABLE `sms_delivery_subscription` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `sms_subscription` --- - -DROP TABLE IF EXISTS `sms_subscription`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sms_subscription` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `sub_number` varchar(255) DEFAULT NULL, - `sub_status` int(11) DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `FKA48A3E439E083448` (`user_id`), - CONSTRAINT `FKA48A3E439E083448` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `sms_subscription` --- - -LOCK TABLES `sms_subscription` WRITE; -/*!40000 ALTER TABLE `sms_subscription` DISABLE KEYS */; -/*!40000 ALTER TABLE `sms_subscription` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `smsparam` --- - -DROP TABLE IF EXISTS `smsparam`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `smsparam` ( - `ID` int(11) NOT NULL AUTO_INCREMENT, - `deliveryStatus` varchar(45) DEFAULT NULL, - `maxNotifications` varchar(11) DEFAULT NULL, - `notificationDelay` varchar(11) DEFAULT NULL, - `userid` int(11) DEFAULT NULL, - `created` varchar(255) DEFAULT NULL, - `created_date` datetime DEFAULT NULL, - `lastupdated` varchar(255) DEFAULT NULL, - `lastupdated_date` datetime DEFAULT NULL, - PRIMARY KEY (`ID`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `smsparam` --- - -LOCK TABLES `smsparam` WRITE; -/*!40000 ALTER TABLE `smsparam` DISABLE KEYS */; -INSERT INTO `smsparam` VALUES (1,'DeliveredToTerminal','1000','10',1,NULL,NULL,NULL,NULL),(2,'DeliveredToTerminal','1000','10',2,NULL,NULL,NULL,NULL),(3,'DeliveredToTerminal','1000','10',3,NULL,NULL,NULL,NULL),(4,'DeliveredToTerminal','1000','10',4,NULL,NULL,NULL,NULL),(5,'DeliveredToTerminal','1000','10',5,NULL,NULL,NULL,NULL); -/*!40000 ALTER TABLE `smsparam` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `smstransactionlog` --- - -DROP TABLE IF EXISTS `smstransactionlog`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `smstransactionlog` ( - `sms_id` int(11) NOT NULL AUTO_INCREMENT, - `effect_date` date DEFAULT NULL, - `addresses` varchar(255) DEFAULT NULL, - `callback_data` varchar(255) DEFAULT NULL, - `client_correlator` varchar(255) DEFAULT NULL, - `message` varchar(255) DEFAULT NULL, - `notify_url` varchar(255) DEFAULT NULL, - `sender_address` varchar(255) DEFAULT NULL, - `sender_name` varchar(255) DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - `batchsize` int(11) DEFAULT NULL, - `criteria` varchar(255) DEFAULT NULL, - `notificationFormat` varchar(255) DEFAULT NULL, - `trnstatus` varchar(255) DEFAULT NULL, - `transaction_id` varchar(255) DEFAULT NULL, - `request_id` varchar(255) DEFAULT NULL, - `txntype` int(11) DEFAULT NULL, - PRIMARY KEY (`sms_id`), - KEY `FK2A1D0F729E083448` (`user_id`), - CONSTRAINT `FK2A1D0F729E083448` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `smstransactionlog` --- - -LOCK TABLES `smstransactionlog` WRITE; -/*!40000 ALTER TABLE `smstransactionlog` DISABLE KEYS */; -INSERT INTO `smstransactionlog` VALUES (1,'2016-08-24','[tel:+94773524308]','some-data-useful-to-the-requester','123456:1472042340971SM11001','Test1','http://application.example.com/notifications/DeliveryInfoNotification','tel:7555',NULL,1,0,NULL,NULL,'success','smstran-1',NULL,1),(2,'2016-08-24',NULL,NULL,NULL,NULL,NULL,'7555',NULL,1,2,NULL,NULL,'success',NULL,NULL,2),(3,'2016-08-24',NULL,NULL,NULL,NULL,NULL,'tel:7555',NULL,1,0,NULL,NULL,'success',NULL,'smstran-1',5),(4,'2016-08-24','[tel:+94773524308]','some-data-useful-to-the-requester','123456:1472042912982SM11002','Test1','http://application.example.com/notifications/DeliveryInfoNotification','tel:7555',NULL,1,0,NULL,NULL,'success','smstran-4',NULL,1),(5,'2016-08-24',NULL,'doSomething()',NULL,NULL,'http://www.yoururl.here/notifications/DeliveryInfoNotification','7555',NULL,1,0,'Vote','JSON','success',NULL,NULL,3),(6,'2016-08-24','[tel:+94773524308]','some-data-useful-to-the-requester','123456:1472043111467SM11003','Test1','http://application.example.com/notifications/DeliveryInfoNotification','tel:7555',NULL,1,0,NULL,NULL,'success','smstran-6',NULL,1),(7,'2016-08-24',NULL,NULL,NULL,NULL,NULL,'tel:7555',NULL,1,0,NULL,NULL,'success',NULL,'smstran-6',5),(8,'2016-08-30','[tel:+94773524308]','some-data-useful-to-the-requester','123456:1472555967935SM11002','Hello World','http://application.example.com/notifications/DeliveryInfoNotification','tel:7555',NULL,1,0,NULL,NULL,'success','smstran-8',NULL,1),(9,'2016-08-30',NULL,NULL,NULL,NULL,NULL,'tel:7555',NULL,1,0,NULL,NULL,'success',NULL,'smstran-8',5),(10,'2016-08-30',NULL,NULL,NULL,NULL,NULL,'7555',NULL,1,1,NULL,NULL,'success',NULL,NULL,2),(11,'2016-08-30',NULL,NULL,NULL,NULL,NULL,'7555',NULL,1,2,NULL,NULL,'success',NULL,NULL,2),(12,'2016-08-30','[tel:+94773524308]','some-data-useful-to-the-requester','123456:1472556483791SM11003','Test1','http://application.example.com/notifications/DeliveryInfoNotification','tel:7555',NULL,1,0,NULL,NULL,'success','smstran-12',NULL,1),(13,'2016-08-30','[tel:+94773524308]','some-data-useful-to-the-requester','123456:1472557262623SM11004','Hello World','http://application.example.com/notifications/DeliveryInfoNotification','tel:7555',NULL,1,0,NULL,NULL,'success','smstran-13',NULL,1),(14,'2016-08-30','[tel:+94773524308]','some-data-useful-to-the-requester','123456:1472557268910SM11005','Hello World','http://application.example.com/notifications/DeliveryInfoNotification','tel:7555',NULL,1,0,NULL,NULL,'success','smstran-14',NULL,1),(15,'2016-08-30','[tel:+94773524308]','some-data-useful-to-the-requester','123456:1472557601440SM11006','Hello World','http://application.example.com/notifications/DeliveryInfoNotification','tel:7555',NULL,1,0,NULL,NULL,'success','smstran-15',NULL,1),(16,'2016-08-30','[tel:+94773524308]','some-data-useful-to-the-requester','1234567890:1472557624395SM11007','Hello World','http://application.example.com/notifications/DeliveryInfoNotification','tel:7555',NULL,1,0,NULL,NULL,'success','smstran-16',NULL,1),(17,'2016-08-30','[tel:+94773524308]','some-data-useful-to-the-requester','1234567890:1472557645748SM11008','Hello World','http://application.example.com/notifications/DeliveryInfoNotification/Test','tel:7555',NULL,1,0,NULL,NULL,'success','smstran-17',NULL,1); -/*!40000 ALTER TABLE `smstransactionlog` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `subscribe_sms_request` --- - -DROP TABLE IF EXISTS `subscribe_sms_request`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `subscribe_sms_request` ( - `subscribe_id` int(11) NOT NULL AUTO_INCREMENT, - `effect_date` date DEFAULT NULL, - `callback_data` varchar(255) DEFAULT NULL, - `client_correlator` varchar(255) DEFAULT NULL, - `criteria` varchar(255) DEFAULT NULL, - `destination_address` varchar(255) DEFAULT NULL, - `notification_format` varchar(255) DEFAULT NULL, - `notify_url` varchar(255) DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - PRIMARY KEY (`subscribe_id`), - KEY `FKC8368A349E083448` (`user_id`), - CONSTRAINT `FKC8368A349E083448` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `subscribe_sms_request` --- - -LOCK TABLES `subscribe_sms_request` WRITE; -/*!40000 ALTER TABLE `subscribe_sms_request` DISABLE KEYS */; -INSERT INTO `subscribe_sms_request` VALUES (1,'2016-08-24','doSomething()','12345','Vote','7555','JSON','http://www.yoururl.here/notifications/DeliveryInfoNotification',1); -/*!40000 ALTER TABLE `subscribe_sms_request` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `user` --- - -DROP TABLE IF EXISTS `user`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `user` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `user_name` varchar(255) DEFAULT NULL, - `user_status` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `UK_lqjrcobrh9jc8wpcar64q1bfh` (`user_name`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `user` --- - -LOCK TABLES `user` WRITE; -/*!40000 ALTER TABLE `user` DISABLE KEYS */; -INSERT INTO `user` VALUES (1,'admin',1),(2,'AuxWithoutAggregate',1),(3,'AuxTestUser',1),(4,'AuxLogoutUser',1),(5,'AutInvSP1',1); -/*!40000 ALTER TABLE `user` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `ussd_subscription` --- - -DROP TABLE IF EXISTS `ussd_subscription`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `ussd_subscription` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `callbackData` varchar(255) DEFAULT NULL, - `clientCorrelator` varchar(255) DEFAULT NULL, - `created_date` date DEFAULT NULL, - `destinationAddress` varchar(255) DEFAULT NULL, - `effect_date` date DEFAULT NULL, - `notifyUrl` varchar(255) DEFAULT NULL, - `resourceUrl` varchar(255) DEFAULT NULL, - `subscriptionId` varchar(255) DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - `subStatus` int(11) NOT NULL, - PRIMARY KEY (`id`), - KEY `FK_ec81kos30iygc5p1gcfq0m9md` (`user_id`), - CONSTRAINT `FK_ec81kos30iygc5p1gcfq0m9md` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `ussd_subscription` --- - -LOCK TABLES `ussd_subscription` WRITE; -/*!40000 ALTER TABLE `ussd_subscription` DISABLE KEYS */; -/*!40000 ALTER TABLE `ussd_subscription` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `ussd_transactions` --- - -DROP TABLE IF EXISTS `ussd_transactions`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `ussd_transactions` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `actionStatus` int(11) NOT NULL, - `address` varchar(255) DEFAULT NULL, - `callbackData` varchar(255) DEFAULT NULL, - `clientCorrelator` varchar(255) DEFAULT NULL, - `effect_date` date DEFAULT NULL, - `keyword` varchar(255) DEFAULT NULL, - `message` varchar(255) DEFAULT NULL, - `notifyUrl` varchar(255) DEFAULT NULL, - `sessionId` varchar(255) DEFAULT NULL, - `shortCode` varchar(255) DEFAULT NULL, - `ussdAction` varchar(255) DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `FK_f6e3wvsa0gqeft93d6r8uo4qx` (`user_id`), - CONSTRAINT `FK_f6e3wvsa0gqeft93d6r8uo4qx` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `ussd_transactions` --- - -LOCK TABLES `ussd_transactions` WRITE; -/*!40000 ALTER TABLE `ussd_transactions` DISABLE KEYS */; -/*!40000 ALTER TABLE `ussd_transactions` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2016-09-15 11:06:21 diff --git a/dep-sandbox/dbscripts/dep-sandbox1_5_0.sql b/dep-sandbox/dbscripts/dep-sandbox1_7_0.sql similarity index 94% rename from dep-sandbox/dbscripts/dep-sandbox1_5_0.sql rename to dep-sandbox/dbscripts/dep-sandbox1_7_0.sql index e377cd06..1ebcc83b 100644 --- a/dep-sandbox/dbscripts/dep-sandbox1_5_0.sql +++ b/dep-sandbox/dbscripts/dep-sandbox1_7_0.sql @@ -29,7 +29,7 @@ CREATE TABLE IF NOT EXISTS `sbxapitypes` ( -- Dumping data for table `sbxapitypes` -- -INSERT INTO `sbxapitypes` VALUES (1,'LOCATION'),(2,'SMS'),(3,'USSD'),(4,'PAYMENT'),(5,'CREDIT'),(6,'WALLET'),(7,'PROVISIONING'),(8,'CUSTOMERINFO'); +INSERT INTO `sbxapitypes` VALUES (1,'LOCATION'),(2,'SMSMESSAGING'),(3,'USSD'),(4,'PAYMENT'),(5,'CREDIT'),(6,'WALLET'),(7,'PROVISIONING'),(8,'CUSTOMERINFO'); -- @@ -49,7 +49,8 @@ CREATE TABLE IF NOT EXISTS `sbxapiservicecalls` ( -- Dumping data for table `sbxapiservicecalls` -- -INSERT INTO `sbxapiservicecalls` VALUES (1,8,'GetAttribute'),(2,8,'GetProfile'),(3,7,'GetApplicable'),(4,6,'MakePayment'),(5,6,'ListPayment'),(6,6,'RefundPayment'),(7,6,'BalanceLookup'),(8,5,'ApplyCredit'),(9,5,'PartialRefund'); +INSERT INTO `sbxapiservicecalls` VALUES (1,8,'GetAttribute'),(2,8,'GetProfile'),(3,7,'GetApplicable'),(4,6,'MakePayment'),(5,6,'ListPayment'),(6,6,'RefundPayment'),(7,6,'BalanceLookup'),(8,5,'ApplyCredit'),(9,5,'PartialRefund'),(10,4,'ChargeUser'),(11,4,'RefundUser'),(12,4,'ListPayment'),(13,1,'Location'),(14,3,'InitUSSD'),(15,2,'SendSMS'),(16,2,'ReceivingSMS'),(17,2,'QuerySMSStatus'),(18,2,'SubscribeToSMSDelivery'),(19,2,'SubscribeToApplication'),(20,2,'StopSubscriptionDelivery'),(21,2,'StopSubscribeToApplication'),(22,7,'ListService'),(23,7,'QueryService'); + @@ -178,6 +179,10 @@ CREATE TABLE IF NOT EXISTS `numbers` ( `reserved_amount` double NOT NULL DEFAULT '0', `num_description` varchar(255) DEFAULT NULL, `num_status` int(11) DEFAULT NULL, + `altitude` VARCHAR(255) DEFAULT NULL, + `latitude` VARCHAR(255) DEFAULT NULL, + `longitude` VARCHAR(255) DEFAULT NULL, + `loc_ret_status` VARCHAR(45) DEFAULT NULL, `user_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), CONSTRAINT `FK88C28E4A9E083448` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) @@ -187,7 +192,7 @@ CREATE TABLE IF NOT EXISTS `numbers` ( -- Dumping data for table `numbers` -- -INSERT INTO `numbers` VALUES (1,'94773524308',4343,3413,13414,989.85,0,'test number',1,1),(2,'94123123123',1344,134413,13413,1000,0,'testAuxenta',1,5),(3,'94771564812',134134,13431,1343,1000,0,'dfaf',1,1); +INSERT INTO `numbers` VALUES (1,'94773524308',4343,3413,13414,989.85,0,'test number',1,'2341','45244444','135131','Retrieved',1),(2,'94123123123',1344,134413,13413,1000,0,'testAuxenta',1,'','','','',5),(3,'94771564812',134134,13431,1343,1000,0,'dfaf',1,'','','','',1); -- -- Table structure for table `payment_gen` @@ -376,7 +381,7 @@ CREATE TABLE IF NOT EXISTS `sbxattribute` ( -- Dumping data for table `sbxattribute` -- -INSERT INTO `sbxattribute` VALUES (1,'title'),(2,'firstName'),(3,'lastName'),(4,'dob'),(5,'address'),(6,'identificationType'),(7,'status'),(8,'ownerType'),(9,'accountType'),(10,'basic'),(11,'billing'),(12,'identification'),(13,'account'),(14,'additionalInfo'),(15,'identificationNumber'),(16,'clientCorrelatorWallet'),(17,'transactionStatus'),(18,'accountStatus'),(19,'currency'),(20,'payment'),(21,'refund'),(22,'sms'),(23,'data'),(24,'minutes'),(25,'referenceCodeCredit'),(26,'clientCorrelator'),(27,'applyCredit'),(28,'referenceCodeWallet'); +INSERT INTO `sbxattribute` VALUES (1,'title'),(2,'firstName'),(3,'lastName'),(4,'dob'),(5,'address'),(6,'identificationType'),(7,'status'),(8,'ownerType'),(9,'accountType'),(10,'basic'),(11,'billing'),(12,'identification'),(13,'account'),(14,'additionalInfo'),(15,'identificationNumber'),(16,'clientCorrelatorWallet'),(17,'transactionStatus'),(18,'accountStatus'),(19,'currency'),(20,'payment'),(21,'refund'),(22,'sms'),(23,'data'),(24,'minutes'),(25,'referenceCodeCredit'),(26,'clientCorrelator'),(27,'applyCredit'),(28,'referenceCodeWallet'),(29,'patialRefund'),(30,'makePayment'),(31,'clientCorrelatorPayment'),(32,'referenceCodePayment'),(33,'refundUser'); -- -- Table structure for table `sbtattributedistribution` -- @@ -394,7 +399,7 @@ CREATE TABLE IF NOT EXISTS `sbtattributedistribution` ( -- Dumping data for table `sbtattributedistribution` -- -INSERT INTO `sbtattributedistribution` VALUES (1,1,2),(2,2,2),(3,3,2),(4,4,2),(5,5,2),(6,6,2),(7,7,2),(8,8,2),(9,9,2),(10,10,1),(11,11,1),(12,12,1),(13,13,1),(14,14,2),(15,15,2),(16,16,4),(17,16,6),(18,17,4),(19,17,6),(20,18,7),(21,19,7),(22,20,4),(23,21,6),(24,22,8),(25,23,8),(26,24,8),(27,25,8),(28,26,8),(29,27,8),(30,28,4),(31,28,6); +INSERT INTO `sbtattributedistribution` VALUES (1,1,2),(2,2,2),(3,3,2),(4,4,2),(5,5,2),(6,6,2),(7,7,2),(8,8,2),(9,9,2),(10,10,1),(11,11,1),(12,12,1),(13,13,1),(14,14,2),(15,15,2),(16,16,4),(17,16,6),(18,17,4),(19,17,6),(20,18,7),(21,19,7),(22,20,4),(23,21,6),(24,22,8),(25,23,8),(26,24,8),(27,25,8),(28,26,8),(29,27,8),(30,28,4),(31,28,6),(32,29,9),(33,26,9),(34,25,9),(35,30,10),(36,31,10),(37,32,10),(38,33,11),(39,31,11),(40,32,11); -- @@ -668,6 +673,8 @@ CREATE TABLE IF NOT EXISTS `ussd_transactions` ( CREATE TABLE IF NOT EXISTS `sbtmessagelog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `request` text, + `status` int(11) DEFAULT 0, + `type` int(11) DEFAULT 0, `servicenameid` int(11) NOT NULL, `userid` int(11) NOT NULL, `reference` varchar(100) DEFAULT NULL, @@ -678,3 +685,15 @@ CREATE TABLE IF NOT EXISTS `sbtmessagelog` ( CONSTRAINT `fk02sbtmessagelog` FOREIGN KEY (`userid`) REFERENCES `user` (`id`) ); +-- +-- Table structure for table `ussd_applications` +-- + +CREATE TABLE IF NOT EXISTS `ussd_applications` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `userid` int(11) NOT NULL, + `shortCode` varchar(255) NOT NULL, + `keyword` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + CONSTRAINT `fk01ussd_application` FOREIGN KEY (`userid`) REFERENCES `user` (`id`) +); \ No newline at end of file diff --git a/dep-sandbox/dbscripts/migration1_6_0to1_7_0.sql b/dep-sandbox/dbscripts/migration1_6_0to1_7_0.sql new file mode 100644 index 00000000..b8971e87 --- /dev/null +++ b/dep-sandbox/dbscripts/migration1_6_0to1_7_0.sql @@ -0,0 +1,22 @@ +USE `sandbox`; + +INSERT INTO `sbxapiservicecalls` VALUES (14,3,'InitUSSD'),(15,2,'SendSMS'),(16,2,'ReceivingSMS'),(17,2,'QuerySMSStatus'),(18,2,'SubscribeToSMSDelivery'),(19,2,'SubscribeToApplication'),(20,2,'StopSubscriptionDelivery'),(21,2,'StopSubscribeToApplication'); + +UPDATE `sbxapitypes` SET `apiname`='SMSMESSAGING' WHERE `id`='2'; + + +CREATE TABLE IF NOT EXISTS `ussd_applications` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `userid` int(11) NOT NULL, + `shortCode` varchar(255) NOT NULL, + `keyword` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + CONSTRAINT `fk01ussd_application` FOREIGN KEY (`userid`) REFERENCES `user` (`id`) +); + + +ALTER TABLE `sandbox`.`numbers` +ADD COLUMN `altitude` VARCHAR(255) NULL DEFAULT NULL AFTER `num_status`, +ADD COLUMN `latitude` VARCHAR(255) NULL DEFAULT NULL AFTER `altitude`, +ADD COLUMN `longitude` VARCHAR(255) NULL DEFAULT NULL AFTER `latitude`, +ADD COLUMN `loc_ret_status` VARCHAR(45) NULL DEFAULT NULL AFTER `longitude`; diff --git a/dep-sandbox/dbscripts/migration1_7_0to1_7_1.sql b/dep-sandbox/dbscripts/migration1_7_0to1_7_1.sql new file mode 100644 index 00000000..608beef6 --- /dev/null +++ b/dep-sandbox/dbscripts/migration1_7_0to1_7_1.sql @@ -0,0 +1 @@ +INSERT INTO `sbxapiservicecalls` VALUES (22,7,'ListService'),(23,7,'QueryService'); \ No newline at end of file diff --git a/dep-sandbox/deploy/config.yml b/dep-sandbox/deploy/config.yml index ee9303be..2698b070 100644 --- a/dep-sandbox/deploy/config.yml +++ b/dep-sandbox/deploy/config.yml @@ -1,7 +1,7 @@ database: driverClass: com.mysql.cj.jdbc.Driver user: root - password: + password: url: jdbc:mysql:///?useSSL=false server: applicationConnectors: @@ -39,3 +39,5 @@ logging: timeZone: UTC requestIdentifierSize: 6 + +behaveType: # Gateway or Hub \ No newline at end of file diff --git a/dep-sandbox/log/sandbox_service.log b/dep-sandbox/log/sandbox_service.log new file mode 100644 index 00000000..a0d0d8f7 --- /dev/null +++ b/dep-sandbox/log/sandbox_service.log @@ -0,0 +1,1682 @@ +INFO [2017-02-06 04:39:09,915] org.eclipse.jetty.util.log: Logging initialized @1076ms +INFO [2017-02-06 04:39:09,997] io.dropwizard.assets.AssetsBundle: Registering AssetBundle with name: swagger-assets for path /swagger-static/* +INFO [2017-02-06 04:39:10,175] io.dropwizard.server.ServerFactory: Starting Application +INFO [2017-02-06 04:39:10,181] io.dropwizard.server.DefaultServerFactory: Registering jersey handler with root path prefix: / +INFO [2017-02-06 04:39:10,191] io.dropwizard.server.DefaultServerFactory: Registering admin handler with root path prefix: / +INFO [2017-02-06 04:39:10,250] org.eclipse.jetty.setuid.SetUIDListener: Opened application@5f577419{HTTP/1.1}{localhost:8181} +INFO [2017-02-06 04:39:10,250] org.eclipse.jetty.setuid.SetUIDListener: Opened admin@28fa700e{HTTP/1.1}{0.0.0.0:8282} +INFO [2017-02-06 04:39:10,252] org.eclipse.jetty.server.Server: jetty-9.2.z-SNAPSHOT +INFO [2017-02-06 04:39:11,101] io.dropwizard.jersey.DropwizardResourceConfig: The following paths were found for the configured resources: + + GET /api-docs (com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON) + GET /api-docs/{route: .+} (com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON) + POST /credit/{v1}/credit/{msisdn}/apply (com.wso2telco.services.dep.sandbox.service.CreditService) + POST /customerinfo/{v1}/config/customer/attribute (com.wso2telco.services.dep.sandbox.service.CustomerInfoConfigurationService) + POST /customerinfo/{v1}/config/customer/profile (com.wso2telco.services.dep.sandbox.service.CustomerInfoConfigurationService) + GET /customerinfo/{v1}/customer/attribute (com.wso2telco.services.dep.sandbox.service.CustomerInfoService) + GET /customerinfo/{v1}/customer/profile (com.wso2telco.services.dep.sandbox.service.CustomerInfoService) + GET /location/{v1}/queries/location (com.wso2telco.services.dep.sandbox.service.SandboxService) + GET /provisioning/{v1}/config/service (com.wso2telco.services.dep.sandbox.service.ProvisionConfigurationService) + POST /provisioning/{v1}/config/service (com.wso2telco.services.dep.sandbox.service.ProvisionConfigurationService) + POST /provisioning/{v1}/config/{msisdn}/service/{serviceCode} (com.wso2telco.services.dep.sandbox.service.ProvisionConfigurationService) + POST /provisioning/{v1}/{msisdn} (com.wso2telco.services.dep.sandbox.service.ProvisionService) + GET /provisioning/{v1}/{msisdn}/list/active (com.wso2telco.services.dep.sandbox.service.ProvisionService) + GET /provisioning/{v1}/{msisdn}/list/applicable (com.wso2telco.services.dep.sandbox.service.ProvisionService) + POST /provisioning/{v1}/{msisdn}/remove (com.wso2telco.services.dep.sandbox.service.ProvisionService) + POST /smsmessaging/{apiVersion}/outbound/{shortCode}/requests (com.wso2telco.services.dep.sandbox.service.SandboxService) + GET /smsmessaging/{apiVersion}/outbound/{shortCode}/requests/{mtSMSTransactionId}/deliveryInfos (com.wso2telco.services.dep.sandbox.service.SandboxService) + GET /swagger (io.federecio.dropwizard.swagger.SwaggerResource) + GET /user/apiType (com.wso2telco.services.dep.sandbox.service.UserService) + POST /user/managenumber (com.wso2telco.services.dep.sandbox.service.UserService) + GET /user/{apiType}/serviceType (com.wso2telco.services.dep.sandbox.service.UserService) + GET /user/{apiType}/{serviceType}/attribute (com.wso2telco.services.dep.sandbox.service.UserService) + POST /user/{userName}/register (com.wso2telco.services.dep.sandbox.service.UserService) + GET /wallet/{v1}/config/{apiType}/{serviceType}/getAccountStatus (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + GET /wallet/{v1}/config/{apiType}/{serviceType}/getTransactionStatus (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + POST /wallet/{v1}/config/{endUserId}/addAccountInfo (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + POST /wallet/{v1}/config/{endUserId}/addTransactionStatus (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + GET /wallet/{v1}/transaction/{endUserId}/balance (com.wso2telco.services.dep.sandbox.service.WalletService) + GET /wallet/{v1}/transaction/{endUserId}/list (com.wso2telco.services.dep.sandbox.service.WalletService) + POST /wallet/{v1}/transaction/{endUserId}/payment (com.wso2telco.services.dep.sandbox.service.WalletService) + POST /wallet/{v1}/transaction/{endUserId}/refund (com.wso2telco.services.dep.sandbox.service.WalletService) + +INFO [2017-02-06 04:39:11,104] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler@2ab0702e{/,null,AVAILABLE} +INFO [2017-02-06 04:39:11,109] io.dropwizard.setup.AdminEnvironment: tasks = + + POST /tasks/log-level (io.dropwizard.servlets.tasks.LogConfigurationTask) + POST /tasks/gc (io.dropwizard.servlets.tasks.GarbageCollectionTask) + +WARN [2017-02-06 04:39:11,109] io.dropwizard.setup.AdminEnvironment: +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! THIS APPLICATION HAS NO HEALTHCHECKS. THIS MEANS YOU WILL NEVER KNOW ! +! IF IT DIES IN PRODUCTION, WHICH MEANS YOU WILL NEVER KNOW IF YOU'RE ! +! LETTING YOUR USERS DOWN. YOU SHOULD ADD A HEALTHCHECK FOR EACH OF YOUR ! +! APPLICATION'S DEPENDENCIES WHICH FULLY (BUT LIGHTLY) TESTS IT. ! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +INFO [2017-02-06 04:39:11,117] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler@5a2bd7c8{/,null,AVAILABLE} +INFO [2017-02-06 04:39:11,158] org.eclipse.jetty.server.ServerConnector: Started application@5f577419{HTTP/1.1}{localhost:8181} +INFO [2017-02-06 04:39:11,159] org.eclipse.jetty.server.ServerConnector: Started admin@28fa700e{HTTP/1.1}{0.0.0.0:8282} +INFO [2017-02-06 04:39:11,160] org.eclipse.jetty.server.Server: Started @2323ms +DEBUG [2017-02-06 04:51:04,682] com.wso2telco.services.dep.sandbox.service.UserService: 0.0 0.0 1 0 0 +DEBUG [2017-02-06 04:51:04,684] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 04:51:04,684] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING NUMBER SERVICE CALL +DEBUG [2017-02-06 04:51:04,689] com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-06 04:51:04,809] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +ERROR [2017-02-06 04:51:04,813] com.wso2telco.services.dep.sandbox.service.UserService: ###ADD MANAGE NUMBER### Error encountered in UserService : +! java.lang.StringIndexOutOfBoundsException: String index out of range: 0 +! at java.lang.String.charAt(String.java:658) ~[na:1.8.0_121] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.checkMSISDN(ManageNumberServiceHandler.java:137) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:51) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:25) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.execute(AbstractRequestHandler.java:66) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.service.UserService.addManageNumber(UserService.java:230) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +DEBUG [2017-02-06 04:52:01,577] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 04:52:01,577] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING API TYPES +DEBUG [2017-02-06 04:52:01,578] com.wso2telco.services.dep.sandbox.servicefactory.user.RetrieveAPITypeServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-06 04:52:01,580] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +DEBUG [2017-02-06 04:52:01,626] com.wso2telco.services.dep.sandbox.service.UserService: GET API TYPES SERVICE RESPONSE : OutboundJaxrsResponse{status=200, reason=OK, hasEntity=true, closed=false, buffered=false} +DEBUG [2017-02-06 04:57:40,577] com.wso2telco.services.dep.sandbox.service.ProvisionService: /{msisdn}/list/active invoked :MSISDNnullnull +DEBUG [2017-02-06 04:57:40,577] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING PROVISIONING FACTORY +DEBUG [2017-02-06 04:57:40,577] com.wso2telco.services.dep.sandbox.servicefactory.provisioning.ProvisioningServiceFactory: ###PROVISION### LOADING LIST OF PROVISIONED SERVICES +DEBUG [2017-02-06 04:57:40,580] com.wso2telco.services.dep.sandbox.servicefactory.provisioning.ListActiveProvisionedServices: Sandbox user : sandbox +DEBUG [2017-02-06 04:57:40,582] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +ERROR [2017-02-06 04:57:40,585] com.wso2telco.services.dep.sandbox.servicefactory.provisioning.ListActiveProvisionedServices: ###PROVISION### Error in Validation : com.wso2telco.dep.oneapivalidation.exceptions.CustomException: SVC0004 +ERROR [2017-02-06 04:57:40,587] com.wso2telco.services.dep.sandbox.service.ProvisionService: LIST ACTIVE PROVISIONED SERVICESE ERROR : +! java.lang.NullPointerException: null +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.getNotWhitelistedNumbers(AbstractRequestHandler.java:95) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.execute(AbstractRequestHandler.java:71) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.service.ProvisionService.getActiveProvisionedServices(ProvisionService.java:123) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:364) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +DEBUG [2017-02-06 04:59:32,365] com.wso2telco.services.dep.sandbox.service.ProvisionConfigurationService: /service invoked : +DEBUG [2017-02-06 04:59:32,366] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING PROVISIONING CONFIGURATION FACTORY +DEBUG [2017-02-06 04:59:32,366] com.wso2telco.services.dep.sandbox.servicefactory.provisionConfig.ProvisioningConfigServiceFactory: ###PROVISIONCONFIG### LOADING SERVICES FOR USER +DEBUG [2017-02-06 04:59:32,368] com.wso2telco.services.dep.sandbox.servicefactory.provisionConfig.RetieveServicesUser: Sandbox user : sandbox +DEBUG [2017-02-06 04:59:32,377] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +ERROR [2017-02-06 04:59:32,378] com.wso2telco.services.dep.sandbox.servicefactory.provisionConfig.RetieveServicesUser: ###PROVISION### Error in Process : java.lang.NullPointerException +DEBUG [2017-02-06 04:59:32,378] com.wso2telco.services.dep.sandbox.service.ProvisionConfigurationService: QUERY AVAILVABLE SERVICE FOR USER RESPONSE : OutboundJaxrsResponse{status=400, reason=Bad Request, hasEntity=true, closed=false, buffered=false} +DEBUG [2017-02-06 05:01:49,128] com.wso2telco.services.dep.sandbox.service.UserService: 0.0 0.0 0 0 0 +DEBUG [2017-02-06 05:01:49,128] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 05:01:49,128] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING NUMBER SERVICE CALL +DEBUG [2017-02-06 05:01:49,128] com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-06 05:01:49,131] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +ERROR [2017-02-06 05:01:49,132] com.wso2telco.services.dep.sandbox.service.UserService: ###ADD MANAGE NUMBER### Error encountered in UserService : +! java.lang.StringIndexOutOfBoundsException: String index out of range: 0 +! at java.lang.String.charAt(String.java:658) ~[na:1.8.0_121] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.checkMSISDN(ManageNumberServiceHandler.java:137) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:51) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:25) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.execute(AbstractRequestHandler.java:66) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.service.UserService.addManageNumber(UserService.java:230) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +DEBUG [2017-02-06 05:02:11,894] com.wso2telco.services.dep.sandbox.service.UserService: 1 10.0 10.0 0 0 0 +DEBUG [2017-02-06 05:02:11,894] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 05:02:11,894] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING NUMBER SERVICE CALL +DEBUG [2017-02-06 05:02:11,894] com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-06 05:02:11,896] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +ERROR [2017-02-06 05:02:11,918] com.wso2telco.services.dep.sandbox.util.CommonUtil: Error in Parsing MSISDN +! com.wso2telco.core.msisdnvalidator.InvalidMSISDNException: null +! at com.wso2telco.core.msisdnvalidator.MSISDNUtil.parse(MSISDNUtil.java:31) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.util.CommonUtil.extractNumberFromMsisdn(CommonUtil.java:85) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:82) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:25) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.execute(AbstractRequestHandler.java:66) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.service.UserService.addManageNumber(UserService.java:230) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +ERROR [2017-02-06 05:02:11,919] com.wso2telco.services.dep.sandbox.service.UserService: ###ADD MANAGE NUMBER### Error encountered in UserService : +! com.wso2telco.core.msisdnvalidator.InvalidMSISDNException: null +! at com.wso2telco.core.msisdnvalidator.MSISDNUtil.parse(MSISDNUtil.java:31) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.util.CommonUtil.extractNumberFromMsisdn(CommonUtil.java:85) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:82) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:25) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.execute(AbstractRequestHandler.java:66) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.service.UserService.addManageNumber(UserService.java:230) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +DEBUG [2017-02-06 05:03:07,376] com.wso2telco.services.dep.sandbox.service.UserService: 0.0 0.0 1 0 0 +DEBUG [2017-02-06 05:03:07,376] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 05:03:07,376] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING NUMBER SERVICE CALL +DEBUG [2017-02-06 05:03:07,376] com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-06 05:03:07,378] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +ERROR [2017-02-06 05:03:07,379] com.wso2telco.services.dep.sandbox.service.UserService: ###ADD MANAGE NUMBER### Error encountered in UserService : +! java.lang.StringIndexOutOfBoundsException: String index out of range: 0 +! at java.lang.String.charAt(String.java:658) ~[na:1.8.0_121] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.checkMSISDN(ManageNumberServiceHandler.java:137) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:51) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:25) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.execute(AbstractRequestHandler.java:66) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.service.UserService.addManageNumber(UserService.java:230) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +DEBUG [2017-02-06 05:03:20,152] com.wso2telco.services.dep.sandbox.service.UserService: 1 0.0 0.0 1 0 0 +DEBUG [2017-02-06 05:03:20,152] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 05:03:20,152] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING NUMBER SERVICE CALL +DEBUG [2017-02-06 05:03:20,152] com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-06 05:03:20,154] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +ERROR [2017-02-06 05:03:20,155] com.wso2telco.services.dep.sandbox.util.CommonUtil: Error in Parsing MSISDN +! com.wso2telco.core.msisdnvalidator.InvalidMSISDNException: null +! at com.wso2telco.core.msisdnvalidator.MSISDNUtil.parse(MSISDNUtil.java:31) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.util.CommonUtil.extractNumberFromMsisdn(CommonUtil.java:85) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:82) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:25) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.execute(AbstractRequestHandler.java:66) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.service.UserService.addManageNumber(UserService.java:230) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +ERROR [2017-02-06 05:03:20,156] com.wso2telco.services.dep.sandbox.service.UserService: ###ADD MANAGE NUMBER### Error encountered in UserService : +! com.wso2telco.core.msisdnvalidator.InvalidMSISDNException: null +! at com.wso2telco.core.msisdnvalidator.MSISDNUtil.parse(MSISDNUtil.java:31) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.util.CommonUtil.extractNumberFromMsisdn(CommonUtil.java:85) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:82) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:25) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.execute(AbstractRequestHandler.java:66) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.service.UserService.addManageNumber(UserService.java:230) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +DEBUG [2017-02-06 05:03:25,630] com.wso2telco.services.dep.sandbox.service.UserService: 0.0 0.0 1 0 0 +DEBUG [2017-02-06 05:03:25,630] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 05:03:25,630] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING NUMBER SERVICE CALL +DEBUG [2017-02-06 05:03:25,630] com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-06 05:03:25,633] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +ERROR [2017-02-06 05:03:25,634] com.wso2telco.services.dep.sandbox.service.UserService: ###ADD MANAGE NUMBER### Error encountered in UserService : +! java.lang.StringIndexOutOfBoundsException: String index out of range: 0 +! at java.lang.String.charAt(String.java:658) ~[na:1.8.0_121] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.checkMSISDN(ManageNumberServiceHandler.java:137) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:51) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:25) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.execute(AbstractRequestHandler.java:66) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.service.UserService.addManageNumber(UserService.java:230) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +DEBUG [2017-02-06 05:06:11,143] com.wso2telco.services.dep.sandbox.service.UserService: 10.0 0.0 1 0 0 +DEBUG [2017-02-06 05:06:11,143] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 05:06:11,143] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING NUMBER SERVICE CALL +DEBUG [2017-02-06 05:06:11,143] com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-06 05:06:11,146] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +ERROR [2017-02-06 05:06:11,146] com.wso2telco.services.dep.sandbox.service.UserService: ###ADD MANAGE NUMBER### Error encountered in UserService : +! java.lang.StringIndexOutOfBoundsException: String index out of range: 0 +! at java.lang.String.charAt(String.java:658) ~[na:1.8.0_121] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.checkMSISDN(ManageNumberServiceHandler.java:137) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:51) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:25) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.execute(AbstractRequestHandler.java:66) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.service.UserService.addManageNumber(UserService.java:230) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +DEBUG [2017-02-06 05:06:13,200] com.wso2telco.services.dep.sandbox.service.UserService: 10.0 0.0 1 0 0 +DEBUG [2017-02-06 05:06:13,200] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 05:06:13,200] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING NUMBER SERVICE CALL +DEBUG [2017-02-06 05:06:13,200] com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-06 05:06:13,202] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +ERROR [2017-02-06 05:06:13,203] com.wso2telco.services.dep.sandbox.service.UserService: ###ADD MANAGE NUMBER### Error encountered in UserService : +! java.lang.StringIndexOutOfBoundsException: String index out of range: 0 +! at java.lang.String.charAt(String.java:658) ~[na:1.8.0_121] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.checkMSISDN(ManageNumberServiceHandler.java:137) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:51) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:25) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.execute(AbstractRequestHandler.java:66) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.service.UserService.addManageNumber(UserService.java:230) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +DEBUG [2017-02-06 05:06:14,035] com.wso2telco.services.dep.sandbox.service.UserService: 10.0 0.0 1 0 0 +DEBUG [2017-02-06 05:06:14,035] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 05:06:14,035] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING NUMBER SERVICE CALL +DEBUG [2017-02-06 05:06:14,035] com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-06 05:06:14,038] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +ERROR [2017-02-06 05:06:14,038] com.wso2telco.services.dep.sandbox.service.UserService: ###ADD MANAGE NUMBER### Error encountered in UserService : +! java.lang.StringIndexOutOfBoundsException: String index out of range: 0 +! at java.lang.String.charAt(String.java:658) ~[na:1.8.0_121] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.checkMSISDN(ManageNumberServiceHandler.java:137) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:51) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:25) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.execute(AbstractRequestHandler.java:66) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.service.UserService.addManageNumber(UserService.java:230) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +DEBUG [2017-02-06 05:06:17,510] com.wso2telco.services.dep.sandbox.service.UserService: 10.0 10.0 1 0 0 +DEBUG [2017-02-06 05:06:17,510] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 05:06:17,510] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING NUMBER SERVICE CALL +DEBUG [2017-02-06 05:06:17,510] com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-06 05:06:17,513] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +ERROR [2017-02-06 05:06:17,513] com.wso2telco.services.dep.sandbox.service.UserService: ###ADD MANAGE NUMBER### Error encountered in UserService : +! java.lang.StringIndexOutOfBoundsException: String index out of range: 0 +! at java.lang.String.charAt(String.java:658) ~[na:1.8.0_121] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.checkMSISDN(ManageNumberServiceHandler.java:137) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:51) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:25) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.execute(AbstractRequestHandler.java:66) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.service.UserService.addManageNumber(UserService.java:230) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +DEBUG [2017-02-06 05:06:18,340] com.wso2telco.services.dep.sandbox.service.UserService: 10.0 10.0 1 0 0 +DEBUG [2017-02-06 05:06:18,340] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 05:06:18,340] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING NUMBER SERVICE CALL +DEBUG [2017-02-06 05:06:18,340] com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-06 05:06:18,342] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +ERROR [2017-02-06 05:06:18,344] com.wso2telco.services.dep.sandbox.service.UserService: ###ADD MANAGE NUMBER### Error encountered in UserService : +! java.lang.StringIndexOutOfBoundsException: String index out of range: 0 +! at java.lang.String.charAt(String.java:658) ~[na:1.8.0_121] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.checkMSISDN(ManageNumberServiceHandler.java:137) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:51) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:25) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.execute(AbstractRequestHandler.java:66) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.service.UserService.addManageNumber(UserService.java:230) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +DEBUG [2017-02-06 05:06:18,783] com.wso2telco.services.dep.sandbox.service.UserService: 10.0 10.0 1 0 0 +DEBUG [2017-02-06 05:06:18,783] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 05:06:18,783] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING NUMBER SERVICE CALL +DEBUG [2017-02-06 05:06:18,783] com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-06 05:06:18,785] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +ERROR [2017-02-06 05:06:18,786] com.wso2telco.services.dep.sandbox.service.UserService: ###ADD MANAGE NUMBER### Error encountered in UserService : +! java.lang.StringIndexOutOfBoundsException: String index out of range: 0 +! at java.lang.String.charAt(String.java:658) ~[na:1.8.0_121] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.checkMSISDN(ManageNumberServiceHandler.java:137) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:51) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:25) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.execute(AbstractRequestHandler.java:66) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.service.UserService.addManageNumber(UserService.java:230) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +DEBUG [2017-02-06 05:07:19,539] com.wso2telco.services.dep.sandbox.service.UserService: 0.0 0.0 1 0 0 +DEBUG [2017-02-06 05:07:19,540] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 05:07:19,540] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING NUMBER SERVICE CALL +DEBUG [2017-02-06 05:07:19,540] com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-06 05:07:19,542] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +ERROR [2017-02-06 05:07:19,543] com.wso2telco.services.dep.sandbox.service.UserService: ###ADD MANAGE NUMBER### Error encountered in UserService : +! java.lang.StringIndexOutOfBoundsException: String index out of range: 0 +! at java.lang.String.charAt(String.java:658) ~[na:1.8.0_121] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.checkMSISDN(ManageNumberServiceHandler.java:137) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:51) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:25) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.execute(AbstractRequestHandler.java:66) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.service.UserService.addManageNumber(UserService.java:230) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +DEBUG [2017-02-06 05:20:18,726] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 05:20:18,726] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING API TYPES +DEBUG [2017-02-06 05:20:18,726] com.wso2telco.services.dep.sandbox.servicefactory.user.RetrieveAPITypeServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-06 05:20:18,727] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +DEBUG [2017-02-06 05:20:18,736] com.wso2telco.services.dep.sandbox.service.UserService: GET API TYPES SERVICE RESPONSE : OutboundJaxrsResponse{status=200, reason=OK, hasEntity=true, closed=false, buffered=false} +DEBUG [2017-02-06 05:20:42,111] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 05:20:42,111] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING API SERVICE CALL TYPES +DEBUG [2017-02-06 05:20:42,115] com.wso2telco.services.dep.sandbox.servicefactory.user.RetrieveAPIServicecallHandler: Sandbox user : sandbox +DEBUG [2017-02-06 05:20:42,118] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +ERROR [2017-02-06 05:20:42,224] com.wso2telco.services.dep.sandbox.servicefactory.user.RetrieveAPIServicecallHandler: ###USER### No any service call is provided for given api LOCATION +DEBUG [2017-02-06 05:20:42,224] com.wso2telco.services.dep.sandbox.service.UserService: GET API SERVICE CALLS RESPONSE : OutboundJaxrsResponse{status=400, reason=Bad Request, hasEntity=true, closed=false, buffered=false} +DEBUG [2017-02-06 05:25:20,786] com.wso2telco.services.dep.sandbox.service.UserService: 0.0 0.0 0 0 0 +DEBUG [2017-02-06 05:25:20,786] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 05:25:20,786] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING NUMBER SERVICE CALL +DEBUG [2017-02-06 05:25:20,786] com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-06 05:25:20,787] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +ERROR [2017-02-06 05:25:20,788] com.wso2telco.services.dep.sandbox.service.UserService: ###ADD MANAGE NUMBER### Error encountered in UserService : +! java.lang.StringIndexOutOfBoundsException: String index out of range: 0 +! at java.lang.String.charAt(String.java:658) ~[na:1.8.0_121] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.checkMSISDN(ManageNumberServiceHandler.java:137) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:51) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:25) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.execute(AbstractRequestHandler.java:66) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.service.UserService.addManageNumber(UserService.java:230) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +DEBUG [2017-02-06 05:25:35,777] com.wso2telco.services.dep.sandbox.service.UserService: 0.0 0.0 0 0 0 +DEBUG [2017-02-06 05:25:35,777] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 05:25:35,777] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING NUMBER SERVICE CALL +DEBUG [2017-02-06 05:25:35,777] com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-06 05:25:35,778] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +ERROR [2017-02-06 05:25:35,779] com.wso2telco.services.dep.sandbox.service.UserService: ###ADD MANAGE NUMBER### Error encountered in UserService : +! java.lang.StringIndexOutOfBoundsException: String index out of range: 0 +! at java.lang.String.charAt(String.java:658) ~[na:1.8.0_121] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.checkMSISDN(ManageNumberServiceHandler.java:137) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:51) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.user.ManageNumberServiceHandler.validate(ManageNumberServiceHandler.java:25) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler.execute(AbstractRequestHandler.java:66) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.wso2telco.services.dep.sandbox.service.UserService.addManageNumber(UserService.java:230) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +INFO [2017-02-06 05:28:34,540] org.eclipse.jetty.server.ServerConnector: Stopped application@5f577419{HTTP/1.1}{localhost:8181} +INFO [2017-02-06 05:28:34,540] org.eclipse.jetty.server.ServerConnector: Stopped admin@28fa700e{HTTP/1.1}{0.0.0.0:8282} +INFO [2017-02-06 05:28:34,541] org.eclipse.jetty.server.handler.ContextHandler: Stopped i.d.j.MutableServletContextHandler@5a2bd7c8{/,null,UNAVAILABLE} +INFO [2017-02-06 05:28:34,543] org.eclipse.jetty.server.handler.ContextHandler: Stopped i.d.j.MutableServletContextHandler@2ab0702e{/,null,UNAVAILABLE} +INFO [2017-02-06 06:36:04,307] org.eclipse.jetty.util.log: Logging initialized @1016ms +INFO [2017-02-06 06:36:04,413] io.dropwizard.assets.AssetsBundle: Registering AssetBundle with name: swagger-assets for path /swagger-static/* +INFO [2017-02-06 06:36:04,641] io.dropwizard.server.ServerFactory: Starting Application +INFO [2017-02-06 06:36:04,649] io.dropwizard.server.DefaultServerFactory: Registering jersey handler with root path prefix: / +INFO [2017-02-06 06:36:04,662] io.dropwizard.server.DefaultServerFactory: Registering admin handler with root path prefix: / +INFO [2017-02-06 06:36:04,704] org.eclipse.jetty.setuid.SetUIDListener: Opened application@5f577419{HTTP/1.1}{localhost:8181} +INFO [2017-02-06 06:36:04,704] org.eclipse.jetty.setuid.SetUIDListener: Opened admin@28fa700e{HTTP/1.1}{0.0.0.0:8282} +INFO [2017-02-06 06:36:04,707] org.eclipse.jetty.server.Server: jetty-9.2.z-SNAPSHOT +INFO [2017-02-06 06:36:05,400] io.dropwizard.jersey.DropwizardResourceConfig: The following paths were found for the configured resources: + + GET /api-docs (com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON) + GET /api-docs/{route: .+} (com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON) + POST /credit/{v1}/credit/{msisdn}/apply (com.wso2telco.services.dep.sandbox.service.CreditService) + POST /customerinfo/{v1}/config/customer/attribute (com.wso2telco.services.dep.sandbox.service.CustomerInfoConfigurationService) + POST /customerinfo/{v1}/config/customer/profile (com.wso2telco.services.dep.sandbox.service.CustomerInfoConfigurationService) + GET /customerinfo/{v1}/customer/attribute (com.wso2telco.services.dep.sandbox.service.CustomerInfoService) + GET /customerinfo/{v1}/customer/profile (com.wso2telco.services.dep.sandbox.service.CustomerInfoService) + GET /location/{v1}/queries/location (com.wso2telco.services.dep.sandbox.service.SandboxService) + GET /provisioning/{v1}/config/service (com.wso2telco.services.dep.sandbox.service.ProvisionConfigurationService) + POST /provisioning/{v1}/config/service (com.wso2telco.services.dep.sandbox.service.ProvisionConfigurationService) + POST /provisioning/{v1}/config/{msisdn}/service/{serviceCode} (com.wso2telco.services.dep.sandbox.service.ProvisionConfigurationService) + POST /provisioning/{v1}/{msisdn} (com.wso2telco.services.dep.sandbox.service.ProvisionService) + GET /provisioning/{v1}/{msisdn}/list/active (com.wso2telco.services.dep.sandbox.service.ProvisionService) + GET /provisioning/{v1}/{msisdn}/list/applicable (com.wso2telco.services.dep.sandbox.service.ProvisionService) + POST /provisioning/{v1}/{msisdn}/remove (com.wso2telco.services.dep.sandbox.service.ProvisionService) + POST /smsmessaging/{apiVersion}/outbound/{shortCode}/requests (com.wso2telco.services.dep.sandbox.service.SandboxService) + GET /smsmessaging/{apiVersion}/outbound/{shortCode}/requests/{mtSMSTransactionId}/deliveryInfos (com.wso2telco.services.dep.sandbox.service.SandboxService) + GET /swagger (io.federecio.dropwizard.swagger.SwaggerResource) + GET /user/apiType (com.wso2telco.services.dep.sandbox.service.UserService) + POST /user/managenumber (com.wso2telco.services.dep.sandbox.service.UserService) + GET /user/{apiType}/serviceType (com.wso2telco.services.dep.sandbox.service.UserService) + GET /user/{apiType}/{serviceType}/attribute (com.wso2telco.services.dep.sandbox.service.UserService) + POST /user/{userName}/register (com.wso2telco.services.dep.sandbox.service.UserService) + GET /wallet/{v1}/config/{apiType}/{serviceType}/getAccountStatus (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + GET /wallet/{v1}/config/{apiType}/{serviceType}/getTransactionStatus (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + POST /wallet/{v1}/config/{endUserId}/addAccountInfo (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + POST /wallet/{v1}/config/{endUserId}/addTransactionStatus (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + GET /wallet/{v1}/transaction/{endUserId}/balance (com.wso2telco.services.dep.sandbox.service.WalletService) + GET /wallet/{v1}/transaction/{endUserId}/list (com.wso2telco.services.dep.sandbox.service.WalletService) + POST /wallet/{v1}/transaction/{endUserId}/payment (com.wso2telco.services.dep.sandbox.service.WalletService) + POST /wallet/{v1}/transaction/{endUserId}/refund (com.wso2telco.services.dep.sandbox.service.WalletService) + +INFO [2017-02-06 06:36:05,403] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler@2ab0702e{/,null,AVAILABLE} +INFO [2017-02-06 06:36:05,408] io.dropwizard.setup.AdminEnvironment: tasks = + + POST /tasks/log-level (io.dropwizard.servlets.tasks.LogConfigurationTask) + POST /tasks/gc (io.dropwizard.servlets.tasks.GarbageCollectionTask) + +WARN [2017-02-06 06:36:05,408] io.dropwizard.setup.AdminEnvironment: +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! THIS APPLICATION HAS NO HEALTHCHECKS. THIS MEANS YOU WILL NEVER KNOW ! +! IF IT DIES IN PRODUCTION, WHICH MEANS YOU WILL NEVER KNOW IF YOU'RE ! +! LETTING YOUR USERS DOWN. YOU SHOULD ADD A HEALTHCHECK FOR EACH OF YOUR ! +! APPLICATION'S DEPENDENCIES WHICH FULLY (BUT LIGHTLY) TESTS IT. ! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +INFO [2017-02-06 06:36:05,413] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler@5a2bd7c8{/,null,AVAILABLE} +INFO [2017-02-06 06:36:05,419] org.eclipse.jetty.server.ServerConnector: Started application@5f577419{HTTP/1.1}{localhost:8181} +INFO [2017-02-06 06:36:05,420] org.eclipse.jetty.server.ServerConnector: Started admin@28fa700e{HTTP/1.1}{0.0.0.0:8282} +INFO [2017-02-06 06:36:05,420] org.eclipse.jetty.server.Server: Started @2132ms +DEBUG [2017-02-06 06:37:49,973] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-06 06:37:49,973] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING API TYPES +DEBUG [2017-02-06 06:37:49,978] com.wso2telco.services.dep.sandbox.servicefactory.user.RetrieveAPITypeServiceHandler: Sandbox user : null +DEBUG [2017-02-06 06:37:49,978] com.wso2telco.services.dep.sandbox.servicefactory.user.RetrieveAPITypeServiceHandler: AuthToken: null +DEBUG [2017-02-06 06:37:51,967] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : null +DEBUG [2017-02-06 06:37:51,990] com.wso2telco.services.dep.sandbox.service.UserService: GET API TYPES SERVICE RESPONSE : OutboundJaxrsResponse{status=200, reason=OK, hasEntity=true, closed=false, buffered=false} +INFO [2017-02-06 06:38:40,221] org.eclipse.jetty.server.ServerConnector: Stopped application@5f577419{HTTP/1.1}{localhost:8181} +INFO [2017-02-06 06:38:40,223] org.eclipse.jetty.server.ServerConnector: Stopped admin@28fa700e{HTTP/1.1}{0.0.0.0:8282} +INFO [2017-02-06 06:38:40,225] org.eclipse.jetty.server.handler.ContextHandler: Stopped i.d.j.MutableServletContextHandler@5a2bd7c8{/,null,UNAVAILABLE} +INFO [2017-02-06 06:38:40,227] org.eclipse.jetty.server.handler.ContextHandler: Stopped i.d.j.MutableServletContextHandler@2ab0702e{/,null,UNAVAILABLE} +INFO [2017-02-07 03:51:51,825] org.eclipse.jetty.util.log: Logging initialized @2819ms +INFO [2017-02-07 03:51:51,945] io.dropwizard.assets.AssetsBundle: Registering AssetBundle with name: swagger-assets for path /swagger-static/* +INFO [2017-02-07 03:51:52,173] io.dropwizard.server.ServerFactory: Starting Application +INFO [2017-02-07 03:51:52,180] io.dropwizard.server.DefaultServerFactory: Registering jersey handler with root path prefix: / +INFO [2017-02-07 03:51:52,208] io.dropwizard.server.DefaultServerFactory: Registering admin handler with root path prefix: / +INFO [2017-02-07 03:51:52,330] org.eclipse.jetty.setuid.SetUIDListener: Opened application@e041f0c{HTTP/1.1}{localhost:8181} +INFO [2017-02-07 03:51:52,332] org.eclipse.jetty.setuid.SetUIDListener: Opened admin@6a175569{HTTP/1.1}{0.0.0.0:8282} +INFO [2017-02-07 03:51:52,336] org.eclipse.jetty.server.Server: jetty-9.2.z-SNAPSHOT +INFO [2017-02-07 03:51:53,321] io.dropwizard.jersey.DropwizardResourceConfig: The following paths were found for the configured resources: + + GET /api-docs (com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON) + GET /api-docs/{route: .+} (com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON) + POST /credit/{v1}/credit/{msisdn}/apply (com.wso2telco.services.dep.sandbox.service.CreditService) + POST /customerinfo/{v1}/config/customer/attribute (com.wso2telco.services.dep.sandbox.service.CustomerInfoConfigurationService) + POST /customerinfo/{v1}/config/customer/profile (com.wso2telco.services.dep.sandbox.service.CustomerInfoConfigurationService) + GET /customerinfo/{v1}/customer/attribute (com.wso2telco.services.dep.sandbox.service.CustomerInfoService) + GET /customerinfo/{v1}/customer/profile (com.wso2telco.services.dep.sandbox.service.CustomerInfoService) + GET /location/{v1}/queries/location (com.wso2telco.services.dep.sandbox.service.SandboxService) + GET /provisioning/{v1}/config/service (com.wso2telco.services.dep.sandbox.service.ProvisionConfigurationService) + POST /provisioning/{v1}/config/service (com.wso2telco.services.dep.sandbox.service.ProvisionConfigurationService) + POST /provisioning/{v1}/config/{msisdn}/service/{serviceCode} (com.wso2telco.services.dep.sandbox.service.ProvisionConfigurationService) + POST /provisioning/{v1}/{msisdn} (com.wso2telco.services.dep.sandbox.service.ProvisionService) + GET /provisioning/{v1}/{msisdn}/list/active (com.wso2telco.services.dep.sandbox.service.ProvisionService) + GET /provisioning/{v1}/{msisdn}/list/applicable (com.wso2telco.services.dep.sandbox.service.ProvisionService) + POST /provisioning/{v1}/{msisdn}/remove (com.wso2telco.services.dep.sandbox.service.ProvisionService) + POST /smsmessaging/{apiVersion}/outbound/{shortCode}/requests (com.wso2telco.services.dep.sandbox.service.SandboxService) + GET /smsmessaging/{apiVersion}/outbound/{shortCode}/requests/{mtSMSTransactionId}/deliveryInfos (com.wso2telco.services.dep.sandbox.service.SandboxService) + GET /swagger (io.federecio.dropwizard.swagger.SwaggerResource) + GET /user/apiType (com.wso2telco.services.dep.sandbox.service.UserService) + POST /user/managenumber (com.wso2telco.services.dep.sandbox.service.UserService) + GET /user/{apiType}/serviceType (com.wso2telco.services.dep.sandbox.service.UserService) + GET /user/{apiType}/{serviceType}/attribute (com.wso2telco.services.dep.sandbox.service.UserService) + POST /user/{userName}/register (com.wso2telco.services.dep.sandbox.service.UserService) + GET /wallet/{v1}/config/{apiType}/{serviceType}/getAccountStatus (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + GET /wallet/{v1}/config/{apiType}/{serviceType}/getTransactionStatus (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + POST /wallet/{v1}/config/{endUserId}/addAccountInfo (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + POST /wallet/{v1}/config/{endUserId}/addTransactionStatus (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + GET /wallet/{v1}/transaction/{endUserId}/balance (com.wso2telco.services.dep.sandbox.service.WalletService) + GET /wallet/{v1}/transaction/{endUserId}/list (com.wso2telco.services.dep.sandbox.service.WalletService) + POST /wallet/{v1}/transaction/{endUserId}/payment (com.wso2telco.services.dep.sandbox.service.WalletService) + POST /wallet/{v1}/transaction/{endUserId}/refund (com.wso2telco.services.dep.sandbox.service.WalletService) + +INFO [2017-02-07 03:51:53,325] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler@102efc59{/,null,AVAILABLE} +INFO [2017-02-07 03:51:53,331] io.dropwizard.setup.AdminEnvironment: tasks = + + POST /tasks/log-level (io.dropwizard.servlets.tasks.LogConfigurationTask) + POST /tasks/gc (io.dropwizard.servlets.tasks.GarbageCollectionTask) + +WARN [2017-02-07 03:51:53,331] io.dropwizard.setup.AdminEnvironment: +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! THIS APPLICATION HAS NO HEALTHCHECKS. THIS MEANS YOU WILL NEVER KNOW ! +! IF IT DIES IN PRODUCTION, WHICH MEANS YOU WILL NEVER KNOW IF YOU'RE ! +! LETTING YOUR USERS DOWN. YOU SHOULD ADD A HEALTHCHECK FOR EACH OF YOUR ! +! APPLICATION'S DEPENDENCIES WHICH FULLY (BUT LIGHTLY) TESTS IT. ! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +INFO [2017-02-07 03:51:53,337] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler@6b8280e6{/,null,AVAILABLE} +INFO [2017-02-07 03:51:53,387] org.eclipse.jetty.server.ServerConnector: Started application@e041f0c{HTTP/1.1}{localhost:8181} +INFO [2017-02-07 03:51:53,387] org.eclipse.jetty.server.ServerConnector: Started admin@6a175569{HTTP/1.1}{0.0.0.0:8282} +INFO [2017-02-07 03:51:53,387] org.eclipse.jetty.server.Server: Started @4383ms +DEBUG [2017-02-07 03:52:18,675] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-07 03:52:18,676] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING API TYPES +DEBUG [2017-02-07 03:52:18,683] com.wso2telco.services.dep.sandbox.servicefactory.user.RetrieveAPITypeServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-07 03:52:18,844] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +DEBUG [2017-02-07 03:52:18,866] com.wso2telco.services.dep.sandbox.service.UserService: GET API TYPES SERVICE RESPONSE : OutboundJaxrsResponse{status=200, reason=OK, hasEntity=true, closed=false, buffered=false} +DEBUG [2017-02-07 04:50:38,661] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-07 04:50:38,663] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING API TYPES +DEBUG [2017-02-07 04:50:38,663] com.wso2telco.services.dep.sandbox.servicefactory.user.RetrieveAPITypeServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-07 04:50:38,667] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +DEBUG [2017-02-07 04:50:38,669] com.wso2telco.services.dep.sandbox.service.UserService: GET API TYPES SERVICE RESPONSE : OutboundJaxrsResponse{status=200, reason=OK, hasEntity=true, closed=false, buffered=false} +INFO [2017-02-07 04:53:23,884] org.eclipse.jetty.server.ServerConnector: Stopped application@e041f0c{HTTP/1.1}{localhost:8181} +INFO [2017-02-07 04:53:23,888] org.eclipse.jetty.server.ServerConnector: Stopped admin@6a175569{HTTP/1.1}{0.0.0.0:8282} +INFO [2017-02-07 04:53:23,888] org.eclipse.jetty.server.handler.ContextHandler: Stopped i.d.j.MutableServletContextHandler@6b8280e6{/,null,UNAVAILABLE} +INFO [2017-02-07 04:53:23,892] org.eclipse.jetty.server.handler.ContextHandler: Stopped i.d.j.MutableServletContextHandler@102efc59{/,null,UNAVAILABLE} +INFO [2017-02-07 04:54:20,648] org.eclipse.jetty.util.log: Logging initialized @1166ms +INFO [2017-02-07 04:54:20,754] io.dropwizard.assets.AssetsBundle: Registering AssetBundle with name: swagger-assets for path /swagger-static/* +INFO [2017-02-07 04:54:21,018] io.dropwizard.server.ServerFactory: Starting Application +INFO [2017-02-07 04:54:21,025] io.dropwizard.server.DefaultServerFactory: Registering jersey handler with root path prefix: / +INFO [2017-02-07 04:54:21,039] io.dropwizard.server.DefaultServerFactory: Registering admin handler with root path prefix: / +INFO [2017-02-07 04:54:21,085] org.eclipse.jetty.setuid.SetUIDListener: Opened application@11ee02f8{HTTP/1.1}{localhost:8181} +INFO [2017-02-07 04:54:21,086] org.eclipse.jetty.setuid.SetUIDListener: Opened admin@4102b1b1{HTTP/1.1}{0.0.0.0:8282} +INFO [2017-02-07 04:54:21,088] org.eclipse.jetty.server.Server: jetty-9.2.z-SNAPSHOT +INFO [2017-02-07 04:54:21,919] io.dropwizard.jersey.DropwizardResourceConfig: The following paths were found for the configured resources: + + GET /api-docs (com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON) + GET /api-docs/{route: .+} (com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON) + POST /credit/{v1}/credit/{msisdn}/apply (com.wso2telco.services.dep.sandbox.service.CreditService) + POST /customerinfo/{v1}/config/customer/attribute (com.wso2telco.services.dep.sandbox.service.CustomerInfoConfigurationService) + POST /customerinfo/{v1}/config/customer/profile (com.wso2telco.services.dep.sandbox.service.CustomerInfoConfigurationService) + GET /customerinfo/{v1}/customer/attribute (com.wso2telco.services.dep.sandbox.service.CustomerInfoService) + GET /customerinfo/{v1}/customer/profile (com.wso2telco.services.dep.sandbox.service.CustomerInfoService) + GET /location/{v1}/queries/location (com.wso2telco.services.dep.sandbox.service.SandboxService) + POST /payment/{v1}/transaction/{endUserId}/payment (com.wso2telco.services.dep.sandbox.service.PaymentService) + GET /provisioning/{v1}/config/service (com.wso2telco.services.dep.sandbox.service.ProvisionConfigurationService) + POST /provisioning/{v1}/config/service (com.wso2telco.services.dep.sandbox.service.ProvisionConfigurationService) + POST /provisioning/{v1}/config/{msisdn}/service/{serviceCode} (com.wso2telco.services.dep.sandbox.service.ProvisionConfigurationService) + POST /provisioning/{v1}/{msisdn} (com.wso2telco.services.dep.sandbox.service.ProvisionService) + GET /provisioning/{v1}/{msisdn}/list/active (com.wso2telco.services.dep.sandbox.service.ProvisionService) + GET /provisioning/{v1}/{msisdn}/list/applicable (com.wso2telco.services.dep.sandbox.service.ProvisionService) + POST /provisioning/{v1}/{msisdn}/remove (com.wso2telco.services.dep.sandbox.service.ProvisionService) + POST /smsmessaging/{apiVersion}/outbound/{shortCode}/requests (com.wso2telco.services.dep.sandbox.service.SandboxService) + GET /smsmessaging/{apiVersion}/outbound/{shortCode}/requests/{mtSMSTransactionId}/deliveryInfos (com.wso2telco.services.dep.sandbox.service.SandboxService) + GET /swagger (io.federecio.dropwizard.swagger.SwaggerResource) + GET /user/apiType (com.wso2telco.services.dep.sandbox.service.UserService) + POST /user/managenumber (com.wso2telco.services.dep.sandbox.service.UserService) + GET /user/{apiType}/serviceType (com.wso2telco.services.dep.sandbox.service.UserService) + GET /user/{apiType}/{serviceType}/attribute (com.wso2telco.services.dep.sandbox.service.UserService) + POST /user/{userName}/register (com.wso2telco.services.dep.sandbox.service.UserService) + GET /wallet/{v1}/config/{apiType}/{serviceType}/getAccountStatus (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + GET /wallet/{v1}/config/{apiType}/{serviceType}/getTransactionStatus (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + POST /wallet/{v1}/config/{endUserId}/addAccountInfo (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + POST /wallet/{v1}/config/{endUserId}/addTransactionStatus (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + GET /wallet/{v1}/transaction/{endUserId}/balance (com.wso2telco.services.dep.sandbox.service.WalletService) + GET /wallet/{v1}/transaction/{endUserId}/list (com.wso2telco.services.dep.sandbox.service.WalletService) + POST /wallet/{v1}/transaction/{endUserId}/payment (com.wso2telco.services.dep.sandbox.service.WalletService) + POST /wallet/{v1}/transaction/{endUserId}/refund (com.wso2telco.services.dep.sandbox.service.WalletService) + +INFO [2017-02-07 04:54:21,923] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler@1daf3b44{/,null,AVAILABLE} +INFO [2017-02-07 04:54:21,929] io.dropwizard.setup.AdminEnvironment: tasks = + + POST /tasks/log-level (io.dropwizard.servlets.tasks.LogConfigurationTask) + POST /tasks/gc (io.dropwizard.servlets.tasks.GarbageCollectionTask) + +WARN [2017-02-07 04:54:21,929] io.dropwizard.setup.AdminEnvironment: +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! THIS APPLICATION HAS NO HEALTHCHECKS. THIS MEANS YOU WILL NEVER KNOW ! +! IF IT DIES IN PRODUCTION, WHICH MEANS YOU WILL NEVER KNOW IF YOU'RE ! +! LETTING YOUR USERS DOWN. YOU SHOULD ADD A HEALTHCHECK FOR EACH OF YOUR ! +! APPLICATION'S DEPENDENCIES WHICH FULLY (BUT LIGHTLY) TESTS IT. ! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +INFO [2017-02-07 04:54:21,937] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler@64f1fd08{/,null,AVAILABLE} +INFO [2017-02-07 04:54:21,945] org.eclipse.jetty.server.ServerConnector: Started application@11ee02f8{HTTP/1.1}{localhost:8181} +INFO [2017-02-07 04:54:21,946] org.eclipse.jetty.server.ServerConnector: Started admin@4102b1b1{HTTP/1.1}{0.0.0.0:8282} +INFO [2017-02-07 04:54:21,946] org.eclipse.jetty.server.Server: Started @2466ms +DEBUG [2017-02-07 04:54:41,754] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING USER FACTORY +DEBUG [2017-02-07 04:54:41,755] com.wso2telco.services.dep.sandbox.servicefactory.user.UserServiceFactory: LOADING API TYPES +DEBUG [2017-02-07 04:54:41,761] com.wso2telco.services.dep.sandbox.servicefactory.user.RetrieveAPITypeServiceHandler: Sandbox user : sandbox +DEBUG [2017-02-07 04:54:41,869] com.wso2telco.services.dep.sandbox.dao.hibernate.HibernateUserDAO: No user found as : sandbox +DEBUG [2017-02-07 04:54:41,887] com.wso2telco.services.dep.sandbox.service.UserService: GET API TYPES SERVICE RESPONSE : OutboundJaxrsResponse{status=200, reason=OK, hasEntity=true, closed=false, buffered=false} +INFO [2017-02-07 06:46:01,888] org.eclipse.jetty.server.ServerConnector: Stopped application@11ee02f8{HTTP/1.1}{localhost:8181} +INFO [2017-02-07 06:46:01,890] org.eclipse.jetty.server.ServerConnector: Stopped admin@4102b1b1{HTTP/1.1}{0.0.0.0:8282} +INFO [2017-02-07 06:46:01,892] org.eclipse.jetty.server.handler.ContextHandler: Stopped i.d.j.MutableServletContextHandler@64f1fd08{/,null,UNAVAILABLE} +INFO [2017-02-07 06:46:01,895] org.eclipse.jetty.server.handler.ContextHandler: Stopped i.d.j.MutableServletContextHandler@1daf3b44{/,null,UNAVAILABLE} +INFO [2017-02-07 06:49:32,420] org.eclipse.jetty.util.log: Logging initialized @1178ms +INFO [2017-02-07 06:49:32,532] io.dropwizard.assets.AssetsBundle: Registering AssetBundle with name: swagger-assets for path /swagger-static/* +INFO [2017-02-07 06:49:32,804] io.dropwizard.server.ServerFactory: Starting Application +INFO [2017-02-07 06:49:32,812] io.dropwizard.server.DefaultServerFactory: Registering jersey handler with root path prefix: / +INFO [2017-02-07 06:49:32,825] io.dropwizard.server.DefaultServerFactory: Registering admin handler with root path prefix: / +INFO [2017-02-07 06:49:32,879] org.eclipse.jetty.setuid.SetUIDListener: Opened application@11ee02f8{HTTP/1.1}{localhost:8181} +INFO [2017-02-07 06:49:32,880] org.eclipse.jetty.setuid.SetUIDListener: Opened admin@4102b1b1{HTTP/1.1}{0.0.0.0:8282} +INFO [2017-02-07 06:49:32,884] org.eclipse.jetty.server.Server: jetty-9.2.z-SNAPSHOT +INFO [2017-02-07 06:49:33,727] io.dropwizard.jersey.DropwizardResourceConfig: The following paths were found for the configured resources: + + GET /api-docs (com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON) + GET /api-docs/{route: .+} (com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON) + POST /credit/{v1}/credit/{msisdn}/apply (com.wso2telco.services.dep.sandbox.service.CreditService) + POST /customerinfo/{v1}/config/customer/attribute (com.wso2telco.services.dep.sandbox.service.CustomerInfoConfigurationService) + POST /customerinfo/{v1}/config/customer/profile (com.wso2telco.services.dep.sandbox.service.CustomerInfoConfigurationService) + GET /customerinfo/{v1}/customer/attribute (com.wso2telco.services.dep.sandbox.service.CustomerInfoService) + GET /customerinfo/{v1}/customer/profile (com.wso2telco.services.dep.sandbox.service.CustomerInfoService) + GET /location/{v1}/queries/location (com.wso2telco.services.dep.sandbox.service.SandboxService) + POST /payment/{v1}/{endUserId}/transactions/amount (com.wso2telco.services.dep.sandbox.service.PaymentService) + GET /provisioning/{v1}/config/service (com.wso2telco.services.dep.sandbox.service.ProvisionConfigurationService) + POST /provisioning/{v1}/config/service (com.wso2telco.services.dep.sandbox.service.ProvisionConfigurationService) + POST /provisioning/{v1}/config/{msisdn}/service/{serviceCode} (com.wso2telco.services.dep.sandbox.service.ProvisionConfigurationService) + POST /provisioning/{v1}/{msisdn} (com.wso2telco.services.dep.sandbox.service.ProvisionService) + GET /provisioning/{v1}/{msisdn}/list/active (com.wso2telco.services.dep.sandbox.service.ProvisionService) + GET /provisioning/{v1}/{msisdn}/list/applicable (com.wso2telco.services.dep.sandbox.service.ProvisionService) + POST /provisioning/{v1}/{msisdn}/remove (com.wso2telco.services.dep.sandbox.service.ProvisionService) + POST /smsmessaging/{apiVersion}/outbound/{shortCode}/requests (com.wso2telco.services.dep.sandbox.service.SandboxService) + GET /smsmessaging/{apiVersion}/outbound/{shortCode}/requests/{mtSMSTransactionId}/deliveryInfos (com.wso2telco.services.dep.sandbox.service.SandboxService) + GET /swagger (io.federecio.dropwizard.swagger.SwaggerResource) + GET /user/apiType (com.wso2telco.services.dep.sandbox.service.UserService) + POST /user/managenumber (com.wso2telco.services.dep.sandbox.service.UserService) + GET /user/{apiType}/serviceType (com.wso2telco.services.dep.sandbox.service.UserService) + GET /user/{apiType}/{serviceType}/attribute (com.wso2telco.services.dep.sandbox.service.UserService) + POST /user/{userName}/register (com.wso2telco.services.dep.sandbox.service.UserService) + GET /wallet/{v1}/config/{apiType}/{serviceType}/getAccountStatus (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + GET /wallet/{v1}/config/{apiType}/{serviceType}/getTransactionStatus (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + POST /wallet/{v1}/config/{endUserId}/addAccountInfo (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + POST /wallet/{v1}/config/{endUserId}/addTransactionStatus (com.wso2telco.services.dep.sandbox.service.WalletConfigurationService) + GET /wallet/{v1}/transaction/{endUserId}/balance (com.wso2telco.services.dep.sandbox.service.WalletService) + GET /wallet/{v1}/transaction/{endUserId}/list (com.wso2telco.services.dep.sandbox.service.WalletService) + POST /wallet/{v1}/transaction/{endUserId}/payment (com.wso2telco.services.dep.sandbox.service.WalletService) + POST /wallet/{v1}/transaction/{endUserId}/refund (com.wso2telco.services.dep.sandbox.service.WalletService) + +INFO [2017-02-07 06:49:33,731] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler@1daf3b44{/,null,AVAILABLE} +INFO [2017-02-07 06:49:33,737] io.dropwizard.setup.AdminEnvironment: tasks = + + POST /tasks/log-level (io.dropwizard.servlets.tasks.LogConfigurationTask) + POST /tasks/gc (io.dropwizard.servlets.tasks.GarbageCollectionTask) + +WARN [2017-02-07 06:49:33,737] io.dropwizard.setup.AdminEnvironment: +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! THIS APPLICATION HAS NO HEALTHCHECKS. THIS MEANS YOU WILL NEVER KNOW ! +! IF IT DIES IN PRODUCTION, WHICH MEANS YOU WILL NEVER KNOW IF YOU'RE ! +! LETTING YOUR USERS DOWN. YOU SHOULD ADD A HEALTHCHECK FOR EACH OF YOUR ! +! APPLICATION'S DEPENDENCIES WHICH FULLY (BUT LIGHTLY) TESTS IT. ! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +INFO [2017-02-07 06:49:33,743] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler@64f1fd08{/,null,AVAILABLE} +INFO [2017-02-07 06:49:33,752] org.eclipse.jetty.server.ServerConnector: Started application@11ee02f8{HTTP/1.1}{localhost:8181} +INFO [2017-02-07 06:49:33,753] org.eclipse.jetty.server.ServerConnector: Started admin@4102b1b1{HTTP/1.1}{0.0.0.0:8282} +INFO [2017-02-07 06:49:33,754] org.eclipse.jetty.server.Server: Started @2514ms +DEBUG [2017-02-07 06:56:35,866] com.wso2telco.services.dep.sandbox.service.PaymentService: ###PAYMENT### /{endUserId} invoked : endUserId - tel:+94773524308 +DEBUG [2017-02-07 06:56:35,866] com.wso2telco.services.dep.sandbox.service.PaymentService: com.wso2telco.services.dep.sandbox.dao.model.custom.MakePaymentRequestBean@20b8df82 +DEBUG [2017-02-07 06:56:35,867] com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory: LOADING PAYMENT FACTORY +ERROR [2017-02-07 06:56:35,872] com.wso2telco.services.dep.sandbox.service.PaymentService: Make Payment SERVICE ERROR +! java.lang.NullPointerException: null +! at com.wso2telco.services.dep.sandbox.service.PaymentService.makePayment(PaymentService.java:69) ~[dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] +! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121] +! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121] +! at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121] +! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.Server.handle(Server.java:499) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [dep-sanbox-1.2.0-SNAPSHOT.jar:na] +! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121] +INFO [2017-02-07 07:03:57,617] org.eclipse.jetty.server.ServerConnector: Stopped application@11ee02f8{HTTP/1.1}{localhost:8181} +INFO [2017-02-07 07:03:57,618] org.eclipse.jetty.server.ServerConnector: Stopped admin@4102b1b1{HTTP/1.1}{0.0.0.0:8282} +INFO [2017-02-07 07:03:57,619] org.eclipse.jetty.server.handler.ContextHandler: Stopped i.d.j.MutableServletContextHandler@64f1fd08{/,null,UNAVAILABLE} +INFO [2017-02-07 07:03:57,623] org.eclipse.jetty.server.handler.ContextHandler: Stopped i.d.j.MutableServletContextHandler@1daf3b44{/,null,UNAVAILABLE} diff --git a/dep-sandbox/pom.xml b/dep-sandbox/pom.xml index 192ac4f6..d9056b8e 100644 --- a/dep-sandbox/pom.xml +++ b/dep-sandbox/pom.xml @@ -13,7 +13,7 @@ com.wso2telco.services.dep services-dep-parent - 1.2.0-SNAPSHOT + 1.7.2-SNAPSHOT ../pom.xml 4.0.0 @@ -85,7 +85,7 @@ 6.0.2 3.0.0.wso2v1 1.8.0-M3 - 2.0.3 + 2.0.19 2.3.1 1.1.wso2v1 3.0.0.wso2v1 diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/CreditDAO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/CreditDAO.java index 3b040cb7..f194680b 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/CreditDAO.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/CreditDAO.java @@ -22,7 +22,7 @@ public interface CreditDAO { public AttributeValues checkDuplication(Integer userId, String serviceCall, String attributeValue, String attributeName) throws Exception; - public AttributeValues getTransactionValue(String endUserId, Integer attributeValue, String serviceCall) throws Exception; + public AttributeValues getTransactionValue(String endUserId, Integer attributeValue, String attributeName, String serviceCall) throws Exception; public Integer saveAttributeValue(AttributeValues valueObj) throws Exception; diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/CustomerInfoDAO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/CustomerInfoDAO.java index 59cd23b7..56e1723f 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/CustomerInfoDAO.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/CustomerInfoDAO.java @@ -29,4 +29,5 @@ public interface CustomerInfoDAO { public List getAttributeServices (String msisdn,Integer userID, String imsi,String[] schema) throws Exception; public boolean checkSchema (String [] schema) throws Exception; + } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/DaoFactory.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/DaoFactory.java index 52a0a091..16938d7d 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/DaoFactory.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/DaoFactory.java @@ -35,7 +35,11 @@ public static NumberDAO getNumberDAO() { public static WalletDAO getWalletDAO(){ return new HibernateFactory().getHibernateWalletDAO(); } - + + public static PaymentDAO getPaymentDAO(){ + return new HibernateFactory().getHibernatePaymentDAO(); + } + public static LoggingDAO getLoggingDAO(){ return new HibernateFactory().getHibernateLoggingDao(); } @@ -44,4 +48,8 @@ public static CreditDAO getCreditDAO(){ return new HibernateFactory().getHibernateCreditDAO(); } + + public static USSDDAO getUSSDDAO() { + return new HibernateFactory().getHibernateUSSDDAO(); + } } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/PaymentDAO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/PaymentDAO.java new file mode 100644 index 00000000..d2900d65 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/PaymentDAO.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao; + +import com.wso2telco.services.dep.sandbox.dao.model.domain.AttributeValues; +import com.wso2telco.services.dep.sandbox.dao.model.domain.ManageNumber; + +import java.util.List; + +public interface PaymentDAO { + + public boolean saveManageNumbers(ManageNumber manageNumber) throws Exception; +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/SMSMessagingDAO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/SMSMessagingDAO.java index ca4dbba6..6728b4ad 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/SMSMessagingDAO.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/SMSMessagingDAO.java @@ -1,21 +1,25 @@ package com.wso2telco.services.dep.sandbox.dao; -import com.wso2telco.services.dep.sandbox.dao.model.domain.SMSDeliveryStatus; -import com.wso2telco.services.dep.sandbox.dao.model.domain.SMSMessagingParam; -import com.wso2telco.services.dep.sandbox.dao.model.domain.SMSRequestLog; -import com.wso2telco.services.dep.sandbox.dao.model.domain.User; +import com.wso2telco.services.dep.sandbox.dao.model.domain.*; + + +import java.util.List; + public interface SMSMessagingDAO { - public SMSDeliveryStatus getPreviousSMSDeliveryDetailsByMtSMSTransactionId(String mtSMSTransactionId); - public SMSRequestLog getPreviousSMSRequestDetailsBySMSId(int smsId); - public boolean saveQueryDeliveryStatusTransaction(String senderAddress, String addresses, String message, - String clientCorrelator, String senderName, String notifyURL, String callbackData, Integer batchsize, - String status, Integer txntype, String criteria, String notificationFormat, User user, String requestId) ; + + public MessageLog getPrevSMSDeliveryDataByTransId(int transactionId); + public SMSRequestLog getPrevSMSRequestDataById(int smsId); public SMSMessagingParam getSMSMessagingParam(int userId); - - public String saveSendSMSTransaction(String senderAddress, String addresses, String message, - String clientCorrelator, String senderName, String notifyURL, String callbackData, Integer batchsize, - String status, Integer txntype, String criteria, String notificationFormat, User user, - String deliveryStatus) ; + public List getMessageInbound(String regid, Integer userid); + + boolean saveDeliverySubscription(User userId, String sender_address, int sub_status, String notify_url, String filter, + String callbackData, String clinetCorrelator, String request); + + boolean isSubscriptionExists(String filterCriteria, String notifyUrl, String callbackData, String clientCorrelator); + boolean removeSubscription(int userId, String senderAddress); + public int saveSubscribeSMSRequest(SubscribeSMSRequest subscribeSMSRequest) throws Exception; + public boolean removeSubscriptionToMessage(String subscriptionID) throws Exception; + boolean saveSMSParameters(SMSMessagingParam messagingParam); } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/USSDDAO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/USSDDAO.java new file mode 100644 index 00000000..7158c2b4 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/USSDDAO.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao; + +import com.wso2telco.services.dep.sandbox.dao.model.domain.UssdApplication; + +import java.util.List; + +public interface USSDDAO { + + List getUssdApplications(int userid, String shortCode, String keyWord); + boolean saveUSSDApplications(UssdApplication ussdApplication) throws Exception; + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateCommonDAO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateCommonDAO.java index 8af5d1d0..f901891b 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateCommonDAO.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateCommonDAO.java @@ -340,6 +340,7 @@ public ManageNumber getMSISDN(String msisdn, String imsi, String mcc, String mnc number = (ManageNumber) query.getSingleResult(); } catch (NoResultException e) { + return null; } catch (Exception ex) { LOG.error("###CUSTOMERINFO### Error While Retriving MSISDN", ex); diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateCreditDAO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateCreditDAO.java index 1a5decd1..cb1c25f2 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateCreditDAO.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateCreditDAO.java @@ -70,12 +70,12 @@ public AttributeValues checkDuplication(Integer userId, String serviceCall, Stri } @Override - public AttributeValues getTransactionValue(String endUserId, Integer attributeValue, String serviceCall) + public AttributeValues getTransactionValue(String endUserId, Integer attributeValue, String attributeName, String serviceCall) throws Exception { Session session = getSession(); AttributeValues resultSet = null; - String service = ServiceName.ApplyCredit.toString(); + //String service = ServiceName.ApplyCredit.toString(); StringBuilder hql = new StringBuilder(); hql.append("SELECT "); @@ -100,9 +100,9 @@ public AttributeValues getTransactionValue(String endUserId, Integer attributeVa Query query = session.createQuery(hql.toString()); query.setParameter("apiName", RequestType.CREDIT.toString()); query.setParameter("tableName", TableName.SBXATTRIBUTEVALUE.toString().toLowerCase()); - query.setParameter("attributeName", serviceCall); + query.setParameter("attributeName", attributeName); query.setParameter("attributeValue", attributeValue); - query.setParameter("serviceCall", service); + query.setParameter("serviceCall", serviceCall); resultSet = (AttributeValues) query.uniqueResult(); diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateFactory.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateFactory.java index 19fce722..db0682f7 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateFactory.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateFactory.java @@ -33,6 +33,10 @@ public HibernateNumberDAO getHibernateNumberDAO() { public HibernateWalletDAO getHibernateWalletDAO() { return new HibernateWalletDAO(); } + + public HibernatePaymentDAO getHibernatePaymentDAO() { + return new HibernatePaymentDAO(); + } public HibernateLoggingDao getHibernateLoggingDao() { return new HibernateLoggingDao(); @@ -41,4 +45,8 @@ public HibernateLoggingDao getHibernateLoggingDao() { public HibernateCreditDAO getHibernateCreditDAO() { return new HibernateCreditDAO(); } + + public HibernateUSSDDAO getHibernateUSSDDAO() { + return new HibernateUSSDDAO(); + } } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateLoggingDao.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateLoggingDao.java index 4239906e..6f1d0d1e 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateLoggingDao.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateLoggingDao.java @@ -1,11 +1,6 @@ package com.wso2telco.services.dep.sandbox.dao.hibernate; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.Map.Entry; import org.apache.commons.logging.LogFactory; @@ -51,85 +46,67 @@ public List getMessageLogs(int userid, List serviceNameIds, String value = CommonUtil.getNullOrTrimmedValue(val); try { StringBuilder hqlQueryBuilder = new StringBuilder(); - if(userid != 0 || serviceNameIds != null || startTimeStamp != null || endTimeStamp != null || (reference != null && value != null)){ - hqlQueryBuilder.append("from MessageLog ml "); - hqlQueryBuilder.append("where "); - if(userid != 0){ - hqlQueryBuilder.append("ml.userid = :id"); - parameterMap.put("id", userid); - if(serviceNameIds != null) - hqlQueryBuilder.append(" AND ml.servicenameid in (:servicenameidList)"); - if(reference != null && value != null){ - hqlQueryBuilder.append(" AND ml.reference = :reference AND ml.value = :value"); - parameterMap.put("reference", reference); - parameterMap.put("value", value); - } - if(startTimeStamp != null){ - hqlQueryBuilder.append(" AND ml.messageTimestamp >= :startTimeStamp"); - parameterMap.put("startTimeStamp", startTimeStamp); - } - if(endTimeStamp != null){ - hqlQueryBuilder.append(" AND ml.messageTimestamp <= :endTimeStamp"); - parameterMap.put("endTimeStamp", endTimeStamp); - } - }else if(serviceNameIds != null){ - hqlQueryBuilder.append("ml.servicenameid in (:servicenameidList)"); - if(reference != null && value != null){ - hqlQueryBuilder.append(" AND ml.reference = :reference AND ml.value = :value"); - parameterMap.put("reference", reference); - parameterMap.put("value", value); - } - if(startTimeStamp != null){ - hqlQueryBuilder.append(" AND ml.messageTimestamp >= :startTimeStamp"); - parameterMap.put("startTimeStamp", startTimeStamp); - } - if(endTimeStamp != null){ - hqlQueryBuilder.append(" AND ml.messageTimestamp <= :endTimeStamp"); - parameterMap.put("endTimeStamp", endTimeStamp); - } - }else if(reference != null && value != null){ - hqlQueryBuilder.append("ml.reference = :reference AND ml.value = :value"); - parameterMap.put("reference", reference); - parameterMap.put("value", value); - if(startTimeStamp != null){ - hqlQueryBuilder.append(" AND ml.messageTimestamp >= :startTimeStamp"); - parameterMap.put("startTimeStamp", startTimeStamp); - } - if(endTimeStamp != null){ - hqlQueryBuilder.append(" AND ml.messageTimestamp <= :endTimeStamp"); - parameterMap.put("endTimeStamp", endTimeStamp); - } - }else if(startTimeStamp != null){ - hqlQueryBuilder.append("ml.messageTimestamp >= :startTimeStamp"); + hqlQueryBuilder.append("from MessageLog ml "); + hqlQueryBuilder.append("where 1=1 "); + + if(userid != 0){ + hqlQueryBuilder.append(" AND ml.userid = :id"); + parameterMap.put("id", userid); + + } + + if(serviceNameIds != null){ + hqlQueryBuilder.append(" AND ml.servicenameid in (:servicenameidList)"); + parameterMap.put("servicenameidList", serviceNameIds); + } + + if(reference != null && value != null){ + hqlQueryBuilder.append(" AND ml.reference = :reference AND ml.value = :value"); + parameterMap.put("reference", reference); + parameterMap.put("value", value); + } + + if(startTimeStamp != null && endTimeStamp != null){ + hqlQueryBuilder.append(" AND ml.messageTimestamp between :startTimeStamp and :endTimeStamp"); + parameterMap.put("startTimeStamp", startTimeStamp); + parameterMap.put("endTimeStamp", endTimeStamp); + + }else if(startTimeStamp != null){ + hqlQueryBuilder.append(" AND ml.messageTimestamp >= :startTimeStamp"); parameterMap.put("startTimeStamp", startTimeStamp); if(endTimeStamp != null){ hqlQueryBuilder.append(" AND ml.messageTimestamp <= :endTimeStamp"); parameterMap.put("endTimeStamp", endTimeStamp); } - }else if(endTimeStamp != null){ - hqlQueryBuilder.append("ml.messageTimestamp <= :endTimeStamp"); + }else if(endTimeStamp != null){ + hqlQueryBuilder.append(" AND ml.messageTimestamp <= :endTimeStamp"); parameterMap.put("endTimeStamp", endTimeStamp); } - Query query = session.createQuery(hqlQueryBuilder.toString()); - - Set> entrySet = parameterMap.entrySet(); + Query query = session.createQuery(hqlQueryBuilder.toString()); - for (Entry entry : entrySet) { + Set> entrySet = parameterMap.entrySet(); + + for (Entry entry : entrySet) { + if(entry.getValue() instanceof List ){ + query.setParameterList(entry.getKey(), (List)entry.getValue()); + }else{ query.setParameter(entry.getKey(), entry.getValue()); } - if(serviceNameIds != null) - query.setParameterList("servicenameidList", serviceNameIds); - - messageLogs = (List) query.getResultList(); + } + + messageLogs = (List) query.getResultList(); + } catch (Exception ex) { - LOG.error("Error in getMessageLogs " + ex); + LOG.error("Error in getMessageLogs " , ex); throw ex; } + if (messageLogs==null){ + return Collections.emptyList(); + }else{ return messageLogs; + } } - - } \ No newline at end of file diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernatePaymentDAO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernatePaymentDAO.java new file mode 100644 index 00000000..4c902756 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernatePaymentDAO.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.hibernate; + +import com.wso2telco.services.dep.sandbox.dao.PaymentDAO; +import com.wso2telco.services.dep.sandbox.dao.model.domain.AttributeValues; +import com.wso2telco.services.dep.sandbox.dao.model.domain.ManageNumber; +import com.wso2telco.services.dep.sandbox.dao.model.domain.MessageLog; +import com.wso2telco.services.dep.sandbox.util.RequestType; +import com.wso2telco.services.dep.sandbox.util.TableName; +import org.apache.commons.logging.LogFactory; +import org.hibernate.Session; +import org.hibernate.query.Query; + +import javax.persistence.NoResultException; +import java.util.List; + +public class HibernatePaymentDAO extends AbstractDAO implements PaymentDAO { + + { + LOG = LogFactory.getLog(PaymentDAO.class); + } + + @Override + public boolean saveManageNumbers(ManageNumber manageNumber) throws Exception { + try { + saveOrUpdate(manageNumber); + } catch (NoResultException e) { + + return false; + } catch (Exception ex) { + LOG.error("###PAYMENT### Error in Payment Service ", ex); + throw ex; + } + return true; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateSMSMessagingDAO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateSMSMessagingDAO.java index 8621356c..efee7cb1 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateSMSMessagingDAO.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateSMSMessagingDAO.java @@ -1,24 +1,28 @@ package com.wso2telco.services.dep.sandbox.dao.hibernate; +import java.util.ArrayList; import java.util.Date; +import java.util.List; +import com.wso2telco.services.dep.sandbox.dao.model.custom.DeliveryReceiptSubscription; +import com.wso2telco.services.dep.sandbox.dao.model.domain.*; +import com.wso2telco.services.dep.sandbox.dao.model.domain.*; import org.apache.commons.logging.LogFactory; +import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.Transaction; import com.wso2telco.services.dep.sandbox.dao.SMSMessagingDAO; -import com.wso2telco.services.dep.sandbox.dao.model.domain.SMSDeliveryStatus; -import com.wso2telco.services.dep.sandbox.dao.model.domain.SMSMessagingParam; -import com.wso2telco.services.dep.sandbox.dao.model.domain.SMSRequestLog; -import com.wso2telco.services.dep.sandbox.dao.model.domain.User; + +import javax.persistence.NoResultException; class HibernateSMSMessagingDAO extends HibernateCommonDAO implements SMSMessagingDAO{ { LOG = LogFactory.getLog(HibernateSMSMessagingDAO.class); } - - + + public SMSMessagingParam getSMSMessagingParam(int userId) { SMSMessagingParam smsMessagingParam = null; @@ -31,18 +35,19 @@ public SMSMessagingParam getSMSMessagingParam(int userId) { return smsMessagingParam; } - public SMSDeliveryStatus getPreviousSMSDeliveryDetailsByMtSMSTransactionId(String mtSMSTransactionId) { + public MessageLog getPrevSMSDeliveryDataByTransId(int mtSMSTransactionId) { - SMSDeliveryStatus smsDeliveryStatus = null; + MessageLog smsDeliveryStatus = null; Session session = getSession(); - smsDeliveryStatus = (SMSDeliveryStatus) session.get(SMSDeliveryStatus.class, mtSMSTransactionId); + smsDeliveryStatus = (MessageLog) session.get(MessageLog.class, mtSMSTransactionId); return smsDeliveryStatus; } - public SMSRequestLog getPreviousSMSRequestDetailsBySMSId(int smsId) { + + public SMSRequestLog getPrevSMSRequestDataById(int smsId) { SMSRequestLog smsRequestLog = null; @@ -114,45 +119,201 @@ public String saveSendSMSTransaction(String senderAddress, String addresses, Str return mtSMSTransactionId; } - public boolean saveQueryDeliveryStatusTransaction(String senderAddress, String addresses, String message, - String clientCorrelator, String senderName, String notifyURL, String callbackData, Integer batchsize, - String status, Integer txntype, String criteria, String notificationFormat, User user, String requestId) { + @Override + public List getMessageInbound(String registrationID, Integer userid) { - Session session = null; - Transaction tx = null; - SMSRequestLog smsRequest = new SMSRequestLog(); + List sendSMSToApplicationList; + Session session = getSession(); - try { - session = getSession(); - tx = session.beginTransaction(); + sendSMSToApplicationList = session.createQuery("from SendSMSToApplication where destinationAddress = ? and user.id = ?").setString(0, registrationID).setInteger(1, userid).list(); - smsRequest.setSenderAddress(senderAddress); - smsRequest.setAddresses((String) addresses); - smsRequest.setMessage(message); - smsRequest.setClientCorrelator(clientCorrelator); - smsRequest.setSenderName(senderName); - smsRequest.setNotifyURL(notifyURL); - smsRequest.setCallbackData(callbackData); - smsRequest.setUser(user); - smsRequest.setDate(new Date()); - smsRequest.setBatchsize(batchsize); - smsRequest.setTransactionstatus(status); - smsRequest.setTxntype(txntype); - smsRequest.setCriteria(criteria); - smsRequest.setNotificationFormat(notificationFormat); - smsRequest.setRequestId(requestId); - session.save(smsRequest); + return sendSMSToApplicationList; - tx.commit(); - } catch (Exception e) { + } + + @Override + public int saveSubscribeSMSRequest(SubscribeSMSRequest SubscribeSMSRequest) throws Exception { + + Session session = null; + Transaction transaction = null; + Integer subsid = null; + + try { + session = getSession(); + transaction = session.beginTransaction(); + session.save(SubscribeSMSRequest); + subsid = SubscribeSMSRequest.getSubscribeId(); + transaction.commit(); + + } catch (Exception e) { + transaction.rollback(); + LOG.error("Error occurred When save subscribe SMS request",e); + throw e; - tx.rollback(); - return false; } finally { + session.close(); + } - session.close(); - } + return subsid; + + } + + @Override + public boolean removeSubscriptionToMessage(String subscriptionID) throws Exception { + + boolean isExists = false; + Session session = null; + Transaction transaction = null; + + try { + session = getSession(); + transaction = session.beginTransaction(); + Query query= session.createQuery("delete FROM SubscribeSMSRequest WHERE subscribe_id = :id"); + query.setInteger("id", Integer.parseInt(subscriptionID)); + int i = query.executeUpdate(); + + if (i >0) { + isExists = true; + } + transaction.commit(); + + } catch (Exception e) { + transaction.rollback(); + LOG.error("Error occurred when remove subscription to message",e); + throw e; + + } finally { + session.close(); + } + return isExists; + } + + @Override + public boolean saveSMSParameters(SMSMessagingParam messagingParam) { + try { + Session session = getSession(); + session.save(messagingParam); + + } catch (NoResultException e) { + return false; + + } catch (Exception ex) { + LOG.error("###SMS Config### Error in SMS Config Service ", ex); + throw ex; + } return true; } + + + public boolean saveDeliverySubscription (User userId, String sender_address,int sub_status, String notify_url, + String filter, String callbackData, String clinetCorrelator, String + request){ + + Session session = null; + Transaction transaction = null; + DeliverySubscription deliverySubscription = new DeliverySubscription(); + + try { + + session = getSession(); + transaction = session.beginTransaction(); + + deliverySubscription.setUser(userId); + deliverySubscription.setSenderAddress(sender_address); + deliverySubscription.setSubStatus(sub_status); + deliverySubscription.setNotifyUrl(notify_url); + deliverySubscription.setFilterCriteria(filter); + deliverySubscription.setCallbackData(callbackData); + deliverySubscription.setClientCorrelator(clinetCorrelator); + deliverySubscription.setRequestData(request); + + session.save(deliverySubscription); + + transaction.commit(); + + } catch (Exception ex) { + transaction.rollback(); + LOG.error("Error occurred while trying to save subscription ",ex); + throw ex; + } finally { + session.close(); + } + + return true; + } + + @Override + public boolean isSubscriptionExists (String filterCriteria, String notifyUrl, String callbackData, String + clientCorrelator){ + + boolean isExists = false; + Session session = getSession(); + + List resultedList = new ArrayList<>(); + + try { + + StringBuilder hqlQueryBuilder = new StringBuilder(); + hqlQueryBuilder.append("FROM DeliverySubscription AS ds WHERE ds.filterCriteria = :filter AND ds" + + ".notifyUrl = :notify AND ds.callbackData = :callback AND ds.clientCorrelator = :client"); + + resultedList = session. + createQuery(hqlQueryBuilder.toString()) + .setParameter("filter", filterCriteria) + .setParameter("notify", notifyUrl) + .setParameter("callback", callbackData) + .setParameter("client", clientCorrelator).getResultList(); + + if (resultedList.size() > 0) { + isExists = true; + } + } catch (Exception e) { + LOG.error("###SUSCRIPTION### Error in retrieving subscriptions", e); + throw e; + } finally { + session.close(); + } + return isExists; + } + + @Override + public boolean removeSubscription ( int userId, String senderAddress){ + + boolean isExists = false; + Session session = null; + Transaction tx = null; + + try { + session = getSession(); + tx = session.beginTransaction(); + Query q = session.createQuery("delete FROM DeliverySubscription AS ds WHERE ds.id = :id AND ds" + + ".senderAddress = :sender_address"); + q.setInteger("id", userId); + q.setParameter("sender_address", senderAddress); + + int i = q.executeUpdate(); + + if (i == 1) { + isExists = true; + } + tx.commit(); + + + } catch (Exception e) { + tx.rollback(); + LOG.error("Error occurred while removing subscription",e); + throw e; + } finally { + session.close(); + } + + return isExists; + } + + + + + + } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateUSSDDAO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateUSSDDAO.java new file mode 100644 index 00000000..6bc34dfe --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/hibernate/HibernateUSSDDAO.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.hibernate; + +import com.wso2telco.services.dep.sandbox.dao.USSDDAO; +import com.wso2telco.services.dep.sandbox.dao.model.domain.UssdApplication; +import org.apache.commons.logging.LogFactory; +import org.hibernate.Session; +import org.hibernate.query.Query; + +import javax.persistence.NoResultException; +import java.util.*; + +public class HibernateUSSDDAO extends AbstractDAO implements USSDDAO { + + { + LOG = LogFactory.getLog(HibernateUSSDDAO.class); + } + + @Override + public List getUssdApplications(int userid, String shortCode, String keyWord) { + + Session session = getSession(); + Map parameterMap = new HashMap(); + List appdistributionList = new ArrayList(); + + StringBuilder hqlQueryBuilder = new StringBuilder(); + hqlQueryBuilder.append("FROM UssdApplication distlist"); + hqlQueryBuilder.append(" WHERE"); + hqlQueryBuilder.append(" distlist.userid = :id AND"); + parameterMap.put("id", userid); + hqlQueryBuilder.append(" distlist.shortCode = :shortCode"); + parameterMap.put("shortCode", shortCode); + + if (keyWord != null) { + hqlQueryBuilder.append(" AND distlist.keyword = :keyword"); + parameterMap.put("keyword", keyWord); + } + + Query query = session.createQuery(hqlQueryBuilder.toString()); + + Set> entrySet = parameterMap.entrySet(); + + for (Map.Entry entry : entrySet) { + if (entry.getValue() instanceof List) { + query.setParameterList(entry.getKey(), (List) entry.getValue()); + } else { + query.setParameter(entry.getKey(), entry.getValue()); + } + + } + + appdistributionList = (List) query.getResultList(); + + return appdistributionList; + } + + @Override + public boolean saveUSSDApplications(UssdApplication ussdApplication) throws Exception { + + try { + saveOrUpdate(ussdApplication); + return true; + + } catch (Exception ex) { + LOG.error("###USSD Config### Error in USSD Config Service ", ex); + throw ex; + } + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/AmountTransactionRequestBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/AmountTransactionRequestBean.java new file mode 100644 index 00000000..2e3dc5fd --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/AmountTransactionRequestBean.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +public class AmountTransactionRequestBean { + + private amountTransaction amountTransaction; + + public amountTransaction getAmountTransaction() { + return amountTransaction; + } + + public void setAmountTransaction(amountTransaction amountTransaction) { + this.amountTransaction = amountTransaction; + } + + public static class amountTransaction { + private String clientCorrelator; + + private String endUserId; + + private ChargePaymentAmount paymentAmount; + + private String referenceCode; + + private String transactionOperationStatus; + + public String getClientCorrelator() { + return clientCorrelator; + } + + public void setClientCorrelator(String clientCorrelator) { + this.clientCorrelator = clientCorrelator; + } + + public String getEndUserId() { + return endUserId; + } + + public void setEndUserId(String endUserId) { + this.endUserId = endUserId; + } + + public String getReferenceCode() { + return referenceCode; + } + + public void setReferenceCode(String referenceCode) { + this.referenceCode = referenceCode; + } + + public ChargePaymentAmount getPaymentAmount() { + return paymentAmount; + } + + public void setPaymentAmount(ChargePaymentAmount paymentAmount) { + this.paymentAmount = paymentAmount; + } + + public String getTransactionOperationStatus() { + return transactionOperationStatus; + } + + public void setTransactionOperationStatus(String transactionOperationStatus) { + this.transactionOperationStatus = transactionOperationStatus; + } + } + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/CallbackReference.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/CallbackReference.java index b7b8fb40..904d913b 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/CallbackReference.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/CallbackReference.java @@ -15,6 +15,9 @@ ******************************************************************************/ package com.wso2telco.services.dep.sandbox.dao.model.custom; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(value = JsonInclude.Include.NON_NULL) public class CallbackReference { private String notifyURL; diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargeAmountResponse.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargeAmountResponse.java new file mode 100644 index 00000000..db591264 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargeAmountResponse.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2015-2016, WSO2.Telco Inc. (http://www.wso2telco.com) All Rights Reserved. + * + * WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +@JsonInclude(value=Include.NON_NULL) +public class ChargeAmountResponse { + + private PaymentChargingInformation chargingInformation; + + private String totalAmountCharged; + + private PaymentChargingMetaData chargingMetaData; + + public PaymentChargingInformation getChargingInformation() { + return chargingInformation; + } + + public void setChargingInformation(PaymentChargingInformation chargingInformation) { + this.chargingInformation = chargingInformation; + } + + public PaymentChargingMetaData getChargingMetaData() { + return chargingMetaData; + } + + public void setChargingMetaData(PaymentChargingMetaData chargingMetaData) { + this.chargingMetaData = chargingMetaData; + } + + public String getTotalAmountCharged() { + return totalAmountCharged; + } + + public void setTotalAmountCharged(String totalAmountCharged) { + this.totalAmountCharged = totalAmountCharged; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargePaymentAmount.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargePaymentAmount.java new file mode 100644 index 00000000..23ff3b8b --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargePaymentAmount.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2015-2016, WSO2.Telco Inc. (http://www.wso2telco.com) All Rights Reserved. + * + * WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +public class ChargePaymentAmount { + + private PaymentChargingInformation chargingInformation; + + private PaymentChargingMetaData chargingMetaData; + + public PaymentChargingInformation getChargingInformation() { + return chargingInformation; + } + + public void setChargingInformation(PaymentChargingInformation chargingInformation) { + this.chargingInformation = chargingInformation; + } + + public PaymentChargingMetaData getChargingMetaData() { + return chargingMetaData; + } + + public void setChargingMetaData(PaymentChargingMetaData chargingMetaData) { + this.chargingMetaData = chargingMetaData; + } + + public String toString() { + StringBuilder builder = new StringBuilder(); + + if (chargingInformation != null) { + builder.append(" " + getChargingInformation().toString()); + } + + if (chargingMetaData != null) { + builder.append(" " + getChargingMetaData().toString()); + } + + return builder.toString(); + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargePaymentDTO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargePaymentDTO.java new file mode 100644 index 00000000..3e3644d6 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargePaymentDTO.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2015-2016, WSO2.Telco Inc. (http://www.wso2telco.com) All Rights Reserved. + * + * WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +public class ChargePaymentDTO { + + private ChargePaymentResponseBean amountTransaction; + + public ChargePaymentResponseBean getAmountTransaction() { + return amountTransaction; + } + + public void setAmountTransaction(ChargePaymentResponseBean amountTransaction) { + this.amountTransaction = amountTransaction; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargePaymentRequestWrapperDTO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargePaymentRequestWrapperDTO.java new file mode 100644 index 00000000..040bda18 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargePaymentRequestWrapperDTO.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2015-2016, WSO2.Telco Inc. (http://www.wso2telco.com) All Rights Reserved. + * + * WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +public class ChargePaymentRequestWrapperDTO extends RequestDTO { + + /** + * + */ + private static final long serialVersionUID = -6173594710611363567L; + + /** The endUserId param **/ + private String endUserId; + + private PaymentRefundTransactionRequestBean paymentRefundTransactionRequestBean; + + public String getEndUserId() { + return endUserId; + } + + public void setEndUserId(String endUserId) { + this.endUserId = endUserId; + } + + public PaymentRefundTransactionRequestBean getPaymentRefundTransactionRequestBean() { + return paymentRefundTransactionRequestBean; + } + + public void setPaymentRefundTransactionRequestBean(PaymentRefundTransactionRequestBean paymentRefundTransactionRequestBean) { + this.paymentRefundTransactionRequestBean = paymentRefundTransactionRequestBean; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargePaymentResponseBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargePaymentResponseBean.java new file mode 100644 index 00000000..064909ee --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargePaymentResponseBean.java @@ -0,0 +1,114 @@ +/******************************************************************************* + * Copyright (c) 2015-2016, WSO2.Telco Inc. (http://www.wso2telco.com) All Rights Reserved. + * + * WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +@JsonInclude(value = Include.NON_NULL) +public class ChargePaymentResponseBean { + + private String clientCorrelator; + + private String endUserId; + + private String originalReferenceCode; + + private String originalServerReferenceCode; + + private ChargeAmountResponse paymentAmount; + + private String referenceCode; + + private String serverReferenceCode; + + private String resourceURL; + + private String transactionOperationStatus; + + public String getClientCorrelator() { + return clientCorrelator; + } + + public void setClientCorrelator(String clientCorrelator) { + this.clientCorrelator = clientCorrelator; + } + + public String getEndUserId() { + return endUserId; + } + + public void setEndUserId(String endUserId) { + this.endUserId = endUserId; + } + + public String getOriginalReferenceCode() { + return originalReferenceCode; + } + + public void setOriginalReferenceCode(String originalReferenceCode) { + this.originalReferenceCode = originalReferenceCode; + } + + public String getOriginalServerReferenceCode() { + return originalServerReferenceCode; + } + + public void setOriginalServerReferenceCode(String originalServerReferenceCode) { + this.originalServerReferenceCode = originalServerReferenceCode; + } + + public String getReferenceCode() { + return referenceCode; + } + + + public void setReferenceCode(String referenceCode) { + this.referenceCode = referenceCode; + } + + public String getServerReferenceCode() { + return serverReferenceCode; + } + + public void setServerReferenceCode(String serverReferenceCode) { + this.serverReferenceCode = serverReferenceCode; + } + + public String getTransactionOperationStatus() { + return transactionOperationStatus; + } + + public void setTransactionOperationStatus(String transactionOperationStatus) { + this.transactionOperationStatus = transactionOperationStatus; + } + + public ChargeAmountResponse getPaymentAmount() { + return paymentAmount; + } + + public void setPaymentAmount(ChargeAmountResponse paymentAmount) { + this.paymentAmount = paymentAmount; + } + + public String getResourceURL() { + return resourceURL; + } + + public void setResourceURL(String resourceURL) { + this.resourceURL = resourceURL; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargeRefundAmountResponse.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargeRefundAmountResponse.java new file mode 100644 index 00000000..c83d8f82 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargeRefundAmountResponse.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2015-2016, WSO2.Telco Inc. (http://www.wso2telco.com) All Rights Reserved. + * + * WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +@JsonInclude(value=Include.NON_NULL) +public class ChargeRefundAmountResponse { + + private PaymentChargingInformation chargingInformation; + + private double totalAmountRefunded; + + private PaymentChargingMetaData chargingMetaData; + + public PaymentChargingInformation getChargingInformation() { + return chargingInformation; + } + + public void setChargingInformation(PaymentChargingInformation chargingInformation) { + this.chargingInformation = chargingInformation; + } + + public PaymentChargingMetaData getChargingMetaData() { + return chargingMetaData; + } + + public void setChargingMetaData(PaymentChargingMetaData chargingMetaData) { + this.chargingMetaData = chargingMetaData; + } + + public double getTotalAmountRefunded() { + return totalAmountRefunded; + } + + public void setTotalAmountRefunded(double totalAmountRefunded) { + this.totalAmountRefunded = totalAmountRefunded; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargingInformation.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargingInformation.java index 87d4636b..ccff6bbc 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargingInformation.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargingInformation.java @@ -19,17 +19,17 @@ public class ChargingInformation { - private String amount; + private double amount; private String currency; private String description; - public String getAmount() { + public double getAmount() { return amount; } - public void setAmount(String amount) { + public void setAmount(double amount) { this.amount = amount; } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargingMetaData.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargingMetaData.java index 7ca25b0f..9e84f0a9 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargingMetaData.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargingMetaData.java @@ -61,4 +61,5 @@ public String toString() { return builder.toString(); } + } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargingMetaDataWithTax.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargingMetaDataWithTax.java new file mode 100644 index 00000000..351cc1f8 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ChargingMetaDataWithTax.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + + + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +@JsonInclude(value=Include.NON_NULL) +public class ChargingMetaDataWithTax { + + private String onBehalfOf; + + private String purchaseCategoryCode; + + private String channel; + + private String tax; + + public String getTax() { + return tax; + } + + public void setTax(String tax) { + this.tax = tax; + } + + public String getOnBehalfOf() { + return onBehalfOf; + } + + public void setOnBehalfOf(String onBehalfOf) { + this.onBehalfOf = onBehalfOf; + } + + public String getPurchaseCategoryCode() { + return purchaseCategoryCode; + } + + public void setPurchaseCategoryCode(String purchaseCategoryCode) { + this.purchaseCategoryCode = purchaseCategoryCode; + } + + public String getChannel() { + return channel; + } + + public void setChannel(String channel) { + this.channel = channel; + } + + public String toString() { + StringBuilder builder = new StringBuilder(); + + builder.append(" onBehalfOf : " + onBehalfOf); + builder.append(" categoryCode : " + purchaseCategoryCode); + builder.append(" channel : " + channel); + builder.append("taxAmount" +tax); + + return builder.toString(); + } + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/CreditApplyResponseBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/CreditApplyResponseBean.java index aac1e334..8ca88a09 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/CreditApplyResponseBean.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/CreditApplyResponseBean.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; - +@JsonInclude(value = JsonInclude.Include.NON_NULL) public class CreditApplyResponseBean { private CreditApplyResponse creditApplyResponse; diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/DeliveryInfoList.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/DeliveryInfoList.java new file mode 100644 index 00000000..952ae6df --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/DeliveryInfoList.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + + +import java.util.List; + +public class DeliveryInfoList { + + private String resourceURL; + private List deliveryInfo; + + + public String getResourceURL() { + return resourceURL; + } + + public void setResourceURL(String resourceURL) { + this.resourceURL = resourceURL; + } + + public List getDeliveryInfo() { + return deliveryInfo; + } + + public void setDeliveryInfo(List deliveryInfo) { + this.deliveryInfo = deliveryInfo; + } + + public static class DeliveryInfo { + + private String address; + private String deliveryStatus; + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getDeliveryStatus() { + return deliveryStatus; + } + + public void setDeliveryStatus(String deliveryStatus) { + this.deliveryStatus = deliveryStatus; + } + } +} + + diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/DeliveryReceiptSubscription.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/DeliveryReceiptSubscription.java new file mode 100644 index 00000000..4176e7ce --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/DeliveryReceiptSubscription.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + + +public class DeliveryReceiptSubscription { + + private CallbackReference callbackReference; + + public CallbackReference getCallbackReference() { + return callbackReference; + } + + public void setCallbackReference(CallbackReference callbackReference) { + this.callbackReference = callbackReference; + } + + public static class CallbackReference{ + + private String callbackData; + private String notifyURL; + + public String getCallbackData() { + return callbackData; + } + + public void setCallbackData(String callbackData) { + this.callbackData = callbackData; + } + + public String getNotifyURL() { + return notifyURL; + } + + public void setNotifyURL(String notifyURL) { + this.notifyURL = notifyURL; + } + } + + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/InboundSMSMessage.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/InboundSMSMessage.java new file mode 100644 index 00000000..a606a88d --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/InboundSMSMessage.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + + +public class InboundSMSMessage { + + private String dateTime; + private String destinationAddress; + private int messageId; + private String message; + private String resourceURL; + private String senderAddress; + + public String getDateTime() { + return dateTime; + } + + public void setDateTime(String dateTime) { + this.dateTime = dateTime; + } + + public String getDestinationAddress() { + return destinationAddress; + } + + public void setDestinationAddress(String destinationAddress) { + this.destinationAddress = destinationAddress; + } + + public int getMessageId() { + return messageId; + } + + public void setMessageId(int messageId) { + this.messageId = messageId; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getResourceURL() { + return resourceURL; + } + + public void setResourceURL(String resourceURL) { + this.resourceURL = resourceURL; + } + + public String getSenderAddress() { + return senderAddress; + } + + public void setSenderAddress(String senderAddress) { + this.senderAddress = senderAddress; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ListCustomerInfoDTO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ListCustomerInfoDTO.java index f6b5e9a5..7a6f0f85 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ListCustomerInfoDTO.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ListCustomerInfoDTO.java @@ -16,8 +16,9 @@ package com.wso2telco.services.dep.sandbox.dao.model.custom; import com.fasterxml.jackson.annotation.JsonProperty; +import com.wso2telco.services.dep.sandbox.servicefactory.customerinfo.GetAttributeResponseWrapper; -public class ListCustomerInfoDTO { +public class ListCustomerInfoDTO extends GetAttributeResponseWrapper.ListCustomerInfoDTO { private ListCustomerInfoAttributesDTO customerInfo; diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/LocationRequestWrapperDTO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/LocationRequestWrapperDTO.java index b7b17110..af47ad5e 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/LocationRequestWrapperDTO.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/LocationRequestWrapperDTO.java @@ -2,9 +2,6 @@ public class LocationRequestWrapperDTO extends RequestDTO { - /** - * - */ private static final long serialVersionUID = -1548321785136669498L; private String address; private String requestedAccuracy; diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ManageNumberRequest.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ManageNumberRequest.java index 56af8923..db897c2c 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ManageNumberRequest.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ManageNumberRequest.java @@ -18,6 +18,14 @@ public class ManageNumberRequest { private int mnc; + private String altitude; + + private String latitude; + + private String longitude; + + private String locationRetrieveStatus; + public String getNumber() { return number; } @@ -82,4 +90,35 @@ public void setMnc(int mnc) { this.mnc = mnc; } + public String getAltitude() { + return altitude; + } + + public void setAltitude(String altitude) { + this.altitude = altitude; + } + + public String getLatitude() { + return latitude; + } + + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + public String getLocationRetrieveStatus() { + return locationRetrieveStatus; + } + + public void setLocationRetrieveStatus(String locationRetrieveStatus) { + this.locationRetrieveStatus = locationRetrieveStatus; + } } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/OutboundSMSMessageRequest.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/OutboundSMSMessageRequest.java new file mode 100644 index 00000000..6adbb610 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/OutboundSMSMessageRequest.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.ArrayList; +import java.util.List; + +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class OutboundSMSMessageRequest { + + + private List address = new ArrayList(); + private OutboundSMSTextMessage outboundSMSTextMessage; + private String clientCorrelator; + private ReceiptRequest receiptRequest; + + + public List getAddress() { + return address; + } + + public void setAddress(List address) { + this.address = address; + } + + public OutboundSMSTextMessage getOutboundSMSTextMessage() { + return outboundSMSTextMessage; + } + + public void setOutboundSMSTextMessage(OutboundSMSTextMessage outboundSMSTextMessage) { + this.outboundSMSTextMessage = outboundSMSTextMessage; + } + + public String getClientCorrelator() { + return clientCorrelator; + } + + public void setClientCorrelator(String clientCorrelator) { + this.clientCorrelator = clientCorrelator; + } + + public ReceiptRequest getReceiptRequest() { + return receiptRequest; + } + + public void setReceiptRequest(ReceiptRequest receiptRequest) { + this.receiptRequest = receiptRequest; + } + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/OutboundSMSMessageRequestBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/OutboundSMSMessageRequestBean.java deleted file mode 100644 index b16f46ba..00000000 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/OutboundSMSMessageRequestBean.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.wso2telco.services.dep.sandbox.dao.model.custom; - -import java.util.ArrayList; -import java.util.List; - -public class OutboundSMSMessageRequestBean { - - private OutboundSMSMessageRequest outboundSMSMessageRequest = null; - - public OutboundSMSMessageRequest getOutboundSMSMessageRequest() { - return outboundSMSMessageRequest; - } - - public void setOutboundSMSMessageRequest(OutboundSMSMessageRequest outboundSMSMessageRequest) { - this.outboundSMSMessageRequest = outboundSMSMessageRequest; - } - - public static class OutboundSMSMessageRequest { - - private List address = new ArrayList(); - private String senderAddress = null; - private OutboundSMSTextMessage outboundSMSTextMessage = null; - private String clientCorrelator = null; - private ReceiptRequest receiptRequest = null; - private String senderName = null; - - public List getAddress() { - return address; - } - - public void setAddress(List address) { - this.address = address; - } - - public String getSenderAddress() { - return senderAddress; - } - - public void setSenderAddress(String senderAddress) { - this.senderAddress = senderAddress; - } - - public OutboundSMSTextMessage getOutboundSMSTextMessage() { - return outboundSMSTextMessage; - } - - public void setOutboundSMSTextMessage(OutboundSMSTextMessage outboundSMSTextMessage) { - this.outboundSMSTextMessage = outboundSMSTextMessage; - } - - public String getClientCorrelator() { - return clientCorrelator; - } - - public void setClientCorrelator(String clientCorrelator) { - this.clientCorrelator = clientCorrelator; - } - - public ReceiptRequest getReceiptRequest() { - return receiptRequest; - } - - public void setReceiptRequest(ReceiptRequest receiptRequest) { - this.receiptRequest = receiptRequest; - } - - public String getSenderName() { - return senderName; - } - - public void setSenderName(String senderName) { - this.senderName = senderName; - } - - public static class OutboundSMSTextMessage { - - private String message = null; - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - } - - public static class ReceiptRequest { - - private String notifyURL = null; - private String callbackData = null; - - public String getNotifyURL() { - return notifyURL; - } - - public void setNotifyURL(String notifyURL) { - this.notifyURL = notifyURL; - } - - public String getCallbackData() { - return callbackData; - } - - public void setCallbackData(String callbackData) { - this.callbackData = callbackData; - } - } - } -} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/OutboundSMSTextMessage.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/OutboundSMSTextMessage.java new file mode 100644 index 00000000..243c014b --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/OutboundSMSTextMessage.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + + +public class OutboundSMSTextMessage { + + private String message; + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentAmountResponseWithTax.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentAmountResponseWithTax.java new file mode 100644 index 00000000..bca5afca --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentAmountResponseWithTax.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +public class PaymentAmountResponseWithTax { + + private ChargingInformation chargingInformation; + + private ChargingMetaDataWithTax chargingMetaData; + + public ChargingMetaDataWithTax getChargingMetaDataWithTax() { + return chargingMetaData; + } + + public void setChargingMetaDataWithTax(ChargingMetaDataWithTax chargingMetaDataWithTax) { + this.chargingMetaData = chargingMetaDataWithTax; + } + + public ChargingInformation getChargingInformation() { + return chargingInformation; + } + + public void setChargingInformation(ChargingInformation chargingInformation) { + this.chargingInformation = chargingInformation; + } + +} + diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentAmountWithTax.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentAmountWithTax.java new file mode 100644 index 00000000..9d5c93e4 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentAmountWithTax.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +public class PaymentAmountWithTax { + + private ChargingInformation chargingInformation; + + private ChargingMetaDataWithTax chargingMetaData; + + public ChargingMetaDataWithTax getChargingMetaData() { + return chargingMetaData; + } + + public void setChargingMetaData(ChargingMetaDataWithTax chargingMetaData) { + this.chargingMetaData = chargingMetaData; + } + + public ChargingInformation getChargingInformation() { + return chargingInformation; + } + + public void setChargingInformation(ChargingInformation chargingInformation) { + this.chargingInformation = chargingInformation; + } + + public String toString() { + StringBuilder builder = new StringBuilder(); + + if (chargingInformation != null) { + builder.append(" " + getChargingInformation().toString()); + } + + if(chargingMetaData != null){ + builder.append(" "+getChargingMetaData().toString()); + } + + return builder.toString(); + } + + + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentChargingInformation.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentChargingInformation.java new file mode 100644 index 00000000..b8cf50bc --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentChargingInformation.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2015-2016, WSO2.Telco Inc. (http://www.wso2telco.com) All Rights Reserved. + * + * WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +public class PaymentChargingInformation { + + private double amount; + + private String currency; + + private String description; + + public double getAmount() { + return amount; + } + + public void setAmount(double amount) { + this.amount = amount; + } + + public String getCurrency() { + return currency; + } + + public void setCurrency(String currency) { + this.currency = currency; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String toString() { + StringBuilder builder = new StringBuilder(); + + builder.append(" Amount : " + amount); + builder.append(" Currency : " + currency); + builder.append(" Description : " + description); + + return builder.toString(); + } + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentChargingMetaData.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentChargingMetaData.java new file mode 100644 index 00000000..103f986d --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentChargingMetaData.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2015-2016, WSO2.Telco Inc. (http://www.wso2telco.com) All Rights Reserved. + * + * WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +@JsonInclude(value=Include.NON_NULL) +public class PaymentChargingMetaData { + + private String onBehalfOf; + + private String purchaseCategoryCode; + + private String channel; + + private String taxAmount; + + public String getOnBehalfOf() { + return onBehalfOf; + } + + public void setOnBehalfOf(String onBehalfOf) { + this.onBehalfOf = onBehalfOf; + } + + public String getPurchaseCategoryCode() { + return purchaseCategoryCode; + } + + public void setPurchaseCategoryCode(String purchaseCategoryCode) { + this.purchaseCategoryCode = purchaseCategoryCode; + } + + public String getChannel() { + return channel; + } + + public void setChannel(String channel) { + this.channel = channel; + } + + public String getTaxAmount() { + return taxAmount; + } + + public void setTaxAmount(String taxAmount) { + this.taxAmount = taxAmount; + } + + public String toString() { + StringBuilder builder = new StringBuilder(); + + builder.append(" onBehalfOf : " + onBehalfOf); + builder.append(" categoryCode : " + purchaseCategoryCode); + builder.append(" channel : " + channel); + + return builder.toString(); + } + + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentListTransactionDTO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentListTransactionDTO.java new file mode 100644 index 00000000..cc51f807 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentListTransactionDTO.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +public class PaymentListTransactionDTO { + + private PaymentListTransactionResponseBean paymentTransactionList; + + public PaymentListTransactionResponseBean getPaymentTransactionList() { + return paymentTransactionList; + } + + public void setPaymentTransactionList(PaymentListTransactionResponseBean paymentTransactionList) { + this.paymentTransactionList = paymentTransactionList; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentListTransactionResponseBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentListTransactionResponseBean.java new file mode 100644 index 00000000..6726acb0 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentListTransactionResponseBean.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.ArrayList; +import java.util.List; + +public class PaymentListTransactionResponseBean { + + private List amountTransaction = new ArrayList(); + + private String resourceURL; + + public List getAmountTransaction() { + return amountTransaction; + } + + public void setAmountTransaction(List amountTransaction) { + this.amountTransaction = amountTransaction; + } + + public String getResourceURL() { + return resourceURL; + } + + public void setResourceURL(String resourceURL) { + this.resourceURL = resourceURL; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentRefundRequestWrapperDTO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentRefundRequestWrapperDTO.java new file mode 100644 index 00000000..a83b5234 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentRefundRequestWrapperDTO.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2015-2016, WSO2.Telco Inc. (http://www.wso2telco.com) All Rights Reserved. + * + * WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +public class PaymentRefundRequestWrapperDTO extends RequestDTO { + + /** The endUserId param **/ + private String endUserId; + + /** The request bean **/ + private PaymentRefundTransactionRequestBean refundRequestBean; + + public String getEndUserId() { + return endUserId; + } + + public void setEndUserId(String endUserId) { + this.endUserId = endUserId; + } + + public PaymentRefundTransactionRequestBean getRefundRequestBean() { + return refundRequestBean; + } + + public void setRefundRequestBean(PaymentRefundTransactionRequestBean refundRequestBean) { + this.refundRequestBean = refundRequestBean; + } +} \ No newline at end of file diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentRefundTransactionRequestBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentRefundTransactionRequestBean.java new file mode 100644 index 00000000..112e0d7d --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentRefundTransactionRequestBean.java @@ -0,0 +1,167 @@ +/******************************************************************************* + * Copyright (c) 2015-2016, WSO2.Telco Inc. (http://www.wso2telco.com) All Rights Reserved. + * + * WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + + +public class PaymentRefundTransactionRequestBean { + + private AmountTransaction amountTransaction; + + public AmountTransaction getAmountTransaction() { + return amountTransaction; + } + + public void setAmountTransaction(AmountTransaction amountTransaction) { + this.amountTransaction = amountTransaction; + } + + + public static class AmountTransaction { + + private String clientCorrelator; + + private String endUserId; + + private String originalServerReferenceCode; + + private ChargePaymentAmount paymentAmount; + + private String referenceCode; + + private String transactionOperationStatus; + + private String callbackData; + + private String mandateId; + + private String notificationFormat; + + private String notifyURL; + + private String productID; + + private String serviceID; + + public String getClientCorrelator() { + return clientCorrelator; + } + + public void setClientCorrelator(String clientCorrelator) { + this.clientCorrelator = clientCorrelator; + } + + public String getEndUserId() { + return endUserId; + } + + public void setEndUserId(String endUserId) { + this.endUserId = endUserId; + } + + public String getOriginalServerReferenceCode() { + return originalServerReferenceCode; + } + + public void setOriginalServerReferenceCode(String originalServerReferenceCode) { + this.originalServerReferenceCode = originalServerReferenceCode; + } + + public String getReferenceCode() { + return referenceCode; + } + + public void setReferenceCode(String referenceCode) { + this.referenceCode = referenceCode; + } + + public String getTransactionOperationStatus() { + return transactionOperationStatus; + } + + public void setTransactionOperationStatus(String transactionOperationStatus) { + this.transactionOperationStatus = transactionOperationStatus; + } + + public ChargePaymentAmount getPaymentAmount() { + return paymentAmount; + } + + public void setPaymentAmount(ChargePaymentAmount paymentAmount) { + this.paymentAmount = paymentAmount; + } + + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Client Correlator : " + getClientCorrelator()); + builder.append("EndUserId : " + getEndUserId()); + builder.append("Reference Code : " + getReferenceCode()); + + if (getPaymentAmount() != null) { + builder.append(" " + getPaymentAmount().toString()); + } + + return builder.toString(); + } + + public String getCallbackData() { + return callbackData; + } + + public void setCallbackData(String callbackData) { + this.callbackData = callbackData; + } + + public String getMandateId() { + return mandateId; + } + + public void setMandateId(String mandateId) { + this.mandateId = mandateId; + } + + public String getNotificationFormat() { + return notificationFormat; + } + + public void setNotificationFormat(String notificationFormat) { + this.notificationFormat = notificationFormat; + } + + public String getNotifyURL() { + return notifyURL; + } + + public void setNotifyURL(String notifyURL) { + this.notifyURL = notifyURL; + } + + public String getProductID() { + return productID; + } + + public void setProductID(String productID) { + this.productID = productID; + } + + public String getServiceID() { + return serviceID; + } + + public void setServiceID(String serviceID) { + this.serviceID = serviceID; + } + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentRefundTransactionResponseBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentRefundTransactionResponseBean.java new file mode 100644 index 00000000..b2b2d915 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/PaymentRefundTransactionResponseBean.java @@ -0,0 +1,159 @@ +package com.wso2telco.services.dep.sandbox.dao.model.custom; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +@JsonInclude(value=Include.NON_NULL) +public class PaymentRefundTransactionResponseBean { + + + private String clientCorrelator; + + private String endUserId; + + private String originalReferenceCode; + + private String originalServerReferenceCode; + + private ChargeRefundAmountResponse paymentAmount; + + private String referenceCode; + + private String serverReferenceCode; + + private String resourceURL; + + private String transactionOperationStatus; + + private String callbackData; + + private String mandateId; + + private String notificationFormat; + + private String notifyURL; + + private String productID; + + private String serviceID; + + public String getClientCorrelator() { + return clientCorrelator; + } + + public void setClientCorrelator(String clientCorrelator) { + this.clientCorrelator = clientCorrelator; + } + + public String getEndUserId() { + return endUserId; + } + + public void setEndUserId(String endUserId) { + this.endUserId = endUserId; + } + + public String getOriginalReferenceCode() { + return originalReferenceCode; + } + + public void setOriginalReferenceCode(String originalReferenceCode) { + this.originalReferenceCode = originalReferenceCode; + } + + public String getOriginalServerReferenceCode() { + return originalServerReferenceCode; + } + + public void setOriginalServerReferenceCode(String originalServerReferenceCode) { + this.originalServerReferenceCode = originalServerReferenceCode; + } + + public String getReferenceCode() { + return referenceCode; + } + + public void setReferenceCode(String referenceCode) { + this.referenceCode = referenceCode; + } + + public String getServerReferenceCode() { + return serverReferenceCode; + } + + public void setServerReferenceCode(String serverReferenceCode) { + this.serverReferenceCode = serverReferenceCode; + } + + public String getResourceURL() { + return resourceURL; + } + + public void setResourceURL(String resourceURL) { + this.resourceURL = resourceURL; + } + + public String getTransactionOperationStatus() { + return transactionOperationStatus; + } + + public void setTransactionOperationStatus(String transactionOperationStatus) { + this.transactionOperationStatus = transactionOperationStatus; + } + + public ChargeRefundAmountResponse getPaymentAmount() { + return paymentAmount; + } + + public void setPaymentAmount(ChargeRefundAmountResponse paymentAmount) { + this.paymentAmount = paymentAmount; + } + + public String getCallbackData() { + return callbackData; + } + + public void setCallbackData(String callbackData) { + this.callbackData = callbackData; + } + + public String getMandateId() { + return mandateId; + } + + public void setMandateId(String mandateId) { + this.mandateId = mandateId; + } + + public String getNotificationFormat() { + return notificationFormat; + } + + public void setNotificationFormat(String notificationFormat) { + this.notificationFormat = notificationFormat; + } + + public String getNotifyURL() { + return notifyURL; + } + + public void setNotifyURL(String notifyURL) { + this.notifyURL = notifyURL; + } + + public String getProductID() { + return productID; + } + + public void setProductID(String productID) { + this.productID = productID; + } + + public String getServiceID() { + return serviceID; + } + + public void setServiceID(String serviceID) { + this.serviceID = serviceID; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ReceiptRequest.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ReceiptRequest.java new file mode 100644 index 00000000..baaaade3 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ReceiptRequest.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(value= JsonInclude.Include.NON_NULL) +public class ReceiptRequest { + + private String notifyURL; + private String callbackData; + + public String getNotifyURL() { + return notifyURL; + } + + public void setNotifyURL(String notifyURL) { + this.notifyURL = notifyURL; + } + + public String getCallbackData() { + return callbackData; + } + + public void setCallbackData(String callbackData) { + this.callbackData = callbackData; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ReceiptResponse.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ReceiptResponse.java new file mode 100644 index 00000000..fdf81361 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/ReceiptResponse.java @@ -0,0 +1,44 @@ + +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(value= JsonInclude.Include.NON_NULL) +public class ReceiptResponse { + + private String notifyURL; + private String callbackData; + + public String getNotifyURL() { + return notifyURL; + } + + public void setNotifyURL(String notifyURL) { + this.notifyURL = notifyURL; + } + + public String getCallbackData() { + return callbackData; + } + + public void setCallbackData(String callbackData) { + this.callbackData = callbackData; + } +} + + diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/RefundPaymentDTO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/RefundPaymentDTO.java new file mode 100644 index 00000000..63ff4d37 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/RefundPaymentDTO.java @@ -0,0 +1,14 @@ +package com.wso2telco.services.dep.sandbox.dao.model.custom; + +public class RefundPaymentDTO { + + private PaymentRefundTransactionResponseBean amountTransaction; + + public PaymentRefundTransactionResponseBean getAmountTransaction() { + return amountTransaction; + } + + public void setAmountTransaction(PaymentRefundTransactionResponseBean amountTransaction) { + this.amountTransaction = amountTransaction; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/RefundRequestBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/RefundRequestBean.java index 78a7733e..06ff72a8 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/RefundRequestBean.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/RefundRequestBean.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; public class RefundRequestBean { @@ -17,25 +32,24 @@ public void setRefundRequest(RefundRequest refundRequest) { public static class RefundRequest{ - private double amount; - + private String clientCorrelator; + + private String msisdn; + private String originalServerReferenceCode; + private String reasonForRefund; - - private String merchantIdentification; - - private String serverTransactionReference; - - private CallbackReference receiptRequest; - public double getAmount() { - return amount; - } + private String refundAmount; - public void setAmount(double amount) { - this.amount = amount; - } + private PaymentAmountWithTax paymentAmount; + + private String referenceCode; + + private String merchantIdentification; + + private ReceiptRequest receiptRequest; public String getClientCorrelator() { return clientCorrelator; @@ -45,6 +59,23 @@ public void setClientCorrelator(String clientCorrelator) { this.clientCorrelator = clientCorrelator; } + + public String getMsisdn() { + return msisdn; + } + + public void setMsisdn(String msisdn) { + this.msisdn = msisdn; + } + + public String getOriginalServerReferenceCode() { + return originalServerReferenceCode; + } + + public void setOriginalServerReferenceCode(String originalServerReferenceCode) { + this.originalServerReferenceCode = originalServerReferenceCode; + } + public String getReasonForRefund() { return reasonForRefund; } @@ -53,29 +84,66 @@ public void setReasonForRefund(String reasonForRefund) { this.reasonForRefund = reasonForRefund; } - public String getMerchantIdentification() { - return merchantIdentification; + public String getRefundAmount() { + return refundAmount; + } + + public void setRefundAmount(String refundAmount) { + this.refundAmount = refundAmount; } - public void setMerchantIdentification(String merchantIdentification) { - this.merchantIdentification = merchantIdentification; + + public PaymentAmountWithTax getPaymentAmount() { + return paymentAmount; } - public String getServerTransactionReference() { - return serverTransactionReference; + public void setPaymentAmount(PaymentAmountWithTax paymentAmount) { + this.paymentAmount = paymentAmount; } - public void setServerTransactionReference(String serverTransactionReference) { - this.serverTransactionReference = serverTransactionReference; + public String getReferenceCode() { + return referenceCode; } - public CallbackReference getReceiptRequest() { + public void setReferenceCode(String referenceCode) { + this.referenceCode = referenceCode; + } + + + public String getMerchantIdentification() { + return merchantIdentification; + } + + public void setMerchantIdentification(String merchantIdentification) { + this.merchantIdentification = merchantIdentification; + } + + public ReceiptRequest getReceiptRequest() { return receiptRequest; } - public void setReceiptRequest(CallbackReference receiptRequest) { + public void setReceiptRequest(ReceiptRequest receiptRequest) { this.receiptRequest = receiptRequest; } + + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Client Correlator : " + getClientCorrelator()); + builder.append("msisdn : " + getMsisdn()); + builder.append("OriginalServerReferenceCode : " +getOriginalServerReferenceCode()); + builder.append("reasonForRefund : " + getReasonForRefund()); + builder.append("refundAmount : " + getPaymentAmount()); + builder.append("callbackData : " +receiptRequest.getCallbackData()); + builder.append("notifyURL : "+receiptRequest.getNotifyURL()); + builder.append("merchantIdentification : "+getMerchantIdentification()); + + if (getPaymentAmount() != null) { + builder.append(" " + getPaymentAmount().toString()); + } + + return builder.toString(); + } + } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/RefundResponseBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/RefundResponseBean.java index 7c4170d8..238abc64 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/RefundResponseBean.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/RefundResponseBean.java @@ -1,83 +1,160 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; +import com.fasterxml.jackson.annotation.JsonInclude; + public class RefundResponseBean { - - private RefundResponse refundResponse; - - - public RefundResponse getRefundResponse() { - return refundResponse; - } - - - public void setRefundResponse(RefundResponse refundResponse) { - this.refundResponse = refundResponse; - } - - - public static class RefundResponse { - - private double amount; - - private String serverTransactionReference; - - private String clientCorrelator; - - private String reasonForRefund; - - private String merchantIdentification; - - private CallbackReference receiptResponse; - - public double getAmount() { - return amount; - } - - public void setAmount(double amount) { - this.amount = amount; - } - - public String getServerTransactionReference() { - return serverTransactionReference; - } - - public void setServerTransactionReference(String serverTransactionReference) { - this.serverTransactionReference = serverTransactionReference; - } - - public String getClientCorrelator() { - return clientCorrelator; - } - - public void setClientCorrelator(String clientCorrelator) { - this.clientCorrelator = clientCorrelator; - } - - public String getReasonForRefund() { - return reasonForRefund; - } - - public void setReasonForRefund(String reasonForRefund) { - this.reasonForRefund = reasonForRefund; - } - - public String getMerchantIdentification() { - return merchantIdentification; - } - - public void setMerchantIdentification(String merchantIdentification) { - this.merchantIdentification = merchantIdentification; - } - - public CallbackReference getReceiptResponse() { - return receiptResponse; - } - - public void setReceiptResponse(CallbackReference receiptResponse) { - this.receiptResponse = receiptResponse; - } - - - } + + private RefundResponse refundResponse; + + + public RefundResponse getRefundResponse() { + return refundResponse; + } + + + public void setRefundResponse(RefundResponse refundResponse) { + this.refundResponse = refundResponse; + } + + @JsonInclude(value= JsonInclude.Include.NON_NULL) + public static class RefundResponse { + + private String clientCorrelator; + + private String endUserID; + + private String originalServerReferenceCode; + + private String reasonForRefund; + + private double refundAmount; + + private String merchantIdentification; + + private PaymentAmountWithTax paymentAmount; + + private ReceiptResponse receiptResponse; + + private String referenceCode; + + private String resourceURL; + + private String transactionOperationStatus; + + private String serverReferanceCode; + + + public String getClientCorrelator() { + return clientCorrelator; + } + + public void setClientCorrelator(String clientCorrelator) { + this.clientCorrelator = clientCorrelator; + } + + public String getEndUserID() { + return endUserID; + } + + public void setEndUserID(String endUserID) { + this.endUserID = endUserID; + } + + public String getOriginalServerReferenceCode() { + return originalServerReferenceCode; + } + + public void setOriginalServerReferenceCode(String originalServerReferenceCode) { + this.originalServerReferenceCode = originalServerReferenceCode; + } + + public String getReasonForRefund() { + return reasonForRefund; + } + + public void setReasonForRefund(String reasonForRefund) { + this.reasonForRefund = reasonForRefund; + } + + public double getRefundAmount() { + return refundAmount; + } + + public void setRefundAmount(double refundAmount) { + this.refundAmount = refundAmount; + } + + + public String getReferenceCode() { + return referenceCode; + } + + public void setReferenceCode(String referenceCode) { + this.referenceCode = referenceCode; + } + + public String getResourceURL() { + return resourceURL; + } + + public void setResourceURL(String resourceURL) { + this.resourceURL = resourceURL; + } + + public String getTransactionOperationStatus() { + return transactionOperationStatus; + } + + public void setTransactionOperationStatus(String transactionOperationStatus) { + this.transactionOperationStatus = transactionOperationStatus; + } + + public PaymentAmountWithTax getPaymentAmount() { + return paymentAmount; + } + + public void setPaymentAmount(PaymentAmountWithTax paymentAmount) { + this.paymentAmount = paymentAmount; + } + + public String getServerReferanceCode() { + return serverReferanceCode; + } + + public void setServerReferanceCode(String serverReferanceCode) { + this.serverReferanceCode = serverReferanceCode; + } + + public ReceiptResponse getReceiptResponse() { + return receiptResponse; + } + + public void setReceiptResponse(ReceiptResponse receiptResponse) { + this.receiptResponse = receiptResponse; + } + + public String getMerchantIdentification() { + return merchantIdentification; + } + + public void setMerchantIdentification(String merchantIdentification) { + this.merchantIdentification = merchantIdentification; + } + } } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/SendMTSMSRequestWrapperDTO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/SendMTSMSRequestWrapperDTO.java deleted file mode 100644 index 5cd3d97b..00000000 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/SendMTSMSRequestWrapperDTO.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.wso2telco.services.dep.sandbox.dao.model.custom; - -public class SendMTSMSRequestWrapperDTO extends RequestDTO { - - private static final long serialVersionUID = 796868921376883562L; - private String shortCode; - private OutboundSMSMessageRequestBean outboundSMSMessageRequestBean; - - public String getShortCode() { - return shortCode; - } - - public void setShortCode(String shortCode) { - this.shortCode = shortCode; - } - - public OutboundSMSMessageRequestBean getOutboundSMSMessageRequestBean() { - return outboundSMSMessageRequestBean; - } - - public void setOutboundSMSMessageRequestBean(OutboundSMSMessageRequestBean outboundSMSMessageRequestBean) { - this.outboundSMSMessageRequestBean = outboundSMSMessageRequestBean; - } -} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/SenderDetails.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/SenderDetails.java new file mode 100644 index 00000000..73b10023 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/SenderDetails.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + + +public class SenderDetails { + + private String senderAddress; + private String operatorCode; + private String senderName; + + + public String getSenderAddress() { + return senderAddress; + } + + public void setSenderAddress(String senderAddress) { + this.senderAddress = senderAddress; + } + + public String getOperatorCode() { + return operatorCode; + } + + public void setOperatorCode(String operatorCode) { + this.operatorCode = operatorCode; + } + + public String getSenderName() { + return senderName; + } + + public void setSenderName(String senderName) { + this.senderName = senderName; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/USSDSessionDTO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/USSDSessionDTO.java new file mode 100644 index 00000000..262087f1 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/USSDSessionDTO.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +public class USSDSessionDTO { + + private USSDSessionInitiatorResponseBean outboundUSSDMessageRequest; + + public USSDSessionInitiatorResponseBean getOutboundUSSDMessageRequest() { + return outboundUSSDMessageRequest; + } + + public void setOutboundUSSDMessageRequest(USSDSessionInitiatorResponseBean outboundUSSDMessageRequest) { + this.outboundUSSDMessageRequest = outboundUSSDMessageRequest; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/USSDSessionInitiatorRequestBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/USSDSessionInitiatorRequestBean.java new file mode 100644 index 00000000..6d251db8 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/USSDSessionInitiatorRequestBean.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +public class USSDSessionInitiatorRequestBean { + + private OutboundUSSDMessageRequest outboundUSSDMessageRequest; + + public OutboundUSSDMessageRequest getOutboundUSSDMessageRequest() { + return outboundUSSDMessageRequest; + } + + public void setOutboundUSSDMessageRequest(OutboundUSSDMessageRequest outboundUSSDMessageRequest) { + this.outboundUSSDMessageRequest = outboundUSSDMessageRequest; + } + + public static class OutboundUSSDMessageRequest { + + private String address; + + private String shortCode; + + private String keyword; + + private String outboundUSSDMessage; + + private String clientCorrelator; + + private USSDSessionResponseRequest responseRequest; + + private String ussdAction; + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getShortCode() { + return shortCode; + } + + public void setShortCode(String shortCode) { + this.shortCode = shortCode; + } + + public String getKeyword() { + return keyword; + } + + public void setKeyword(String keyword) { + this.keyword = keyword; + } + + public String getOutboundUSSDMessage() { + return outboundUSSDMessage; + } + + public void setOutboundUSSDMessage(String outboundUSSDMessage) { + this.outboundUSSDMessage = outboundUSSDMessage; + } + + public String getClientCorrelator() { + return clientCorrelator; + } + + public void setClientCorrelator(String clientCorrelator) { + this.clientCorrelator = clientCorrelator; + } + + public USSDSessionResponseRequest getResponseRequest() { + return responseRequest; + } + + public void setResponseRequest(USSDSessionResponseRequest responseRequest) { + this.responseRequest = responseRequest; + } + + public String getUssdAction() { + return ussdAction; + } + + public void setUssdAction(String ussdAction) { + this.ussdAction = ussdAction; + } + } + + +} + diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/USSDSessionInitiatorResponseBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/USSDSessionInitiatorResponseBean.java new file mode 100644 index 00000000..17f4a205 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/USSDSessionInitiatorResponseBean.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class USSDSessionInitiatorResponseBean { + + private String address; + + private String keyword; + + private String shortCode; + + private String outboundUSSDMessage; + + private String clientCorrelator; + + private USSDSessionResponseRequest responseRequest; + + private String ussdAction; + + private String deliveryStatus; + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getKeyword() { + return keyword; + } + + public void setKeyword(String keyword) { + this.keyword = keyword; + } + + public String getShortCode() { + return shortCode; + } + + public void setShortCode(String shortCode) { + this.shortCode = shortCode; + } + + public String getOutboundUSSDMessage() { + return outboundUSSDMessage; + } + + public void setOutboundUSSDMessage(String outboundUSSDMessage) { + this.outboundUSSDMessage = outboundUSSDMessage; + } + + public String getClientCorrelator() { + return clientCorrelator; + } + + public void setClientCorrelator(String clientCorrelator) { + this.clientCorrelator = clientCorrelator; + } + + public USSDSessionResponseRequest getResponseRequest() { + return responseRequest; + } + + public void setResponseRequest(USSDSessionResponseRequest responseRequest) { + this.responseRequest = responseRequest; + } + + public String getUssdAction() { + return ussdAction; + } + + public void setUssdAction(String ussdAction) { + this.ussdAction = ussdAction; + } + + public String getDeliveryStatus() { + return deliveryStatus; + } + + public void setDeliveryStatus(String deliveryStatus) { + this.deliveryStatus = deliveryStatus; + } + } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/USSDSessionRequestWrapperDTO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/USSDSessionRequestWrapperDTO.java new file mode 100644 index 00000000..f7c97bf8 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/USSDSessionRequestWrapperDTO.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +public class USSDSessionRequestWrapperDTO extends RequestDTO { + + private String endUserId; + + private USSDSessionInitiatorRequestBean ussdSessionRequestBean; + + public String getEndUserId() { + return endUserId; + } + + public void setEndUserId(String endUserId) { + this.endUserId = endUserId; + } + + public USSDSessionInitiatorRequestBean getUssdSessionRequestBean() { + return ussdSessionRequestBean; + } + + public void setUssdSessionRequestBean(USSDSessionInitiatorRequestBean ussdSessionRequestBean) { + this.ussdSessionRequestBean = ussdSessionRequestBean; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/USSDSessionResponseRequest.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/USSDSessionResponseRequest.java new file mode 100644 index 00000000..f263173f --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/custom/USSDSessionResponseRequest.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.custom; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(value= JsonInclude.Include.NON_NULL) +public class USSDSessionResponseRequest { + + private String notifyURL; + + private String callbackData; + + public String getNotifyURL() { + return notifyURL; + } + + public void setNotifyURL(String notifyURL) { + this.notifyURL = notifyURL; + } + + public String getCallbackData() { + return callbackData; + } + + public void setCallbackData(String callbackData) { + this.callbackData = callbackData; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/ManageNumber.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/ManageNumber.java index 0bd5f65b..2a2c9fa4 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/ManageNumber.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/ManageNumber.java @@ -50,6 +50,18 @@ public class ManageNumber implements Serializable { @Column(name = "num_status") private int status; + @Column(name="altitude") + private String altitude; + + @Column(name="latitude") + private String latitude; + + @Column(name="longitude") + private String longitude; + + @Column(name="loc_ret_status") + private String locationRetrieveStatus; + @ManyToOne @JoinColumn(name = "user_id", referencedColumnName = "id") private User user; @@ -182,4 +194,68 @@ public double getReserved_amount() { public void setReserved_amount(double reserved_amount) { this.reserved_amount = reserved_amount; } + + /** + * get location parameter altitude. + * @return altitude + */ + public String getAltitude() { + return altitude; + } + + /** + * Set location parameter altitude. + * @param altitude altitude + */ + public void setAltitude(String altitude) { + this.altitude = altitude; + } + + /** + * Get location parameter latitude + * @return latitude + */ + public String getLatitude() { + return latitude; + } + + /** + * Set location parameter latitude. + * @param latitude latitude + */ + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + /** + * Get location parameter longitude. + * @return longitude + */ + public String getLongitude() { + return longitude; + } + + /** + * Set location parameter longitude. + * @param longitude longitude + */ + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + /** + * Get Location Retrieve Status. + * @return status + */ + public String getLocationRetrieveStatus() { + return locationRetrieveStatus; + } + + /** + * Set Location Retrieve Status. + * @param locationRetrieveStatus status + */ + public void setLocationRetrieveStatus(String locationRetrieveStatus) { + this.locationRetrieveStatus = locationRetrieveStatus; + } } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/MessageLog.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/MessageLog.java index 4e3b6d15..b83a1249 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/MessageLog.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/MessageLog.java @@ -15,89 +15,106 @@ @Entity @Table(name = "sbtmessagelog") public class MessageLog { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") - private int id; - - @Column(name = "request") - private String request; - - @Column(name = "servicenameid") - private int servicenameid; - - @Column(name = "userid") - private int userid; - - @Column(name = "reference") - private String reference; - - @Column(name = "value") - private String value; - - @Temporal(javax.persistence.TemporalType.TIMESTAMP) - @Column(name="messagetimestamp") + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private int id; + + @Column(name = "request") + private String request; + + @Column(name = "status") + private int status; + + @Column(name = "type") + private int type; + + @Column(name = "servicenameid") + private int servicenameid; + + @Column(name = "userid") + private int userid; + + @Column(name = "reference") + private String reference; + + @Column(name = "value") + private String value; + + @Temporal(javax.persistence.TemporalType.TIMESTAMP) + @Column(name = "messagetimestamp") private Date messageTimestamp; - public int getId() { - return id; - } + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getRequest() { + return request; + } + + public void setRequest(String request) { + this.request = request; + } - public void setId(int id) { - this.id = id; - } + public int getServicenameid() { + return servicenameid; + } - public String getRequest() { - return request; - } + public void setServicenameid(int servicenameid) { + this.servicenameid = servicenameid; + } - public void setRequest(String request) { - this.request = request; - } + public int getUserid() { + return userid; + } - public int getServicenameid() { - return servicenameid; - } + public void setUserid(int userid) { + this.userid = userid; + } - public void setServicenameid(int servicenameid) { - this.servicenameid = servicenameid; - } + public String getReference() { + return reference; + } - public int getUserid() { - return userid; - } + public void setReference(String reference) { + this.reference = reference; + } - public void setUserid(int userid) { - this.userid = userid; - } + public String getValue() { + return value; + } - public String getReference() { - return reference; - } + public void setValue(String value) { + this.value = value; + } - public void setReference(String reference) { - this.reference = reference; - } + public Date getMessageTimestamp() { + return messageTimestamp; + } - public String getValue() { - return value; - } + public void setMessageTimestamp(Date messageTimestamp) { + this.messageTimestamp = messageTimestamp; + } - public void setValue(String value) { - this.value = value; - } + public int getStatus() { + return status; + } - public Date getMessageTimestamp() { - return messageTimestamp; - } + public void setStatus(int status) { + this.status = status; + } - public void setMessageTimestamp(Date messageTimestamp) { - this.messageTimestamp = messageTimestamp; - } - - - - + public int getType() { + return type; + } + public void setType(int type) { + this.type = type; + } } \ No newline at end of file diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/SendSMSToApplication.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/SendSMSToApplication.java index 14cb321d..79b9d991 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/SendSMSToApplication.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/SendSMSToApplication.java @@ -36,7 +36,8 @@ public class SendSMSToApplication { @Column(name="destination_address") private String destinationAddress; - + + @Column(name="message") private String message; @Temporal(javax.persistence.TemporalType.DATE) diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/SubscribeSMSRequest.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/SubscribeSMSRequest.java index aa17ed0f..cd34a493 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/SubscribeSMSRequest.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/SubscribeSMSRequest.java @@ -41,7 +41,8 @@ public class SubscribeSMSRequest implements Serializable { @Column(name="callback_data") private String callbackData; - + + @Column(name="criteria") private String criteria; @Column(name="notification_format") diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/UssdApplication.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/UssdApplication.java new file mode 100644 index 00000000..09893707 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/dao/model/domain/UssdApplication.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.dao.model.domain; + +import javax.persistence.*; + +@Entity +@Table(name = "ussd_applications") +public class UssdApplication { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private int id; + + @Column(name = "userid") + private int userid; + + @Column(name = "shortCode") + private String shortCode; + + @Column(name = "keyword") + private String keyword; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getUserid() { + return userid; + } + + public void setUserid(int userid) { + this.userid = userid; + } + + public String getShortCode() { + return shortCode; + } + + public void setShortCode(String shortCode) { + this.shortCode = shortCode; + } + + public String getKeyword() { + return keyword; + } + + public void setKeyword(String keyword) { + this.keyword = keyword; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/Application.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/Application.java index 48e63127..bfa50787 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/Application.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/Application.java @@ -16,13 +16,13 @@ package com.wso2telco.services.dep.sandbox.service; +import com.wso2telco.core.mi.AbstractApplication; +import io.dropwizard.setup.Environment; + import java.util.ArrayList; import java.util.List; -import com.wso2telco.core.mi.AbstractApplication; -import com.wso2telco.core.mi.ConfigDTO; - -import io.dropwizard.setup.Environment; +import static com.wso2telco.services.dep.sandbox.service.SandboxDTO.getBehaveType; public class Application extends AbstractApplication { @@ -30,7 +30,6 @@ public class Application extends AbstractApplication { protected List getRestFulComponents() { List listOfObject =new ArrayList(); listOfObject.add(new UserService()); - listOfObject.add(new SandboxService()); listOfObject.add(new ProvisionService()); listOfObject.add(new ProvisionConfigurationService()); listOfObject.add(new CustomerInfoService()); @@ -38,14 +37,29 @@ protected List getRestFulComponents() { listOfObject.add(new CreditService()); listOfObject.add(new WalletService()); listOfObject.add(new WalletConfigurationService()); + listOfObject.add(new PaymentService_v0_8()); + listOfObject.add(new PaymentService_v1_3()); + listOfObject.add(new LocationService()); + listOfObject.add(new USSDService()); + listOfObject.add(new USSSDConfigurationService()); + listOfObject.add(new SMSConfigurationService()); + + if(getBehaveType().equals("Hub")){ + + listOfObject.add(new smsServiceHub()); + + }else if(getBehaveType().equals("Gateway")) { + + listOfObject.add(new SmsServiceGateway()); + } return listOfObject; } - public static void main(String[] args) { try { new Application().run(args); } catch (Exception e) { + e.printStackTrace(); System.out.println("Unable to start the server " + e.getMessage()); } } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/CreditService.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/CreditService.java index 744d6b69..83f1ed20 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/CreditService.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/CreditService.java @@ -11,6 +11,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import com.wso2telco.services.dep.sandbox.dao.model.custom.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -19,9 +20,6 @@ import com.wordnik.swagger.annotations.ApiImplicitParams; import com.wordnik.swagger.annotations.ApiOperation; import com.wordnik.swagger.annotations.ApiParam; -import com.wso2telco.services.dep.sandbox.dao.model.custom.CreditApplyRequestWrapper; -import com.wso2telco.services.dep.sandbox.dao.model.custom.CreditRequestBean; -import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; import com.wso2telco.services.dep.sandbox.exception.SandboxException.SandboxErrorType; import com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory; import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; @@ -61,8 +59,8 @@ public Response creditApplyForRequestedService( try { returnable = handler.execute(requestDTO); - Response response = Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); - return response; + return Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); + } catch (Exception ex) { LOG.error("###CREDIT### Error in Credit Service", ex); Response response = Response.status(Status.BAD_REQUEST).entity(SandboxErrorType.SERVICE_ERROR.getCode() + " " + SandboxErrorType.SERVICE_ERROR.getMessage()).build(); @@ -70,7 +68,7 @@ public Response creditApplyForRequestedService( } } - /*@POST + @POST @Path("/{msisdn}/refund") @ApiOperation(value = "patialRefundForRequestedService", notes = "patial refund requested service", response = Response.class) @ApiImplicitParams({ @@ -102,6 +100,6 @@ public Response patialRefundForRequestedService( Response response = Response.status(Status.BAD_REQUEST).entity(SandboxErrorType.SERVICE_ERROR.getCode() + " " + SandboxErrorType.SERVICE_ERROR.getMessage()).build(); return response; } - }*/ + } } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/LocationService.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/LocationService.java new file mode 100644 index 00000000..25db557d --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/LocationService.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.service; + +import com.wordnik.swagger.annotations.*; +import com.wso2telco.services.dep.sandbox.dao.model.custom.LocationRequestWrapperDTO; +import com.wso2telco.services.dep.sandbox.exception.SandboxException; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; +import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; +import com.wso2telco.services.dep.sandbox.util.RequestType; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/location/v1") +@Produces({MediaType.APPLICATION_JSON}) +@Api(value = "location", description = "Rest Service for Location API") +public class LocationService { + + Log LOG = LogFactory.getLog(LocationService.class); + + @GET + @Path("/queries/location") + @ApiOperation(value = "locationService", notes = "locationService", response = Response.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "sandbox", value = "Authorization token", required = true, dataType = "string", paramType = "header") }) + public Response location( + @ApiParam(value = "address", required = true) @QueryParam("address") String address, @ApiParam(value = "requestedAccuracy", required = true) @QueryParam("requestedAccuracy") String requestedAccuracy, + @Context HttpServletRequest request) { + LOG.debug("address={address}&requestedAccuracy={requestedAccuracy} invorked :" + address +" " +requestedAccuracy); + LocationRequestWrapperDTO requestDTO = new LocationRequestWrapperDTO(); + requestDTO.setHttpRequest(request); + requestDTO.setAddress(address); + requestDTO.setRequestedAccuracy(requestedAccuracy); + requestDTO.setRequestType(RequestType.LOCATION); + + RequestHandleable handler = RequestBuilderFactory.getInstance(requestDTO); + Returnable returnable = null; + + try { + returnable = handler.execute(requestDTO); + Response response = Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); + LOG.debug("Location SERVICE RESPONSE : " + response); + return response; + } catch (Exception ex) { + LOG.error("Location SERVICE ERROR : ", ex); + return Response.status(Response.Status.BAD_REQUEST).entity( + SandboxException.SandboxErrorType.SERVICE_ERROR.getCode() + " " + SandboxException.SandboxErrorType.SERVICE_ERROR.getMessage()) + .build(); + } + + } + + + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/PaymentService_v0_8.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/PaymentService_v0_8.java new file mode 100644 index 00000000..43ab84e6 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/PaymentService_v0_8.java @@ -0,0 +1,122 @@ + +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.service; + + +import com.google.gson.Gson; +import com.wordnik.swagger.annotations.*; +import com.wso2telco.core.dbutils.exception.ServiceError; +import com.wso2telco.dep.oneapivalidation.exceptions.PolicyException; +import com.wso2telco.services.dep.sandbox.dao.model.custom.*; +import com.wso2telco.services.dep.sandbox.exception.SandboxException; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; +import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; +import com.wso2telco.services.dep.sandbox.util.RequestError; +import com.wso2telco.services.dep.sandbox.util.RequestType; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + + +@Path("payment/v0_8") +@Produces({MediaType.APPLICATION_JSON}) +@Api(value = "payment/v08", description = "Rest Service for Payment API") + + +public class PaymentService_v0_8 { + + protected static final String POLICYEXCEPTION = "POL0001"; + + Log LOG = LogFactory.getLog(PaymentService_v0_8.class); + + @POST + @Path("/{endUserId}/transactions/amount") + @ApiOperation(value = "makePaymentService", notes = "make payment service", response = Response.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "sandbox", value = "Authorization token", required = true, dataType = "string", paramType = "header")}) + public Response makePayment( + @ApiParam(value = "endUserId", required = true) @PathParam("endUserId") String endUserId, + PaymentRefundTransactionRequestBean makePaymentRequestBean, @Context HttpServletRequest request) { + if (LOG.isDebugEnabled()) { + LOG.debug("###PAYMENT### /{endUserId} invoked : endUserId - " + endUserId); + } + if (LOG.isDebugEnabled() && makePaymentRequestBean != null) { + LOG.debug(makePaymentRequestBean); + } + //Separate Charged and Refunded request calls + if (makePaymentRequestBean.getAmountTransaction().getTransactionOperationStatus().equalsIgnoreCase("charged")) { + + ChargePaymentRequestWrapperDTO requestDTO = new ChargePaymentRequestWrapperDTO(); + requestDTO.setHttpRequest(request); + requestDTO.setEndUserId(endUserId); + requestDTO.setPaymentRefundTransactionRequestBean(makePaymentRequestBean); + requestDTO.setRequestType(RequestType.PAYMENT); + + RequestHandleable handler = RequestBuilderFactory.getInstance(requestDTO); + Returnable returnable = null; + + try { + returnable = handler.execute(requestDTO); + Response response = Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); + return response; + } catch (Exception ex) { + LOG.error("Make Payment SERVICE ERROR", ex); + Response response = Response.status(Response.Status.BAD_REQUEST).entity( + SandboxException.SandboxErrorType.SERVICE_ERROR.getCode() + " " + SandboxException.SandboxErrorType.SERVICE_ERROR.getMessage()) + .build(); + return response; + } + } else if (makePaymentRequestBean.getAmountTransaction().getTransactionOperationStatus().equalsIgnoreCase("refunded")){ + + PaymentRefundRequestWrapperDTO requestDTO = new PaymentRefundRequestWrapperDTO(); + requestDTO.setHttpRequest(request); + requestDTO.setEndUserId(endUserId); + requestDTO.setRefundRequestBean(makePaymentRequestBean); + requestDTO.setRequestType(RequestType.PAYMENT); + + RequestHandleable handler = RequestBuilderFactory.getInstance(requestDTO); + Returnable returnable = null; + + try { + returnable = handler.execute(requestDTO); + Response response = Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); + return response; + } catch (Exception ex) { + LOG.error("Make Payment SERVICE ERROR", ex); + Response response = Response.status(Response.Status.BAD_REQUEST).entity( + SandboxException.SandboxErrorType.SERVICE_ERROR.getCode() + " " + SandboxException.SandboxErrorType.SERVICE_ERROR.getMessage()) + .build(); + return response; + } + } + + PolicyException policyException = new PolicyException(POLICYEXCEPTION, (ServiceError.INVALID_INPUT_VALUE).getMessage(), "transactionOperationStatus should be Charged/Refunded"); + RequestError requestError = new RequestError(); + requestError.setPolicyException(policyException); + Gson gson = new Gson(); + String errorMessage = gson.toJson(requestError); + Response response = Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); + return response; + + } + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/PaymentService_v1_3.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/PaymentService_v1_3.java new file mode 100644 index 00000000..c8fb3bcc --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/PaymentService_v1_3.java @@ -0,0 +1,154 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.service; + +import com.google.gson.Gson; +import com.wordnik.swagger.annotations.*; +import com.wso2telco.core.dbutils.exception.ServiceError; +import com.wso2telco.dep.oneapivalidation.exceptions.PolicyException; +import com.wso2telco.services.dep.sandbox.dao.model.custom.*; +import com.wso2telco.services.dep.sandbox.exception.SandboxException; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; +import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; +import com.wso2telco.services.dep.sandbox.servicefactory.payment.PaymentListTransactionRequestWrapper; +import com.wso2telco.services.dep.sandbox.util.RequestError; +import com.wso2telco.services.dep.sandbox.util.RequestType; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("payment/v1_3") +@Produces({MediaType.APPLICATION_JSON}) +@Api(value = "payment/v1_3", description = "Rest Service for Payment API") +public class PaymentService_v1_3 { + + protected static final String POLICYEXCEPTION = "POL0001"; + + Log LOG = LogFactory.getLog(PaymentService_v1_3.class); + + @POST + @Path("/{endUserId}/transactions/amount") + @ApiOperation(value = "makePaymentService", notes = "make payment service", response = Response.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "sandbox", value = "Authorization token", required = true, dataType = "string", paramType = "header")}) + public Response makePayment( + @ApiParam(value = "endUserId", required = true) @PathParam("endUserId") String endUserId, + PaymentRefundTransactionRequestBean makePaymentRequestBean, @Context HttpServletRequest request) { + if (LOG.isDebugEnabled()) { + LOG.debug("###PAYMENT### /{endUserId} invoked : endUserId - " + endUserId); + } + if (LOG.isDebugEnabled() && makePaymentRequestBean != null) { + LOG.debug(makePaymentRequestBean); + } + //Separate Charged and Refunded request calls + if (makePaymentRequestBean.getAmountTransaction().getTransactionOperationStatus().equalsIgnoreCase("charged")) { + + ChargePaymentRequestWrapperDTO requestDTO = new ChargePaymentRequestWrapperDTO(); + requestDTO.setHttpRequest(request); + requestDTO.setEndUserId(endUserId); + requestDTO.setPaymentRefundTransactionRequestBean(makePaymentRequestBean); + requestDTO.setRequestType(RequestType.PAYMENT); + + RequestHandleable handler = RequestBuilderFactory.getInstance(requestDTO); + Returnable returnable = null; + + try { + returnable = handler.execute(requestDTO); + Response response = Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); + return response; + } catch (Exception ex) { + LOG.error("Make Payment SERVICE ERROR", ex); + Response response = Response.status(Response.Status.BAD_REQUEST).entity( + SandboxException.SandboxErrorType.SERVICE_ERROR.getCode() + " " + SandboxException.SandboxErrorType.SERVICE_ERROR.getMessage()) + .build(); + return response; + } + + } else if (makePaymentRequestBean.getAmountTransaction().getTransactionOperationStatus().equalsIgnoreCase("refunded")){ + + PaymentRefundRequestWrapperDTO requestDTO = new PaymentRefundRequestWrapperDTO(); + requestDTO.setHttpRequest(request); + requestDTO.setEndUserId(endUserId); + requestDTO.setRefundRequestBean(makePaymentRequestBean); + requestDTO.setRequestType(RequestType.PAYMENT); + + RequestHandleable handler = RequestBuilderFactory.getInstance(requestDTO); + Returnable returnable = null; + + try { + returnable = handler.execute(requestDTO); + Response response = Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); + return response; + } catch (Exception ex) { + LOG.error("Make Payment SERVICE ERROR", ex); + Response response = Response.status(Response.Status.BAD_REQUEST).entity( + SandboxException.SandboxErrorType.SERVICE_ERROR.getCode() + " " + SandboxException.SandboxErrorType.SERVICE_ERROR.getMessage()) + .build(); + return response; + } + } + + PolicyException policyException = new PolicyException(POLICYEXCEPTION, (ServiceError.INVALID_INPUT_VALUE).getMessage(), "transactionOperationStatus should be Charged/Refunded"); + RequestError requestError = new RequestError(); + requestError.setPolicyException(policyException); + Gson gson = new Gson(); + String errorMessage = gson.toJson(requestError); + Response response = Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); + return response; + + } + + @GET + @Path("/{endUserId}/transactions") + @ApiOperation(value = "listTransactionService", notes = "listTransactionService", response = Response.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "sandbox", value = "Authorization token", required = true, dataType = "string", paramType = "header")}) + public Response getAttributeServices( + @ApiParam(value = "endUserId", required = false) @PathParam("endUserId") String endUserId, + @Context HttpServletRequest request) { + LOG.debug("/{endUserId}/transactions invorked :" + endUserId); + PaymentListTransactionRequestWrapper requestDTO = new PaymentListTransactionRequestWrapper(); + requestDTO.setHttpRequest(request); + requestDTO.setEndUserId(endUserId); + requestDTO.setRequestType(RequestType.PAYMENT); + + RequestHandleable handler = RequestBuilderFactory.getInstance(requestDTO); + Returnable returnable = null; + + try { + returnable = handler.execute(requestDTO); + Response response = Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); + if (LOG.isDebugEnabled()) { + LOG.debug("List Transaction SERVICE RESPONSE : " + response); + } + return response; + } catch (Exception ex) { + LOG.error("List Transaction SERVICE ERROR : ", ex); + return Response.status(Response.Status.BAD_REQUEST).entity( + SandboxException.SandboxErrorType.SERVICE_ERROR.getCode() + " " + SandboxException.SandboxErrorType.SERVICE_ERROR.getMessage()) + .build(); + } + + } + + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/SMSConfigurationService.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/SMSConfigurationService.java new file mode 100644 index 00000000..ac2f57a7 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/SMSConfigurationService.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.service; + +import com.wordnik.swagger.annotations.Api; +import com.wordnik.swagger.annotations.ApiImplicitParam; +import com.wordnik.swagger.annotations.ApiImplicitParams; +import com.wordnik.swagger.annotations.ApiOperation; +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; +import com.wso2telco.services.dep.sandbox.exception.SandboxException; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; +import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; +import com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.SMSParameterConfigRequestBean; +import com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.SMSParameterConfigRequestWrapper; +import com.wso2telco.services.dep.sandbox.servicefactory.ussd.USSDApplicationConfigRequestBean; +import com.wso2telco.services.dep.sandbox.servicefactory.ussd.USSDApplicationConfigRequestWrapper; +import com.wso2telco.services.dep.sandbox.util.RequestType; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + + +@Path("/sms/{v1}/config") +@Consumes({ MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN }) +@Produces({ MediaType.APPLICATION_JSON }) +@Api(value = "/sms/{v1}/config", description = "Rest Services for SMS API related Configurations") +public class SMSConfigurationService { + + Log log = LogFactory.getLog(SMSConfigurationService.class); + + @POST + @Path("/addSMSParameters") + @ApiOperation(value = "addApplicationInfo", notes = "Add new application for ussd", response = Response.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "sandbox", value = "username", required = true, dataType = "string", paramType = "header") }) + public Response addAccountInfo( + SMSParameterConfigRequestBean smsParameterConfigRequestBean, @Context HttpServletRequest request) { + + SMSParameterConfigRequestWrapper requestDTO = new SMSParameterConfigRequestWrapper(); + requestDTO.setHttpRequest(request); + requestDTO.setParameterConfigRequestBean(smsParameterConfigRequestBean); + requestDTO.setRequestType(RequestType.SMSCONFIG); + + RequestHandleable handler = RequestBuilderFactory.getInstance(requestDTO); + Returnable returnable = null; + + try { + returnable = handler.execute(requestDTO); + Response response = Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); + return response; + } catch (Exception ex) { + log.error("###USSD### Error in USSD Configuration add Application info service", ex); + Response response = Response.status(Response.Status.BAD_REQUEST).entity( + SandboxException.SandboxErrorType.SERVICE_ERROR.getCode() + " " + SandboxException.SandboxErrorType.SERVICE_ERROR.getMessage()) + .build(); + return response; + } + } + + + + + + + + + + + + + + + + + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/SandboxDTO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/SandboxDTO.java index ab1a7016..0307ff5a 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/SandboxDTO.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/SandboxDTO.java @@ -26,6 +26,9 @@ public class SandboxDTO extends ConfigDTO{ private static final long serialVersionUID = 4016247712134961725L; @JsonProperty private static int requestIdentifierSize; + + @JsonProperty + private static String behaveType; public static int getRequestIdentifierSize() { return requestIdentifierSize; @@ -33,6 +36,12 @@ public static int getRequestIdentifierSize() { public void setRequestIdentifierSize(int requestIdentifierSize) { SandboxDTO.requestIdentifierSize = requestIdentifierSize; } - - + + public static String getBehaveType() { + return behaveType; + } + + public void setBehaveType(String behaveType) { + SandboxDTO.behaveType = behaveType; + } } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/SandboxService.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/SandboxService.java index 1fc69939..0fe16638 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/SandboxService.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/SandboxService.java @@ -17,25 +17,20 @@ package com.wso2telco.services.dep.sandbox.service; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import com.wordnik.swagger.annotations.Api; +import com.wordnik.swagger.annotations.ApiImplicitParam; +import com.wordnik.swagger.annotations.ApiImplicitParams; +import com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.hub.outboundSMSMessageRequestBeanHub; +import com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.hub.sendMTSMSRequestWrapperDTOHub; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.wordnik.swagger.annotations.ApiOperation; -import com.wso2telco.services.dep.sandbox.dao.model.custom.LocationRequestWrapperDTO; -import com.wso2telco.services.dep.sandbox.dao.model.custom.OutboundSMSMessageRequestBean; -import com.wso2telco.services.dep.sandbox.dao.model.custom.QuerySMSDeliveryStatusRequestWrapperDTO; -import com.wso2telco.services.dep.sandbox.dao.model.custom.SendMTSMSRequestWrapperDTO; import com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory; import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; @@ -49,13 +44,14 @@ * * @since 1.8.0-SNAPSHOT */ -@Path("/") +@Path("/smsmessaging") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) +@Api(value = "/{v1}/sms", description = "sms") public class SandboxService { Log LOG = LogFactory.getLog(SandboxService.class); - @GET +/* @GET @Path("/location/{v1}/queries/location") @ApiOperation(value = "get Location ", notes = "get Location ", response = Response.class) public Response getLocation(@QueryParam("address") String address, @@ -78,19 +74,24 @@ public Response getLocation(@QueryParam("address") String address, } catch (Exception e) { return Response.status(Response.Status.BAD_REQUEST).entity(returnable.getResponse()).build(); } - } + }*/ @POST - @Path("/smsmessaging/{apiVersion}/outbound/{shortCode}/requests") + @Path("/{apiVersion}/outbound/{shortCode}/requests") + @ApiOperation(value = "sms", notes = "sms ", response = Response.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "sandbox", value = "Authorization token", + required = true, dataType = "string", paramType = "header") + }) public Response handleSendMTSMSRequest(@Context HttpServletRequest httpRequest, @PathParam("apiVersion") String apiVersion, - @PathParam("shortCode") String shortCode, OutboundSMSMessageRequestBean outboundSMSMessageRequestBean) { + @PathParam("shortCode") String shortCode, outboundSMSMessageRequestBeanHub outboundSMSMessageRequestBean_hub) { - SendMTSMSRequestWrapperDTO requestDTO = new SendMTSMSRequestWrapperDTO(); + sendMTSMSRequestWrapperDTOHub requestDTO = new sendMTSMSRequestWrapperDTOHub(); requestDTO.setHttpRequest(httpRequest); requestDTO.setRequestType(RequestType.SMSMESSAGING); requestDTO.setApiVersion(apiVersion); requestDTO.setShortCode(shortCode); - requestDTO.setOutboundSMSMessageRequestBean(outboundSMSMessageRequestBean); + requestDTO.setOutboundSMSMessageRequestBean(outboundSMSMessageRequestBean_hub); RequestHandleable handler = RequestBuilderFactory.getInstance(requestDTO); @@ -102,11 +103,11 @@ public Response handleSendMTSMSRequest(@Context HttpServletRequest httpRequest, return Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); } catch (Exception e) { + e.printStackTrace(); return Response.status(Response.Status.BAD_REQUEST).entity(returnable.getResponse()).build(); } } - - @GET +/* @GET @Path("/smsmessaging/{apiVersion}/outbound/{shortCode}/requests/{mtSMSTransactionId}/deliveryInfos") public Response handleQuerySMSDeliveryStatusRequest(@Context HttpServletRequest httpRequest, @PathParam("apiVersion") String apiVersion, @PathParam("shortCode") String shortCode, @@ -130,5 +131,5 @@ public Response handleQuerySMSDeliveryStatusRequest(@Context HttpServletRequest } return null; - } + }*/ } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/SmsServiceGateway.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/SmsServiceGateway.java new file mode 100644 index 00000000..29f659cc --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/SmsServiceGateway.java @@ -0,0 +1,285 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.service; + + + +import com.wordnik.swagger.annotations.*; +import com.wso2telco.services.dep.sandbox.exception.SandboxException; + +import com.wordnik.swagger.annotations.Api; +import com.wordnik.swagger.annotations.ApiImplicitParam; +import com.wordnik.swagger.annotations.ApiImplicitParams; +import com.wordnik.swagger.annotations.ApiOperation; +import com.wso2telco.services.dep.sandbox.dao.model.custom.QuerySMSDeliveryStatusRequestWrapperDTO; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactoryGateway; +import com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway.*; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; +import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; +import com.wso2telco.services.dep.sandbox.util.RequestType; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + + +@Path("smsmessaging") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Api(value = "/v1_2/sms", description = " Rest Service for SMS API") + public class SmsServiceGateway { + + Log LOG = LogFactory.getLog(SmsServiceGateway.class); + + @POST + @Path("/v1_2/outbound/{shortCode}/requests") + @ApiOperation(value = "Send SMS Service", notes = "Send SMS service in Gateway", response = Response.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "sandbox", value = "Authorization token", + required = true, dataType = "string", paramType = "header") + }) + public Response handleSendMTSMSRequest(@Context HttpServletRequest httpRequest, + @PathParam("shortCode") String shortCode, OutboundSMSMessageRequestBeanGateway outboundSMSMessageRequestBean_gateway) { + + SendMTSMSRequestWrapperDTOGateway requestDTO = new SendMTSMSRequestWrapperDTOGateway(); + requestDTO.setHttpRequest(httpRequest); + requestDTO.setRequestType(RequestType.SMSMESSAGING); + requestDTO.setApiVersion("v1_2"); + requestDTO.setShortCode(shortCode); + requestDTO.setOutboundSMSMessageRequestBeanGw(outboundSMSMessageRequestBean_gateway); + + RequestHandleable handler = RequestBuilderFactoryGateway.getInstance(requestDTO); + + Returnable returnable = null; + + try { + + returnable = handler.execute(requestDTO); + return Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); + } catch (Exception e) { + return Response.status(Response.Status.BAD_REQUEST).entity(returnable.getResponse()).build(); + } + } + + + @GET + @Path("/v1_2/inbound/registrations/{registrationId}/messages") + @ApiOperation(value = "Receiving SMS Service", notes = "Receiving SMS API", response = Response.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "sandbox", value = "Authorization token", required = true, dataType = "string", paramType = "header") }) + public Response ReceivingSMS( + @ApiParam(value = "registrationId", required = true) @PathParam("registrationId") String registrationID, @ApiParam(value = "maxBatchSize", required = true) @QueryParam("maxBatchSize") int maxBatchSize, + @Context HttpServletRequest request) { + + LOG.debug("registrationId={registrationId}&maxBatchSize={maxBatchSize} invorked :" + registrationID +" " +maxBatchSize); + + ReceivingSMSRequestWrapperGateway requestDTO = new ReceivingSMSRequestWrapperGateway(); + requestDTO.setHttpRequest(request); + requestDTO.setRegistrationID(registrationID); + requestDTO.setMaxBatchSize(maxBatchSize); + requestDTO.setRequestType(RequestType.SMSMESSAGING); + + RequestHandleable handler = RequestBuilderFactoryGateway.getInstance(requestDTO); + Returnable returnable = null; + + try { + returnable = handler.execute(requestDTO); + Response response = Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); + LOG.debug("SMS RECEIVING SERVICE RESPONSE : " + response); + return response; + } catch (Exception ex) { + LOG.error("SMS RECEIVING SERVICE ERROR : ", ex); + return Response.status(Response.Status.BAD_REQUEST).entity( + SandboxException.SandboxErrorType.SERVICE_ERROR.getCode() + " " + SandboxException.SandboxErrorType.SERVICE_ERROR.getMessage()) + .build(); + } + + } + + @POST + @Path("/v1_2/inbound/subscriptions") + @ApiOperation(value = "Subscribe to Notifications of Messages Sent to Your Application Service", notes = "SMS subscriptions service in Gateway", response = Response.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "sandbox", value = "Authorization token", + required = true, dataType = "string", paramType = "header") + }) + public Response subscribeToApplication(@Context HttpServletRequest httpRequest, SubscribeApplicationNotificationsRequestBeanGateway subscribeApplicationNotificationsRequestBean) { + + SubscribeApplicationNotificationsRequestWrapperGateway requestDTO = new SubscribeApplicationNotificationsRequestWrapperGateway(); + requestDTO.setHttpRequest(httpRequest); + requestDTO.setRequestType(RequestType.SMSMESSAGING); + requestDTO.setApiVersion("v1_2"); + requestDTO.setSubscribeApplicationNotificationsRequestBean(subscribeApplicationNotificationsRequestBean); + RequestHandleable handler = RequestBuilderFactoryGateway.getInstance(requestDTO); + Returnable returnable = null; + + try { + + returnable = handler.execute(requestDTO); + return Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); + } catch (Exception e) { + return Response.status(Response.Status.BAD_REQUEST).entity(returnable.getResponse()).build(); + } + } + + @DELETE + @Path("/v1_2/inbound/subscriptions/{subscriptionID}") + @ApiOperation(value = "Stop the Subscription to Message Notifications", notes = "SMS subscriptions service in Gateway", response = Response.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "sandbox", value = "Authorization token", + required = true, dataType = "string", paramType = "header") + }) + public Response deleteSubscribeToApplication(@ApiParam(value = "subscriptionID", required = true) @PathParam("subscriptionID") String subscriptionID,@Context HttpServletRequest httpRequest) { + + StopSubscriptionMessageNotificationRequestWrapper requestDTO = new StopSubscriptionMessageNotificationRequestWrapper(); + requestDTO.setHttpRequest(httpRequest); + requestDTO.setRequestType(RequestType.SMSMESSAGING); + requestDTO.setApiVersion("v1_2"); + requestDTO.setSubscriptionID(subscriptionID); + RequestHandleable handler = RequestBuilderFactoryGateway.getInstance(requestDTO); + Returnable returnable = null; + + try { + + returnable = handler.execute(requestDTO); + return Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); + } catch (Exception e) { + return Response.status(Response.Status.BAD_REQUEST).entity(returnable.getResponse()).build(); + } + } + + @POST + @Path("/v1_2/outbound/{senderAddress}/subscriptions") + @ApiOperation(value = "Subscribe to delivery status notifications sent by SMS", notes = "Subscribe SMS service in Gateway", response = Response.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "sandbox", value = "Authorization token", + required = true, dataType = "string", paramType = "header") + }) + public Response handleSubscribeToDeliveryNotifications( + @Context HttpServletRequest httpRequest, + @ApiParam(value = "senderAddress", required = true) + @PathParam("senderAddress") String senderAddress, + SubscribeToDeliveryNotificationRequestBeanGateway subscribeToDeliveryNotificationRequestBeanGateway) { + if (LOG.isDebugEnabled()) { + LOG.debug("###SMS### /{senderAddress} invoked : senderAddress - " + senderAddress); + } + if (LOG.isDebugEnabled() && subscribeToDeliveryNotificationRequestBeanGateway != null) { + LOG.debug(subscribeToDeliveryNotificationRequestBeanGateway); + } + + SubscribeToDeliveryNotificationWrapperDTOGateway requestDTO = new + SubscribeToDeliveryNotificationWrapperDTOGateway(); + requestDTO.setHttpRequest(httpRequest); + requestDTO.setRequestType(RequestType.SMSMESSAGING); + requestDTO.setApiVersion("v1_2"); + requestDTO.setSenderAddress(senderAddress); + requestDTO.setSubscribeToDeliveryNotificationRequestBeanGateway + (subscribeToDeliveryNotificationRequestBeanGateway); + + RequestHandleable handler = RequestBuilderFactoryGateway.getInstance(requestDTO); + + Returnable returnable = null; + + try { + returnable = handler.execute(requestDTO); + Response response = Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); + return response; + } catch (Exception e) { + LOG.error("Subscribe to Notification SERVICE ERROR", e); + return Response.status(Response.Status.BAD_REQUEST).entity( + SandboxException.SandboxErrorType.SERVICE_ERROR.getCode() + " " + SandboxException + .SandboxErrorType.SERVICE_ERROR.getMessage()) + .build(); + } + } + + @DELETE + @Path("/v1_2/outbound/{senderAddress}/subscription/{subscriptionID}") + @ApiOperation(value = "Stop subscribing to delivery status notifications", notes = "Stop subscribing to delivery status notifications", response = Response.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "sandbox", value = "Authorization token", + required = true, dataType = "string", paramType = "header") + }) + public Response handleDeleteSubscriptionNotification( + @Context HttpServletRequest httpRequest, + @ApiParam(value = "senderAddress", required = true) + @PathParam("senderAddress") String senderAddress, @PathParam("subscriptionID") int subscriptionID) { + + if (LOG.isDebugEnabled()) { + LOG.debug("###SMS### /{senderAddress} invoked : senderAddress - " + senderAddress); + } + + StopSubscriptionNotificationRequestWrapper requestDTO = new StopSubscriptionNotificationRequestWrapper(); + + requestDTO.setHttpRequest(httpRequest); + requestDTO.setApiVersion("v1_2"); + requestDTO.setSenderAddress(senderAddress); + requestDTO.setSubscriptionID(subscriptionID); + requestDTO.setRequestType(RequestType.SMSMESSAGING); + + RequestHandleable handler = RequestBuilderFactoryGateway.getInstance(requestDTO); + + Returnable returnable = null; + + try { + returnable = handler.execute(requestDTO); + Response response = Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); + return response; + } catch (Exception e) { + LOG.error("Subscribe to Notification SERVICE ERROR", e); + return Response.status(Response.Status.BAD_REQUEST).entity( + SandboxException.SandboxErrorType.SERVICE_ERROR.getCode() + " " + SandboxException + .SandboxErrorType.SERVICE_ERROR.getMessage()) + .build(); + } + } + + @GET + @Path("/v1_2/outbound/{shortCode}/requests/{smsTransactionId}/deliveryInfos") + @ApiOperation(value = "querySMSDeliveryStatusRequest", notes = "Request SMS Delivary Status", response = Response.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "sandbox", value = "Authorization token", required = true, dataType = "string", paramType = "header")}) + + public Response handleQuerySmsDelivaryStatusRequest(@Context HttpServletRequest httpServletRequest, @PathParam("shortCode") String shortCode, @PathParam("smsTransactionId") String smsTransactionId) + { + QuerySMSDeliveryStatusRequestWrapperDTO requestWrapperDTO = new QuerySMSDeliveryStatusRequestWrapperDTO(); + requestWrapperDTO.setShortCode(shortCode); + requestWrapperDTO.setApiVersion("v1_2"); + requestWrapperDTO.setMtSMSTransactionId(smsTransactionId); + requestWrapperDTO.setHttpRequest(httpServletRequest); + requestWrapperDTO.setRequestType(RequestType.SMSMESSAGING); + RequestHandleable requestHandler = RequestBuilderFactory.getInstance(requestWrapperDTO); + Returnable returnable = null; + try { + returnable = requestHandler.execute(requestWrapperDTO); + return Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); + } catch (Exception e) { + LOG.error("SMS QUERY DELIVERY STATUS ERROR"+e); + return Response.status(Response.Status.BAD_REQUEST).entity(returnable.getResponse()).build(); + } + + + } + + + +} + diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/USSDService.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/USSDService.java new file mode 100644 index 00000000..12da1463 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/USSDService.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.service; + +import com.wordnik.swagger.annotations.*; +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; +import com.wso2telco.services.dep.sandbox.dao.model.custom.USSDSessionInitiatorRequestBean; +import com.wso2telco.services.dep.sandbox.dao.model.custom.USSDSessionRequestWrapperDTO; +import com.wso2telco.services.dep.sandbox.exception.SandboxException; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; +import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; +import com.wso2telco.services.dep.sandbox.util.RequestType; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("ussd/{v1}") +@Produces({MediaType.APPLICATION_JSON}) +@Api(value = "ussd/v1", description = "Rest Service for USSD API") +public class USSDService { + + Log LOG = LogFactory.getLog(USSDService.class); + + @POST + @Path("/outbound/{endUserId}") + @ApiOperation(value = "ussdSession", notes = "initiate ussd session with endUser", response = Response.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "sandbox", value = "Authorization token", required = true, dataType = "string", paramType = "header")}) + public Response ussdSession( + @ApiParam(value = "endUserId", required = true) @PathParam("endUserId") String endUserId, + USSDSessionInitiatorRequestBean ussdSessionRequestBean, @Context HttpServletRequest request) { + if (LOG.isDebugEnabled()) { + LOG.debug("###USSD### /{endUserId} invoked : endUserId - " + endUserId); + } + if (LOG.isDebugEnabled() && ussdSessionRequestBean != null) { + LOG.debug(ussdSessionRequestBean); + } + + USSDSessionRequestWrapperDTO requestDTO = new USSDSessionRequestWrapperDTO(); + requestDTO.setHttpRequest(request); + requestDTO.setEndUserId(endUserId); + requestDTO.setUssdSessionRequestBean(ussdSessionRequestBean); + requestDTO.setRequestType(RequestType.USSD); + + RequestHandleable handler = RequestBuilderFactory.getInstance(requestDTO); + Returnable returnable; + + try { + returnable = handler.execute(requestDTO); + Response response = Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); + return response; + } catch (Exception ex) { + LOG.error("USSD initializing session Error", ex); + Response response = Response.status(Response.Status.BAD_REQUEST).entity( + SandboxException.SandboxErrorType.SERVICE_ERROR.getCode() + " " + SandboxException.SandboxErrorType.SERVICE_ERROR.getMessage()) + .build(); + return response; + } + } + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/USSSDConfigurationService.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/USSSDConfigurationService.java new file mode 100644 index 00000000..a5c3a3f6 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/USSSDConfigurationService.java @@ -0,0 +1,91 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.service; + +import com.wordnik.swagger.annotations.*; +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; +import com.wso2telco.services.dep.sandbox.exception.SandboxException; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; +import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; +import com.wso2telco.services.dep.sandbox.servicefactory.ussd.USSDApplicationConfigRequestBean; +import com.wso2telco.services.dep.sandbox.servicefactory.ussd.USSDApplicationConfigRequestWrapper; +import com.wso2telco.services.dep.sandbox.util.RequestType; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/ussd/{v1}/config") +@Consumes({ MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN }) +@Produces({ MediaType.APPLICATION_JSON }) +@Api(value = "/ussd/{v1}/config", description = "Rest Services for USSD API related Configurations") +public class USSSDConfigurationService { + + + Log log = LogFactory.getLog(USSSDConfigurationService.class); + + @POST + @Path("/addApplicationInfo") + @ApiOperation(value = "addApplicationInfo", notes = "Add new application for ussd", response = Response.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "sandbox", value = "username", required = true, dataType = "string", paramType = "header") }) + public Response addAccountInfo( + USSDApplicationConfigRequestBean ussdApplicationConfigRequestBean, @Context HttpServletRequest request) { + + USSDApplicationConfigRequestWrapper requestDTO = new USSDApplicationConfigRequestWrapper(); + requestDTO.setHttpRequest(request); + requestDTO.setUssdApplicationConfigRequestBean(ussdApplicationConfigRequestBean); + requestDTO.setRequestType(RequestType.USSDCONFIG); + + RequestHandleable handler = RequestBuilderFactory.getInstance(requestDTO); + Returnable returnable = null; + + try { + returnable = handler.execute(requestDTO); + Response response = Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); + return response; + } catch (Exception ex) { + log.error("###USSD### Error in USSD Configuration add Application info service", ex); + Response response = Response.status(Response.Status.BAD_REQUEST).entity( + SandboxException.SandboxErrorType.SERVICE_ERROR.getCode() + " " + SandboxException.SandboxErrorType.SERVICE_ERROR.getMessage()) + .build(); + return response; + } + } + + + + + + + + + + + + + +} + + + + diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/smsServiceHub.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/smsServiceHub.java new file mode 100644 index 00000000..3f018117 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/service/smsServiceHub.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.service; + +import com.wordnik.swagger.annotations.Api; +import com.wordnik.swagger.annotations.ApiImplicitParam; +import com.wordnik.swagger.annotations.ApiImplicitParams; +import com.wordnik.swagger.annotations.ApiOperation; +import com.wso2telco.services.dep.sandbox.dao.model.custom.QuerySMSDeliveryStatusRequestWrapperDTO; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactory; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestBuilderFactoryHub; +import com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.hub.outboundSMSMessageRequestBeanHub; +import com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.hub.sendMTSMSRequestWrapperDTOHub; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; +import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; +import com.wso2telco.services.dep.sandbox.util.RequestType; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import static com.wso2telco.services.dep.sandbox.service.SandboxDTO.getBehaveType; + +@Path("smsmessaging") +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +@Api(value = "/v1_3/sms", description = "sms") +public class smsServiceHub { + + Log LOG = LogFactory.getLog(smsServiceHub.class); + String mode = getBehaveType(); + + @POST + @Path("/v1_3/outbound/{shortCode}/requests") + @ApiOperation(value = "sms", notes = "sms ", response = Response.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "sandbox", value = "Authorization token", + required = true, dataType = "string", paramType = "header") + }) + public Response handleSendMTSMSRequest(@Context HttpServletRequest httpRequest, + @PathParam("shortCode") String shortCode, outboundSMSMessageRequestBeanHub outboundSMSMessageRequestBean_hub) { + + sendMTSMSRequestWrapperDTOHub requestDTO = new sendMTSMSRequestWrapperDTOHub(); + requestDTO.setHttpRequest(httpRequest); + requestDTO.setRequestType(RequestType.SMSMESSAGING); + requestDTO.setApiVersion("v1_3"); + requestDTO.setShortCode(shortCode); + requestDTO.setOutboundSMSMessageRequestBean(outboundSMSMessageRequestBean_hub); + + RequestHandleable handler = RequestBuilderFactoryHub.getInstance(requestDTO); + + Returnable returnable = null; + + try { + + returnable = handler.execute(requestDTO); + return Response.status(returnable.getHttpStatus()).entity(returnable.getResponse()).build(); + } catch (Exception e) { + + e.printStackTrace(); + return Response.status(Response.Status.BAD_REQUEST).entity(returnable.getResponse()).build(); + } + } + + + + + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/AbstractRequestHandler.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/AbstractRequestHandler.java index d1c9d52b..ecddcecf 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/AbstractRequestHandler.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/AbstractRequestHandler.java @@ -1,37 +1,43 @@ package com.wso2telco.services.dep.sandbox.servicefactory; -import java.util.ArrayList; -import java.util.Base64; -import java.util.Base64.Decoder; -import java.util.List; - -import javax.ws.rs.core.Response.Status; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.json.JSONException; -import org.json.JSONObject; - import com.wso2telco.core.dbutils.exception.ThrowableError; +import com.wso2telco.dep.oneapivalidation.exceptions.CustomException; import com.wso2telco.dep.oneapivalidation.exceptions.PolicyException; import com.wso2telco.dep.oneapivalidation.exceptions.ServiceException; import com.wso2telco.services.dep.sandbox.dao.DaoFactory; import com.wso2telco.services.dep.sandbox.dao.GenaricDAO; +import com.wso2telco.services.dep.sandbox.dao.LoggingDAO; import com.wso2telco.services.dep.sandbox.dao.UserDAO; import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; -import com.wso2telco.services.dep.sandbox.dao.model.domain.ManageNumber; -import com.wso2telco.services.dep.sandbox.dao.model.domain.User; +import com.wso2telco.services.dep.sandbox.dao.model.domain.*; import com.wso2telco.services.dep.sandbox.util.RequestError; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.bouncycastle.asn1.dvcs.ServiceType; +import org.json.JSONException; +import org.json.JSONObject; + +import javax.ws.rs.core.Response.Status; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Base64.Decoder; +import java.util.Date; +import java.util.List; public abstract class AbstractRequestHandler implements RequestHandleable { protected Log LOG; protected GenaricDAO dao; protected UserDAO userDAO; + protected User user; + protected LoggingDAO loggingDAO; + private int referenceNumber; { dao =DaoFactory.getGenaricDAO(); userDAO = DaoFactory.getUserDAO(); - } + loggingDAO = DaoFactory.getLoggingDAO(); + + } /** * internally used to indicate the type of exception being stored is a * ServiceException @@ -43,6 +49,7 @@ public abstract class AbstractRequestHandler implements R */ protected static final int POLICYEXCEPTION = 2; + public final Returnable execute(final RequestDTO requestDTO) throws Exception { E2 wrapperDTO = (E2) requestDTO; init(wrapperDTO); @@ -61,7 +68,7 @@ public final Returnable execute(final RequestDTO requestDTO) throws Exception { /** * load user domain object from db */ - final User user = userDAO.getUser(sandboxusr); + user = userDAO.getUser(sandboxusr); requestDTO.setUser(user); validate(wrapperDTO); /** @@ -69,19 +76,30 @@ public final Returnable execute(final RequestDTO requestDTO) throws Exception { */ if (!(this instanceof AddressIgnorerable)) { List userNotWhiteListed = getNotWhitelistedNumbers(user); + if (userNotWhiteListed != null && !userNotWhiteListed.isEmpty()) { Returnable responseDTO = getResponseDTO(); LOG.debug("Location parameters are empty"); responseDTO.setRequestError( - constructRequestError(SERVICEEXCEPTION, "SVC0001", "A service error occurred. Error code is %1", - StringUtils.join(userNotWhiteListed.toArray()) + " Not Whitelisted")); + constructRequestError(SERVICEEXCEPTION, "SVC0002", "A service error occurred. Error code is %1", + StringUtils.join(userNotWhiteListed.toArray())+" Not WhiteListed")); responseDTO.setHttpStatus(Status.BAD_REQUEST); return responseDTO; } } - return process(wrapperDTO); + /** + * log the request in the DB. + */ + if(this instanceof RequestResponseRequestHandleable){ + + RequestResponseRequestHandleable requestResponseRequestHandleable = (RequestResponseRequestHandleable)this; + String requestType = requestDTO.getRequestType().toString(); + saveMessageLog(requestType,requestResponseRequestHandleable.getApiServiceCalls(), + requestResponseRequestHandleable.getJosonString(requestDTO),requestResponseRequestHandleable.getnumber(requestDTO)); + } + return process(wrapperDTO); } private List getNotWhitelistedNumbers(User user) throws Exception { @@ -113,9 +131,38 @@ private List getNotWhitelistedNumbers(User user) throws Exception { protected abstract void init(final E2 extendedRequestDTO) throws Exception; - protected String getLastMobileNumber(String str) { - return str.substring(Math.max(0, str.length() - 11)); - } + protected String getLastMobileNumber(String str) throws Exception { + + if (str.contains("tel:+")) { + String[] parts = str.split("\\+"); + String numberOnly = parts[1]; + return str.substring(Math.max(0, str.length() - numberOnly.length())); + + } else if (str.contains("tel:")) { + String[] parts = str.split("\\:"); + String numberOnly = parts[1]; + return str.substring(Math.max(0, str.length() - numberOnly.length())); + + } else if (str.contains("etel:")) { + String[] parts = str.split("\\:"); + String numberOnly = parts[1]; + return str.substring(Math.max(0, str.length() - numberOnly.length())); + + } else if (str.contains("etel:+")) { + String[] parts = str.split("\\+"); + String numberOnly = parts[1]; + return str.substring(Math.max(0, str.length() - numberOnly.length())); + + } else if (str.contains("+")) { + String[] parts = str.split("\\+"); + String numberOnly = parts[1]; + return str.substring(Math.max(0, str.length() - numberOnly.length())); + + } else { + + return str; + } + } private String getProfileIdFromRequest(RequestDTO requestDTO) { @@ -169,4 +216,40 @@ protected RequestError constructRequestError(int type,ThrowableError throwableEr } return error; } + + public int getReferenceNumber() { + return referenceNumber; + } + + public void setReferenceNumber(int referenceNumber) { + this.referenceNumber = referenceNumber; + } + + /** + * This method is used for store request on the DB. + * @param requestType type of the request + * @param apiService api name + * @param jsonString request + * @param number msisdn + * @throws Exception + */ + private int saveMessageLog(String requestType,String apiService, String jsonString, String number) throws Exception { + + APITypes apiTypes = dao.getAPIType(requestType); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), apiService); + + MessageLog messageLog = new MessageLog(); + messageLog.setServicenameid(apiServiceCalls.getApiServiceCallId()); + messageLog.setUserid(user.getId()); + messageLog.setReference("msisdn"); + messageLog.setStatus(0); + messageLog.setType(MessageType.Request.getValue()); + messageLog.setValue("tel:+"+number); + messageLog.setRequest(jsonString); + messageLog.setMessageTimestamp(new Date()); + int ref_number = loggingDAO.saveMessageLog(messageLog); + setReferenceNumber(ref_number); + return ref_number; + + } } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/MessageProcessStatus.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/MessageProcessStatus.java new file mode 100644 index 00000000..892d1b27 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/MessageProcessStatus.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory; + +public enum MessageProcessStatus { + + Failed(0),Success(1); + + private int value; + + private MessageProcessStatus(int value) { this.value=value; } + + public int getValue() { + return value; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/MessageType.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/MessageType.java new file mode 100644 index 00000000..7d217851 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/MessageType.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory; + + +public enum MessageType { + + Request(0),Response(1); + + private int value; + + private MessageType(int value) { + this.value= value; + } + + public int getValue() { + return value; + } + +} + + + diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/RequestBuilderFactory.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/RequestBuilderFactory.java index 4bd5c2b4..3590120c 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/RequestBuilderFactory.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/RequestBuilderFactory.java @@ -1,5 +1,7 @@ package com.wso2telco.services.dep.sandbox.servicefactory; +import com.wso2telco.services.dep.sandbox.servicefactory.ussd.USSDConfigServiceFactory; +import com.wso2telco.services.dep.sandbox.servicefactory.ussd.USSDRequestFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -39,6 +41,7 @@ public static RequestHandleable getInstance(final RequestDTO requestDTO) { break; case USSD: LOG.debug("LOADING USSD FACTORY"); + requestHandler = USSDRequestFactory.getInstance(requestDTO); break; case PAYMENT: LOG.debug("LOADING PAYMENT FACTORY"); @@ -76,7 +79,15 @@ public static RequestHandleable getInstance(final RequestDTO requestDTO) { LOG.debug("LOADING WALLET CONFIGURATION FACTORY"); requestHandler = WalletConfigServiceFactory.getInstance(requestDTO); break; - default: + case USSDCONFIG: + LOG.debug("LOADING USSD CONFIGURATION FACTORY"); + requestHandler = USSDConfigServiceFactory.getInstance(requestDTO); + break; + case SMSCONFIG: + LOG.debug("LOADING SMS CONFIGURATION FACTORY"); + requestHandler = SMSRequestFactory.getInstance(requestDTO); + break; + default: LOG.debug("APPROPIATE FACTORY CLASS NOT FOUND"); break; } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/RequestBuilderFactoryGateway.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/RequestBuilderFactoryGateway.java new file mode 100644 index 00000000..ff50ba8d --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/RequestBuilderFactoryGateway.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory; + + +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; +import com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.SMSRequestFactory; +import com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway.SMSRequestFactoryGateway; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class RequestBuilderFactoryGateway { + + + static Log LOG = LogFactory.getLog(RequestBuilderFactoryHub.class); + + @SuppressWarnings("rawtypes") + public static RequestHandleable getInstance(final RequestDTO requestDTO) { + + RequestHandleable requestHandler = null; + + switch (requestDTO.getRequestType()) { + case SMSMESSAGING: + LOG.debug("LOADING SMS MESSAGING FACTORY"); + requestHandler = SMSRequestFactoryGateway.getInstance(requestDTO); + break; + default: + LOG.debug("APPROPIATE FACTORY CLASS NOT FOUND"); + break; + } + return requestHandler; + } + + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/RequestBuilderFactoryHub.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/RequestBuilderFactoryHub.java new file mode 100644 index 00000000..cb136d58 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/RequestBuilderFactoryHub.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory; + + +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; +import com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.hub.SMSRequestFactoryHub; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class RequestBuilderFactoryHub { + + + static Log LOG = LogFactory.getLog(RequestBuilderFactoryHub.class); + + @SuppressWarnings("rawtypes") + public static RequestHandleable getInstance(final RequestDTO requestDTO) { + + RequestHandleable requestHandler = null; + + switch (requestDTO.getRequestType()) { + case SMSMESSAGING: + LOG.debug("LOADING SMS MESSAGING FACTORY"); + requestHandler = SMSRequestFactoryHub.getInstance(requestDTO); + break; + default: + LOG.debug("APPROPIATE FACTORY CLASS NOT FOUND"); + break; + } + return requestHandler; + } + + + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/RequestResponseRequestHandleable.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/RequestResponseRequestHandleable.java new file mode 100644 index 00000000..7fb379de --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/RequestResponseRequestHandleable.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory; + + +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; + +public interface RequestResponseRequestHandleable { + + String getApiServiceCalls() ; + String getJosonString(final E2 requestDTO); + String getnumber(final E2 requestDTO) throws Exception; + + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/credit/AttributeName.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/credit/AttributeName.java index 19f2b8f0..3354288b 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/credit/AttributeName.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/credit/AttributeName.java @@ -1,6 +1,6 @@ package com.wso2telco.services.dep.sandbox.servicefactory.credit; public enum AttributeName { - referenceCodeCredit, clientCorrelator, applyCredit + referenceCodeCredit, clientCorrelator, applyCredit, patialRefund } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/credit/CreditApplyRequestHandler.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/credit/CreditApplyRequestHandler.java index f74f07ae..14a68c29 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/credit/CreditApplyRequestHandler.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/credit/CreditApplyRequestHandler.java @@ -58,8 +58,10 @@ public class CreditApplyRequestHandler extends AbstractRequestHandler implements RequestResponseRequestHandleable { + + final String REFUND_AMOUNT = "refundAmount"; + final String MSISDN = "msisdn"; + final String CLIENTCORRELATOR = "clientCorrelator"; + final String REASON = "reasonForRefund"; + final String REFERENCE = "originalServerReferenceCode"; + final String REFERENCE_CODE = "referenceCode"; + final String ON_BEHALF_OF = "onBehalfOf"; + final String CATEGORY_CODE = "categoryCode"; + final String CHANNEL = "channel"; + final String TAX_AMOUNT = "taxAmount"; + final String CURRENCY = "currency"; + final String AMOUNT = "amount"; + final String TAX = "tax"; + final String CALL_BACK_DATA = "callbackData"; + final String NOTIFY_URL = "notifyURL"; + final String MERCHANT_IDENTIFICATION = "merchantIdentification"; + final String DESCRIPTION = "description"; + final String PURCHASE_CATEGORY_CODE = "purchaseCategoryCode"; + + private NumberDAO numberDao; + private CreditDAO creditDAO; + private MessageLogHandler logHandler; + private PatialRefundRequestWrapper requestWrapperDTO; + private PatialRefundResponseWrapper responseWrapperDTO; + private Integer correlatorid; + private LoggingDAO loggingDao; + private String responseReferenceCode; + private boolean isOriginalServerReferenceCode; + private double amount; + private double paymentAmount = 0.0; + + + { + LOG = LogFactory.getLog(PatialRefundRequestHandler.class); + loggingDao = DaoFactory.getLoggingDAO(); + numberDao = DaoFactory.getNumberDAO(); + creditDAO = DaoFactory.getCreditDAO(); + dao = DaoFactory.getGenaricDAO(); + logHandler = MessageLogHandler.getInstance(); + } + + private static boolean currencySymbol(@Nonnull final String currencyCode) { + try { + final Currency currency = Currency.getInstance(currencyCode); + return true; + } catch (final IllegalArgumentException x) { + return false; + } + } + + @Override + protected Returnable getResponseDTO() { + return responseWrapperDTO; + } + + @Override + protected List getAddress() { + List address = new ArrayList(); + address.add(requestWrapperDTO.getMsisdn()); + return address; + } + + @Override + protected boolean validate(PatialRefundRequestWrapper wrapperDTO) throws Exception { + + RefundRequestBean requestBean = wrapperDTO.getRefundRequestBean(); + RefundRequest request = requestBean.getRefundRequest(); + PaymentAmountWithTax paymentAmountWithTax = request.getPaymentAmount(); + ChargingInformation chargingInformation = paymentAmountWithTax.getChargingInformation(); + ChargingMetaDataWithTax metadata = paymentAmountWithTax.getChargingMetaData(); + String callbackData = null; + String notifyURL = null; + + if (requestBean != null && request != null) { + + String RefundAmount = CommonUtil.getNullOrTrimmedValue(request.getRefundAmount()); + String msisdn = CommonUtil.getNullOrTrimmedValue(request.getMsisdn()); + String clientCorrelator = CommonUtil.getNullOrTrimmedValue(request.getClientCorrelator()); + String reasonForRefund = CommonUtil.getNullOrTrimmedValue(request.getReasonForRefund()); + String originalServerReferenceCode = CommonUtil.getNullOrTrimmedValue(request.getOriginalServerReferenceCode()); + String onBehalfOf = CommonUtil.getNullOrTrimmedValue(metadata.getOnBehalfOf()); + String categoryCode = CommonUtil.getNullOrTrimmedValue(metadata.getPurchaseCategoryCode()); + String channel = CommonUtil.getNullOrTrimmedValue(metadata.getChannel()); + String taxAmount = CommonUtil.getNullOrTrimmedValue(metadata.getTax()); + String referenceCode = CommonUtil.getNullOrTrimmedValue(request.getReferenceCode()); + String currency = CommonUtil.getNullOrTrimmedValue(chargingInformation.getCurrency()); + String amount = CommonUtil.getNullOrTrimmedValue(String.valueOf(chargingInformation.getAmount())); + + if(request.getReceiptRequest()!=null) { + callbackData = CommonUtil.getNullOrTrimmedValue(request.getReceiptRequest().getCallbackData()); + notifyURL = CommonUtil.getNullOrTrimmedValue(request.getReceiptRequest().getNotifyURL()); + } + + String merchantIdentification = CommonUtil.getNullOrTrimmedValue(request.getMerchantIdentification()); + String description = CommonUtil.getNullOrTrimmedValue(chargingInformation.getDescription()); + String purchaseCategoryCode = CommonUtil.getNullOrTrimmedValue(metadata.getPurchaseCategoryCode()); + + try { + ValidationRule[] validationRules = { + new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY_DOUBLE_GT_ZERO, REFUND_AMOUNT, RefundAmount), + new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY_TEL_END_USER_ID, MSISDN, msisdn), + new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, CLIENTCORRELATOR, clientCorrelator), + new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, REFERENCE, originalServerReferenceCode), + new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, REASON, reasonForRefund), + new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, ON_BEHALF_OF, onBehalfOf), + new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, CATEGORY_CODE, categoryCode), + new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, CHANNEL, channel), + new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL_DOUBLE_GE_ZERO, TAX_AMOUNT, taxAmount), + new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, REFERENCE_CODE, referenceCode), + new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, CURRENCY, currency), + new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY_DOUBLE_GE_ZERO, AMOUNT, amount), + new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, CALL_BACK_DATA, callbackData), + new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, NOTIFY_URL, notifyURL), + new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, MERCHANT_IDENTIFICATION, merchantIdentification), + new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, DESCRIPTION, description), + new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, PURCHASE_CATEGORY_CODE, purchaseCategoryCode) + + }; + + Validation.checkRequestParams(validationRules); + } catch (CustomException ex) { + LOG.error("###CREDIT### Error in Validation : " + ex); + responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, ex.getErrcode(), + ex.getErrmsg(), ex.getErrvar()[0])); + responseWrapperDTO.setHttpStatus(javax.ws.rs.core.Response.Status.BAD_REQUEST); + } + return true; + } else { + responseWrapperDTO.setRequestError( + constructRequestError(SERVICEEXCEPTION, ServiceError.INVALID_INPUT_VALUE.getCode(), + ServiceError.INVALID_INPUT_VALUE.getMessage(), wrapperDTO.getMsisdn())); + responseWrapperDTO.setHttpStatus(javax.ws.rs.core.Response.Status.BAD_REQUEST); + } + return false; + } + + @Override + protected Returnable process(PatialRefundRequestWrapper extendedRequestDTO) throws Exception { + + if (responseWrapperDTO.getRequestError() != null) { + responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); + return responseWrapperDTO; + } + + RefundRequestBean requestBean = extendedRequestDTO.getRefundRequestBean(); + RefundRequest request = requestBean.getRefundRequest(); + PaymentAmountWithTax paymentAmountWithTax = request.getPaymentAmount(); + ChargingInformation chargingInformation = paymentAmountWithTax.getChargingInformation(); + ChargingMetaDataWithTax metadata = paymentAmountWithTax.getChargingMetaData(); + + String RefundAmount = CommonUtil.getNullOrTrimmedValue(request.getRefundAmount()); + String msisdn = CommonUtil.getNullOrTrimmedValue(request.getMsisdn()); + String clientCorrelator = CommonUtil.getNullOrTrimmedValue(request.getClientCorrelator()); + String reasonForRefund = CommonUtil.getNullOrTrimmedValue(request.getReasonForRefund()); + String serverTransactionReference = CommonUtil.getNullOrTrimmedValue(request.getOriginalServerReferenceCode()); + String userName = extendedRequestDTO.getUser().getUserName(); + String serviceCreditApply = ServiceName.PartialRefund.toString(); + String channel = CommonUtil.getNullOrTrimmedValue(metadata.getChannel()); + String referenceCode = CommonUtil.getNullOrTrimmedValue(String.valueOf(request.getReferenceCode())); + String endUserID = getLastMobileNumber(extendedRequestDTO.getMsisdn()); + String currency = CommonUtil.getNullOrTrimmedValue(chargingInformation.getCurrency()); + String endUserIdPath = extendedRequestDTO.getMsisdn(); + amount = Double.parseDouble(CommonUtil.getNullOrTrimmedValue(String.valueOf(chargingInformation.getAmount()))); + String callbackData = CommonUtil.getNullOrTrimmedValue(request.getReceiptRequest().getCallbackData()); + String notifyURL = CommonUtil.getNullOrTrimmedValue(request.getReceiptRequest().getNotifyURL()); + String merchantIdentification = CommonUtil.getNullOrTrimmedValue(request.getMerchantIdentification()); + + + String serverReferenceCodeFormat = String.format("%06d", getReferenceNumber()); + String serverReferenceCode = "PAYMENT_REF" + serverReferenceCodeFormat; + // Save Request Log + APITypes apiTypes = dao.getAPIType(extendedRequestDTO.getRequestType().toString().toLowerCase()); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), serviceCreditApply); + + try { + + Integer userId = extendedRequestDTO.getUser().getId(); + int serviceNameId = apiServiceCalls.getApiServiceCallId(); + + if (clientCorrelator != null) { + + String response = checkDuplicateClientCorrelator(clientCorrelator, userId, serviceNameId, endUserID, MessageProcessStatus.Success, MessageType.Response, referenceCode); + + if (response != null) { + RefundResponseBean bean = new RefundResponseBean(); + org.json.JSONObject json = new org.json.JSONObject(response); + String jasonString = json.getJSONObject("refundResponse").toString(); + ObjectMapper mapper = new ObjectMapper(); + RefundResponse res = mapper.readValue(jasonString, RefundResponse.class); + bean.setRefundResponse(res); + responseWrapperDTO.setRefundResponseBean(bean); + responseWrapperDTO.setHttpStatus(Response.Status.OK); + return responseWrapperDTO; + } + + } + + String result = checkReferenceCode(userId, serviceNameId, endUserID, MessageProcessStatus.Success, MessageType.Response, referenceCode); + + if ((result != null)) { + LOG.error("###REFUND### Already charged for this reference code"); + responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Already used reference code")); + responseWrapperDTO.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapperDTO; + } + + // check serverReferenceCode against OriginalServerReferenceCode + Double validTransaction = checkOriginalServerReferenceWithServerReference(userId, endUserID, MessageProcessStatus.Success, MessageType.Response, serverTransactionReference); + + // check account amount decimal format + Double partialRefundAmount = Double.parseDouble(RefundAmount); + BigDecimal bigDecimal = new BigDecimal(RefundAmount); + Integer decimalDigits = bigDecimal.scale(); + if (!((decimalDigits <= 2) && (decimalDigits >= 0)) || partialRefundAmount < 0) { + LOG.error("###REFUND### amount should be a whole number or two digit decimal"); + responseWrapperDTO + .setRequestError(constructRequestError(SERVICEEXCEPTION, ServiceError.INVALID_INPUT_VALUE, + "amount should be a whole or two digit decimal positive number")); + responseWrapperDTO.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapperDTO; + } + + if(currency!=null) { + // check valid account currency for endUserId + boolean isValidCurrency = currencySymbol(currency); + if (!isValidCurrency) { + LOG.error("###REFUND### currency code not as per ISO 4217"); + responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "currency code not as per ISO 4217")); + responseWrapperDTO.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapperDTO; + + } + } + + // check path param endUserId and request body endUserId + if (!(getLastMobileNumber(endUserIdPath).equals(getLastMobileNumber(msisdn)))) { + LOG.error("###REFUND### two different endUserId provided"); + responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "two different endUserId provided")); + responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); + return responseWrapperDTO; + } + + //Check channel. + if (channel != null && !containsChannel(channel)) { + LOG.error("###REFUND### Valid channel doesn't exists for the given inputs"); + responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Valid channel doesn't exists for the given inputs")); + responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); + return responseWrapperDTO; + } + + if (!isOriginalServerReferenceCode) { + LOG.error("###REFUND### no payment matching for this Refund"); + responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "no payment matching for this Refund")); + responseWrapperDTO.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapperDTO; + } + + if (paymentAmount != amount) { + LOG.error("###REFUND### Charging Information amount miss match"); + responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Charging Information amount miss match")); + responseWrapperDTO.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapperDTO; + } + + // Check for exceeded Amount + if (validTransaction == 0.0) { + LOG.error("###REFUND### exceeds refund Amount"); + responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "exceeds refund Amount")); + responseWrapperDTO.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapperDTO; + } + + ReceiptResponse receiptResponse = new ReceiptResponse(); + receiptResponse.setCallbackData(callbackData); + receiptResponse.setNotifyURL(notifyURL); + + if (partialRefundAmount <= validTransaction) { + + + ManageNumber manageNumber = numberDao.getNumber(endUserID, userName); + if (manageNumber != null) { + updateBalance(manageNumber, Double.parseDouble(RefundAmount)); + RefundResponseBean responseBean = buildJsonResponseBody(RefundAmount, clientCorrelator, msisdn, reasonForRefund, + serverTransactionReference, OperationStatus.Refunded.toString(), referenceCode, serverReferenceCode, chargingInformation, metadata,receiptResponse,merchantIdentification); + + saveResponse(extendedRequestDTO, endUserID, responseBean, apiServiceCalls, MessageProcessStatus.Success); + responseWrapperDTO.setHttpStatus(Response.Status.CREATED); + return responseWrapperDTO; + } else { + responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Number is not Registered for the Service")); + responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); + return responseWrapperDTO; + } + + } else { + LOG.error("###REFUND### Cannot Proceed Refund"); + responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Cannot Proceed Refund")); + responseWrapperDTO.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapperDTO; + + } + + + } catch (Exception ex) { + LOG.error("###REFUND### Error in processing credit service request. ", ex); + responseWrapperDTO + .setRequestError(constructRequestError(SERVICEEXCEPTION, ServiceError.SERVICE_ERROR_OCCURED, null)); + responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); + return responseWrapperDTO; + } + } + + @Override + protected void init(PatialRefundRequestWrapper extendedRequestDTO) throws Exception { + requestWrapperDTO = extendedRequestDTO; + responseWrapperDTO = new PatialRefundResponseWrapper(); + } + + private void updateBalance(ManageNumber manageNumber, double amount) throws Exception { + + double newBalance = manageNumber.getBalance() + amount; + manageNumber.setBalance(newBalance); + numberDao.saveManageNumbers(manageNumber); + } + + private RefundResponseBean buildJsonResponseBody(String amount, String clientCorrelator, String enduserID, + String reason, String serverTransactionReference, String + operationStatus, String referenceCode, String + serverReferenceCode, ChargingInformation + chargingInformation, ChargingMetaDataWithTax + chargingMetaDataWithTax, ReceiptResponse receiptResponse, + String merchantIdentification) { + + PaymentAmountWithTax paymentAmountWithTax = new PaymentAmountWithTax(); + paymentAmountWithTax.setChargingInformation(chargingInformation); + paymentAmountWithTax.setChargingMetaData(chargingMetaDataWithTax); + + RefundResponse refundResponse = new RefundResponse(); + refundResponse.setRefundAmount(Double.parseDouble(amount)); + refundResponse.setOriginalServerReferenceCode(serverTransactionReference); + refundResponse.setClientCorrelator(clientCorrelator); + refundResponse.setEndUserID(enduserID); + refundResponse.setReasonForRefund(reason); + refundResponse.setMerchantIdentification(merchantIdentification); + refundResponse.setPaymentAmount(paymentAmountWithTax); + refundResponse.setReceiptResponse(receiptResponse); + refundResponse.setReferenceCode(referenceCode); + refundResponse.setServerReferanceCode(serverReferenceCode); + refundResponse.setResourceURL(CommonUtil.getResourceUrl(requestWrapperDTO)); + refundResponse.setTransactionOperationStatus(operationStatus); + + RefundResponseBean refundResponseBean = new RefundResponseBean(); + refundResponseBean.setRefundResponse(refundResponse); + responseWrapperDTO.setRefundResponseBean(refundResponseBean); + return refundResponseBean; + + } + + public boolean containsChannel(String channelValue) { + + for (Channel channel : Channel.values()) { + if (channel.name().toLowerCase().equals(channelValue.toLowerCase())) { + return true; + } + } + + return false; + } + + // Check already existing clientcorrelator return response body + private String checkDuplicateClientCorrelator(String clientCorrelator, int userId, int serviceNameId, String tel, MessageProcessStatus status, MessageType type, String referenceCode) throws Exception { + + List list = new ArrayList<>(); + list.add(serviceNameId); + List response = loggingDAO.getMessageLogs(userId, list, "msisdn", "tel:+" + tel, null, null); + + String jsonString = null; + + for (int i = 0; i < response.size(); i++) { + + if (response != null) { + + int responseStatus = response.get(i).getStatus(); + int responseType = response.get(i).getType(); + String responseClientCorrelator; + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = response.get(i).getRequest(); + org.json.JSONObject json = new org.json.JSONObject(request); + responseClientCorrelator = null; + + if (json.getJSONObject("refundResponse").has("clientCorrelator")) { + responseClientCorrelator = json.getJSONObject("refundResponse").get("clientCorrelator").toString(); + } + + int responseUserId = response.get(i).getUserid(); + String responseTel = response.get(i).getValue(); + + // Check client correlator + if ((responseClientCorrelator != null && responseClientCorrelator.equals(clientCorrelator)) && + responseUserId == userId && responseTel.equals("tel:+" + tel)) { + jsonString = json.toString(); + break; + } + } + + } + + } + + return jsonString; + } + + //check reference code + private String checkReferenceCode(int userId, int serviceNameId, String tel, MessageProcessStatus status, MessageType type, String referenceCode) throws Exception { + + List list = new ArrayList<>(); + list.add(serviceNameId); + List response = loggingDAO.getMessageLogs(userId, list, "msisdn", "tel:+" + tel, null, null); + String jsonString = null; + + for (int i = 0; i < response.size(); i++) { + + if (response != null) { + + int responseStatus = response.get(i).getStatus(); + int responseType = response.get(i).getType(); + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = response.get(i).getRequest(); + org.json.JSONObject json = new org.json.JSONObject(request); + responseReferenceCode = json.getJSONObject("refundResponse").get("referenceCode").toString(); + + int responseUserId = response.get(i).getUserid(); + String responseTel = response.get(i).getValue(); + + // Check reference CodeDuplication + if (responseUserId == userId && responseTel.equals("tel:+" + tel) && responseReferenceCode.equals(referenceCode)) { + jsonString = responseReferenceCode; + break; + } + } + + } + + } + + return jsonString; + } + + + private double checkOriginalServerReferenceWithServerReference(int userId, String tel, MessageProcessStatus status, MessageType type, String originalServerReferenceCode) throws Exception { + + double totalAmountRefunded = 0.0; + + APITypes apiTypes = dao.getAPIType(RequestType.PAYMENT.toString()); + APIServiceCalls apiServiceCallsForMakePayment = dao.getServiceCall(apiTypes.getId(), ServiceName.ChargeUser.toString()); + List list = new ArrayList<>(); + list.add(apiServiceCallsForMakePayment.getApiServiceCallId()); + List servercodeList = loggingDAO.getMessageLogs(userId, list, "msisdn", "tel:+" + tel, null, null); + + for (int i = 0; i < servercodeList.size(); i++) { + + if (servercodeList != null) { + + int responseStatus = servercodeList.get(i).getStatus(); + int responseType = servercodeList.get(i).getType(); + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = servercodeList.get(i).getRequest(); + org.json.JSONObject json = new org.json.JSONObject(request); + String serverReferenceCode = json.get("serverReferenceCode").toString(); + + int responseUserId = servercodeList.get(i).getUserid(); + String responseTel = servercodeList.get(i).getValue(); + + if (responseUserId == userId && responseTel.equals("tel:+" + tel) && serverReferenceCode.equals(originalServerReferenceCode)) { + isOriginalServerReferenceCode = true; + paymentAmount = Double.valueOf(json.getJSONObject("paymentAmount").getJSONObject("chargingInformation").get("amount").toString()); + } + } + } + } + + if (isOriginalServerReferenceCode) { + + APITypes adiTypesForCredit = dao.getAPIType(RequestType.CREDIT.toString()); + APIServiceCalls apiServiceCalls = dao.getServiceCall(adiTypesForCredit.getId(), ServiceName.PartialRefund.toString()); + int refundId = apiServiceCalls.getApiServiceCallId(); + List PartialRefundIdList = new ArrayList<>(); + PartialRefundIdList.add(refundId); + + List originalServerReferenceCodeList = loggingDAO.getMessageLogs(userId, PartialRefundIdList, "msisdn", "tel:+" + tel, null, null); + + for (int i = 0; i < originalServerReferenceCodeList.size(); i++) { + + int responseStatus = originalServerReferenceCodeList.get(i).getStatus(); + int responseType = originalServerReferenceCodeList.get(i).getType(); + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = originalServerReferenceCodeList.get(i).getRequest(); + org.json.JSONObject json = new org.json.JSONObject(request); + String responseOriginalServerReferenceCode = json.getJSONObject("refundResponse").get("originalServerReferenceCode").toString(); + + int responseUserId = originalServerReferenceCodeList.get(i).getUserid(); + String responseTel = originalServerReferenceCodeList.get(i).getValue(); + + // Check reference CodeDuplication + if (responseUserId == userId && responseTel.equals("tel:+" + tel) && responseOriginalServerReferenceCode.equals(originalServerReferenceCode)) { + totalAmountRefunded += Double.valueOf(json.getJSONObject("refundResponse").get("refundAmount").toString()); + } + } + } + + APIServiceCalls apiServiceCall = dao.getServiceCall(apiTypes.getId(), ServiceName.RefundUser.toString()); + List refundIdList = new ArrayList<>(); + refundIdList.add(apiServiceCall.getApiServiceCallId()); + + List messageLogsForRefundList = loggingDAO.getMessageLogs(userId, refundIdList, "msisdn", "tel:+" + tel, null, null); + + for (int i = 0; i < messageLogsForRefundList.size(); i++) { + int responseStatus = messageLogsForRefundList.get(i).getStatus(); + int responseType = messageLogsForRefundList.get(i).getType(); + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + + String request = messageLogsForRefundList.get(i).getRequest(); + org.json.JSONObject json = new org.json.JSONObject(request); + String responseOriginalServerReferenceCode = json.get("originalServerReferenceCode").toString(); + int responseUserId = messageLogsForRefundList.get(i).getUserid(); + String responseTel = messageLogsForRefundList.get(i).getValue(); + + // Check reference CodeDuplication + if (responseUserId == userId && responseTel.equals("tel:+" + tel) && responseOriginalServerReferenceCode.equals(originalServerReferenceCode)) { + totalAmountRefunded += Double.valueOf(json.getJSONObject("paymentAmount").getJSONObject("chargingInformation").get("amount").toString()); + } + } + } + + } + return (paymentAmount - totalAmountRefunded); + } + + // Save Response in messageLog table + private void saveResponse(PatialRefundRequestWrapper extendedRequestDTO, + String endUserIdPath, RefundResponseBean responseBean, APIServiceCalls apiServiceCalls, MessageProcessStatus status) throws Exception { + + Gson resp = new Gson(); + JsonElement je = new JsonParser().parse(resp.toJson(responseBean)); + JsonObject asJsonObject = je.getAsJsonObject(); + String jsonInString = asJsonObject.toString(); + //setting messagelog responses + MessageLog messageLog = new MessageLog(); + messageLog = new MessageLog(); + messageLog.setRequest(jsonInString); + messageLog.setStatus(status.getValue()); + messageLog.setType(1); + messageLog.setServicenameid(apiServiceCalls.getApiServiceCallId()); + messageLog.setUserid(extendedRequestDTO.getUser().getId()); + messageLog.setReference("msisdn"); + messageLog.setValue("tel:+"+endUserIdPath); + messageLog.setMessageTimestamp(new Date()); + + loggingDAO.saveMessageLog(messageLog); + } + + + @Override + public String getApiServiceCalls() { + return ServiceName.PartialRefund.toString(); + } -public class PatialRefundRequestHandler extends AbstractRequestHandler { - - private NumberDAO numberDao; - private MessageLogHandler logHandler; - private PatialRefundRequestWrapper requestWrapperDTO; - private PatialRefundResponseWrapper responseWrapperDTO; - - final String REFUND_REQUEST = "refundRequest"; - final String MSISDN = "msisdn"; - final String AMOUNT = "amount"; - final String CLIENTCORRELATOR = "clientCorrelator"; - final String REASON = "reasonForRefund"; - final String ID = "merchantIdentification"; - final String REFERENCE = "serverTransactionReference"; - final String RECEIPT = "receiptRequest"; - final String NOTIFYURL = "notifyURL"; - final String CALLBACKDATA = "callbackData"; - - { - LOG = LogFactory.getLog(PatialRefundRequestHandler.class); - numberDao = DaoFactory.getNumberDAO(); - dao = DaoFactory.getGenaricDAO(); - logHandler = MessageLogHandler.getInstance(); - } - - @Override - protected Returnable getResponseDTO() { - return responseWrapperDTO; - } - - @Override - protected List getAddress() { - List address = new ArrayList(); - address.add(requestWrapperDTO.getMsisdn()); - return address; - } - - @Override - protected boolean validate(PatialRefundRequestWrapper wrapperDTO) throws Exception { - - RefundRequestBean requestBean = wrapperDTO.getRefundRequestBean(); - RefundRequest request = requestBean.getRefundRequest(); - - if (requestBean != null && request != null) { - - CallbackReference callRef = request.getReceiptRequest(); - - if (callRef != null) { - double amount = request.getAmount(); - String msisdn = CommonUtil.getNullOrTrimmedValue("+" + wrapperDTO.getMsisdn()); - String clientCorrelator = CommonUtil.getNullOrTrimmedValue(request.getClientCorrelator()); - String reasonForRefund = CommonUtil.getNullOrTrimmedValue(request.getReasonForRefund()); - String merchantIdentification = CommonUtil.getNullOrTrimmedValue(request.getMerchantIdentification()); - String serverTransactionReference = CommonUtil - .getNullOrTrimmedValue(request.getServerTransactionReference()); - String notifyURL = CommonUtil.getNullOrTrimmedValue(callRef.getNotifyURL()); - String callbackData = CommonUtil.getNullOrTrimmedValue(callRef.getCallbackData()); - - try { - ValidationRule[] validationRules = { - new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY_DOUBLE_GT_ZERO, "amount", - amount), - new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY_TEL_END_USER_ID, "msisdn", - msisdn), - new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "clientCorrelator", - clientCorrelator), - new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "reasonForRefund", - reasonForRefund), - new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "merchantIdentification", - merchantIdentification), - new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "serverTransactionReference", - serverTransactionReference), - new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY_URL, "notifyURL", notifyURL), - new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "callbackData", callbackData) }; - - Validation.checkRequestParams(validationRules); - } catch (CustomException ex) { - LOG.error("###CREDIT### Error in Validation : " + ex); - responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, ex.getErrcode(), - ex.getErrmsg(), wrapperDTO.getMsisdn())); - responseWrapperDTO.setHttpStatus(javax.ws.rs.core.Response.Status.BAD_REQUEST); - } - return true; - } else { - responseWrapperDTO.setRequestError( - constructRequestError(SERVICEEXCEPTION, ServiceError.INVALID_INPUT_VALUE.getCode(), - ServiceError.INVALID_INPUT_VALUE.getMessage(), wrapperDTO.getMsisdn())); - responseWrapperDTO.setHttpStatus(javax.ws.rs.core.Response.Status.BAD_REQUEST); - } - - } - return false; - } - - @Override - protected Returnable process(PatialRefundRequestWrapper extendedRequestDTO) throws Exception { - if (responseWrapperDTO.getRequestError() != null) { - return responseWrapperDTO; - } - - RefundRequestBean requestBean = extendedRequestDTO.getRefundRequestBean(); - RefundRequest request = requestBean.getRefundRequest(); - - APITypes apiType = dao.getAPIType(RequestType.CREDIT.toString().toLowerCase()); - APIServiceCalls serviceType = dao.getServiceCall(apiType.getId(), ServiceName.PatialRefund.toString()); - JSONObject obj = buildJSONObject(request); - logHandler.saveMessageLog(serviceType.getApiServiceCallId(), extendedRequestDTO.getUser().getId(), MSISDN, extendedRequestDTO.getMsisdn(), obj); - - double amount = request.getAmount(); - String msisdn = CommonUtil.getNullOrTrimmedValue(extendedRequestDTO.getMsisdn()); - String clientCorrelator = CommonUtil.getNullOrTrimmedValue(request.getClientCorrelator()); - String reasonForRefund = CommonUtil.getNullOrTrimmedValue(request.getReasonForRefund()); - String merchantIdentification = CommonUtil.getNullOrTrimmedValue(request.getMerchantIdentification()); - String serverTransactionReference = CommonUtil.getNullOrTrimmedValue(request.getServerTransactionReference()); - String notifyURL = CommonUtil.getNullOrTrimmedValue(request.getReceiptRequest().getNotifyURL()); - String callbackData = CommonUtil.getNullOrTrimmedValue(request.getReceiptRequest().getCallbackData()); - try { - ManageNumber manageNumber = numberDao.getNumber(msisdn, extendedRequestDTO.getUser().getUserName()); - if (manageNumber != null) { - updateBalance(manageNumber, amount); - buildJsonResponseBody(amount, clientCorrelator, merchantIdentification, reasonForRefund, - serverTransactionReference, callbackData, notifyURL); - responseWrapperDTO.setHttpStatus(Response.Status.OK); - return responseWrapperDTO; - } else { - responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, - ServiceError.INVALID_INPUT_VALUE, "Number is not Registered for the Service")); - responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); - return responseWrapperDTO; - } - } catch (Exception ex) { - LOG.error("###CREDIT### Error in processing credit service request. ", ex); - responseWrapperDTO - .setRequestError(constructRequestError(SERVICEEXCEPTION, ServiceError.SERVICE_ERROR_OCCURED, null)); - responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); - return responseWrapperDTO; - } - } - - @Override - protected void init(PatialRefundRequestWrapper extendedRequestDTO) throws Exception { - requestWrapperDTO = extendedRequestDTO; - responseWrapperDTO = new PatialRefundResponseWrapper(); - } - - private void updateBalance(ManageNumber manageNumber, double amount) throws Exception { - - double newBalance = manageNumber.getBalance() + amount; - manageNumber.setBalance(newBalance); - numberDao.saveManageNumbers(manageNumber); - } - - private void buildJsonResponseBody(double amount, String clientCorrelator, String merchantIdentification, - String reason, String serverTransactionReference, String callbackData, String notifyURL) { - - CallbackReference receiptResponse = new CallbackReference(); - receiptResponse.setCallbackData(callbackData); - receiptResponse.setNotifyURL(notifyURL); - receiptResponse.setResourceURL(CommonUtil.getResourceUrl(requestWrapperDTO)); - RefundResponse refundResponse = new RefundResponse(); - refundResponse.setAmount(amount); - refundResponse.setServerTransactionReference(serverTransactionReference); - refundResponse.setClientCorrelator(clientCorrelator); - refundResponse.setMerchantIdentification(merchantIdentification); - refundResponse.setReasonForRefund(reason); - refundResponse.setReceiptResponse(receiptResponse); - RefundResponseBean refundResponseBean = new RefundResponseBean(); - refundResponseBean.setRefundResponse(refundResponse); - responseWrapperDTO.setRefundResponseBean(refundResponseBean); - - } - - @SuppressWarnings("unchecked") - private JSONObject buildJSONObject(RefundRequest request){ - - JSONObject obj = new JSONObject(); - JSONObject refundRequest = new JSONObject(); - JSONObject receiptRequest = new JSONObject(); - - receiptRequest.put(NOTIFYURL, request.getReceiptRequest().getNotifyURL()); - receiptRequest.put(CALLBACKDATA, request.getReceiptRequest().getCallbackData()); - - refundRequest.put(AMOUNT, request.getAmount()); - refundRequest.put(CLIENTCORRELATOR, request.getClientCorrelator()); - refundRequest.put(REASON, request.getReasonForRefund()); - refundRequest.put(ID, request.getMerchantIdentification()); - refundRequest.put(REFERENCE, request.getServerTransactionReference()); - refundRequest.put(RECEIPT, receiptRequest); - - obj.put(REFUND_REQUEST, refundRequest); - return obj; - } + @Override + public String getJosonString(PatialRefundRequestWrapper requestDTO) { + Gson gson = new Gson(); + String jasonString = gson.toJson(requestDTO.getRefundRequestBean()); + return jasonString; + } + @Override + public String getnumber(PatialRefundRequestWrapper requestDTO) throws Exception { + return getLastMobileNumber(requestDTO.getMsisdn()); + } } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/credit/PatialRefundResponseWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/credit/PatialRefundResponseWrapper.java index db21e740..79e54917 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/credit/PatialRefundResponseWrapper.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/credit/PatialRefundResponseWrapper.java @@ -1,5 +1,6 @@ package com.wso2telco.services.dep.sandbox.servicefactory.credit; +import com.wso2telco.services.dep.sandbox.dao.model.custom.ErrorResponseDTO; import com.wso2telco.services.dep.sandbox.dao.model.custom.RefundResponseBean; import com.wso2telco.services.dep.sandbox.servicefactory.AbstractReturnWrapperDTO; @@ -9,11 +10,13 @@ public class PatialRefundResponseWrapper extends AbstractReturnWrapperDTO { @Override public Object getResponse() { - if (getRequestError() != null) { - return getRequestError(); - } - return refundResponseBean; + if (getRequestError() == null) { + return refundResponseBean; + } else { + ErrorResponseDTO response = new ErrorResponseDTO(getRequestError()); + return response; + } } public RefundResponseBean getRefundResponseBean() { diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/customerinfo/GetAttributeRequestHandler.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/customerinfo/GetAttributeRequestHandler.java index 86e3c078..85e85063 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/customerinfo/GetAttributeRequestHandler.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/customerinfo/GetAttributeRequestHandler.java @@ -6,9 +6,21 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.wso2telco.services.dep.sandbox.dao.model.custom.Customer; +import com.wso2telco.services.dep.sandbox.dao.model.custom.CustomerInfoDTO; +import com.wso2telco.services.dep.sandbox.dao.model.domain.*; +import com.wso2telco.services.dep.sandbox.servicefactory.MessageProcessStatus; +import com.wso2telco.services.dep.sandbox.servicefactory.MessageType; import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.logging.LogFactory; -import org.json.simple.JSONObject; + import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -20,9 +32,6 @@ import com.wso2telco.services.dep.sandbox.dao.DaoFactory; import com.wso2telco.services.dep.sandbox.dao.model.custom.ListCustomerInfoAttributesDTO; import com.wso2telco.services.dep.sandbox.dao.model.custom.ListCustomerInfoDTO; -import com.wso2telco.services.dep.sandbox.dao.model.domain.APIServiceCalls; -import com.wso2telco.services.dep.sandbox.dao.model.domain.APITypes; -import com.wso2telco.services.dep.sandbox.dao.model.domain.AttributeValues; import com.wso2telco.services.dep.sandbox.service.SandboxDTO; import com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler; import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; @@ -30,6 +39,9 @@ import com.wso2telco.services.dep.sandbox.util.CommonUtil; import com.wso2telco.services.dep.sandbox.util.MessageLogHandler; import com.wso2telco.services.dep.sandbox.util.ServiceName; +import org.json.JSONObject; +import org.json.JSONTokener; +import org.json.simple.parser.JSONParser; public class GetAttributeRequestHandler extends AbstractRequestHandler { @@ -39,8 +51,14 @@ public class GetAttributeRequestHandler extends private GetAttributeResponseWrapper responseWrapperDTO; private static String schemaValues = null; private MessageLogHandler logHandler; + private String requestIdentifierCode ; + static final String CUSTOMER = "customer"; + static final String REQUESTIDENTIFIER = "requestIdentifier"; + static final String MSISDN = "msisdn"; + static final String IMSI ="imsi"; + - { + { LOG = LogFactory.getLog(GetAttributeRequestHandler.class); customerInfoDao = DaoFactory.getCustomerInfoDAO(); dao = DaoFactory.getGenaricDAO(); @@ -68,6 +86,8 @@ protected List getAddress() { protected boolean validate(GetAttributeRequestWrapper wrapperDTO) throws Exception { + String duplicateRequestId = null; + String msisdn = CommonUtil .getNullOrTrimmedValue(wrapperDTO.getMsisdn()); String imsi = CommonUtil.getNullOrTrimmedValue(wrapperDTO.getImsi()); @@ -77,9 +97,11 @@ protected boolean validate(GetAttributeRequestWrapper wrapperDTO) String onBehalfOf = CommonUtil.getNullOrTrimmedValue(wrapperDTO.getOnBehalfOf()); String purchaseCategoryCode = CommonUtil.getNullOrTrimmedValue(wrapperDTO.getPurchaseCategoryCode()); String requestIdentifier = CommonUtil.getNullOrTrimmedValue(wrapperDTO.getRequestIdentifier()); - + APITypes apiTypes = dao.getAPIType(wrapperDTO.getRequestType().toString().toLowerCase()); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), ServiceName.GetAttribute.toString().toLowerCase()); + - List validationRulesList = new ArrayList<>(); + List validationRulesList = new ArrayList<>(); try { if (msisdn == null && imsi == null) { @@ -95,7 +117,6 @@ protected boolean validate(GetAttributeRequestWrapper wrapperDTO) } validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "schema", schema)); - if (msisdn != null) { validationRulesList.add(new ValidationRule( ValidationRule.VALIDATION_TYPE_OPTIONAL_TEL, "msisdn", @@ -119,7 +140,7 @@ protected boolean validate(GetAttributeRequestWrapper wrapperDTO) ValidationRule.VALIDATION_TYPE_OPTIONAL_INT_GE_ZERO, "mnc", mnc)); validationRulesList.add(new ValidationRule( - ValidationRule.VALIDATION_TYPE_MANDATORY_INT_GE_ZERO, + ValidationRule.VALIDATION_TYPE_OPTIONAL_INT_GE_ZERO, "mcc", mcc)); } @@ -128,8 +149,6 @@ protected boolean validate(GetAttributeRequestWrapper wrapperDTO) validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "purchaseCategoryCode", purchaseCategoryCode)); validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "requestIdentifier", requestIdentifier)); - - if (requestIdentifier != null && checkRequestIdentifierSize(requestIdentifier)) { validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "requestIdentifier", @@ -183,11 +202,9 @@ protected Returnable process(GetAttributeRequestWrapper extendedRequestDTO) obj.put("mcc",extendedRequestDTO.getMcc()); obj.put("mnc",extendedRequestDTO.getMnc()); obj.put("userName",extendedRequestDTO.getUser().getUserName()); - logHandler.saveMessageLog(apiServiceCalls.getApiServiceCallId(), extendedRequestDTO.getUser().getId(), "msisdn", extendedRequestDTO.getMsisdn(), obj); String msisdn = null; ObjectMapper mapper = new ObjectMapper(); - JsonNode node = null; String number = CommonUtil.getNullOrTrimmedValue(extendedRequestDTO .getMsisdn()); String imsi = CommonUtil.getNullOrTrimmedValue(extendedRequestDTO @@ -204,6 +221,16 @@ protected Returnable process(GetAttributeRequestWrapper extendedRequestDTO) msisdn = CommonUtil.extractNumberFromMsisdn(number); } + String duplicateRequestId = checkDuplicateRequestCode(extendedRequestDTO.getUser().getId(),apiServiceCalls.getApiServiceCallId(),MessageProcessStatus.Success, MessageType.Response,extendedRequestDTO.getRequestIdentifier()); + + if(duplicateRequestId != null) + { + LOG.error("###CUSTOMERINFO### Already used requestIdentifier code is entered"); + responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "An already used requestIdentifier code is entered")); + responseWrapperDTO.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapperDTO; + } List customerInfoServices = null; // check request parameter schema has the matching values @@ -251,23 +278,17 @@ protected Returnable process(GetAttributeRequestWrapper extendedRequestDTO) .getAttributeName().toString(); if (values.getValue()!=null && (Attribute.basic.toString()).equals(schemaValues)) { isNullObject = false; - node = mapper.readValue(values.getValue(), JsonNode.class); - customerInfo.setBasic(node); + customerInfo.setBasic(mapper.readValue(values.getValue().toString(), JsonNode.class)); } else if (values.getValue()!=null && (Attribute.billing.toString()).equals(schemaValues)) { isNullObject = false; - node = mapper.readValue(values.getValue(), JsonNode.class); - customerInfo.setBilling(node); + customerInfo.setBilling(mapper.readValue(values.getValue(), JsonNode.class)); } else if (values.getValue()!=null && Attribute.account.toString().equals(schemaValues)) { isNullObject = false; - node = mapper.readValue(values.getValue(), JsonNode.class); - - customerInfo.setAccount(node); + customerInfo.setAccount(mapper.readValue(values.getValue(), JsonNode.class)); } else if (values.getValue()!=null && Attribute.identification.toString().equals(schemaValues)) { isNullObject = false; - node = mapper.readValue(values.getValue(), JsonNode.class); - - customerInfo.setIdentification(node); + customerInfo.setIdentification(mapper.readValue(values.getValue(), JsonNode.class)); } } if(isNullObject){ @@ -289,12 +310,17 @@ protected Returnable process(GetAttributeRequestWrapper extendedRequestDTO) customerInfo.setPurchaseCategoryCode(CommonUtil.getNullOrTrimmedValue(extendedRequestDTO.getPurchaseCategoryCode())); customerInfo.setRequestIdentifier( CommonUtil.getNullOrTrimmedValue(extendedRequestDTO.getRequestIdentifier())); customerInfo.setResponseIdentifier("RES" + RandomStringUtils.randomAlphabetic(8)); - - ListCustomerInfoDTO customer = new ListCustomerInfoDTO(); customer.setCustomer(customerInfo); - responseWrapperDTO.setCustomer(customer); + responseWrapperDTO.setListCustomerInfoDTO(customer); responseWrapperDTO.setHttpStatus(Response.Status.OK); + if(msisdn != null) { + saveResponse(extendedRequestDTO.getMsisdn(), customer, apiServiceCalls, MessageProcessStatus.Success); + } + else + { + saveResponse(extendedRequestDTO.getImsi(), customer, apiServiceCalls, MessageProcessStatus.Success); + } return responseWrapperDTO; } @@ -318,4 +344,77 @@ private boolean checkRequestIdentifierSize(String requestIdentifier) { return false; } } + + private String checkDuplicateRequestCode(int userId, int serviceNameId, MessageProcessStatus status, MessageType type, String requestIdentityCode) throws Exception { + List serviceNameIdList = new ArrayList(); + serviceNameIdList.add(serviceNameId); + String requestCode = null; + try { + List messageLogs = loggingDAO.getMessageLogs(userId,serviceNameIdList,null,null,null,null); + for(int i=0;i { @@ -53,8 +61,12 @@ public class GetProfileRequestHandler extends AbstractRequestHandler validationRulesList = new ArrayList<>(); @@ -129,21 +143,31 @@ protected boolean validate(GetProfileRequestWrapper wrapperDTO) throws Exception validationRulesList.add(new ValidationRule( ValidationRule.VALIDATION_TYPE_OPTIONAL_INT_GE_ZERO, "mnc", mnc)); - validationRulesList.add(new ValidationRule( - ValidationRule.VALIDATION_TYPE_MANDATORY_INT_GE_ZERO, - "mcc", mcc)); + } - + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "onBehalfOf", onBehalfOf)); validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "purchaseCategoryCode", purchaseCategoryCode)); validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "requestIdentifier", requestIdentifier)); + String duplicateRequestId = checkDuplicateRequestCode(wrapperDTO.getUser().getId(),apiServiceCalls.getApiServiceCallId(),MessageProcessStatus.Success, MessageType.Response,requestIdentifier); + + if (requestIdentifier != null && checkRequestIdentifierSize(requestIdentifier)) { validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "requestIdentifier", requestIdentifier)); + if((duplicateRequestId != null)) + { + LOG.error("###CUSTOMERINFO### Already used requestIdentifier code is entered"); + responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "An already used requestIdentifier code is entered")); + responseWrapperDTO.setHttpStatus(Response.Status.BAD_REQUEST); + + } + } else { responseWrapperDTO.setRequestError(constructRequestError( SERVICEEXCEPTION, "SVC0002", "Invalid input value for message part %1", @@ -178,14 +202,13 @@ protected Returnable process(GetProfileRequestWrapper extendedRequestDTO) throws APITypes apiTypes = dao.getAPIType(extendedRequestDTO.getRequestType().toString().toLowerCase()); APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), ServiceName.GetProfile.toString().toLowerCase()); - JSONObject obj = new JSONObject(); + JSONObject obj = new JSONObject(); obj.put("msisdn",extendedRequestDTO.getMsisdn()); obj.put("imsi",extendedRequestDTO.getImsi()); obj.put("mcc",extendedRequestDTO.getMcc()); obj.put("mnc",extendedRequestDTO.getMnc()); obj.put("userName",extendedRequestDTO.getUser().getUserName()); - logHandler.saveMessageLog(apiServiceCalls.getApiServiceCallId(), extendedRequestDTO.getUser().getId(), "msisdn", extendedRequestDTO.getMsisdn(), obj); - + if (responseWrapperDTO.getRequestError() != null) { responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); return responseWrapperDTO; @@ -212,6 +235,15 @@ protected Returnable process(GetProfileRequestWrapper extendedRequestDTO) throws } else { phoneNumber = number.getNumber(); } + String duplicateRequestId = checkDuplicateRequestCode(extendedRequestDTO.getUser().getId(),apiServiceCalls.getApiServiceCallId(),MessageProcessStatus.Success, MessageType.Response,extendedRequestDTO.getRequestIdentifier()); + if(duplicateRequestId != null) + { + LOG.error("###CUSTOMERINFO### Already used requestIdentifier code is entered"); + responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "An already used requestIdentifier code is entered")); + responseWrapperDTO.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapperDTO; + } CustomerInfoDTO customerInfoDTO = customerInfoDAO.getProfileData(phoneNumber, extendedRequestDTO.getUser()); @@ -235,6 +267,9 @@ protected void init(GetProfileRequestWrapper extendedRequestDTO) throws Exceptio } private void populateResponse(ManageNumber number, CustomerInfoDTO customerInfoDTO, GetProfileRequestWrapper extendedRequestDTO) throws Exception{ + APITypes apiTypes = dao.getAPIType(extendedRequestDTO.getRequestType().toString().toLowerCase()); + String serviceCallType = ServiceName.GetProfile.toString(); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(),serviceCallType); Customer customer = new Customer(); CustomerDTOWrapper customerDTOWrapper = new CustomerDTOWrapper(); ObjectMapper mapper = new ObjectMapper(); @@ -263,6 +298,13 @@ private void populateResponse(ManageNumber number, CustomerInfoDTO customerInfoD customer.setResourceURL(CommonUtil.getResourceUrl(requestWrapperDTO)); customerDTOWrapper.setCustomer(customer); responseWrapperDTO.setCustomerDTOWrapper(customerDTOWrapper); + if(extendedRequestDTO.getMsisdn() !=null) { + saveResponse(extendedRequestDTO.getMsisdn(), customerDTOWrapper, apiServiceCalls, MessageProcessStatus.Success); + } + else + { + saveResponse(extendedRequestDTO.getImsi(), customerDTOWrapper, apiServiceCalls, MessageProcessStatus.Success); + } } @@ -279,4 +321,76 @@ private boolean checkRequestIdentifierSize(String requestIdentifier) { } } + + private void saveResponse(String endUserId, CustomerDTOWrapper customerDTOWrapper , APIServiceCalls serviceCalls, MessageProcessStatus status) throws Exception { + ObjectMapper mapper = new ObjectMapper(); + String jsonRequestString = null; + try { + jsonRequestString = mapper.writeValueAsString(customerDTOWrapper); + } catch (JsonProcessingException e) { + LOG.error("an error occurred while converting JsonNode to string"+e); + } + MessageLog messageLog = new MessageLog(); + messageLog.setRequest(jsonRequestString); + messageLog.setUserid(user.getId()); + messageLog.setStatus(status.getValue()); + messageLog.setType(MessageType.Response.getValue()); + if(requestWrapperDTO.getMsisdn() !=null) { + messageLog.setReference(MSISDN); + } + if(requestWrapperDTO.getMsisdn()==null) + { + messageLog.setReference(IMSI); + } + messageLog.setValue(endUserId); + messageLog.setServicenameid(serviceCalls.getApiServiceCallId()); + try { + loggingDAO.saveMessageLog(messageLog); + } catch (Exception e) { + LOG.error("An error occured while saving the response"+e); + throw e; + } + + } + + private String checkDuplicateRequestCode(int userId, int serviceNameId, MessageProcessStatus status, MessageType type, String requestIdentityCode) throws Exception { + List serviceNameIdList = new ArrayList(); + serviceNameIdList.add(serviceNameId); + String requestCode = null; + try { + List messageLogs = loggingDAO.getMessageLogs(userId,serviceNameIdList,null,null,null,null); + for(int i=0;i{ +public class LocationRequestHandler extends AbstractRequestHandler implements RequestResponseRequestHandleable { final static String RETRIEVED = "Retrieved"; final static String NOT_RETRIEVED="NotRetrieved"; final static String SIMPLE_DATE_FORMAT= "yyyy-MM-dd HH:mm:ss"; LocationResponseWrapperDTO responseWrapperDTO =null; LocationRequestWrapperDTO extendedRequestDTO=null; + private NumberDAO numberDAO; private LocationDAO locationDao=null; { LOG = LogFactory.getLog(LocationRequestHandler.class); locationDao= DaoFactory.getLocationDAO(); - } + numberDAO = DaoFactory.getNumberDAO(); + } @Override protected Returnable process(LocationRequestWrapperDTO extendedRequestDTO) throws Exception { - + if (responseWrapperDTO.getRequestError() != null) { + responseWrapperDTO.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapperDTO; + } User user=extendedRequestDTO.getUser(); - - //Temp status variable - Locationparam locparam = locationDao.queryLocationParam(user.getId()); - - if (locparam != null) { - - - if (locparam.getLocationRetrieveStatus().equals(RETRIEVED)) { - LOG.debug("Location retrieve status : "+ RETRIEVED); - - locationDao.saveTransaction(extendedRequestDTO.getAddress(), - Double.valueOf(extendedRequestDTO.getRequestedAccuracy()), - "Retrieved", user); - - TerminalLocationList objTerminalLocationList = new TerminalLocationList(); - - TerminalLocation objTerminalLocation = new TerminalLocation(); - objTerminalLocation.setAddress(extendedRequestDTO.getAddress()); - - TerminalLocation.CurrentLocation objCurrentLocation = new TerminalLocation.CurrentLocation(); - objCurrentLocation.setAccuracy(Double.valueOf(extendedRequestDTO.getRequestedAccuracy())); - objCurrentLocation.setAltitude(Double.parseDouble(locparam.getAltitude())); - objCurrentLocation.setLatitude(Double.parseDouble(locparam.getLatitude())); - objCurrentLocation.setLongitude(Double.parseDouble(locparam.getLongitude())); - - SimpleDateFormat dateFormat = new SimpleDateFormat(SIMPLE_DATE_FORMAT); - Date currentDate = new Date(); - objCurrentLocation.setTimestamp(dateFormat.format(currentDate)); - - objTerminalLocation.setCurrentLocation(objCurrentLocation); - objTerminalLocation.setLocationRetrievalStatus(RETRIEVED); - - objTerminalLocationList.setTerminalLocation(objTerminalLocation); - - - responseWrapperDTO.setTerminalLocationList(objTerminalLocationList); - responseWrapperDTO.setHttpStatus(Status.OK); - - } else if (locparam.getLocationRetrieveStatus().equals(NOT_RETRIEVED)) { - - LOG.debug("Location retrieve status :"+NOT_RETRIEVED); - - locationDao.saveTransaction(extendedRequestDTO.getAddress(), - Double.valueOf(extendedRequestDTO.getRequestedAccuracy()), - NOT_RETRIEVED, user); - - TerminalLocationList objTerminalLocationList = new TerminalLocationList(); - - TerminalLocation objTerminalLocation = new TerminalLocation(); - objTerminalLocation.setAddress(extendedRequestDTO.getAddress()); - objTerminalLocation.setLocationRetrievalStatus("NotRetrieved"); - - objTerminalLocationList.setTerminalLocation(objTerminalLocation); - - responseWrapperDTO.setTerminalLocationList(objTerminalLocationList); - responseWrapperDTO.setHttpStatus(Status.OK); - - } else if (locparam.getLocationRetrieveStatus().equals("Error")) { - - LOG.debug("Location retrieve status : Error"); - responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, "SVC0002", "Invalid input value for message part %1", extendedRequestDTO.getAddress())); - responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); + APITypes apiTypes = dao.getAPIType(extendedRequestDTO.getRequestType().toString().toLowerCase()); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), ServiceName.Location.toString()); + ManageNumber manageNumber; + + try { + + TerminalLocationList objTerminalLocationList = new TerminalLocationList(); + List terminalLocationArrayList = new ArrayList<>(); + List address = Arrays.asList(extendedRequestDTO.getAddress().split(",")); + + for (int i = 0; i < address.size(); i++) { + + manageNumber = numberDAO.getNumber(getLastMobileNumber(address.get(i).toString()), user.getUserName()); + + if (manageNumber != null) { + + if (manageNumber.getLocationRetrieveStatus().equals(RETRIEVED)) { + LOG.debug("Location retrieve status : " + RETRIEVED); + + TerminalLocation objTerminalLocation = new TerminalLocation(); + objTerminalLocation.setAddress(address.get(i).toString()); + + TerminalLocation.CurrentLocation objCurrentLocation = new TerminalLocation.CurrentLocation(); + objCurrentLocation.setAccuracy(Double.valueOf(extendedRequestDTO.getRequestedAccuracy())); + objCurrentLocation.setAltitude(Double.parseDouble(manageNumber.getAltitude())); + objCurrentLocation.setLatitude(Double.parseDouble(manageNumber.getLatitude())); + objCurrentLocation.setLongitude(Double.parseDouble(manageNumber.getLongitude())); + + SimpleDateFormat dateFormat = new SimpleDateFormat(SIMPLE_DATE_FORMAT); + Date currentDate = new Date(); + objCurrentLocation.setTimestamp(dateFormat.format(currentDate)); + + objTerminalLocation.setCurrentLocation(objCurrentLocation); + objTerminalLocation.setLocationRetrievalStatus(RETRIEVED); + + terminalLocationArrayList.add(objTerminalLocation); + + + } else if (manageNumber.getLocationRetrieveStatus().equals(NOT_RETRIEVED)) { + + LOG.debug("Location retrieve status :" + NOT_RETRIEVED); + + locationDao.saveTransaction(extendedRequestDTO.getAddress(), + Double.valueOf(extendedRequestDTO.getRequestedAccuracy()), + NOT_RETRIEVED, user); + + TerminalLocation objTerminalLocation = new TerminalLocation(); + objTerminalLocation.setAddress(address.get(i).toString()); + objTerminalLocation.setLocationRetrievalStatus("NotRetrieved"); + terminalLocationArrayList.add(objTerminalLocation); + responseWrapperDTO.setTerminalLocationList(objTerminalLocationList); + responseWrapperDTO.setHttpStatus(Status.OK); + + } + + if (manageNumber.getLocationRetrieveStatus().equals("Error")) { + + LOG.debug("Location retrieve status : Error"); + responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, "SVC0002", + "Invalid input value for message part %1", extendedRequestDTO.getAddress())); + responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); + return responseWrapperDTO; + } + + } } - } else { - LOG.debug("Location parameters are empty"); - responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION,"SVC0002", "Invalid input value for message part %1",extendedRequestDTO.getAddress())); - responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); - } - - ///////////// - - + objTerminalLocationList.setTerminalLocation(terminalLocationArrayList); + + responseWrapperDTO.setTerminalLocationList(objTerminalLocationList); + responseWrapperDTO.setHttpStatus(Status.OK); + saveResponse(objTerminalLocationList, extendedRequestDTO.getAddress(), apiServiceCalls, + MessageProcessStatus.Success); + + + }catch (Exception ex){ + LOG.debug("Error occurs in location retriever"); + responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, "SVC0002", "Invalid input value for message part %1", extendedRequestDTO.getAddress())); + responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); + throw ex; + } + return responseWrapperDTO; } @Override protected boolean validate(LocationRequestWrapperDTO wrapperDTO) throws Exception { - ValidateLocation validator = new ValidateLocation(); - String[] params ={wrapperDTO.getAddress(),wrapperDTO.getRequestedAccuracy()}; - validator.validate(params); - return false; + List validationRulesList = new ArrayList<>(); + List address = Arrays.asList(extendedRequestDTO.getAddress().split(",")); + + try { + + for (Object addres : address) { + validationRulesList.add( + new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY_TEL_END_USER_ID, "Address", + addres.toString())); + } + validationRulesList.add( + new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY_DOUBLE_GE_ZERO, "Accuracy",extendedRequestDTO.getRequestedAccuracy())); + ValidationRule[] validationRules = new ValidationRule[validationRulesList.size()]; + validationRules = validationRulesList.toArray(validationRules); + Validation.checkRequestParams(validationRules); + + } catch (CustomException ex) { + LOG.error("###LOCATION### Error in Validations. ", ex); + responseWrapperDTO.setRequestError( + constructRequestError(SERVICEEXCEPTION, ex.getErrcode(), ex.getErrmsg(), ex.getErrvar()[0])); + return false; + } + return true; } @@ -132,7 +187,7 @@ protected Returnable getResponseDTO() { @Override protected List getAddress() { List address =new ArrayList(); - address.add(extendedRequestDTO.getAddress()); + address = Arrays.asList(extendedRequestDTO.getAddress().split(",")); return address; } @@ -143,4 +198,56 @@ protected void init(LocationRequestWrapperDTO extendedRequestDTO) throws Excepti this.extendedRequestDTO =extendedRequestDTO; } + @Override + public String getApiServiceCalls() { + try { + return ServiceName.Location.toString(); + }catch (Exception ex){ + return null; + } + } + + @Override + public String getJosonString(LocationRequestWrapperDTO requestDTO) { + JSONObject obj = new JSONObject(); + obj.put("msisdn",requestDTO.getAddress().toString()); + return obj.toString(); + } + + @Override + public String getnumber(LocationRequestWrapperDTO requestDTO) { + return requestDTO.getAddress(); + } + + /** + * This method is use to save response. + * @param terminalLocation location object. + * @param endUserId mobile number. + * @param apiServiceCalls + * @param status + * @throws Exception + */ + private void saveResponse(TerminalLocationList terminalLocation,String endUserId, APIServiceCalls apiServiceCalls, MessageProcessStatus status) throws Exception { + + String jsonInString = null; + Gson resp = new Gson(); + JsonElement je = new JsonParser().parse(resp.toJson(terminalLocation)); + JsonObject asJsonObject = je.getAsJsonObject(); + jsonInString = asJsonObject.toString(); + + //setting messagelog responses + MessageLog messageLog = new MessageLog(); + messageLog = new MessageLog(); + messageLog.setRequest(jsonInString); + messageLog.setStatus(status.getValue()); + messageLog.setType(MessageType.Response.getValue()); + messageLog.setServicenameid(apiServiceCalls.getApiServiceCallId()); + messageLog.setUserid(extendedRequestDTO.getUser().getId()); + messageLog.setReference("msisdn"); + messageLog.setValue(getLastMobileNumber(endUserId)); + messageLog.setMessageTimestamp(new Date()); + + loggingDAO.saveMessageLog(messageLog); + } + } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/location/LocationResponseWrapperDTO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/location/LocationResponseWrapperDTO.java index ecdca6a0..cc11bd55 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/location/LocationResponseWrapperDTO.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/location/LocationResponseWrapperDTO.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.location; import com.fasterxml.jackson.annotation.JsonInclude; @@ -38,7 +53,7 @@ public Object getResponse() { @JsonInclude(value=Include.NON_NULL) class LocationResponse{ - + private RequestError requestError; private TerminalLocationList terminalLocationList ; @@ -46,7 +61,7 @@ class LocationResponse{ this.requestError=requestError; this.terminalLocationList=terminalLocationList; } - + public RequestError getRequestError() { return requestError; } @@ -59,7 +74,7 @@ public TerminalLocationList getTerminalLocationList() { public void setTerminalLocationList(TerminalLocationList terminalLocationList) { this.terminalLocationList = terminalLocationList; } - + } - + } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/location/TerminalLocation.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/location/TerminalLocation.java index 81c0e5cb..1fac7550 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/location/TerminalLocation.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/location/TerminalLocation.java @@ -1,21 +1,29 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.location; -/** - * - * @author Dialog - */ +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(value= JsonInclude.Include.NON_NULL) public class TerminalLocation { private String address=null; private CurrentLocation currentLocation; private String locationRetrievalStatus=null; - private RequestError errorInformation; + /** * @return the address @@ -59,20 +67,7 @@ public void setLocationRetrievalStatus(String locationRetrievalStatus) { this.locationRetrievalStatus = locationRetrievalStatus; } - /** - * @return the errorInformation - */ - public RequestError getErrorInformation() { - return errorInformation; - } - - /** - * @param errorInformation the errorInformation to set - */ - public void setErrorInformation(RequestError errorInformation) { - this.errorInformation = errorInformation; - } - + @JsonInclude(value= JsonInclude.Include.NON_NULL) public static class CurrentLocation { private Double accuracy=0.0; diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/location/TerminalLocationList.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/location/TerminalLocationList.java index 79634fb2..f9bc0936 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/location/TerminalLocationList.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/location/TerminalLocationList.java @@ -1,30 +1,39 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.location; -/** - * - * @author Dialog - */ +import java.util.List; + public class TerminalLocationList { - private TerminalLocation terminalLocation; + private List terminalLocation; /** * @return the terminalLocation */ - public TerminalLocation getTerminalLocation() { + public List getTerminalLocation() { return terminalLocation; } /** * @param terminalLocation the terminalLocation to set */ - public void setTerminalLocation(TerminalLocation terminalLocation) { + + public void setTerminalLocation(List terminalLocation) { this.terminalLocation = terminalLocation; } } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentListTransactionRequestHandler.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentListTransactionRequestHandler.java new file mode 100644 index 00000000..1c45a484 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentListTransactionRequestHandler.java @@ -0,0 +1,201 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.payment; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.wso2telco.core.dbutils.exception.ServiceError; +import com.wso2telco.dep.oneapivalidation.exceptions.CustomException; +import com.wso2telco.dep.oneapivalidation.util.Validation; +import com.wso2telco.dep.oneapivalidation.util.ValidationRule; +import com.wso2telco.services.dep.sandbox.dao.DaoFactory; +import com.wso2telco.services.dep.sandbox.dao.PaymentDAO; +import com.wso2telco.services.dep.sandbox.dao.model.custom.PaymentListTransactionDTO; +import com.wso2telco.services.dep.sandbox.dao.model.custom.PaymentListTransactionResponseBean; +import com.wso2telco.services.dep.sandbox.dao.model.domain.APIServiceCalls; +import com.wso2telco.services.dep.sandbox.dao.model.domain.APITypes; +import com.wso2telco.services.dep.sandbox.dao.model.domain.MessageLog; +import com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler; +import com.wso2telco.services.dep.sandbox.servicefactory.MessageType; +import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; +import com.wso2telco.services.dep.sandbox.servicefactory.MessageProcessStatus; +import com.wso2telco.services.dep.sandbox.util.*; +import org.apache.commons.logging.LogFactory; +import org.json.simple.JSONObject; + +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.List; + +public class PaymentListTransactionRequestHandler extends AbstractRequestHandler { + + private PaymentDAO paymentDAO; + private PaymentListTransactionResponseWrapper responseWrapper; + private PaymentListTransactionRequestWrapper requestWrapper; + private MessageLogHandler logHandler; + + { + LOG = LogFactory.getLog(PaymentListTransactionRequestHandler.class); + paymentDAO = DaoFactory.getPaymentDAO(); + dao = DaoFactory.getGenaricDAO(); + logHandler = MessageLogHandler.getInstance(); + + } + + @Override + protected Returnable getResponseDTO() { + return responseWrapper; + } + + @Override + protected List getAddress() { + List address = new ArrayList(); + address.add(requestWrapper.getEndUserId()); + return address; + } + + @Override + protected boolean validate(PaymentListTransactionRequestWrapper wrapperDTO) throws Exception { + + String endUserId = CommonUtil.getNullOrTrimmedValue(wrapperDTO.getEndUserId()); + + try { + ValidationRule[] validationRules = {new ValidationRule( + ValidationRule.VALIDATION_TYPE_MANDATORY_TEL_END_USER_ID, "endUserId", endUserId)}; + + Validation.checkRequestParams(validationRules); + } catch (CustomException ex) { + LOG.error("###PAYMENT### Error in Validations. ", ex); + responseWrapper.setRequestError( + constructRequestError(SERVICEEXCEPTION, ex.getErrcode(), ex.getErrmsg(), ex.getErrvar()[0])); + return false; + } + + return true; + } + + @Override + protected Returnable process(PaymentListTransactionRequestWrapper extendedRequestDTO) throws Exception { + + if (responseWrapper.getRequestError() != null) { + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + try { + + String msisdn = extendedRequestDTO.getEndUserId(); + String endUserId = getLastMobileNumber(msisdn); + Integer userId = extendedRequestDTO.getUser().getId(); + + String serviceCallPayment = ServiceName.ChargeUser.toString(); + String serviceCallRefund = ServiceName.RefundUser.toString(); + APITypes paymentApi = dao.getAPIType(RequestType.PAYMENT.toString()); + APIServiceCalls apiServiceCallPayment = dao.getServiceCall(paymentApi.getId(), serviceCallPayment); + APIServiceCalls apiServiceCallRefund = dao.getServiceCall(paymentApi.getId(), serviceCallRefund); + + + int paymentId = apiServiceCallPayment.getApiServiceCallId(); + int refundId = apiServiceCallRefund.getApiServiceCallId(); + List list = new ArrayList<>(); + list.add(paymentId); + list.add(refundId); + + JSONObject object = new JSONObject(); + object.put("endUserId", msisdn); + + + PaymentListTransactionResponseBean paymentTransaction = new PaymentListTransactionResponseBean(); + List listNodes = new ArrayList(); + List responses = loggingDAO.getMessageLogs(userId, list, "msisdn", "tel:+" + endUserId, null, null); + + String jsonString = null; + + if (responses != null && !responses.isEmpty()) { + for (int i = 0; i < responses.size(); i++) { + + int responseStatus = responses.get(i).getStatus(); + int responseType = responses.get(i).getType(); + + if (responseType == MessageType.Response.getValue() && responseStatus == MessageProcessStatus.Success.getValue()) { + String request = responses.get(i).getRequest(); + org.json.JSONObject json = new org.json.JSONObject(request); + + int responseUserId = responses.get(i).getUserid(); + String responseTel = responses.get(i).getValue(); + + if (responseUserId == userId && responseTel.equals("tel:+" + endUserId)) { + jsonString = json.toString(); + JsonParser parser = new JsonParser(); + JsonObject jsonObject = (JsonObject) parser.parse(jsonString); + JsonElement get = jsonObject.get("paymentAmount"); + JsonObject asJsonObjectPayment = get.getAsJsonObject(); + asJsonObjectPayment.remove("totalAmountCharged"); + asJsonObjectPayment.remove("totalAmountRefunded"); + asJsonObjectPayment.remove("chargingMetaData"); + jsonObject.remove("clientCorrelator"); + jsonObject.remove("notifyURL"); + jsonObject.remove("originalReferenceCode"); + jsonObject.remove("originalServerReferenceCode"); + String jsonInString = null; + jsonInString = jsonObject.toString(); + + JsonNode node = null; + ObjectMapper mapper = new ObjectMapper(); + node = mapper.readValue(jsonInString, JsonNode.class); + listNodes.add(node); + } + + } + + } + paymentTransaction.setAmountTransaction(listNodes); + } else { + LOG.error("###PAYMENT### Valid Transaction List Not Available for msisdn: " + endUserId); + responseWrapper.setHttpStatus(Response.Status.NO_CONTENT); + responseWrapper.setHttpStatus(Response.Status.OK); + return responseWrapper; + } + + paymentTransaction.setResourceURL(CommonUtil.getResourceUrl(extendedRequestDTO)); + + PaymentListTransactionDTO listTransactionDTO = new PaymentListTransactionDTO(); + + listTransactionDTO.setPaymentTransactionList(paymentTransaction); + responseWrapper.setListPaymentDTO(listTransactionDTO); + responseWrapper.setHttpStatus(Response.Status.OK); + + } catch (Exception ex) { + LOG.error("###PAYMENT### Error Occurred in PAYMENT Service. ", ex); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + responseWrapper + .setRequestError(constructRequestError(SERVICEEXCEPTION, ServiceError.SERVICE_ERROR_OCCURED, null)); + throw ex; + } + + return responseWrapper; + } + + + @Override + protected void init(PaymentListTransactionRequestWrapper extendedRequestDTO) throws Exception { + requestWrapper = extendedRequestDTO; + responseWrapper = new PaymentListTransactionResponseWrapper(); + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentListTransactionRequestWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentListTransactionRequestWrapper.java new file mode 100644 index 00000000..6a874112 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentListTransactionRequestWrapper.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.payment; + +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; + +public class PaymentListTransactionRequestWrapper extends RequestDTO { + + private String endUserId; + + public String getEndUserId() { + return endUserId; + } + + public void setEndUserId(String endUserId) { + this.endUserId = endUserId; + } + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentListTransactionResponseWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentListTransactionResponseWrapper.java new file mode 100644 index 00000000..233e152a --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentListTransactionResponseWrapper.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.payment; + +import com.wso2telco.services.dep.sandbox.dao.model.custom.ErrorResponseDTO; +import com.wso2telco.services.dep.sandbox.dao.model.custom.PaymentListTransactionDTO; +import com.wso2telco.services.dep.sandbox.servicefactory.AbstractReturnWrapperDTO; + +public class PaymentListTransactionResponseWrapper extends AbstractReturnWrapperDTO { + + private PaymentListTransactionDTO listPaymentDTO; + + @Override + public Object getResponse() { + if (getRequestError() == null) { + return getListPaymentDTO(); + } else { + ErrorResponseDTO response = new ErrorResponseDTO(getRequestError()); + return response; + } + } + + public PaymentListTransactionDTO getListPaymentDTO() { + return listPaymentDTO; + } + + public void setListPaymentDTO(PaymentListTransactionDTO listPaymentDTO) { + this.listPaymentDTO = listPaymentDTO; + } +} \ No newline at end of file diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentRefundRequestHandler0_8.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentRefundRequestHandler0_8.java new file mode 100644 index 00000000..321d4f71 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentRefundRequestHandler0_8.java @@ -0,0 +1,665 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.payment; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.ibm.icu.math.BigDecimal; +import com.wso2telco.core.dbutils.exception.ServiceError; +import com.wso2telco.dep.oneapivalidation.exceptions.CustomException; +import com.wso2telco.dep.oneapivalidation.util.Validation; +import com.wso2telco.dep.oneapivalidation.util.ValidationRule; +import com.wso2telco.services.dep.sandbox.dao.DaoFactory; +import com.wso2telco.services.dep.sandbox.dao.LoggingDAO; +import com.wso2telco.services.dep.sandbox.dao.NumberDAO; +import com.wso2telco.services.dep.sandbox.dao.PaymentDAO; +import com.wso2telco.services.dep.sandbox.dao.model.custom.*; +import com.wso2telco.services.dep.sandbox.dao.model.domain.*; +import com.wso2telco.services.dep.sandbox.servicefactory.*; +import com.wso2telco.services.dep.sandbox.servicefactory.MessageProcessStatus; +import com.wso2telco.services.dep.sandbox.servicefactory.wallet.Channel; +import com.wso2telco.services.dep.sandbox.servicefactory.wallet.TransactionStatus; +import com.wso2telco.services.dep.sandbox.util.*; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.commons.logging.LogFactory; +import org.json.JSONObject; + +import javax.annotation.Nonnull; +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.Currency; +import java.util.Date; +import java.util.List; + +public class PaymentRefundRequestHandler0_8 extends AbstractRequestHandler implements RequestResponseRequestHandleable { + + + private PaymentDAO paymentDAO; + private LoggingDAO loggingDAO; + private NumberDAO numberDAO; + private PaymentRefundRequestWrapperDTO requestWrapperDTO; + private PaymentRefundResponseWrapper responseWrapper; + private MessageLogHandler logHandler; + private String serviceCallRefund; + private boolean isContainsMetaData; + private String responseReferenceCode; + private boolean isOriginalServerReferenceCode; + private double totalAmountRefunded; + + { + LOG = LogFactory.getLog(PaymentRefundRequestHandler0_8.class); + paymentDAO = DaoFactory.getPaymentDAO(); + loggingDAO = DaoFactory.getLoggingDAO(); + numberDAO = DaoFactory.getNumberDAO(); + dao = DaoFactory.getGenaricDAO(); + logHandler = MessageLogHandler.getInstance(); + } + + @Override + protected Returnable getResponseDTO() { + return responseWrapper; + } + + @Override + protected List getAddress() { + List address = new ArrayList(); + address.add(requestWrapperDTO.getEndUserId()); + return address; + } + + @Override + protected void init(PaymentRefundRequestWrapperDTO extendedRequestDTO) throws Exception { + responseWrapper = new PaymentRefundResponseWrapper(); + requestWrapperDTO = extendedRequestDTO; + } + + protected ValidationRule getOriginalServerReferenceCodeRule( String originalServerReferenceCode){ + return new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, + "originalServerReferenceCode", originalServerReferenceCode); + + } + @Override + protected boolean validate(PaymentRefundRequestWrapperDTO wrapperDTO) throws Exception { + + PaymentRefundTransactionRequestBean requestBean = wrapperDTO.getRefundRequestBean(); + PaymentRefundTransactionRequestBean.AmountTransaction request = requestBean.getAmountTransaction(); + ChargePaymentAmount paymentAmount = request.getPaymentAmount(); + PaymentChargingInformation chargingInformation = paymentAmount.getChargingInformation(); + PaymentChargingMetaData metaData = paymentAmount.getChargingMetaData(); + + String clientCorrelator = CommonUtil.getNullOrTrimmedValue(request.getClientCorrelator()); + String endUserID = CommonUtil.getNullOrTrimmedValue(wrapperDTO.getEndUserId()); + String msisdn = CommonUtil.getNullOrTrimmedValue(request.getEndUserId()); + String amount = CommonUtil.getNullOrTrimmedValue(String.valueOf(chargingInformation.getAmount())); + String currency = CommonUtil.getNullOrTrimmedValue(chargingInformation.getCurrency().toString()); + String description = CommonUtil.getNullOrTrimmedValue(chargingInformation.getDescription()); + String onBehalfOf = CommonUtil.getNullOrTrimmedValue(metaData.getOnBehalfOf()); + String categoryCode = CommonUtil.getNullOrTrimmedValue(metaData.getPurchaseCategoryCode()); + String channel = CommonUtil.getNullOrTrimmedValue(metaData.getChannel()); + String taxAmount = CommonUtil.getNullOrTrimmedValue(metaData.getTaxAmount()); + String referenceCode = CommonUtil.getNullOrTrimmedValue(request.getReferenceCode()); + String transactionOperationStatus = CommonUtil.getNullOrTrimmedValue(request.getTransactionOperationStatus()); + String callbackData = CommonUtil.getNullOrTrimmedValue(request.getCallbackData()); + String mandateId = CommonUtil.getNullOrTrimmedValue(request.getMandateId()); + String notificationFormat = CommonUtil.getNullOrTrimmedValue(request.getNotificationFormat()); + String notifyURL = CommonUtil.getNullOrTrimmedValue(request.getNotifyURL()); + String productID = CommonUtil.getNullOrTrimmedValue(request.getProductID()); + String serviceID = CommonUtil.getNullOrTrimmedValue(request.getServiceID()); + String originalServerReferenceCode = CommonUtil.getNullOrTrimmedValue(request.getOriginalServerReferenceCode()); + + + List validationRulesList = new ArrayList<>(); + + try { + + validationRulesList.add( + new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "clientCorrelator", clientCorrelator)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY_TEL_END_USER_ID, + "endUserID", endUserID)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY_TEL_END_USER_ID, + "endUserID", msisdn)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, + "amount", amount)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, + "currency", currency)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, + "description", description)); + if (metaData != null) { + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, + "onBehalfOf", onBehalfOf)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, + "categoryCode", categoryCode)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, + "channel", channel)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL_DOUBLE_GE_ZERO, + "taxAmount", taxAmount)); + } + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, + "referenceCode", referenceCode)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, + "transactionOperationStatus", transactionOperationStatus)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, + "callbackData", callbackData)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, + "mandateId", mandateId)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, + "notificationFormat", notificationFormat)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, + "notifyURL", notifyURL)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, + "productID", productID)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, + "serviceID", serviceID)); + validationRulesList.add(getOriginalServerReferenceCodeRule (originalServerReferenceCode)); + + + ValidationRule[] validationRules = new ValidationRule[validationRulesList.size()]; + validationRules = validationRulesList.toArray(validationRules); + + Validation.checkRequestParams(validationRules); + + } catch (CustomException ex) { + LOG.error("###REFUND### Error in Validations. ", ex); + responseWrapper.setRequestError( + constructRequestError(SERVICEEXCEPTION, ex.getErrcode(), ex.getErrmsg(), ex.getErrvar()[0])); + return false; + } + return true; + } + + @Override + protected Returnable process(PaymentRefundRequestWrapperDTO extendedRequestDTO) throws Exception { + if (responseWrapper.getRequestError() != null) { + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + PaymentRefundTransactionRequestBean requestBean = extendedRequestDTO.getRefundRequestBean(); + PaymentRefundTransactionRequestBean.AmountTransaction request = requestBean.getAmountTransaction(); + ChargePaymentAmount paymentAmount = request.getPaymentAmount(); + PaymentChargingInformation chargingInformation = paymentAmount.getChargingInformation(); + PaymentChargingMetaData metadata = paymentAmount.getChargingMetaData(); + + String clientCorrelator = CommonUtil.getNullOrTrimmedValue(request.getClientCorrelator()); + String endUserIdPath = extendedRequestDTO.getEndUserId(); + String endUserIdRequest = request.getEndUserId(); + String endUserId = getLastMobileNumber(endUserIdPath); + String originalServerReferenceCode = CommonUtil + .getNullOrTrimmedValue(request.getOriginalServerReferenceCode()); + String amount = CommonUtil.getNullOrTrimmedValue(String.valueOf(chargingInformation.getAmount())); + String currency = CommonUtil.getNullOrTrimmedValue(chargingInformation.getCurrency()); + String description = CommonUtil.getNullOrTrimmedValue(chargingInformation.getDescription()); + String onBehalfOf = CommonUtil.getNullOrTrimmedValue(metadata.getOnBehalfOf()); + String categoryCode = CommonUtil.getNullOrTrimmedValue(metadata.getPurchaseCategoryCode()); + String channel = CommonUtil.getNullOrTrimmedValue(metadata.getChannel()); + String taxAmount = CommonUtil.getNullOrTrimmedValue(metadata.getTaxAmount()); + String referenceCode = CommonUtil.getNullOrTrimmedValue(request.getReferenceCode()); + String transactionOperationStatus = CommonUtil.getNullOrTrimmedValue(request.getTransactionOperationStatus()); + serviceCallRefund = ServiceName.RefundUser.toString(); + Integer userId = extendedRequestDTO.getUser().getId(); + String callbackData = CommonUtil.getNullOrTrimmedValue(request.getCallbackData()); + String mandateId = CommonUtil.getNullOrTrimmedValue(request.getMandateId()); + String notificationFormat = CommonUtil.getNullOrTrimmedValue(request.getNotificationFormat()); + String notifyURL = CommonUtil.getNullOrTrimmedValue(request.getNotifyURL()); + String productID = CommonUtil.getNullOrTrimmedValue(request.getProductID()); + String serviceID = CommonUtil.getNullOrTrimmedValue(request.getServiceID()); + + PaymentRefundTransactionResponseBean responseBean = new PaymentRefundTransactionResponseBean(); + ChargeRefundAmountResponse payAmount = new ChargeRefundAmountResponse(); + PaymentChargingInformation chargeInformation = new PaymentChargingInformation(); + PaymentChargingMetaData chargeMetaData = new PaymentChargingMetaData(); + + APITypes apiTypes = dao.getAPIType(RequestType.PAYMENT.toString()); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), serviceCallRefund); + + Gson gson = new Gson(); +// String jsonString = gson.toJson(requestBean); + + try { + + int serviceNameId = apiServiceCalls.getApiServiceCallId(); + + if (clientCorrelator != null) { + + String response = checkDuplicateClientCorrelator(clientCorrelator, userId, serviceNameId, endUserId, MessageProcessStatus.Success, MessageType.Response, referenceCode); + + if (response != null) { + + // return already send response + PaymentRefundTransactionResponseBean obj = null; + obj = gson.fromJson(response, PaymentRefundTransactionResponseBean.class); + RefundPaymentDTO dto = new RefundPaymentDTO(); + dto.setAmountTransaction(obj); + responseWrapper.setRefundPaymentDTO(dto); + responseWrapper.setHttpStatus(Response.Status.OK); + return responseWrapper; + } + } + + //check referenceCode + String result = checkReferenceCode(userId, serviceNameId, endUserId, MessageProcessStatus.Success, MessageType.Response, referenceCode); + + if((result!=null)){ + LOG.error("###PAYMENT### Already charged for this reference code"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Already charged for this reference code")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + APIServiceCalls apiServiceCallForMakePayment = dao.getServiceCall(apiTypes.getId(), ServiceName.ChargeUser.toString()); + + int serviceIdForMakePayment = apiServiceCallForMakePayment.getApiServiceCallId(); + + Double validTransaction = checkOriginalServerReferenceWithServerReference(userId, serviceIdForMakePayment, endUserId, MessageProcessStatus.Success, MessageType.Response, originalServerReferenceCode); + + // check path param endUserId and request body endUserId + if (!(getLastMobileNumber(endUserIdPath).equals(getLastMobileNumber(endUserIdRequest)))) { + LOG.error("###REFUND### two different endUserId provided"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "two different endUserId provided")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + // check valid amount format + if ((NumberUtils.isNumber(amount) != true)) { + LOG.error("###REFUND### amount should be a valid number"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "amount should be a valid number")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + // check account amount decimal format + Double chargeAmount = Double.parseDouble(amount); + BigDecimal bigDecimal = new BigDecimal(amount); + Integer decimalDigits = bigDecimal.scale(); + if (!((decimalDigits <= 2) && (decimalDigits >= 0)) || chargeAmount < 0) { + LOG.error("###REFUND### amount should be a whole number or two digit decimal"); + responseWrapper + .setRequestError(constructRequestError(SERVICEEXCEPTION, ServiceError.INVALID_INPUT_VALUE, + "amount should be a whole or two digit decimal positive number")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + // check valid account currency for endUserId + if (currency != null) { + boolean isValidCurrency = currencySymbol(currency); + if (!isValidCurrency) { + LOG.error("###REFUND### currency code not as per ISO 4217"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "currency code not as per ISO 4217")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + + } + } + + // check channel + if (channel != null && !containsChannel(channel)) { + LOG.error("###REFUND### Valid channel doesn't exists for the given inputs"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Valid channel doesn't exists for the given inputs")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + responseBean.setClientCorrelator(clientCorrelator); + responseBean.setEndUserId(endUserIdPath); + responseBean.setOriginalServerReferenceCode(originalServerReferenceCode); + responseBean.setCallbackData(callbackData); + responseBean.setMandateId(mandateId); + responseBean.setNotificationFormat(notificationFormat); + responseBean.setNotifyURL(notifyURL); + responseBean.setProductID(productID); + responseBean.setServiceID(serviceID); + + chargeInformation.setAmount(Double.parseDouble(amount)); + chargeInformation.setCurrency(currency); + chargeInformation.setDescription(description); + + if (onBehalfOf != null || categoryCode != null || channel != null) { + chargeMetaData.setPurchaseCategoryCode(categoryCode); + chargeMetaData.setChannel(channel); + chargeMetaData.setOnBehalfOf(onBehalfOf); + chargeMetaData.setTaxAmount(taxAmount); + isContainsMetaData = true; + } + + responseBean.setReferenceCode(referenceCode); + responseBean.setResourceURL(CommonUtil.getResourceUrl(extendedRequestDTO)); + + + // For inspection + Double totalAmountToRefund = chargeAmount; + Double refundAmount = chargeAmount; + totalAmountToRefund+=totalAmountRefunded; + + // Setting the total Amount Refund + payAmount.setTotalAmountRefunded(Double.parseDouble(totalAmountToRefund.toString())); + + if (!isOriginalServerReferenceCode) { + LOG.error("###REFUND### no payment matching for this Refund"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "no payment matching for this Refund")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + // Check for exceeded Amount + if (validTransaction == 0.0 || validTransaction < 0) { + LOG.error("###REFUND### exceeds refund Amount"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "exceeds refund Amount")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + if (refundAmount <= validTransaction) { + ManageNumber manageNumber = numberDAO.getNumber(endUserId, extendedRequestDTO.getUser().getUserName()); + Double updateBalance = manageNumber.getBalance() + chargeAmount; + manageNumber.setBalance(updateBalance); + + // set transaction operation status as Refunded + if (paymentDAO.saveManageNumbers(manageNumber)) { + responseBean.setTransactionOperationStatus(TransactionStatus.Refunded.toString()); + } + } else { + LOG.error("###REFUND### Cannot Proceed Refund"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Cannot Proceed Refund")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + responseWrapper.setHttpStatus(Response.Status.CREATED); + RefundPaymentDTO refundPaymentDTO = new RefundPaymentDTO(); + payAmount.setChargingInformation(chargingInformation); + payAmount.setChargingMetaData(chargeMetaData); + responseBean.setPaymentAmount(payAmount); + refundPaymentDTO.setAmountTransaction(responseBean); // RefundTransaction + responseWrapper.setRefundPaymentDTO(refundPaymentDTO); + + // Save Response in message log table + saveResponse(userId, endUserId, responseBean, apiServiceCalls, MessageProcessStatus.Success); + + } catch (Exception ex) { + LOG.error("###REFUND### Error Occured in PAYMENT Service. ", ex); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + responseWrapper + .setRequestError(constructRequestError(SERVICEEXCEPTION, ServiceError.SERVICE_ERROR_OCCURED, null)); + + } + return responseWrapper; + } + + private String checkDuplicateClientCorrelator(String clientCorrelator, int userId, int serviceNameId, String tel, MessageProcessStatus status, MessageType type, String referenceCode) throws Exception { + + List list = new ArrayList<>(); + list.add(serviceNameId); + List response = loggingDAO.getMessageLogs(userId, list, "msisdn", "tel:+" + tel, null, null); + + String jsonString = null; + + for (int i = 0; i < response.size(); i++) { + + if (response != null) { + + int responseStatus = response.get(i).getStatus(); + int responseType = response.get(i).getType(); + String responseClientCorrelator; + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = response.get(i).getRequest(); + JSONObject json = new JSONObject(request); + + responseClientCorrelator = null; + + if (json.has("clientCorrelator")) { + responseClientCorrelator = json.get("clientCorrelator").toString(); + } + + responseReferenceCode = json.get("referenceCode").toString(); + + int responseUserId = response.get(i).getUserid(); + String responseTel = response.get(i).getValue(); + + // Check client correlator + if ((responseClientCorrelator!=null && responseClientCorrelator.equals(clientCorrelator)) && + responseUserId == userId && responseTel.equals("tel:+" + tel)) { + jsonString = json.toString(); + break; + } + } + + } + } + + return jsonString; + + } + + //check reference code + private String checkReferenceCode(int userId, int serviceNameId, String tel, MessageProcessStatus status, MessageType type, String referenceCode) throws Exception { + + List list = new ArrayList<>(); + list.add(serviceNameId); + List response = loggingDAO.getMessageLogs(userId, list, "msisdn", "tel:+" + tel, null, null); + + String jsonString = null; + + for (int i = 0; i < response.size(); i++) { + + if (response != null) { + + int responseStatus = response.get(i).getStatus(); + int responseType = response.get(i).getType(); + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = response.get(i).getRequest(); + JSONObject json = new JSONObject(request); + responseReferenceCode = json.get("referenceCode").toString(); + + int responseUserId = response.get(i).getUserid(); + String responseTel = response.get(i).getValue(); + + // Check reference CodeDuplication + if (responseUserId == userId && responseTel.equals("tel:+" + tel) && responseReferenceCode.equals(referenceCode)) { + jsonString = responseReferenceCode; + break; + } + } + + } + + } + + return jsonString; + } + + private double checkOriginalServerReferenceWithServerReference(int userId, int serviceNameId, String tel, MessageProcessStatus status, MessageType type, String originalServerReferenceCode) throws Exception { + + List list = new ArrayList<>(); + list.add(serviceNameId); + List servercodeList = loggingDAO.getMessageLogs(userId, list, "msisdn", "tel:+" + tel, null, null); + + + APITypes apiTypes = dao.getAPIType(RequestType.PAYMENT.toString()); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), serviceCallRefund); + + int refundId = apiServiceCalls.getApiServiceCallId(); + List list1 = new ArrayList<>(); + list1.add(refundId); + + List originalServerReferenceCodeList = loggingDAO.getMessageLogs(userId, list1, "msisdn", "tel:+" + tel, null, null); + + Double paymentAmount = 0.0; + + + for (int i = 0; i < servercodeList.size(); i++) { + + if (servercodeList != null) { + + int responseStatus = servercodeList.get(i).getStatus(); + int responseType = servercodeList.get(i).getType(); + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = servercodeList.get(i).getRequest(); + JSONObject json = new JSONObject(request); + String serverReferenceCode = json.get("serverReferenceCode").toString(); + + int responseUserId = servercodeList.get(i).getUserid(); + String responseTel = servercodeList.get(i).getValue(); + + if (responseUserId == userId && responseTel.equals("tel:+" + tel) && serverReferenceCode.equals(originalServerReferenceCode)) { + isOriginalServerReferenceCode = true; + paymentAmount = Double.valueOf(json.getJSONObject("paymentAmount").getJSONObject("chargingInformation").get("amount").toString()); + } + } + + } + + } + + if (isOriginalServerReferenceCode) { + + for (int i = 0; i< originalServerReferenceCodeList.size(); i++) { + + if (originalServerReferenceCodeList != null) { + + int responseStatus = originalServerReferenceCodeList.get(i).getStatus(); + int responseType = originalServerReferenceCodeList.get(i).getType(); + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = originalServerReferenceCodeList.get(i).getRequest(); + JSONObject json = new JSONObject(request); + String responseOriginalServerReferenceCode = json.get("originalServerReferenceCode").toString(); + + int responseUserId = originalServerReferenceCodeList.get(i).getUserid(); + String responseTel = originalServerReferenceCodeList.get(i).getValue(); + + // Check reference CodeDuplication + if (responseUserId == userId && responseTel.equals("tel:+" + tel) && responseOriginalServerReferenceCode.equals(originalServerReferenceCode)) { + totalAmountRefunded += Double.valueOf(json.getJSONObject("paymentAmount").getJSONObject("chargingInformation").get("amount").toString()); + } + } + + } + + } + + } + + APITypes apiTypeCredit = dao.getAPIType(RequestType.CREDIT.toString()); + APIServiceCalls apiServiceCallCredit = dao.getServiceCall(apiTypeCredit.getId(), ServiceName.PartialRefund.toString()); + List refundIdList = new ArrayList<>(); + refundIdList.add(apiServiceCallCredit.getApiServiceCallId()); + + List messageLogForPartialRefund = loggingDAO.getMessageLogs(userId, refundIdList, "msisdn", "tel:+" + tel, null, null); + + if (messageLogForPartialRefund != null) { + + for (int i = 0; i< messageLogForPartialRefund.size(); i++) { + + int responseStatus = messageLogForPartialRefund.get(i).getStatus(); + int responseType = messageLogForPartialRefund.get(i).getType(); + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + + String request = messageLogForPartialRefund.get(i).getRequest(); + JSONObject json = new JSONObject(request); + String responseOriginalServerReferenceCode = json.getJSONObject("refundResponse").get("originalServerReferenceCode").toString(); + + int responseUserId = messageLogForPartialRefund.get(i).getUserid(); + String responseTel = messageLogForPartialRefund.get(i).getValue(); + + // Check reference CodeDuplication + if (responseUserId == userId && responseTel.equals("tel:+" + tel) && responseOriginalServerReferenceCode.equals(originalServerReferenceCode)) { + totalAmountRefunded += Double.valueOf(json.getJSONObject("refundResponse").get("refundAmount").toString()); + } + } + } + + } + + return (paymentAmount-totalAmountRefunded); + } + + // save Response in messageLog table + private void saveResponse(Integer userId, String endUserIdPath, PaymentRefundTransactionResponseBean responseBean, APIServiceCalls apiServiceCalls, MessageProcessStatus status) throws Exception { + + String jsonInString = null; + Gson resp = new Gson(); + + JsonElement je = new JsonParser().parse(resp.toJson(responseBean)); + JsonObject asJsonObject = je.getAsJsonObject(); + jsonInString = asJsonObject.toString(); + + //setting messagelog responses + MessageLog messageLog = new MessageLog(); + messageLog = new MessageLog(); + messageLog.setRequest(jsonInString); + messageLog.setStatus(status.getValue()); + messageLog.setType(MessageType.Response.getValue()); + messageLog.setServicenameid(apiServiceCalls.getApiServiceCallId()); + messageLog.setUserid(userId); + messageLog.setReference("msisdn"); + messageLog.setValue("tel:+"+endUserIdPath); + messageLog.setMessageTimestamp(new Date()); + + loggingDAO.saveMessageLog(messageLog); + } + + private static boolean currencySymbol(@Nonnull final String currencyCode) { + try { + final Currency currency = Currency.getInstance(currencyCode); + return true; + } catch (final IllegalArgumentException x) { + return false; + } + } + + public boolean containsChannel(String channelValue) { + + for (Channel channel : Channel.values()) { + if (channel.name().toLowerCase().equals(channelValue.toLowerCase())) { + return true; + } + } + + return false; + } + + @Override + public String getApiServiceCalls() { + return ServiceName.RefundUser.toString(); + } + + @Override + public String getJosonString(PaymentRefundRequestWrapperDTO requestDTO) { + Gson gson = new Gson(); + String jsonString = gson.toJson(requestDTO.getRefundRequestBean()); + return jsonString; } + + @Override + public String getnumber(PaymentRefundRequestWrapperDTO requestDTO) throws Exception { + return getLastMobileNumber(requestDTO.getEndUserId()); + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentRefundRequestHandler1_3.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentRefundRequestHandler1_3.java new file mode 100644 index 00000000..6e3a8773 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentRefundRequestHandler1_3.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.payment; + +import com.wso2telco.dep.oneapivalidation.util.ValidationRule; + + +public class PaymentRefundRequestHandler1_3 extends PaymentRefundRequestHandler0_8 { + + protected ValidationRule getOriginalServerReferenceCodeRule( String originalServerReferenceCode){ + return new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, + "originalServerReferenceCode", originalServerReferenceCode); + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentRefundResponseWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentRefundResponseWrapper.java new file mode 100644 index 00000000..6443ba1a --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentRefundResponseWrapper.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.payment; + +import com.wso2telco.services.dep.sandbox.dao.model.custom.ErrorResponseDTO; +import com.wso2telco.services.dep.sandbox.dao.model.custom.RefundPaymentDTO; +import com.wso2telco.services.dep.sandbox.servicefactory.AbstractReturnWrapperDTO; + +public class PaymentRefundResponseWrapper extends AbstractReturnWrapperDTO { + + private RefundPaymentDTO refundPaymentDTO; + + public RefundPaymentDTO getRefundPaymentDTO() { + return refundPaymentDTO; + } + + public void setRefundPaymentDTO(RefundPaymentDTO refundPaymentDTO) { + this.refundPaymentDTO = refundPaymentDTO; + } + + @Override + public Object getResponse() { + if (getRequestError() == null) { + return refundPaymentDTO; + } else { + ErrorResponseDTO response = new ErrorResponseDTO(getRequestError()); + return response; + + } + } + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentRequestFactory.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentRequestFactory.java index 16387749..368c04af 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentRequestFactory.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentRequestFactory.java @@ -1,12 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.payment; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; + public class PaymentRequestFactory { - // TODO: based on the json body need to implement request handle - public static RequestHandleable getInstance(final RequestDTO requestDTO) { + private static Log LOG = LogFactory.getLog(PaymentRequestFactory.class); + + public static RequestHandleable getInstance(final RequestDTO requestDTO) { + + final String MAKE_PAYMENT = "ChargePaymentRequestWrapper"; + final String REFUND_PAYMENT = "PaymentRefundRequestWrapper"; + final String LIST_PAYMENT = "transactions"; + + if(requestDTO.getHttpRequest().getPathInfo().contains("v1")){ + + if(requestDTO.toString().contains(REFUND_PAYMENT)){ + LOG.debug("LOADING REFUND PAYMENT SERVICE"); + return new PaymentRefundRequestHandler1_3(); + } else if(requestDTO.toString().contains(MAKE_PAYMENT)){ + LOG.debug("LOADING MAKE PAYMENT SERVICE"); + return new PaymentRequestHandler(); + } else if (requestDTO.getRequestPath().contains(LIST_PAYMENT)){ + LOG.debug("LOADING LIST PAYMENT SERVICE"); + return new PaymentListTransactionRequestHandler(); + } + return null; + } else if (requestDTO.getHttpRequest().getPathInfo().contains("v0_8")) { + + if (requestDTO.toString().contains(REFUND_PAYMENT)) { + LOG.debug("LOADING REFUND PAYMENT SERVICE"); + return new PaymentRefundRequestHandler0_8(); + } else if (requestDTO.toString().contains(MAKE_PAYMENT)) { + LOG.debug("LOADING MAKE PAYMENT SERVICE"); + return new PaymentRequestHandler(); + } + return null; + } + return null; + } - return null; - } } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentRequestHandler.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentRequestHandler.java new file mode 100644 index 00000000..5cca0294 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentRequestHandler.java @@ -0,0 +1,504 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.payment; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.ibm.icu.math.BigDecimal; +import com.wso2telco.core.dbutils.exception.PolicyError; +import com.wso2telco.core.dbutils.exception.ServiceError; +import com.wso2telco.dep.oneapivalidation.exceptions.CustomException; +import com.wso2telco.dep.oneapivalidation.util.Validation; +import com.wso2telco.dep.oneapivalidation.util.ValidationRule; +import com.wso2telco.services.dep.sandbox.dao.DaoFactory; +import com.wso2telco.services.dep.sandbox.dao.LoggingDAO; +import com.wso2telco.services.dep.sandbox.dao.NumberDAO; +import com.wso2telco.services.dep.sandbox.dao.PaymentDAO; +import com.wso2telco.services.dep.sandbox.dao.model.custom.*; +import com.wso2telco.services.dep.sandbox.dao.model.domain.*; +import com.wso2telco.services.dep.sandbox.servicefactory.*; +import com.wso2telco.services.dep.sandbox.servicefactory.MessageProcessStatus; +import com.wso2telco.services.dep.sandbox.servicefactory.wallet.Channel; +import com.wso2telco.services.dep.sandbox.servicefactory.wallet.TransactionStatus; +import com.wso2telco.services.dep.sandbox.util.*; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.commons.logging.LogFactory; +import org.json.JSONObject; + + +import javax.annotation.Nonnull; +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.Currency; +import java.util.Date; +import java.util.List; + +public class PaymentRequestHandler extends AbstractRequestHandler implements RequestResponseRequestHandleable { + + private PaymentDAO paymentDAO; + private LoggingDAO loggingDAO; + private NumberDAO numberDAO; + private ChargePaymentRequestWrapperDTO requestWrapperDTO; + private PaymentResponseWrapper responseWrapper; + private MessageLogHandler logHandler; + private String serviceCallPayment; + + private String responseReferenceCode; + + { + LOG = LogFactory.getLog(PaymentRequestHandler.class); + paymentDAO = DaoFactory.getPaymentDAO(); + loggingDAO = DaoFactory.getLoggingDAO(); + numberDAO = DaoFactory.getNumberDAO(); + dao = DaoFactory.getGenaricDAO(); + logHandler = MessageLogHandler.getInstance(); + } + + @Override + protected Returnable getResponseDTO() { + return responseWrapper; + } + + @Override + protected List getAddress() { + List address = new ArrayList(); + address.add(requestWrapperDTO.getEndUserId()); + return address; + } + + @Override + protected void init(ChargePaymentRequestWrapperDTO extendedRequestDTO) throws Exception { + responseWrapper = new PaymentResponseWrapper(); + requestWrapperDTO = extendedRequestDTO; + } + + @Override + protected boolean validate(ChargePaymentRequestWrapperDTO wrapperDTO) throws Exception { + PaymentRefundTransactionRequestBean requestBean = wrapperDTO.getPaymentRefundTransactionRequestBean(); + PaymentRefundTransactionRequestBean.AmountTransaction request = requestBean.getAmountTransaction(); + ChargePaymentAmount paymentAmount = request.getPaymentAmount(); + PaymentChargingInformation chargingInformation = paymentAmount.getChargingInformation(); + PaymentChargingMetaData metaData = paymentAmount.getChargingMetaData(); + + String clientCorrelator = CommonUtil.getNullOrTrimmedValue(request.getClientCorrelator()); + String endUserID = CommonUtil.getNullOrTrimmedValue(wrapperDTO.getEndUserId()); + String msisdn = CommonUtil.getNullOrTrimmedValue(request.getEndUserId()); + String amount = CommonUtil.getNullOrTrimmedValue(String.valueOf(chargingInformation.getAmount())); + String currency = CommonUtil.getNullOrTrimmedValue(chargingInformation.getCurrency().toString()); + String description = CommonUtil.getNullOrTrimmedValue(chargingInformation.getDescription()); + String onBehalfOf = CommonUtil.getNullOrTrimmedValue(metaData.getOnBehalfOf()); + String categoryCode = CommonUtil.getNullOrTrimmedValue(metaData.getPurchaseCategoryCode()); + String channel = CommonUtil.getNullOrTrimmedValue(metaData.getChannel()); + String taxAmount = CommonUtil.getNullOrTrimmedValue(metaData.getTaxAmount()); + String referenceCode = CommonUtil.getNullOrTrimmedValue(request.getReferenceCode()); + String transactionOperationStatus = CommonUtil.getNullOrTrimmedValue(request.getTransactionOperationStatus()); + + List validationRulesList = new ArrayList<>(); + + try { + + validationRulesList.add( + new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "clientCorrelator", clientCorrelator)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY_TEL_END_USER_ID, + "endUserID", endUserID)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY_TEL_END_USER_ID, + "msisdn", msisdn)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, + "amount", amount)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, + "currency", currency)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, + "description", description)); + if (metaData != null) { + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, + "onBehalfOf", onBehalfOf)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, + "categoryCode", categoryCode)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, + "channel", channel)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL_DOUBLE_GE_ZERO, + "taxAmount", taxAmount)); + } + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, + "referenceCode", referenceCode)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, + "transactionOperationStatus", transactionOperationStatus)); + + ValidationRule[] validationRules = new ValidationRule[validationRulesList.size()]; + validationRules = validationRulesList.toArray(validationRules); + + Validation.checkRequestParams(validationRules); + + } catch (CustomException ex) { + LOG.error("###PAYMENT### Error in Validations. ", ex); + responseWrapper.setRequestError( + constructRequestError(SERVICEEXCEPTION, ex.getErrcode(), ex.getErrmsg(), ex.getErrvar()[0])); + return false; + } + return true; + + } + + @Override + protected Returnable process(ChargePaymentRequestWrapperDTO extendedRequestDTO) throws Exception { + if (responseWrapper.getRequestError() != null) { + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + PaymentRefundTransactionRequestBean requestBean = extendedRequestDTO.getPaymentRefundTransactionRequestBean(); + PaymentRefundTransactionRequestBean.AmountTransaction request = requestBean.getAmountTransaction(); + ChargePaymentAmount paymentAmount = request.getPaymentAmount(); + PaymentChargingInformation chargingInformation = paymentAmount.getChargingInformation(); + PaymentChargingMetaData metadata = paymentAmount.getChargingMetaData(); + + String clientCorrelator = CommonUtil.getNullOrTrimmedValue(request.getClientCorrelator()); + String endUserIdPath = extendedRequestDTO.getEndUserId(); + String endUserIdRequest = request.getEndUserId(); + String endUserId = getLastMobileNumber(endUserIdPath); + String amount = CommonUtil.getNullOrTrimmedValue(String.valueOf(chargingInformation.getAmount())); + String currency = CommonUtil.getNullOrTrimmedValue(chargingInformation.getCurrency()); + String description = CommonUtil.getNullOrTrimmedValue(chargingInformation.getDescription()); + String onBehalfOf = CommonUtil.getNullOrTrimmedValue(metadata.getOnBehalfOf()); + String categoryCode = CommonUtil.getNullOrTrimmedValue(metadata.getPurchaseCategoryCode()); + String channel = CommonUtil.getNullOrTrimmedValue(metadata.getChannel()); + String taxAmount = CommonUtil.getNullOrTrimmedValue(metadata.getTaxAmount()); + String referenceCode = CommonUtil.getNullOrTrimmedValue(request.getReferenceCode()); + String transactionOperationStatus = CommonUtil.getNullOrTrimmedValue(request.getTransactionOperationStatus()); + serviceCallPayment = ServiceName.ChargeUser.toString(); + Integer userId = extendedRequestDTO.getUser().getId(); + + ChargePaymentResponseBean responseBean = new ChargePaymentResponseBean(); + ChargeAmountResponse payAmount = new ChargeAmountResponse(); + PaymentChargingInformation chargeInformation = new PaymentChargingInformation(); + PaymentChargingMetaData chargeMetaData = new PaymentChargingMetaData(); + + // Save Request Log + APITypes apiTypes = dao.getAPIType(extendedRequestDTO.getRequestType().toString().toLowerCase()); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), serviceCallPayment); + + Gson gson = new Gson(); +// String jsonString = gson.toJson(requestBean); + + try { + + int serviceNameId = apiServiceCalls.getApiServiceCallId(); + + if (clientCorrelator != null) { + + String response = checkDuplicateClientCorrelator(clientCorrelator, userId, serviceNameId, endUserId, MessageProcessStatus.Success, MessageType.Response, referenceCode); + + if (response != null) { + + // return already sent response + ChargePaymentResponseBean obj = null; + obj = gson.fromJson(response, ChargePaymentResponseBean.class); + ChargePaymentDTO dto = new ChargePaymentDTO(); + dto.setAmountTransaction(obj); + responseWrapper.setMakePaymentDTO(dto); + responseWrapper.setHttpStatus(Response.Status.OK); + return responseWrapper; + + } + } + + //check referenceCode + String duplicateReferenceCode = checkReferenceCode(userId, serviceNameId, endUserId, MessageProcessStatus.Success, MessageType.Response, referenceCode); + + if((duplicateReferenceCode!=null)){ + LOG.error("###PAYMENT### Already charged for this reference code"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Already charged for this reference code")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + + // check path param endUserId and request body endUserId + if (!(getLastMobileNumber(endUserIdPath).equals(getLastMobileNumber(endUserIdRequest)))) { + LOG.error("###PAYMENT### two different endUserId provided"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "two different endUserId provided")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + // check account valid amount + if (NumberUtils.isNumber(amount) != true) { + LOG.error("###PAYMENT### amount should be a valid positive number"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "amount should be positive number")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + // check account amount decimal format + Double chargeAmount = Double.parseDouble(amount); + BigDecimal bigDecimal = new BigDecimal(amount); + Integer decimalDigits = bigDecimal.scale(); + if (!((decimalDigits <= 2) && (decimalDigits >= 0)) || chargeAmount < 0) { + LOG.error("###PAYMENT### amount should be a whole number or two digit decimal"); + responseWrapper + .setRequestError(constructRequestError(SERVICEEXCEPTION, ServiceError.INVALID_INPUT_VALUE, + "amount should be a whole or two digit decimal positive number")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + // check valid account currency for endUserId + boolean isValidCurrency = currencySymbol(currency); + if (!isValidCurrency) { + LOG.error("###PAYMENT### currency code not valid accorfing to ISO 4217"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "currency code not valid accorfing to ISO 4217")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + // check channel + if (channel != null && !containsChannel(channel)) { + LOG.error("###PAYMENT### Valid channel doesn't exists for the given inputs"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Valid channel doesn't exists for the given inputs")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + responseBean.setClientCorrelator(clientCorrelator); + responseBean.setEndUserId(endUserIdPath); + + chargeInformation.setAmount(Double.parseDouble(amount)); + chargeInformation.setCurrency(currency); + chargeInformation.setDescription(description); + + Double chargeTaxAmount = 0.0; + + if(taxAmount!=null) { + // Get the tax Amount + chargeTaxAmount = Double.parseDouble(taxAmount); + } + // Setting the Total Amount Charged + Double total = chargeTaxAmount + chargeAmount; + payAmount.setTotalAmountCharged(total.toString()); + + if (onBehalfOf != null || categoryCode != null || channel != null) { + chargeMetaData.setPurchaseCategoryCode(categoryCode); + chargeMetaData.setChannel(channel); + chargeMetaData.setOnBehalfOf(onBehalfOf); + chargeMetaData.setTaxAmount(taxAmount); + } + + responseBean.setReferenceCode(referenceCode); + responseBean.setResourceURL(CommonUtil.getResourceUrl(extendedRequestDTO)); + + // Setting the serverReference Code + String serverReferenceCodeFormat = String.format("%06d", getReferenceNumber()); + String serverReferenceCode = "PAYMENT_REF" + serverReferenceCodeFormat; + responseBean.setServerReferenceCode(serverReferenceCode); + + responseBean.setTransactionOperationStatus(transactionOperationStatus); + + ManageNumber manageNumber = numberDAO.getNumber(endUserId, + extendedRequestDTO.getUser().getUserName().toString()); + Double balance = manageNumber.getBalance(); + + // transaction operation status as denied + if ((balance < chargeAmount)) { + LOG.error("###PAYMENT### Denied : Account balance insufficient to charge request "); + responseWrapper.setHttpStatus(Response.Status.FORBIDDEN); + responseWrapper + .setRequestError(constructRequestError(POLICYEXCEPTION, PolicyError.NO_VALID_SERVICES_AVAILABLE, + "Denied : Account balance insufficient to charge request")); + return responseWrapper; + } else if (balance >= chargeAmount) { + balance = balance - chargeAmount; + manageNumber.setBalance(balance); + numberDAO.saveManageNumbers(manageNumber); + responseBean.setTransactionOperationStatus(TransactionStatus.Charged.toString()); + } + + ChargePaymentDTO makePaymentDTO = new ChargePaymentDTO(); + payAmount.setChargingInformation(chargeInformation); + if (onBehalfOf != null || categoryCode != null || channel != null) { + payAmount.setChargingMetaData(chargeMetaData); + } + responseBean.setPaymentAmount(payAmount); + makePaymentDTO.setAmountTransaction(responseBean); + responseWrapper.setMakePaymentDTO(makePaymentDTO); + responseWrapper.setHttpStatus(Response.Status.CREATED); + + // Save Success Response + saveResponse(extendedRequestDTO, endUserId, responseBean, apiServiceCalls, MessageProcessStatus.Success); + + } catch (Exception ex) { + LOG.error("###PAYMENT### Error Occured in PAYMENT Service. ", ex); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + responseWrapper + .setRequestError(constructRequestError(SERVICEEXCEPTION, ServiceError.SERVICE_ERROR_OCCURED, null)); + } + return responseWrapper; + + } + + // Check already existing clientcorrelator return response body + private String checkDuplicateClientCorrelator(String clientCorrelator, int userId, int serviceNameId, String tel, MessageProcessStatus status, MessageType type, String referenceCode) throws Exception { + + List list = new ArrayList<>(); + list.add(serviceNameId); + List response = loggingDAO.getMessageLogs(userId, list, "msisdn", "tel:+" + tel, null, null); + + String jsonString = null; + + for (int i = 0; i < response.size(); i++) { + + if (response != null) { + + int responseStatus = response.get(i).getStatus(); + int responseType = response.get(i).getType(); + String responseClientCorrelator; + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = response.get(i).getRequest(); + JSONObject json = new JSONObject(request); + responseClientCorrelator = null; + + if (json.has("clientCorrelator")) { + responseClientCorrelator = json.get("clientCorrelator").toString(); + } + + responseReferenceCode = json.get("referenceCode").toString(); + + int responseUserId = response.get(i).getUserid(); + String responseTel = response.get(i).getValue(); + + // Check client correlator + if ((responseClientCorrelator!=null && responseClientCorrelator.equals(clientCorrelator)) && + responseUserId == userId && responseTel.equals("tel:+" + tel)) { + jsonString = json.toString(); + break; + } + } + + } + + } + + return jsonString; + } + + //check reference code + private String checkReferenceCode(int userId, int serviceNameId, String tel, MessageProcessStatus status, MessageType type, String referenceCode) throws Exception { + + List list = new ArrayList<>(); + list.add(serviceNameId); + List response = loggingDAO.getMessageLogs(userId, list, "msisdn", "tel:+" + tel, null, null); + + String jsonString = null; + + for (int i = 0; i < response.size(); i++) { + + if (response != null) { + + int responseStatus = response.get(i).getStatus(); + int responseType = response.get(i).getType(); + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = response.get(i).getRequest(); + JSONObject json = new JSONObject(request); + responseReferenceCode = json.get("referenceCode").toString(); + + int responseUserId = response.get(i).getUserid(); + String responseTel = response.get(i).getValue(); + + // Check reference CodeDuplication + if (responseUserId == userId && responseTel.equals("tel:+" + tel) && responseReferenceCode.equals(referenceCode)) { + jsonString = responseReferenceCode; + break; + } + } + + } + + } + + return jsonString; + } + + // Save Response in messageLog table + private void saveResponse(ChargePaymentRequestWrapperDTO extendedRequestDTO, + String endUserIdPath, ChargePaymentResponseBean responseBean, APIServiceCalls apiServiceCalls, MessageProcessStatus status) throws Exception { + + String jsonInString = null; + Gson resp = new Gson(); + + JsonElement je = new JsonParser().parse(resp.toJson(responseBean)); + JsonObject asJsonObject = je.getAsJsonObject(); + jsonInString = asJsonObject.toString(); + + //setting messagelog responses + MessageLog messageLog1 = new MessageLog(); + messageLog1 = new MessageLog(); + messageLog1.setRequest(jsonInString); + messageLog1.setStatus(status.getValue()); + messageLog1.setType(MessageType.Response.getValue()); + messageLog1.setServicenameid(apiServiceCalls.getApiServiceCallId()); + messageLog1.setUserid(extendedRequestDTO.getUser().getId()); + messageLog1.setReference("msisdn"); + messageLog1.setValue("tel:+"+endUserIdPath); + messageLog1.setMessageTimestamp(new Date()); + + loggingDAO.saveMessageLog(messageLog1); + } + + private static boolean currencySymbol(@Nonnull final String currencyCode) { + try { + final Currency currency = Currency.getInstance(currencyCode); + return true; + } catch (final IllegalArgumentException x) { + return false; + } + } + + public boolean containsChannel(String channelValue) { + for (Channel channel : Channel.values()) { + if (channel.name().toLowerCase().equals(channelValue.toLowerCase())) { + return true; + } + } + return false; + } + + @Override + public String getApiServiceCalls() { + return ServiceName.ChargeUser.toString(); + + } + + @Override + public String getJosonString(ChargePaymentRequestWrapperDTO requestDTO) { + Gson gson = new Gson(); + String jsonString = gson.toJson(requestDTO.getPaymentRefundTransactionRequestBean()); + return jsonString; + } + + @Override + public String getnumber(ChargePaymentRequestWrapperDTO requestDTO) throws Exception { + return getLastMobileNumber(requestDTO.getEndUserId()); + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentResponseWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentResponseWrapper.java new file mode 100644 index 00000000..ea6fa589 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/payment/PaymentResponseWrapper.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.payment; + +import com.wso2telco.services.dep.sandbox.dao.model.custom.ChargePaymentDTO; +import com.wso2telco.services.dep.sandbox.dao.model.custom.ErrorResponseDTO; +import com.wso2telco.services.dep.sandbox.servicefactory.AbstractReturnWrapperDTO; + +public class PaymentResponseWrapper extends AbstractReturnWrapperDTO { + + private ChargePaymentDTO makePaymentDTO; + + public ChargePaymentDTO getMakePaymentDTO() { + return makePaymentDTO; + } + + public void setMakePaymentDTO(ChargePaymentDTO makePaymentDTO) { + this.makePaymentDTO = makePaymentDTO; + } + + @Override + public Object getResponse() { + if (getRequestError() == null) { + return makePaymentDTO; + } else { + ErrorResponseDTO response = new ErrorResponseDTO(getRequestError()); + return response; + + } + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/provisioning/ListActiveProvisionedServices.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/provisioning/ListActiveProvisionedServices.java index 9bda2587..e26ce93c 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/provisioning/ListActiveProvisionedServices.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/provisioning/ListActiveProvisionedServices.java @@ -23,6 +23,13 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.wso2telco.services.dep.sandbox.dao.model.custom.*; +import com.wso2telco.services.dep.sandbox.dao.model.domain.*; +import com.wso2telco.services.dep.sandbox.servicefactory.MessageProcessStatus; +import com.wso2telco.services.dep.sandbox.servicefactory.MessageType; +import com.wso2telco.services.dep.sandbox.util.ServiceName; import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.logging.LogFactory; @@ -33,14 +40,6 @@ import com.wso2telco.dep.oneapivalidation.util.ValidationRule; import com.wso2telco.services.dep.sandbox.dao.DaoFactory; import com.wso2telco.services.dep.sandbox.dao.ProvisioningDAO; -import com.wso2telco.services.dep.sandbox.dao.model.custom.ListProvisionedDTO; -import com.wso2telco.services.dep.sandbox.dao.model.custom.ListProvisionedRequestWrapperDTO; -import com.wso2telco.services.dep.sandbox.dao.model.custom.ServiceInfoListProvisionedDTO; -import com.wso2telco.services.dep.sandbox.dao.model.custom.ServiceListProvisioned; -import com.wso2telco.services.dep.sandbox.dao.model.custom.ServiceListProvisionedDTO; -import com.wso2telco.services.dep.sandbox.dao.model.custom.ServiceMetaInfoListProvisionedDTO; -import com.wso2telco.services.dep.sandbox.dao.model.domain.ManageNumber; -import com.wso2telco.services.dep.sandbox.dao.model.domain.User; import com.wso2telco.services.dep.sandbox.exception.SandboxException; import com.wso2telco.services.dep.sandbox.exception.SandboxException.SandboxErrorType; import com.wso2telco.services.dep.sandbox.service.SandboxDTO; @@ -50,6 +49,7 @@ import com.wso2telco.services.dep.sandbox.util.ProvisioningStatusCodes; import com.wso2telco.services.dep.sandbox.util.ProvisioningUtil; import com.wso2telco.services.dep.sandbox.util.ProvisioningUtil.ProvisionRequestTypes; +import org.json.JSONObject; /** * @@ -62,6 +62,10 @@ public class ListActiveProvisionedServices extends private ProvisioningDAO provisioningDao; private ListProvisionedRequestWrapperDTO requestWrapperDTO; private ListActiveProvisionedServicesResponseWrapper responseWrapper; + private String requestIdentifierCode ; + static final String MSISDN = "msisdn"; + static final String SERVICELIST = "serviceList"; + static final String REQUESTIDENTIFIER = "requestIdentifier"; private final String NUMERIC_REGEX = "[0-9]+"; { @@ -113,17 +117,22 @@ protected boolean validate(ListProvisionedRequestWrapperDTO wrapperDTO) validationRulesList.add(new ValidationRule( ValidationRule.VALIDATION_TYPE_OPTIONAL_INT_GE_ZERO, "limit", limit)); - - - if ((mcc != null && mcc.trim().length() > 0) - || (mnc != null && mnc.trim().length() > 0)) { + + if (mcc != null) { + validationRulesList.add(new ValidationRule( + ValidationRule.VALIDATION_TYPE_OPTIONAL_INT_GE_ZERO, + "mcc", mcc)); + validationRulesList.add(new ValidationRule( + ValidationRule.VALIDATION_TYPE_MANDATORY_INT_GE_ZERO, + "mnc", mnc)); + } else if (mnc != null) { validationRulesList.add(new ValidationRule( - ValidationRule.VALIDATION_TYPE_MANDATORY_NUMBER, "mcc", - mcc)); + ValidationRule.VALIDATION_TYPE_OPTIONAL_INT_GE_ZERO, + "mnc", mnc)); validationRulesList.add(new ValidationRule( - ValidationRule.VALIDATION_TYPE_MANDATORY_NUMBER, "mnc", - mnc)); + ValidationRule.VALIDATION_TYPE_OPTIONAL_INT_GE_ZERO, + "mcc", mcc)); } else { validationRulesList.add(new ValidationRule( @@ -211,7 +220,9 @@ protected Returnable process( responseWrapper.setHttpStatus(Status.BAD_REQUEST); return responseWrapper; - } + } + APITypes apiTypes = dao.getAPIType(extendedRequestDTO.getRequestType().toString().toLowerCase()); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), ServiceName.ListService.toString().toLowerCase()); User user = extendedRequestDTO.getUser(); @@ -252,6 +263,15 @@ protected Returnable process( } else { phoneNumber = number.getNumber(); } + String duplicateRequestId = checkDuplicateRequestCode(extendedRequestDTO.getUser().getId(),apiServiceCalls.getApiServiceCallId(),MessageProcessStatus.Success, MessageType.Response,extendedRequestDTO.getRequestIdentifier()); + if(duplicateRequestId != null) + { + LOG.error("###CUSTOMERINFO### Already used requestIdentifier code is entered"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "An already used requestIdentifier code is entered")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } List provisionedServices = provisioningDao .getActiveProvisionedServices(phoneNumber, @@ -303,6 +323,7 @@ protected Returnable process( ServiceListProvisionedDTO serviceListDTO = new ServiceListProvisionedDTO(); serviceListDTO.setServiceList(serviceList); responseWrapper.setServiceListDTO(serviceListDTO); + saveResponse(extendedRequestDTO.getMsisdn(), serviceListDTO, apiServiceCalls, MessageProcessStatus.Success); } catch (Exception ex) { LOG.error("###PROVISION### Error Occured in List Provisioned Service. " @@ -346,5 +367,69 @@ private boolean isNumeric(String input) { return false; } + private void saveResponse(String endUserId, ServiceListProvisionedDTO listCustomerInfoDTO, APIServiceCalls serviceCalls, MessageProcessStatus status) throws Exception { + ObjectMapper mapper = new ObjectMapper(); + String jsonRequestString = null; + try { + jsonRequestString = mapper.writeValueAsString(listCustomerInfoDTO); + } catch (JsonProcessingException e) { + LOG.error("an error occurred while converting JsonNode to string"+e); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + } + MessageLog messageLog = new MessageLog(); + messageLog.setRequest(jsonRequestString); + messageLog.setUserid(user.getId()); + messageLog.setStatus(status.getValue()); + messageLog.setType(MessageType.Response.getValue()); + messageLog.setReference(MSISDN); + messageLog.setValue(endUserId); + messageLog.setServicenameid(serviceCalls.getApiServiceCallId()); + try { + loggingDAO.saveMessageLog(messageLog); + } catch (Exception e) { + LOG.error("An error occured while saving the response"+e); + throw e; + } + + } + + private String checkDuplicateRequestCode(int userId, int serviceNameId, MessageProcessStatus status, MessageType type, String requestIdentityCode) throws Exception { + List serviceNameIdList = new ArrayList(); + serviceNameIdList.add(serviceNameId); + String requestCode = null; + try { + List messageLogs = loggingDAO.getMessageLogs(userId,serviceNameIdList,null,null,null,null); + for(int i=0;i validationRules = new ArrayList<>(); - - if ((mcc != null && mcc.trim().length() > 0) - || (mnc != null && mnc.trim().length() > 0)) { + if (mcc != null) { + validationRules.add(new ValidationRule( + ValidationRule.VALIDATION_TYPE_OPTIONAL_INT_GE_ZERO, + "mcc", mcc)); + validationRules.add(new ValidationRule( + ValidationRule.VALIDATION_TYPE_MANDATORY_INT_GE_ZERO, + "mnc", mnc)); + } else if (mnc != null) { validationRules.add(new ValidationRule( - ValidationRule.VALIDATION_TYPE_MANDATORY_NUMBER, "mcc", - mcc)); + ValidationRule.VALIDATION_TYPE_OPTIONAL_INT_GE_ZERO, + "mnc", mnc)); validationRules.add(new ValidationRule( - ValidationRule.VALIDATION_TYPE_MANDATORY_NUMBER, "mnc", - mnc)); + ValidationRule.VALIDATION_TYPE_OPTIONAL_INT_GE_ZERO, + "mcc", mcc)); } else { validationRules.add(new ValidationRule( diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/provisioning/QueryApplicableProvisioningService.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/provisioning/QueryApplicableProvisioningService.java index 35b1dbaf..75dfb82e 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/provisioning/QueryApplicableProvisioningService.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/provisioning/QueryApplicableProvisioningService.java @@ -22,6 +22,13 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.wso2telco.services.dep.sandbox.dao.model.custom.*; +import com.wso2telco.services.dep.sandbox.dao.model.domain.*; +import com.wso2telco.services.dep.sandbox.servicefactory.MessageProcessStatus; +import com.wso2telco.services.dep.sandbox.servicefactory.MessageType; +import com.wso2telco.services.dep.sandbox.util.ServiceName; import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.logging.LogFactory; @@ -33,13 +40,6 @@ import com.wso2telco.dep.oneapivalidation.util.ValidationRule; import com.wso2telco.services.dep.sandbox.dao.DaoFactory; import com.wso2telco.services.dep.sandbox.dao.ProvisioningDAO; -import com.wso2telco.services.dep.sandbox.dao.model.custom.QueryProvisioningServicesRequestWrapper; -import com.wso2telco.services.dep.sandbox.dao.model.custom.ServiceInfo; -import com.wso2telco.services.dep.sandbox.dao.model.custom.ServiceList; -import com.wso2telco.services.dep.sandbox.dao.model.custom.ServiceListDTO; -import com.wso2telco.services.dep.sandbox.dao.model.domain.ManageNumber; -import com.wso2telco.services.dep.sandbox.dao.model.domain.ProvisionAllService; -import com.wso2telco.services.dep.sandbox.dao.model.domain.User; import com.wso2telco.services.dep.sandbox.exception.SandboxException; import com.wso2telco.services.dep.sandbox.exception.SandboxException.SandboxErrorType; import com.wso2telco.services.dep.sandbox.service.SandboxDTO; @@ -48,6 +48,7 @@ import com.wso2telco.services.dep.sandbox.util.CommonUtil; import com.wso2telco.services.dep.sandbox.util.ProvisioningUtil; import com.wso2telco.services.dep.sandbox.util.ProvisioningUtil.ProvisionRequestTypes; +import org.json.JSONObject; public class QueryApplicableProvisioningService extends AbstractRequestHandler { @@ -55,6 +56,10 @@ public class QueryApplicableProvisioningService private ProvisioningDAO provisioningDao; private QueryProvisioningServicesRequestWrapper requestWrapperDTO; private QueryApplicableProvisioningServiceResponseWrapper responseWrapper; + private String requestIdentifierCode ; + static final String MSISDN = "msisdn"; + static final String SERVICELIST = "serviceList"; + static final String REQUESTIDENTIFIER = "requestIdentifier"; private final String NUMERIC_REGEX = "[0-9]+"; @@ -103,25 +108,31 @@ protected boolean validate(QueryProvisioningServicesRequestWrapper wrapperDTO) t validationRulesList.add(new ValidationRule( ValidationRule.VALIDATION_TYPE_OPTIONAL_INT_GE_ZERO, "limit", limit)); - - - if ((mcc != null && mcc.trim().length() > 0) - || (mnc != null && mnc.trim().length() > 0)) { + + + if (mcc != null) { validationRulesList.add(new ValidationRule( - ValidationRule.VALIDATION_TYPE_MANDATORY_NUMBER, "mcc", - mcc)); + ValidationRule.VALIDATION_TYPE_OPTIONAL_INT_GE_ZERO, + "mcc", mcc)); validationRulesList.add(new ValidationRule( - ValidationRule.VALIDATION_TYPE_MANDATORY_NUMBER, "mnc", - mnc)); - } else { + ValidationRule.VALIDATION_TYPE_MANDATORY_INT_GE_ZERO, + "mnc", mnc)); + } else if (mnc != null) { + validationRulesList.add(new ValidationRule( + ValidationRule.VALIDATION_TYPE_OPTIONAL_INT_GE_ZERO, + "mnc", mnc)); + validationRulesList.add(new ValidationRule( + ValidationRule.VALIDATION_TYPE_OPTIONAL_INT_GE_ZERO, + "mcc", mcc)); + }else { validationRulesList.add(new ValidationRule( ValidationRule.VALIDATION_TYPE_OPTIONAL, "mcc", mcc)); validationRulesList.add(new ValidationRule( ValidationRule.VALIDATION_TYPE_OPTIONAL, "mnc", mnc)); - } + } if (offset != null && isNumeric(offset)) { validationRulesList.add(new ValidationRule( @@ -204,6 +215,8 @@ protected Returnable process(QueryProvisioningServicesRequestWrapper extendedReq responseWrapper.setHttpStatus(Status.BAD_REQUEST); return responseWrapper; } + APITypes apiTypes = dao.getAPIType(extendedRequestDTO.getRequestType().toString().toLowerCase()); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), ServiceName.QueryService.toString().toLowerCase()); try { User user = extendedRequestDTO.getUser(); @@ -232,6 +245,17 @@ protected Returnable process(QueryProvisioningServicesRequestWrapper extendedReq } else { phoneNumber = number.getNumber(); } + + String duplicateRequestId = checkDuplicateRequestCode(extendedRequestDTO.getUser().getId(),apiServiceCalls.getApiServiceCallId(),MessageProcessStatus.Success, MessageType.Response,extendedRequestDTO.getRequestIdentifier()); + + if(duplicateRequestId != null) + { + LOG.error("###CUSTOMERINFO### Already used requestIdentifier code is entered"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "An already used requestIdentifier code is entered")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } List applicableServices = provisioningDao.getApplicableProvisionServices(phoneNumber,user.getUserName(),offset, limit); @@ -264,6 +288,8 @@ protected Returnable process(QueryProvisioningServicesRequestWrapper extendedReq ServiceListDTO serviceListDTO = new ServiceListDTO(); serviceListDTO.setServiceList(serviceList); responseWrapper.setServiceListDTO(serviceListDTO); + saveResponse(extendedRequestDTO.getMsisdn(), serviceListDTO, apiServiceCalls, MessageProcessStatus.Success); + } catch (Exception ex) { LOG.error("###PROVISION### Error Occured in Query Applicable Service. " + ex); @@ -302,4 +328,69 @@ private boolean isNumeric(String input) { return false; } + + private void saveResponse(String endUserId, ServiceListDTO serviceListDTO, APIServiceCalls serviceCalls, MessageProcessStatus status) throws Exception { + ObjectMapper mapper = new ObjectMapper(); + String jsonRequestString = null; + try { + jsonRequestString = mapper.writeValueAsString(serviceListDTO); + } catch (JsonProcessingException e) { + LOG.error("an error occurred while converting JsonNode to string"+e); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + } + MessageLog messageLog = new MessageLog(); + messageLog.setRequest(jsonRequestString); + messageLog.setUserid(user.getId()); + messageLog.setStatus(status.getValue()); + messageLog.setType(MessageType.Response.getValue()); + messageLog.setReference(MSISDN); + messageLog.setValue(endUserId); + messageLog.setServicenameid(serviceCalls.getApiServiceCallId()); + try { + loggingDAO.saveMessageLog(messageLog); + } catch (Exception e) { + LOG.error("An error occured while saving the response"+e); + throw e; + } + + } + + private String checkDuplicateRequestCode(int userId, int serviceNameId, MessageProcessStatus status, MessageType type, String requestIdentityCode) throws Exception { + List serviceNameIdList = new ArrayList(); + serviceNameIdList.add(serviceNameId); + String requestCode = null; + try { + List messageLogs = loggingDAO.getMessageLogs(userId,serviceNameIdList,null,null,null,null); + for(int i=0;i 0) - || (mnc != null && mnc.trim().length() > 0)) { - - validationRules - .add(new ValidationRule( - ValidationRule.VALIDATION_TYPE_MANDATORY_NUMBER, - "mcc", mcc)); - validationRules - .add(new ValidationRule( - ValidationRule.VALIDATION_TYPE_MANDATORY_NUMBER, - "mnc", mnc)); + if (mcc != null) { + validationRules.add(new ValidationRule( + ValidationRule.VALIDATION_TYPE_OPTIONAL_INT_GE_ZERO, + "mcc", mcc)); + validationRules.add(new ValidationRule( + ValidationRule.VALIDATION_TYPE_MANDATORY_INT_GE_ZERO, + "mnc", mnc)); + } else if (mnc != null) { + validationRules.add(new ValidationRule( + ValidationRule.VALIDATION_TYPE_OPTIONAL_INT_GE_ZERO, + "mnc", mnc)); + validationRules.add(new ValidationRule( + ValidationRule.VALIDATION_TYPE_OPTIONAL_INT_GE_ZERO, + "mcc", mcc)); } else { validationRules.add(new ValidationRule( @@ -301,7 +304,7 @@ protected Returnable process( clientReferenceCode, notifyURL, callbackData, statusMap); // create json body from updated service object buildJsonResponseBody(deletedServiceList); - responseWrapper.setHttpStatus(Response.Status.OK); + responseWrapper.setHttpStatus(Response.Status.CREATED); return responseWrapper; } else { // check for already removed provisioned service for request @@ -396,7 +399,7 @@ private void buildJsonResponseBody(String serviceCode, .setServiceRemoveResponse(serviceRemovalResponse); responseWrapper .setRemoveProvisionedResponseBean(removeProvisionResponseBean); - responseWrapper.setHttpStatus(Response.Status.OK); + responseWrapper.setHttpStatus(Response.Status.CREATED); } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/OutboundSMSMessageResponseBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/OutboundSMSMessageResponseBean.java deleted file mode 100644 index d19c7bef..00000000 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/OutboundSMSMessageResponseBean.java +++ /dev/null @@ -1,172 +0,0 @@ -package com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging; - -import java.util.ArrayList; -import java.util.List; - -public class OutboundSMSMessageResponseBean { - - private OutboundSMSMessageRequest outboundSMSMessageRequest = null; - - public OutboundSMSMessageRequest getOutboundSMSMessageRequest() { - return outboundSMSMessageRequest; - } - - public void setOutboundSMSMessageRequest(OutboundSMSMessageRequest outboundSMSMessageRequest) { - this.outboundSMSMessageRequest = outboundSMSMessageRequest; - } - - public static class OutboundSMSMessageRequest { - - private List address = new ArrayList(); - private DeliveryInfoList deliveryInfoList = null; - private String senderAddress = null; - private OutboundSMSTextMessage outboundSMSTextMessage = null; - private String clientCorrelator = null; - private ReceiptRequest receiptRequest = null; - private String senderName = null; - private String resourceURL = null; - - public List getAddress() { - return address; - } - - public void setAddress(List address) { - this.address = address; - } - - public DeliveryInfoList getDeliveryInfoList() { - return deliveryInfoList; - } - - public void setDeliveryInfoList(DeliveryInfoList deliveryInfoList) { - this.deliveryInfoList = deliveryInfoList; - } - - public String getSenderAddress() { - return senderAddress; - } - - public void setSenderAddress(String senderAddress) { - this.senderAddress = senderAddress; - } - - public OutboundSMSTextMessage getOutboundSMSTextMessage() { - return outboundSMSTextMessage; - } - - public void setOutboundSMSTextMessage(OutboundSMSTextMessage outboundSMSTextMessage) { - this.outboundSMSTextMessage = outboundSMSTextMessage; - } - - public String getClientCorrelator() { - return clientCorrelator; - } - - public void setClientCorrelator(String clientCorrelator) { - this.clientCorrelator = clientCorrelator; - } - - public ReceiptRequest getReceiptRequest() { - return receiptRequest; - } - - public void setReceiptRequest(ReceiptRequest receiptRequest) { - this.receiptRequest = receiptRequest; - } - - public String getSenderName() { - return senderName; - } - - public void setSenderName(String senderName) { - this.senderName = senderName; - } - - public String getResourceURL() { - return resourceURL; - } - - public void setResourceURL(String resourceURL) { - this.resourceURL = resourceURL; - } - - public static class DeliveryInfoList { - - private String resourceURL = null; - private List deliveryInfo = new ArrayList(); - - public String getResourceURL() { - return resourceURL; - } - - public void setResourceURL(String resourceURL) { - this.resourceURL = resourceURL; - } - - public List getDeliveryInfo() { - return deliveryInfo; - } - - public void setDeliveryInfo(List deliveryInfo) { - this.deliveryInfo = deliveryInfo; - } - - public static class DeliveryInfo { - - private String address = null; - private String deliveryStatus = null; - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public String getDeliveryStatus() { - return deliveryStatus; - } - - public void setDeliveryStatus(String deliveryStatus) { - this.deliveryStatus = deliveryStatus; - } - } - } - - public static class OutboundSMSTextMessage { - - private String message = null; - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - } - - public static class ReceiptRequest { - - private String notifyURL = null; - private String callbackData = null; - - public String getNotifyURL() { - return notifyURL; - } - - public void setNotifyURL(String notifyURL) { - this.notifyURL = notifyURL; - } - - public String getCallbackData() { - return callbackData; - } - - public void setCallbackData(String callbackData) { - this.callbackData = callbackData; - } - } - } -} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/QuerySMSDeliveryStatusResponseWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/QuerySMSDeliveryStatusResponseWrapper.java index 0b21c3df..3570fb11 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/QuerySMSDeliveryStatusResponseWrapper.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/QuerySMSDeliveryStatusResponseWrapper.java @@ -16,6 +16,7 @@ package com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging; import com.wso2telco.dep.oneapivalidation.exceptions.RequestError; +import com.wso2telco.services.dep.sandbox.dao.model.custom.ErrorResponseDTO; import com.wso2telco.services.dep.sandbox.servicefactory.AbstractReturnWrapperDTO; public class QuerySMSDeliveryStatusResponseWrapper extends AbstractReturnWrapperDTO { @@ -33,8 +34,17 @@ public void setQuerySMSDeliveryStatusResponseBean( @Override public Object getResponse() { - // TODO Auto-generated method stub - return null; + + + if(getRequestError() == null) + { + return getQuerySMSDeliveryStatusResponseBean(); + } + else + { + ErrorResponseDTO response = new ErrorResponseDTO(getRequestError()); + return response; + } } class QuerySMSDeliveryStatusResponse { diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/QuerySMSDeliveryStatusService.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/QuerySMSDeliveryStatusService.java index 3b79c2af..b3fe8d83 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/QuerySMSDeliveryStatusService.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/QuerySMSDeliveryStatusService.java @@ -1,26 +1,37 @@ package com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging; -import java.util.ArrayList; -import java.util.List; +import java.util.*; import javax.ws.rs.core.Response.Status; +import com.wso2telco.dep.oneapivalidation.exceptions.CustomException; +import com.wso2telco.dep.oneapivalidation.util.ValidationRule; +import com.wso2telco.services.dep.sandbox.dao.model.domain.*; +import com.wso2telco.services.dep.sandbox.servicefactory.*; +import com.wso2telco.services.dep.sandbox.util.CommonUtil; +import com.wso2telco.services.dep.sandbox.util.ServiceName; import org.apache.commons.logging.LogFactory; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.wso2telco.dep.oneapivalidation.service.impl.smsmessaging.ValidateDeliveryStatus; import com.wso2telco.services.dep.sandbox.dao.DaoFactory; import com.wso2telco.services.dep.sandbox.dao.SMSMessagingDAO; import com.wso2telco.services.dep.sandbox.dao.model.custom.QuerySMSDeliveryStatusRequestWrapperDTO; -import com.wso2telco.services.dep.sandbox.dao.model.domain.SMSDeliveryStatus; -import com.wso2telco.services.dep.sandbox.dao.model.domain.SMSRequestLog; -import com.wso2telco.services.dep.sandbox.dao.model.domain.User; -import com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler; -import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; +import org.json.JSONArray; +import org.json.JSONObject; -class QuerySMSDeliveryStatusService extends AbstractRequestHandler { +class QuerySMSDeliveryStatusService extends AbstractRequestHandler implements AddressIgnorerable { + + public static final String OUTBOUND_SMS_MESSAGE_REQUEST= "outboundSMSMessageRequest"; + public static final String DELIVERY_INFO_LIST = "deliveryInfoList"; + public static final String DELIVERY_INFO = "deliveryInfo"; + public static final String ADDRESS = "address"; + public static final String DELIVERY_STATUS = "deliveryStatus"; + public static final String RESOURCE_URL="resourceURL"; + public static final String SENDER_ADDRESS ="senderAddress"; + public static final String PARAM_SENDER_ADDRESS = "sender_address"; + public static final String PARAM_TRANSACTION_ID ="transaction_id"; Gson gson = new GsonBuilder().serializeNulls().create(); QuerySMSDeliveryStatusRequestWrapperDTO extendedRequestDTO = null; QuerySMSDeliveryStatusResponseWrapper responseWrapperDTO = null; @@ -34,10 +45,26 @@ class QuerySMSDeliveryStatusService extends AbstractRequestHandler validationRulesList = new ArrayList<>(); + + try + { + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY,PARAM_SENDER_ADDRESS,shortCode)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY,PARAM_TRANSACTION_ID,transactionId)); + } + catch (CustomException ex) + { + + LOG.error("###QuerySMSDeliveryStatus### Error in Validations. ", ex); + responseWrapperDTO.setRequestError( + constructRequestError(SERVICEEXCEPTION, ex.getErrcode(), ex.getErrmsg(), ex.getErrvar()[0])); + return false; + } + + + return true; } @Override @@ -46,99 +73,166 @@ protected Returnable process(QuerySMSDeliveryStatusRequestWrapperDTO extendedReq try { User user = extendedRequestDTO.getUser(); + int userId = user.getId(); + String id = Integer.toString(userId); + SMSRequestLog previousSMSRequestDetails = null; + MessageLog previousSMSDeliveryDetails = null; + JSONObject jsonObject = null; + QuerySMSDeliveryStatusResponseBean responseBean = new QuerySMSDeliveryStatusResponseBean(); + APITypes apiType = dao.getAPIType(extendedRequestDTO.getRequestType().toString().toLowerCase()); + String serviceCall = ServiceName.QuerySMSStatus.toString(); + APIServiceCalls apiService = dao.getServiceCall(apiType.getId(), serviceCall); + String previousServiceCall = ServiceName.SendSMS.toString(); + APIServiceCalls previousApiService = dao.getServiceCall(apiType.getId(),previousServiceCall); + + ArrayList> deliveryStatusArraylist = new ArrayList(); String mtSMSTransactionIdParts[] = extendedRequestDTO.getMtSMSTransactionId().split("-"); - String previousShortCode = null; - String previousDeliveryStatus = null; + String sendersAddress = null; + String deliveryStat = null; + String resourceUrl = null; + String recieverAddress = null; + String trimmedAddress = null; String senderAddress = extendedRequestDTO.getShortCode(); if (extendedRequestDTO.getShortCode().contains("tel:+")) { - senderAddress = extendedRequestDTO.getShortCode().replace("tel:+", "").trim(); + senderAddress = getLastMobileNumber(extendedRequestDTO.getShortCode()); + } else if (extendedRequestDTO.getShortCode().contains("tel:")) { - senderAddress = extendedRequestDTO.getShortCode().replace("tel:", "").trim(); + senderAddress = getLastMobileNumber(extendedRequestDTO.getShortCode()); + + } - SMSDeliveryStatus previousSMSDeliveryDetails = smsMessagingDAO - .getPreviousSMSDeliveryDetailsByMtSMSTransactionId(extendedRequestDTO.getMtSMSTransactionId()); - if (previousSMSDeliveryDetails != null) { - previousShortCode = previousSMSDeliveryDetails.getSenderAddress(); - previousDeliveryStatus = previousSMSDeliveryDetails.getDeliveryStatus(); + int deliveryStatus = 0; + int type = 0; + int apiId = 0; + String jsonRequestString = null; + + if(mtSMSTransactionIdParts.length !=2) + { + previousSMSDeliveryDetails = smsMessagingDAO.getPrevSMSDeliveryDataByTransId(Integer.valueOf(mtSMSTransactionIdParts[0])); + } + else if (mtSMSTransactionIdParts.length ==2) + { + previousSMSDeliveryDetails = smsMessagingDAO.getPrevSMSDeliveryDataByTransId(Integer.valueOf(mtSMSTransactionIdParts[1])); } - if (mtSMSTransactionIdParts.length != 2) { + if(previousSMSDeliveryDetails != null) + { + deliveryStatus = previousSMSDeliveryDetails.getStatus(); + type = previousSMSDeliveryDetails.getType(); + apiId = previousSMSDeliveryDetails.getServicenameid(); - responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, "SVC0002", - "Invalid input value for message part %1", extendedRequestDTO.getMtSMSTransactionId())); - responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); - } else { + int messageLogId = previousSMSDeliveryDetails.getId(); - SMSRequestLog previousSMSRequestDetails = smsMessagingDAO - .getPreviousSMSRequestDetailsBySMSId(Integer.parseInt(mtSMSTransactionIdParts[1])); + String transactionId[] =extendedRequestDTO.getMtSMSTransactionId().split("-"); + String newTransactionId = null; + if(transactionId.length != 2) + { + newTransactionId = transactionId[0]; + } + if(transactionId.length == 2) + { + newTransactionId = transactionId[1]; + } - if (previousSMSRequestDetails == null) { + if(deliveryStatus == MessageProcessStatus.Success.getValue() && type == MessageType.Response.getValue() && apiId == previousApiService.getApiServiceCallId() && messageLogId== Integer.valueOf(newTransactionId)) + { - responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, "SVC0002", - "Invalid input value for message part %1", extendedRequestDTO.getMtSMSTransactionId())); - responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); - } else if (!dao.isWhiteListedSenderAddress(user.getId(), senderAddress)) { + jsonRequestString = previousSMSDeliveryDetails.getRequest(); + jsonObject = new JSONObject(jsonRequestString); + JSONObject jsonChildObj = (JSONObject) jsonObject.getJSONObject(OUTBOUND_SMS_MESSAGE_REQUEST); + JSONObject jsoninnerChild = (JSONObject) jsonChildObj.getJSONObject(DELIVERY_INFO_LIST); - responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, "SVC0001", - "A service error occurred. Error code is %1", - extendedRequestDTO.getShortCode() + " Not Provisioned")); - responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); - } else if (previousSMSDeliveryDetails == null) { + String address = null; + String status = null; - responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, "SVC0002", - "Invalid input value for message part %1", extendedRequestDTO.getMtSMSTransactionId())); - responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); - } else if (!extendedRequestDTO.getShortCode().equals(previousShortCode)) { + JSONArray deliveryListArray = jsoninnerChild.getJSONArray(DELIVERY_INFO); + String arrayList = deliveryListArray.toString(); + for (int i = 0; i < deliveryListArray.length(); i++) { + HashMap delivaryStatusHashmap = new HashMap<>(); + JSONObject jsonArrayList = deliveryListArray.getJSONObject(i); + address = jsonArrayList.optString(ADDRESS); + status = jsonArrayList.optString(DELIVERY_STATUS); + delivaryStatusHashmap.put(ADDRESS, address); + delivaryStatusHashmap.put(DELIVERY_STATUS, status); + deliveryStatusArraylist.add(delivaryStatusHashmap); - responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, "SVC0004", - "No valid addresses provided in message part %1", extendedRequestDTO.getShortCode())); - responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); - } else { + } - boolean queryDeliveryStatusTransactionStatus = smsMessagingDAO.saveQueryDeliveryStatusTransaction( - extendedRequestDTO.getShortCode(), null, null, null, null, null, null, 0, "success", 5, - null, null, user, extendedRequestDTO.getMtSMSTransactionId()); + deliveryStat = status; + recieverAddress = address; + resourceUrl = jsonChildObj.getString(RESOURCE_URL); + sendersAddress = jsonChildObj.getString(SENDER_ADDRESS); - if (!queryDeliveryStatusTransactionStatus) { + trimmedAddress = getLastMobileNumber(sendersAddress); - responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, "SVC0001", - "A service error occurred. Error code is %1", "Access failure for API")); - responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); - } else { + } - String shortCodes[] = previousSMSRequestDetails.getAddresses().replace("[", "").replace("]", "") - .split(","); - QuerySMSDeliveryStatusResponseBean responseBean = new QuerySMSDeliveryStatusResponseBean(); + } - QuerySMSDeliveryStatusResponseBean.DeliveryInfoList responseDeliveryInfoList = new QuerySMSDeliveryStatusResponseBean.DeliveryInfoList(); - List deliveryInforArrayList = new ArrayList(); + if (previousSMSDeliveryDetails == null) { - for (int i = 0; i < shortCodes.length; i++) { + responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, "SVC0002", + "Invalid input value for message part %1", extendedRequestDTO.getMtSMSTransactionId())); + responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); + } else if (!dao.isWhiteListedSenderAddress(user.getId(), senderAddress)) { - QuerySMSDeliveryStatusResponseBean.DeliveryInfoList.DeliveryInfo responseDeliveryInfo = new QuerySMSDeliveryStatusResponseBean.DeliveryInfoList.DeliveryInfo(); + responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, "SVC0001", + "A service error occurred. Error code is %1", + extendedRequestDTO.getShortCode() + " Not Provisioned")); + responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); + } else if (!senderAddress.equals(trimmedAddress)) { - responseDeliveryInfo.setAddress(shortCodes[i]); - responseDeliveryInfo.setDeliveryStatus(previousDeliveryStatus); + responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, "SVC0004", + "No valid addresses provided in message part %1", extendedRequestDTO.getShortCode())); + responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); + } else { - deliveryInforArrayList.add(responseDeliveryInfo); - } - responseDeliveryInfoList.setDeliveryInfo(deliveryInforArrayList); - responseDeliveryInfoList - .setResourceURL(getresourceURL(extendedRequestDTO.getMtSMSTransactionId()).toString()); - responseBean.setDeliveryInfoList(responseDeliveryInfoList); + String shortCodes[] = recieverAddress.replace("[", "").replace("]", "") + .split(","); + String deliveryStatusArray[] = deliveryStat.split(","); + + QuerySMSDeliveryStatusResponseBean.DeliveryInfoList responseDeliveryInfoList = new QuerySMSDeliveryStatusResponseBean.DeliveryInfoList(); + + List deliveryInforArrayList = new ArrayList(); + + + + for(int i=0; i getAddress() { - // TODO Auto-generated method stub return null; } @@ -187,4 +280,22 @@ private StringBuilder getresourceURL(final String mtSMSTransactionId) { return resourceURLBuilder; } + + private int saveResponse(String endUserIdPath, QuerySMSDeliveryStatusResponseBean responseBean, APIServiceCalls + apiServiceCalls, MessageProcessStatus status) throws Exception { + Gson gson = new Gson(); + String jsonString = gson.toJson(responseBean); + MessageLog messageLog =new MessageLog(); + messageLog.setRequest(jsonString); + messageLog.setServicenameid(apiServiceCalls.getApiServiceCallId()); + messageLog.setUserid(extendedRequestDTO.getUser().getId()); + messageLog.setType(MessageType.Response.getValue()); + messageLog.setValue(endUserIdPath); + messageLog.setReference("shortcode"); + messageLog.setMessageTimestamp(new Date()); + messageLog.setStatus(status.getValue()); + int i = loggingDAO.saveMessageLog(messageLog); + return i; + + } } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/RetrieveSMSMessagesService.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/RetrieveSMSMessagesService.java deleted file mode 100644 index 9408f367..00000000 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/RetrieveSMSMessagesService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging; - -import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; -import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; -import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; - -public class RetrieveSMSMessagesService implements RequestHandleable{ - - @Override - public Returnable execute(RequestDTO requestDTO) throws Exception { - // TODO Auto-generated method stub - return null; - } -} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SMSParameterConfigRequestBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SMSParameterConfigRequestBean.java new file mode 100644 index 00000000..fccd6ea1 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SMSParameterConfigRequestBean.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging; + +public class SMSParameterConfigRequestBean { + + + private String deliveryStatus; + private String maxNotifications; + private String notificationDelay; + + + public String getDeliveryStatus() { + return deliveryStatus; + } + + public void setDeliveryStatus(String deliveryStatus) { + this.deliveryStatus = deliveryStatus; + } + + public String getMaxNotifications() { + return maxNotifications; + } + + public void setMaxNotifications(String maxNotifications) { + this.maxNotifications = maxNotifications; + } + + public String getNotificationDelay() { + return notificationDelay; + } + + public void setNotificationDelay(String notificationDelay) { + this.notificationDelay = notificationDelay; + } + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SMSParameterConfigRequestWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SMSParameterConfigRequestWrapper.java new file mode 100644 index 00000000..abe6f7bd --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SMSParameterConfigRequestWrapper.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging; + + +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; + +public class SMSParameterConfigRequestWrapper extends RequestDTO { + + private SMSParameterConfigRequestBean parameterConfigRequestBean; + + + public SMSParameterConfigRequestBean getParameterConfigRequestBean() { + return parameterConfigRequestBean; + } + + public void setParameterConfigRequestBean(SMSParameterConfigRequestBean parameterConfigRequestBean) { + this.parameterConfigRequestBean = parameterConfigRequestBean; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SMSParameterConfigResponseWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SMSParameterConfigResponseWrapper.java new file mode 100644 index 00000000..7a330cd6 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SMSParameterConfigResponseWrapper.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging; + + +import com.wso2telco.services.dep.sandbox.dao.model.custom.ErrorResponseDTO; +import com.wso2telco.services.dep.sandbox.servicefactory.AbstractReturnWrapperDTO; + +public class SMSParameterConfigResponseWrapper extends AbstractReturnWrapperDTO { + private String status; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @Override + public Object getResponse() { + + if (getRequestError() == null) { + return status; + } else { + ErrorResponseDTO response = new ErrorResponseDTO(getRequestError()); + return response; + } + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SMSParameterInsertConfigHandler.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SMSParameterInsertConfigHandler.java new file mode 100644 index 00000000..4dd5fbfe --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SMSParameterInsertConfigHandler.java @@ -0,0 +1,154 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging; + + +import com.wso2telco.core.dbutils.exception.ServiceError; +import com.wso2telco.dep.oneapivalidation.exceptions.CustomException; +import com.wso2telco.dep.oneapivalidation.util.Validation; +import com.wso2telco.dep.oneapivalidation.util.ValidationRule; +import com.wso2telco.services.dep.sandbox.dao.DaoFactory; +import com.wso2telco.services.dep.sandbox.dao.SMSMessagingDAO; +import com.wso2telco.services.dep.sandbox.dao.model.domain.SMSMessagingParam; +import com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler; +import com.wso2telco.services.dep.sandbox.servicefactory.AddressIgnorerable; +import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; + +import org.apache.commons.logging.LogFactory; + +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class SMSParameterInsertConfigHandler extends AbstractRequestHandler + implements AddressIgnorerable { + + + private SMSParameterConfigRequestWrapper requestWrapper; + private SMSParameterConfigResponseWrapper responseWrapper; + private SMSMessagingDAO smsMessagingDAO; + + + { + LOG = LogFactory.getLog(SMSParameterInsertConfigHandler.class); + smsMessagingDAO = DaoFactory.getSMSMessagingDAO(); + } + + + @Override + protected Returnable getResponseDTO() { + return responseWrapper; + } + + @Override + protected List getAddress() { + return null; + } + + @Override + protected boolean validate(SMSParameterConfigRequestWrapper wrapperDTO) throws Exception { + + SMSParameterConfigRequestBean requestBean = wrapperDTO.getParameterConfigRequestBean(); + + + String deliveryStatus = requestBean.getDeliveryStatus(); + String maxNotifications = requestBean.getMaxNotifications(); + String notificationDelay = requestBean.getNotificationDelay(); + + List validationRulesList = new ArrayList<>(); + + try { + validationRulesList + .add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "deliveryStatus", + deliveryStatus)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, + "maxNotifications", maxNotifications)); + validationRulesList + .add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY_INT_GE_ZERO, + "notificationDelay", notificationDelay)); + + ValidationRule[] validationRules = new ValidationRule[validationRulesList.size()]; + validationRules = validationRulesList.toArray(validationRules); + + Validation.checkRequestParams(validationRules); + + } catch (CustomException ex) { + LOG.error("###SMSCONFIG### Error in Validations. ", ex); + responseWrapper.setRequestError( + constructRequestError(SERVICEEXCEPTION, ex.getErrcode(), ex.getErrmsg(), ex.getErrvar()[0])); + return false; + } + return true; + } + + @Override + protected Returnable process(SMSParameterConfigRequestWrapper extendedRequestDTO) throws Exception { + + if (responseWrapper.getRequestError() != null) { + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + + try { + SMSParameterConfigRequestBean requestBean = extendedRequestDTO.getParameterConfigRequestBean(); + + String deliveryStatus = requestBean.getDeliveryStatus(); + String maxNotifications = requestBean.getMaxNotifications(); + String notificationDelay = requestBean.getNotificationDelay(); + + SMSMessagingParam smsMessagingParam = new SMSMessagingParam(); + smsMessagingParam.setDeliveryStatus(deliveryStatus); + smsMessagingParam.setMaxNotifications(maxNotifications); + smsMessagingParam.setNotificationDelay(notificationDelay); + smsMessagingParam.setUserid(user.getId()); + smsMessagingParam.setCreated("1"); + smsMessagingParam.setCreatedDate(new Date()); + + boolean result = smsMessagingDAO.saveSMSParameters(smsMessagingParam); + + + if (!result) { + LOG.error("###USSD CONFIG### Error occur in save applications"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Error occur in save applications")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + + } else { + responseWrapper.setStatus("Successful"); + responseWrapper.setHttpStatus(Response.Status.OK); + } + + } catch (Exception ex) { + + LOG.error("###USSD CONFIG### Error occur in save applications"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Error occur in save applications")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + } + + return responseWrapper; + + } + + @Override + protected void init(SMSParameterConfigRequestWrapper extendedRequestDTO) throws Exception { + + requestWrapper = extendedRequestDTO; + responseWrapper = new SMSParameterConfigResponseWrapper(); + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SMSRequestFactory.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SMSRequestFactory.java index 9f55b160..f6319e37 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SMSRequestFactory.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SMSRequestFactory.java @@ -1,65 +1,33 @@ package com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging; +import com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway + .StopSubscribeToDeliveryNotificationService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; -import com.wso2telco.services.dep.sandbox.dao.model.custom.SendMTSMSRequestWrapperDTO; import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; + public class SMSRequestFactory { private static Log LOG = LogFactory.getLog(SMSRequestFactory.class); public static RequestHandleable getInstance(final RequestDTO requestDTO) { - SendMTSMSRequestWrapperDTO sendMTSMSRequestWrapperDTO = (SendMTSMSRequestWrapperDTO) requestDTO; - final String QUERY_DELIVERY_STATUS = "deliveryInfos"; - final String SEND_MT_SMS = "requests"; - final String RETRIVE_SMS = "registrations"; - final String OUTBOUND_REQUEST = "outbound"; - final String INBOUND_REQUEST = "inbound"; + final String QUERY_DELIVERY_STATUS = "deliveryinfos"; + final String CONFIGAPP = "addsmsparameters"; if (requestDTO.getRequestPath().toLowerCase().contains(QUERY_DELIVERY_STATUS) && requestDTO.isGet()) { - LOG.debug("LOADING QUERY SMS DELIVERY STATUS SERVICE"); return new QuerySMSDeliveryStatusService(); - } else if (requestDTO.getRequestPath().toLowerCase().contains(SEND_MT_SMS) - && requestDTO.isPost()) { - - LOG.debug("LOADING SEND MT SMS SERVICE"); - return new SendMTSMSService(); - } else if (requestDTO.getRequestPath().toLowerCase().contains(RETRIVE_SMS) - && requestDTO.isGet()) { - - LOG.debug("LOADING RETRIEVE SMS MESSAGES SERVICE"); - return new RetrieveSMSMessagesService(); - } else if (requestDTO.getRequestPath().toLowerCase().contains(OUTBOUND_REQUEST) - && requestDTO.isPost()) { - LOG.debug("LOADING SUBSCRIBE TO DELIVERY NOTIFICATION SERVICE"); - return new SubscribeToDeliveryNotificationService(); - } else if (requestDTO.getRequestPath().toLowerCase().contains(OUTBOUND_REQUEST) - && requestDTO.isDelete()) { - - LOG.debug("LOADING STOP SUBSCRIBE TO DELIVERY NOTIFICATION SERVICE"); - return new StopSubscribeToDeliveryNotificationService(); - } else if (requestDTO.getRequestPath().toLowerCase().contains(INBOUND_REQUEST) - && requestDTO.isPost()) { - - LOG.debug("LOADING SUBSCRIBE TO MO NOTIFICATION SERVICE"); - return new SubscribeToMONotificationService(); - } else if (requestDTO.getRequestPath().toLowerCase().contains(INBOUND_REQUEST) - && requestDTO.isDelete()) { - - LOG.debug("LOADING STOP SUBSCRIBE TO MO NOTIFICATION SERVICE"); - return new StopSubscribeToMONotificationService(); - } else { - - // should return unsupported api exception - } + } else if (requestDTO.getRequestPath().toLowerCase().contains(CONFIGAPP)) { + LOG.debug("LOADING CONFIGURATION SMS SERVICE"); + return new SMSParameterInsertConfigHandler(); + } return null; } } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SendMTSMSResponseWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SendMTSMSResponseWrapper.java deleted file mode 100644 index 67f50d94..00000000 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SendMTSMSResponseWrapper.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging; - -import com.wso2telco.services.dep.sandbox.servicefactory.AbstractReturnWrapperDTO; -import com.wso2telco.services.dep.sandbox.util.RequestError; - -public class SendMTSMSResponseWrapper extends AbstractReturnWrapperDTO { - - private OutboundSMSMessageResponseBean outboundSMSMessageResponseBean = null; - - public OutboundSMSMessageResponseBean getOutboundSMSMessageResponseBean() { - return outboundSMSMessageResponseBean; - } - - public void setOutboundSMSMessageResponseBean(OutboundSMSMessageResponseBean outboundSMSMessageResponseBean) { - this.outboundSMSMessageResponseBean = outboundSMSMessageResponseBean; - } - - @Override - public Object getResponse() { - - SendMTSMSResponse response = new SendMTSMSResponse(getRequestError(), outboundSMSMessageResponseBean); - return response; - } - - class SendMTSMSResponse { - - private RequestError requestError; - private OutboundSMSMessageResponseBean outboundSMSMessageResponseBean; - - SendMTSMSResponse(RequestError requestError, OutboundSMSMessageResponseBean outboundSMSMessageResponseBean) { - this.requestError = requestError; - this.outboundSMSMessageResponseBean = outboundSMSMessageResponseBean; - } - - public RequestError getRequestError() { - return requestError; - } - - public void setRequestError(RequestError requestError) { - this.requestError = requestError; - } - - public OutboundSMSMessageResponseBean getOutboundSMSMessageResponseBean() { - return outboundSMSMessageResponseBean; - } - - public void setOutboundSMSMessageResponseBean(OutboundSMSMessageResponseBean outboundSMSMessageResponseBean) { - this.outboundSMSMessageResponseBean = outboundSMSMessageResponseBean; - } - } -} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SendMTSMSService.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SendMTSMSService.java deleted file mode 100644 index bd7febdf..00000000 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SendMTSMSService.java +++ /dev/null @@ -1,209 +0,0 @@ -package com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.ws.rs.core.Response.Status; - -import org.apache.commons.logging.LogFactory; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.wso2telco.dep.oneapivalidation.service.impl.smsmessaging.ValidateSendSms; -import com.wso2telco.services.dep.sandbox.dao.DaoFactory; -import com.wso2telco.services.dep.sandbox.dao.SMSMessagingDAO; -import com.wso2telco.services.dep.sandbox.dao.model.custom.OutboundSMSMessageRequestBean; -import com.wso2telco.services.dep.sandbox.dao.model.custom.SendMTSMSRequestWrapperDTO; -import com.wso2telco.services.dep.sandbox.dao.model.domain.SMSMessagingParam; -import com.wso2telco.services.dep.sandbox.dao.model.domain.User; -import com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler; -import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; - -class SendMTSMSService extends AbstractRequestHandler { - - Gson gson = new GsonBuilder().serializeNulls().create(); - SendMTSMSRequestWrapperDTO extendedRequestDTO = null; - SendMTSMSResponseWrapper responseWrapperDTO = null; - private SMSMessagingDAO smsMessagingDAO = null; - - { - LOG = LogFactory.getLog(SendMTSMSService.class); - smsMessagingDAO = DaoFactory.getSMSMessagingDAO(); - } - - @Override - protected Returnable process(SendMTSMSRequestWrapperDTO extendedRequestDTO) throws Exception { - - try { - - User user = extendedRequestDTO.getUser(); - SMSMessagingParam smsMessagingParam = smsMessagingDAO.getSMSMessagingParam(user.getId()); - - String senderAddress = extendedRequestDTO.getOutboundSMSMessageRequestBean().getOutboundSMSMessageRequest() - .getSenderAddress(); - if (extendedRequestDTO.getOutboundSMSMessageRequestBean().getOutboundSMSMessageRequest().getSenderAddress() - .contains("tel:+")) { - senderAddress = extendedRequestDTO.getOutboundSMSMessageRequestBean().getOutboundSMSMessageRequest() - .getSenderAddress().replace("tel:+", "").trim(); - } else if (extendedRequestDTO.getOutboundSMSMessageRequestBean().getOutboundSMSMessageRequest() - .getSenderAddress().contains("tel:")) { - senderAddress = extendedRequestDTO.getOutboundSMSMessageRequestBean().getOutboundSMSMessageRequest() - .getSenderAddress().replace("tel:", "").trim(); - } - - if (!dao.isWhiteListedSenderAddress(user.getId(), senderAddress)) { - - responseWrapperDTO - .setRequestError( - constructRequestError(SERVICEEXCEPTION, "SVC0001", - "A service error occurred. Error code is %1", - extendedRequestDTO.getOutboundSMSMessageRequestBean() - .getOutboundSMSMessageRequest().getSenderAddress() - + " Not Provisioned")); - responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); - } else { - - OutboundSMSMessageRequestBean requestBean = extendedRequestDTO.getOutboundSMSMessageRequestBean(); - - String mtSMSTransactionId = smsMessagingDAO.saveSendSMSTransaction( - requestBean.getOutboundSMSMessageRequest().getSenderAddress(), - requestBean.getOutboundSMSMessageRequest().getAddress().toArray().toString(), - requestBean.getOutboundSMSMessageRequest().getOutboundSMSTextMessage().getMessage(), - requestBean.getOutboundSMSMessageRequest().getClientCorrelator(), - requestBean.getOutboundSMSMessageRequest().getSenderName(), - requestBean.getOutboundSMSMessageRequest().getReceiptRequest().getNotifyURL(), - requestBean.getOutboundSMSMessageRequest().getReceiptRequest().getCallbackData(), 0, "success", - 1, null, null, user, smsMessagingParam.getDeliveryStatus()); - - if (mtSMSTransactionId == null) { - - responseWrapperDTO.setRequestError(constructRequestError(SERVICEEXCEPTION, "SVC0001", - "A service error occurred. Error code is %1", "Access failure for API")); - responseWrapperDTO.setHttpStatus(Status.BAD_REQUEST); - } else { - - OutboundSMSMessageResponseBean responseBean = new OutboundSMSMessageResponseBean(); - - OutboundSMSMessageResponseBean.OutboundSMSMessageRequest smsMessageResponse = new OutboundSMSMessageResponseBean.OutboundSMSMessageRequest(); - smsMessageResponse.setAddress(requestBean.getOutboundSMSMessageRequest().getAddress()); - - OutboundSMSMessageResponseBean.OutboundSMSMessageRequest.DeliveryInfoList responseDeliveryInfoList = new OutboundSMSMessageResponseBean.OutboundSMSMessageRequest.DeliveryInfoList(); - - List deliveryInforArrayList = new ArrayList(); - Iterator addressReader = requestBean.getOutboundSMSMessageRequest().getAddress().iterator(); - while (addressReader.hasNext()) { - - OutboundSMSMessageResponseBean.OutboundSMSMessageRequest.DeliveryInfoList.DeliveryInfo responseDeliveryInfo = new OutboundSMSMessageResponseBean.OutboundSMSMessageRequest.DeliveryInfoList.DeliveryInfo(); - responseDeliveryInfo.setAddress(addressReader.next()); - responseDeliveryInfo.setDeliveryStatus(smsMessagingParam.getDeliveryStatus()); - - deliveryInforArrayList.add(responseDeliveryInfo); - } - responseDeliveryInfoList.setDeliveryInfo(deliveryInforArrayList); - responseDeliveryInfoList.setResourceURL(getinSideResourceURL(mtSMSTransactionId).toString()); - smsMessageResponse.setDeliveryInfoList(responseDeliveryInfoList); - - smsMessageResponse.setSenderAddress(requestBean.getOutboundSMSMessageRequest().getSenderAddress()); - OutboundSMSMessageResponseBean.OutboundSMSMessageRequest.OutboundSMSTextMessage responseSMSTextMessage = new OutboundSMSMessageResponseBean.OutboundSMSMessageRequest.OutboundSMSTextMessage(); - responseSMSTextMessage.setMessage( - requestBean.getOutboundSMSMessageRequest().getOutboundSMSTextMessage().getMessage()); - smsMessageResponse.setOutboundSMSTextMessage(responseSMSTextMessage); - - smsMessageResponse - .setClientCorrelator(requestBean.getOutboundSMSMessageRequest().getClientCorrelator()); - - OutboundSMSMessageResponseBean.OutboundSMSMessageRequest.ReceiptRequest responseReceiptRequest = new OutboundSMSMessageResponseBean.OutboundSMSMessageRequest.ReceiptRequest(); - responseReceiptRequest.setNotifyURL( - requestBean.getOutboundSMSMessageRequest().getReceiptRequest().getNotifyURL()); - responseReceiptRequest.setCallbackData( - requestBean.getOutboundSMSMessageRequest().getReceiptRequest().getCallbackData()); - smsMessageResponse.setReceiptRequest(responseReceiptRequest); - - smsMessageResponse.setSenderName(requestBean.getOutboundSMSMessageRequest().getSenderName()); - smsMessageResponse.setResourceURL(getoutSideResourceURL(mtSMSTransactionId).toString()); - - responseBean.setOutboundSMSMessageRequest(smsMessageResponse); - - responseWrapperDTO.setOutboundSMSMessageResponseBean(responseBean); - responseWrapperDTO.setHttpStatus(Status.OK); - } - } - } catch (Exception e) { - - throw e; - } - - return responseWrapperDTO; - } - - @Override - protected boolean validate(SendMTSMSRequestWrapperDTO wrapperDTO) throws Exception { - - ValidateSendSms validator = new ValidateSendSms(); - validator.validate(gson.toJson(wrapperDTO.getOutboundSMSMessageRequestBean())); - return false; - } - - @Override - protected Returnable getResponseDTO() { - - return responseWrapperDTO; - } - - @Override - protected List getAddress() { - - List addresses = new ArrayList(); - addresses = extendedRequestDTO.getOutboundSMSMessageRequestBean().getOutboundSMSMessageRequest().getAddress(); - return addresses; - } - - @Override - protected void init(SendMTSMSRequestWrapperDTO extendedRequestDTO) throws Exception { - - responseWrapperDTO = new SendMTSMSResponseWrapper(); - this.extendedRequestDTO = extendedRequestDTO; - } - - private StringBuilder getinSideResourceURL(final String mtSMSTransactionId) { - - StringBuilder inSideResourceURLBuilder = new StringBuilder(); - try { - - inSideResourceURLBuilder.append("http://wso2telco.sandbox.com"); - inSideResourceURLBuilder.append("/smsmessaging/"); - inSideResourceURLBuilder.append(extendedRequestDTO.getApiVersion()); - inSideResourceURLBuilder.append("/outbound/"); - inSideResourceURLBuilder.append(extendedRequestDTO.getShortCode()); - inSideResourceURLBuilder.append("/requests/"); - inSideResourceURLBuilder.append(mtSMSTransactionId); - inSideResourceURLBuilder.append("/deliveryInfos"); - } catch (Exception e) { - - throw e; - } - - return inSideResourceURLBuilder; - } - - private StringBuilder getoutSideResourceURL(final String mtSMSTransactionId) { - - StringBuilder outSideResourceURLBuilder = new StringBuilder(); - try { - - outSideResourceURLBuilder.append("http://wso2telco.sandbox.com"); - outSideResourceURLBuilder.append("/smsmessaging/"); - outSideResourceURLBuilder.append(extendedRequestDTO.getApiVersion()); - outSideResourceURLBuilder.append("/outbound/"); - outSideResourceURLBuilder.append(extendedRequestDTO.getShortCode()); - outSideResourceURLBuilder.append("/requests/"); - outSideResourceURLBuilder.append(mtSMSTransactionId); - } catch (Exception e) { - - throw e; - } - - return outSideResourceURLBuilder; - } -} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/StopSubscribeToDeliveryNotificationService.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/StopSubscribeToDeliveryNotificationService.java deleted file mode 100644 index 8561f6a9..00000000 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/StopSubscribeToDeliveryNotificationService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging; - -import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; -import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; -import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; - -public class StopSubscribeToDeliveryNotificationService implements RequestHandleable{ - - @Override - public Returnable execute(RequestDTO requestDTO) throws Exception { - // TODO Auto-generated method stub - return null; - } -} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/StopSubscribeToMONotificationService.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/StopSubscribeToMONotificationService.java deleted file mode 100644 index 73596834..00000000 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/StopSubscribeToMONotificationService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging; - -import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; -import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; -import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; - -public class StopSubscribeToMONotificationService implements RequestHandleable { - - @Override - public Returnable execute(RequestDTO requestDTO) throws Exception { - // TODO Auto-generated method stub - return null; - } -} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SubscribeToDeliveryNotificationService.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SubscribeToDeliveryNotificationService.java deleted file mode 100644 index 82cd5899..00000000 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SubscribeToDeliveryNotificationService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging; - -import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; -import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; -import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; - -public class SubscribeToDeliveryNotificationService implements RequestHandleable{ - - @Override - public Returnable execute(RequestDTO requestDTO) throws Exception { - // TODO Auto-generated method stub - return null; - } -} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SubscribeToMONotificationService.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SubscribeToMONotificationService.java deleted file mode 100644 index cad4f8fe..00000000 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/SubscribeToMONotificationService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging; - -import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; -import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; -import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; - -public class SubscribeToMONotificationService implements RequestHandleable { - - @Override - public Returnable execute(RequestDTO requestDTO) throws Exception { - // TODO Auto-generated method stub - return null; - } -} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/CallReferenceResponse.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/CallReferenceResponse.java new file mode 100644 index 00000000..27050d13 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/CallReferenceResponse.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class CallReferenceResponse { + + private String callbackData; + private String notifyURL; + + public String getCallbackData() { + return callbackData; + } + + public void setCallbackData(String callbackData) { + this.callbackData = callbackData; + } + + public String getNotifyURL() { + return notifyURL; + } + + public void setNotifyURL(String notifyURL) { + this.notifyURL = notifyURL; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/OutboundSMSMessageRequestBeanGateway.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/OutboundSMSMessageRequestBeanGateway.java new file mode 100644 index 00000000..757a8c55 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/OutboundSMSMessageRequestBeanGateway.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + + +import com.wso2telco.services.dep.sandbox.dao.model.custom.OutboundSMSMessageRequest; + +import java.util.List; + +public class OutboundSMSMessageRequestBeanGateway { + + + private OutboundSMSMessageRequest_Gw outboundSMSMessageRequest; + + + public OutboundSMSMessageRequest_Gw getOutboundSMSMessageRequest() { + return outboundSMSMessageRequest; + } + + public void setOutboundSMSMessageRequest(OutboundSMSMessageRequest_Gw outboundSMSMessageRequest) { + this.outboundSMSMessageRequest = outboundSMSMessageRequest; + } + + public class OutboundSMSMessageRequest_Gw extends OutboundSMSMessageRequest { + + + private String senderAddress; + private String senderName; + + public String getSenderAddress() { + return senderAddress; + } + + public void setSenderAddress(String senderAddress) { + this.senderAddress = senderAddress; + } + + public String getSenderName() { + return senderName; + } + + public void setSenderName(String senderName) { + this.senderName = senderName; + } + } + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/OutboundSMSMessageResponseBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/OutboundSMSMessageResponseBean.java new file mode 100644 index 00000000..e83a947d --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/OutboundSMSMessageResponseBean.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + + +import com.wso2telco.services.dep.sandbox.dao.model.custom.DeliveryInfoList; +import com.wso2telco.services.dep.sandbox.dao.model.custom.OutboundSMSMessageRequest; + +class OutboundSMSMessageResponseBean { + + + private OutboundSMSMessageResponseGateway outboundSMSMessageRequest; + + + public OutboundSMSMessageResponseGateway getOutboundSMSMessageRequest() { + return outboundSMSMessageRequest; + } + + public void setOutboundSMSMessageRequest(OutboundSMSMessageResponseGateway outboundSMSMessageRequest) { + this.outboundSMSMessageRequest = outboundSMSMessageRequest; + } + + public static class OutboundSMSMessageResponseGateway extends OutboundSMSMessageRequest { + + + private DeliveryInfoList deliveryInfoList; + private String senderAddress; + private String senderName; + private String resourceURL; + + + public DeliveryInfoList getDeliveryInfoList() { + return deliveryInfoList; + } + + public void setDeliveryInfoList(DeliveryInfoList deliveryInfoList) { + this.deliveryInfoList = deliveryInfoList; + } + + public String getSenderAddress() { + return senderAddress; + } + + public void setSenderAddress(String senderAddress) { + this.senderAddress = senderAddress; + } + + public String getSenderName() { + return senderName; + } + + public void setSenderName(String senderName) { + this.senderName = senderName; + } + + public String getResourceURL() { + return resourceURL; + } + + public void setResourceURL(String resourceURL) { + this.resourceURL = resourceURL; + } + } + + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/ReceivingSMSHandler.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/ReceivingSMSHandler.java new file mode 100644 index 00000000..5946e9c4 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/ReceivingSMSHandler.java @@ -0,0 +1,194 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + +import com.google.gson.Gson; +import com.wso2telco.core.dbutils.exception.ServiceError; +import com.wso2telco.dep.oneapivalidation.exceptions.CustomException; +import com.wso2telco.dep.oneapivalidation.util.Validation; +import com.wso2telco.dep.oneapivalidation.util.ValidationRule; +import com.wso2telco.services.dep.sandbox.dao.DaoFactory; +import com.wso2telco.services.dep.sandbox.dao.SMSMessagingDAO; +import com.wso2telco.services.dep.sandbox.dao.model.custom.InboundSMSMessage; +import com.wso2telco.services.dep.sandbox.dao.model.domain.APIServiceCalls; +import com.wso2telco.services.dep.sandbox.dao.model.domain.APITypes; +import com.wso2telco.services.dep.sandbox.dao.model.domain.MessageLog; +import com.wso2telco.services.dep.sandbox.dao.model.domain.SendSMSToApplication; +import com.wso2telco.services.dep.sandbox.servicefactory.*; +import com.wso2telco.services.dep.sandbox.util.CommonUtil; +import com.wso2telco.services.dep.sandbox.util.ServiceName; +import org.apache.commons.logging.LogFactory; +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + + class ReceivingSMSHandler extends AbstractRequestHandler implements + AddressIgnorerable { + + private ReceivingSMSResponseWrapper responseWrapper; + private ReceivingSMSRequestWrapperGateway requestWrapper; + private SMSMessagingDAO smsMessagingDAO; + private String resourceURL; + + + { + LOG = LogFactory.getLog(ReceivingSMSHandler.class); + smsMessagingDAO = DaoFactory.getSMSMessagingDAO(); + } + + + @Override + protected Returnable getResponseDTO() { + return responseWrapper; + } + + @Override + protected List getAddress() { + return null; + } + + @Override + protected boolean validate(ReceivingSMSRequestWrapperGateway wrapperDTO) throws Exception { + + + String registrationId = wrapperDTO.getRegistrationID(); + int maxBatchSize = wrapperDTO.getMaxBatchSize(); + + try { + ValidationRule[] rules = { + new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "registrationId", registrationId), + new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL_INT_GE_ZERO, "maxBatchSize", + maxBatchSize)}; + + + Validation.checkRequestParams(rules); + + } catch (CustomException ex) { + LOG.error("###SMS### Error in Validations. ", ex); + responseWrapper.setRequestError( + constructRequestError(SERVICEEXCEPTION, ex.getErrcode(), ex.getErrmsg(), ex.getErrvar()[0])); + return false; + } + return true; + } + + @Override + protected Returnable process(ReceivingSMSRequestWrapperGateway extendedRequestDTO) throws Exception { + + if (responseWrapper.getRequestError() != null) { + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + try { + String registrationId = extendedRequestDTO.getRegistrationID(); + int maxBatchSize = extendedRequestDTO.getMaxBatchSize(); + + APITypes apiTypes = dao.getAPIType(extendedRequestDTO.getRequestType().toString().toLowerCase()); + String serviceCallPayment = ServiceName.ReceivingSMS.toString(); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), serviceCallPayment); + + if (!dao.isWhiteListedSenderAddress(user.getId(), registrationId)) { + LOG.error("###SMS### Destination address is not WhiteListed "); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Destination Address is not WhiteListed")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + + List smsMessageList = smsMessagingDAO.getMessageInbound(registrationId, user.getId()); + List inboundSMSMessageList = new ArrayList<>(); + + if (maxBatchSize > smsMessageList.size()) { + + maxBatchSize = smsMessageList.size(); + } + + for (int i = 0; i < maxBatchSize; i++) { + + InboundSMSMessage inboundSMSMessage = new InboundSMSMessage(); + inboundSMSMessage.setDateTime((smsMessageList.get(i).getDate()).toString()); + inboundSMSMessage.setDestinationAddress(smsMessageList.get(i).getDestinationAddress()); + inboundSMSMessage.setMessage(smsMessageList.get(i).getMessage()); + inboundSMSMessage.setMessageId(smsMessageList.get(i).getSmsId()); + inboundSMSMessage.setSenderAddress(smsMessageList.get(i).getSenderAddress()); + inboundSMSMessage.setResourceURL(resourceURL + "/" + smsMessageList.get(i).getSmsId()); + inboundSMSMessageList.add(inboundSMSMessage); + } + + ReceivingSMSResponseBean responseBean = new ReceivingSMSResponseBean(); + ReceivingSMSResponseBean.InboundSMSMessageList list = new ReceivingSMSResponseBean + .InboundSMSMessageList(); + list.setInboundSMSMessages(inboundSMSMessageList); + + responseBean.setInboundSMSMessageList(list); + responseBean.setNumberOfMessagesInThisBatch(maxBatchSize); + responseBean.setResourceURL(resourceURL); + responseBean.setTotalNumberOfPendingMessages(smsMessageList.size()-maxBatchSize); + + responseWrapper.setReceivingSMSResponseBean(responseBean); + responseWrapper.setHttpStatus(Response.Status.OK); + + // Save Success Response + saveResponse(registrationId, responseBean, apiServiceCalls, MessageProcessStatus.Success); + + }catch (Exception ex){ + LOG.error("###SMS### Error Occurred in SMS Receiving Service. ", ex); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + responseWrapper + .setRequestError(constructRequestError(SERVICEEXCEPTION, ServiceError.SERVICE_ERROR_OCCURED, + "Error Occurred in SMS Receiving Service.")); + } + + return responseWrapper; + } + + @Override + protected void init(ReceivingSMSRequestWrapperGateway extendedRequestDTO) throws Exception { + + requestWrapper = extendedRequestDTO; + responseWrapper = new ReceivingSMSResponseWrapper(); + resourceURL = CommonUtil.getResourceUrl(requestWrapper); + + } + + + // Save Response in messageLog table + private void saveResponse(String endUserIdPath, ReceivingSMSResponseBean responseBean, APIServiceCalls + apiServiceCalls, MessageProcessStatus status) throws Exception { + + Gson gson = new Gson(); + String jsonString = gson.toJson(responseBean); + + //setting messagelog responses + new MessageLog(); + MessageLog messageLog; + messageLog = new MessageLog(); + messageLog.setRequest(jsonString); + messageLog.setStatus(status.getValue()); + messageLog.setType(MessageType.Response.getValue()); + messageLog.setServicenameid(apiServiceCalls.getApiServiceCallId()); + messageLog.setUserid(user.getId()); + messageLog.setReference("shortCode"); + messageLog.setValue(endUserIdPath); + messageLog.setMessageTimestamp(new Date()); + + loggingDAO.saveMessageLog(messageLog); + } + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/ReceivingSMSRequestWrapperGateway.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/ReceivingSMSRequestWrapperGateway.java new file mode 100644 index 00000000..d6851775 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/ReceivingSMSRequestWrapperGateway.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + + +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; + +public class ReceivingSMSRequestWrapperGateway extends RequestDTO { + + + private String registrationID; + private int maxBatchSize; + + public String getRegistrationID() { + return registrationID; + } + + public void setRegistrationID(String registrationID) { + this.registrationID = registrationID; + } + + public int getMaxBatchSize() { + return maxBatchSize; + } + + public void setMaxBatchSize(int maxBatchSize) { + this.maxBatchSize = maxBatchSize; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/ReceivingSMSResponseBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/ReceivingSMSResponseBean.java new file mode 100644 index 00000000..abe30c0a --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/ReceivingSMSResponseBean.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.wso2telco.services.dep.sandbox.dao.model.custom.InboundSMSMessage; +import java.util.List; + +@JsonInclude(value = JsonInclude.Include.NON_NULL) + class ReceivingSMSResponseBean { + + private InboundSMSMessageList inboundSMSMessageList; + private int numberOfMessagesInThisBatch; + private String resourceURL; + private int totalNumberOfPendingMessages; + + public InboundSMSMessageList getInboundSMSMessageList() { + return inboundSMSMessageList; + } + + public void setInboundSMSMessageList(InboundSMSMessageList inboundSMSMessageList) { + this.inboundSMSMessageList = inboundSMSMessageList; + } + + public int getNumberOfMessagesInThisBatch() { + return numberOfMessagesInThisBatch; + } + + public void setNumberOfMessagesInThisBatch(int numberOfMessagesInThisBatch) { + this.numberOfMessagesInThisBatch = numberOfMessagesInThisBatch; + } + + public String getResourceURL() { + return resourceURL; + } + + public void setResourceURL(String resourceURL) { + this.resourceURL = resourceURL; + } + + public int getTotalNumberOfPendingMessages() { + return totalNumberOfPendingMessages; + } + + public void setTotalNumberOfPendingMessages(int totalNumberOfPendingMessages) { + this.totalNumberOfPendingMessages = totalNumberOfPendingMessages; + } + + @JsonInclude(value = JsonInclude.Include.NON_NULL) + public static class InboundSMSMessageList{ + + private List inboundSMSMessages; + + public List getInboundSMSMessages() { + return inboundSMSMessages; + } + + public void setInboundSMSMessages(List inboundSMSMessages) { + this.inboundSMSMessages = inboundSMSMessages; + } + + + + } + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/ReceivingSMSResponseWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/ReceivingSMSResponseWrapper.java new file mode 100644 index 00000000..90bedd78 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/ReceivingSMSResponseWrapper.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + + +import com.wso2telco.services.dep.sandbox.dao.model.custom.ErrorResponseDTO; +import com.wso2telco.services.dep.sandbox.servicefactory.AbstractReturnWrapperDTO; + + class ReceivingSMSResponseWrapper extends AbstractReturnWrapperDTO { + + + private ReceivingSMSResponseBean receivingSMSResponseBean; + + public ReceivingSMSResponseBean getReceivingSMSResponseBean() { + return receivingSMSResponseBean; + } + + public void setReceivingSMSResponseBean(ReceivingSMSResponseBean receivingSMSResponseBean) { + this.receivingSMSResponseBean = receivingSMSResponseBean; + } + + @Override + public Object getResponse() { + if (getRequestError() == null) { + return receivingSMSResponseBean; + }else{ + ErrorResponseDTO response= new ErrorResponseDTO(getRequestError()); + return response; + } + + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SMSRequestFactoryGateway.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SMSRequestFactoryGateway.java new file mode 100644 index 00000000..bbc7f506 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SMSRequestFactoryGateway.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + + + +public class SMSRequestFactoryGateway { + + private static Log LOG = LogFactory.getLog(SMSRequestFactoryGateway.class); + + public static RequestHandleable getInstance(final RequestDTO requestDTO) { + + final String QUERY_DELIVERY_STATUS = "deliveryinfos"; + final String SEND_MT_SMS = "requests"; + final String RETRIVE_SMS = "registrations"; + final String OUTBOUND_REQUEST = "outbound"; + final String INBOUND_REQUEST = "inbound"; + final String SUBSCRIBE_TO_DELEVERY_NOTIFICATION = "subscriptions"; + final String STOP_DELIVERY_SUBSCRIPTION_NOTIFICATION = "subscription"; + final String SUBSCRIPTIONS = "subscriptions"; + + + if (requestDTO.getRequestPath().toLowerCase().contains(SEND_MT_SMS) + && requestDTO.isPost()) { + LOG.debug("LOADING SEND MT SMS SERVICE"); + return new SendMTSMSService(); + + } else if (requestDTO.getRequestPath().toLowerCase().contains(SUBSCRIBE_TO_DELEVERY_NOTIFICATION) && requestDTO.getRequestPath().toLowerCase().contains(OUTBOUND_REQUEST)&& requestDTO.isPost()) { + LOG.debug("LOADING NOTIFICATION SUBSCRIPTION SERVICE"); + return new SubscribeToDeliveryNotificationService(); + + } else if (requestDTO.getRequestPath().toLowerCase().contains(STOP_DELIVERY_SUBSCRIPTION_NOTIFICATION) && requestDTO.getRequestPath().toLowerCase().contains(OUTBOUND_REQUEST)&& requestDTO.isDelete()) { + LOG.debug("LOADING STOP SUBSCRIPTION NOTIFICATION SERVICE"); + return new StopSubscribeToDeliveryNotificationService(); + } + else if (requestDTO.getRequestPath().toLowerCase().contains(RETRIVE_SMS) + && requestDTO.isGet()) { + + LOG.debug("LOADING RETRIVE SMS SERVICE"); + return new ReceivingSMSHandler(); + } + else if (requestDTO.getRequestPath().toLowerCase().contains(SUBSCRIPTIONS) + && requestDTO.isPost()) { + LOG.debug("LOADING SUBSCRIPTIONS SMS SERVICE"); + + return new SubscribeApplicationNotificationsHandler(); + } + + else if (requestDTO.getRequestPath().toLowerCase().contains(SUBSCRIPTIONS) + && requestDTO.isDelete()) { + LOG.debug("LOADING SUBSCRIPTIONS SMS SERVICE"); + + return new StopSubscriptionMessageNotificationHandler(); + } + + else { + return null; + } + + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SendMTSMSRequestWrapperDTOGateway.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SendMTSMSRequestWrapperDTOGateway.java new file mode 100644 index 00000000..f6419e03 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SendMTSMSRequestWrapperDTOGateway.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + + +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; + +public class SendMTSMSRequestWrapperDTOGateway extends RequestDTO { + + private static final long serialVersionUID = 796868921376883562L; + private String shortCode; + private OutboundSMSMessageRequestBeanGateway outboundSMSMessageRequestBeanGw; + + + public String getShortCode() { + return shortCode; + } + + public void setShortCode(String shortCode) { + this.shortCode = shortCode; + } + + public OutboundSMSMessageRequestBeanGateway getOutboundSMSMessageRequestBeanGw() { + return outboundSMSMessageRequestBeanGw; + } + + public void setOutboundSMSMessageRequestBeanGw(OutboundSMSMessageRequestBeanGateway outboundSMSMessageRequestBeanGw) { + this.outboundSMSMessageRequestBeanGw = outboundSMSMessageRequestBeanGw; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SendMTSMSResponseWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SendMTSMSResponseWrapper.java new file mode 100644 index 00000000..1f0335b4 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SendMTSMSResponseWrapper.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + + +import com.wso2telco.services.dep.sandbox.dao.model.custom.ErrorResponseDTO; +import com.wso2telco.services.dep.sandbox.servicefactory.AbstractReturnWrapperDTO; + +class SendMTSMSResponseWrapper extends AbstractReturnWrapperDTO { + + + private OutboundSMSMessageResponseBean outboundSMSMessageResponseBeanGw; + + + public OutboundSMSMessageResponseBean getOutboundSMSMessageResponseBeanGw() { + return outboundSMSMessageResponseBeanGw; + } + + public void setOutboundSMSMessageResponseBeanGw(OutboundSMSMessageResponseBean + outboundSMSMessageResponseBeanGw) { + this.outboundSMSMessageResponseBeanGw = outboundSMSMessageResponseBeanGw; + } + + @Override + public Object getResponse() { + + if (getRequestError() == null) { + return outboundSMSMessageResponseBeanGw; + }else{ + ErrorResponseDTO response= new ErrorResponseDTO(getRequestError()); + return response; + } + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SendMTSMSService.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SendMTSMSService.java new file mode 100644 index 00000000..6c293a3d --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SendMTSMSService.java @@ -0,0 +1,335 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.wso2telco.core.dbutils.exception.ServiceError; +import com.wso2telco.dep.oneapivalidation.exceptions.CustomException; +import com.wso2telco.dep.oneapivalidation.util.Validation; +import com.wso2telco.dep.oneapivalidation.util.ValidationRule; +import com.wso2telco.services.dep.sandbox.dao.DaoFactory; +import com.wso2telco.services.dep.sandbox.dao.SMSMessagingDAO; +import com.wso2telco.services.dep.sandbox.dao.model.custom.*; +import com.wso2telco.services.dep.sandbox.dao.model.domain.*; +import com.wso2telco.services.dep.sandbox.servicefactory.*; +import com.wso2telco.services.dep.sandbox.util.CommonUtil; +import com.wso2telco.services.dep.sandbox.util.ServiceName; +import org.apache.commons.logging.LogFactory; +import org.json.JSONObject; + +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +class SendMTSMSService extends AbstractRequestHandler implements + RequestResponseRequestHandleable { + + private Gson gson = new GsonBuilder().serializeNulls().create(); + private SendMTSMSRequestWrapperDTOGateway extendedRequestDTO; + private SendMTSMSResponseWrapper responseWrapper; + private SMSMessagingDAO smsMessagingDAO; + private String resourceURL; + + + { + LOG = LogFactory.getLog(SendMTSMSService.class); + smsMessagingDAO = DaoFactory.getSMSMessagingDAO(); + } + + + @Override + protected Returnable getResponseDTO() { + return responseWrapper; + } + + @Override + protected List getAddress() { + List addresses; + addresses = extendedRequestDTO.getOutboundSMSMessageRequestBeanGw().getOutboundSMSMessageRequest().getAddress(); + return addresses; + } + + @Override + protected boolean validate(SendMTSMSRequestWrapperDTOGateway wrapperDTO) throws Exception { + OutboundSMSMessageRequestBeanGateway outboundSMSMessageRequestBeanGateway = wrapperDTO + .getOutboundSMSMessageRequestBeanGw(); + + String address = CommonUtil.getNullOrTrimmedValue(outboundSMSMessageRequestBeanGateway + .getOutboundSMSMessageRequest().getAddress().toString()); + String callBackData = CommonUtil.getNullOrTrimmedValue(outboundSMSMessageRequestBeanGateway + .getOutboundSMSMessageRequest().getReceiptRequest().getCallbackData()); + String clientCorrelator = CommonUtil.getNullOrTrimmedValue(outboundSMSMessageRequestBeanGateway + .getOutboundSMSMessageRequest().getClientCorrelator()); + String message = CommonUtil.getNullOrTrimmedValue(outboundSMSMessageRequestBeanGateway + .getOutboundSMSMessageRequest().getOutboundSMSTextMessage().getMessage()); + String notifyURL = CommonUtil.getNullOrTrimmedValue(outboundSMSMessageRequestBeanGateway + .getOutboundSMSMessageRequest().getReceiptRequest().getNotifyURL()); + String senderAddress = CommonUtil.getNullOrTrimmedValue(outboundSMSMessageRequestBeanGateway + .getOutboundSMSMessageRequest().getSenderAddress()); + String senderName = CommonUtil.getNullOrTrimmedValue(outboundSMSMessageRequestBeanGateway + .getOutboundSMSMessageRequest().getSenderName()); + + + List validationRulesList = new ArrayList<>(); + + try { + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "address", address)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "callBackData", callBackData)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "clientCorrelator", clientCorrelator)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "message", message)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "notifyURL", notifyURL)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "senderName", senderName)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "senderAddress", senderAddress)); + + ValidationRule[] validationRules = new ValidationRule[validationRulesList.size()]; + validationRules = validationRulesList.toArray(validationRules); + + Validation.checkRequestParams(validationRules); + + } catch (CustomException ex) { + LOG.error("###SMS### Error in Validations. ", ex); + responseWrapper.setRequestError( + constructRequestError(SERVICEEXCEPTION, ex.getErrcode(), ex.getErrmsg(), ex.getErrvar()[0])); + return false; + } + return true; + } + + @Override + protected Returnable process(SendMTSMSRequestWrapperDTOGateway extendedRequestDTO) throws Exception { + + if (responseWrapper.getRequestError() != null) { + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + try { + User user = extendedRequestDTO.getUser(); + SMSMessagingParam smsMessagingParam = smsMessagingDAO.getSMSMessagingParam(user.getId()); + APITypes apiTypes = dao.getAPIType(extendedRequestDTO.getRequestType().toString().toLowerCase()); + String serviceCallPayment = ServiceName.SendSMS.toString(); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), serviceCallPayment); + String clientCorrelator = CommonUtil.getNullOrTrimmedValue(extendedRequestDTO + .getOutboundSMSMessageRequestBeanGw().getOutboundSMSMessageRequest().getClientCorrelator()); + Integer userId = extendedRequestDTO.getUser().getId(); + int serviceNameId = apiServiceCalls.getApiServiceCallId(); + String endUserId = extendedRequestDTO.getOutboundSMSMessageRequestBeanGw().getOutboundSMSMessageRequest() + .getAddress().toString(); + + String senderAddress = extendedRequestDTO.getOutboundSMSMessageRequestBeanGw().getOutboundSMSMessageRequest().getSenderAddress(); + String senderAddressOnly= senderAddress.replaceAll("[^0-9]", ""); + + + + OutboundSMSMessageRequestBeanGateway requestBean = extendedRequestDTO.getOutboundSMSMessageRequestBeanGw(); + + OutboundSMSMessageResponseBean responseBean = new OutboundSMSMessageResponseBean(); + + OutboundSMSMessageResponseBean.OutboundSMSMessageResponseGateway smsMessageResponse = new + OutboundSMSMessageResponseBean.OutboundSMSMessageResponseGateway(); + + + if (clientCorrelator != null) { + String response = checkDuplicateClientCorrelator(clientCorrelator, userId, serviceNameId, endUserId, + MessageProcessStatus.Success, MessageType.Response); + if (response != null) { + + // return already sent response + OutboundSMSMessageResponseBean obj; + obj = gson.fromJson(response, OutboundSMSMessageResponseBean.class); + responseWrapper.setOutboundSMSMessageResponseBeanGw(obj); + responseWrapper.setHttpStatus(Response.Status.OK); + return responseWrapper; + + } + } + + if(!dao.isWhiteListedSenderAddress(user.getId(), senderAddressOnly)){ + LOG.error("###SMS### sender address is not WhiteListed "); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Sender Address is not WhiteListed")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + smsMessageResponse.setResourceURL(getoutSideResourceURL(getReferenceNumber())); + smsMessageResponse.setSenderAddress(requestBean.getOutboundSMSMessageRequest().getSenderAddress()); + smsMessageResponse.setReceiptRequest(requestBean.getOutboundSMSMessageRequest().getReceiptRequest()); + smsMessageResponse.setSenderAddress(requestBean.getOutboundSMSMessageRequest().getSenderAddress()); + smsMessageResponse.setOutboundSMSTextMessage(requestBean.getOutboundSMSMessageRequest() + .getOutboundSMSTextMessage()); + smsMessageResponse.setClientCorrelator(requestBean.getOutboundSMSMessageRequest().getClientCorrelator()); + smsMessageResponse.setAddress(requestBean.getOutboundSMSMessageRequest().getAddress()); + smsMessageResponse.setSenderName(requestBean.getOutboundSMSMessageRequest().getSenderName()); + + DeliveryInfoList deliveryInfoList = new DeliveryInfoList(); + deliveryInfoList.setResourceURL(getinSideResourceURL(getReferenceNumber())); + List infoList = new ArrayList(); + + for (String s : requestBean.getOutboundSMSMessageRequest().getAddress()) { + + DeliveryInfoList.DeliveryInfo deliveryInfo = new DeliveryInfoList.DeliveryInfo(); + deliveryInfo.setAddress(s); + deliveryInfo.setDeliveryStatus(smsMessagingParam.getDeliveryStatus()); + infoList.add(deliveryInfo); + } + + deliveryInfoList.setDeliveryInfo(infoList); + smsMessageResponse.setDeliveryInfoList(deliveryInfoList); + responseBean.setOutboundSMSMessageRequest(smsMessageResponse); + + responseWrapper.setOutboundSMSMessageResponseBeanGw(responseBean); + responseWrapper.setHttpStatus(Response.Status.CREATED); + + // Save Success Response + saveResponse(endUserId, responseBean, apiServiceCalls, MessageProcessStatus.Success); + + } catch (Exception ex) { + LOG.error("###SMS### Error Occurred in SMS Service. ", ex); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + responseWrapper + .setRequestError(constructRequestError(SERVICEEXCEPTION, ServiceError.SERVICE_ERROR_OCCURED, + "Error Occurred in SMS Service.")); + } + + return responseWrapper; + + + } + + @Override + protected void init(SendMTSMSRequestWrapperDTOGateway extendedRequestDTO) throws Exception { + + responseWrapper = new SendMTSMSResponseWrapper(); + this.extendedRequestDTO = extendedRequestDTO; + resourceURL = CommonUtil.getResourceUrl(extendedRequestDTO); + + } + + + /** + * Generating inside resource URL. + * + * @param mtSMSTransactionId Unique ID + * @return URL + */ + private String getinSideResourceURL(int mtSMSTransactionId) { + + int index = resourceURL.lastIndexOf('/'); + String resourceURLs = resourceURL.substring(0, index) + "/" + (mtSMSTransactionId + 1); + return resourceURLs + "/deliveryInfos"; + } + + /** + * Genarating outside resource URL. + * + * @param mtSMSTransactionId Unique Id. + * @return URL + */ + private String getoutSideResourceURL(int mtSMSTransactionId) { + + int index = resourceURL.lastIndexOf('/'); + String resourceURLs = resourceURL.substring(0, index) + "/" + (mtSMSTransactionId + 1); + return resourceURLs; + } + + + // Save Response in messageLog table + private void saveResponse(String endUserIdPath, OutboundSMSMessageResponseBean responseBean, APIServiceCalls + apiServiceCalls, MessageProcessStatus status) throws Exception { + + Gson gson = new Gson(); + String jsonString = gson.toJson(responseBean); + + //setting messagelog responses + new MessageLog(); + MessageLog messageLog; + messageLog = new MessageLog(); + messageLog.setRequest(jsonString); + messageLog.setStatus(status.getValue()); + messageLog.setType(MessageType.Response.getValue()); + messageLog.setServicenameid(apiServiceCalls.getApiServiceCallId()); + messageLog.setUserid(extendedRequestDTO.getUser().getId()); + messageLog.setReference("msisdn"); + messageLog.setValue(endUserIdPath); + messageLog.setMessageTimestamp(new Date()); + + loggingDAO.saveMessageLog(messageLog); + } + + + private String checkDuplicateClientCorrelator(String clientCorrelator, int userId, int serviceNameId, String tel, + MessageProcessStatus status, MessageType type) throws Exception { + + List list = new ArrayList<>(); + list.add(serviceNameId); + + List response = loggingDAO.getMessageLogs(userId, list, "msisdn", tel, null, null); + + String jsonString = null; + + for (MessageLog aResponse : response) { + + int responseStatus = aResponse.getStatus(); + int responseType = aResponse.getType(); + String responseClientCorrelator = null; + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = aResponse.getRequest(); + JSONObject json = new JSONObject(request); + + if(json.getJSONObject("outboundSMSMessageRequest").has("clientCorrelator")) { + responseClientCorrelator = json.getJSONObject("outboundSMSMessageRequest").get + ("clientCorrelator").toString(); + } + int responseUserId = aResponse.getUserid(); + String responseTel = aResponse.getValue(); + + // check for duplicate clientCorrelators + if ((responseClientCorrelator != null && responseClientCorrelator.equals(clientCorrelator)) && + responseUserId == userId && responseTel.equals(tel)) { + jsonString = json.toString(); + break; + } + } + + } + return jsonString; + } + + + @Override + public String getApiServiceCalls() { + try { + return ServiceName.SendSMS.toString(); + } catch (Exception ex) { + return null; + } + } + + @Override + public String getJosonString(SendMTSMSRequestWrapperDTOGateway requestDTO) { + Gson gson = new Gson(); + return gson.toJson(requestDTO.getOutboundSMSMessageRequestBeanGw()); + } + + @Override + public String getnumber(SendMTSMSRequestWrapperDTOGateway requestDTO) { + return requestDTO.getOutboundSMSMessageRequestBeanGw().getOutboundSMSMessageRequest().getAddress().toString(); + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/StopSubscribeToDeliveryNotificationService.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/StopSubscribeToDeliveryNotificationService.java new file mode 100644 index 00000000..d53ff3b1 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/StopSubscribeToDeliveryNotificationService.java @@ -0,0 +1,142 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + +import com.wso2telco.core.dbutils.exception.ServiceError; +import com.wso2telco.dep.oneapivalidation.exceptions.CustomException; +import com.wso2telco.dep.oneapivalidation.util.Validation; +import com.wso2telco.dep.oneapivalidation.util.ValidationRule; +import com.wso2telco.services.dep.sandbox.dao.DaoFactory; +import com.wso2telco.services.dep.sandbox.dao.SMSMessagingDAO; +import com.wso2telco.services.dep.sandbox.dao.model.domain.APIServiceCalls; +import com.wso2telco.services.dep.sandbox.dao.model.domain.APITypes; +import com.wso2telco.services.dep.sandbox.dao.model.domain.MessageLog; +import com.wso2telco.services.dep.sandbox.servicefactory.*; +import com.wso2telco.services.dep.sandbox.util.RequestType; +import com.wso2telco.services.dep.sandbox.util.ServiceName; +import org.apache.commons.logging.LogFactory; + +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class StopSubscribeToDeliveryNotificationService extends + AbstractRequestHandler + implements AddressIgnorerable { + + private StopSubscriptionNotificationRequestWrapper requestWrapper; + private SMSMessagingDAO smsMessagingDAO; + private StopSubscriptionNotificationResponseWrapper responseWrapper; + private String serviceCallSMS; + + { + LOG = LogFactory.getLog(StopSubscribeToDeliveryNotificationService.class); + smsMessagingDAO = DaoFactory.getSMSMessagingDAO(); + } + + @Override + protected Returnable getResponseDTO() { + return responseWrapper; + } + + @Override + protected List getAddress() { + return null; + } + + @Override + protected void init(StopSubscriptionNotificationRequestWrapper extendedRequestDTO) throws Exception { + responseWrapper = new StopSubscriptionNotificationResponseWrapper(); + requestWrapper = extendedRequestDTO; + } + + @Override + protected boolean validate(StopSubscriptionNotificationRequestWrapper wrapperDTO) throws Exception { + + String senderAddress = requestWrapper.getSenderAddress(); + int subscriptionID = requestWrapper.getSubscriptionID(); + + List validationRulesList = new ArrayList<>(); + + try { + validationRulesList.add( + new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "senderAddress", senderAddress)); + validationRulesList.add( + new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "subscriptionID", subscriptionID)); + + ValidationRule[] validationRules = new ValidationRule[validationRulesList.size()]; + validationRules = validationRulesList.toArray(validationRules); + + Validation.checkRequestParams(validationRules); + + } catch (CustomException ex) { + LOG.error("###SUBSCRIPTION### Error in Validations. ", ex); + return false; + } + + return true; + } + + @Override + protected Returnable process(StopSubscriptionNotificationRequestWrapper extendedRequestDTO) throws Exception { + + serviceCallSMS = ServiceName.StopSubscriptionDelivery.toString(); + APITypes apiTypes = dao.getAPIType(RequestType.SMSMESSAGING.toString()); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), serviceCallSMS); + + + String senderAddress = requestWrapper.getSenderAddress(); + int subscriptionID = requestWrapper.getSubscriptionID(); + + // check for existing subscription + boolean isDelete = smsMessagingDAO.removeSubscription(subscriptionID, senderAddress); + + String deletedMessage = "Subscriber "+subscriptionID+ " removed from subscription"; + + if (isDelete) { + responseWrapper.setStatus("NO CONTENT"); + responseWrapper.setHttpStatus(Response.Status.NO_CONTENT); + saveResponse(senderAddress, deletedMessage,apiServiceCalls, extendedRequestDTO.getUser().getId(), MessageProcessStatus.Success); + } else { + LOG.error("###SUBSCRIPTION### NO Subscriber found"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.SERVICE_ERROR_OCCURED, "NO Subscriber found")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + } + + return responseWrapper; + } + + // Save Response in messageLog table + private void saveResponse(String senderAddress, String request, APIServiceCalls + apiServiceCalls, int userId, MessageProcessStatus status) throws Exception { + + new MessageLog(); + MessageLog messageLog; + messageLog = new MessageLog(); + messageLog.setRequest(request); + messageLog.setStatus(status.getValue()); + messageLog.setType(MessageType.Response.getValue()); + messageLog.setServicenameid(apiServiceCalls.getApiServiceCallId()); + messageLog.setUserid(userId); + messageLog.setReference("msisdn"); + messageLog.setValue(senderAddress); + messageLog.setMessageTimestamp(new Date()); + + loggingDAO.saveMessageLog(messageLog); + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/StopSubscriptionMessageNotificationHandler.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/StopSubscriptionMessageNotificationHandler.java new file mode 100644 index 00000000..5b945429 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/StopSubscriptionMessageNotificationHandler.java @@ -0,0 +1,148 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + + +import com.google.gson.Gson; +import com.wso2telco.core.dbutils.exception.ServiceError; +import com.wso2telco.dep.oneapivalidation.exceptions.CustomException; +import com.wso2telco.dep.oneapivalidation.util.Validation; +import com.wso2telco.dep.oneapivalidation.util.ValidationRule; +import com.wso2telco.services.dep.sandbox.dao.DaoFactory; +import com.wso2telco.services.dep.sandbox.dao.SMSMessagingDAO; +import com.wso2telco.services.dep.sandbox.dao.model.domain.APIServiceCalls; +import com.wso2telco.services.dep.sandbox.dao.model.domain.APITypes; +import com.wso2telco.services.dep.sandbox.dao.model.domain.MessageLog; +import com.wso2telco.services.dep.sandbox.servicefactory.*; +import com.wso2telco.services.dep.sandbox.util.ServiceName; +import org.apache.commons.logging.LogFactory; + +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class StopSubscriptionMessageNotificationHandler extends AbstractRequestHandler implements AddressIgnorerable { + + + private StopSubscriptionMessageNotificationRequestWrapper requestWrapper; + private StopSubscriptionMessageNotificationResponseWrapper responseWrapper; + private SMSMessagingDAO smsMessagingDAO; + + + { + LOG = LogFactory.getLog(StopSubscriptionMessageNotificationHandler.class); + smsMessagingDAO = DaoFactory.getSMSMessagingDAO(); + } + + @Override + protected Returnable getResponseDTO() { + return responseWrapper; + } + + @Override + protected List getAddress() { + return null; + } + + @Override + protected boolean validate(StopSubscriptionMessageNotificationRequestWrapper wrapperDTO) throws Exception { + + String subscriptionID = wrapperDTO.getSubscriptionID(); + + List validationRulesList = new ArrayList<>(); + + try { + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "subscriptionID", subscriptionID)); + ValidationRule[] validationRules = new ValidationRule[validationRulesList.size()]; + validationRules = validationRulesList.toArray(validationRules); + Validation.checkRequestParams(validationRules); + + } catch (CustomException ex) { + LOG.error("###SMS### Error in Validations. ", ex); + responseWrapper.setRequestError( + constructRequestError(SERVICEEXCEPTION, ex.getErrcode(), ex.getErrmsg(), ex.getErrvar()[0])); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return false; + } + return true; + } + + + @Override + protected Returnable process(StopSubscriptionMessageNotificationRequestWrapper extendedRequestDTO) throws Exception { + + if (responseWrapper.getRequestError() != null) { + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + String subscriptionID = extendedRequestDTO.getSubscriptionID(); + + APITypes apiTypes = dao.getAPIType(extendedRequestDTO.getRequestType().toString().toLowerCase()); + String serviceCallPayment = ServiceName.SubscribeToApplication.toString(); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), serviceCallPayment); + + + boolean delete = smsMessagingDAO.removeSubscriptionToMessage(subscriptionID); + if (delete) { + responseWrapper.setStatus("NO CONTENT"); + responseWrapper.setHttpStatus(Response.Status.NO_CONTENT); + + // Save Success Response + saveResponse(subscriptionID, apiServiceCalls, MessageProcessStatus.Success); + + } else { + LOG.error("###SMS SUBSCRIPTION### NO Subscriber found"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "NO Subscriber found")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + + } + return responseWrapper; + } + + @Override + protected void init(StopSubscriptionMessageNotificationRequestWrapper extendedRequestDTO) throws Exception { + + responseWrapper = new StopSubscriptionMessageNotificationResponseWrapper(); + this.requestWrapper = extendedRequestDTO; + + } + + + private void saveResponse(String subscriptionID, APIServiceCalls apiServiceCalls, MessageProcessStatus status) throws Exception { + + String jsonString = "Stop the subscription to subscriptionID: "+subscriptionID; + + //setting messagelog responses + new MessageLog(); + MessageLog messageLog; + messageLog = new MessageLog(); + messageLog.setRequest(jsonString); + messageLog.setStatus(status.getValue()); + messageLog.setType(MessageType.Response.getValue()); + messageLog.setServicenameid(apiServiceCalls.getApiServiceCallId()); + messageLog.setUserid(user.getId()); + messageLog.setReference("subscriptionID"); + messageLog.setValue(subscriptionID); + messageLog.setMessageTimestamp(new Date()); + + loggingDAO.saveMessageLog(messageLog); + } + + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/StopSubscriptionMessageNotificationRequestWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/StopSubscriptionMessageNotificationRequestWrapper.java new file mode 100644 index 00000000..f3388b5b --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/StopSubscriptionMessageNotificationRequestWrapper.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + + +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; + +public class StopSubscriptionMessageNotificationRequestWrapper extends RequestDTO { + + private String subscriptionID; + + public String getSubscriptionID() { + return subscriptionID; + } + + public void setSubscriptionID(String subscriptionID) { + this.subscriptionID = subscriptionID; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/StopSubscriptionMessageNotificationResponseWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/StopSubscriptionMessageNotificationResponseWrapper.java new file mode 100644 index 00000000..63278a29 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/StopSubscriptionMessageNotificationResponseWrapper.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + + +import com.wso2telco.services.dep.sandbox.servicefactory.AbstractReturnWrapperDTO; + +public class StopSubscriptionMessageNotificationResponseWrapper extends AbstractReturnWrapperDTO { + + private String status; + + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @Override + public Object getResponse() { + if (getRequestError() != null) { + return getRequestError(); + } + return getStatus(); + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/StopSubscriptionNotificationRequestWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/StopSubscriptionNotificationRequestWrapper.java new file mode 100644 index 00000000..b78c1fc7 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/StopSubscriptionNotificationRequestWrapper.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; + +public class StopSubscriptionNotificationRequestWrapper extends RequestDTO { + + private String senderAddress; + + private int subscriptionID; + + public String getSenderAddress() { + return senderAddress; + } + + public void setSenderAddress(String senderAddress) { + this.senderAddress = senderAddress; + } + + public int getSubscriptionID() { + return subscriptionID; + } + + public void setSubscriptionID(int subscriptionID) { + this.subscriptionID = subscriptionID; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/StopSubscriptionNotificationResponseWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/StopSubscriptionNotificationResponseWrapper.java new file mode 100644 index 00000000..63325b86 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/StopSubscriptionNotificationResponseWrapper.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + +import com.wso2telco.services.dep.sandbox.servicefactory.AbstractReturnWrapperDTO; + +public class StopSubscriptionNotificationResponseWrapper extends AbstractReturnWrapperDTO { + + private String status; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @Override + public Object getResponse() { + + if (getRequestError() != null) { + return getRequestError(); + } + return getStatus(); + } + +} + + diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeApplicationNotificationsHandler.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeApplicationNotificationsHandler.java new file mode 100644 index 00000000..23307173 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeApplicationNotificationsHandler.java @@ -0,0 +1,329 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.wso2telco.core.dbutils.exception.ServiceError; +import com.wso2telco.dep.oneapivalidation.exceptions.CustomException; +import com.wso2telco.dep.oneapivalidation.util.Validation; +import com.wso2telco.dep.oneapivalidation.util.ValidationRule; +import com.wso2telco.services.dep.sandbox.dao.DaoFactory; +import com.wso2telco.services.dep.sandbox.dao.SMSMessagingDAO; +import com.wso2telco.services.dep.sandbox.dao.model.custom.DeliveryReceiptSubscription; +import com.wso2telco.services.dep.sandbox.dao.model.domain.*; +import com.wso2telco.services.dep.sandbox.servicefactory.*; +import com.wso2telco.services.dep.sandbox.util.CommonUtil; +import com.wso2telco.services.dep.sandbox.util.ServiceName; +import org.apache.commons.logging.LogFactory; +import org.json.JSONObject; + +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +class SubscribeApplicationNotificationsHandler extends + AbstractRequestHandler implements AddressIgnorerable, + RequestResponseRequestHandleable { + + private SubscribeApplicationNotificationsResponseWrapper responseWrapper; + private SubscribeApplicationNotificationsRequestWrapperGateway requestWrapper; + private SMSMessagingDAO smsMessagingDAO; + private Gson gson = new GsonBuilder().serializeNulls().create(); + + + { + LOG = LogFactory.getLog(SubscribeApplicationNotificationsHandler.class); + smsMessagingDAO = DaoFactory.getSMSMessagingDAO(); + } + + + @Override + protected Returnable getResponseDTO() { + return responseWrapper; + } + + @Override + protected List getAddress() { + return null; + } + + @Override + protected boolean validate(SubscribeApplicationNotificationsRequestWrapperGateway wrapperDTO) throws Exception { + + SubscribeApplicationNotificationsRequestBeanGateway subscribeApplicationNotificationsRequestBean = wrapperDTO + .getSubscribeApplicationNotificationsRequestBean(); + + String callbackData = CommonUtil.getNullOrTrimmedValue(subscribeApplicationNotificationsRequestBean + .getSubscription().getCallbackReference().getCallbackData()); + String clientCorrelator = CommonUtil.getNullOrTrimmedValue(subscribeApplicationNotificationsRequestBean + .getSubscription().getClientCorrelator()); + String criteria = CommonUtil.getNullOrTrimmedValue(subscribeApplicationNotificationsRequestBean + .getSubscription().getCriteria()); + String destinationAddress = CommonUtil.getNullOrTrimmedValue(subscribeApplicationNotificationsRequestBean + .getSubscription().getDestinationAddress()); + String notificationFormat = CommonUtil.getNullOrTrimmedValue(subscribeApplicationNotificationsRequestBean + .getSubscription().getNotificationFormat()); + String notifyURL = CommonUtil.getNullOrTrimmedValue(subscribeApplicationNotificationsRequestBean + .getSubscription().getCallbackReference().getNotifyURL()); + + List validationRulesList = new ArrayList<>(); + + try { + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "callbackData", + callbackData)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "criteria", criteria)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "clientCorrelator", + clientCorrelator)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, + "destinationAddress", destinationAddress)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "notifyURL", + notifyURL)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "notificationFormat", + notificationFormat)); + + ValidationRule[] validationRules = new ValidationRule[validationRulesList.size()]; + validationRules = validationRulesList.toArray(validationRules); + + Validation.checkRequestParams(validationRules); + + } catch (CustomException ex) { + LOG.error("###SMS### Error in Validations. ", ex); + responseWrapper.setRequestError( + constructRequestError(SERVICEEXCEPTION, ex.getErrcode(), ex.getErrmsg(), ex.getErrvar()[0])); + return false; + } + return true; + } + + @Override + protected Returnable process(SubscribeApplicationNotificationsRequestWrapperGateway extendedRequestDTO) throws + Exception { + + if (responseWrapper.getRequestError() != null) { + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + try { + + User user = extendedRequestDTO.getUser(); + String clientCorrelator = CommonUtil.getNullOrTrimmedValue(extendedRequestDTO + .getSubscribeApplicationNotificationsRequestBean().getSubscription().getClientCorrelator()); + Integer userId = extendedRequestDTO.getUser().getId(); + + APITypes apiTypes = dao.getAPIType(extendedRequestDTO.getRequestType().toString().toLowerCase()); + String serviceCallPayment = ServiceName.SubscribeToApplication.toString(); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), serviceCallPayment); + int serviceNameId = apiServiceCalls.getApiServiceCallId(); + String endUserId = extendedRequestDTO.getSubscribeApplicationNotificationsRequestBean().getSubscription() + .getDestinationAddress(); + + String destinationAddress = extendedRequestDTO.getSubscribeApplicationNotificationsRequestBean() + .getSubscription().getDestinationAddress(); + String criteria = extendedRequestDTO.getSubscribeApplicationNotificationsRequestBean().getSubscription() + .getCriteria(); + String notifyURL = extendedRequestDTO.getSubscribeApplicationNotificationsRequestBean().getSubscription() + .getCallbackReference().getNotifyURL(); + String callbackData = extendedRequestDTO.getSubscribeApplicationNotificationsRequestBean() + .getSubscription().getCallbackReference().getCallbackData(); + + String notificationFormat = extendedRequestDTO.getSubscribeApplicationNotificationsRequestBean() + .getSubscription().getNotificationFormat(); + + + if (clientCorrelator != null) { + String response = checkDuplicateClientCorrelator(clientCorrelator, userId, serviceNameId, endUserId, + MessageProcessStatus.Success, MessageType.Response); + if (response != null) { + // return already sent response + SubscribeApplicationNotificationsResponseBean obj; + obj = gson.fromJson(response, SubscribeApplicationNotificationsResponseBean.class); + responseWrapper.setResponseBean(obj); + responseWrapper.setHttpStatus(Response.Status.OK); + return responseWrapper; + + } + } + + if (!dao.isWhiteListedSenderAddress(user.getId(), getLastMobileNumber(destinationAddress))) { + LOG.error("###SMS### Destination Address is not WhiteListed "); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Destination Address is not WhiteListed")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + for (int i = 0; i < user.getSubscribeSMSRequestList().size(); i++) { + + if (destinationAddress.equals(user.getSubscribeSMSRequestList().get(i).getDestinationAddress()) && + criteria.equals(user.getSubscribeSMSRequestList().get(i).getCriteria())) { + LOG.error("###SMS### Overlapped criteria "); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Overlapped criteria")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + } + + SubscribeSMSRequest subscribeSMSRequest = new SubscribeSMSRequest(); + subscribeSMSRequest.setCallbackData(callbackData); + subscribeSMSRequest.setClientCorrelator(clientCorrelator); + subscribeSMSRequest.setCriteria(criteria); + subscribeSMSRequest.setDestinationAddress(destinationAddress); + subscribeSMSRequest.setNotifyURL(notifyURL); + subscribeSMSRequest.setUser(user); + subscribeSMSRequest.setDate(new Date()); + subscribeSMSRequest.setNotificationFormat("JSON"); + Integer subsId = smsMessagingDAO.saveSubscribeSMSRequest(subscribeSMSRequest); + + String resourceURLMaker = CommonUtil.getResourceUrl(extendedRequestDTO); + int index = resourceURLMaker.lastIndexOf('/'); + String resourceURL = resourceURLMaker.substring(0, index) + "/" + subsId; + + SubscribeApplicationNotificationsResponseBean responseBean = new + SubscribeApplicationNotificationsResponseBean(); + SubscribeApplicationNotificationsResponseBean.SubscribeApplicationNotificationsResponse + applicationNotificationsResponse = new SubscribeApplicationNotificationsResponseBean + .SubscribeApplicationNotificationsResponse(); + + applicationNotificationsResponse.setClientCorrelator(clientCorrelator); + applicationNotificationsResponse.setCriteria(criteria); + applicationNotificationsResponse.setDestinationAddress(destinationAddress); + applicationNotificationsResponse.setResourceURL(resourceURL); + applicationNotificationsResponse.setNotificationFormat(notificationFormat); + + SubscribeApplicationNotificationsResponseBean.SubscribeApplicationNotificationsResponse.CallbackReference + callbackReference = new DeliveryReceiptSubscription.CallbackReference(); + callbackReference.setCallbackData(callbackData); + callbackReference.setNotifyURL(notifyURL); + + applicationNotificationsResponse.setCallbackReference(callbackReference); + + responseBean.setSubscription(applicationNotificationsResponse); + + responseWrapper.setResponseBean(responseBean); + responseWrapper.setHttpStatus(Response.Status.CREATED); + + // Save Success Response + saveResponse(endUserId, responseBean, apiServiceCalls, MessageProcessStatus.Success); + + } catch (Exception ex) { + LOG.error("###SMS### Error Occurred in Subscribe Application Notifications.", ex); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + responseWrapper + .setRequestError(constructRequestError(SERVICEEXCEPTION, ServiceError.SERVICE_ERROR_OCCURED, + "###SMS### Error Occurred in Subscribe Application Notifications.")); + } + + + return responseWrapper; + } + + @Override + protected void init(SubscribeApplicationNotificationsRequestWrapperGateway extendedRequestDTO) throws Exception { + + responseWrapper = new SubscribeApplicationNotificationsResponseWrapper(); + this.requestWrapper = extendedRequestDTO; + + } + + + private String checkDuplicateClientCorrelator(String clientCorrelator, int userId, int serviceNameId, String tel, + MessageProcessStatus status, MessageType type) throws Exception { + + List list = new ArrayList<>(); + list.add(serviceNameId); + + List response = loggingDAO.getMessageLogs(userId, list, "destinationAddress", getLastMobileNumber(tel), null, null); + + String jsonString = null; + + for (MessageLog aResponse : response) { + + int responseStatus = aResponse.getStatus(); + int responseType = aResponse.getType(); + String responseClientCorrelator = null; + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = aResponse.getRequest(); + JSONObject json = new JSONObject(request); + + if (json.getJSONObject("subscription").has("clientCorrelator")) { + + responseClientCorrelator = json.getJSONObject("subscription").get("clientCorrelator").toString(); + } + int responseUserId = aResponse.getUserid(); + String responseTel = aResponse.getValue(); + + // check for duplicate clientCorrelators + if ((responseClientCorrelator != null && responseClientCorrelator.equals(clientCorrelator)) && + responseUserId == userId && responseTel.equals(getLastMobileNumber(tel))) { + jsonString = json.toString(); + break; + } + } + + } + return jsonString; + } + + + private void saveResponse(String endUserIdPath, SubscribeApplicationNotificationsResponseBean responseBean, + APIServiceCalls + apiServiceCalls, MessageProcessStatus status) throws Exception { + + Gson gson = new Gson(); + String jsonString = gson.toJson(responseBean); + + //setting messagelog responses + new MessageLog(); + MessageLog messageLog; + messageLog = new MessageLog(); + messageLog.setRequest(jsonString); + messageLog.setStatus(status.getValue()); + messageLog.setType(MessageType.Response.getValue()); + messageLog.setServicenameid(apiServiceCalls.getApiServiceCallId()); + messageLog.setUserid(user.getId()); + messageLog.setReference("destinationAddress"); + messageLog.setValue(getLastMobileNumber(endUserIdPath)); + messageLog.setMessageTimestamp(new Date()); + + loggingDAO.saveMessageLog(messageLog); + } + + @Override + public String getApiServiceCalls() { + try { + return ServiceName.SubscribeToApplication.toString(); + } catch (Exception ex) { + return null; + } + } + + @Override + public String getJosonString(SubscribeApplicationNotificationsRequestWrapperGateway requestDTO) { + Gson gson = new Gson(); + return gson.toJson(requestDTO.getSubscribeApplicationNotificationsRequestBean()); + } + + @Override + public String getnumber(SubscribeApplicationNotificationsRequestWrapperGateway requestDTO) { + return requestDTO.getSubscribeApplicationNotificationsRequestBean().getSubscription().getDestinationAddress(); + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeApplicationNotificationsRequestBeanGateway.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeApplicationNotificationsRequestBeanGateway.java new file mode 100644 index 00000000..795590e4 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeApplicationNotificationsRequestBeanGateway.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + + +import com.wso2telco.services.dep.sandbox.dao.model.custom.DeliveryReceiptSubscription; + +public class SubscribeApplicationNotificationsRequestBeanGateway { + + private Subscription subscription; + + + public Subscription getSubscription() { + return subscription; + } + + public void setSubscription(Subscription subscription) { + this.subscription = subscription; + } + + static class Subscription extends DeliveryReceiptSubscription{ + + private String criteria; + private String destinationAddress; + private String notificationFormat; + private String clientCorrelator; + + public String getCriteria() { + return criteria; + } + + public void setCriteria(String criteria) { + this.criteria = criteria; + } + + public String getDestinationAddress() { + return destinationAddress; + } + + public void setDestinationAddress(String destinationAddress) { + this.destinationAddress = destinationAddress; + } + + public String getNotificationFormat() { + return notificationFormat; + } + + public void setNotificationFormat(String notificationFormat) { + this.notificationFormat = notificationFormat; + } + + public String getClientCorrelator() { + return clientCorrelator; + } + + public void setClientCorrelator(String clientCorrelator) { + this.clientCorrelator = clientCorrelator; + } + } + + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeApplicationNotificationsRequestWrapperGateway.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeApplicationNotificationsRequestWrapperGateway.java new file mode 100644 index 00000000..47df6c2e --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeApplicationNotificationsRequestWrapperGateway.java @@ -0,0 +1,33 @@ + +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; + +public class SubscribeApplicationNotificationsRequestWrapperGateway extends RequestDTO { + + private SubscribeApplicationNotificationsRequestBeanGateway subscribeApplicationNotificationsRequestBean; + + public SubscribeApplicationNotificationsRequestBeanGateway getSubscribeApplicationNotificationsRequestBean() { + return subscribeApplicationNotificationsRequestBean; + } + + public void setSubscribeApplicationNotificationsRequestBean(SubscribeApplicationNotificationsRequestBeanGateway + subscribeApplicationNotificationsRequestBean) { + this.subscribeApplicationNotificationsRequestBean = subscribeApplicationNotificationsRequestBean; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeApplicationNotificationsResponseBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeApplicationNotificationsResponseBean.java new file mode 100644 index 00000000..9db9b2d7 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeApplicationNotificationsResponseBean.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.wso2telco.services.dep.sandbox.dao.model.custom.DeliveryReceiptSubscription; + + class SubscribeApplicationNotificationsResponseBean { + + + private SubscribeApplicationNotificationsResponse subscription; + + public SubscribeApplicationNotificationsResponse getSubscription() { + return subscription; + } + + public void setSubscription(SubscribeApplicationNotificationsResponse subscription) { + this.subscription = subscription; + } + + @JsonInclude(value = JsonInclude.Include.NON_NULL) + public static class SubscribeApplicationNotificationsResponse extends DeliveryReceiptSubscription { + + private String criteria; + private String destinationAddress; + private String notificationFormat; + private String clientCorrelator; + private String resourceURL; + + public String getCriteria() { + return criteria; + } + + public void setCriteria(String criteria) { + this.criteria = criteria; + } + + public String getDestinationAddress() { + return destinationAddress; + } + + public void setDestinationAddress(String destinationAddress) { + this.destinationAddress = destinationAddress; + } + + public String getNotificationFormat() { + return notificationFormat; + } + + public void setNotificationFormat(String notificationFormat) { + this.notificationFormat = notificationFormat; + } + + public String getClientCorrelator() { + return clientCorrelator; + } + + public void setClientCorrelator(String clientCorrelator) { + this.clientCorrelator = clientCorrelator; + } + + public String getResourceURL() { + return resourceURL; + } + + public void setResourceURL(String resourceURL) { + this.resourceURL = resourceURL; + } + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeApplicationNotificationsResponseWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeApplicationNotificationsResponseWrapper.java new file mode 100644 index 00000000..836ed582 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeApplicationNotificationsResponseWrapper.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + +import com.wso2telco.services.dep.sandbox.dao.model.custom.ErrorResponseDTO; +import com.wso2telco.services.dep.sandbox.servicefactory.AbstractReturnWrapperDTO; + +class SubscribeApplicationNotificationsResponseWrapper extends AbstractReturnWrapperDTO { + + + private SubscribeApplicationNotificationsResponseBean responseBean; + + public SubscribeApplicationNotificationsResponseBean getResponseBean() { + return responseBean; + } + + public void setResponseBean(SubscribeApplicationNotificationsResponseBean responseBean) { + this.responseBean = responseBean; + } + + @Override + public Object getResponse() { + if (getRequestError() == null) { + return responseBean; + }else{ + ErrorResponseDTO response= new ErrorResponseDTO(getRequestError()); + return response; + } + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeToDeliveryDTO.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeToDeliveryDTO.java new file mode 100644 index 00000000..c837c691 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeToDeliveryDTO.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + +public class SubscribeToDeliveryDTO { + + private SubscribeToDeliveryNotificationResponseBean deliveryReceiptSubscription; + + public SubscribeToDeliveryNotificationResponseBean getDeliveryReceiptSubscription() { + return deliveryReceiptSubscription; + } + + public void setDeliveryReceiptSubscription(SubscribeToDeliveryNotificationResponseBean + deliveryReceiptSubscription) { + this.deliveryReceiptSubscription = deliveryReceiptSubscription; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeToDeliveryNotificationRequestBeanGateway.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeToDeliveryNotificationRequestBeanGateway.java new file mode 100644 index 00000000..f7848a77 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeToDeliveryNotificationRequestBeanGateway.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + + +import com.wso2telco.services.dep.sandbox.dao.model.custom.DeliveryReceiptSubscription; + +public class SubscribeToDeliveryNotificationRequestBeanGateway { + + private DeliveryReceiptSubscriptionBean deliveryReceiptSubscription; + + public DeliveryReceiptSubscriptionBean getDeliveryReceiptSubscription() { + return deliveryReceiptSubscription; + } + + public void setDeliveryReceiptSubscription(DeliveryReceiptSubscriptionBean deliveryReceiptSubscription) { + this.deliveryReceiptSubscription = deliveryReceiptSubscription; + } + + public static class DeliveryReceiptSubscriptionBean extends DeliveryReceiptSubscription { + + private String filterCriteria; + private String clientCorrelator; + + public String getFilterCriteria() { + return filterCriteria; + } + + public void setFilterCriteria(String filterCriteria) { + this.filterCriteria = filterCriteria; + } + + public String getClientCorrelator() { + return clientCorrelator; + } + + public void setClientCorrelator(String clientCorrelator) { + this.clientCorrelator = clientCorrelator; + } + + + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeToDeliveryNotificationResponseBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeToDeliveryNotificationResponseBean.java new file mode 100644 index 00000000..498b12d8 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeToDeliveryNotificationResponseBean.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class SubscribeToDeliveryNotificationResponseBean { + + private CallReferenceResponse callbackReference; + private String clientCorrelator; + private String filterCriteria; + private String resourceURL; + + public String getClientCorrelator() { + return clientCorrelator; + } + + public void setClientCorrelator(String clientCorrelator) { + this.clientCorrelator = clientCorrelator; + } + + public String getFilterCriteria() { + return filterCriteria; + } + + public void setFilterCriteria(String filterCriteria) { + this.filterCriteria = filterCriteria; + } + + public String getResourceURL() { + return resourceURL; + } + + public void setResourceURL(String resourceURL) { + this.resourceURL = resourceURL; + } + + public CallReferenceResponse getCallbackReference() { + return callbackReference; + } + + public void setCallbackReference(CallReferenceResponse callbackReference) { + this.callbackReference = callbackReference; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeToDeliveryNotificationResponseWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeToDeliveryNotificationResponseWrapper.java new file mode 100644 index 00000000..6b6e88b4 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeToDeliveryNotificationResponseWrapper.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + +import com.wso2telco.services.dep.sandbox.dao.model.custom.ErrorResponseDTO; +import com.wso2telco.services.dep.sandbox.servicefactory.AbstractReturnWrapperDTO; + +public class SubscribeToDeliveryNotificationResponseWrapper extends AbstractReturnWrapperDTO { + + private SubscribeToDeliveryDTO subcribeToDeliveryDTO; + + public SubscribeToDeliveryDTO getSubcribeToDeliveryDTO() { + return subcribeToDeliveryDTO; + } + + public void setSubcribeToDeliveryDTO(SubscribeToDeliveryDTO subcribeToDeliveryDTO) { + this.subcribeToDeliveryDTO = subcribeToDeliveryDTO; + } + + @Override + public Object getResponse() { + if (getRequestError() == null) { + return subcribeToDeliveryDTO; + } else { + ErrorResponseDTO response = new ErrorResponseDTO(getRequestError()); + return response; + + } + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeToDeliveryNotificationService.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeToDeliveryNotificationService.java new file mode 100644 index 00000000..2a9acbe9 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeToDeliveryNotificationService.java @@ -0,0 +1,274 @@ +package com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.wso2telco.dep.oneapivalidation.exceptions.CustomException; +import com.wso2telco.dep.oneapivalidation.util.Validation; +import com.wso2telco.dep.oneapivalidation.util.ValidationRule; +import com.wso2telco.services.dep.sandbox.dao.DaoFactory; +import com.wso2telco.services.dep.sandbox.dao.SMSMessagingDAO; +import com.wso2telco.services.dep.sandbox.dao.model.custom.DeliveryReceiptSubscription; +import com.wso2telco.services.dep.sandbox.dao.model.domain.APIServiceCalls; +import com.wso2telco.services.dep.sandbox.dao.model.domain.APITypes; +import com.wso2telco.services.dep.sandbox.dao.model.domain.MessageLog; +import com.wso2telco.services.dep.sandbox.dao.model.domain.User; +import com.wso2telco.services.dep.sandbox.servicefactory.*; +import com.wso2telco.services.dep.sandbox.util.CommonUtil; +import com.wso2telco.services.dep.sandbox.util.RequestType; +import com.wso2telco.services.dep.sandbox.util.ServiceName; +import org.apache.commons.logging.LogFactory; +import org.json.JSONObject; + +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +class SubscribeToDeliveryNotificationService extends + AbstractRequestHandler implements AddressIgnorerable, + RequestResponseRequestHandleable { + + private SMSMessagingDAO smsMessagingDAO; + private SubscribeToDeliveryNotificationWrapperDTOGateway requestWrapperDTOGateway; + private SubscribeToDeliveryNotificationResponseWrapper responseWrapper; + private String serviceCallSMS; + private String jsonRequest; + private static final int SUBSCRIPTION_STATUS = 1; + + { + LOG = LogFactory.getLog(SubscribeToDeliveryNotificationService.class); + smsMessagingDAO = DaoFactory.getSMSMessagingDAO(); + } + + @Override + protected Returnable getResponseDTO() { + return responseWrapper; + } + + @Override + protected List getAddress() { + return null; + } + + @Override + protected void init(SubscribeToDeliveryNotificationWrapperDTOGateway extendedRequestDTO) throws Exception { + responseWrapper = new SubscribeToDeliveryNotificationResponseWrapper(); + requestWrapperDTOGateway = extendedRequestDTO; + } + + @Override + protected boolean validate(SubscribeToDeliveryNotificationWrapperDTOGateway wrapperDTO) throws Exception { + SubscribeToDeliveryNotificationRequestBeanGateway requestBean = wrapperDTO + .getSubscribeToDeliveryNotificationRequestBeanGateway(); + SubscribeToDeliveryNotificationRequestBeanGateway.DeliveryReceiptSubscriptionBean request = requestBean + .getDeliveryReceiptSubscription(); + DeliveryReceiptSubscription.CallbackReference callbackReference = request.getCallbackReference(); + + String clientCorrelator = CommonUtil.getNullOrTrimmedValue(request.getClientCorrelator()); + String filterCriteria = CommonUtil.getNullOrTrimmedValue(request.getFilterCriteria()); + String callbackData = CommonUtil.getNullOrTrimmedValue(callbackReference.getCallbackData()); + String notifyURL = CommonUtil.getNullOrTrimmedValue(callbackReference.getNotifyURL()); + + List validationRulesList = new ArrayList<>(); + + try { + + validationRulesList.add( + new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "clientCorrelator", clientCorrelator)); + validationRulesList.add( + new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "filterCriteria", filterCriteria)); + validationRulesList.add( + new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "callbackData", callbackData)); + validationRulesList.add( + new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "notifyURL", notifyURL)); + + ValidationRule[] validationRules = new ValidationRule[validationRulesList.size()]; + validationRules = validationRulesList.toArray(validationRules); + + Validation.checkRequestParams(validationRules); + + } catch (CustomException ex) { + LOG.error("###SMS SUBSCRIPTION### Error in Validations. ", ex); + responseWrapper.setRequestError( + constructRequestError(SERVICEEXCEPTION, ex.getErrcode(), ex.getErrmsg(), ex.getErrvar()[0])); + return false; + } + + return true; + } + + @Override + protected Returnable process(SubscribeToDeliveryNotificationWrapperDTOGateway extendedRequestDTO) throws Exception { + if (responseWrapper.getRequestError() != null) { + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + SubscribeToDeliveryNotificationRequestBeanGateway requestBean = extendedRequestDTO + .getSubscribeToDeliveryNotificationRequestBeanGateway(); + SubscribeToDeliveryNotificationRequestBeanGateway.DeliveryReceiptSubscriptionBean request = requestBean + .getDeliveryReceiptSubscription(); + DeliveryReceiptSubscription.CallbackReference callbackReference = request.getCallbackReference(); + + serviceCallSMS = ServiceName.SubscribeToSMSDelivery.toString(); + APITypes apiTypes = dao.getAPIType(RequestType.SMSMESSAGING.toString()); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), serviceCallSMS); + + Gson gson = new Gson(); + + jsonRequest = gson.toJson(requestBean); + + int serviceNameId = apiServiceCalls.getApiServiceCallId(); + + String clientCorrelator = CommonUtil.getNullOrTrimmedValue(request.getClientCorrelator()); + String senderAddress = requestWrapperDTOGateway.getSenderAddress(); + String filterCriteria = CommonUtil.getNullOrTrimmedValue(request.getFilterCriteria()); + String callbackData = CommonUtil.getNullOrTrimmedValue(callbackReference.getCallbackData()); + String notifyURL = CommonUtil.getNullOrTrimmedValue(callbackReference.getNotifyURL()); + User user = extendedRequestDTO.getUser(); + Integer userId = extendedRequestDTO.getUser().getId(); + + if (clientCorrelator != null) { + + String response = checkDuplicateClientCorrelator(clientCorrelator, userId, serviceNameId, senderAddress, + MessageProcessStatus.Success, MessageType.Response); + + if (response != null) { + // send already saved response + SubscribeToDeliveryNotificationResponseBean object = null; + object = gson.fromJson(response, SubscribeToDeliveryNotificationResponseBean.class); + SubscribeToDeliveryDTO dto = new SubscribeToDeliveryDTO(); + dto.setDeliveryReceiptSubscription(object); + responseWrapper.setSubcribeToDeliveryDTO(dto); + responseWrapper.setHttpStatus(Response.Status.OK); + return responseWrapper; + + } + } + + SubscribeToDeliveryNotificationResponseBean responseBean = new SubscribeToDeliveryNotificationResponseBean(); + CallReferenceResponse response = new CallReferenceResponse(); + + responseBean.setClientCorrelator(clientCorrelator); + responseBean.setFilterCriteria(filterCriteria); + responseBean.setResourceURL(CommonUtil.getResourceUrl(extendedRequestDTO)); + response.setCallbackData(callbackData); + response.setNotifyURL(notifyURL); + + responseWrapper.setHttpStatus(Response.Status.CREATED); + SubscribeToDeliveryDTO dto = new SubscribeToDeliveryDTO(); + dto.setDeliveryReceiptSubscription(responseBean); + response.setNotifyURL(notifyURL); + response.setCallbackData(callbackData); + responseBean.setCallbackReference(response); + responseWrapper.setSubcribeToDeliveryDTO(dto); + + SubscribeToDeliveryDTO toDeliveryDTO = new SubscribeToDeliveryDTO(); + toDeliveryDTO.setDeliveryReceiptSubscription(responseBean); + + if (smsMessagingDAO.isSubscriptionExists(filterCriteria, notifyURL, callbackData, clientCorrelator)) { + + String resp = gson.toJson(responseBean); + + SubscribeToDeliveryNotificationResponseBean object = null; + + object = gson.fromJson(resp, SubscribeToDeliveryNotificationResponseBean.class); + SubscribeToDeliveryDTO dto1 = new SubscribeToDeliveryDTO(); + dto1.setDeliveryReceiptSubscription(object); + responseWrapper.setSubcribeToDeliveryDTO(dto); + responseWrapper.setHttpStatus(Response.Status.CREATED); + return responseWrapper; + } else { + smsMessagingDAO.saveDeliverySubscription(user, senderAddress, SUBSCRIPTION_STATUS, notifyURL, + filterCriteria, + callbackData, clientCorrelator, jsonRequest); + saveResponse(userId, senderAddress, responseBean, apiServiceCalls, MessageProcessStatus.Success); + } + + return responseWrapper; + } + + private void saveResponse(Integer userId, String senderAddress, SubscribeToDeliveryNotificationResponseBean + responseBean, APIServiceCalls apiServiceCalls, MessageProcessStatus status) throws Exception { + + String jsonInString = null; + Gson resp = new Gson(); + + JsonElement je = new JsonParser().parse(resp.toJson(responseBean)); + JsonObject asJsonObject = je.getAsJsonObject(); + jsonInString = asJsonObject.toString(); + + MessageLog messageLog = new MessageLog(); + messageLog = new MessageLog(); + messageLog.setRequest(jsonInString); + messageLog.setStatus(status.getValue()); + messageLog.setType(MessageType.Response.getValue()); + messageLog.setServicenameid(apiServiceCalls.getApiServiceCallId()); + messageLog.setUserid(userId); + messageLog.setReference("senderAddress"); + messageLog.setValue(getLastMobileNumber(senderAddress)); + messageLog.setMessageTimestamp(new Date()); + + loggingDAO.saveMessageLog(messageLog); + } + + private String checkDuplicateClientCorrelator(String clientCorrelator, int userId, int serviceNameId, String + senderAddress, MessageProcessStatus status, MessageType type) throws Exception { + + List list = new ArrayList<>(); + list.add(serviceNameId); + List response = loggingDAO.getMessageLogs(userId, list, "senderAddress", getLastMobileNumber(senderAddress), null, null); + + String jsonString = null; + + for (int i = 0; i < response.size(); i++) { + + if (response != null) { + + int responseStatus = response.get(i).getStatus(); + int responseType = response.get(i).getType(); + String responseClientCorrelator; + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = response.get(i).getRequest(); + JSONObject json = new JSONObject(request); + + responseClientCorrelator = null; + + if (json.has("clientCorrelator")) { + responseClientCorrelator = json.get("clientCorrelator").toString(); + } + + int responseUserId = response.get(i).getUserid(); + + // Check client correlator + if ((responseClientCorrelator != null && responseClientCorrelator.equals(clientCorrelator)) && + responseUserId == userId) { + jsonString = json.toString(); + break; + } + } + + } + } + return jsonString; + } + + @Override + public String getApiServiceCalls() { + return ServiceName.SubscribeToSMSDelivery.toString(); + } + + @Override + public String getJosonString(SubscribeToDeliveryNotificationWrapperDTOGateway requestDTO) { + Gson gson = new Gson(); + return gson.toJson(requestDTO.getSubscribeToDeliveryNotificationRequestBeanGateway()); + } + + @Override + public String getnumber(SubscribeToDeliveryNotificationWrapperDTOGateway requestDTO) { + return requestDTO.getSenderAddress(); + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeToDeliveryNotificationWrapperDTOGateway.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeToDeliveryNotificationWrapperDTOGateway.java new file mode 100644 index 00000000..3eee2d09 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/gateway/SubscribeToDeliveryNotificationWrapperDTOGateway.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.gateway; + +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; + +public class SubscribeToDeliveryNotificationWrapperDTOGateway extends RequestDTO{ + + private static final long serialVersionUID = 796868921376883562L; + private String senderAddress; + private SubscribeToDeliveryNotificationRequestBeanGateway subscribeToDeliveryNotificationRequestBeanGateway; + + public String getSenderAddress() { + return senderAddress; + } + + public void setSenderAddress(String senderAddress) { + this.senderAddress = senderAddress; + } + + public SubscribeToDeliveryNotificationRequestBeanGateway getSubscribeToDeliveryNotificationRequestBeanGateway() { + return subscribeToDeliveryNotificationRequestBeanGateway; + } + + public void setSubscribeToDeliveryNotificationRequestBeanGateway + (SubscribeToDeliveryNotificationRequestBeanGateway subscribeToDeliveryNotificationRequestBeanGateway) { + this.subscribeToDeliveryNotificationRequestBeanGateway = subscribeToDeliveryNotificationRequestBeanGateway; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/hub/OutboundSMSMessageResponseBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/hub/OutboundSMSMessageResponseBean.java new file mode 100644 index 00000000..c8652226 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/hub/OutboundSMSMessageResponseBean.java @@ -0,0 +1,54 @@ +package com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.hub; + +import com.wso2telco.services.dep.sandbox.dao.model.custom.DeliveryInfoList; +import com.wso2telco.services.dep.sandbox.dao.model.custom.OutboundSMSMessageRequest; +import com.wso2telco.services.dep.sandbox.dao.model.custom.SenderDetails; + +import java.util.ArrayList; +import java.util.List; + + class OutboundSMSMessageResponseBean { + + private OutboundSMSMessageResponse outboundSMSMessageRequest; + + public OutboundSMSMessageResponse getOutboundSMSMessageRequest() { + return outboundSMSMessageRequest; + } + + public void setOutboundSMSMessageRequest(OutboundSMSMessageResponse outboundSMSMessageResponse) { + this.outboundSMSMessageRequest = outboundSMSMessageResponse; + } + + static class OutboundSMSMessageResponse extends OutboundSMSMessageRequest { + + + private DeliveryInfoList deliveryInfoList; + private List senderAddress; + private String resourceURL; + + + public DeliveryInfoList getDeliveryInfoList() { + return deliveryInfoList; + } + + public void setDeliveryInfoList(DeliveryInfoList deliveryInfoList) { + this.deliveryInfoList = deliveryInfoList; + } + + public List getSenderAddress() { + return senderAddress; + } + + public void setSenderAddress(List senderAddress) { + this.senderAddress = senderAddress; + } + + public String getResourceURL() { + return resourceURL; + } + + public void setResourceURL(String resourceURL) { + this.resourceURL = resourceURL; + } + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/hub/SMSRequestFactoryHub.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/hub/SMSRequestFactoryHub.java new file mode 100644 index 00000000..9d581e77 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/hub/SMSRequestFactoryHub.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.hub; + +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + + public class SMSRequestFactoryHub { + + private static Log LOG = LogFactory.getLog(SMSRequestFactoryHub.class); + + public static RequestHandleable getInstance(final RequestDTO requestDTO) { + + final String QUERY_DELIVERY_STATUS = "deliveryInfos"; + final String SEND_MT_SMS = "requests"; + final String RETRIVE_SMS = "registrations"; + final String OUTBOUND_REQUEST = "outbound"; + final String INBOUND_REQUEST = "inbound"; + + + if (requestDTO.getRequestPath().toLowerCase().contains(SEND_MT_SMS) + && requestDTO.isPost()) { + LOG.debug("LOADING SEND MT SMS SERVICE"); + + return new SendMTSMSService(); + } + + else { + return null; + } + + } + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/hub/SendMTSMSResponseWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/hub/SendMTSMSResponseWrapper.java new file mode 100644 index 00000000..bf7f9ece --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/hub/SendMTSMSResponseWrapper.java @@ -0,0 +1,33 @@ +package com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.hub; + +import com.wso2telco.services.dep.sandbox.dao.model.custom.ErrorResponseDTO; +import com.wso2telco.services.dep.sandbox.servicefactory.AbstractReturnWrapperDTO; + + class SendMTSMSResponseWrapper extends AbstractReturnWrapperDTO { + + private OutboundSMSMessageResponseBean outboundSMSMessageResponseBeanHub; + + public OutboundSMSMessageResponseBean getOutboundSMSMessageResponseBeanHub() { + return outboundSMSMessageResponseBeanHub; + } + + public void setOutboundSMSMessageResponseBeanHub(OutboundSMSMessageResponseBean outboundSMSMessageResponseBeanHub) { + this.outboundSMSMessageResponseBeanHub = outboundSMSMessageResponseBeanHub; + } + + @Override + public Object getResponse() { + + + if (getRequestError() == null) { + return outboundSMSMessageResponseBeanHub; + }else{ + ErrorResponseDTO response= new ErrorResponseDTO(getRequestError()); + return response; + } + + } + + + } + diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/hub/SendMTSMSService.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/hub/SendMTSMSService.java new file mode 100644 index 00000000..09c0a3d7 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/hub/SendMTSMSService.java @@ -0,0 +1,306 @@ +package com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.hub; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import com.google.gson.*; +import com.wso2telco.core.dbutils.exception.ServiceError; +import com.wso2telco.dep.oneapivalidation.exceptions.CustomException; +import com.wso2telco.dep.oneapivalidation.util.Validation; +import com.wso2telco.dep.oneapivalidation.util.ValidationRule; +import com.wso2telco.services.dep.sandbox.dao.model.custom.*; +import com.wso2telco.services.dep.sandbox.dao.model.domain.*; +import com.wso2telco.services.dep.sandbox.servicefactory.*; +import com.wso2telco.services.dep.sandbox.util.CommonUtil; +import com.wso2telco.services.dep.sandbox.util.ServiceName; +import org.apache.commons.logging.LogFactory; +import com.wso2telco.services.dep.sandbox.dao.DaoFactory; +import com.wso2telco.services.dep.sandbox.dao.SMSMessagingDAO; +import org.json.JSONObject; + + class SendMTSMSService extends AbstractRequestHandler implements + RequestResponseRequestHandleable { + + private Gson gson = new GsonBuilder().serializeNulls().create(); + private sendMTSMSRequestWrapperDTOHub extendedRequestDTO; + private SendMTSMSResponseWrapper responseWrapper; + private SMSMessagingDAO smsMessagingDAO; + + { + LOG = LogFactory.getLog(SendMTSMSService.class); + smsMessagingDAO = DaoFactory.getSMSMessagingDAO(); + } + + + @Override + protected Returnable getResponseDTO() { + + return responseWrapper; + } + + @Override + protected List getAddress() { + + List addresses; + addresses = extendedRequestDTO.getOutboundSMSMessageRequestBean().getOutboundSMSMessageRequest().getAddress(); + return addresses; + } + + @Override + protected void init(sendMTSMSRequestWrapperDTOHub extendedRequestDTO) throws Exception { + + responseWrapper = new SendMTSMSResponseWrapper(); + this.extendedRequestDTO = extendedRequestDTO; + } + + + @Override + protected boolean validate(sendMTSMSRequestWrapperDTOHub wrapperDTO) throws Exception { + + outboundSMSMessageRequestBeanHub outboundSMSMessageRequestBean_hub = wrapperDTO + .getOutboundSMSMessageRequestBean(); + + String address = CommonUtil.getNullOrTrimmedValue(outboundSMSMessageRequestBean_hub + .getOutboundSMSMessageRequest().getAddress().toString()); + String callBackData = CommonUtil.getNullOrTrimmedValue(outboundSMSMessageRequestBean_hub + .getOutboundSMSMessageRequest().getReceiptRequest().getCallbackData()); + String clientCorrelator = CommonUtil.getNullOrTrimmedValue(outboundSMSMessageRequestBean_hub + .getOutboundSMSMessageRequest().getClientCorrelator()); + String message = CommonUtil.getNullOrTrimmedValue(outboundSMSMessageRequestBean_hub + .getOutboundSMSMessageRequest().getOutboundSMSTextMessage().getMessage()); + String notifyURL = CommonUtil.getNullOrTrimmedValue(outboundSMSMessageRequestBean_hub + .getOutboundSMSMessageRequest().getReceiptRequest().getNotifyURL()); + + + List validationRulesList = new ArrayList<>(); + + try { + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "address", address)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "callBackData", + callBackData)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "clientCorrelator", + clientCorrelator)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "message", message)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, "notifyURL", + notifyURL)); + + ValidationRule[] validationRules = new ValidationRule[validationRulesList.size()]; + validationRules = validationRulesList.toArray(validationRules); + + Validation.checkRequestParams(validationRules); + + } catch (CustomException ex) { + LOG.error("###SMS### Error in Validations. ", ex); + responseWrapper.setRequestError( + constructRequestError(SERVICEEXCEPTION, ex.getErrcode(), ex.getErrmsg(), ex.getErrvar()[0])); + return false; + } + return true; + } + + + @Override + protected Returnable process(sendMTSMSRequestWrapperDTOHub extendedRequestDTO) throws Exception { + + try { + User user = extendedRequestDTO.getUser(); + SMSMessagingParam smsMessagingParam = smsMessagingDAO.getSMSMessagingParam(user.getId()); + APITypes apiTypes = dao.getAPIType(extendedRequestDTO.getRequestType().toString().toLowerCase()); + String serviceCallPayment = ServiceName.SendSMS.toString(); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), serviceCallPayment); + String clientCorrelator = CommonUtil.getNullOrTrimmedValue(extendedRequestDTO + .getOutboundSMSMessageRequestBean().getOutboundSMSMessageRequest().getClientCorrelator()); + Integer userId = extendedRequestDTO.getUser().getId(); + int serviceNameId = apiServiceCalls.getApiServiceCallId(); + String endUserId = extendedRequestDTO.getOutboundSMSMessageRequestBean().getOutboundSMSMessageRequest() + .getAddress().toString(); + + outboundSMSMessageRequestBeanHub requestBean = extendedRequestDTO.getOutboundSMSMessageRequestBean(); + + OutboundSMSMessageResponseBean responseBean = new OutboundSMSMessageResponseBean(); + + OutboundSMSMessageResponseBean.OutboundSMSMessageResponse smsMessageResponse = new + OutboundSMSMessageResponseBean.OutboundSMSMessageResponse(); + + + if (clientCorrelator != null) { + String response = checkDuplicateClientCorrelator(clientCorrelator, userId, serviceNameId, endUserId, + MessageProcessStatus.Success, MessageType.Response); + if (response != null) { + + // return already sent response + OutboundSMSMessageResponseBean obj; + obj = gson.fromJson(response, OutboundSMSMessageResponseBean.class); + responseWrapper.setOutboundSMSMessageResponseBeanHub(obj); + responseWrapper.setHttpStatus(Response.Status.OK); + return responseWrapper; + + } + } + + smsMessageResponse.setResourceURL(getoutSideResourceURL(Integer.toString(getReferenceNumber()))); + smsMessageResponse.setSenderAddress(requestBean.getOutboundSMSMessageRequest().getSenderAddress()); + smsMessageResponse.setReceiptRequest(requestBean.getOutboundSMSMessageRequest().getReceiptRequest()); + smsMessageResponse.setSenderAddress(requestBean.getOutboundSMSMessageRequest().getSenderAddress()); + smsMessageResponse.setOutboundSMSTextMessage(requestBean.getOutboundSMSMessageRequest() + .getOutboundSMSTextMessage()); + smsMessageResponse.setClientCorrelator(requestBean.getOutboundSMSMessageRequest().getClientCorrelator()); + smsMessageResponse.setAddress(requestBean.getOutboundSMSMessageRequest().getAddress()); + + DeliveryInfoList deliveryInfoList = new DeliveryInfoList(); + deliveryInfoList.setResourceURL(getinSideResourceURL(Integer.toString(getReferenceNumber()))); + List infoList = new ArrayList(); + + for (String s : requestBean.getOutboundSMSMessageRequest().getAddress()) { + + DeliveryInfoList.DeliveryInfo deliveryInfo = new DeliveryInfoList.DeliveryInfo(); + deliveryInfo.setAddress(s); + deliveryInfo.setDeliveryStatus(smsMessagingParam.getDeliveryStatus()); + infoList.add(deliveryInfo); + } + + deliveryInfoList.setDeliveryInfo(infoList); + smsMessageResponse.setDeliveryInfoList(deliveryInfoList); + responseBean.setOutboundSMSMessageRequest(smsMessageResponse); + + responseWrapper.setOutboundSMSMessageResponseBeanHub(responseBean); + responseWrapper.setHttpStatus(Status.CREATED); + + // Save Success Response + saveResponse(endUserId, responseBean, apiServiceCalls, MessageProcessStatus.Success); + + } catch (Exception ex) { + LOG.error("###SMS### Error Occurred in SMS Service. ", ex); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + responseWrapper + .setRequestError(constructRequestError(SERVICEEXCEPTION, ServiceError.SERVICE_ERROR_OCCURED, + "Error Occurred in SMS Service.")); + } + + return responseWrapper; + } + + /** + * Generating inside resource URL. + * + * @param mtSMSTransactionId Unique ID + * @return URL + */ + private String getinSideResourceURL(final String mtSMSTransactionId) { + + return "http://wso2telco.sandbox.com" + + "/smsmessaging/" + + extendedRequestDTO.getApiVersion() + + "/outbound/" + + extendedRequestDTO.getShortCode() + + "/requests/" + + mtSMSTransactionId + + "/deliveryInfos"; + } + + /** + * Genarating outside resource URL. + * + * @param mtSMSTransactionId Unique Id. + * @return URL + */ + private String getoutSideResourceURL(final String mtSMSTransactionId) { + + return "http://wso2telco.sandbox.com" + + "/smsmessaging/" + + extendedRequestDTO.getApiVersion() + + "/outbound/" + + extendedRequestDTO.getShortCode() + + "/requests/" + + mtSMSTransactionId; + } + + + // Save Response in messageLog table + private void saveResponse(String endUserIdPath, OutboundSMSMessageResponseBean responseBean, APIServiceCalls + apiServiceCalls, MessageProcessStatus status) throws Exception { + + Gson gson = new Gson(); + String jsonString = gson.toJson(responseBean); + + //setting messagelog responses + new MessageLog(); + MessageLog messageLog; + messageLog = new MessageLog(); + messageLog.setRequest(jsonString); + messageLog.setStatus(status.getValue()); + messageLog.setType(MessageType.Response.getValue()); + messageLog.setServicenameid(apiServiceCalls.getApiServiceCallId()); + messageLog.setUserid(extendedRequestDTO.getUser().getId()); + messageLog.setReference("msisdn"); + messageLog.setValue(endUserIdPath); + messageLog.setMessageTimestamp(new Date()); + + loggingDAO.saveMessageLog(messageLog); + } + + + private String checkDuplicateClientCorrelator(String clientCorrelator, int userId, int serviceNameId, String tel, + MessageProcessStatus status, MessageType type) throws Exception { + + List list = new ArrayList<>(); + list.add(serviceNameId); + + List response = loggingDAO.getMessageLogs(userId, list, "msisdn", tel, null, null); + + String jsonString = null; + + for (MessageLog aResponse : response) { + + int responseStatus = aResponse.getStatus(); + int responseType = aResponse.getType(); + String responseClientCorrelator; + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = aResponse.getRequest(); + JSONObject json = new JSONObject(request); + + responseClientCorrelator = json.getJSONObject("outboundSMSMessageRequest").get + ("clientCorrelator").toString(); + + int responseUserId = aResponse.getUserid(); + String responseTel = aResponse.getValue(); + + // check for duplicate clientCorrelators + if ((responseClientCorrelator != null && responseClientCorrelator.equals(clientCorrelator)) && + responseUserId == userId && responseTel.equals(tel)) { + jsonString = json.toString(); + break; + } + } + + + } + + return jsonString; + + } + + + @Override + public String getApiServiceCalls() { + try { + return ServiceName.SendSMS.toString(); + } catch (Exception ex) { + return null; + } + } + + @Override + public String getJosonString(sendMTSMSRequestWrapperDTOHub requestDTO) { + Gson gson = new Gson(); + return gson.toJson(requestDTO.getOutboundSMSMessageRequestBean()); + } + + @Override + public String getnumber(sendMTSMSRequestWrapperDTOHub requestDTO) { + return requestDTO.getOutboundSMSMessageRequestBean().getOutboundSMSMessageRequest().getAddress().toString(); + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/hub/outboundSMSMessageRequestBeanHub.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/hub/outboundSMSMessageRequestBeanHub.java new file mode 100644 index 00000000..915e4410 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/hub/outboundSMSMessageRequestBeanHub.java @@ -0,0 +1,34 @@ +package com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.hub; + +import com.wso2telco.services.dep.sandbox.dao.model.custom.OutboundSMSMessageRequest; +import com.wso2telco.services.dep.sandbox.dao.model.custom.SenderDetails; + +import java.util.ArrayList; +import java.util.List; + +public class outboundSMSMessageRequestBeanHub { + + private OutboundSMSMessageRequest_Hub outboundSMSMessageRequest; + + public OutboundSMSMessageRequest_Hub getOutboundSMSMessageRequest() { + return outboundSMSMessageRequest; + } + + public void setOutboundSMSMessageRequest(OutboundSMSMessageRequest_Hub outboundSMSMessageRequestHub) { + this.outboundSMSMessageRequest = outboundSMSMessageRequestHub; + } + + public class OutboundSMSMessageRequest_Hub extends OutboundSMSMessageRequest { + + + private List senderAddress; + + public List getSenderAddress() { + return senderAddress; + } + + public void setSenderAddress(List senderAddress) { + this.senderAddress = senderAddress; + } + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/hub/sendMTSMSRequestWrapperDTOHub.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/hub/sendMTSMSRequestWrapperDTOHub.java new file mode 100644 index 00000000..618336a7 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/smsmessaging/hub/sendMTSMSRequestWrapperDTOHub.java @@ -0,0 +1,26 @@ +package com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.hub; + +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; + +public class sendMTSMSRequestWrapperDTOHub extends RequestDTO { + + private static final long serialVersionUID = 796868921376883562L; + private String shortCode; + private com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.hub.outboundSMSMessageRequestBeanHub outboundSMSMessageRequestBeanHub; + + public String getShortCode() { + return shortCode; + } + + public void setShortCode(String shortCode) { + this.shortCode = shortCode; + } + + public com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.hub.outboundSMSMessageRequestBeanHub getOutboundSMSMessageRequestBean() { + return outboundSMSMessageRequestBeanHub; + } + + public void setOutboundSMSMessageRequestBean(com.wso2telco.services.dep.sandbox.servicefactory.smsmessaging.hub.outboundSMSMessageRequestBeanHub outboundSMSMessageRequestBeanHub) { + this.outboundSMSMessageRequestBeanHub = outboundSMSMessageRequestBeanHub; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/user/ManageNumberServiceHandler.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/user/ManageNumberServiceHandler.java index a25e6c02..de835885 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/user/ManageNumberServiceHandler.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/user/ManageNumberServiceHandler.java @@ -107,6 +107,10 @@ protected Returnable process(ManageNumberRequestWrapperDTO extendedRequestDTO) t manageNumber.setIMSI(extendedRequestDTO.getManageNumberRequest().getImsi()); manageNumber.setMCC(extendedRequestDTO.getManageNumberRequest().getMcc()); manageNumber.setMNC(extendedRequestDTO.getManageNumberRequest().getMnc()); + manageNumber.setAltitude(extendedRequestDTO.getManageNumberRequest().getAltitude()); + manageNumber.setLatitude(extendedRequestDTO.getManageNumberRequest().getLatitude()); + manageNumber.setLongitude(extendedRequestDTO.getManageNumberRequest().getLongitude()); + manageNumber.setLocationRetrieveStatus(extendedRequestDTO.getManageNumberRequest().getLocationRetrieveStatus()); numberDAO.saveManageNumbers(manageNumber); responseWrapper.setHttpStatus(Response.Status.CREATED); responseWrapper.setStatus("Successful"); diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/InitiateUSSDSessionRequestHandler.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/InitiateUSSDSessionRequestHandler.java new file mode 100644 index 00000000..39b730e2 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/InitiateUSSDSessionRequestHandler.java @@ -0,0 +1,335 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.ussd; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.wso2telco.core.dbutils.exception.ServiceError; +import com.wso2telco.dep.oneapivalidation.exceptions.CustomException; +import com.wso2telco.dep.oneapivalidation.util.Validation; +import com.wso2telco.dep.oneapivalidation.util.ValidationRule; +import com.wso2telco.services.dep.sandbox.dao.DaoFactory; +import com.wso2telco.services.dep.sandbox.dao.USSDDAO; +import com.wso2telco.services.dep.sandbox.dao.model.custom.*; +import com.wso2telco.services.dep.sandbox.dao.model.domain.APIServiceCalls; +import com.wso2telco.services.dep.sandbox.dao.model.domain.APITypes; +import com.wso2telco.services.dep.sandbox.dao.model.domain.MessageLog; +import com.wso2telco.services.dep.sandbox.dao.model.domain.UssdApplication; +import com.wso2telco.services.dep.sandbox.servicefactory.*; +import com.wso2telco.services.dep.sandbox.util.CommonUtil; +import com.wso2telco.services.dep.sandbox.util.RequestType; +import com.wso2telco.services.dep.sandbox.util.ServiceName; +import org.apache.commons.logging.LogFactory; +import org.json.JSONObject; + +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class InitiateUSSDSessionRequestHandler extends AbstractRequestHandler + implements RequestResponseRequestHandleable { + + private USSDSessionRequestWrapperDTO requestWrapperDTO; + private USSDSessionResponseWrapper responseWrapper; + private USSDDAO ussdDAO; + private String serviceCallUSSD; + private static final String DELIVERY_STATUS = "SENT"; + + { + LOG = LogFactory.getLog(InitiateUSSDSessionRequestHandler.class); + ussdDAO = DaoFactory.getUSSDDAO(); + } + + @Override + protected Returnable getResponseDTO() { + return responseWrapper; + } + + @Override + protected List getAddress() { + List address = new ArrayList<>(); + address.add(requestWrapperDTO.getEndUserId()); + return address; + } + + @Override + protected void init(USSDSessionRequestWrapperDTO extendedRequestDTO) throws Exception { + responseWrapper = new USSDSessionResponseWrapper(); + requestWrapperDTO = extendedRequestDTO; + } + + @Override + protected boolean validate(USSDSessionRequestWrapperDTO wrapperDTO) throws Exception { + + USSDSessionInitiatorRequestBean requestBean = wrapperDTO.getUssdSessionRequestBean(); + USSDSessionInitiatorRequestBean.OutboundUSSDMessageRequest request = requestBean + .getOutboundUSSDMessageRequest(); + USSDSessionResponseRequest responseRequest = request.getResponseRequest(); + + String address = CommonUtil.getNullOrTrimmedValue(request.getAddress()); + String shortCode = CommonUtil.getNullOrTrimmedValue(request.getShortCode()); + String keyword = CommonUtil.getNullOrTrimmedValue(request.getKeyword()); + String clientCorrelator = CommonUtil.getNullOrTrimmedValue(request.getClientCorrelator()); + String endUserId = CommonUtil.getNullOrTrimmedValue(wrapperDTO.getEndUserId()); + String outboundUSSDMessage = CommonUtil.getNullOrTrimmedValue(request.getOutboundUSSDMessage()); + String notifyURL = CommonUtil.getNullOrTrimmedValue(responseRequest.getNotifyURL()); + String callbackData = CommonUtil.getNullOrTrimmedValue(responseRequest.getCallbackData()); + String ussdAction = CommonUtil.getNullOrTrimmedValue(request.getUssdAction()); + + List validationRulesList = new ArrayList<>(); + + try { + + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, + "address", address)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, + "shortCode", shortCode)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, + "clientCorrelator", clientCorrelator)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, + "keyword", keyword)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, + "outboundUSSDMessage", outboundUSSDMessage)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, + "ussdAction", ussdAction)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_OPTIONAL, + "notifyURL", notifyURL)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, + "callbackData", callbackData)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY_TEL_END_USER_ID, + "endUserId", endUserId)); + + ValidationRule[] validationRules = new ValidationRule[validationRulesList.size()]; + validationRules = validationRulesList.toArray(validationRules); + + Validation.checkRequestParams(validationRules); + + } catch (CustomException ex) { + LOG.error("###USSD### Error in Validations", ex); + responseWrapper.setRequestError( + constructRequestError(SERVICEEXCEPTION, ex.getErrcode(), ex.getErrmsg(), ex.getErrvar()[0])); + return false; + } + + return true; + } + + @Override + protected Returnable process(USSDSessionRequestWrapperDTO extendedRequestDTO) throws Exception { + if (responseWrapper.getRequestError() != null) { + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + USSDSessionInitiatorRequestBean requestBean = extendedRequestDTO.getUssdSessionRequestBean(); + USSDSessionInitiatorRequestBean.OutboundUSSDMessageRequest request = requestBean + .getOutboundUSSDMessageRequest(); + USSDSessionResponseRequest responseRequest = request.getResponseRequest(); + + String shortCode = CommonUtil.getNullOrTrimmedValue(request.getShortCode()); + String keyword = CommonUtil.getNullOrTrimmedValue(request.getKeyword()); + String clientCorrelator = CommonUtil.getNullOrTrimmedValue(request.getClientCorrelator()); + String endUserIdPath = extendedRequestDTO.getEndUserId(); +// String endUserIdRequest = request.getAddress(); + String address = getLastMobileNumber(endUserIdPath); + String outboundUSSDMessage = CommonUtil.getNullOrTrimmedValue(request.getOutboundUSSDMessage()); + String notifyURL = CommonUtil.getNullOrTrimmedValue(responseRequest.getNotifyURL()); + String callbackData = CommonUtil.getNullOrTrimmedValue(responseRequest.getCallbackData()); + String ussdAction = CommonUtil.getNullOrTrimmedValue(request.getUssdAction()); + Integer userId = extendedRequestDTO.getUser().getId(); + serviceCallUSSD = ServiceName.InitUSSD.toString(); + + USSDSessionInitiatorResponseBean responseBean = new USSDSessionInitiatorResponseBean(); + USSDSessionResponseRequest responseRequestBean = new USSDSessionResponseRequest(); + + + APITypes apiTypes = dao.getAPIType(RequestType.USSD.toString()); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), serviceCallUSSD); + + // Todo: Exception Handling + + // Todo: Handle ussdAction + + int serviceNameId = apiServiceCalls.getApiServiceCallId(); + Gson gson = new Gson(); + + String response = checkDuplicateClientCorrelator(clientCorrelator, userId, serviceNameId, endUserIdPath, + MessageProcessStatus.Success, MessageType.Response); + + if (response != null) { + // Send already sent response + USSDSessionInitiatorResponseBean object; + object = gson.fromJson(response, USSDSessionInitiatorResponseBean.class); + USSDSessionDTO dto = new USSDSessionDTO(); + dto.setOutboundUSSDMessageRequest(object); + responseWrapper.setUssdSessionDTO(dto); + responseWrapper.setHttpStatus(Response.Status.OK); + return responseWrapper; + } + + boolean test = checkForRegisteredApplications(userId, shortCode, keyword); + + if (!test) { + LOG.error("###USSD### No Applications Registered for Provided ShortCode"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "No Applications Registered for Provided ShortCode")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + + } + + responseBean.setAddress(address); + responseBean.setKeyword(keyword); + responseBean.setShortCode(shortCode); + responseBean.setOutboundUSSDMessage(outboundUSSDMessage); + responseBean.setClientCorrelator(clientCorrelator); + responseBean.setUssdAction(ussdAction); + + responseRequestBean.setNotifyURL(notifyURL); + responseRequestBean.setCallbackData(callbackData); + responseBean.setResponseRequest(responseRequestBean); + responseWrapper.setHttpStatus(Response.Status.OK); + USSDSessionDTO ussdSessionDTO = new USSDSessionDTO(); + responseBean.setDeliveryStatus(DELIVERY_STATUS); + ussdSessionDTO.setOutboundUSSDMessageRequest(responseBean); + responseWrapper.setUssdSessionDTO(ussdSessionDTO); + + saveResponse(userId, endUserIdPath, responseBean, apiServiceCalls, MessageProcessStatus.Success); + + return responseWrapper; + } + + private void saveResponse(Integer userid, String endUserIdPath, USSDSessionInitiatorResponseBean responseBean, + APIServiceCalls apiServiceCalls, MessageProcessStatus status) throws Exception { + + String jsonInString; + Gson gson = new Gson(); + + JsonElement je = new JsonParser().parse(gson.toJson(responseBean)); + JsonObject asJsonObject = je.getAsJsonObject(); + jsonInString = asJsonObject.toString(); + + MessageLog messageLog = new MessageLog(); + messageLog.setRequest(jsonInString); + messageLog.setStatus(status.getValue()); + messageLog.setType(MessageType.Response.getValue()); + messageLog.setServicenameid(apiServiceCalls.getApiServiceCallId()); + messageLog.setUserid(userid); + messageLog.setReference("msisdn"); + messageLog.setValue(endUserIdPath); + messageLog.setMessageTimestamp(new Date()); + + loggingDAO.saveMessageLog(messageLog); + } + + private String checkDuplicateClientCorrelator(String clientCorrelator, int userId, int serviceNameId, String tel, + MessageProcessStatus status, MessageType type) throws Exception { + + List list = new ArrayList<>(); + list.add(serviceNameId); + + List response = loggingDAO.getMessageLogs(userId, list, "msisdn", tel, null, null); + + String jsonString = null; + + for (int i = 0; i < response.size(); i++) { + + int responseStatus = response.get(i).getStatus(); + int responseType = response.get(i).getType(); + String responseClientCorrelator; + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = response.get(i).getRequest(); + JSONObject json = new JSONObject(request); + + responseClientCorrelator = json.get("clientCorrelator").toString(); + + int responseUserId = response.get(i).getUserid(); + String responseTel = response.get(i).getValue(); + + // check for duplicate clientCorrelators + if ((responseClientCorrelator != null && responseClientCorrelator.equals(clientCorrelator)) && + responseUserId == userId && responseTel.equals(tel)) { + jsonString = json.toString(); + break; + } + } + + + } + + return jsonString; + + } + + private boolean checkForRegisteredApplications(int userId, String shortCode, String keyword) { + + List applicationList = ussdDAO.getUssdApplications(userId, shortCode, keyword); + boolean flag = false; + + if (applicationList.size() == 0) { + flag = false; + + } else { + + if (applicationList.size() > 1 && keyword == null) { + flag = false; + } + + for (int i = 0; i < applicationList.size(); i++) { + + int responseUserId = applicationList.get(i).getUserid(); + String responseKeyWord = applicationList.get(i).getKeyword(); + String responseShortCode = applicationList.get(i).getShortCode(); + + + if (keyword == null) { + if (userId == responseUserId && shortCode.equals(responseShortCode)) { + flag = true; + } + } else { + if (userId == responseUserId && shortCode.equals(responseShortCode) && keyword.equals + (responseKeyWord)) { + flag = true; + } + } + } + } + + return flag; + + } + + + @Override + public String getApiServiceCalls() { + return ServiceName.InitUSSD.toString(); + } + + @Override + public String getJosonString(USSDSessionRequestWrapperDTO requestDTO) { + Gson gson = new Gson(); + return gson.toJson(requestDTO.getUssdSessionRequestBean()); + } + + @Override + public String getnumber(USSDSessionRequestWrapperDTO requestDTO) { + return requestDTO.getEndUserId(); + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDAction.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDAction.java new file mode 100644 index 00000000..b249a298 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDAction.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.ussd; + +public enum USSDAction { + mtinit, mtcont, moinit, mocont, mtfin, +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDApplicationConfigHandler.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDApplicationConfigHandler.java new file mode 100644 index 00000000..3ca90966 --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDApplicationConfigHandler.java @@ -0,0 +1,143 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.ussd; + + +import com.wso2telco.core.dbutils.exception.ServiceError; +import com.wso2telco.dep.oneapivalidation.exceptions.CustomException; +import com.wso2telco.dep.oneapivalidation.util.Validation; +import com.wso2telco.dep.oneapivalidation.util.ValidationRule; +import com.wso2telco.services.dep.sandbox.dao.DaoFactory; +import com.wso2telco.services.dep.sandbox.dao.USSDDAO; +import com.wso2telco.services.dep.sandbox.dao.model.domain.UssdApplication; +import com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler; +import com.wso2telco.services.dep.sandbox.servicefactory.AddressIgnorerable; +import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; +import com.wso2telco.services.dep.sandbox.util.CommonUtil; +import org.apache.commons.logging.LogFactory; + +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.List; + +public class USSDApplicationConfigHandler extends AbstractRequestHandler + implements AddressIgnorerable { + + + private USSDApplicationConfigRequestWrapper requestWrapper; + private USSDApplicationConfigResponseWrapper responseWrapper; + private USSDDAO ussdDAO; + + { + LOG = LogFactory.getLog(USSDApplicationConfigHandler.class); + ussdDAO = DaoFactory.getUSSDDAO(); + } + + + @Override + protected Returnable getResponseDTO() { + return responseWrapper; + } + + @Override + protected List getAddress() { + return null; + } + + @Override + protected boolean validate(USSDApplicationConfigRequestWrapper wrapperDTO) throws Exception { + + USSDApplicationConfigRequestBean requestBean = wrapperDTO.getUssdApplicationConfigRequestBean(); + + String shortCode = CommonUtil.getNullOrTrimmedValue(requestBean.getShortCode()); + String keyWord = CommonUtil.getNullOrTrimmedValue(requestBean.getKeyWord()); + int userId = Integer.parseInt(CommonUtil.getNullOrTrimmedValue(String.valueOf(requestBean.getUserID()))); + List validationRulesList = new ArrayList<>(); + + try { + validationRulesList + .add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, "shortCode", shortCode)); + validationRulesList.add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY, + "keyWord", keyWord)); + validationRulesList + .add(new ValidationRule(ValidationRule.VALIDATION_TYPE_MANDATORY_INT_GE_ZERO, "userId", userId)); + + ValidationRule[] validationRules = new ValidationRule[validationRulesList.size()]; + validationRules = validationRulesList.toArray(validationRules); + + Validation.checkRequestParams(validationRules); + + } catch (CustomException ex) { + LOG.error("###WALLETCONFIG### Error in Validations. ", ex); + responseWrapper.setRequestError( + constructRequestError(SERVICEEXCEPTION, ex.getErrcode(), ex.getErrmsg(), ex.getErrvar()[0])); + return false; + } + return true; + } + + @Override + protected Returnable process(USSDApplicationConfigRequestWrapper extendedRequestDTO) throws Exception { + if (responseWrapper.getRequestError() != null) { + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } + + try { + USSDApplicationConfigRequestBean requestBean = extendedRequestDTO.getUssdApplicationConfigRequestBean(); + + String shortCode = requestBean.getShortCode(); + String keyword = requestBean.getKeyWord(); + int userId = requestBean.getUserID(); + + UssdApplication application = new UssdApplication(); + application.setShortCode(shortCode); + application.setKeyword(keyword); + application.setUserid(userId); + + boolean result = ussdDAO.saveUSSDApplications(application); + + if (!result) { + LOG.error("###USSD CONFIG### Error occur in save applications"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Error occur in save applications")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + + } else { + responseWrapper.setStatus("Successful"); + responseWrapper.setHttpStatus(Response.Status.OK); + } + + } catch (Exception ex) { + + LOG.error("###USSD CONFIG### Error occur in save applications"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Error occur in save applications")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + } + + return responseWrapper; + + } + + @Override + protected void init(USSDApplicationConfigRequestWrapper extendedRequestDTO) throws Exception { + + requestWrapper = extendedRequestDTO; + responseWrapper = new USSDApplicationConfigResponseWrapper(); + + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDApplicationConfigRequestBean.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDApplicationConfigRequestBean.java new file mode 100644 index 00000000..dc985e1e --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDApplicationConfigRequestBean.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.ussd; + + +public class USSDApplicationConfigRequestBean { + + private String shortCode; + private String keyWord; + private int userID; + + public String getShortCode() { + return shortCode; + } + + public void setShortCode(String shortCode) { + this.shortCode = shortCode; + } + + public String getKeyWord() { + return keyWord; + } + + public void setKeyWord(String keyWord) { + this.keyWord = keyWord; + } + + public int getUserID() { + return userID; + } + + public void setUserID(int userID) { + this.userID = userID; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDApplicationConfigRequestWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDApplicationConfigRequestWrapper.java new file mode 100644 index 00000000..bcede02c --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDApplicationConfigRequestWrapper.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.ussd; + + +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; + +public class USSDApplicationConfigRequestWrapper extends RequestDTO { + + private USSDApplicationConfigRequestBean ussdApplicationConfigRequestBean; + + public USSDApplicationConfigRequestBean getUssdApplicationConfigRequestBean() { + return ussdApplicationConfigRequestBean; + } + + public void setUssdApplicationConfigRequestBean(USSDApplicationConfigRequestBean ussdApplicationConfigRequestBean) { + this.ussdApplicationConfigRequestBean = ussdApplicationConfigRequestBean; + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDApplicationConfigResponseWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDApplicationConfigResponseWrapper.java new file mode 100644 index 00000000..e9c09ffe --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDApplicationConfigResponseWrapper.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.ussd; + + +import com.wso2telco.services.dep.sandbox.dao.model.custom.ErrorResponseDTO; +import com.wso2telco.services.dep.sandbox.servicefactory.AbstractReturnWrapperDTO; + +public class USSDApplicationConfigResponseWrapper extends AbstractReturnWrapperDTO { + private String status; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @Override + public Object getResponse() { + + if (getRequestError() == null) { + return status; + } else { + ErrorResponseDTO response = new ErrorResponseDTO(getRequestError()); + return response; + } + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDConfigServiceFactory.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDConfigServiceFactory.java new file mode 100644 index 00000000..3a15723f --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDConfigServiceFactory.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.ussd; + + +import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; +import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class USSDConfigServiceFactory { + + + private static Log LOG = LogFactory.getLog(USSDConfigServiceFactory.class); + + public static RequestHandleable getInstance(final RequestDTO requestDTO) { + + final String APPLICATION = "Application"; + + if (requestDTO.getRequestPath().contains(APPLICATION)) { + LOG.debug("LOADING APPLICATION SAVE SERVICE"); + return new USSDApplicationConfigHandler(); + } else + return null; + } + + +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDRequestFactory.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDRequestFactory.java index e6d51f2e..2830e474 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDRequestFactory.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDRequestFactory.java @@ -2,11 +2,24 @@ import com.wso2telco.services.dep.sandbox.dao.model.custom.RequestDTO; import com.wso2telco.services.dep.sandbox.servicefactory.RequestHandleable; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; public class USSDRequestFactory { - // TODO: based on the json body need to implement request handle - public static RequestHandleable getInstance(final RequestDTO requestDTO) { + private static Log LOG = LogFactory.getLog(USSDRequestFactory.class); - return null; - } + public static RequestHandleable getInstance(final RequestDTO requestDTO) { + + final String INITIATE_USSD_SESSION = "USSD"; + + if (requestDTO.getRequestPath().contains(INITIATE_USSD_SESSION.toLowerCase())) { + if (LOG.isDebugEnabled()) { + LOG.debug("Loading Initiate USSD Session"); + return new InitiateUSSDSessionRequestHandler(); + } + } + return null; + } } + + diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDSessionResponseWrapper.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDSessionResponseWrapper.java new file mode 100644 index 00000000..89486ecd --- /dev/null +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/ussd/USSDSessionResponseWrapper.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2015-2017, WSO2.Telco Inc. (http://www.wso2telco.com) + * + * All Rights Reserved. WSO2.Telco Inc. licences 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 com.wso2telco.services.dep.sandbox.servicefactory.ussd; + +import com.wso2telco.services.dep.sandbox.dao.model.custom.ErrorResponseDTO; +import com.wso2telco.services.dep.sandbox.dao.model.custom.USSDSessionDTO; +import com.wso2telco.services.dep.sandbox.servicefactory.AbstractReturnWrapperDTO; + +public class USSDSessionResponseWrapper extends AbstractReturnWrapperDTO { + + private USSDSessionDTO ussdSessionDTO; + + public USSDSessionDTO getUssdSessionDTO() { + return ussdSessionDTO; + } + + public void setUssdSessionDTO(USSDSessionDTO ussdSessionDTO) { + this.ussdSessionDTO = ussdSessionDTO; + } + + @Override + public Object getResponse() { + if (getRequestError() == null) { + return ussdSessionDTO; + } else { + ErrorResponseDTO response = new ErrorResponseDTO(getRequestError()); + return response; + } + + } +} diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/wallet/AttributeName.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/wallet/AttributeName.java index 7e6664a2..e99baf6c 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/wallet/AttributeName.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/wallet/AttributeName.java @@ -16,5 +16,5 @@ package com.wso2telco.services.dep.sandbox.servicefactory.wallet; public enum AttributeName { - Payment, Refund, accountStatus, Currency, clientCorrelatorWallet, transactionStatus, referenceCodeWallet + Payment, Refund, accountStatus, Currency, clientCorrelatorWallet, transactionStatus, referenceCodeWallet, makePayment, clientCorrelatorPayment, referenceCodePayment,refundUser, } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/wallet/ListTransactionRequestHandler.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/wallet/ListTransactionRequestHandler.java index 2a587a54..806114b0 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/wallet/ListTransactionRequestHandler.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/wallet/ListTransactionRequestHandler.java @@ -6,6 +6,10 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import com.wso2telco.services.dep.sandbox.dao.model.domain.*; +import com.wso2telco.services.dep.sandbox.servicefactory.MessageProcessStatus; +import com.wso2telco.services.dep.sandbox.servicefactory.MessageType; +import com.wso2telco.services.dep.sandbox.util.*; import org.apache.commons.logging.LogFactory; import org.json.simple.JSONObject; @@ -24,16 +28,8 @@ import com.wso2telco.services.dep.sandbox.dao.WalletDAO; import com.wso2telco.services.dep.sandbox.dao.model.custom.ListTransactionResponseBean; import com.wso2telco.services.dep.sandbox.dao.model.custom.ListTransactionDTO; -import com.wso2telco.services.dep.sandbox.dao.model.domain.APIServiceCalls; -import com.wso2telco.services.dep.sandbox.dao.model.domain.APITypes; -import com.wso2telco.services.dep.sandbox.dao.model.domain.AttributeValues; -import com.wso2telco.services.dep.sandbox.dao.model.domain.ManageNumber; import com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler; import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; -import com.wso2telco.services.dep.sandbox.util.CommonUtil; -import com.wso2telco.services.dep.sandbox.util.MessageLogHandler; -import com.wso2telco.services.dep.sandbox.util.ServiceName; -import com.wso2telco.services.dep.sandbox.util.TableName; public class ListTransactionRequestHandler extends AbstractRequestHandler { @@ -92,10 +88,20 @@ protected Returnable process(ListTransactionRequestWrapper extendedRequestDTO) t try { String msisdn = extendedRequestDTO.getEndUserId(); String endUserId = getLastMobileNumber(msisdn); - List amounTransaction = null; - List attributeName = new ArrayList(); - attributeName.add(AttributeName.Payment.toString().toLowerCase()); - attributeName.add(AttributeName.Refund.toString().toLowerCase()); + APITypes walletApi = dao.getAPIType(RequestType.WALLET.toString()); + + String serviceCallMakePayment = ServiceName.MakePayment.toString(); + String serviceCallRefundPayment = ServiceName.RefundPayment.toString(); + APIServiceCalls apiServiceCallPayment = dao.getServiceCall(walletApi.getId(), serviceCallMakePayment); + APIServiceCalls apiServiceCallRefund = dao.getServiceCall(walletApi.getId(), serviceCallRefundPayment); + + int paymentId = apiServiceCallPayment.getApiServiceCallId(); + int refundId = apiServiceCallRefund.getApiServiceCallId(); + + List attributeName = new ArrayList<>(); + attributeName.add(paymentId); + attributeName.add(refundId); + Integer userId = extendedRequestDTO.getUser().getId(); // Save Request Log @@ -106,32 +112,47 @@ protected Returnable process(ListTransactionRequestWrapper extendedRequestDTO) t logHandler.saveMessageLog(apiServiceCalls.getApiServiceCallId(), extendedRequestDTO.getUser().getId(), "msisdn", msisdn, object); - String tableName = TableName.NUMBERS.toString().toLowerCase(); ListTransactionResponseBean paymentTransaction = new ListTransactionResponseBean(); - amounTransaction = walletDAO.getTransactionValue(endUserId, attributeName, tableName, userId); + List responses = loggingDAO.getMessageLogs(userId, attributeName, "msisdn", "tel:+" + endUserId, null, null); - List listNodes = new ArrayList(); - if (amounTransaction != null && !amounTransaction.isEmpty()) { - for (AttributeValues values : amounTransaction) { - JsonParser parser = new JsonParser(); - JsonObject jsonObject = parser.parse(values.getValue()).getAsJsonObject(); - JsonElement get = jsonObject.get("paymentAmount"); - JsonObject asJsonObjectPayment = get.getAsJsonObject(); - asJsonObjectPayment.remove("chargingMetaData"); - jsonObject.remove("clientCorrelator"); - jsonObject.remove("notifyURL"); - jsonObject.remove("originalReferenceCode"); - jsonObject.remove("originalServerReferenceCode"); - jsonObject.remove("resourceURL"); - String jsonInString = null; - jsonInString = jsonObject.toString(); - - JsonNode node = null; - ObjectMapper mapper = new ObjectMapper(); - node = mapper.readValue(jsonInString, JsonNode.class); - listNodes.add(node); - } + List listNodes = new ArrayList(); + String jsonString = null; + + if (responses != null && !responses.isEmpty()) { + for (int i = 0; i < responses.size(); i++) { + + int responseStatus = responses.get(i).getStatus(); + int responseType = responses.get(i).getType(); + + if (responseType == MessageType.Response.getValue() && responseStatus == MessageProcessStatus.Success.getValue()) { + String request = responses.get(i).getRequest(); + org.json.JSONObject json = new org.json.JSONObject(request); + + int responseUserId = responses.get(i).getUserid(); + String responseTel = responses.get(i).getValue(); + + if (responseUserId == userId && responseTel.equals("tel:+" + endUserId)) { + jsonString = json.toString(); + JsonParser parser = new JsonParser(); + JsonObject jsonObject = (JsonObject) parser.parse(jsonString); + JsonElement get = jsonObject.get("paymentAmount"); + JsonObject asJsonObjectPayment = get.getAsJsonObject(); + asJsonObjectPayment.remove("chargingMetaData"); + jsonObject.remove("clientCorrelator"); + jsonObject.remove("notifyURL"); + jsonObject.remove("originalReferenceCode"); + jsonObject.remove("originalServerReferenceCode"); + jsonObject.remove("resourceURL"); + String jsonInString = null; + jsonInString = jsonObject.toString(); + + ObjectMapper mapper = new ObjectMapper(); + JsonNode node = mapper.readValue(jsonInString, JsonNode.class); + listNodes.add(node); + } + } + } paymentTransaction.setAmountTransaction(listNodes); } else { LOG.error("###WALLET### Valid Transaction List Not Available for msisdn: " + endUserId); diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/wallet/MakePaymentRequestHandler.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/wallet/MakePaymentRequestHandler.java index e51b19c5..f58e4dc4 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/wallet/MakePaymentRequestHandler.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/wallet/MakePaymentRequestHandler.java @@ -9,6 +9,8 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import com.wso2telco.services.dep.sandbox.dao.model.custom.*; +import com.wso2telco.services.dep.sandbox.servicefactory.*; import org.apache.commons.lang.math.NumberUtils; import org.apache.commons.logging.LogFactory; @@ -26,15 +28,7 @@ import com.wso2telco.services.dep.sandbox.dao.LoggingDAO; import com.wso2telco.services.dep.sandbox.dao.NumberDAO; import com.wso2telco.services.dep.sandbox.dao.WalletDAO; -import com.wso2telco.services.dep.sandbox.dao.model.custom.ChargingInformation; -import com.wso2telco.services.dep.sandbox.dao.model.custom.ChargingMetaData; -import com.wso2telco.services.dep.sandbox.dao.model.custom.MakePaymentDTO; -import com.wso2telco.services.dep.sandbox.dao.model.custom.MakePaymentRequestBean; import com.wso2telco.services.dep.sandbox.dao.model.custom.MakePaymentRequestBean.makePayment; -import com.wso2telco.services.dep.sandbox.dao.model.custom.MakePaymentRequestWrapperDTO; -import com.wso2telco.services.dep.sandbox.dao.model.custom.MakePaymentResponseBean; -import com.wso2telco.services.dep.sandbox.dao.model.custom.PaymentAmount; -import com.wso2telco.services.dep.sandbox.dao.model.custom.PaymentAmountResponse; import com.wso2telco.services.dep.sandbox.dao.model.domain.APIServiceCalls; import com.wso2telco.services.dep.sandbox.dao.model.domain.APITypes; import com.wso2telco.services.dep.sandbox.dao.model.domain.AttributeDistribution; @@ -42,33 +36,38 @@ import com.wso2telco.services.dep.sandbox.dao.model.domain.Attributes; import com.wso2telco.services.dep.sandbox.dao.model.domain.ManageNumber; import com.wso2telco.services.dep.sandbox.dao.model.domain.MessageLog; -import com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler; -import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; import com.wso2telco.services.dep.sandbox.util.CommonUtil; import com.wso2telco.services.dep.sandbox.util.CreditStatusCodes; import com.wso2telco.services.dep.sandbox.util.MessageLogHandler; import com.wso2telco.services.dep.sandbox.util.RequestType; import com.wso2telco.services.dep.sandbox.util.ServiceName; import com.wso2telco.services.dep.sandbox.util.TableName; +import org.json.JSONObject; -public class MakePaymentRequestHandler extends AbstractRequestHandler { +public class MakePaymentRequestHandler extends AbstractRequestHandler implements RequestResponseRequestHandleable { private WalletDAO walletDAO; private LoggingDAO loggingDAO; private NumberDAO numberDAO; private MakePaymentRequestWrapperDTO requestWrapperDTO; private MakePaymentResponseWrapper responseWrapper; - private MessageLogHandler logHandler; private String serviceCallPayment; - private Integer transactionId; - + private String responseReferenceCode; { LOG = LogFactory.getLog(MakePaymentRequestHandler.class); walletDAO = DaoFactory.getWalletDAO(); loggingDAO = DaoFactory.getLoggingDAO(); numberDAO = DaoFactory.getNumberDAO(); dao = DaoFactory.getGenaricDAO(); - logHandler = MessageLogHandler.getInstance(); + } + + private static boolean currencySymbol(@Nonnull final String currencyCode) { + try { + final Currency currency = Currency.getInstance(currencyCode); + return true; + } catch (final IllegalArgumentException x) { + return false; + } } @Override @@ -101,7 +100,7 @@ protected boolean validate(MakePaymentRequestWrapperDTO wrapperDTO) throws Excep String clientCorrelator = CommonUtil.getNullOrTrimmedValue(request.getClientCorrelator()); String endUserID = CommonUtil.getNullOrTrimmedValue(wrapperDTO.getEndUserId()); String msisdn = CommonUtil.getNullOrTrimmedValue(request.getEndUserId()); - String amount = CommonUtil.getNullOrTrimmedValue(chargingInformation.getAmount().toString()); + String amount = CommonUtil.getNullOrTrimmedValue(String.valueOf(chargingInformation.getAmount())); String currency = CommonUtil.getNullOrTrimmedValue(chargingInformation.getCurrency()); String description = CommonUtil.getNullOrTrimmedValue(chargingInformation.getDescription()); String onBehalfOf = CommonUtil.getNullOrTrimmedValue(metaData.getOnBehalfOf()); @@ -169,7 +168,7 @@ protected Returnable process(MakePaymentRequestWrapperDTO extendedRequestDTO) th String endUserIdPath = extendedRequestDTO.getEndUserId(); String endUserIdRequest = request.getEndUserId(); String endUserId = getLastMobileNumber(endUserIdPath); - String amount = CommonUtil.getNullOrTrimmedValue(chargingInformation.getAmount()); + String amount = CommonUtil.getNullOrTrimmedValue(String.valueOf(chargingInformation.getAmount())); String currency = CommonUtil.getNullOrTrimmedValue(chargingInformation.getCurrency()); String description = CommonUtil.getNullOrTrimmedValue(chargingInformation.getDescription()); String onBehalfOf = CommonUtil.getNullOrTrimmedValue(metadata.getOnBehalfOf()); @@ -188,54 +187,41 @@ protected Returnable process(MakePaymentRequestWrapperDTO extendedRequestDTO) th // Save Request Log APITypes apiTypes = dao.getAPIType(extendedRequestDTO.getRequestType().toString().toLowerCase()); - APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), serviceCallPayment); - - Gson gson = new Gson(); - String jsonString = gson.toJson(requestBean); - MessageLog messageLog = new MessageLog(); - messageLog.setServicenameid(apiServiceCalls.getApiServiceCallId()); - messageLog.setUserid(extendedRequestDTO.getUser().getId()); - messageLog.setReference("msisdn"); - messageLog.setValue(endUserIdPath); - messageLog.setRequest(jsonString); - messageLog.setMessageTimestamp(new Date()); - - int ref_number = loggingDAO.saveMessageLog(messageLog); - String serverReferenceCodeFormat = String.format("%06d", ref_number); - String serverReferenceCode = "WALLET_REF_" + serverReferenceCodeFormat; - - // check already charge request against client correlator - if (clientCorrelator != null) { - String tableAttributeValue = TableName.SBXATTRIBUTEVALUE.toString().toLowerCase(); - String clientCorrelatorAttribute = AttributeName.clientCorrelatorWallet.toString(); - AttributeValues duplicateClientCorrelator = walletDAO.checkDuplicateValue(serviceCallPayment, - clientCorrelator, clientCorrelatorAttribute, tableAttributeValue); - if (duplicateClientCorrelator != null) { - APIServiceCalls apiServiceCall = duplicateClientCorrelator.getAttributedid().getAPIServiceCall(); - String serviceCall = apiServiceCall.getServiceName(); - ManageNumber manageNumber = numberDAO.getNumber(endUserId, userName); - Integer id = duplicateClientCorrelator.getOwnerdid(); - AttributeValues response = walletDAO.getResponse(id); - if (serviceCall.equals(serviceCallPayment) && (response.getOwnerdid() == manageNumber.getId())) { - // return already sent response - MakePaymentResponseBean obj = null; - obj = gson.fromJson(response.getValue(), MakePaymentResponseBean.class); - MakePaymentDTO dto = new MakePaymentDTO(); - dto.setmakePayment(obj); - responseWrapper.setMakePaymentDTO(dto); - responseWrapper.setHttpStatus(Response.Status.OK); - return responseWrapper; - } else { - responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, - ServiceError.INVALID_INPUT_VALUE, "Clientcorrelator is already used")); - responseWrapper.setHttpStatus(Status.BAD_REQUEST); - return responseWrapper; - } - } - } + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), serviceCallPayment); + Gson gson = new Gson(); + int serviceNameId = apiServiceCalls.getApiServiceCallId(); + + if (clientCorrelator != null) { + + String response = checkDuplicateClientCorrelator(clientCorrelator, userId, serviceNameId, endUserId, + MessageProcessStatus.Success, MessageType.Response, referenceCode); + + if (response != null) { + // return already sent response + MakePaymentResponseBean obj = null; + obj = gson.fromJson(response, MakePaymentResponseBean.class); + MakePaymentDTO dto = new MakePaymentDTO(); + dto.setmakePayment(obj); + responseWrapper.setMakePaymentDTO(dto); + responseWrapper.setHttpStatus(Response.Status.OK); + return responseWrapper; + } + } + + //check referenceCode + String duplicateReferenceCode = checkReferenceCode(userId, serviceNameId, endUserId, MessageProcessStatus + .Success, MessageType.Response, referenceCode); + + if ((duplicateReferenceCode != null)) { + LOG.error("###WALLET### Already used reference code"); + responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, + ServiceError.INVALID_INPUT_VALUE, "Already used reference code")); + responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + return responseWrapper; + } // check path param endUserId and request body endUserId - if (!(endUserIdPath.equals(endUserIdRequest))) { + if (!(getLastMobileNumber(endUserIdPath).equals(getLastMobileNumber(endUserIdRequest)))) { LOG.error("###WALLET### two different endUserId provided"); responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, ServiceError.INVALID_INPUT_VALUE, "two different endUserId provided")); @@ -269,7 +255,7 @@ protected Returnable process(MakePaymentRequestWrapperDTO extendedRequestDTO) th if (!isValidCurrency) { LOG.error("###WALLET### currency code not valid accorfing to ISO 4217"); responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, - ServiceError.INVALID_INPUT_VALUE, "currency code not valid accorfing to ISO 4217")); + ServiceError.INVALID_INPUT_VALUE, "currency code not valid according to ISO 4217")); responseWrapper.setHttpStatus(Status.BAD_REQUEST); return responseWrapper; } @@ -299,23 +285,10 @@ protected Returnable process(MakePaymentRequestWrapperDTO extendedRequestDTO) th return responseWrapper; } - // check already charged request against reference code - String referenceCodeAttribue = AttributeName.referenceCodeWallet.toString(); - String tableNumber = TableName.NUMBERS.toString().toLowerCase(); - AttributeValues duplicateReferenceCode = walletDAO.checkDuplicateValue(serviceCallPayment, referenceCode, - referenceCodeAttribue, tableNumber); - if (duplicateReferenceCode != null) { - LOG.error("###WALLET### Already charged for this reference code"); - responseWrapper.setRequestError(constructRequestError(SERVICEEXCEPTION, - ServiceError.INVALID_INPUT_VALUE, "Already charged for this reference code")); - responseWrapper.setHttpStatus(Status.BAD_REQUEST); - return responseWrapper; - } - responseBean.setClientCorrelator(clientCorrelator); responseBean.setEndUserId(endUserIdPath); - chargeInformation.setAmount(amount); + chargeInformation.setAmount(Double.parseDouble(amount)); chargeInformation.setCurrency(currency); chargeInformation.setDescription(description); @@ -325,6 +298,11 @@ protected Returnable process(MakePaymentRequestWrapperDTO extendedRequestDTO) th chargeMetaData.setOnBehalfOf(onBehalfOf); } + // Setting the serverReference Code + String serverReferenceCodeFormat = String.format("%06d", getReferenceNumber()); + String serverReferenceCode = "WALLET_REF" + serverReferenceCodeFormat; + responseBean.setServerReferenceCode(serverReferenceCode); + responseBean.setReferenceCode(referenceCode); responseBean.setServerReferenceCode(serverReferenceCode); responseBean.setNotifyURL(notifyURL); @@ -344,17 +322,15 @@ protected Returnable process(MakePaymentRequestWrapperDTO extendedRequestDTO) th "Denied : Account balance insufficient to charge request")); return responseWrapper; } - - // set transaction operation status as refused - else if (transactionStatusValue != null) { - String transactionStatus = transactionStatusValue.getValue(); - if (transactionStatus.equals(TransactionStatus.Refused.toString())) { - responseBean.setTransactionOperationStatus(TransactionStatus.Refused.toString()); - } - // set transaction status as charged - } else if (balance >= chargeAmount) { + // set transaction operation status as refused + else if (transactionStatusValue != null) { + String transactionStatus = transactionStatusValue.getValue(); + if (transactionStatus.equals(TransactionStatus.Refused.toString())) { + responseBean.setTransactionOperationStatus(TransactionStatus.Refused.toString()); + } + + } else if (balance >= chargeAmount) { balance = balance - chargeAmount; - // walletDAO.updateBalance(endUserId, balance, userId); manageNumber.setBalance(balance); numberDAO.saveManageNumbers(manageNumber); responseBean.setTransactionOperationStatus(TransactionStatus.Charged.toString()); @@ -368,16 +344,11 @@ else if (transactionStatusValue != null) { responseBean.setPaymentAmount(payAmount); makePaymentDTO.setmakePayment(responseBean); responseWrapper.setMakePaymentDTO(makePaymentDTO); - responseWrapper.setHttpStatus(Response.Status.OK); + responseWrapper.setHttpStatus(Response.Status.CREATED); - // save payment transaction - transactionId = saveTransaction(responseBean, endUserId, userName); + // Save Success Response + saveResponse(extendedRequestDTO, endUserId, responseBean, apiServiceCalls, MessageProcessStatus.Success); - // save client correlator - if (clientCorrelator != null) { - saveClientCorrelator(endUserId, clientCorrelator); - } - saveReferenceCode(endUserId, referenceCode, userName); } catch (Exception ex) { LOG.error("###WALLET### Error Occured in WALLET Service. ", ex); responseWrapper.setHttpStatus(Status.BAD_REQUEST); @@ -387,110 +358,147 @@ else if (transactionStatusValue != null) { return responseWrapper; } - public Integer saveTransaction(MakePaymentResponseBean responseBean, String endUserId, String userName) - throws Exception { - Integer transactionId = null; - try { - AttributeValues valueObj = new AttributeValues(); - String tableName = TableName.NUMBERS.toString().toLowerCase(); - String attributeName = AttributeName.Payment.toString().toLowerCase(); - APITypes api = dao.getAPIType(RequestType.WALLET.toString()); - APIServiceCalls call = dao.getServiceCall(api.getId(), serviceCallPayment); - Attributes attributes = dao.getAttribute(attributeName); - AttributeDistribution dis = dao.getAttributeDistribution(call.getApiServiceCallId(), - attributes.getAttributeId()); - ManageNumber manageNumber = numberDAO.getNumber(endUserId, userName); - Integer ownerId = manageNumber.getId(); - String jsonInString = null; - Gson gson = new Gson(); - - JsonElement je = new JsonParser().parse(gson.toJson(responseBean)); - JsonObject asJsonObject = je.getAsJsonObject(); - jsonInString = asJsonObject.toString(); - - valueObj = new AttributeValues(); - valueObj.setAttributedid(dis); - valueObj.setOwnerdid(ownerId); - valueObj.setTobject(tableName); - valueObj.setValue(jsonInString); - transactionId = walletDAO.saveAttributeValue(valueObj); + private boolean containsChannel(String channelValue) { - } catch (Exception ex) { - LOG.error("###WALLET### Error in processing save transaction. ", ex); - responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); + for (Channel channel : Channel.values()) { + if (channel.name().toLowerCase().equals(channelValue.toLowerCase())) { + return true; + } } - return transactionId; + + return false; } - public void saveClientCorrelator(String endUserId, String clientCorrelator) throws Exception { - Integer ownerId = null; - try { - AttributeValues valueObj = new AttributeValues(); - String tableName = TableName.SBXATTRIBUTEVALUE.toString().toLowerCase(); - String attributeName = AttributeName.clientCorrelatorWallet.toString(); - APITypes api = dao.getAPIType(RequestType.WALLET.toString()); - APIServiceCalls call = dao.getServiceCall(api.getId(), serviceCallPayment); - Attributes attributes = dao.getAttribute(attributeName); - AttributeDistribution dis = dao.getAttributeDistribution(call.getApiServiceCallId(), - attributes.getAttributeId()); - ownerId = transactionId; - - valueObj = new AttributeValues(); - valueObj.setAttributedid(dis); - valueObj.setOwnerdid(ownerId); - valueObj.setTobject(tableName); - valueObj.setValue(clientCorrelator); - dao.saveAttributeValue(valueObj); - } catch (Exception ex) { - LOG.error("###WALLET### Error in processing save insertion of clientCorrelator request. ", ex); - responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); - } - } + // Check already existing clientcorrelator return response body + private String checkDuplicateClientCorrelator(String clientCorrelator, int userId, int serviceNameId, String tel, + MessageProcessStatus status, MessageType type, String + referenceCode) throws Exception { + List list = new ArrayList<>(); + list.add(serviceNameId); + List response = loggingDAO.getMessageLogs(userId, list, "msisdn", "tel:+" + tel, null, null); - private static boolean currencySymbol(@Nonnull final String currencyCode) { - try { - final Currency currency = Currency.getInstance(currencyCode); - return true; - } catch (final IllegalArgumentException x) { - return false; - } - } + String jsonString = null; - public void saveReferenceCode(String endUserId, String referenceCode, String userName) throws Exception { - try { - AttributeValues valueObj = new AttributeValues(); - String tableName = TableName.NUMBERS.toString().toLowerCase(); - String attributeName = AttributeName.referenceCodeWallet.toString(); - APITypes api = dao.getAPIType(RequestType.WALLET.toString()); - APIServiceCalls call = dao.getServiceCall(api.getId(), serviceCallPayment); - Attributes attributes = dao.getAttribute(attributeName); - AttributeDistribution dis = dao.getAttributeDistribution(call.getApiServiceCallId(), - attributes.getAttributeId()); - ManageNumber manageNumber = numberDAO.getNumber(endUserId, userName); - Integer ownerId = manageNumber.getId(); - - valueObj = new AttributeValues(); - valueObj.setAttributedid(dis); - valueObj.setOwnerdid(ownerId); - valueObj.setTobject(tableName); - valueObj.setValue(referenceCode); - dao.saveAttributeValue(valueObj); + for (int i = 0; i < response.size(); i++) { - } catch (Exception ex) { - LOG.error("###WALLET### Error in processing save of referenceCode request. ", ex); - responseWrapper.setHttpStatus(Response.Status.BAD_REQUEST); - } - } + if (response != null) { - public boolean containsChannel(String channelValue) { + int responseStatus = response.get(i).getStatus(); + int responseType = response.get(i).getType(); + String responseClientCorrelator; - for (Channel channel : Channel.values()) { - if (channel.name().toLowerCase().equals(channelValue.toLowerCase())) { - return true; - } - } + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = response.get(i).getRequest(); + JSONObject json = new JSONObject(request); + responseClientCorrelator = null; - return false; - } + if (json.has("clientCorrelator")) { + responseClientCorrelator = json.get("clientCorrelator").toString(); + } + + responseReferenceCode = json.get("referenceCode").toString(); + + int responseUserId = response.get(i).getUserid(); + String responseTel = response.get(i).getValue(); + + // Check client correlator + if ((responseClientCorrelator != null && responseClientCorrelator.equals(clientCorrelator)) && + responseUserId == userId && responseTel.equals("tel:+" + tel)) { + jsonString = json.toString(); + break; + } + } + + } + + } + + return jsonString; + } + + //check reference code + private String checkReferenceCode(int userId, int serviceNameId, String tel, MessageProcessStatus status, + MessageType type, String referenceCode) throws Exception { + + List list = new ArrayList<>(); + list.add(serviceNameId); + List response = loggingDAO.getMessageLogs(userId, list, "msisdn", "tel:+" + tel, null, null); + + String jsonString = null; + + for (int i = 0; i < response.size(); i++) { + + if (response != null) { + + int responseStatus = response.get(i).getStatus(); + int responseType = response.get(i).getType(); + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = response.get(i).getRequest(); + JSONObject json = new JSONObject(request); + responseReferenceCode = json.get("referenceCode").toString(); + + int responseUserId = response.get(i).getUserid(); + String responseTel = response.get(i).getValue(); + + // Check reference CodeDuplication + if (responseUserId == userId && responseTel.equals("tel:+" + tel) && responseReferenceCode.equals + (referenceCode)) { + jsonString = responseReferenceCode; + break; + } + } + + } + + } + + return jsonString; + } + + // Save Response in messageLog table + private void saveResponse(MakePaymentRequestWrapperDTO extendedRequestDTO, + String endUserIdPath, MakePaymentResponseBean responseBean, APIServiceCalls + apiServiceCalls, MessageProcessStatus status) throws Exception { + + String jsonInString = null; + Gson resp = new Gson(); + + JsonElement jsonElement = new JsonParser().parse(resp.toJson(responseBean)); + JsonObject asJsonObject = jsonElement.getAsJsonObject(); + jsonInString = asJsonObject.toString(); + + //setting messagelog responses + MessageLog messageLog = new MessageLog(); + messageLog = new MessageLog(); + messageLog.setRequest(jsonInString); + messageLog.setStatus(status.getValue()); + messageLog.setType(MessageType.Response.getValue()); + messageLog.setServicenameid(apiServiceCalls.getApiServiceCallId()); + messageLog.setUserid(extendedRequestDTO.getUser().getId()); + messageLog.setReference("msisdn"); + messageLog.setValue("tel:+"+endUserIdPath); + messageLog.setMessageTimestamp(new Date()); + + loggingDAO.saveMessageLog(messageLog); + } + + @Override + public String getApiServiceCalls() { + return ServiceName.MakePayment.toString(); + + } + + @Override + public String getJosonString(MakePaymentRequestWrapperDTO requestDTO) { + Gson gson = new Gson(); + String jsonString = gson.toJson(requestDTO.getMakePaymentRequestBean()); + return jsonString; + } + + @Override + public String getnumber(MakePaymentRequestWrapperDTO requestDTO) throws Exception { + return getLastMobileNumber(requestDTO.getEndUserId()); + } } \ No newline at end of file diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/wallet/RefundTransactionRequestHandler.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/wallet/RefundTransactionRequestHandler.java index 730a9da0..b554ecb2 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/wallet/RefundTransactionRequestHandler.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/servicefactory/wallet/RefundTransactionRequestHandler.java @@ -9,6 +9,8 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import com.wso2telco.services.dep.sandbox.dao.model.custom.*; +import com.wso2telco.services.dep.sandbox.servicefactory.*; import org.apache.commons.lang.math.NumberUtils; import org.apache.commons.logging.LogFactory; @@ -25,18 +27,7 @@ import com.wso2telco.services.dep.sandbox.dao.LoggingDAO; import com.wso2telco.services.dep.sandbox.dao.NumberDAO; import com.wso2telco.services.dep.sandbox.dao.WalletDAO; -import com.wso2telco.services.dep.sandbox.dao.model.custom.ChargingInformation; -import com.wso2telco.services.dep.sandbox.dao.model.custom.ChargingMetaData; -import com.wso2telco.services.dep.sandbox.dao.model.custom.MakePaymentDTO; -import com.wso2telco.services.dep.sandbox.dao.model.custom.MakePaymentResponseBean; -import com.wso2telco.services.dep.sandbox.dao.model.custom.PaymentAmount; -import com.wso2telco.services.dep.sandbox.dao.model.custom.PaymentAmountResponse; -import com.wso2telco.services.dep.sandbox.dao.model.custom.RefundTransactionDTO; -import com.wso2telco.services.dep.sandbox.dao.model.custom.RefundTransactionRequestBean; import com.wso2telco.services.dep.sandbox.dao.model.custom.RefundTransactionRequestBean.RefundTransaction; -import com.wso2telco.services.dep.sandbox.dao.model.custom.RefundTransactionResponseBean; -import com.wso2telco.services.dep.sandbox.dao.model.custom.RefundRequestWrapperDTO; -import com.wso2telco.services.dep.sandbox.dao.model.custom.RefundResponseBean; import com.wso2telco.services.dep.sandbox.dao.model.domain.APIServiceCalls; import com.wso2telco.services.dep.sandbox.dao.model.domain.APITypes; import com.wso2telco.services.dep.sandbox.dao.model.domain.AttributeDistribution; @@ -44,16 +35,15 @@ import com.wso2telco.services.dep.sandbox.dao.model.domain.Attributes; import com.wso2telco.services.dep.sandbox.dao.model.domain.ManageNumber; import com.wso2telco.services.dep.sandbox.dao.model.domain.MessageLog; -import com.wso2telco.services.dep.sandbox.servicefactory.AbstractRequestHandler; -import com.wso2telco.services.dep.sandbox.servicefactory.Returnable; import com.wso2telco.services.dep.sandbox.servicefactory.wallet.AttributeName; import com.wso2telco.services.dep.sandbox.util.CommonUtil; import com.wso2telco.services.dep.sandbox.util.MessageLogHandler; import com.wso2telco.services.dep.sandbox.util.RequestType; import com.wso2telco.services.dep.sandbox.util.ServiceName; import com.wso2telco.services.dep.sandbox.util.TableName; +import org.json.JSONObject; -public class RefundTransactionRequestHandler extends AbstractRequestHandler { +public class RefundTransactionRequestHandler extends AbstractRequestHandler implements RequestResponseRequestHandleable{ private WalletDAO walletDAO; private LoggingDAO loggingDAO; @@ -63,7 +53,9 @@ public class RefundTransactionRequestHandler extends AbstractRequestHandler list = new ArrayList<>(); + list.add(serviceNameId); + List response = loggingDAO.getMessageLogs(userId, list, "msisdn", "tel:+" + tel, null, null); + + String jsonString = null; + + for (int i = 0; i < response.size(); i++) { + + if (response != null) { + + int responseStatus = response.get(i).getStatus(); + int responseType = response.get(i).getType(); + String responseClientCorrelator; + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = response.get(i).getRequest(); + JSONObject json = new JSONObject(request); + + responseClientCorrelator = null; + + if (json.has("clientCorrelator")) { + responseClientCorrelator = json.get("clientCorrelator").toString(); + } + + responseReferenceCode = json.get("referenceCode").toString(); + + int responseUserId = response.get(i).getUserid(); + String responseTel = response.get(i).getValue(); + + // Check client correlator + if ((responseClientCorrelator != null && responseClientCorrelator.equals(clientCorrelator)) && + responseUserId == userId && responseTel.equals("tel:+" + tel)) { + jsonString = json.toString(); + break; + } + } + + } + } + + return jsonString; + + } + + //check reference code + private String checkReferenceCode(int userId, int serviceNameId, String tel, MessageProcessStatus status, + MessageType type, String referenceCode) throws Exception { + + List list = new ArrayList<>(); + list.add(serviceNameId); + List response = loggingDAO.getMessageLogs(userId, list, "msisdn", "tel:+" + tel, null, null); + + String jsonString = null; + + for (int i = 0; i < response.size(); i++) { + + if (response != null) { + + int responseStatus = response.get(i).getStatus(); + int responseType = response.get(i).getType(); + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = response.get(i).getRequest(); + JSONObject json = new JSONObject(request); + responseReferenceCode = json.get("referenceCode").toString(); + + int responseUserId = response.get(i).getUserid(); + String responseTel = response.get(i).getValue(); + + // Check reference CodeDuplication + if (responseUserId == userId && responseTel.equals("tel:+" + tel) && responseReferenceCode.equals + (referenceCode)) { + jsonString = responseReferenceCode; + break; + } + } + + } + + } + + return jsonString; + } + + private double checkOriginalServerReferenceWithServerReference(int userId, int serviceNameId, String tel, + MessageProcessStatus status, MessageType type, + String originalServerReferenceCode, String + originalReferenceCode) throws Exception { + + List list = new ArrayList<>(); + list.add(serviceNameId); + List servercodeList = loggingDAO.getMessageLogs(userId, list, "msisdn", "tel:+" + tel, null, null); + + + APITypes apiTypes = dao.getAPIType(RequestType.WALLET.toString()); + APIServiceCalls apiServiceCalls = dao.getServiceCall(apiTypes.getId(), serviceCallRefund); + + int refundId = apiServiceCalls.getApiServiceCallId(); + List list1 = new ArrayList<>(); + list1.add(refundId); + + List originalServerReferenceCodeList = loggingDAO.getMessageLogs(userId, list1, "msisdn", "tel:+" + + tel, null, null); + + Double paymentAmount = 0.0; + + + for (int i = 0; i < servercodeList.size(); i++) { + + if (servercodeList != null) { + + int responseStatus = servercodeList.get(i).getStatus(); + int responseType = servercodeList.get(i).getType(); + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + String request = servercodeList.get(i).getRequest(); + JSONObject json = new JSONObject(request); + String serverReferenceCode = json.get("serverReferenceCode").toString(); + String referenceCode = json.get("referenceCode").toString(); + + int responseUserId = servercodeList.get(i).getUserid(); + String responseTel = servercodeList.get(i).getValue(); + + if (responseUserId == userId && responseTel.equals("tel:+" + tel) && serverReferenceCode.equals + (originalServerReferenceCode) && referenceCode.equals(originalReferenceCode)) { + isOriginalServerReferenceCode = true; + paymentAmount = Double.valueOf(json.getJSONObject("paymentAmount").getJSONObject + ("chargingInformation").get("amount").toString()); + } + } + + } + + } + + if (isOriginalServerReferenceCode) { + + APITypes apiTypeCredit = dao.getAPIType(RequestType.WALLET.toString()); + APIServiceCalls apiServiceCallCredit = dao.getServiceCall(apiTypeCredit.getId(), ServiceName.RefundPayment + .toString()); + List refundIdList = new ArrayList<>(); + refundIdList.add(apiServiceCallCredit.getApiServiceCallId()); + + List messageLogForPartialRefund = loggingDAO.getMessageLogs(userId, refundIdList, "msisdn", + "tel:+" + tel, null, null); + + if (messageLogForPartialRefund != null) { + + for (int i = 0; i < messageLogForPartialRefund.size(); i++) { + + int responseStatus = messageLogForPartialRefund.get(i).getStatus(); + int responseType = messageLogForPartialRefund.get(i).getType(); + + if (responseType == type.getValue() && responseStatus == status.getValue()) { + + String request = messageLogForPartialRefund.get(i).getRequest(); + JSONObject json = new JSONObject(request); + String responseOriginalServerReferenceCode = json.get("originalServerReferenceCode").toString(); + + int responseUserId = messageLogForPartialRefund.get(i).getUserid(); + String responseTel = messageLogForPartialRefund.get(i).getValue(); + + // Check reference CodeDuplication + if (responseUserId == userId && responseTel.equals("tel:+" + tel) && + responseOriginalServerReferenceCode.equals(originalServerReferenceCode)) { + totalAmountRefunded += Double.valueOf(json.getJSONObject("paymentAmount").getJSONObject + ("chargingInformation").get("amount").toString()); + } + } + } + + } + } + + return (paymentAmount - totalAmountRefunded); + } + + // save Response in messageLog table + private void saveResponse(Integer userId, String endUserIdPath, RefundTransactionResponseBean responseBean, APIServiceCalls apiServiceCalls, MessageProcessStatus status) throws Exception { + + String jsonInString = null; + Gson resp = new Gson(); + + JsonElement je = new JsonParser().parse(resp.toJson(responseBean)); + JsonObject asJsonObject = je.getAsJsonObject(); + jsonInString = asJsonObject.toString(); + + //setting messagelog responses + MessageLog messageLog = new MessageLog(); + messageLog = new MessageLog(); + messageLog.setRequest(jsonInString); + messageLog.setStatus(status.getValue()); + messageLog.setType(MessageType.Response.getValue()); + messageLog.setServicenameid(apiServiceCalls.getApiServiceCallId()); + messageLog.setUserid(userId); + messageLog.setReference("msisdn"); + messageLog.setValue("tel:+"+endUserIdPath); + messageLog.setMessageTimestamp(new Date()); + + loggingDAO.saveMessageLog(messageLog); + } + + + @Override + public String getApiServiceCalls() { + return ServiceName.RefundPayment.toString(); + } + + @Override + public String getJosonString(RefundRequestWrapperDTO requestDTO) { + Gson gson = new Gson(); + String jsonString = gson.toJson(requestDTO.getRefundRequestBean()); + return jsonString; + } + + @Override + public String getnumber(RefundRequestWrapperDTO requestDTO) throws Exception { + return getLastMobileNumber(requestDTO.getEndUserId()); + } } \ No newline at end of file diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/util/MessageLogHandler.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/util/MessageLogHandler.java index 759a5dc2..c4d5c19a 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/util/MessageLogHandler.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/util/MessageLogHandler.java @@ -18,7 +18,7 @@ public class MessageLogHandler { - + private Log log = LogFactory.getLog(MessageLogHandler.class); private ExecutorService executorService; private static MessageLogHandler instance; @@ -28,14 +28,14 @@ private MessageLogHandler() { executorService = Executors.newFixedThreadPool(10); dbservice = new HibernateLoggingDao(); } - + public synchronized static MessageLogHandler getInstance() { if (instance == null) { instance = new MessageLogHandler(); } return instance; } - + public void saveMessageLog(final int servicenameid, final int userid, final String reference, final String value, JSONObject obj) throws Exception { MessageLog messageLog = new MessageLog(); executorService.execute(new Runnable() { @@ -45,7 +45,7 @@ public void run() { obj.writeJSONString(out); String jsonString = out.toString(); log.debug("JSON Sting" + jsonString); - + messageLog.setServicenameid(servicenameid); messageLog.setUserid(userid); messageLog.setReference(reference); @@ -54,17 +54,16 @@ public void run() { messageLog.setMessageTimestamp(new Date()); log.debug("messagelog object has been created"); dbservice.saveMessageLog(messageLog); - + } catch (Exception e) { log.debug("error while inserting data into database", e); } } }); } - public List getMessageLogs(final int userid, final List serviceNameIds, final String reference, final String value, final Date startTimeStamp, final Date endTimeStamp) throws Exception { - + return dbservice.getMessageLogs(userid, serviceNameIds, reference, value, startTimeStamp, endTimeStamp); } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/util/RequestType.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/util/RequestType.java index 46c5edfc..afc78868 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/util/RequestType.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/util/RequestType.java @@ -1,6 +1,6 @@ package com.wso2telco.services.dep.sandbox.util; public enum RequestType { - SMSMESSAGING, PAYMENT, USSD, LOCATION, MOBILEID, PROVISIONING,PROVISIONINGCONFIG, USER, CUSTOMERINFO,CUSTOMERINFOCONFIG, CREDIT, WALLET, WALLETCONFIG; + SMSMESSAGING, PAYMENT, USSD, LOCATION, MOBILEID, PROVISIONING,PROVISIONINGCONFIG, USER, CUSTOMERINFO,CUSTOMERINFOCONFIG, CREDIT, WALLET, WALLETCONFIG, USSDCONFIG, SMSCONFIG; } diff --git a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/util/ServiceName.java b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/util/ServiceName.java index 6580b1e8..7912a94e 100644 --- a/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/util/ServiceName.java +++ b/dep-sandbox/src/main/java/com/wso2telco/services/dep/sandbox/util/ServiceName.java @@ -1,6 +1,8 @@ package com.wso2telco.services.dep.sandbox.util; public enum ServiceName { - GetAttribute, GetProfile, ApplyCredit, PatialRefund, MakePayment, ListPayment, RefundPayment, BalanceLookup,; + + GetAttribute, GetProfile, ApplyCredit, PartialRefund, MakePayment, ListPayment, RefundPayment, BalanceLookup, ChargeUser,RefundUser, Location, SendSMS, ReceivingSMS, SubscribeToApplication, StopSubscribeToApplication, + SubscribeToSMSDelivery, StopSubscriptionDelivery, InitUSSD, QuerySMSStatus, ListService, QueryService; } diff --git a/dep-sandbox/src/main/java/hibernate.cfg.xml b/dep-sandbox/src/main/java/hibernate.cfg.xml index b24bb9a7..c8608b71 100644 --- a/dep-sandbox/src/main/java/hibernate.cfg.xml +++ b/dep-sandbox/src/main/java/hibernate.cfg.xml @@ -13,7 +13,7 @@ - true + false true thread @@ -56,5 +56,6 @@ + \ No newline at end of file diff --git a/feature/sandbox/pom.xml b/feature/sandbox/pom.xml index 5d00ec05..cdc620e9 100644 --- a/feature/sandbox/pom.xml +++ b/feature/sandbox/pom.xml @@ -5,7 +5,7 @@ com.wso2telco.services.dep services-dep-parent - 1.2.0-SNAPSHOT + 1.7.2-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index 05d93ad3..fddac42e 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ com.wso2telco.services.dep services-dep-parent pom - 1.2.0-SNAPSHOT + 1.7.2-SNAPSHOT WSO2Telco Core - Component WSO2Telco Core Aggregate Pom http://wso2telco.com