From dbf329e0c82e36e25abd56c549e19b81253c211b Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Wed, 17 Mar 2021 00:33:25 -0400 Subject: [PATCH 01/11] activate travis ci on my branch for testing --- .travis.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index fa7793de7..a98b76035 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,2 @@ language: java -deploy: - provider: releases - file_glob: true - file: "**/*.war" - skip_cleanup: true - on: - repo: ESIPFed/Geoweaver - tags: true From 83cc9d9f8a28183c0009975aa8410f7c3f80c22b Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Wed, 17 Mar 2021 00:44:32 -0400 Subject: [PATCH 02/11] fix the travis ci error in building geoweaver --- .travis.yml | 2 ++ README.md | 2 +- pom.xml | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a98b76035..b2244dbe9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,2 +1,4 @@ language: java +jdk: + - openjdk11 diff --git a/README.md b/README.md index 85ce5fa6b..5834f1133 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/ESIPFed/Geoweaver.svg?branch=master)](https://travis-ci.org/ESIPFed/Geoweaver) [![License](https://img.shields.io/github/license/ESIPFed/Geoweaver.svg)](https://github.com/ESIPFed/Geoweaver/blob/master/LICENSE) [![Stars](https://img.shields.io/github/stars/ESIPFed/Geoweaver.svg)](https://github.com/ESIPFed/Geoweaver/stargazers) [![Forks](https://img.shields.io/github/forks/ESIPFed/Geoweaver.svg)](https://github.com/ESIPFed/Geoweaver/network/members) [![Issues](https://img.shields.io/github/issues/ESIPFed/Geoweaver.svg)](https://github.com/ESIPFed/Geoweaver/issues) [![Coverage](https://img.shields.io/badge/covarege-100%25-success.svg)](https://codecov.io/) +[![Build Status](https://travis-ci.org/ZihengSun/Geoweaver.svg?branch=master)](https://travis-ci.org/ESIPFed/Geoweaver) [![License](https://img.shields.io/github/license/ESIPFed/Geoweaver.svg)](https://github.com/ESIPFed/Geoweaver/blob/master/LICENSE) [![Stars](https://img.shields.io/github/stars/ESIPFed/Geoweaver.svg)](https://github.com/ESIPFed/Geoweaver/stargazers) [![Forks](https://img.shields.io/github/forks/ESIPFed/Geoweaver.svg)](https://github.com/ESIPFed/Geoweaver/network/members) [![Issues](https://img.shields.io/github/issues/ESIPFed/Geoweaver.svg)](https://github.com/ESIPFed/Geoweaver/issues) [![Coverage](https://img.shields.io/badge/covarege-100%25-success.svg)](https://codecov.io/) # [Geoweaver](https://esipfed.github.io/Geoweaver/) diff --git a/pom.xml b/pom.xml index e494bcf56..facb1a309 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ - 1.8 + [5.3.1,) From 34c96a489ec49ab7d703f42da544372dd84b4848 Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Wed, 17 Mar 2021 01:02:03 -0400 Subject: [PATCH 03/11] update, remove httpclient library --- pom.xml | 4 +- src/main/java/com/gw/tools/HistoryTool.java | 25 +- src/main/java/com/gw/tools/HostTool.java | 12 +- src/main/java/com/gw/tools/ProcessTool.java | 19 +- src/main/java/com/gw/tools/WorkflowTool.java | 22 +- src/main/java/com/gw/utils/BaseTool.java | 9 - src/main/java/com/gw/utils/MyHttpUtils.java | 855 +++++++++---------- 7 files changed, 450 insertions(+), 496 deletions(-) diff --git a/pom.xml b/pom.xml index facb1a309..97dbda309 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ - + 1.8 [5.3.1,) @@ -261,11 +261,13 @@ commons-codec 1.3 + commons-httpclient commons-httpclient 3.1 + org.apache.commons diff --git a/src/main/java/com/gw/tools/HistoryTool.java b/src/main/java/com/gw/tools/HistoryTool.java index 1ff5d7414..515b4c0c2 100644 --- a/src/main/java/com/gw/tools/HistoryTool.java +++ b/src/main/java/com/gw/tools/HistoryTool.java @@ -1,32 +1,25 @@ package com.gw.tools; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.List; -import java.util.Optional; import java.util.Collection; -import javax.annotation.PostConstruct; import java.util.Iterator; - -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Configurable; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.http.HttpHeaders; -import org.springframework.stereotype.Service; +import java.util.List; +import java.util.Optional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gw.database.DataBaseOperation; import com.gw.database.HistoryRepository; -import com.gw.jpa.Environment; import com.gw.jpa.ExecutionStatus; import com.gw.jpa.History; import com.gw.ssh.SSHSession; import com.gw.utils.BaseTool; import com.gw.utils.RandomString; -import com.gw.utils.SysDir; import com.gw.web.GeoweaverController; + +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Configurable; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpHeaders; +import org.springframework.stereotype.Service; /** * * All the actions related to the History table diff --git a/src/main/java/com/gw/tools/HostTool.java b/src/main/java/com/gw/tools/HostTool.java index 92fab84ed..845cc472d 100644 --- a/src/main/java/com/gw/tools/HostTool.java +++ b/src/main/java/com/gw/tools/HostTool.java @@ -1,19 +1,11 @@ package com.gw.tools; -import java.sql.ResultSet; import java.sql.SQLException; import java.util.Collection; import java.util.Iterator; -import java.util.List; - -import org.apache.log4j.Logger; -import org.json.simple.JSONObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gw.database.DataBaseOperation; import com.gw.database.EnvironmentRepository; import com.gw.database.HistoryRepository; import com.gw.database.HostRepository; @@ -23,6 +15,10 @@ import com.gw.utils.BaseTool; import com.gw.utils.RandomString; +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + @Service public class HostTool { diff --git a/src/main/java/com/gw/tools/ProcessTool.java b/src/main/java/com/gw/tools/ProcessTool.java index 67d13c22d..1ebe3f250 100644 --- a/src/main/java/com/gw/tools/ProcessTool.java +++ b/src/main/java/com/gw/tools/ProcessTool.java @@ -1,32 +1,27 @@ package com.gw.tools; import java.io.File; -import java.sql.ResultSet; import java.sql.SQLException; import java.util.Iterator; import java.util.List; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; - import com.fasterxml.jackson.databind.ObjectMapper; -import com.gw.database.DataBaseOperation; import com.gw.database.HistoryRepository; import com.gw.database.ProcessRepository; import com.gw.jpa.ExecutionStatus; -import com.gw.jpa.History; -import com.gw.jpa.Workflow; import com.gw.jpa.GWProcess; +import com.gw.jpa.History; import com.gw.ssh.SSHSession; import com.gw.utils.BaseTool; import com.gw.utils.RandomString; -import com.gw.utils.SysDir; import com.gw.web.GeoweaverController; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + @Service public class ProcessTool { diff --git a/src/main/java/com/gw/tools/WorkflowTool.java b/src/main/java/com/gw/tools/WorkflowTool.java index dec5fed57..623c06169 100644 --- a/src/main/java/com/gw/tools/WorkflowTool.java +++ b/src/main/java/com/gw/tools/WorkflowTool.java @@ -1,7 +1,5 @@ package com.gw.tools; -import java.sql.ResultSet; -import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -9,27 +7,23 @@ import java.util.Map; import java.util.Optional; -import org.apache.log4j.Logger; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - import com.fasterxml.jackson.databind.ObjectMapper; -import com.gw.database.DataBaseOperation; import com.gw.database.HistoryRepository; import com.gw.database.WorkflowRepository; import com.gw.jpa.History; -import com.gw.jpa.Host; import com.gw.jpa.Workflow; import com.gw.tasks.GeoweaverWorkflowTask; import com.gw.tasks.TaskManager; -import com.gw.utils.BaseTool; import com.gw.utils.RandomString; import com.gw.utils.STATUS; -import com.gw.web.GeoweaverController; + +import org.apache.log4j.Logger; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; /** * diff --git a/src/main/java/com/gw/utils/BaseTool.java b/src/main/java/com/gw/utils/BaseTool.java index 5931ccf0a..1ec5a5360 100644 --- a/src/main/java/com/gw/utils/BaseTool.java +++ b/src/main/java/com/gw/utils/BaseTool.java @@ -7,7 +7,6 @@ import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; @@ -27,19 +26,12 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; -import java.util.HashMap; import java.util.List; -import java.util.Map; - -import javax.persistence.Lob; -import javax.xml.soap.SOAPException; import org.apache.commons.io.IOUtils; import org.dom4j.Document; import org.dom4j.DocumentHelper; import org.dom4j.Element; -import org.dom4j.Node; -import org.dom4j.XPath; import org.dom4j.io.SAXReader; import org.kamranzafar.jtar.TarEntry; import org.kamranzafar.jtar.TarOutputStream; @@ -48,7 +40,6 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import com.fasterxml.jackson.databind.ObjectMapper; /** diff --git a/src/main/java/com/gw/utils/MyHttpUtils.java b/src/main/java/com/gw/utils/MyHttpUtils.java index eb9b67ad2..cadd59cff 100644 --- a/src/main/java/com/gw/utils/MyHttpUtils.java +++ b/src/main/java/com/gw/utils/MyHttpUtils.java @@ -1,22 +1,5 @@ package com.gw.utils; -import java.net.*; -import java.util.Map; - -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.httpclient.Credentials; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.httpclient.NameValuePair; -import org.apache.commons.httpclient.UsernamePasswordCredentials; -import org.apache.commons.httpclient.auth.AuthScope; -import org.apache.commons.httpclient.methods.PostMethod; -import org.apache.commons.httpclient.methods.StringRequestEntity; -import org.apache.log4j.Logger; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.io.*; /** * * @author Administrator @@ -27,73 +10,73 @@ public class MyHttpUtils { - public static Logger theLogger = Logger.getLogger(MyHttpUtils.class); + // public static Logger theLogger = Logger.getLogger(MyHttpUtils.class); - /** - * - * @param querystr - * @return - */ - public static NameValuePair[] turnStr2NVPs(String querystr) { + // /** + // * + // * @param querystr + // * @return + // */ + // public static NameValuePair[] turnStr2NVPs(String querystr) { - String[] ss = querystr.split("&"); + // String[] ss = querystr.split("&"); - NameValuePair[] nvps = new NameValuePair[ss.length]; + // NameValuePair[] nvps = new NameValuePair[ss.length]; - for(int i=0;i> "Content-Type: text/xml;charset=UTF-8[\r][\n]" +// // Open the connection and prepare to POST +// URLConnection uc = u.openConnection(); +// HttpURLConnection huc = (HttpURLConnection)uc; +// // Fri Sep 02 23:37:24 EDT 2016:DEBUG:>> "Content-Type: text/xml;charset=UTF-8[\r][\n]" - huc.setRequestProperty("Content-Type", "text/xml;charset=UTF-8"); - huc.setDoOutput(true); - huc.setDoInput(true); - huc.setAllowUserInteraction(false); +// huc.setRequestProperty("Content-Type", "text/xml;charset=UTF-8"); +// huc.setDoOutput(true); +// huc.setDoInput(true); +// huc.setAllowUserInteraction(false); - DataOutputStream dstream = new DataOutputStream(huc.getOutputStream()); +// DataOutputStream dstream = new DataOutputStream(huc.getOutputStream()); - // POST it - dstream.writeBytes(postContent); - dstream.close(); +// // POST it +// dstream.writeBytes(postContent); +// dstream.close(); - //add by Ziheng Sun on 5/3/2016 - to judge if the URL is secured - int code = huc.getResponseCode(); - if(code == 401){ - throw new RuntimeException("HTTP Code 401 Unauthorized visit. This URL is secured."); - } +// //add by Ziheng Sun on 5/3/2016 - to judge if the URL is secured +// int code = huc.getResponseCode(); +// if(code == 401){ +// throw new RuntimeException("HTTP Code 401 Unauthorized visit. This URL is secured."); +// } - // Read Response - InputStream in = huc.getInputStream(); +// // Read Response +// InputStream in = huc.getInputStream(); - BufferedReader r = new BufferedReader(new InputStreamReader(in)); - StringBuffer buf = new StringBuffer(); - String line; - while ((line = r.readLine())!=null) - buf.append(line); +// BufferedReader r = new BufferedReader(new InputStreamReader(in)); +// StringBuffer buf = new StringBuffer(); +// String line; +// while ((line = r.readLine())!=null) +// buf.append(line); - in.close(); +// in.close(); - return buf.toString(); - } +// return buf.toString(); +// } /** * * doPost @@ -221,59 +204,59 @@ public static String doPost2(String url, String postContent) throws Exception { * @return * @throws Exception */ - public static String doPost(String url, String postContent, String contenttype) throws Exception { +// public static String doPost(String url, String postContent, String contenttype) throws Exception { - URL u = new URL(url); +// URL u = new URL(url); - // Open the connection and prepare to POST +// // Open the connection and prepare to POST - URLConnection uc = u.openConnection(); +// URLConnection uc = u.openConnection(); - HttpURLConnection huc = (HttpURLConnection)uc; -// Fri Sep 02 23:37:24 EDT 2016:DEBUG:>> "Content-Type: text/xml;charset=UTF-8[\r][\n]" +// HttpURLConnection huc = (HttpURLConnection)uc; +// // Fri Sep 02 23:37:24 EDT 2016:DEBUG:>> "Content-Type: text/xml;charset=UTF-8[\r][\n]" - huc.setRequestProperty("Content-Type", contenttype); +// huc.setRequestProperty("Content-Type", contenttype); - huc.setDoOutput(true); +// huc.setDoOutput(true); - huc.setDoInput(true); +// huc.setDoInput(true); - huc.setAllowUserInteraction(false); +// huc.setAllowUserInteraction(false); - DataOutputStream dstream = new DataOutputStream(huc.getOutputStream()); +// DataOutputStream dstream = new DataOutputStream(huc.getOutputStream()); - // POST it - dstream.writeBytes(postContent); +// // POST it +// dstream.writeBytes(postContent); - dstream.close(); +// dstream.close(); - //add by Ziheng Sun on 5/3/2016 - to judge if the URL is secured - int code = huc.getResponseCode(); +// //add by Ziheng Sun on 5/3/2016 - to judge if the URL is secured +// int code = huc.getResponseCode(); - if(code == 401){ +// if(code == 401){ - throw new RuntimeException("HTTP Code 401 Unauthorized visit. This URL is secured."); +// throw new RuntimeException("HTTP Code 401 Unauthorized visit. This URL is secured."); - } +// } - // Read Response - InputStream in = huc.getInputStream(); +// // Read Response +// InputStream in = huc.getInputStream(); - BufferedReader r = new BufferedReader(new InputStreamReader(in)); +// BufferedReader r = new BufferedReader(new InputStreamReader(in)); - StringBuffer buf = new StringBuffer(); +// StringBuffer buf = new StringBuffer(); - String line; +// String line; - while ((line = r.readLine())!=null) +// while ((line = r.readLine())!=null) - buf.append(line); +// buf.append(line); - in.close(); +// in.close(); - return buf.toString(); +// return buf.toString(); - } +// } @@ -285,42 +268,42 @@ public static String doPost(String url, String postContent, String contenttype) * @return * @throws Exception */ - public static String doPost(String url, String postContent) throws Exception { - URL u = new URL(url); + // public static String doPost(String url, String postContent) throws Exception { + // URL u = new URL(url); - // Open the connection and prepare to POST - URLConnection uc = u.openConnection(); - HttpURLConnection huc = (HttpURLConnection)uc; - huc.setDoOutput(true); - huc.setDoInput(true); - huc.setAllowUserInteraction(false); + // // Open the connection and prepare to POST + // URLConnection uc = u.openConnection(); + // HttpURLConnection huc = (HttpURLConnection)uc; + // huc.setDoOutput(true); + // huc.setDoInput(true); + // huc.setAllowUserInteraction(false); - DataOutputStream dstream = new DataOutputStream(huc.getOutputStream()); + // DataOutputStream dstream = new DataOutputStream(huc.getOutputStream()); - // POST it - dstream.writeBytes(postContent); - dstream.close(); + // // POST it + // dstream.writeBytes(postContent); + // dstream.close(); - //add by Ziheng Sun on 5/3/2016 - to judge if the URL is secured - int code = huc.getResponseCode(); - if(code == 401){ - throw new RuntimeException("HTTP Code 401 Unauthorized visit. This URL is secured."); - } + // //add by Ziheng Sun on 5/3/2016 - to judge if the URL is secured + // int code = huc.getResponseCode(); + // if(code == 401){ + // throw new RuntimeException("HTTP Code 401 Unauthorized visit. This URL is secured."); + // } - // Read Response - InputStream in = huc.getInputStream(); + // // Read Response + // InputStream in = huc.getInputStream(); - BufferedReader r = new BufferedReader(new InputStreamReader(in)); - StringBuffer buf = new StringBuffer(); - String line; - while ((line = r.readLine())!=null) - buf.append(line); + // BufferedReader r = new BufferedReader(new InputStreamReader(in)); + // StringBuffer buf = new StringBuffer(); + // String line; + // while ((line = r.readLine())!=null) + // buf.append(line); - in.close(); + // in.close(); - return buf.toString(); - } + // return buf.toString(); + // } /** * HTTP GET @@ -328,41 +311,41 @@ public static String doPost(String url, String postContent) throws Exception { * @return * @throws Exception */ - public static String doGet(String url) throws Exception - { + // public static String doGet(String url) throws Exception + // { - //url = java.net.URLEncoder.encode(url,"UTF-8"); + // //url = java.net.URLEncoder.encode(url,"UTF-8"); - theLogger.debug("Encoded URL: " + url); + // theLogger.debug("Encoded URL: " + url); - URL u = new URL(url); + // URL u = new URL(url); - // Open the connection and prepare to POST - URLConnection uc = u.openConnection(); - HttpURLConnection huc = (HttpURLConnection)uc; - huc.setDoOutput(false); - huc.setDoInput(true); - huc.setAllowUserInteraction(false); + // // Open the connection and prepare to POST + // URLConnection uc = u.openConnection(); + // HttpURLConnection huc = (HttpURLConnection)uc; + // huc.setDoOutput(false); + // huc.setDoInput(true); + // huc.setAllowUserInteraction(false); - //add by Ziheng Sun on 5/3/2016 - to judge if the URL is secured - int code = huc.getResponseCode(); - if(code == 401){ - throw new RuntimeException("HTTP Code 401 Unauthorized visit. This URL is secured."); - } + // //add by Ziheng Sun on 5/3/2016 - to judge if the URL is secured + // int code = huc.getResponseCode(); + // if(code == 401){ + // throw new RuntimeException("HTTP Code 401 Unauthorized visit. This URL is secured."); + // } - // Read Response - InputStream in = huc.getInputStream(); + // // Read Response + // InputStream in = huc.getInputStream(); - BufferedReader r = new BufferedReader(new InputStreamReader(in)); - StringBuffer buf = new StringBuffer(); - String line; - while ((line = r.readLine())!=null) - buf.append(line); + // BufferedReader r = new BufferedReader(new InputStreamReader(in)); + // StringBuffer buf = new StringBuffer(); + // String line; + // while ((line = r.readLine())!=null) + // buf.append(line); - in.close(); + // in.close(); - return buf.toString(); - } + // return buf.toString(); + // } /** * HTTP GET with cookies * @param url @@ -370,37 +353,37 @@ public static String doGet(String url) throws Exception * @return * @throws Exception */ - public static String doGetWithCookies(String url, String cookie_str) throws Exception - { - URL u = new URL(url); - - // Open the connection and prepare to POST - URLConnection uc = u.openConnection(); - HttpURLConnection huc = (HttpURLConnection)uc; - huc.setDoOutput(false); - huc.setDoInput(true); - huc.setAllowUserInteraction(false); - huc.setRequestProperty("Cookie", cookie_str); - - //add by Ziheng Sun on 5/3/2016 - to judge if the URL is secured - int code = huc.getResponseCode(); - if(code == 401){ - throw new RuntimeException("HTTP Code 401 Unauthorized visit. This URL is secured."); - } - - // Read Response - InputStream in = huc.getInputStream(); - - BufferedReader r = new BufferedReader(new InputStreamReader(in)); - StringBuffer buf = new StringBuffer(); - String line; - while ((line = r.readLine())!=null) - buf.append(line); - - in.close(); - - return buf.toString(); - } + // public static String doGetWithCookies(String url, String cookie_str) throws Exception + // { + // URL u = new URL(url); + + // // Open the connection and prepare to POST + // URLConnection uc = u.openConnection(); + // HttpURLConnection huc = (HttpURLConnection)uc; + // huc.setDoOutput(false); + // huc.setDoInput(true); + // huc.setAllowUserInteraction(false); + // huc.setRequestProperty("Cookie", cookie_str); + + // //add by Ziheng Sun on 5/3/2016 - to judge if the URL is secured + // int code = huc.getResponseCode(); + // if(code == 401){ + // throw new RuntimeException("HTTP Code 401 Unauthorized visit. This URL is secured."); + // } + + // // Read Response + // InputStream in = huc.getInputStream(); + + // BufferedReader r = new BufferedReader(new InputStreamReader(in)); + // StringBuffer buf = new StringBuffer(); + // String line; + // while ((line = r.readLine())!=null) + // buf.append(line); + + // in.close(); + + // return buf.toString(); + // } /** * Login request only returns headers without body @@ -408,227 +391,227 @@ public static String doGetWithCookies(String url, String cookie_str) throws Exce * @param body * @return */ - public static org.springframework.http.ResponseEntity login_jupyterhub(String target_url, org.springframework.http.HttpEntity requestentity, String hostid){ - - org.springframework.http.ResponseEntity resp = null; - - try{ - - java.net.http.HttpClient client = java.net.http.HttpClient.newHttpClient(); - - // Host: geoweaver2.eastus.cloudapp.azure.com:8000 - // User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0 - // Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 - // Accept-Language: en-US,en;q=0.5 - // Accept-Encoding: gzip, deflate - // Content-Type: application/x-www-form-urlencoded - // Content-Length: 34 - // Origin: http://geoweaver2.eastus.cloudapp.azure.com:8000 - // DNT: 1 - // Connection: keep-alive - // Referer: http://geoweaver2.eastus.cloudapp.azure.com:8000/hub/login - // Cookie: _xsrf=2|c0891671|6a2f9feb3275ae40b57960c55db32f51|1615354056 - // Upgrade-Insecure-Requests: 1 - // create a request - System.out.println("Testing JupyterHub Request.."); - - // ObjectMapper objectMapper = new ObjectMapper(); - // String requestBody = objectMapper.writeValueAsString(values); - org.springframework.http.HttpHeaders headers = requestentity.getHeaders(); +// public static org.springframework.http.ResponseEntity login_jupyterhub(String target_url, org.springframework.http.HttpEntity requestentity, String hostid){ + +// org.springframework.http.ResponseEntity resp = null; + +// try{ + +// java.net.http.HttpClient client = java.net.http.HttpClient.newHttpClient(); + +// // Host: geoweaver2.eastus.cloudapp.azure.com:8000 +// // User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0 +// // Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 +// // Accept-Language: en-US,en;q=0.5 +// // Accept-Encoding: gzip, deflate +// // Content-Type: application/x-www-form-urlencoded +// // Content-Length: 34 +// // Origin: http://geoweaver2.eastus.cloudapp.azure.com:8000 +// // DNT: 1 +// // Connection: keep-alive +// // Referer: http://geoweaver2.eastus.cloudapp.azure.com:8000/hub/login +// // Cookie: _xsrf=2|c0891671|6a2f9feb3275ae40b57960c55db32f51|1615354056 +// // Upgrade-Insecure-Requests: 1 +// // create a request +// System.out.println("Testing JupyterHub Request.."); + +// // ObjectMapper objectMapper = new ObjectMapper(); +// // String requestBody = objectMapper.writeValueAsString(values); +// org.springframework.http.HttpHeaders headers = requestentity.getHeaders(); - Map header_vm = headers.toSingleValueMap(); +// Map header_vm = headers.toSingleValueMap(); - java.net.http.HttpRequest.Builder builder = java.net.http.HttpRequest.newBuilder(URI.create(target_url)); +// java.net.http.HttpRequest.Builder builder = java.net.http.HttpRequest.newBuilder(URI.create(target_url)); - for (java.util.Map.Entry mapElement : header_vm.entrySet()) { +// for (java.util.Map.Entry mapElement : header_vm.entrySet()) { - String key = (String)mapElement.getKey(); +// String key = (String)mapElement.getKey(); - String value = (String)mapElement.getValue(); +// String value = (String)mapElement.getValue(); - System.out.println(key + " : " + value); +// System.out.println(key + " : " + value); - String lowkey = key.toLowerCase(); +// String lowkey = key.toLowerCase(); - if(lowkey.equals("host") || lowkey.equals("connection") || lowkey.equals("content-length")){ +// if(lowkey.equals("host") || lowkey.equals("connection") || lowkey.equals("content-length")){ - continue; +// continue; - } +// } - builder = builder.header(key, value); +// builder = builder.header(key, value); - } +// } - java.net.http.HttpRequest request = builder - // .header("Cache-Control", "max-age=0") - // .header("Upgrade-Insecure-Requests", "1") - // .header("Content-Type", "application/x-www-form-urlencoded") - // .header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36") - // .header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9") - // .header("Sec-Fetch-Site", "same-origin") - // .header("Sec-Fetch-Mode", "navigate") - // .header("Sec-Fetch-User", "?1") - // .header("Sec-Fetch-Dest", "document") - // .header("Cookie", "_xsrf=2|c0891671|6a2f9feb3275ae40b57960c55db32f51|1615354056") - // .header("Upgrade-Insecure-Requests", "1") - .version(java.net.http.HttpClient.Version.HTTP_1_1) - .POST(java.net.http.HttpRequest.BodyPublishers.ofString(String.valueOf(requestentity.getBody()))) - .build(); +// java.net.http.HttpRequest request = builder +// // .header("Cache-Control", "max-age=0") +// // .header("Upgrade-Insecure-Requests", "1") +// // .header("Content-Type", "application/x-www-form-urlencoded") +// // .header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36") +// // .header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9") +// // .header("Sec-Fetch-Site", "same-origin") +// // .header("Sec-Fetch-Mode", "navigate") +// // .header("Sec-Fetch-User", "?1") +// // .header("Sec-Fetch-Dest", "document") +// // .header("Cookie", "_xsrf=2|c0891671|6a2f9feb3275ae40b57960c55db32f51|1615354056") +// // .header("Upgrade-Insecure-Requests", "1") +// .version(java.net.http.HttpClient.Version.HTTP_1_1) +// .POST(java.net.http.HttpRequest.BodyPublishers.ofString(String.valueOf(requestentity.getBody()))) +// .build(); - System.out.println(request.headers().map()); +// System.out.println(request.headers().map()); - java.net.http.HttpResponse response = client.send(request, java.net.http.HttpResponse.BodyHandlers.ofString()); +// java.net.http.HttpResponse response = client.send(request, java.net.http.HttpResponse.BodyHandlers.ofString()); - java.net.http.HttpHeaders respheaders = response.headers(); +// java.net.http.HttpHeaders respheaders = response.headers(); - respheaders.map().forEach((k, v) -> System.out.println(k + ":" + v)); +// respheaders.map().forEach((k, v) -> System.out.println(k + ":" + v)); - // print status code - System.out.println(response.statusCode()); +// // print status code +// System.out.println(response.statusCode()); - // print response body - System.out.println(response.body()); +// // print response body +// System.out.println(response.body()); - // org.springframework.http.HttpHeaders respheaders = ; +// // org.springframework.http.HttpHeaders respheaders = ; -// MultiValueMap headers =new LinkedMultiValueMap(); +// // MultiValueMap headers =new LinkedMultiValueMap(); - org.springframework.http.HttpHeaders newresponseheaders = new org.springframework.http.HttpHeaders(); +// org.springframework.http.HttpHeaders newresponseheaders = new org.springframework.http.HttpHeaders(); -// logger.info("Redirection: " + newresponseheaders); +// // logger.info("Redirection: " + newresponseheaders); - System.out.println("Response: " + response.body()); +// System.out.println("Response: " + response.body()); -// responseEntity = restTemplate.exchange(uri, method, requestentity, String.class); +// // responseEntity = restTemplate.exchange(uri, method, requestentity, String.class); -// responseEntity.getHeaders().compute("Location", (k, v) -> {v.clear(); v.add("/Geoweaver/web/jupyter-proxy/tree?");}); +// // responseEntity.getHeaders().compute("Location", (k, v) -> {v.clear(); v.add("/Geoweaver/web/jupyter-proxy/tree?");}); -// responseEntity.getHeaders().set("Location", "/Geoweaver/web/jupyter-proxy/tree?"); +// // responseEntity.getHeaders().set("Location", "/Geoweaver/web/jupyter-proxy/tree?"); -// respheaders.set("Location", "/Geoweaver/web/jupyter-proxy/tree?"); +// // respheaders.set("Location", "/Geoweaver/web/jupyter-proxy/tree?"); -// respheaders.setLocation(new URI("/Geoweaver/web/jupyter-proxy/tree?")); +// // respheaders.setLocation(new URI("/Geoweaver/web/jupyter-proxy/tree?")); -// respheaders.add("Test", "Test Value"); +// // respheaders.add("Test", "Test Value"); - respheaders.map().forEach((key, value) -> { +// respheaders.map().forEach((key, value) -> { - if(key.toLowerCase().equals("location")) { +// if(key.toLowerCase().equals("location")) { - newresponseheaders.set(key, "/Geoweaver/jupyter-proxy/" + hostid + value.get(0)); +// newresponseheaders.set(key, "/Geoweaver/jupyter-proxy/" + hostid + value.get(0)); - }else { +// }else { - newresponseheaders.set(key, value.get(0)); +// newresponseheaders.set(key, value.get(0)); - } +// } - }); +// }); - resp = new org.springframework.http.ResponseEntity( - response.body(), - newresponseheaders, - response.statusCode()); +// resp = new org.springframework.http.ResponseEntity( +// response.body(), +// newresponseheaders, +// response.statusCode()); - }catch(Exception e){ - - e.printStackTrace(); - - } - - return resp; - - } - - public static void testJupyterHubLogin(){ - - try{ - - java.net.http.HttpClient client = java.net.http.HttpClient.newHttpClient(); - // Host: geoweaver2.eastus.cloudapp.azure.com:8000 - // User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0 - // Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 - // Accept-Language: en-US,en;q=0.5 - // Accept-Encoding: gzip, deflate - // Content-Type: application/x-www-form-urlencoded - // Content-Length: 34 - // Origin: http://geoweaver2.eastus.cloudapp.azure.com:8000 - // DNT: 1 - // Connection: keep-alive - // Referer: http://geoweaver2.eastus.cloudapp.azure.com:8000/hub/login - // Cookie: _xsrf=2|c0891671|6a2f9feb3275ae40b57960c55db32f51|1615354056 - // Upgrade-Insecure-Requests: 1 - // create a request - System.out.println("Testing JupyterHub Request.."); - - java.net.http.HttpRequest request = java.net.http.HttpRequest.newBuilder(URI.create("http://geoweaver2.eastus.cloudapp.azure.com:8000/hub/login?next=")) - // .headers(headers) - .header("Cache-Control", "max-age=1") - .header("Upgrade-Insecure-Requests", "1") - .header("Content-Type", "application/x-www-form-urlencoded") - .header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36") - .header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9") - .header("Sec-Fetch-Site", "same-origin") - .header("Sec-Fetch-Mode", "navigate") - .header("Sec-Fetch-User", "?1") - .header("Sec-Fetch-Dest", "document") - .header("Cookie", "_xsrf=2|c0891671|6a2f9feb3275ae40b57960c55db32f51|1615354056") - .header("Upgrade-Insecure-Requests", "1") - .version(java.net.http.HttpClient.Version.HTTP_1_1) - .POST(java.net.http.HttpRequest.BodyPublishers.ofString("username=%%%%%%%%%%%%%&password=###########################")) - .build(); - - System.out.println(request.headers().map()); +// }catch(Exception e){ + +// e.printStackTrace(); + +// } + +// return resp; + +// } + +// public static void testJupyterHubLogin(){ + +// try{ + +// java.net.http.HttpClient client = java.net.http.HttpClient.newHttpClient(); +// // Host: geoweaver2.eastus.cloudapp.azure.com:8000 +// // User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0 +// // Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 +// // Accept-Language: en-US,en;q=0.5 +// // Accept-Encoding: gzip, deflate +// // Content-Type: application/x-www-form-urlencoded +// // Content-Length: 34 +// // Origin: http://geoweaver2.eastus.cloudapp.azure.com:8000 +// // DNT: 1 +// // Connection: keep-alive +// // Referer: http://geoweaver2.eastus.cloudapp.azure.com:8000/hub/login +// // Cookie: _xsrf=2|c0891671|6a2f9feb3275ae40b57960c55db32f51|1615354056 +// // Upgrade-Insecure-Requests: 1 +// // create a request +// System.out.println("Testing JupyterHub Request.."); + +// java.net.http.HttpRequest request = java.net.http.HttpRequest.newBuilder(URI.create("http://geoweaver2.eastus.cloudapp.azure.com:8000/hub/login?next=")) +// // .headers(headers) +// .header("Cache-Control", "max-age=1") +// .header("Upgrade-Insecure-Requests", "1") +// .header("Content-Type", "application/x-www-form-urlencoded") +// .header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36") +// .header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9") +// .header("Sec-Fetch-Site", "same-origin") +// .header("Sec-Fetch-Mode", "navigate") +// .header("Sec-Fetch-User", "?1") +// .header("Sec-Fetch-Dest", "document") +// .header("Cookie", "_xsrf=2|c0891671|6a2f9feb3275ae40b57960c55db32f51|1615354056") +// .header("Upgrade-Insecure-Requests", "1") +// .version(java.net.http.HttpClient.Version.HTTP_1_1) +// .POST(java.net.http.HttpRequest.BodyPublishers.ofString("username=%%%%%%%%%%%%%&password=###########################")) +// .build(); + +// System.out.println(request.headers().map()); - // use the client to send the request - java.net.http.HttpResponse response = client.send(request, java.net.http.HttpResponse.BodyHandlers.ofString()); +// // use the client to send the request +// java.net.http.HttpResponse response = client.send(request, java.net.http.HttpResponse.BodyHandlers.ofString()); - java.net.http.HttpHeaders respheaders = response.headers(); +// java.net.http.HttpHeaders respheaders = response.headers(); - respheaders.map().forEach((k, v) -> System.out.println(k + ":" + v)); +// respheaders.map().forEach((k, v) -> System.out.println(k + ":" + v)); - // print status code - System.out.println(response.statusCode()); +// // print status code +// System.out.println(response.statusCode()); - // print response body - System.out.println(response.body()); +// // print response body +// System.out.println(response.body()); - }catch(Exception e){ +// }catch(Exception e){ - e.printStackTrace(); +// e.printStackTrace(); - } +// } - } +// } - public static void main(String[] args){ - -// String url = "http://test.webdav.org/auth-basic/"; -// String postContent = "test"; -// String username = "user1"; -// String password = "user1"; -// theLogger.info("Request: " + postContent); -// String resp = MyHttpUtils.doPost_BasicAuth(url, postContent, username, password); -// theLogger.info("Response: " + resp); - - try { - // String resp = MyHttpUtils.doGet("http://ows.dev.52north.org:8080/wps/WebProcessingService?request=GetCapabilities&service=WPS&version=2.0.0"); +// public static void main(String[] args){ + +// // String url = "http://test.webdav.org/auth-basic/"; +// // String postContent = "test"; +// // String username = "user1"; +// // String password = "user1"; +// // theLogger.info("Request: " + postContent); +// // String resp = MyHttpUtils.doPost_BasicAuth(url, postContent, username, password); +// // theLogger.info("Response: " + resp); + +// try { +// // String resp = MyHttpUtils.doGet("http://ows.dev.52north.org:8080/wps/WebProcessingService?request=GetCapabilities&service=WPS&version=2.0.0"); - // theLogger.debug("Response:" + resp); +// // theLogger.debug("Response:" + resp); - MyHttpUtils.testJupyterHubLogin(); +// MyHttpUtils.testJupyterHubLogin(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } } From 30847cfe8fb651db46369b0bbb17ea39042230a6 Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Wed, 17 Mar 2021 01:19:24 -0400 Subject: [PATCH 04/11] update --- .vscode/settings.json | 3 +++ pom.xml | 22 +--------------------- 2 files changed, 4 insertions(+), 21 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..e0f15db2e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "automatic" +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 97dbda309..1c9a4a3ba 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ - 1.8 + [5.3.1,) @@ -150,26 +150,6 @@ json-simple 1.1.1 - - log4j - log4j - 1.2.17 - - - org.dom4j - dom4j - 2.1.3 - - - org.slf4j - slf4j-api - 1.7.12 - - - org.slf4j - slf4j-log4j12 - 1.7.12 - - - org.apache.commons - commons-text - 1.6 - - - com.googlecode.json-simple - json-simple - 1.1.1 - @@ -295,6 +276,8 @@ commons-fileupload 1.3.3 + + From 804d6818941b195353ccddb1eead81ac886f4bbb Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Mon, 22 Mar 2021 16:22:24 -0400 Subject: [PATCH 06/11] update --- pom.xml | 2 +- src/main/java/com/gw/web/GeoweaverController.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 1cad5a43f..2370db4bf 100644 --- a/pom.xml +++ b/pom.xml @@ -248,7 +248,7 @@ org.dom4j dom4j - 2.1.1 + [2.1.3,) org.slf4j diff --git a/src/main/java/com/gw/web/GeoweaverController.java b/src/main/java/com/gw/web/GeoweaverController.java index 7e7421977..c8ce5e1b2 100644 --- a/src/main/java/com/gw/web/GeoweaverController.java +++ b/src/main/java/com/gw/web/GeoweaverController.java @@ -1304,7 +1304,7 @@ public String sshterminal(ModelMap model, WebRequest request, SessionStatus stat e.printStackTrace(); - throw new RuntimeException(); + throw new RuntimeException(e.getLocalizedMessage()); } From e2ec89bf5fe3d9f48c50b06e7a56fdd895f090dc Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Tue, 23 Mar 2021 15:29:31 -0400 Subject: [PATCH 07/11] update --- .../java/com/gw/web/JupyterController.java | 146 +++++++++++------- src/main/resources/static/js/gw.host.js | 20 ++- src/main/resources/templates/geoweaver.html | 5 + 3 files changed, 109 insertions(+), 62 deletions(-) diff --git a/src/main/java/com/gw/web/JupyterController.java b/src/main/java/com/gw/web/JupyterController.java index 5bce1c150..1a1e883b8 100644 --- a/src/main/java/com/gw/web/JupyterController.java +++ b/src/main/java/com/gw/web/JupyterController.java @@ -1157,58 +1157,6 @@ public ResponseEntity jupyterhub_login( HttpMethod method, @PathVariable("hostid HttpHeaders respheaders = updateHeader(responseEntity.getHeaders(), responseEntity.getBody(), hostid); -// HttpHeaders respheaders = responseEntity.getHeaders(); - -// if(responseEntity.getStatusCode()==HttpStatus.FOUND) { - -// // MultiValueMap headers =new LinkedMultiValueMap(); - -// HttpHeaders newresponseheaders = new HttpHeaders(); - -// // logger.info("Redirection: " + newresponseheaders); -// // -// logger.info("Response: " + responseEntity.getBody()); - -// // responseEntity = restTemplate.exchange(uri, method, requestentity, String.class); - -// // responseEntity.getHeaders().compute("Location", (k, v) -> {v.clear(); v.add("/Geoweaver/web/jupyter-proxy/tree?");}); - -// // responseEntity.getHeaders().set("Location", "/Geoweaver/web/jupyter-proxy/tree?"); - -// // respheaders.set("Location", "/Geoweaver/web/jupyter-proxy/tree?"); - -// // respheaders.setLocation(new URI("/Geoweaver/web/jupyter-proxy/tree?")); - -// // respheaders.add("Test", "Test Value"); - -// // respheaders.forEach((key, value) -> { - -// // if(key.toLowerCase().equals("location")) { - -// // newresponseheaders.set(key, "/Geoweaver/jupyter-proxy/" + hostid + value.get(0)); - -// // }else { - -// // newresponseheaders.set(key, value.get(0)); - -// // } - -// // }); - -// respheaders = newresponseheaders; - -// // Set ent = respheaders.entrySet(); - -// logger.info(respheaders.toString()); - -// }else if(responseEntity.getStatusCode()==HttpStatus.UNAUTHORIZED) { - -// logger.error("Login Unauthorized"); - -// } - -// resp = new ResponseEntity(null, respheaders, resp.getStatusCode()); - resp = new ResponseEntity( responseEntity.getBody(), respheaders, @@ -1217,16 +1165,94 @@ public ResponseEntity jupyterhub_login( HttpMethod method, @PathVariable("hostid }catch (HttpStatusCodeException ex) { - // http status code e.g. `404 NOT_FOUND` -// logger.error(ex.getStatusCode().toString()); + String newbody = addURLProxy(ex.getResponseBodyAsString(), hostid); - // get response body -// System.out.println(ex.getResponseBodyAsString()); + resp = errorControl(newbody, hostid); - // get http headers -// HttpHeaders headers = ex.getResponseHeaders(); -// System.out.println(headers.get("Content-Type")); -// System.out.println(headers.get("Server")); + }catch(Exception e) { + + e.printStackTrace(); + + resp = errorControl(e.getLocalizedMessage(), hostid); + + } + + return resp; + + } + + @RequestMapping(value="/jupyter-proxy/{hostid}/lab/login", method = RequestMethod.POST) + public ResponseEntity jupyterlab_login( HttpMethod method, @PathVariable("hostid") String hostid, + @RequestHeader HttpHeaders httpheaders, HttpServletRequest request) throws URISyntaxException + { +// ResponseEntity resp = processPost(reqentity, method, request); + + ResponseEntity resp = null; + + +// resp = processUtil(reqentity, method, request, hostid); + + try { + +// URI uri = new URI("https", null, server, port, request.getRequestURI(), request.getQueryString(), null); + + logger.debug("=============="); + + logger.debug("Login attempt starts..."); + + logger.debug("Request URI: " + request.getRequestURI()); + + logger.info("HTTP Method: " + method.toString()); + + HttpHeaders newheaders = getHeaders(httpheaders, method, request, hostid); + + MultiValueMap map= new LinkedMultiValueMap(); + + Iterator hmIterator = request.getParameterMap().entrySet().iterator(); + + // Iterate through the hashmap + + StringBuffer reqstr = new StringBuffer(); + + while (hmIterator.hasNext()) { + + Map.Entry mapElement = (Map.Entry)hmIterator.next(); + + map.add((String)mapElement.getKey(), ((String[])(mapElement.getValue()))[0]); + + if(!bt.isNull(reqstr.toString())) { + + reqstr.append("&"); + + } + + reqstr.append((String)mapElement.getKey()).append("=").append(((String[])(mapElement.getValue()))[0]); + + } + + +// HttpHeaders newheaders = this.updateHeaderReferer(httpheaders, h, realurl, request.getQueryString()); + + HttpEntity requestentity = new HttpEntity(reqstr.toString(), newheaders); + + // RestTemplate restTemplate1 = new RestTemplate(new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory())); + // List interceptors = new ArrayList<>(); + // interceptors.add(new LoggingRequestInterceptor()); + // restTemplate1.setInterceptors(interceptors); + + String target_url = getRealTargetURL(newheaders.get("target_url").get(0)); + + ResponseEntity responseEntity = restTemplate.exchange(target_url, method, requestentity, String.class); + + HttpHeaders respheaders = updateHeader(responseEntity.getHeaders(), responseEntity.getBody(), hostid); + + resp = new ResponseEntity( + responseEntity.getBody(), + respheaders, + responseEntity.getStatusCode()); + + + }catch (HttpStatusCodeException ex) { String newbody = addURLProxy(ex.getResponseBodyAsString(), hostid); diff --git a/src/main/resources/static/js/gw.host.js b/src/main/resources/static/js/gw.host.js index c5021702e..a37b589fd 100644 --- a/src/main/resources/static/js/gw.host.js +++ b/src/main/resources/static/js/gw.host.js @@ -900,7 +900,7 @@ GW.host = { } - }else if(hosttype=="jupyter" || hosttype=="jupyterhub"){ + }else if(hosttype=="jupyter" || hosttype=="jupyterhub" || hosttype=="jupyterlab"){ if($("#hostname").val()&&$("#jupyter_home_url").val()){ @@ -1144,7 +1144,7 @@ GW.host = { hostid + "')\" data-toggle=\"tooltip\" title=\"Browser File Hierarchy\">"; - }else if(hosttype=="jupyter" || hosttype=="jupyterhub" ){ + }else if(hosttype=="jupyter" || hosttype=="jupyterhub" || hosttype=="jupyterlab" ){ content += "'+ ' '; + }else if(host_type=="jupyterlab"){ + + content = '
'+ + ' '+ + '
'+ + ' '+ + '
'+ + '
'+ + '
'+ + ' '+ + '
'+ + ' '+ + '
'+ + '
'; + }else if(host_type == "ssh") { content = '
'+ @@ -1744,6 +1759,7 @@ GW.host = { ' '+ ' '+ ' '+ + ' '+ ' '+ ' '+ '
'+ diff --git a/src/main/resources/templates/geoweaver.html b/src/main/resources/templates/geoweaver.html index 6278e005a..7dfacbed8 100644 --- a/src/main/resources/templates/geoweaver.html +++ b/src/main/resources/templates/geoweaver.html @@ -411,6 +411,11 @@

logging information and errors

Jupyter Hub + +
  • + Jupyter Lab +
  • +
  • Google Earth Engine From a028d1d0ba4c6d849184991e3754680f26283805 Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Tue, 23 Mar 2021 17:13:36 -0400 Subject: [PATCH 08/11] update --- src/main/resources/static/js/gw.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/resources/static/js/gw.js b/src/main/resources/static/js/gw.js index e546ec6b0..c93330ca1 100644 --- a/src/main/resources/static/js/gw.js +++ b/src/main/resources/static/js/gw.js @@ -1,6 +1,4 @@ /** -* -* author: Ziheng Sun * * date: 20180925 * @@ -18,11 +16,11 @@ edu = { sponsor: "ESIPLab incubator project", - version: "0.8.6", + version: "0.9.2", - author: "Ziheng Sun", + author: "open source contributors", - institute: "George Mason University" + institute: "NASA, NSF, George Mason University, ESIP, University of Texas Austin, University of Washington, University of Idaho, " } } From 18d6cb5444c4e8eedc3415b652903ea3f0fb671e Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Fri, 26 Mar 2021 10:41:14 -0400 Subject: [PATCH 09/11] update --- pom.xml | 9 +++++++-- .../java/com/gw/ssh/SecurityConfiguration.java | 1 + src/main/java/com/gw/web/JupyterController.java | 14 +++++++++++--- src/main/resources/log4j.properties | 2 +- src/main/resources/static/js/gw.js | 4 ++-- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 2370db4bf..dc308f51b 100644 --- a/pom.xml +++ b/pom.xml @@ -10,12 +10,12 @@ com.gw geoweaver - 0.9.2 + 0.9.3 geoweaver A workflow management for hybrid AI experiments of various scales - jar + war @@ -200,6 +200,11 @@ thymeleaf-spring5 ${thymeleaf-version} +