forked from Raxa/raxacore
-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refractored sms with use of token instead of session and made the pro…
…cess async
- Loading branch information
1 parent
cb0581a
commit 7529244
Showing
11 changed files
with
140 additions
and
105 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
bahmnicore-api/src/main/java/org/bahmni/module/bahmnicore/config/AsyncConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.bahmni.module.bahmnicore.config; | ||
|
||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.scheduling.annotation.EnableAsync; | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
|
||
import java.util.concurrent.Executor; | ||
@Configuration | ||
@EnableAsync | ||
public class AsyncConfig { | ||
|
||
@Bean(name = "bahmniCoreAsync") | ||
public Executor threadPoolTaskExecutor() { | ||
ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor(); | ||
return threadPoolTaskExecutor; | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
...nicore-api/src/main/java/org/bahmni/module/bahmnicore/service/RegistrationSmsService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
package org.bahmni.module.bahmnicore.service; | ||
|
||
import org.openmrs.api.context.UserContext; | ||
import org.openmrs.module.emrapi.patient.PatientProfile; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
public interface RegistrationSmsService { | ||
@Transactional(readOnly = true) | ||
void sendRegistrationSMS(PatientProfile profile,String location,String reportingSessionCookie); | ||
void sendRegistrationSMS(PatientProfile profile, String location, UserContext userContext); | ||
} |
46 changes: 23 additions & 23 deletions
46
...nicore-api/src/main/java/org/bahmni/module/bahmnicore/service/impl/ConnectionDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
package org.bahmni.module.bahmnicore.service.impl; | ||
|
||
|
||
import org.bahmni.module.bahmnicore.properties.BahmniCoreProperties; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class ConnectionDetails { | ||
private static final String AUTH_URI = "openmrs.auth.uri"; | ||
private static final String OPENMRS_USER = "openmrs.user"; | ||
private static final String OPENMRS_PASSWORD = "openmrs.password"; | ||
private static final String OPENMRS_WEBCLIENT_CONNECT_TIMEOUT = "openmrs.connectionTimeoutInMilliseconds"; | ||
private static final String OPENMRS_WEBCLIENT_READ_TIMEOUT = "openmrs.replyTimeoutInMilliseconds"; | ||
|
||
public static org.bahmni.webclients.ConnectionDetails get() { | ||
return new org.bahmni.webclients.ConnectionDetails( | ||
BahmniCoreProperties.getProperty(AUTH_URI), | ||
BahmniCoreProperties.getProperty(OPENMRS_USER), | ||
BahmniCoreProperties.getProperty(OPENMRS_PASSWORD), | ||
Integer.parseInt(BahmniCoreProperties.getProperty(OPENMRS_WEBCLIENT_CONNECT_TIMEOUT)), | ||
Integer.parseInt(BahmniCoreProperties.getProperty(OPENMRS_WEBCLIENT_READ_TIMEOUT))); | ||
} | ||
} | ||
//package org.bahmni.module.bahmnicore.service.impl; | ||
// | ||
// | ||
//import org.bahmni.module.bahmnicore.properties.BahmniCoreProperties; | ||
//import org.springframework.stereotype.Component; | ||
// | ||
//@Component | ||
//public class ConnectionDetails { | ||
// private static final String AUTH_URI = "openmrs.auth.uri"; | ||
// private static final String OPENMRS_USER = "openmrs.user"; | ||
// private static final String OPENMRS_PASSWORD = "openmrs.password"; | ||
// private static final String OPENMRS_WEBCLIENT_CONNECT_TIMEOUT = "openmrs.connectionTimeoutInMilliseconds"; | ||
// private static final String OPENMRS_WEBCLIENT_READ_TIMEOUT = "openmrs.replyTimeoutInMilliseconds"; | ||
// | ||
// public static org.bahmni.webclients.ConnectionDetails get() { | ||
// return new org.bahmni.webclients.ConnectionDetails( | ||
// BahmniCoreProperties.getProperty(AUTH_URI), | ||
// BahmniCoreProperties.getProperty(OPENMRS_USER), | ||
// BahmniCoreProperties.getProperty(OPENMRS_PASSWORD), | ||
// Integer.parseInt(BahmniCoreProperties.getProperty(OPENMRS_WEBCLIENT_CONNECT_TIMEOUT)), | ||
// Integer.parseInt(BahmniCoreProperties.getProperty(OPENMRS_WEBCLIENT_READ_TIMEOUT))); | ||
// } | ||
//} |
70 changes: 35 additions & 35 deletions
70
bahmnicore-api/src/main/java/org/bahmni/module/bahmnicore/service/impl/OpenmrsLoginImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
package org.bahmni.module.bahmnicore.service.impl; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
|
||
import org.bahmni.module.bahmnicore.service.OpenmrsLogin; | ||
import org.bahmni.webclients.ClientCookies; | ||
import org.bahmni.webclients.HttpClient; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class OpenmrsLoginImpl implements OpenmrsLogin { | ||
private ClientCookies cookies; | ||
|
||
@Override | ||
public void getConnection() { | ||
HttpClient authenticatedWebClient = WebClientFactory.getClient(); | ||
org.bahmni.webclients.ConnectionDetails connectionDetails = ConnectionDetails.get(); | ||
String authUri = connectionDetails.getAuthUrl(); | ||
getCookiesAfterConnection(authenticatedWebClient, authUri); | ||
} | ||
|
||
public void getCookiesAfterConnection(HttpClient authenticatedWebClient, String urlString) { | ||
try { | ||
this.cookies = authenticatedWebClient.getCookies(new URI(urlString)); | ||
} catch (URISyntaxException e) { | ||
throw new RuntimeException("Is not a valid URI - " + urlString); | ||
} | ||
} | ||
|
||
@Override | ||
public ClientCookies getCookies() { | ||
return cookies; | ||
} | ||
} | ||
//package org.bahmni.module.bahmnicore.service.impl; | ||
// | ||
//import java.net.URI; | ||
//import java.net.URISyntaxException; | ||
// | ||
//import org.bahmni.module.bahmnicore.service.OpenmrsLogin; | ||
//import org.bahmni.webclients.ClientCookies; | ||
//import org.bahmni.webclients.HttpClient; | ||
//import org.springframework.stereotype.Component; | ||
// | ||
//@Component | ||
//public class OpenmrsLoginImpl implements OpenmrsLogin { | ||
// private ClientCookies cookies; | ||
// | ||
// @Override | ||
// public void getConnection() { | ||
// HttpClient authenticatedWebClient = WebClientFactory.getClient(); | ||
// org.bahmni.webclients.ConnectionDetails connectionDetails = ConnectionDetails.get(); | ||
// String authUri = connectionDetails.getAuthUrl(); | ||
// getCookiesAfterConnection(authenticatedWebClient, authUri); | ||
// } | ||
// | ||
// public void getCookiesAfterConnection(HttpClient authenticatedWebClient, String urlString) { | ||
// try { | ||
// this.cookies = authenticatedWebClient.getCookies(new URI(urlString)); | ||
// } catch (URISyntaxException e) { | ||
// throw new RuntimeException("Is not a valid URI - " + urlString); | ||
// } | ||
// } | ||
// | ||
// @Override | ||
// public ClientCookies getCookies() { | ||
// return cookies; | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 21 additions & 21 deletions
42
bahmnicore-api/src/main/java/org/bahmni/module/bahmnicore/service/impl/WebClientFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
package org.bahmni.module.bahmnicore.service.impl; | ||
|
||
import org.bahmni.webclients.ConnectionDetails; | ||
import org.bahmni.webclients.HttpClient; | ||
import org.bahmni.webclients.openmrs.OpenMRSLoginAuthenticator; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class WebClientFactory { | ||
|
||
public static HttpClient getClient() { | ||
ConnectionDetails connectionDetails = org.bahmni.module.bahmnicore.service.impl.ConnectionDetails.get(); | ||
return new HttpClient(connectionDetails, getAuthenticator(connectionDetails)); | ||
} | ||
|
||
|
||
private static OpenMRSLoginAuthenticator getAuthenticator(ConnectionDetails connectionDetails) { | ||
return new OpenMRSLoginAuthenticator(connectionDetails); | ||
|
||
} | ||
} | ||
//package org.bahmni.module.bahmnicore.service.impl; | ||
// | ||
//import org.bahmni.webclients.ConnectionDetails; | ||
//import org.bahmni.webclients.HttpClient; | ||
//import org.bahmni.webclients.openmrs.OpenMRSLoginAuthenticator; | ||
//import org.springframework.stereotype.Component; | ||
// | ||
//@Component | ||
//public class WebClientFactory { | ||
// | ||
// public static HttpClient getaClient() { | ||
// ConnectionDetails connectionDetails = org.bahmni.module.bahmnicore.service.impl.ConnectionDetails.get(); | ||
// return new HttpClient(connectionDetails, getAuthenticator(connectionDetails)); | ||
// } | ||
// | ||
// | ||
// private static OpenMRSLoginAuthenticator getAuthenticator(ConnectionDetails connectionDetails) { | ||
// return new OpenMRSLoginAuthenticator(connectionDetails); | ||
// | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters