Commit df018ca8 authored by Alessio Roppolo's avatar Alessio Roppolo

Inserted Proxy Management

parent aae2abf5
......@@ -16,66 +16,46 @@
</properties>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.0</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.1.5</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
<version>2.5.2</version>
<scope>provided</scope>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.18.3</version>
<exclusions>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-all</artifactId>
</exclusion>
</exclusions>
<version>1.19.4</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-all</artifactId>
<version>5.0</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.18.3</version>
<version>1.19.4</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.18.3</version>
<version>1.19.4</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.18.3</version>
<version>1.19.4</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.6</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.7.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>4.3.7.Final</version>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
......@@ -100,38 +80,38 @@
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<version>8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>1.7.1</version>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.1</version>
<version>2.10.6</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>2.7.2</version>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.1</version>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.6.0</version>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.10</version>
<version>1.7.30</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
......
......@@ -25,23 +25,44 @@ public class QuartzSchedulerListener implements ServletContextListener {
// execute Login operation to retrieve Token for next Rest Calls
executeLogin();
String url = null;
url = System.getenv("MEMO_URL");
log.debug("System.getenv(MEMO_URL): " + url);
if (url == null) {
Properties prop = new Properties();
try {
prop.load(this.getClass().getClassLoader().getResourceAsStream("config.properties"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
url = prop.getProperty("MEMOUrl");
log.debug("prop.getProperty(MEMOUrl): " + url);
String MemoUrl = null;
String proxyIp = null;
String proxyPort = null;
Properties prop = new Properties();
try {
prop.load(this.getClass().getClassLoader().getResourceAsStream("config.properties"));
} catch (IOException e) {
e.printStackTrace();
}
MemoUrl = System.getenv("MEMO_URL");
log.debug("System.getenv(MEMO_URL): " + MemoUrl);
if (MemoUrl == null) {
MemoUrl = prop.getProperty("MEMOUrl");
log.debug("prop.getProperty(MEMOUrl): " + MemoUrl);
}
Utilities.MemoUrl = url;
Utilities.MemoUrl = MemoUrl;
log.debug("Utilities.MemoUrl: " + Utilities.MemoUrl);
proxyIp = System.getenv("PROXY_IP");
log.debug("System.getenv(PROXY_IP): " + proxyIp);
if (proxyIp == null) {
proxyIp = prop.getProperty("proxyIp");
log.debug("prop.getProperty(proxyIp): " + proxyIp);
}
Utilities.proxyIp = proxyIp;
log.debug("Utilities.proxyIp: " + Utilities.proxyIp);
proxyPort = System.getenv("PROXY_PORT");
log.debug("System.getenv(PROXY_PORT): " + proxyPort);
if (proxyPort == null) {
proxyPort = prop.getProperty("proxyPort");
log.debug("prop.getProperty(proxyPort): " + proxyPort);
}
Utilities.proxyPort = proxyPort;
log.debug("Utilities.proxyPort: " + Utilities.proxyPort);
}
private void executeLogin() {
......
......@@ -5,6 +5,8 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.util.List;
......@@ -55,7 +57,17 @@ public class ActiveMarketActions {
+ timeframe + "/");
log.debug("invokeGetMarketSession - Rest url: " + url.toString());
HttpURLConnection connService = (HttpURLConnection) url.openConnection();
HttpURLConnection connService;
Proxy proxy;
if (Utilities.proxyIp.equals("") || Utilities.proxyIp == null) {
proxy = Proxy.NO_PROXY;
} else {
int proxyPort = Integer.parseInt(Utilities.proxyPort);
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(Utilities.proxyIp, proxyPort));
}
connService = (HttpURLConnection) url.openConnection(proxy);
connService.setDoOutput(true);
connService.setRequestMethod("GET");
connService.setRequestProperty("Accept", "application/json");
......
......@@ -4,6 +4,8 @@ import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.util.List;
......@@ -47,11 +49,21 @@ public class ActiveSessions {
List<ActiveSessionItem> myActiveSessionItemList = null;
try {
URL url = new URL(Utilities.MemoUrl + "/activeSessions/" + marketActorName + "/" + marketplaceForm
+ "/" + timeframe + "/");
URL url = new URL(Utilities.MemoUrl + "/activeSessions/" + marketActorName + "/" + marketplaceForm + "/"
+ timeframe + "/");
log.debug("invokeGetMarketSession - Rest url: " + url.toString());
HttpURLConnection connService = (HttpURLConnection) url.openConnection();
HttpURLConnection connService;
Proxy proxy;
if (Utilities.proxyIp.equals("") || Utilities.proxyIp == null) {
proxy = Proxy.NO_PROXY;
} else {
int proxyPort = Integer.parseInt(Utilities.proxyPort);
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(Utilities.proxyIp, proxyPort));
}
connService = (HttpURLConnection) url.openConnection(proxy);
connService.setDoOutput(true);
connService.setRequestMethod("GET");
connService.setRequestProperty("Accept", "application/json");
......
......@@ -4,6 +4,8 @@ import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.util.List;
......@@ -52,7 +54,17 @@ public class ClearingPrices {
+ marketplaceForm + "/" + timeframe + "/");
log.debug("invokeGetMarketSession - Rest url: " + url.toString());
HttpURLConnection connService = (HttpURLConnection) url.openConnection();
HttpURLConnection connService;
Proxy proxy;
if (Utilities.proxyIp.equals("") || Utilities.proxyIp == null) {
proxy = Proxy.NO_PROXY;
} else {
int proxyPort = Integer.parseInt(Utilities.proxyPort);
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(Utilities.proxyIp, proxyPort));
}
connService = (HttpURLConnection) url.openConnection(proxy);
connService.setDoOutput(true);
connService.setRequestMethod("GET");
connService.setRequestProperty("Accept", "application/json");
......
......@@ -5,6 +5,8 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.util.List;
......@@ -54,7 +56,17 @@ public class CorrelatedMarkeActions {
Utilities.MemoUrl + "/correlatedMarketActions/" + marketActorName + "/" + timeframe + "/");
log.debug("invokeGetMarketSession - Rest url: " + url.toString());
HttpURLConnection connService = (HttpURLConnection) url.openConnection();
HttpURLConnection connService;
Proxy proxy;
if (Utilities.proxyIp.equals("") || Utilities.proxyIp == null) {
proxy = Proxy.NO_PROXY;
} else {
int proxyPort = Integer.parseInt(Utilities.proxyPort);
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(Utilities.proxyIp, proxyPort));
}
connService = (HttpURLConnection) url.openConnection(proxy);
connService.setDoOutput(true);
connService.setRequestMethod("GET");
connService.setRequestProperty("Accept", "application/json");
......
......@@ -4,6 +4,8 @@ import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.util.List;
......@@ -50,7 +52,17 @@ public class MarketResults {
URL url = new URL(Utilities.MemoUrl + "/marketResults/" + marketplaceForm + "/" + timeframe + "/");
log.debug("invokeGetMarketSession - Rest url: " + url.toString());
HttpURLConnection connService = (HttpURLConnection) url.openConnection();
HttpURLConnection connService;
Proxy proxy;
if (Utilities.proxyIp.equals("") || Utilities.proxyIp == null) {
proxy = Proxy.NO_PROXY;
} else {
int proxyPort = Integer.parseInt(Utilities.proxyPort);
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(Utilities.proxyIp, proxyPort));
}
connService = (HttpURLConnection) url.openConnection(proxy);
connService.setDoOutput(true);
connService.setRequestMethod("GET");
connService.setRequestProperty("Accept", "application/json");
......
......@@ -4,6 +4,8 @@ import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.util.List;
import com.google.gson.reflect.TypeToken;
......@@ -51,7 +53,17 @@ public class ReferencePrices {
+ marketplaceForm + "/" + timeframe + "/");
log.debug("invokeGetMarketSession - Rest url: " + url.toString());
HttpURLConnection connService = (HttpURLConnection) url.openConnection();
HttpURLConnection connService;
Proxy proxy;
if (Utilities.proxyIp.equals("") || Utilities.proxyIp == null) {
proxy = Proxy.NO_PROXY;
} else {
int proxyPort = Integer.parseInt(Utilities.proxyPort);
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(Utilities.proxyIp, proxyPort));
}
connService = (HttpURLConnection) url.openConnection(proxy);
connService.setDoOutput(true);
connService.setRequestMethod("GET");
connService.setRequestProperty("Accept", "application/json");
......
......@@ -17,6 +17,8 @@ public class Utilities {
private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(Utilities.class);
public static String MemoUrl = "";
public static String proxyIp = "";
public static String proxyPort = "";
// public String getMEMOurl() {
// String url = null;
......
MEMOUrl=MEMO_URL
MEMOUrl=http://83.235.169.221/catalyst/marketplace/italy-sicily-palermo/memo
#MEMOUrl=MEMO_URL
proxyIp=161.27.206.250
proxyPort=8080
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment