Skip to content

Commit

Permalink
uplifted remrem-shared version to 0.3.3 to support versioning functio…
Browse files Browse the repository at this point in the history
…nality (#73)
  • Loading branch information
xdurvak authored Jul 24, 2017
1 parent 0e71c97 commit 18da0f8
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 0.3.8
- Added copyright headers to the source code.
- Uplifted remrem-shared version to 0.3.3 to get the versions of publish and all loaded protocols.

## 0.3.7
- Updated remrem-shared version to 0.3.2 to support base64 encryption functionality for Ldap manager password.
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ subprojects {
compile 'org.apache.commons:commons-lang3:3.5'

//Injectable Message Library and its Implementation
compile 'com.github.Ericsson:eiffel-remrem-shared:0.3.2'
compile 'com.github.Ericsson:eiffel-remrem-shared:0.3.3'
compile 'com.github.Ericsson:eiffel-remrem-protocol-interface:0.0.1'
//For publishing eiffel2.0 events
compile("com.github.Ericsson:eiffel-remrem-semantics:0.2.3"){
compile("com.github.Ericsson:eiffel-remrem-semantics:0.2.5"){
exclude group: 'org.apache.commons'
}

Expand Down
5 changes: 5 additions & 0 deletions publish-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ apply plugin: 'application'
//To create executable CLI jar
jar {
baseName = 'publish-cli'
manifest {
attributes('Main-Class': 'com.ericsson.eiffel.remrem.publish.cli.CLI')
attributes('remremVersionKey': 'serviceVersion')
attributes('serviceVersion': version)
}
}

//This task is used for spring boot repackaging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package com.ericsson.eiffel.remrem.publish.cli;

import java.util.ArrayList;
import java.util.Map;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
Expand All @@ -27,6 +28,7 @@
import org.apache.commons.lang3.ArrayUtils;

import com.ericsson.eiffel.remrem.publish.config.PropertiesConfig;
import com.ericsson.eiffel.remrem.shared.VersionService;

public class CliOptions {

Expand Down Expand Up @@ -77,6 +79,7 @@ public static void createCLIOptions() {
options.addOption("mp", "messaging_protocol", true, "name of messaging protocol to be used, e.g. eiffel3, eiffelsemantics, default is eiffelsemantics");
options.addOption("domain", "domainId", true, "identifies the domain that produces the event");
options.addOption("ud", "user_domain_suffix", true, "user domain suffix");
options.addOption("v", "lists the versions of publish and all loaded protocols");
contentGroup = createContentGroup();
options.addOptionGroup(contentGroup);
}
Expand Down Expand Up @@ -124,7 +127,9 @@ public static void afterParseChecks() throws MissingOptionException {
if (commandLine.hasOption("h")) {
System.out.println("You passed help flag.");
help(0);
} else {
} else if (commandLine.hasOption("v")) {
printVersions();
}else {
checkRequiredOptions();
}
}
Expand Down Expand Up @@ -264,4 +269,28 @@ public static void exit(int errorCode) {
else
System.exit(errorCode);
}

/**
* Lists the versions of publish and all loaded protocols
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private static void printVersions() {
Map versions = new VersionService().getMessagingVersions();
Map<String, String> endpointVersions = (Map<String, String>) versions.get("endpointVersions");
Map<String, String> serviceVersion = (Map<String, String>) versions.get("serviceVersion");

if(serviceVersion != null) {
System.out.print("REMReM Publish version ");
for (String version: serviceVersion.values()) {
System.out.println(version);
}
}
if(endpointVersions != null) {
System.out.println("Available endpoints");
for (Map.Entry<String, String> entry : endpointVersions.entrySet()) {
System.out.println(entry);
}
}
exit(0);
}
}
5 changes: 5 additions & 0 deletions publish-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ plugins {
//This task creates the executable service war
war {
baseName = 'publish-service'
manifest {
attributes('Main-Class': 'com.ericsson.eiffel.remrem.publish.service.App')
attributes('remremVersionKey': 'serviceVersion')
attributes('serviceVersion': version)
}
}

//JacocoReport task can be used to generate code coverage reports in different formats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
package com.ericsson.eiffel.remrem.publish.controller;

import java.util.Map;

import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
Expand All @@ -29,12 +31,14 @@
import com.ericsson.eiffel.remrem.publish.helper.PublishUtils;
import com.ericsson.eiffel.remrem.publish.service.MessageService;
import com.ericsson.eiffel.remrem.publish.service.SendResult;
import com.ericsson.eiffel.remrem.shared.VersionService;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;

import ch.qos.logback.classic.Logger;

@RestController
@RequestMapping("/producer")
@RequestMapping("/*")
public class ProducerController {

@Autowired
Expand All @@ -45,7 +49,7 @@ public class ProducerController {
Logger log = (Logger) LoggerFactory.getLogger(ProducerController.class);

@SuppressWarnings({ "rawtypes", "unchecked" })
@RequestMapping(value = "/msg", method = RequestMethod.POST)
@RequestMapping(value = "/producer/msg", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity send(@RequestParam(value = "mp", required = false) String msgProtocol,
@RequestParam(value = "ud", required = false) String userDomain, @RequestBody JsonElement body) {
Expand All @@ -56,4 +60,14 @@ public ResponseEntity send(@RequestParam(value = "mp", required = false) String
SendResult result = messageService.send(body, msgService, userDomain);
return new ResponseEntity(result, messageService.getHttpStatus());
}

/**
* @return this method returns the current version of publish and all loaded protocols.
*/
@RequestMapping(value = "/versions", method = RequestMethod.GET)
public JsonElement getVersions() {
JsonParser parser = new JsonParser();
Map<String, Map<String, String>> versions = new VersionService().getMessagingVersions();
return parser.parse(versions.toString());
}
}

0 comments on commit 18da0f8

Please sign in to comment.