Skip to content

Commit

Permalink
Add REST endpoint for listing available message protocols (#142)
Browse files Browse the repository at this point in the history
* Add REST endpoint for listing available message protocols

* Add REST endpoint for listing available message protocols

* Made changes in CHANGELOG.md

* Fixed review comments on SemanticService

* Provided proper variables names

Co-authored-by: Vishnu Alapati <[email protected]>
Co-authored-by: Vishnu Alapati <[email protected]>
Co-authored-by: Vishnu Alapati <[email protected]>
  • Loading branch information
4 people authored Dec 7, 2021
1 parent 70a1ec6 commit 88052f3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

## 2.2.0
- Updated schemas to match the Paris edition of the protocol.
- Provided implementation for getProtocolEdition() method which returns the edition name
- Uplifted eiffel-remrem-protocol-interface version from 2.1.1 to 2.1.2.

## 2.1.1
- Uplifted eiffel-remrem-parent version from 2.0.4 to 2.0.5.
Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>com.github.eiffel-community</groupId>
<artifactId>eiffel-remrem-protocol-interface</artifactId>
<version>2.1.1</version>
<version>2.1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -185,6 +185,7 @@
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<semanticsVersion>${project.version}</semanticsVersion>
<semanticsEditionName>Paris</semanticsEditionName>
</manifestEntries>
</archive>
<appendAssemblyId>false</appendAssemblyId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@
import static com.ericsson.eiffel.remrem.semantics.EiffelEventType.TESTSUITE_FINISHED;
import static com.ericsson.eiffel.remrem.semantics.EiffelEventType.TESTSUITE_STARTED;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;

import javax.annotation.PostConstruct;
import javax.inject.Named;
Expand Down Expand Up @@ -127,11 +133,13 @@ public class SemanticsService implements MsgService {
private static final String DOMAIN_ID = "domainId";
private static final String PROTOCOL = "eiffel";
private static final String DOT = ".";
private static final String SEMANTICS_EDITION_NAME = "semanticsEditionName";
private final ArrayList<String> supportedEventTypes = new ArrayList<String>();
public static final Logger log = LoggerFactory.getLogger(SemanticsService.class);
private Event event = new Event();
public static String purlSerializer;
private boolean purlSerializerFlag = false;
private static String editionName;
private static Gson gson = new Gson();
private static Map<EiffelEventType, Class<? extends Event>> eventTypes = SemanticsService.eventType();

Expand Down Expand Up @@ -460,4 +468,33 @@ public static Source setSerializerGav(Source source) {
source.setSerializer(serializer);
return source;
}
}

@Override
public String getProtocolEdition() {
Enumeration<?> files;
try {
files = Thread.currentThread()
.getContextClassLoader()
.getResources(JarFile.MANIFEST_NAME);
while (files.hasMoreElements()) {
try {
final URL url = (URL) files.nextElement();
final InputStream inputStream = url.openStream();
if (inputStream != null) {
final Manifest manifest = new Manifest(inputStream);
final Attributes mainAttribs = manifest.getMainAttributes();
final String edition = mainAttribs.getValue(SEMANTICS_EDITION_NAME);
if (edition != null) {
editionName = edition;
}
}
} catch (Exception e) {
// Silently ignore wrong manifests on classpath?
}
}
} catch (IOException e) {
// Silently ignore wrong manifests on classpath?
}
return editionName;
}
}

0 comments on commit 88052f3

Please sign in to comment.