-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Conor Flynn
committed
Feb 1, 2023
1 parent
101a189
commit d673db0
Showing
11 changed files
with
277 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <classpath> | ||
| <classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
| <attributes> | ||
| <attribute name="optional" value="true"/> | ||
| <attribute name="maven.pomderived" value="true"/> | ||
| </attributes> | ||
| </classpathentry> | ||
| <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | ||
| <attributes> | ||
| <attribute name="maven.pomderived" value="true"/> | ||
| </attributes> | ||
| </classpathentry> | ||
| <classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
| <attributes> | ||
| <attribute name="optional" value="true"/> | ||
| <attribute name="maven.pomderived" value="true"/> | ||
| <attribute name="test" value="true"/> | ||
| </attributes> | ||
| </classpathentry> | ||
| <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> | ||
| <attributes> | ||
| <attribute name="maven.pomderived" value="true"/> | ||
| </attributes> | ||
| </classpathentry> | ||
| <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
| <attributes> | ||
| <attribute name="maven.pomderived" value="true"/> | ||
| </attributes> | ||
| </classpathentry> | ||
| <classpathentry kind="output" path="target/classes"/> | ||
| </classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| /target/ | ||
| /bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <projectDescription> | ||
| <name>Api-Handler</name> | ||
| <comment></comment> | ||
| <projects> | ||
| </projects> | ||
| <buildSpec> | ||
| <buildCommand> | ||
| <name>org.eclipse.jdt.core.javabuilder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
| <buildCommand> | ||
| <name>org.eclipse.m2e.core.maven2Builder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
| </buildSpec> | ||
| <natures> | ||
| <nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
| <nature>org.eclipse.jdt.core.javanature</nature> | ||
| </natures> | ||
| </projectDescription> |
8 changes: 8 additions & 0 deletions
8
DeFi-Data-Engine/Api-Handler/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| eclipse.preferences.version=1 | ||
| org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
| org.eclipse.jdt.core.compiler.compliance=1.8 | ||
| org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
| org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
| org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore | ||
| org.eclipse.jdt.core.compiler.release=disabled | ||
| org.eclipse.jdt.core.compiler.source=1.8 |
Binary file removed
BIN
-1.76 KB
DeFi-Data-Engine/Api-Handler/bin/org/stream/external/communication/RequestFramework.class
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <groupId>ApiHandler</groupId> | ||
| <artifactId>ApiHandler</artifactId> | ||
| <version>0.0.1</version> | ||
| <packaging>jar</packaging> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.reflections</groupId> | ||
| <artifactId>reflections</artifactId> | ||
| <version>0.10.2</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.slf4j</groupId> | ||
| <artifactId>slf4j-api</artifactId> | ||
| <version>1.7.5</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.slf4j</groupId> | ||
| <artifactId>slf4j-log4j12</artifactId> | ||
| <version>1.7.5</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>log4j</groupId> | ||
| <artifactId>log4j</artifactId> | ||
| <version>1.2.17</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.mongodb</groupId> | ||
| <artifactId>mongo-java-driver</artifactId> | ||
| <version>3.12.11</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.squareup.okhttp3</groupId> | ||
| <artifactId>okhttp</artifactId> | ||
| <version>4.2.0</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.json</groupId> | ||
| <artifactId>json</artifactId> | ||
| <version>20220320</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>junit</groupId> | ||
| <artifactId>junit</artifactId> | ||
| <version>4.13.2</version> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <!-- plugin to run test cases from maven --> | ||
| <plugin> | ||
| <artifactId>maven-surefire-plugin</artifactId> | ||
| <version>3.0.0-M5</version> | ||
| <configuration> | ||
| <systemPropertyVariables> | ||
| <log4j.configuration>log4j.xml</log4j.configuration> | ||
| </systemPropertyVariables> | ||
| </configuration> | ||
| </plugin> | ||
|
|
||
| <plugin> | ||
| <artifactId>maven-assembly-plugin</artifactId> | ||
| <configuration> | ||
| <archive> | ||
| <manifest> | ||
| <mainClass>org.main.Main</mainClass> | ||
| </manifest> | ||
| </archive> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
|
|
||
| <properties> | ||
| <java.version>17</java.version> | ||
| <maven.compiler.source>1.8</maven.compiler.source> | ||
| <maven.compiler.target>1.8</maven.compiler.target> | ||
| </properties> | ||
|
|
||
| </project> | ||
|
|
80 changes: 80 additions & 0 deletions
80
...Data-Engine/Api-Handler/src/main/java/org/stream/external/requester/RequestFramework.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| package org.stream.external.requester; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.HashSet; | ||
| import java.util.Iterator; | ||
| import java.util.Set; | ||
| import okhttp3.Request; | ||
| import okhttp3.Request.Builder; | ||
|
|
||
| public abstract class RequestFramework { | ||
| private final String url; | ||
| private final HashSet<String> properties; | ||
| private final HashMap<String, String> headers; | ||
| private final String[] tags; | ||
|
|
||
| public RequestFramework(String url, HashSet<String> properties, HashMap<String, String> headers, String... tags) { | ||
| this.url = url; | ||
| this.properties = properties; | ||
| this.headers = headers; | ||
| this.tags = tags; | ||
| } | ||
|
|
||
| public final Request getRequest(HashMap<String, String> properties, HashMap<String, String> headers) { | ||
| Set<String> property_keys = properties.keySet(); | ||
| Set<String> header_keys = headers.keySet(); | ||
| Iterator<String> var6 = this.properties.iterator(); | ||
|
|
||
| while (var6.hasNext()) { | ||
| String property = (String) var6.next(); | ||
| if (!properties.containsKey(property)) { | ||
| System.err.println(String.format("Missing required property <%s>", property)); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| Set<String> req_header_keys = this.headers.keySet(); | ||
| Iterator<String> var7 = req_header_keys.iterator(); | ||
|
|
||
| while (var7.hasNext()) { | ||
| String header = (String) var7.next(); | ||
| if (!header_keys.contains(header)) { | ||
| System.err.println(String.format("Missing required header <%s>", header)); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| Builder builder = new Builder(); | ||
| StringBuilder url_builder = new StringBuilder(this.url); | ||
| if (!property_keys.isEmpty()) { | ||
| url_builder.append("?"); | ||
| } | ||
|
|
||
| Iterator<String> properties_itr = property_keys.iterator(); | ||
|
|
||
| String key; | ||
| while (properties_itr.hasNext()) { | ||
| key = (String) properties_itr.next(); | ||
| url_builder.append(String.format("%s=%s", key, properties.get(key))); | ||
| if (properties_itr.hasNext()) { | ||
| url_builder.append("&"); | ||
| } | ||
| } | ||
|
|
||
| builder = builder.url(url_builder.toString()); | ||
| Iterator<String> var10 = header_keys.iterator(); | ||
|
|
||
| while (var10.hasNext()) { | ||
| key = (String) var10.next(); | ||
| builder.addHeader(key, (String) headers.get(key)); | ||
| } | ||
|
|
||
| return builder.build(); | ||
| } | ||
|
|
||
| public final String[] getTags() { | ||
| return this.tags; | ||
| } | ||
|
|
||
| public abstract void process(Request var1); | ||
| } |
47 changes: 47 additions & 0 deletions
47
DeFi-Data-Engine/Api-Handler/src/main/resources/requests/template.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # === Required Properties === | ||
| # These properties are required regardless of the request and should maintain a uniform syntax. | ||
|
|
||
| # Name of the call to be referenced in the engine | ||
| request.name= template | ||
|
|
||
| # Base url of the REST API call | ||
| url.base= http://localhost:8080 | ||
|
|
||
| # This property details all required properties to be passed on runtime when called. Optional | ||
| # properties are not required to be specified here. Note that properties can be given a default | ||
| # value or can be forced to be specified. The list is in (<key>, <value>) pairs, with each property | ||
| # having both a key and value specified. Default values can be placed in the <value> property. | ||
| # Key's with no default property that are required on runtime can be filled as '.'. In this example | ||
| # <property1> has the default value <value1>, <property2> is required on runtime, and <property3> | ||
| # has the default value <value3>. | ||
| url.properties= property1,value1,\ | ||
| property2,.,\ | ||
| property3,value3 | ||
|
|
||
| # This property details all headers to be passed on runtime when generating the request. | ||
| # Optional headers can be passed on runtime and are not required to be specified here. Note | ||
| # that headers can be given a default value or can be forced to be specified. The list is in | ||
| # (<key>, <value>) pairs, with each property having both a key and value specified. Default | ||
| # values can be placed in the <value> property. Key's with no default property that are required | ||
| # on runtime can be filled as '.'. In this example <header1> has the default value <value1>, | ||
| # and headers <header2> and <header3> are required on runtime. | ||
| url.headers= header1,value1,\ | ||
| header2,.,\ | ||
| header3,. | ||
|
|
||
| # This property determines if the call is recursive, meaning that all data points required | ||
| # cannot be obtained in a single request. There are several integrated recursive types | ||
| # which have specific properties and handlers. Please review documentation to get a full | ||
| # list of these tags. To default with no recursive call, set this property to <single>. | ||
| # This property we will set to <parameterized> for a clearer example. | ||
| url.recursion.type=parameterized | ||
|
|
||
| # This property sets all tags pertaining to the type of recursive call. Please refer to | ||
| # the documentation for the full list of all tags and specified recursive types. All tags | ||
| # are in (<key>, <value>) pairs, with each property having both a key and value specified. | ||
| # Should a tag not require an accompanying <value>, please set it to '.'. In this | ||
| # example we will set the tags for <parameterized> which are as follows: | ||
| # -rp: recursive parameter | ||
| # -l: limit on items from request | ||
| # -t: type of parameter (url or incremental) | ||
| # FINISH |
Binary file modified
BIN
+56 Bytes
(100%)
...ta-Engine/Api-Handler/target/classes/org/stream/external/requester/RequestFramework.class
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| (View https://github.rpi.edu/DataINCITE/IDEA-DeFi-CRAFT/wiki for more information). |