Skip to content

Commit

Permalink
Merge pull request #6 from bd2kccd/development
Browse files Browse the repository at this point in the history
Merge v0.0.1 to Master
  • Loading branch information
kvb2univpitt authored Mar 30, 2017
2 parents 30202e9 + 5425c51 commit 513d654
Show file tree
Hide file tree
Showing 27 changed files with 1,195 additions and 1,150 deletions.
13 changes: 12 additions & 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 All @@ -17,6 +17,17 @@
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<repositories>
<repository>
<id>ccd-releases</id>
<url>https://ccd3.vm.bridges.psc.edu/nexus/content/repositories/releases/</url>
</repository>
<repository>
<id>ccd-snapshots</id>
<url>https://ccd3.vm.bridges.psc.edu/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>

<distributionManagement>
<repository>
<id>ccd-releases</id>
Expand Down
86 changes: 39 additions & 47 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,13 +16,12 @@
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;
Expand All @@ -33,64 +32,57 @@ public class RestHttpsClient {

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());
// 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);

// 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);

return localContext;
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);

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

return localContext;
}

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

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

public static void main(String[] args) throws Exception {
Expand Down
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
@@ -1,63 +1,65 @@
package edu.pitt.dbmi.ccd.rest.client.dto.algo;

import java.util.List;
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 Map<String, Object> 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 Map<String, Object> getHpcParameters() {
return hpcParameters;
}

public void setHpcParameters(Map<String, Object> 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
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2015 University of Pittsburgh.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package edu.pitt.dbmi.ccd.rest.client.dto.algo;

/**
*
* Feb 21, 2017 12:24:39 PM
*
* @author Chirayu Kong Wongchokprasitti, PhD (chw20@pitt.edu)
*
*/
public class HpcParameter {

private String key;

private String value;

public String getKey() {
return key;
}

public void setKey(String key) {
this.key = key;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}
}
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
Loading

0 comments on commit 513d654

Please sign in to comment.