Skip to content

Commit d501c3c

Browse files
author
Neville Fernandes
committed
Initial Commit
0 parents  commit d501c3c

File tree

181 files changed

+10340
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+10340
-0
lines changed

.classpath

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src/main/java"/>
4+
<classpathentry kind="src" path="src/test/java"/>
5+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
6+
<attributes>
7+
<attribute name="maven.pomderived" value="true"/>
8+
</attributes>
9+
</classpathentry>
10+
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/com.sap.core.runtime.sdkTarget/Java Web Tomcat 7">
11+
<attributes>
12+
<attribute name="owner.project.facets" value="jst.web"/>
13+
</attributes>
14+
</classpathentry>
15+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
16+
<attributes>
17+
<attribute name="maven.pomderived" value="true"/>
18+
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
19+
</attributes>
20+
</classpathentry>
21+
<classpathentry kind="output" path="target/classes"/>
22+
</classpath>

.project

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>fsconnect</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.wst.common.project.facet.core.builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.wst.validation.validationbuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>org.eclipse.m2e.core.maven2Builder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
31+
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
32+
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
33+
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
34+
<nature>org.eclipse.jdt.core.javanature</nature>
35+
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
36+
</natures>
37+
</projectDescription>

.settings/.jsdtscope

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="WebContent"/>
4+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
5+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
6+
<attributes>
7+
<attribute name="hide" value="true"/>
8+
</attributes>
9+
</classpathentry>
10+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
11+
<classpathentry kind="output" path=""/>
12+
</classpath>

.settings/org.eclipse.jdt.core.prefs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.compliance=1.8
5+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
8+
org.eclipse.jdt.core.compiler.source=1.8

.settings/org.eclipse.m2e.core.prefs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
2+
<wb-module deploy-name="fsconnect-0.0.1-SNAPSHOT">
3+
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
4+
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
5+
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
6+
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
7+
<property name="context-root" value="fsconnect"/>
8+
<property name="java-output-path" value="/fsconnect/build/classes"/>
9+
</wb-module>
10+
</project-modules>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<root>
2+
<facet id="jpt.jaxb">
3+
<node name="classgen">
4+
<attribute name="package" value="com.sap.csc.domain"/>
5+
</node>
6+
</facet>
7+
<facet id="jst.jaxrs">
8+
<node name="libprov">
9+
<attribute name="provider-id" value="jaxrs-no-op-library-provider"/>
10+
</node>
11+
</facet>
12+
</root>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<faceted-project>
3+
<runtime name="Java Web Tomcat 7"/>
4+
<fixed facet="java"/>
5+
<fixed facet="wst.jsdt.web"/>
6+
<fixed facet="jst.web"/>
7+
<installed facet="java" version="1.8"/>
8+
<installed facet="jst.web" version="3.0"/>
9+
<installed facet="wst.jsdt.web" version="1.0"/>
10+
<installed facet="jst.jaxrs" version="2.0"/>
11+
</faceted-project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Window
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
disabled=06target
2+
eclipse.preferences.version=1

WebContent/META-INF/MANIFEST.MF

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
Class-Path:
3+

WebContent/WEB-INF/web.xml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
3+
<display-name>fsconnect</display-name>
4+
<welcome-file-list>
5+
<welcome-file>index.html</welcome-file>
6+
<welcome-file>index.htm</welcome-file>
7+
<welcome-file>index.jsp</welcome-file>
8+
<welcome-file>default.html</welcome-file>
9+
<welcome-file>default.htm</welcome-file>
10+
<welcome-file>default.jsp</welcome-file>
11+
</welcome-file-list>
12+
13+
14+
<servlet>
15+
<servlet-name>Jersey REST Service</servlet-name>
16+
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
17+
<!-- Register resources and providers under com.vogella.jersey.first package. -->
18+
<init-param>
19+
<param-name>jersey.config.server.provider.packages</param-name>
20+
<param-value>com.sap.csc.handler</param-value>
21+
</init-param>
22+
<load-on-startup>1</load-on-startup>
23+
</servlet>
24+
<servlet-mapping>
25+
<servlet-name>Jersey REST Service</servlet-name>
26+
<url-pattern>/rest/*</url-pattern>
27+
</servlet-mapping>
28+
29+
30+
</web-app>

pom.xml

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.sap.csc</groupId>
5+
<artifactId>fsconnect</artifactId>
6+
<version>0.0.1-SNAPSHOT</version>
7+
<packaging>war</packaging>
8+
<build>
9+
<sourceDirectory>src</sourceDirectory>
10+
<plugins>
11+
<plugin>
12+
<artifactId>maven-war-plugin</artifactId>
13+
<version>3.0.0</version>
14+
<configuration>
15+
<warSourceDirectory>WebContent</warSourceDirectory>
16+
</configuration>
17+
</plugin>
18+
<plugin>
19+
<artifactId>maven-compiler-plugin</artifactId>
20+
<version>3.7.0</version>
21+
<configuration>
22+
<source>1.8</source>
23+
<target>1.8</target>
24+
</configuration>
25+
</plugin>
26+
</plugins>
27+
</build>
28+
29+
<dependencies>
30+
31+
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
32+
<dependency>
33+
<groupId>org.slf4j</groupId>
34+
<artifactId>slf4j-log4j12</artifactId>
35+
<version>1.7.25</version>
36+
<scope>test</scope>
37+
</dependency>
38+
39+
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider -->
40+
<dependency>
41+
<groupId>com.fasterxml.jackson.jaxrs</groupId>
42+
<artifactId>jackson-jaxrs-json-provider</artifactId>
43+
<version>2.5.4</version>
44+
</dependency>
45+
46+
<!-- https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api -->
47+
<dependency>
48+
<groupId>javax.ws.rs</groupId>
49+
<artifactId>javax.ws.rs-api</artifactId>
50+
<version>2.1</version>
51+
</dependency>
52+
53+
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client -->
54+
<dependency>
55+
<groupId>org.glassfish.jersey.core</groupId>
56+
<artifactId>jersey-client</artifactId>
57+
<version>2.26</version>
58+
</dependency>
59+
60+
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.containers/jersey-container-servlet -->
61+
<dependency>
62+
<groupId>org.glassfish.jersey.containers</groupId>
63+
<artifactId>jersey-container-servlet</artifactId>
64+
<version>2.26</version>
65+
</dependency>
66+
67+
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.media/jersey-media-json-jackson -->
68+
<dependency>
69+
<groupId>org.glassfish.jersey.media</groupId>
70+
<artifactId>jersey-media-json-jackson</artifactId>
71+
<version>2.26</version>
72+
</dependency>
73+
74+
75+
<!-- Fixes the issue of InjectionManagerFactory in Jersey -->
76+
<dependency>
77+
<groupId>org.glassfish.jersey.inject</groupId>
78+
<artifactId>jersey-hk2</artifactId>
79+
<version>2.26-b06</version>
80+
</dependency>
81+
82+
<!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-ri -->
83+
<dependency>
84+
<groupId>com.sun.xml.bind</groupId>
85+
<artifactId>jaxb-ri</artifactId>
86+
<version>2.2.11</version>
87+
<type>pom</type>
88+
</dependency>
89+
90+
91+
</dependencies>
92+
</project>

src/main/java/com/.DS_Store

8 KB
Binary file not shown.

src/main/java/com/sap/.DS_Store

8 KB
Binary file not shown.

src/main/java/com/sap/csc/.DS_Store

8 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.sap.csc.client;
2+
3+
import java.io.IOException;
4+
import java.io.InputStream;
5+
import java.util.Properties;
6+
7+
public class FlexCredentials {
8+
9+
private static final Properties props = loadProperties();
10+
public static final String APP_ID = props.getProperty("appId");
11+
public static final String APP_KEY = props.getProperty("appKey");
12+
13+
14+
private FlexCredentials() {
15+
super();
16+
}
17+
18+
private static Properties loadProperties() {
19+
Properties properties = new Properties();
20+
try (final InputStream stream = FlexCredentials.class.getResourceAsStream("/flex.properties")) {
21+
properties.load(stream);
22+
} catch (IOException e) {
23+
throw new RuntimeException(e);
24+
}
25+
return properties;
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.sap.csc.client;
2+
3+
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
4+
5+
import javax.ws.rs.client.Client;
6+
import javax.ws.rs.client.ClientBuilder;
7+
import javax.ws.rs.core.Response;
8+
import javax.ws.rs.core.UriBuilder;
9+
import java.net.URI;
10+
import java.util.HashMap;
11+
import java.util.Map;
12+
13+
public class FlexHelper {
14+
public static final String FLEX_BASE = "https://api.flightstats.com/flex";
15+
public static final String APP_ID = "appId";
16+
public static final String APP_KEY = "appKey";
17+
public static final String EXTENDED_OPTIONS = "extendedOptions";
18+
public static final String INCLUDE_NEW_FIELDS = "includeNewFields";
19+
public static final String INCLUDE_DELTAS = "includeDeltas";
20+
public static final String INCLUDE_DIRECTS = "includeDirects";
21+
public static final String INCLUDE_CARGO = "includeCargo";
22+
public static final String INCLUDE_SURFACE = "includeSurface";
23+
public static final String EXCLUDE_APPENDIX = "excludeAppendix";
24+
public static final String LANGUAGE_CODE = "languageCode:%s";
25+
private static final Client httpClient = ClientBuilder.newClient().register(JacksonJsonProvider.class);
26+
27+
private FlexHelper() {
28+
super();
29+
}
30+
31+
public static <X> X executeHttpGet(URI uri, Class<X> clazz) {
32+
Response response = httpClient.target(uri).request("application/json;charset=UTF-8").get(Response.class);
33+
checkForError(uri, response);
34+
return response.readEntity(clazz);
35+
}
36+
37+
private static void checkForError(URI source, Response response) {
38+
if (response.getStatus() >= 300) {
39+
throw new RuntimeException("http status=" + response.getStatus() + ", source: " + source + ": "
40+
+ response.readEntity(String.class));
41+
}
42+
}
43+
44+
public static UriBuilder createRequestUri(String path, Map<String, String> options, String appId, String appKey) {
45+
UriBuilder builder = UriBuilder.fromPath(FLEX_BASE + path).queryParam(APP_ID, appId).queryParam(APP_KEY,
46+
appKey);
47+
appendQueryParams(options, builder);
48+
return builder;
49+
}
50+
51+
private static void appendQueryParams(Map<String, String> options, UriBuilder builder) {
52+
options = options == null ? new HashMap<>() : options;
53+
if (options.containsKey(EXTENDED_OPTIONS)) {
54+
options.put(EXTENDED_OPTIONS, options.get(EXTENDED_OPTIONS) + ",useHttpErrors");
55+
} else {
56+
options.put(EXTENDED_OPTIONS, "useHttpErrors");
57+
}
58+
for (Map.Entry<String, String> option : options.entrySet()) {
59+
builder.queryParam(option.getKey(), option.getValue());
60+
}
61+
}
62+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.sap.csc.client;
2+
3+
import java.time.LocalDate;
4+
import java.util.Map;
5+
6+
import javax.ws.rs.core.UriBuilder;
7+
8+
import com.sap.csc.domain.ResponseRule;
9+
10+
public class FlightAlertsClient {
11+
public static final String AIRPORT = "airport";
12+
public static final String CODE_TYPE = "codeType";
13+
public static final String UTC = "utc";
14+
public static final String MAX_POSITIONS = "maxPositions";
15+
public static final String MAX_POSITION_AGE_MINUTES = "maxPositionAgeMinutes";
16+
public static final String HOUR_OF_DAY = "hourOfDay";
17+
public static final String NUM_HOURS = "numHours";
18+
public static final String INCLUDE_FLIGHT_PLAN = "includeFlightPlan";
19+
20+
private String appKey;
21+
private String appId;
22+
23+
public FlightAlertsClient(String appId, String appKey) {
24+
this.appKey = appKey;
25+
this.appId = appId;
26+
}
27+
28+
public ResponseRule testAlert(String carrier, String flight, String arrAirport, String depAirport,
29+
Map<String, String> options) {
30+
UriBuilder builder = FlexHelper.createRequestUri(String.format("/alerts/rest/v1/json/testdelivery/%s/%s/from/%s/to/%s",
31+
carrier, flight, arrAirport, depAirport), options, appId, appKey);
32+
return FlexHelper.executeHttpGet(builder.build(), ResponseRule.class);
33+
}
34+
35+
public Object createAlert(String carrier, String flight, String depAirport, LocalDate date,
36+
Map<String, String> options) {
37+
UriBuilder builder = FlexHelper.createRequestUri(String.format("/alerts/rest/v1/json/create/%s/%s/from/%s/departing/%s/%s/%s",
38+
carrier, flight, depAirport, date.getYear(), date.getMonthValue(), date.getDayOfMonth()),
39+
options, appId, appKey);
40+
return FlexHelper.executeHttpGet(builder.build(), Object.class);
41+
}
42+
43+
}

0 commit comments

Comments
 (0)