Skip to content

Commit

Permalink
Code reformatted.
Browse files Browse the repository at this point in the history
Remove SNAPSHOT from project version.
  • Loading branch information
kvb2univpitt committed Mar 30, 2017
1 parent 2bc2713 commit 5425c51
Show file tree
Hide file tree
Showing 25 changed files with 1,133 additions and 1,160 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>edu.pitt.dbmi.ccd</groupId>
<artifactId>causal-tetrad-rest-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.1</version>
<packaging>jar</packaging>

<name>causal-tetrad-rest-client</name>
Expand Down
105 changes: 52 additions & 53 deletions src/main/java/edu/pitt/dbmi/ccd/rest/client/RestHttpsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,77 +16,76 @@
import org.apache.http.ssl.SSLContextBuilder;

/**
*
*
* Aug 20, 2016 12:17:02 AM
*
*
* @author Chirayu (Kong) Wongchokprasitti, PhD
*
*
*/

public class RestHttpsClient {

private final String email;
private final String password;
private final String scheme;
private final String hostname;
private final int port;
private final String email;
private final String password;
private final String scheme;
private final String hostname;
private final int port;

private final CloseableHttpClient httpClient;
private final HttpClientContext localContext;
private final CloseableHttpClient httpClient;
private final HttpClientContext localContext;

public RestHttpsClient(String email, String password, String scheme, String hostname, int port) throws Exception {
this.email = email;
this.password = password;
this.scheme = scheme;
this.hostname = hostname;
this.port = port;
this.httpClient = createHttpClient();
this.localContext = establishCustomContext(httpClient);
}
public RestHttpsClient(String email, String password, String scheme, String hostname, int port) throws Exception {
this.email = email;
this.password = password;
this.scheme = scheme;
this.hostname = hostname;
this.port = port;
this.httpClient = createHttpClient();
this.localContext = establishCustomContext(httpClient);
}

private CloseableHttpClient createHttpClient() throws Exception {
// Trust own CA and all self-signed certs
SSLContextBuilder builder = new SSLContextBuilder();
builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
private CloseableHttpClient createHttpClient() throws Exception {
// Trust own CA and all self-signed certs
SSLContextBuilder builder = new SSLContextBuilder();
builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());

SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(), new String[] { "TLSv1.2" },
null, SSLConnectionSocketFactory.getDefaultHostnameVerifier());
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(), new String[]{"TLSv1.2"},
null, SSLConnectionSocketFactory.getDefaultHostnameVerifier());

CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(new AuthScope(hostname, port), new UsernamePasswordCredentials(email, password));
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(new AuthScope(hostname, port), new UsernamePasswordCredentials(email, password));

CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(sslsf)
.setDefaultCredentialsProvider(credsProvider).build();
CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(sslsf)
.setDefaultCredentialsProvider(credsProvider).build();

return httpClient;
}
return httpClient;
}

private HttpClientContext establishCustomContext(CloseableHttpClient httpclient) throws Exception {
HttpHost target = new HttpHost(hostname, port, scheme);
private HttpClientContext establishCustomContext(CloseableHttpClient httpclient) throws Exception {
HttpHost target = new HttpHost(hostname, port, scheme);

// Create AuthCache instance
AuthCache authCache = new BasicAuthCache();
// Generate BASIC scheme object and add it to the local
// auth cache
BasicScheme basicAuth = new BasicScheme();
authCache.put(target, basicAuth);
// Create AuthCache instance
AuthCache authCache = new BasicAuthCache();
// Generate BASIC scheme object and add it to the local
// auth cache
BasicScheme basicAuth = new BasicScheme();
authCache.put(target, basicAuth);

// Add AuthCache to the execution context
HttpClientContext localContext = HttpClientContext.create();
localContext.setAuthCache(authCache);
// Add AuthCache to the execution context
HttpClientContext localContext = HttpClientContext.create();
localContext.setAuthCache(authCache);

return localContext;
}
return localContext;
}

public CloseableHttpClient getHttpClient() {
return httpClient;
}
public CloseableHttpClient getHttpClient() {
return httpClient;
}

public HttpClientContext getLocalContext() {
return localContext;
}
public HttpClientContext getLocalContext() {
return localContext;
}

public static void main(String[] args) throws Exception {
public static void main(String[] args) throws Exception {

}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package edu.pitt.dbmi.ccd.rest.client.dto.algo;

/**
*
*
* Aug 24, 2016 6:09:21 PM
*
*
* @author Chirayu (Kong) Wongchokprasitti, PhD
*
*
*/
public class AlgorithmInfo {

Expand All @@ -18,27 +18,27 @@ public AlgorithmInfo() {
}

public int getId() {
return id;
return id;
}

public void setId(int id) {
this.id = id;
this.id = id;
}

public String getName() {
return name;
return name;
}

public void setName(String name) {
this.name = name;
this.name = name;
}

public String getDescription() {
return description;
return description;
}

public void setDescription(String description) {
this.description = description;
this.description = description;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,62 @@
import java.util.Map;

/**
*
*
* Aug 25, 2016 2:20:41 PM
*
*
* @author Chirayu (Kong) Wongchokprasitti, PhD
*
*
*/
public class AlgorithmParamRequest {

private long datasetFileId;

private Map<String, Object> dataValidation;

private Map<String, Object> AlgorithmParameters;

private Map<String, Object> jvmOptions;

private List<HpcParameter> hpcParameters;


public long getDatasetFileId() {
return datasetFileId;
}

public void setDatasetFileId(long dataFileId) {
this.datasetFileId = dataFileId;
}

public Map<String, Object> getDataValidation() {
return dataValidation;
}

public void setDataValidation(Map<String, Object> dataValidation) {
this.dataValidation = dataValidation;
}

public Map<String, Object> getAlgorithmParameters() {
return AlgorithmParameters;
}

public void setAlgorithmParameters(Map<String, Object> algorithmParameters) {
AlgorithmParameters = algorithmParameters;
}

public Map<String, Object> getJvmOptions() {
return jvmOptions;
}

public void setJvmOptions(Map<String, Object> jvmOptions) {
this.jvmOptions = jvmOptions;
}

public List<HpcParameter> getHpcParameters() {
return hpcParameters;
}

public void setHpcParameters(List<HpcParameter> hpcParameters) {
this.hpcParameters = hpcParameters;
}


private long datasetFileId;

private Map<String, Object> dataValidation;

private Map<String, Object> AlgorithmParameters;

private Map<String, Object> jvmOptions;

private List<HpcParameter> hpcParameters;

public long getDatasetFileId() {
return datasetFileId;
}

public void setDatasetFileId(long dataFileId) {
this.datasetFileId = dataFileId;
}

public Map<String, Object> getDataValidation() {
return dataValidation;
}

public void setDataValidation(Map<String, Object> dataValidation) {
this.dataValidation = dataValidation;
}

public Map<String, Object> getAlgorithmParameters() {
return AlgorithmParameters;
}

public void setAlgorithmParameters(Map<String, Object> algorithmParameters) {
AlgorithmParameters = algorithmParameters;
}

public Map<String, Object> getJvmOptions() {
return jvmOptions;
}

public void setJvmOptions(Map<String, Object> jvmOptions) {
this.jvmOptions = jvmOptions;
}

public List<HpcParameter> getHpcParameters() {
return hpcParameters;
}

public void setHpcParameters(List<HpcParameter> hpcParameters) {
this.hpcParameters = hpcParameters;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import java.util.Date;

/**
*
*
* Aug 31, 2016 12:48:31 PM
*
*
* @author Chirayu (Kong) Wongchokprasitti, PhD
*
*
*/
public class JobInfo {

Expand All @@ -18,11 +18,11 @@ public class JobInfo {
private Date addedTime;

private String resultFileName;

private String resultJsonFileName;

private String errorResultFileName;

private int status;

public Long getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
import java.util.Date;

/**
*
*
* Sep 26, 2016 1:35:27 PM
*
*
* @author Chirayu (Kong) Wongchokprasitti, PhD
*
*
*/
public class ResultFile {

private String name;

private Date creationTime;

private Date lastModifiedTime;

private long fileSize;

public String getName() {
Expand Down
Loading

0 comments on commit 5425c51

Please sign in to comment.