diff --git a/.gitignore b/.gitignore index a524e30f..f8c91664 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,15 @@ repos/ smsmoduledb.* -!gradle/wrapper/gradle-wrapper.jar \ No newline at end of file +!gradle/wrapper/gradle-wrapper.jar + +###################### +# Mac OSX +###################### +.DS_Store +.svn + +###################### +# jenv +###################### +.java-version diff --git a/README.md b/README.md index 4688846e..9c63e3e8 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,39 @@ # message-gateway +## Development +To start your in dev mode, run: +``` +./gradlew bootRun +``` ## Build set up -##### To create standalone application: - ./gradlew clean build +To create standalone application run: + +``` +./gradlew clean build +``` +You can also create a standalone application by running: +``` +./gradlew clean bootJar +``` + ##### To run - cd build/lib - - java -jar message-gateway-0.0.1.jar + +``` +cd build/lib + +java -jar message-gateway-0.0.1.jar +``` + +You can also run the application without packaging +``` +./gradlew bootRun +``` ##### To create deployable war: +``` ./gradlew clean build -Pprofile=deployable +``` war file can be found in build/libs diff --git a/build.gradle b/build.gradle index 4e088680..ab9e2606 100644 --- a/build.gradle +++ b/build.gradle @@ -6,19 +6,20 @@ buildscript { jcenter() } dependencies { - classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.1.5.RELEASE', - 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0' } } -apply plugin: 'java' -apply plugin: 'idea' -apply plugin: 'eclipse' -apply plugin: 'spring-boot' -apply plugin: 'license' +plugins { + id 'org.springframework.boot' version '2.1.0.RELEASE' + // id 'io.spring.dependency-management' version '1.0.11.RELEASE' + id 'java' + id 'idea' + id 'eclipse' + id "com.github.hierynomus.license" version "0.15.0" + id 'war' +} -if (project.hasProperty('profile') - && project.getProperty('profile') == 'deployable') { +if (project.hasProperty('profile') && project.getProperty('profile') == 'deployable') { apply from: 'profile-deployable.gradle' } else { apply from: 'profile-standalone.gradle' @@ -31,9 +32,15 @@ repositories { maven { url "https://repository.jboss.org/nexus/content/repositories/releases" } } +group 'org.fineract' +version '0.0.1' +sourceCompatibility=11 +targetCompatibility=11 +assert System.properties["java.specification.version"] == "1.8" || "1.9" || "10" || "11" + license { header rootProject.file('./LICENSE.md') - excludes(["**/*.html", "**/*.mustache", "**/package-info.java", "**/keystore.jks"]) + excludes(["**/*.html", "**/*.yml", "**/*.mustache", "**/package-info.java", "**/keystore.jks"]) strictCheck true } @@ -42,22 +49,33 @@ task licenseFormatBuildScripts (type:nl.javadude.gradle.plugins.license.License) } licenseFormat.dependsOn licenseFormatBuildScripts + dependencies { - compile("org.springframework.boot:spring-boot-starter-web") - compile("org.springframework.boot:spring-boot-starter-actuator") - compile("org.springframework.boot:spring-boot-starter-data-jpa") - compile("org.flywaydb:flyway-core") - compile('org.apache.velocity:velocity:1.7') - compile('com.squareup.okhttp:okhttp:2.0.0') - compile('com.squareup.okhttp:okhttp-urlconnection:2.0.0') - compile('com.squareup.retrofit:retrofit:1.6.1') - compile('com.twilio.sdk:twilio:7.1.0') - compile('org.drizzle.jdbc:drizzle-jdbc:1.3') - compile('com.infobip:infobip-api-java-client:1.1.0') - testCompile("org.springframework.boot:spring-boot-starter-test") - -} - -task wrapper(type: Wrapper) { - gradleVersion = '1.11' + + implementation "org.springframework.boot:spring-boot-starter-web:${springBootVersion}" + implementation "org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}" + implementation "org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}" + testImplementation "org.springframework.boot:spring-boot-starter-test:${springBootVersion}" + implementation "org.flywaydb:flyway-core:${flywayCoreBootVersion}" + implementation "org.apache.velocity:velocity:${apacheVelocityVersion}" + implementation "com.squareup.okhttp:okhttp:${squareupOkhttpVersion}" + implementation "com.squareup.okhttp:okhttp-urlconnection:${squareupOkhttpUrlConnectionVersion}" + implementation "com.squareup.retrofit:retrofit:${squareupRetrofitVersion}" + implementation "com.twilio.sdk:twilio:${twilioSdkVersion}" + implementation "org.drizzle.jdbc:drizzle-jdbc:${drizzleJdbcVersion}" + implementation "com.google.code.gson:gson:${googleCodeGsonVersion}" + implementation ("com.infobip:infobip-api-java-client:${infobipApiJavaClientVersion}") { + exclude group: 'com.google.code.gson', module: 'gson' + } +} + +bootJar { + mainClassName = "org.fineract.messagegateway.MessageGateway" +} + +test { + useJUnitPlatform() +} +wrapper { + gradleVersion = '6.6.1' } diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..799e66aa --- /dev/null +++ b/gradle.properties @@ -0,0 +1,12 @@ +rootProject.name=message-gateway + +springBootVersion=2.4.4 +flywayCoreBootVersion=6.5.7 +apacheVelocityVersion:1.7 +squareupOkhttpVersion:2.0.0 +squareupOkhttpUrlConnectionVersion:2.0.0 +squareupRetrofitVersion:1.6.1 +twilioSdkVersion:7.1.0 +drizzleJdbcVersion:1.4 +googleCodeGsonVersion:2.8.7 +infobipApiJavaClientVersion:2.3.0 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5819be93..9b485717 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,6 @@ -#Wed Sep 03 14:15:20 CEST 2014 +#Sun Jun 13 01:47:04 CDT 2021 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip - +distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 index 91a7e269..9d82f789 --- a/gradlew +++ b/gradlew @@ -42,11 +42,6 @@ case "`uname`" in ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" @@ -61,9 +56,9 @@ while [ -h "$PRG" ] ; do fi done SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- +cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" -cd "$SAVED" >&- +cd "$SAVED" >/dev/null CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -114,6 +109,7 @@ fi if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` diff --git a/gradlew.bat b/gradlew.bat index 24131cc0..aec99730 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,109 +1,90 @@ -@REM -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/profile-deployable.gradle b/profile-deployable.gradle index 0c9fa7e1..b6ec7995 100644 --- a/profile-deployable.gradle +++ b/profile-deployable.gradle @@ -10,5 +10,5 @@ war { } dependencies { - providedRuntime("org.springframework.boot:spring-boot-starter-tomcat") + providedRuntime("org.springframework.boot:spring-boot-starter-tomcat:${springBootVersion}") } diff --git a/profile-standalone.gradle b/profile-standalone.gradle index 4c341d54..2b66d8b1 100644 --- a/profile-standalone.gradle +++ b/profile-standalone.gradle @@ -1,4 +1,4 @@ jar { - baseName = 'message-gateway' - version = '0.0.1' + archiveBaseName = 'message-gateway' + archiveVersion = '0.0.1' } diff --git a/src/main/java/org/fineract/messagegateway/configuration/MessageGatewayConfiguration.java b/src/main/java/org/fineract/messagegateway/configuration/MessageGatewayConfiguration.java index f778172b..fd9539dc 100644 --- a/src/main/java/org/fineract/messagegateway/configuration/MessageGatewayConfiguration.java +++ b/src/main/java/org/fineract/messagegateway/configuration/MessageGatewayConfiguration.java @@ -24,7 +24,7 @@ import org.fineract.messagegateway.sms.domain.SMSMessage; import org.fineract.messagegateway.tenants.domain.Tenant; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.orm.jpa.EntityScan; +import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; diff --git a/src/main/java/org/fineract/messagegateway/configuration/MessageGatewayInitializer.java b/src/main/java/org/fineract/messagegateway/configuration/MessageGatewayInitializer.java index 23935c45..dd36398e 100644 --- a/src/main/java/org/fineract/messagegateway/configuration/MessageGatewayInitializer.java +++ b/src/main/java/org/fineract/messagegateway/configuration/MessageGatewayInitializer.java @@ -19,7 +19,7 @@ package org.fineract.messagegateway.configuration; import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.context.web.SpringBootServletInitializer; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; public class MessageGatewayInitializer extends SpringBootServletInitializer { diff --git a/src/main/java/org/fineract/messagegateway/helpers/JsonParserHelper.java b/src/main/java/org/fineract/messagegateway/helpers/JsonParserHelper.java index 0c437c65..0cd42c19 100644 --- a/src/main/java/org/fineract/messagegateway/helpers/JsonParserHelper.java +++ b/src/main/java/org/fineract/messagegateway/helpers/JsonParserHelper.java @@ -36,7 +36,7 @@ import org.joda.time.MonthDay; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; -import org.springframework.format.number.NumberFormatter; +import org.springframework.format.number.NumberStyleFormatter; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -611,7 +611,7 @@ public BigDecimal convertFrom(final String numericalValueFormatted, final String source = source.replaceAll(" ", Character.toString('\u00a0')); } - final NumberFormatter numberFormatter = new NumberFormatter(); + final NumberStyleFormatter numberFormatter = new NumberStyleFormatter(); final Number parsedNumber = numberFormatter.parse(source, clientApplicationLocale); if (parsedNumber instanceof BigDecimal) { number = (BigDecimal) parsedNumber; @@ -708,4 +708,4 @@ private Locale extractLocaleValue(final JsonObject object) { } return clientApplicationLocale; } -} \ No newline at end of file +} diff --git a/src/main/java/org/fineract/messagegateway/sms/domain/AbstractPersistableCustom.java b/src/main/java/org/fineract/messagegateway/sms/domain/AbstractPersistableCustom.java index 6213d1ec..a57c5306 100644 --- a/src/main/java/org/fineract/messagegateway/sms/domain/AbstractPersistableCustom.java +++ b/src/main/java/org/fineract/messagegateway/sms/domain/AbstractPersistableCustom.java @@ -32,7 +32,7 @@ public abstract class AbstractPersistableCustom implements Persistable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) protected PK id; /* @@ -116,4 +116,4 @@ public int hashCode() { return hashCode; } -} \ No newline at end of file +} diff --git a/src/main/java/org/fineract/messagegateway/sms/providers/impl/infobip/InfoBipApiResource.java b/src/main/java/org/fineract/messagegateway/sms/providers/impl/infobip/InfoBipApiResource.java index 74da33b3..c6ddd53f 100644 --- a/src/main/java/org/fineract/messagegateway/sms/providers/impl/infobip/InfoBipApiResource.java +++ b/src/main/java/org/fineract/messagegateway/sms/providers/impl/infobip/InfoBipApiResource.java @@ -34,6 +34,8 @@ import infobip.api.model.sms.mt.reports.SMSReport; import infobip.api.model.sms.mt.reports.SMSReportResponse; +import java.util.Optional; + @RestController @RequestMapping("/infobip") public class InfoBipApiResource { @@ -49,8 +51,10 @@ public InfoBipApiResource(final SmsOutboundMessageRepository smsOutboundMessageR @RequestMapping(value = "/report/{messageId}", method = RequestMethod.POST, consumes = {"application/json"}, produces = {"application/json"}) public ResponseEntity updateDeliveryStatus(@PathVariable("messageId") final Long messageId, @RequestBody final SMSReportResponse payload) { - SMSMessage message = this.smsOutboundMessageRepository.findOne(messageId) ; - if(message != null) { +// SMSMessage message = this.smsOutboundMessageRepository.findById(messageId) ; + Optional optMessage = this.smsOutboundMessageRepository.findById(messageId); + SMSMessage message = optMessage.orElse(null); + if(message != null) { SMSReport report = payload.getResults().get(0) ; logger.debug("Status Callback received from InfoBip for "+messageId+" with status:"+report.getStatus()); message.setDeliveryStatus(InfoBipStatus.smsStatus(report.getStatus().getGroupId()).getValue()); diff --git a/src/main/java/org/fineract/messagegateway/sms/providers/impl/jasmin/JasminSMSApiResource.java b/src/main/java/org/fineract/messagegateway/sms/providers/impl/jasmin/JasminSMSApiResource.java index 2afa64c3..78375d89 100644 --- a/src/main/java/org/fineract/messagegateway/sms/providers/impl/jasmin/JasminSMSApiResource.java +++ b/src/main/java/org/fineract/messagegateway/sms/providers/impl/jasmin/JasminSMSApiResource.java @@ -32,6 +32,8 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.Optional; + @RestController @RequestMapping("/jasminsms") public class JasminSMSApiResource { @@ -57,7 +59,8 @@ public ResponseEntity updateDeliveryStatus(@PathVariable("messageId") fina @RequestParam("dlvrd") Integer dlvrd, @RequestParam("err") Integer err, @RequestParam("text") String text) { - SMSMessage message = this.smsOutboundMessageRepository.findOne(messageId) ; + Optional optMessage = this.smsOutboundMessageRepository.findById(messageId) ; + SMSMessage message = optMessage.orElse(null); if(message != null) { logger.info("Status Callback received from JasminSMS for "+messageId+" with status:"+messageStatus); message.setDeliveryStatus(smsStatus(messageStatus).getValue()); diff --git a/src/main/java/org/fineract/messagegateway/sms/providers/impl/twilio/TwilioApiResource.java b/src/main/java/org/fineract/messagegateway/sms/providers/impl/twilio/TwilioApiResource.java index 4e7fb822..6dc7adb5 100644 --- a/src/main/java/org/fineract/messagegateway/sms/providers/impl/twilio/TwilioApiResource.java +++ b/src/main/java/org/fineract/messagegateway/sms/providers/impl/twilio/TwilioApiResource.java @@ -31,6 +31,8 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import java.util.Optional; + @RestController @RequestMapping("/twilio") public class TwilioApiResource { @@ -46,7 +48,8 @@ public TwilioApiResource(final SmsOutboundMessageRepository smsOutboundMessageRe @RequestMapping(value = "/report/{messageId}", method = RequestMethod.POST, consumes = {"application/x-www-form-urlencoded"}, produces = {"application/x-www-form-urlencoded"}) public ResponseEntity updateDeliveryStatus(@PathVariable("messageId") final Long messageId, @ModelAttribute final TwilioReponseData payload) { - SMSMessage message = this.smsOutboundMessageRepository.findOne(messageId) ; + Optional optMessage = this.smsOutboundMessageRepository.findById(messageId) ; + SMSMessage message = optMessage.orElse(null); if(message != null) { logger.info("Status Callback received from Twilio for "+messageId+" with status:"+payload.getMessageStatus()); message.setDeliveryStatus(TwilioStatus.smsStatus(payload.getMessageStatus()).getValue()); diff --git a/src/main/java/org/fineract/messagegateway/sms/service/SMSMessageService.java b/src/main/java/org/fineract/messagegateway/sms/service/SMSMessageService.java index 06159cc8..35f92911 100644 --- a/src/main/java/org/fineract/messagegateway/sms/service/SMSMessageService.java +++ b/src/main/java/org/fineract/messagegateway/sms/service/SMSMessageService.java @@ -92,7 +92,7 @@ public void sendShortMessage(final String tenantId, final String tenantAppKey, f for(SMSMessage message: messages) { message.setTenant(tenant.getId()); } - this.smsOutboundMessageRepository.save(messages) ; + this.smsOutboundMessageRepository.saveAll(messages) ; this.executorService.execute(new MessageTask(tenant, this.smsOutboundMessageRepository, this.smsProviderFactory, messages)); } @@ -150,7 +150,7 @@ public MessageTask(final Tenant tenant, final SmsOutboundMessageRepository smsOu @Override public void run() { this.smsProviderFactory.sendShortMessage(messages); - this.smsOutboundMessageRepository.save(messages) ; + this.smsOutboundMessageRepository.saveAll(messages) ; } } @@ -171,14 +171,14 @@ public Integer call() throws Exception { Integer initialSize = 200; Integer totalPageSize = 0; do { - PageRequest pageRequest = new PageRequest(page, initialSize); + PageRequest pageRequest = PageRequest.of(page, initialSize); logger.info("Reading Pending Messages on bootup....."); Page messages = this.smsOutboundMessageRepository.findByDeliveryStatus(SmsMessageStatusType.PENDING.getValue(), pageRequest) ; logger.info("Pending Messages size.....{}", messages.getTotalElements()); page++; totalPageSize = messages.getTotalPages(); this.smsProviderFactory.sendShortMessage(messages.getContent()); - this.smsOutboundMessageRepository.save(messages) ; + this.smsOutboundMessageRepository.saveAll(messages) ; }while (page < totalPageSize); return totalPageSize; } diff --git a/src/main/resources/db/migration/V1__Initial_Setup.sql b/src/main/resources/db/migration/V1__Initial_Setup.sql index ba772b79..e2ac0457 100644 --- a/src/main/resources/db/migration/V1__Initial_Setup.sql +++ b/src/main/resources/db/migration/V1__Initial_Setup.sql @@ -1,3 +1,7 @@ +-- noinspection SqlNoDataSourceInspectionForFile + +-- noinspection SqlDialectInspectionForFile + -- -- Licensed to the Apache Software Foundation (ASF) under one -- or more contributor license agreements. See the NOTICE file @@ -46,8 +50,8 @@ CREATE TABLE m_outbound_messages ( source_address VARCHAR(100) NULL DEFAULT NULL, sms_bridge_id BIGINT(20) NOT NULL, mobile_number VARCHAR(255) NOT NULL, - submitted_on_date TIMESTAMP NOT NULL, delivered_on_date TIMESTAMP NOT NULL, + submitted_on_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, delivery_status INT(3) NOT NULL, message VARCHAR(4096) NOT NULL, CONSTRAINT `m_outbound_messages_1` FOREIGN KEY (`sms_bridge_id`) REFERENCES `m_sms_bridge` (`id`)