Skip to content

Commit

Permalink
ER Lookup configurations for a link when generating events for eiffel…
Browse files Browse the repository at this point in the history
…-remrem-generate. (#134)
  • Loading branch information
xlakann authored and Umadevi-Kapu committed Oct 1, 2019
1 parent 81fb79a commit 816a90b
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.6
- Added ER Lookup configurations for a link when generating events
- Uplifted eiffel-remrem-generate cersion from 2.0.5 to 2.0.6

## 2.0.5
- Uplifted eiffel-remrem-parent version from 2.0.1 to 2.0.2.
- Uplifted eiffel-remrem-shared version from 2.0.1 to 2.0.2.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>

<properties>
<eiffel-remrem-generate.version>2.0.5</eiffel-remrem-generate.version>
<eiffel-remrem-generate.version>2.0.6</eiffel-remrem-generate.version>
<eiffel-remrem-shared.version>2.0.2</eiffel-remrem-shared.version>
<eiffel-remrem-semantics.version>2.0.6</eiffel-remrem-semantics.version>
</properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
Copyright 2019 Ericsson AB.
For a full list of individual contributors, please see the commit history.
Licensed 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.ericsson.eiffel.remrem.generate.config;

import javax.annotation.PostConstruct;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

import ch.qos.logback.classic.Logger;

/**
* This class is used to check whether Event-Repository lookUp is enabled or not based on property
* event-repository.enabled in property file.
*
*/

@Profile("!integration-test")
@Configuration
@Component("event-repository")
public class ErLookUpConfig {

Logger log = (Logger) LoggerFactory.getLogger(ErLookUpConfig.class);

@Value("${event-repository.url}")
private String erURL;
@Value("${event-repository.enabled}")
private String eventRepositoryEnabled;

private boolean eventRepositoryCheck;

public String getErURL() {
return erURL;
}

public void setErURL(String erURL) {
this.erURL = erURL;
}

public String getEventRepositoryEnabled() {
return eventRepositoryEnabled;
}

public void setEventRepositoryEnabled(String eventRepositoryEnabled) {
this.eventRepositoryEnabled = eventRepositoryEnabled;
}


/**
* This method is used to check whether to enable Event-Repository lookup .
* If event-repository.enabled is false, it didn't perform lookup functionality while fetching events.
* If event-repository.enabled is true, it sets ER URL for lookup and
* if event-repository.enabled is not provided or mis-spelt or if event-repository.enabled = true and
* event-repository.url not provided , then the service gets terminated.
*
*/
@PostConstruct
public void checkAndLoadEventRepositoryConfiguration() throws InterruptedException {
if (eventRepositoryEnabled.equalsIgnoreCase("true") || eventRepositoryEnabled.equalsIgnoreCase("false")) {
eventRepositoryCheck = Boolean.parseBoolean(eventRepositoryEnabled);
log.info("Checking whether Event Repository configurations for lookup are enabled or not");
if (eventRepositoryCheck) {
if (!erURL.isEmpty()) {
log.info("Event Repository configurations for lookup are enabled");
setErURL(erURL);
log.info("Configured Event Repository URL for lookup : " + getErURL());
} else {
log.error("Enabled Event Repository configurations for lookUp but not provided Event Repository URL");
throw new InterruptedException("Event Repository URL not configured");

}
} else {
log.info("Event Repository configurations for lookup are not enabled");
}
} else {
log.error("Please check and provide proper value for event-repository.enabled field in configuration file");
log.info("Allowed values are either true or false");
throw new InterruptedException("Provided incorrect values for lookup configurations");
}
}
}
9 changes: 7 additions & 2 deletions service/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ jasypt.encryptor.password:<Any value which was used at the time of encrypting th

#Ldap authentication configurations

activedirectory.generate.enabled:false
activedirectory.generate.enabled:false
activedirectory.ldapUrl :
activedirectory.managerPassword : ENC(<encrypted password>) or password
activedirectory.managerDn:
activedirectory.rootDn :
activedirectory.userSearchFilter:
activedirectory.userSearchFilter:

#Event Repository configurations

event-repository.enabled:false
event-repository.url :http://localhost:<port>/optional to specify context-path
7 changes: 6 additions & 1 deletion service/src/main/resources/config.template.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@
activedirectory.managerPassword : ENC(<encrypted password>) or password
activedirectory.managerDn:
activedirectory.rootDn :
activedirectory.userSearchFilter:
activedirectory.userSearchFilter:

#Event Repository configurations

event-repository.enabled:<true/false>(default value is false)
event-repository.url :<http(s)://<event-repository hostname>:<port number>/<(optional to specify context-path)>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.google.gson.JsonParser;
import com.jayway.restassured.RestAssured;

import org.apache.http.HttpStatus;
import org.hamcrest.Matchers;
import org.junit.Before;
Expand All @@ -39,6 +40,9 @@
import java.util.jar.Manifest;

import static com.jayway.restassured.RestAssured.given;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

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

private String version = "3.0.0";
@Value("${event-repository.enabled}")
private boolean eventRepositoryEnabled;
@Value("${event-repository.url}")
private String erURL;

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

Expand All @@ -80,7 +88,7 @@ private String loadEventBody(final String fileName) throws IOException {
final byte[] bytes = Files.readAllBytes(file.toPath());
return new String(bytes);
}

public static String getMessagingVersion() {
Enumeration resEnum;
try {
Expand Down Expand Up @@ -195,4 +203,16 @@ public void testGetEventTypeTemplateNoFileExists() {
.then()
.statusCode(HttpStatus.SC_NOT_FOUND);
}
@Test
public void testErLookUpConfigurations(){
if(eventRepositoryEnabled){
if(!erURL.isEmpty())
assertTrue(erURL,true);
else
assertNull(erURL,null);
}
else{
assertFalse(eventRepositoryEnabled);
}
}
}

0 comments on commit 816a90b

Please sign in to comment.