Compare commits

...

3 Commits

Author SHA1 Message Date
hcyi
b715f0e05c fix(TUP-34595):we are trying to access api.eu.cloud.talend.com without (#5010)
passing through a proxy.
2022-01-29 11:18:54 +08:00
Chao MENG
7f8d221d6b chore: change the url check url (#4973) 2022-01-19 11:59:30 +08:00
Jill Yan
69fd0c5138 Revert "APPINT-33992 (#4937)" (#4966)
This reverts commit 21232bf4e4.
2022-01-14 17:33:19 +08:00
3 changed files with 33 additions and 15 deletions

View File

@@ -50,8 +50,6 @@ public class NetworkUtil {
private static final String TALEND_DISABLE_INTERNET = "talend.disable.internet";//$NON-NLS-1$
private static final String HTTP_NETWORK_URL = "https://talend-update.talend.com";
private static final int DEFAULT_TIMEOUT = 4000;
private static final int DEFAULT_NEXUS_TIMEOUT = 20000;// same as preference value
@@ -89,7 +87,7 @@ public class NetworkUtil {
}
HttpURLConnection conn = null;
try {
URL url = new URL(HTTP_NETWORK_URL);
URL url = new URL(getCheckUrl());
conn = (HttpURLConnection) url.openConnection();
conn.setDefaultUseCaches(false);
conn.setUseCaches(false);
@@ -112,6 +110,15 @@ public class NetworkUtil {
return true;
}
private static String getCheckUrl() {
String customUrl = System.getProperty("talend.studio.network.checkUrlPath");
if (StringUtils.isNotBlank(customUrl)) {
return customUrl;
} else {
return "https://talend-update.talend.com/nexus/content/repositories/libraries/";
}
}
public static boolean isNetworkValid(String url, Integer timeout) {
if (url == null) {
return isNetworkValid(timeout);

View File

@@ -14,6 +14,7 @@ package org.talend.core.pendo;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
@@ -31,8 +32,7 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.entity.ContentType;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Level;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -41,10 +41,12 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.utils.VersionUtils;
import org.talend.commons.utils.network.IProxySelectorProvider;
import org.talend.commons.utils.network.NetworkUtil;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.context.Context;
import org.talend.core.context.RepositoryContext;
import org.talend.core.nexus.HttpClientTransport;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.core.service.IRemoteService;
import org.talend.core.service.IStudioLiteP2Service;
@@ -118,8 +120,9 @@ public class PendoTrackSender {
return;
}
CloseableHttpClient client = null;
DefaultHttpClient client = null;
CloseableHttpResponse response = null;
IProxySelectorProvider proxySelectorProvider = null;
try {
String pendoInfo = getPendoInfo();
if (StringUtils.isBlank(pendoInfo)) {
@@ -130,11 +133,14 @@ public class PendoTrackSender {
throw new Exception("Pendo key is empty");
}
client = HttpClients.createDefault();
client = new DefaultHttpClient();
String url = getBaseUrl() + PENDO_TRACK;
HttpPost httpPost = new HttpPost(url);
httpPost.setHeader(HEAD_CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType());
httpPost.setHeader(HEAD_PENDO_KEY, pendoKey);
proxySelectorProvider = HttpClientTransport.addProxy(client, new URI(url));
EntityBuilder entityBuilder = EntityBuilder.create();
entityBuilder.setText(generateTrackData(pendoInfo)).setContentType(ContentType.APPLICATION_JSON);
HttpEntity entity = entityBuilder.build();
@@ -146,6 +152,8 @@ public class PendoTrackSender {
throw new Exception(statusLine.toString() + ", server message: [" + responseStr + "]");
}
} finally {
HttpClientTransport.removeProxy(proxySelectorProvider);
client.getConnectionManager().shutdown();
if (response != null) {
try {
response.close();
@@ -213,14 +221,18 @@ public class PendoTrackSender {
}
private String getPendoInfo(String baseUrl, String token) throws Exception {
CloseableHttpClient client = null;
DefaultHttpClient client = null;
CloseableHttpResponse response = null;
IProxySelectorProvider proxySelectorProvider = null;
try {
client = HttpClients.createDefault();
client = new DefaultHttpClient();
String url = baseUrl + PENDO_INFO;
HttpGet httpGet = new HttpGet(url);
httpGet.setHeader(HEAD_AUTHORIZATION, "Bearer " + token);
proxySelectorProvider = HttpClientTransport.addProxy(client, new URI(url));
response = client.execute(httpGet, HttpClientContext.create());
StatusLine statusLine = response.getStatusLine();
String responseStr = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
@@ -229,6 +241,8 @@ public class PendoTrackSender {
}
return responseStr;
} finally {
HttpClientTransport.removeProxy(proxySelectorProvider);
client.getConnectionManager().shutdown();
if (response != null) {
try {
response.close();

View File

@@ -71,8 +71,6 @@ public class RepositoryConstants {
// folder
public static final String FOLDER_PATTERN = "^[a-zA-Z]+[a-zA-Z0-9\\_]*$"; //$NON-NLS-1$
public static final String RESOURCES_PATTERN = "^[a-zA-Z]+[a-zA-Z0-9\\_]*$"; //$NON-NLS-1$
public static final String REPOSITORY_ITEM_PATTERN_INTERN = "a-zA-Z0-9\\.\\-\\_\\ \\(\\)\\[\\]="; //$NON-NLS-1$
@@ -153,11 +151,10 @@ public class RepositoryConstants {
|| type == ERepositoryObjectType.METADATA_WSDL_SCHEMA
|| type == ERepositoryObjectType.METADATA_VALIDATION_RULES
|| type == ERepositoryObjectType.METADATA_FILE_FTP || type == ERepositoryObjectType.METADATA_EDIFACT) {
return METADATA_NAME_PATTERN;
} else if( type == ERepositoryObjectType.RESOURCES) {
return RESOURCES_PATTERN;
return METADATA_NAME_PATTERN;
}
// GLIU: add for TESB-3837
} else if (type != null && "SERVICES".equals(type.getType())) { //$NON-NLS-1$
else if (type != null && "SERVICES".equals(type.getType())) { //$NON-NLS-1$
return SERVICES_NAME_PATTERN;
} else if (type != null && type.getType() != null && type.getType().startsWith("MDM.")) { //$NON-NLS-1$
return MDM_ITEM_PATTERN;