Skip to content

Commit 14fcffd

Browse files
authored
Fix the reset password issue (#131)
* fix: reset password * fix: build issue * fix: update the url * fix: update config properties * fix: initialize constructor
1 parent 09b4650 commit 14fcffd

4 files changed

Lines changed: 73 additions & 14 deletions

File tree

src/main/java/com/iemr/admin/service/employeemaster/EmployeeMasterServiceImpl.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.slf4j.Logger;
4646
import org.slf4j.LoggerFactory;
4747
import org.springframework.beans.factory.annotation.Autowired;
48+
import org.springframework.beans.factory.annotation.Value;
4849
import org.springframework.http.HttpEntity;
4950
import org.springframework.http.HttpMethod;
5051
import org.springframework.http.ResponseEntity;
@@ -113,7 +114,10 @@ public class EmployeeMasterServiceImpl implements EmployeeMasterInter {
113114

114115
private static HttpUtils httpUtils = new HttpUtils();
115116

116-
private String common_url = ConfigProperties.getPropertyByName("common-url");
117+
@Value("${common-url}")
118+
private String common_url;
119+
120+
// private String common_url = ConfigProperties.getPropertyByName("common-url");
117121

118122
private final String COMMON_BASE_URL = "common-url";
119123

@@ -470,7 +474,7 @@ private Set<String> getCTICampaignRoles(String campaignName, String authToken) t
470474
ObjectMapper objectMapper = new ObjectMapper();
471475
Set<String> resultSet = new HashSet<String>();
472476
HttpEntity<Object> request = RestTemplateUtil.createRequestEntity(campaignName, authToken);
473-
String url = configProperties.getPropertyByName("common-url") + configProperties.getPropertyByName("create-feedback");
477+
String url = common_url +"/" + configProperties.getPropertyByName("create-feedback");
474478

475479
ResponseEntity<String> responseStr = restTemplate.exchange(url, HttpMethod.POST, request, String.class);
476480
OutputResponse response = objectMapper.readValue(responseStr.getBody(), OutputResponse.class);
@@ -713,7 +717,8 @@ public void createUserInCallCentre(M_User1 user, String authToken) {
713717
logger.info("EmployeeMasterServiceImpl.createUserInCallCentre - start");
714718
if (ENABLE_CTI_USER_CREATION) {
715719
String UserCreateAPIURL = "";
716-
String ctiServer = configProperties.getPropertyByName("common-url");
720+
// String ctiServer = configProperties.getPropertyByName("common-url");
721+
String ctiServer=common_url;
717722
UserCreateAPIURL = ctiServer + configProperties.getPropertyByName("create-update-users-url");
718723
HashMap<String, Object> headers = new HashMap<String, Object>();
719724
JSONObject request = new JSONObject();
@@ -747,7 +752,8 @@ public void updateUserInCallCentre(String userName, String ctiRole, String authT
747752

748753
if (ENABLE_CTI_USER_CREATION) {
749754
String UserCreateAPIURL = "";
750-
String ctiServer = configProperties.getPropertyByName("common-url");
755+
// String ctiServer = configProperties.getPropertyByName("common-url");
756+
String ctiServer=common_url;
751757
UserCreateAPIURL = ctiServer + configProperties.getPropertyByName("create-update-users-url");
752758
HashMap<String, Object> headers = new HashMap<String, Object>();
753759
JSONObject request = new JSONObject();

src/main/java/com/iemr/admin/service/provideronboard/EncryptUserPassword123.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.json.JSONObject;
2525
import org.slf4j.Logger;
2626
import org.slf4j.LoggerFactory;
27+
import org.springframework.beans.factory.annotation.Value;
2728
import org.springframework.scheduling.annotation.Async;
2829
import org.springframework.stereotype.Service;
2930

@@ -34,15 +35,31 @@
3435
import com.iemr.admin.utils.mapper.InputMapper;
3536
import com.iemr.admin.utils.response.OutputResponse;
3637

38+
import jakarta.annotation.PostConstruct;
39+
3740
@Service
3841
public class EncryptUserPassword123 {
3942
private static HttpUtils utils = new HttpUtils();
40-
private static String commonBaseURL = ConfigProperties.getPropertyByName("common-url");
41-
private static String encryptPasswordURL = commonBaseURL
42-
+ ConfigProperties.getPropertyByName("encrypt-password-url");
43+
// private static String commonBaseURL =
44+
// ConfigProperties.getPropertyByName("common-url");
45+
46+
@Value("${common-url}")
47+
private String commonBaseURL;
48+
49+
// private String encryptPasswordURL = commonBaseURL + "/"
50+
// + ConfigProperties.getPropertyByName("encrypt-password-url");
4351

4452
private Logger logger = LoggerFactory.getLogger(this.getClass().getName());
4553

54+
private String encryptPasswordURL;
55+
56+
@PostConstruct
57+
public void init() {
58+
encryptPasswordURL = commonBaseURL + "/" +
59+
ConfigProperties.getPropertyByName("encrypt-password-url");
60+
logger.info("commonBaseURL=" + encryptPasswordURL);
61+
}
62+
4663
@Async
4764
public OutputResponse encryptUserCredentials(M_User data) {
4865
JSONObject request = new JSONObject();

src/main/java/com/iemr/admin/service/user/EncryptUserPassword.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.json.JSONObject;
2525
import org.slf4j.Logger;
2626
import org.slf4j.LoggerFactory;
27+
import org.springframework.beans.factory.annotation.Value;
2728
import org.springframework.scheduling.annotation.Async;
2829
import org.springframework.stereotype.Service;
2930

@@ -33,15 +34,34 @@
3334
import com.iemr.admin.utils.mapper.InputMapper;
3435
import com.iemr.admin.utils.response.OutputResponse;
3536

37+
import jakarta.annotation.PostConstruct;
38+
3639
@Service
3740
public class EncryptUserPassword {
3841
private static HttpUtils utils = new HttpUtils();
39-
private static String commonBaseURL = ConfigProperties.getPropertyByName("common-url");
40-
private static String encryptPasswordURL = commonBaseURL
41-
+ ConfigProperties.getPropertyByName("encrypt-password-url");
42+
43+
@Value("${common-url}")
44+
private String commonBaseURL;
45+
46+
// @Value("${encrypt-password-url}")
47+
// private String encryptPasswordEndpoint;
48+
49+
// private static String commonBaseURL =
50+
// ConfigProperties.getPropertyByName("common-url");
51+
// private String encryptPasswordURL = commonBaseURL + "/" +
52+
// ConfigProperties.getPropertyByName("encrypt-password-url");
4253

4354
private Logger logger = LoggerFactory.getLogger(this.getClass().getName());
4455

56+
private String encryptPasswordURL;
57+
58+
@PostConstruct
59+
public void init() {
60+
encryptPasswordURL = commonBaseURL + "/" +
61+
ConfigProperties.getPropertyByName("encrypt-password-url");
62+
logger.info("commonBaseURL" + encryptPasswordURL);
63+
}
64+
4565
@Async
4666
public OutputResponse encryptUserCredentials(M_User1 data) {
4767
JSONObject request = new JSONObject();

src/main/java/com/iemr/admin/utils/config/ConfigProperties.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,27 @@ public static int getSessionExpiryTime() {
118118
public static String getPropertyByName(String propertyName) {
119119
String result = null;
120120
try {
121-
if (properties == null) {
122-
initalizeProperties();
121+
// if (properties == null) {
122+
// initalizeProperties();
123+
// }
124+
// // result = environment.getProperty(propertyName);
125+
// result = properties.getProperty(propertyName);
126+
127+
if (environment != null)
128+
{
129+
result = environment.getProperty(propertyName);
130+
}
131+
if (result == null)
132+
{
133+
if (properties == null)
134+
{
135+
initalizeProperties();
136+
}
137+
result = properties.getProperty(propertyName).trim();
138+
} else
139+
{
140+
result = result.trim();
123141
}
124-
// result = environment.getProperty(propertyName);
125-
result = properties.getProperty(propertyName);
126142
} catch (Exception e) {
127143
logger.error(propertyName + " retrival failed.", e);
128144
}

0 commit comments

Comments
 (0)