Skip to content

Commit 816a90b

Browse files
xlakannUmadevi-Kapu
authored andcommitted
ER Lookup configurations for a link when generating events for eiffel-remrem-generate. (#134)
1 parent 81fb79a commit 816a90b

File tree

6 files changed

+134
-5
lines changed

6 files changed

+134
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.6
2+
- Added ER Lookup configurations for a link when generating events
3+
- Uplifted eiffel-remrem-generate cersion from 2.0.5 to 2.0.6
4+
15
## 2.0.5
26
- Uplifted eiffel-remrem-parent version from 2.0.1 to 2.0.2.
37
- Uplifted eiffel-remrem-shared version from 2.0.1 to 2.0.2.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111

1212
<properties>
13-
<eiffel-remrem-generate.version>2.0.5</eiffel-remrem-generate.version>
13+
<eiffel-remrem-generate.version>2.0.6</eiffel-remrem-generate.version>
1414
<eiffel-remrem-shared.version>2.0.2</eiffel-remrem-shared.version>
1515
<eiffel-remrem-semantics.version>2.0.6</eiffel-remrem-semantics.version>
1616
</properties>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
Copyright 2019 Ericsson AB.
3+
For a full list of individual contributors, please see the commit history.
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
package com.ericsson.eiffel.remrem.generate.config;
16+
17+
import javax.annotation.PostConstruct;
18+
import org.slf4j.LoggerFactory;
19+
import org.springframework.beans.factory.annotation.Value;
20+
import org.springframework.context.annotation.Configuration;
21+
import org.springframework.context.annotation.Profile;
22+
import org.springframework.stereotype.Component;
23+
24+
import ch.qos.logback.classic.Logger;
25+
26+
/**
27+
* This class is used to check whether Event-Repository lookUp is enabled or not based on property
28+
* event-repository.enabled in property file.
29+
*
30+
*/
31+
32+
@Profile("!integration-test")
33+
@Configuration
34+
@Component("event-repository")
35+
public class ErLookUpConfig {
36+
37+
Logger log = (Logger) LoggerFactory.getLogger(ErLookUpConfig.class);
38+
39+
@Value("${event-repository.url}")
40+
private String erURL;
41+
@Value("${event-repository.enabled}")
42+
private String eventRepositoryEnabled;
43+
44+
private boolean eventRepositoryCheck;
45+
46+
public String getErURL() {
47+
return erURL;
48+
}
49+
50+
public void setErURL(String erURL) {
51+
this.erURL = erURL;
52+
}
53+
54+
public String getEventRepositoryEnabled() {
55+
return eventRepositoryEnabled;
56+
}
57+
58+
public void setEventRepositoryEnabled(String eventRepositoryEnabled) {
59+
this.eventRepositoryEnabled = eventRepositoryEnabled;
60+
}
61+
62+
63+
/**
64+
* This method is used to check whether to enable Event-Repository lookup .
65+
* If event-repository.enabled is false, it didn't perform lookup functionality while fetching events.
66+
* If event-repository.enabled is true, it sets ER URL for lookup and
67+
* if event-repository.enabled is not provided or mis-spelt or if event-repository.enabled = true and
68+
* event-repository.url not provided , then the service gets terminated.
69+
*
70+
*/
71+
@PostConstruct
72+
public void checkAndLoadEventRepositoryConfiguration() throws InterruptedException {
73+
if (eventRepositoryEnabled.equalsIgnoreCase("true") || eventRepositoryEnabled.equalsIgnoreCase("false")) {
74+
eventRepositoryCheck = Boolean.parseBoolean(eventRepositoryEnabled);
75+
log.info("Checking whether Event Repository configurations for lookup are enabled or not");
76+
if (eventRepositoryCheck) {
77+
if (!erURL.isEmpty()) {
78+
log.info("Event Repository configurations for lookup are enabled");
79+
setErURL(erURL);
80+
log.info("Configured Event Repository URL for lookup : " + getErURL());
81+
} else {
82+
log.error("Enabled Event Repository configurations for lookUp but not provided Event Repository URL");
83+
throw new InterruptedException("Event Repository URL not configured");
84+
85+
}
86+
} else {
87+
log.info("Event Repository configurations for lookup are not enabled");
88+
}
89+
} else {
90+
log.error("Please check and provide proper value for event-repository.enabled field in configuration file");
91+
log.info("Allowed values are either true or false");
92+
throw new InterruptedException("Provided incorrect values for lookup configurations");
93+
}
94+
}
95+
}

service/src/main/resources/application.properties

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ jasypt.encryptor.password:<Any value which was used at the time of encrypting th
1515

1616
#Ldap authentication configurations
1717

18-
activedirectory.generate.enabled:false
18+
activedirectory.generate.enabled:false
1919
activedirectory.ldapUrl :
2020
activedirectory.managerPassword : ENC(<encrypted password>) or password
2121
activedirectory.managerDn:
2222
activedirectory.rootDn :
23-
activedirectory.userSearchFilter:
23+
activedirectory.userSearchFilter:
24+
25+
#Event Repository configurations
26+
27+
event-repository.enabled:false
28+
event-repository.url :http://localhost:<port>/optional to specify context-path

service/src/main/resources/config.template.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@
2020
activedirectory.managerPassword : ENC(<encrypted password>) or password
2121
activedirectory.managerDn:
2222
activedirectory.rootDn :
23-
activedirectory.userSearchFilter:
23+
activedirectory.userSearchFilter:
24+
25+
#Event Repository configurations
26+
27+
event-repository.enabled:<true/false>(default value is false)
28+
event-repository.url :<http(s)://<event-repository hostname>:<port number>/<(optional to specify context-path)>

service/src/test/java/com/ericsson/eiffel/remrem/generate/integrationtest/EiffelRemremControllerIT.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import com.google.gson.JsonParser;
1818
import com.jayway.restassured.RestAssured;
19+
1920
import org.apache.http.HttpStatus;
2021
import org.hamcrest.Matchers;
2122
import org.junit.Before;
@@ -39,6 +40,9 @@
3940
import java.util.jar.Manifest;
4041

4142
import static com.jayway.restassured.RestAssured.given;
43+
import static org.junit.Assert.assertFalse;
44+
import static org.junit.Assert.assertNull;
45+
import static org.junit.Assert.assertTrue;
4246

4347
@ActiveProfiles("integration-test")
4448
@RunWith(SpringRunner.class)
@@ -58,6 +62,10 @@ public class EiffelRemremControllerIT {
5862
private String activityFinishedDuplicateKeysBody;
5963

6064
private String version = "3.0.0";
65+
@Value("${event-repository.enabled}")
66+
private boolean eventRepositoryEnabled;
67+
@Value("${event-repository.url}")
68+
private String erURL;
6169

6270
private String credentials = "Basic " + Base64.getEncoder().encodeToString("user:secret".getBytes());
6371

@@ -80,7 +88,7 @@ private String loadEventBody(final String fileName) throws IOException {
8088
final byte[] bytes = Files.readAllBytes(file.toPath());
8189
return new String(bytes);
8290
}
83-
91+
8492
public static String getMessagingVersion() {
8593
Enumeration resEnum;
8694
try {
@@ -195,4 +203,16 @@ public void testGetEventTypeTemplateNoFileExists() {
195203
.then()
196204
.statusCode(HttpStatus.SC_NOT_FOUND);
197205
}
206+
@Test
207+
public void testErLookUpConfigurations(){
208+
if(eventRepositoryEnabled){
209+
if(!erURL.isEmpty())
210+
assertTrue(erURL,true);
211+
else
212+
assertNull(erURL,null);
213+
}
214+
else{
215+
assertFalse(eventRepositoryEnabled);
216+
}
217+
}
198218
}

0 commit comments

Comments
 (0)