Skip to content

Commit c10ec94

Browse files
authored
Removed archived repo remrem-shared dependencies (#199)
* Removed archived repo remrem shared dependencies.
1 parent 59306e1 commit c10ec94

File tree

8 files changed

+262
-17
lines changed

8 files changed

+262
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- updated eiffel-remrem-semantics version from 2.2.1 to 2.2.2
55
- Introduced new (/message_protocols) Endpoint which returns the available message protocols list and their respective edition names.
66
- Updated all curl commands in documentation
7+
- Removed archived repo remrem-shared dependencies
78

89
## 2.1.4
910
- Fixed issue related to ER lookup strategy in REMReM-generate.

cli/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
<artifactId>generate-cli</artifactId>
1212
<packaging>jar</packaging>
1313
<dependencies>
14-
<dependency>
15-
<groupId>com.github.eiffel-community</groupId>
16-
<artifactId>eiffel-remrem-shared</artifactId>
17-
</dependency>
1814
<dependency>
1915
<groupId>com.github.eiffel-community</groupId>
2016
<artifactId>eiffel-remrem-semantics</artifactId>

cli/src/main/java/com/ericsson/eiffel/remrem/generate/cli/CLIOptions.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.apache.commons.cli.Options;
2828

2929
import com.ericsson.eiffel.remrem.generate.config.PropertiesConfig;
30-
import com.ericsson.eiffel.remrem.shared.VersionService;
3130

3231

3332
public class CLIOptions {
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/*
2+
Copyright 2017 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.cli;
16+
17+
import java.io.FileInputStream;
18+
import java.io.IOException;
19+
import java.io.InputStream;
20+
import java.net.URL;
21+
import java.util.Enumeration;
22+
import java.util.HashMap;
23+
import java.util.Map;
24+
import java.util.jar.Attributes;
25+
import java.util.jar.JarFile;
26+
import java.util.jar.Manifest;
27+
28+
import com.google.gson.JsonParser;
29+
import ch.qos.logback.classic.Logger;
30+
import org.slf4j.LoggerFactory;
31+
32+
/**
33+
* This class will search in all registered jars and their manifest file for
34+
* attribute Remrem-Version-Key. It will return a list with all versions found.
35+
*/
36+
public class VersionService {
37+
38+
private static final String WEB_INF = "WEB-INF";
39+
private static final String VERSION = "version";
40+
private static final String META_INF_MANIFEST_MF = "META-INF/MANIFEST.MF";
41+
private static final String REMREM_VERSION_KEY = "remremVersionKey";
42+
private static final String IS_ENDPOINT_VERSION = "isEndpointVersion";
43+
private static final String ENDPOINT_VERSION = "endpointVersions";
44+
private static final String SERVICE_VERSION = "serviceVersion";
45+
private Logger log = (Logger) LoggerFactory.getLogger(VersionService.class);
46+
JsonParser parser = new JsonParser();
47+
Map<String, Map<String, String>> versions = new HashMap<>();
48+
Map<String, String> endpointVersions = new HashMap<String, String>();
49+
Map<String, String> serviceVersion = new HashMap<String, String>();
50+
/**
51+
* This method will load and parse the MINIFEST files to get the version of
52+
* the loaded messaging protocols. It is required to define the versions as
53+
* mainifest attributes in the build.gradle or pom.xml files using
54+
* attributes "remremVersionKey" and "isEndpointVersion" to specify the type
55+
* of the protocol or service and if it is endpoint or not respectively.
56+
* Example for build.gradle: manifest { attributes('remremVersionKey':
57+
* 'semanticsVersion') attributes('semanticsVersion': version)
58+
* attributes('isEndpointVersion': 'true') }
59+
*
60+
* @return a map containing the protocol and service types with their
61+
* versions {"endpointVersions" : {"semanticsVersion" : "1.1.1"},
62+
* "serviceVersion": {"remremGenerateVersion": "0.1.1"}}
63+
*/
64+
public Map<String, Map<String, String>> getMessagingVersions() {
65+
Enumeration<?> resEnum;
66+
67+
try {
68+
resEnum = Thread.currentThread().getContextClassLoader().getResources(JarFile.MANIFEST_NAME);
69+
while (resEnum.hasMoreElements()) {
70+
try {
71+
URL url = (URL) resEnum.nextElement();
72+
InputStream is = url.openStream();
73+
if (is != null) {
74+
Manifest manifest = new Manifest(is);
75+
Attributes mainAttribs = manifest.getMainAttributes();
76+
String versionKey = mainAttribs.getValue(REMREM_VERSION_KEY);
77+
if (versionKey != null) {
78+
String version = mainAttribs.getValue(versionKey);
79+
if (version != null) {
80+
81+
if (mainAttribs.getValue(IS_ENDPOINT_VERSION) != null) {
82+
endpointVersions.put(versionKey, version);
83+
} else {
84+
serviceVersion.put(versionKey, version);
85+
}
86+
}
87+
}
88+
}
89+
} catch (Exception e) {
90+
// Silently ignore wrong manifests on classpath?
91+
log.debug("Ignore wrong manifests on classpath ",e.getMessage());
92+
}
93+
}
94+
if(serviceVersion.isEmpty()){
95+
serviceVersion=getServiceVersion();
96+
}
97+
versions.put(ENDPOINT_VERSION, endpointVersions);
98+
versions.put(SERVICE_VERSION, serviceVersion);
99+
} catch (IOException e1) {
100+
// Silently ignore wrong manifests on classpath?
101+
log.debug("Ignore wrong manifests on classpath ",e1.getMessage());
102+
}
103+
return versions;
104+
}
105+
106+
/**
107+
* this method will parse manifest file of current project.
108+
*
109+
* @return map containing the version of current project.
110+
*/
111+
public Map<String, String> getServiceVersion() {
112+
String resourcesPath = this.getClass().getClassLoader().getResource("").getPath();
113+
String manifestPath = resourcesPath.substring(0, resourcesPath.lastIndexOf(WEB_INF)).concat(META_INF_MANIFEST_MF);
114+
try {
115+
Manifest manifest = new Manifest(new FileInputStream(manifestPath));
116+
Attributes mainAttribs = manifest.getMainAttributes();
117+
String versionKey = mainAttribs.getValue(REMREM_VERSION_KEY);
118+
if (versionKey != null) {
119+
String version = mainAttribs.getValue(versionKey);
120+
if (version != null) {
121+
serviceVersion.put(VERSION, version);
122+
}
123+
}
124+
} catch (IOException e) {
125+
e.printStackTrace();
126+
}
127+
return serviceVersion;
128+
}
129+
}
130+

pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,13 @@
1111

1212
<properties>
1313
<eiffel-remrem-generate.version>2.1.5</eiffel-remrem-generate.version>
14-
<eiffel-remrem-shared.version>2.0.5</eiffel-remrem-shared.version>
1514
<eiffel-remrem-semantics.version>2.2.2</eiffel-remrem-semantics.version>
1615
</properties>
1716
<artifactId>eiffel-remrem-generate</artifactId>
1817
<version>${eiffel-remrem-generate.version}</version>
1918
<packaging>pom</packaging>
2019
<dependencyManagement>
2120
<dependencies>
22-
<dependency>
23-
<groupId>com.github.eiffel-community</groupId>
24-
<artifactId>eiffel-remrem-shared</artifactId>
25-
<version>${eiffel-remrem-shared.version}</version>
26-
</dependency>
2721
<dependency>
2822
<groupId>com.github.eiffel-community</groupId>
2923
<artifactId>eiffel-remrem-semantics</artifactId>

service/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
<artifactId>generate-service</artifactId>
1212
<packaging>war</packaging>
1313
<dependencies>
14-
<dependency>
15-
<groupId>com.github.eiffel-community</groupId>
16-
<artifactId>eiffel-remrem-shared</artifactId>
17-
</dependency>
1814
<dependency>
1915
<groupId>com.github.eiffel-community</groupId>
2016
<artifactId>eiffel-remrem-semantics</artifactId>

service/src/main/java/com/ericsson/eiffel/remrem/generate/controller/RemremGenerateController.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import com.ericsson.eiffel.remrem.generate.constants.RemremGenerateServiceConstants;
1919
import com.ericsson.eiffel.remrem.generate.exception.REMGenerateException;
2020
import com.ericsson.eiffel.remrem.protocol.MsgService;
21-
import com.ericsson.eiffel.remrem.shared.VersionService;
2221
import com.google.gson.Gson;
2322
import com.google.gson.GsonBuilder;
2423
import com.google.gson.JsonArray;
@@ -415,4 +414,4 @@ public static String readJasyptKeyFile(final String jasyptKeyFilePath) {
415414
}
416415
return jasyptKey;
417416
}
418-
}
417+
}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/*
2+
Copyright 2017 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.controller;
16+
17+
import java.io.FileInputStream;
18+
import java.io.IOException;
19+
import java.io.InputStream;
20+
import java.net.URL;
21+
import java.util.Enumeration;
22+
import java.util.HashMap;
23+
import java.util.Map;
24+
import java.util.jar.Attributes;
25+
import java.util.jar.JarFile;
26+
import java.util.jar.Manifest;
27+
28+
import com.google.gson.JsonParser;
29+
import ch.qos.logback.classic.Logger;
30+
import org.slf4j.LoggerFactory;
31+
32+
/**
33+
* This class will search in all registered jars and their manifest file for
34+
* attribute Remrem-Version-Key. It will return a list with all versions found.
35+
*/
36+
public class VersionService {
37+
38+
private static final String WEB_INF = "WEB-INF";
39+
private static final String VERSION = "version";
40+
private static final String META_INF_MANIFEST_MF = "META-INF/MANIFEST.MF";
41+
private static final String REMREM_VERSION_KEY = "remremVersionKey";
42+
private static final String IS_ENDPOINT_VERSION = "isEndpointVersion";
43+
private static final String ENDPOINT_VERSION = "endpointVersions";
44+
private static final String SERVICE_VERSION = "serviceVersion";
45+
private Logger log = (Logger) LoggerFactory.getLogger(VersionService.class);
46+
JsonParser parser = new JsonParser();
47+
Map<String, Map<String, String>> versions = new HashMap<>();
48+
Map<String, String> endpointVersions = new HashMap<String, String>();
49+
Map<String, String> serviceVersion = new HashMap<String, String>();
50+
/**
51+
* This method will load and parse the MINIFEST files to get the version of
52+
* the loaded messaging protocols. It is required to define the versions as
53+
* mainifest attributes in the build.gradle or pom.xml files using
54+
* attributes "remremVersionKey" and "isEndpointVersion" to specify the type
55+
* of the protocol or service and if it is endpoint or not respectively.
56+
* Example for build.gradle: manifest { attributes('remremVersionKey':
57+
* 'semanticsVersion') attributes('semanticsVersion': version)
58+
* attributes('isEndpointVersion': 'true') }
59+
*
60+
* @return a map containing the protocol and service types with their
61+
* versions {"endpointVersions" : {"semanticsVersion" : "1.1.1"},
62+
* "serviceVersion": {"remremGenerateVersion": "0.1.1"}}
63+
*/
64+
public Map<String, Map<String, String>> getMessagingVersions() {
65+
Enumeration<?> resEnum;
66+
67+
try {
68+
resEnum = Thread.currentThread().getContextClassLoader().getResources(JarFile.MANIFEST_NAME);
69+
while (resEnum.hasMoreElements()) {
70+
try {
71+
URL url = (URL) resEnum.nextElement();
72+
InputStream is = url.openStream();
73+
if (is != null) {
74+
Manifest manifest = new Manifest(is);
75+
Attributes mainAttribs = manifest.getMainAttributes();
76+
String versionKey = mainAttribs.getValue(REMREM_VERSION_KEY);
77+
if (versionKey != null) {
78+
String version = mainAttribs.getValue(versionKey);
79+
if (version != null) {
80+
81+
if (mainAttribs.getValue(IS_ENDPOINT_VERSION) != null) {
82+
endpointVersions.put(versionKey, version);
83+
} else {
84+
serviceVersion.put(versionKey, version);
85+
}
86+
}
87+
}
88+
}
89+
} catch (Exception e) {
90+
// Silently ignore wrong manifests on classpath?
91+
log.debug("Ignore wrong manifests on classpath ",e.getMessage());
92+
}
93+
}
94+
if(serviceVersion.isEmpty()){
95+
serviceVersion=getServiceVersion();
96+
}
97+
versions.put(ENDPOINT_VERSION, endpointVersions);
98+
versions.put(SERVICE_VERSION, serviceVersion);
99+
} catch (IOException e1) {
100+
// Silently ignore wrong manifests on classpath?
101+
log.debug("Ignore wrong manifests on classpath ",e1.getMessage());
102+
}
103+
return versions;
104+
}
105+
106+
/**
107+
* this method will parse manifest file of current project.
108+
*
109+
* @return map containing the version of current project.
110+
*/
111+
public Map<String, String> getServiceVersion() {
112+
String resourcesPath = this.getClass().getClassLoader().getResource("").getPath();
113+
String manifestPath = resourcesPath.substring(0, resourcesPath.lastIndexOf(WEB_INF)).concat(META_INF_MANIFEST_MF);
114+
try {
115+
Manifest manifest = new Manifest(new FileInputStream(manifestPath));
116+
Attributes mainAttribs = manifest.getMainAttributes();
117+
String versionKey = mainAttribs.getValue(REMREM_VERSION_KEY);
118+
if (versionKey != null) {
119+
String version = mainAttribs.getValue(versionKey);
120+
if (version != null) {
121+
serviceVersion.put(VERSION, version);
122+
}
123+
}
124+
} catch (IOException e) {
125+
e.printStackTrace();
126+
}
127+
return serviceVersion;
128+
}
129+
}
130+

0 commit comments

Comments
 (0)