Compare commits
1 Commits
patch/7.1.
...
patch_clou
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66efe6b15e |
@@ -13,9 +13,7 @@ Require-Bundle: org.apache.log4j;visibility:=reexport,
|
||||
org.talend.libraries.apache,
|
||||
org.apache.xerces,
|
||||
com.ibm.icu,
|
||||
org.apache.commons.io,
|
||||
org.talend.utils,
|
||||
org.eclipse.core.net
|
||||
org.apache.commons.io
|
||||
Export-Package: org.talend.commons,
|
||||
org.talend.commons.exception,
|
||||
org.talend.commons.i18n,
|
||||
|
||||
@@ -17,13 +17,11 @@ import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.eclipse.core.net.proxy.IProxyService;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
import org.osgi.util.tracker.ServiceTracker;
|
||||
import org.talend.commons.exception.ExceptionService;
|
||||
import org.talend.commons.runtime.debug.TalendDebugHandler;
|
||||
|
||||
@@ -54,8 +52,6 @@ public class CommonsPlugin implements BundleActivator {
|
||||
// TESB-17856: For commandline builds ESB Micorservice bundle
|
||||
private static boolean isESBMicorservice = false;
|
||||
|
||||
private static ServiceTracker proxyTracker;
|
||||
|
||||
public static boolean isWorkbenchCreated() {
|
||||
return isWorkbenchCreated;
|
||||
}
|
||||
@@ -164,13 +160,4 @@ public class CommonsPlugin implements BundleActivator {
|
||||
InstanceScope.INSTANCE.getNode("org.eclipse.m2e.core").putBoolean("eclipse.m2.offline", state);
|
||||
}
|
||||
|
||||
public static IProxyService getProxyService() {
|
||||
if (proxyTracker == null) {
|
||||
proxyTracker = new ServiceTracker(Platform.getBundle(PLUGIN_ID).getBundleContext(), IProxyService.class.getName(),
|
||||
null);
|
||||
proxyTracker.open();
|
||||
}
|
||||
return (IProxyService) proxyTracker.getService();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2020 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.commons.exception;
|
||||
|
||||
public class ClientException extends PersistenceException {
|
||||
|
||||
private Integer httpCode;
|
||||
|
||||
public ClientException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ClientException(Integer httpCode, String message) {
|
||||
super(message);
|
||||
this.httpCode = httpCode;
|
||||
}
|
||||
|
||||
public ClientException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public ClientException(Integer httpCode, String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.httpCode = httpCode;
|
||||
}
|
||||
|
||||
public ClientException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public ClientException(Integer httpCode, Throwable cause) {
|
||||
super(cause);
|
||||
this.httpCode = httpCode;
|
||||
}
|
||||
|
||||
public Integer getHttpCode() {
|
||||
return httpCode;
|
||||
}
|
||||
|
||||
public void setHttpCode(Integer httpCode) {
|
||||
this.httpCode = httpCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getLocalizedMessage();
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,3 @@ AS400ResultSet.unknowCloumn=Invalid argument\: unknown column name
|
||||
AS400ResultSet.parameterIndex=Invalid argument\: parameter index
|
||||
AS400ResultSet.outofRange=\ is out of range.
|
||||
ITaCoKitService.exception.multipleInstance=More than one instance found: {0}
|
||||
TalendProxySelector.exception.badUriMap=Bad uri map: {0}
|
||||
TalendProxySelector.exception.proxySelectionError=Error occurs when selecting proxy for {0}
|
||||
|
||||
|
||||
@@ -35,8 +35,6 @@ public interface ITaCoKitService {
|
||||
|
||||
boolean isTaCoKitCar(File file, IProgressMonitor monitor) throws Exception;
|
||||
|
||||
boolean isNeedMigration(String projectLabel) throws Exception;
|
||||
|
||||
void checkMigration(final IProgressMonitor monitor) throws Exception;
|
||||
|
||||
public static ITaCoKitService getInstance() throws Exception {
|
||||
|
||||
@@ -123,10 +123,6 @@ public class FileCopyUtils {
|
||||
if (!resFolder.exists()) {
|
||||
return;
|
||||
}
|
||||
if (resFolder.getAbsolutePath().equals(destFolder.getAbsolutePath())) {// If the source path and target path are
|
||||
// same, don't copy
|
||||
return;
|
||||
}
|
||||
destFolder.mkdirs();
|
||||
String[] file = resFolder.list();
|
||||
File temp = null;
|
||||
|
||||
@@ -120,41 +120,33 @@ public class SAPHanaDataBaseMetadata extends FakeDatabaseMetaData {
|
||||
public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types)
|
||||
throws SQLException {
|
||||
String[] neededTypes = getNeededTypes(types);
|
||||
ResultSet rs = connection.getMetaData().getTables(catalog, schemaPattern, tableNamePattern, neededTypes);
|
||||
List<String[]> list = new ArrayList<String[]>();
|
||||
// has other types which is not Calculation View
|
||||
if (neededTypes.length > 1 || !ArrayUtils.contains(neededTypes, NEEDED_TYPES[3])) {
|
||||
ResultSet rs = connection.getMetaData().getTables(catalog, schemaPattern, tableNamePattern, neededTypes);
|
||||
while (rs.next()) {
|
||||
String name = rs.getString("TABLE_NAME"); //$NON-NLS-1$
|
||||
String schema = rs.getString("TABLE_SCHEM"); //$NON-NLS-1$
|
||||
String type = rs.getString("TABLE_TYPE"); //$NON-NLS-1$
|
||||
while (rs.next()) {
|
||||
String name = rs.getString("TABLE_NAME"); //$NON-NLS-1$
|
||||
String schema = rs.getString("TABLE_SCHEM"); //$NON-NLS-1$
|
||||
String type = rs.getString("TABLE_TYPE"); //$NON-NLS-1$
|
||||
|
||||
String id = ""; //$NON-NLS-1$
|
||||
String remarks = ""; //$NON-NLS-1$
|
||||
try {
|
||||
remarks = rs.getString("REMARKS"); //$NON-NLS-1$
|
||||
} catch (Exception e) {
|
||||
// nothing
|
||||
}
|
||||
String id = ""; //$NON-NLS-1$
|
||||
String remarks = ""; //$NON-NLS-1$
|
||||
try {
|
||||
remarks = rs.getString("REMARKS"); //$NON-NLS-1$
|
||||
} catch (Exception e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
if (ArrayUtils.contains(neededTypes, type)) {
|
||||
// check if the type is contained is in the types needed.
|
||||
// since sybase can return some system views as "SYSTEM VIEW" instead of "VIEW/TABLE" from the
|
||||
// request.
|
||||
String[] r = new String[] { id, schema, name, type, remarks, null };
|
||||
list.add(r);
|
||||
}
|
||||
if (ArrayUtils.contains(neededTypes, type)) {
|
||||
// check if the type is contained is in the types needed.
|
||||
// since sybase can return some system views as "SYSTEM VIEW" instead of "VIEW/TABLE" from the request.
|
||||
String[] r = new String[] { id, schema, name, type, remarks, null };
|
||||
list.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
// For Calculation View
|
||||
if (ArrayUtils.contains(neededTypes, NEEDED_TYPES[3])) {
|
||||
// check if the type is contained is in the types needed.
|
||||
String sqlcv = "SELECT OBJECT_NAME,PACKAGE_ID FROM _SYS_REPO.ACTIVE_OBJECT WHERE OBJECT_SUFFIX = 'calculationview'"; //$NON-NLS-1$
|
||||
if (tableNamePattern != null && !tableNamePattern.equals("%")) { //$NON-NLS-1$
|
||||
sqlcv += " AND (OBJECT_NAME LIKE '" + tableNamePattern + "'"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
sqlcv += " OR PACKAGE_ID LIKE '" + tableNamePattern + "')"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
String sqlcv = "SELECT CATALOG_NAME,SCHEMA_NAME,CUBE_NAME, COLUMN_OBJECT,CUBE_TYPE,DESCRIPTION from _SYS_BI.BIMC_CUBES"; //$NON-NLS-1$
|
||||
ResultSet rscv = null;
|
||||
Statement stmtcv = null;
|
||||
List<String[]> listcv = new ArrayList<String[]>();
|
||||
@@ -162,16 +154,25 @@ public class SAPHanaDataBaseMetadata extends FakeDatabaseMetaData {
|
||||
stmtcv = connection.createStatement();
|
||||
rscv = stmtcv.executeQuery(sqlcv);
|
||||
while (rscv.next()) {
|
||||
String objectName = rscv.getString("OBJECT_NAME"); //$NON-NLS-1$
|
||||
if (objectName != null) {
|
||||
objectName = objectName.trim();
|
||||
String catalogName = rscv.getString("CATALOG_NAME"); //$NON-NLS-1$
|
||||
if (catalogName != null) {
|
||||
catalogName = catalogName.trim();
|
||||
}
|
||||
String packageId = rscv.getString("PACKAGE_ID"); //$NON-NLS-1$
|
||||
if (packageId != null) {
|
||||
packageId = packageId.trim();
|
||||
String schemaName = rscv.getString("SCHEMA_NAME"); //$NON-NLS-1$
|
||||
if (schemaName != null) {
|
||||
schemaName = schemaName.trim();
|
||||
}
|
||||
String name = packageId + "/" + objectName; //$NON-NLS-1$
|
||||
String[] r = new String[] { "", "_SYS_BIC", name, NEEDED_TYPES[3], "", packageId }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
String cubeName = rscv.getString("CUBE_NAME"); //$NON-NLS-1$
|
||||
if (cubeName != null) {
|
||||
cubeName = cubeName.trim();
|
||||
}
|
||||
String id = ""; //$NON-NLS-1$
|
||||
// String type = rscv.getString("CUBE_TYPE"); //$NON-NLS-1$
|
||||
|
||||
String remarks = rscv.getString("DESCRIPTION"); //$NON-NLS-1$
|
||||
String name = catalogName + "/" + cubeName;//$NON-NLS-1$
|
||||
|
||||
String[] r = new String[] { id, schemaName, name, NEEDED_TYPES[3], remarks, catalogName };
|
||||
listcv.add(r);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
|
||||
@@ -42,17 +42,13 @@ 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";
|
||||
|
||||
public static final String ORG_TALEND_DESIGNER_CORE = "org.talend.designer.core";
|
||||
|
||||
public static boolean isNetworkValid() {
|
||||
String disableInternet = System.getProperty(TALEND_DISABLE_INTERNET);
|
||||
if ("true".equals(disableInternet)) { //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
URL url = new URL(HTTP_NETWORK_URL);
|
||||
URL url = new URL("https://www.talend.com"); //$NON-NLS-1$
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setConnectTimeout(4000);
|
||||
conn.setReadTimeout(4000);
|
||||
|
||||
@@ -13,211 +13,37 @@
|
||||
package org.talend.commons.utils.network;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.PasswordAuthentication;
|
||||
import java.net.Proxy;
|
||||
import java.net.ProxySelector;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Priority;
|
||||
import org.eclipse.core.internal.net.ProxyManager;
|
||||
import org.eclipse.core.net.proxy.IProxyService;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.i18n.internal.Messages;
|
||||
import org.talend.daikon.sandbox.properties.ClassLoaderIsolatedSystemProperties;
|
||||
|
||||
import sun.net.spi.DefaultProxySelector;
|
||||
|
||||
/**
|
||||
* DOC cmeng class global comment. Detailled comment
|
||||
*/
|
||||
public class TalendProxySelector extends ProxySelector {
|
||||
|
||||
public static final String PROP_PRINT_LOGS = "talend.studio.proxy.printLogs";
|
||||
|
||||
private static final String ECLIPSE_PROXY_SELECTOR = ".EclipseProxySelector"; //$NON-NLS-1$
|
||||
|
||||
private static final String PROP_ALLOW_PROXY_REDIRECT = "talend.studio.proxy.allowProxyRedirect";
|
||||
private ProxySelector defaultSelector;
|
||||
|
||||
private static final String PROP_ALLOW_PROXY_REDIRECT_EXCLUDE = "talend.studio.proxy.redirect.whiteList";
|
||||
|
||||
private static final String PROP_EXECUTE_CONNECTION_FAILED = "talend.studio.proxy.executeConnectionFailed";
|
||||
|
||||
private static final String PROP_UPDATE_SYSTEM_PROPERTIES_FOR_JRE = "talend.studio.proxy.jre.updateSystemProperties";
|
||||
|
||||
private static final String PROP_CHECK_PROXY = "talend.studio.proxy.checkProxy";
|
||||
|
||||
private static final String PROP_VALIDATE_URI = "talend.studio.proxy.validateUri";
|
||||
|
||||
private static final String PROP_PROXY_SELECTOR = "talend.studio.proxy.selector";
|
||||
|
||||
private static final String PROP_PROXY_SELECTOR_DEFAULT = "default";
|
||||
|
||||
private static final String PROP_PROXY_SELECTOR_JRE = "jre";
|
||||
|
||||
private static final String PROP_PROXY_HOST_MAP = "talend.studio.proxy.hostMap";
|
||||
|
||||
private static final String PROP_DISABLE_DEFAULT_SELECTOR_PROVIDER = "talend.studio.proxy.disableDefaultSelectorProvider";
|
||||
|
||||
/**
|
||||
* Example: update.talend.com,socket:http,https:http;nexus.talend.com,socket,http;,socket:http
|
||||
*/
|
||||
private static final String PROP_PROXY_MAP_HOST_DEFAULT = "";
|
||||
|
||||
/**
|
||||
* Example: svn.company.com;nexus.company.com
|
||||
*/
|
||||
private static final String PROP_ALLOW_PROXY_REDIRECT_EXCLUDE_DEFAULT = "";
|
||||
|
||||
private static final String KEY_DEFAULT = ":default:";
|
||||
|
||||
private static Field uriHostField;
|
||||
|
||||
private static Method proxyManagerUpdateSystemPropertiesFunc;
|
||||
|
||||
private static boolean checkProxy = Boolean.valueOf(System.getProperty(PROP_CHECK_PROXY, Boolean.TRUE.toString()));
|
||||
|
||||
/**
|
||||
* Note: eclipse default selector may be different between TOS and TIS, TOS may use jre one, TIS may use egit one
|
||||
*/
|
||||
private ProxySelector eclipseDefaultSelector;
|
||||
|
||||
private ProxySelector jreDefaultSelector;
|
||||
|
||||
private EProxySelector eProxySelector;
|
||||
|
||||
final private Map<Object, Collection<IProxySelectorProvider>> selectorProviders;
|
||||
|
||||
private Map<String, Map<String, String>> hostMap;
|
||||
|
||||
private Set<String> redirectWhiteList;
|
||||
final private List<IProxySelectorProvider> selectorProviders;
|
||||
|
||||
private volatile static TalendProxySelector instance;
|
||||
|
||||
private static Object instanceLock = new Object();
|
||||
|
||||
private boolean printProxyLog = false;
|
||||
|
||||
private boolean allowProxyRedirect = false;
|
||||
|
||||
private boolean disableDefaultSelectorProvider = false;
|
||||
|
||||
private boolean validateUri = true;
|
||||
|
||||
private boolean executeConnectionFailed = true;
|
||||
|
||||
private boolean updateSystemPropertiesForJre = true;
|
||||
|
||||
private TalendProxySelector(final ProxySelector eclipseDefaultSelector) {
|
||||
this.eclipseDefaultSelector = eclipseDefaultSelector;
|
||||
this.jreDefaultSelector = new DefaultProxySelector();
|
||||
|
||||
selectorProviders = Collections.synchronizedMap(new HashMap<>());
|
||||
allowProxyRedirect = Boolean.valueOf(System.getProperty(PROP_ALLOW_PROXY_REDIRECT, Boolean.FALSE.toString()));
|
||||
disableDefaultSelectorProvider = Boolean
|
||||
.valueOf(System.getProperty(PROP_DISABLE_DEFAULT_SELECTOR_PROVIDER, Boolean.FALSE.toString()));
|
||||
printProxyLog = Boolean.valueOf(System.getProperty(PROP_PRINT_LOGS, Boolean.FALSE.toString()));
|
||||
validateUri = Boolean.valueOf(System.getProperty(PROP_VALIDATE_URI, Boolean.TRUE.toString()));
|
||||
executeConnectionFailed = Boolean.valueOf(System.getProperty(PROP_EXECUTE_CONNECTION_FAILED, Boolean.TRUE.toString()));
|
||||
updateSystemPropertiesForJre = Boolean
|
||||
.valueOf(System.getProperty(PROP_UPDATE_SYSTEM_PROPERTIES_FOR_JRE, Boolean.TRUE.toString()));
|
||||
|
||||
switch (System.getProperty(PROP_PROXY_SELECTOR, PROP_PROXY_SELECTOR_DEFAULT).toLowerCase()) {
|
||||
case PROP_PROXY_SELECTOR_JRE:
|
||||
this.eProxySelector = EProxySelector.jre;
|
||||
break;
|
||||
default:
|
||||
this.eProxySelector = EProxySelector.eclipse_default;
|
||||
break;
|
||||
}
|
||||
|
||||
initHostMap();
|
||||
initRedirectList();
|
||||
}
|
||||
|
||||
private void initHostMap() {
|
||||
try {
|
||||
hostMap = new HashMap<>();
|
||||
String property = System.getProperty(PROP_PROXY_HOST_MAP, PROP_PROXY_MAP_HOST_DEFAULT);
|
||||
if (StringUtils.isEmpty(property)) {
|
||||
return;
|
||||
}
|
||||
String[] splits = property.split(";");
|
||||
for (String split : splits) {
|
||||
try {
|
||||
int index = split.indexOf(',');
|
||||
String uri = split.substring(0, index);
|
||||
String key = StringUtils.strip(uri);
|
||||
if (StringUtils.isBlank(key)) {
|
||||
key = KEY_DEFAULT;
|
||||
}
|
||||
key = key.toLowerCase();
|
||||
Map<String, String> protocolMap = hostMap.get(key);
|
||||
if (protocolMap == null) {
|
||||
protocolMap = new HashMap<>();
|
||||
hostMap.put(key, protocolMap);
|
||||
}
|
||||
int protocolMapIndex = index + 1;
|
||||
String protocolMapStr = split.substring(protocolMapIndex);
|
||||
String[] entry = protocolMapStr.split(",");
|
||||
for (String pMap : entry) {
|
||||
try {
|
||||
String[] mapEntry = pMap.split(":");
|
||||
if (mapEntry.length != 2) {
|
||||
ExceptionHandler.process(
|
||||
new Exception(Messages.getString("TalendProxySelector.exception.badUriMap", pMap)));
|
||||
continue;
|
||||
}
|
||||
protocolMap.put(mapEntry[0].toLowerCase(), mapEntry[1].toLowerCase());
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void initRedirectList() {
|
||||
try {
|
||||
redirectWhiteList = new HashSet<>();
|
||||
String property = System.getProperty(PROP_ALLOW_PROXY_REDIRECT_EXCLUDE, PROP_ALLOW_PROXY_REDIRECT_EXCLUDE_DEFAULT);
|
||||
if (StringUtils.isEmpty(property)) {
|
||||
return;
|
||||
}
|
||||
String[] split = property.split(";");
|
||||
for (String host : split) {
|
||||
host = StringUtils.strip(host);
|
||||
if (StringUtils.isBlank(host)) {
|
||||
host = KEY_DEFAULT;
|
||||
}
|
||||
redirectWhiteList.add(host);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
private TalendProxySelector(final ProxySelector defaultSelector) {
|
||||
this.defaultSelector = defaultSelector;
|
||||
selectorProviders = new ArrayList<>();
|
||||
}
|
||||
|
||||
public static TalendProxySelector getInstance() {
|
||||
@@ -232,18 +58,6 @@ public class TalendProxySelector extends ProxySelector {
|
||||
synchronized (instanceLock) {
|
||||
if (instance == null) {
|
||||
instance = new TalendProxySelector(proxySelector);
|
||||
try {
|
||||
uriHostField = URI.class.getDeclaredField("host");
|
||||
uriHostField.setAccessible(true);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
try {
|
||||
proxyManagerUpdateSystemPropertiesFunc = ProxyManager.class.getDeclaredMethod("updateSystemProperties");
|
||||
proxyManagerUpdateSystemPropertiesFunc.setAccessible(true);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,216 +70,19 @@ public class TalendProxySelector extends ProxySelector {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
if (instance.getEclipseDefaultSelector() == null
|
||||
if (instance.getDefaultProxySelector() == null
|
||||
|| (proxySelector != null && proxySelector.getClass().getName().endsWith(ECLIPSE_PROXY_SELECTOR))) {
|
||||
instance.setEclipseDefaultSelector(proxySelector);
|
||||
instance.setDefaultProxySelector(proxySelector);
|
||||
}
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static void checkProxy() {
|
||||
if (!checkProxy) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
TalendProxySelector.getInstance();
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Proxy> select(final URI uri) {
|
||||
if (printProxyLog) {
|
||||
ExceptionHandler.log("TalendProxySelector.select " + uri);
|
||||
}
|
||||
if (uri == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
URI validatedUri = validateUri(uri);
|
||||
Set<Proxy> results = new LinkedHashSet<>();
|
||||
|
||||
try {
|
||||
final Set<Proxy> resultFromProviders = getProxysFromProviders(validatedUri);
|
||||
if (resultFromProviders != null && !resultFromProviders.isEmpty()) {
|
||||
results.addAll(resultFromProviders);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
if (printProxyLog) {
|
||||
ExceptionHandler.log("TalendProxySelector.resultFromProviders " + results);
|
||||
}
|
||||
|
||||
ProxySelector defaultProxySelector = getDefaultProxySelector();
|
||||
if (printProxyLog) {
|
||||
ExceptionHandler.log("TalendProxySelector.defaultProxySelector " + defaultProxySelector);
|
||||
}
|
||||
if (defaultProxySelector != null) {
|
||||
/**
|
||||
* don't validate uri here, so that we can know whether it is an issue uri
|
||||
*/
|
||||
URI newUri = getNewUri(validatedUri, false);
|
||||
List<Proxy> defaultProxys = null;
|
||||
if (validateUri && StringUtils.isBlank(newUri.getHost())) {
|
||||
/**
|
||||
* If host is blank, force to use jre proxy selector to avoid the eclipse proxy selector bug
|
||||
*/
|
||||
defaultProxys = getJreProxySelector().select(newUri);
|
||||
} else {
|
||||
defaultProxys = defaultProxySelector.select(newUri);
|
||||
}
|
||||
if (printProxyLog) {
|
||||
ExceptionHandler.log("TalendProxySelector.defaultProxys " + defaultProxys);
|
||||
}
|
||||
try {
|
||||
results.addAll(filterProxys(validatedUri, defaultProxys));
|
||||
} catch (Exception e) {
|
||||
results.addAll(defaultProxys);
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
if (printProxyLog) {
|
||||
String proxys = results.toString();
|
||||
ExceptionHandler.log("Selected proxys for " + uri + ", " + proxys);
|
||||
ExceptionHandler.process(new Exception("Proxy call stacks"), Priority.INFO);
|
||||
}
|
||||
return new LinkedList<Proxy>(results);
|
||||
}
|
||||
|
||||
private URI validateUri(URI uri) {
|
||||
if (!validateUri) {
|
||||
return uri;
|
||||
}
|
||||
|
||||
URI validatedUri = null;
|
||||
try {
|
||||
/**
|
||||
* DON'T use URI.create(), MUST use the conductor which requires authority
|
||||
*/
|
||||
validatedUri = new URI(uri.getScheme(), uri.getAuthority(), uri.getPath(), uri.getQuery(), uri.getFragment());
|
||||
|
||||
/**
|
||||
* Validate the host, if the host is empty, it will cause the eclipse selector to return dirrect
|
||||
*/
|
||||
if (StringUtils.isBlank(validatedUri.getHost())) {
|
||||
String authority = validatedUri.getAuthority();
|
||||
if (StringUtils.isNotBlank(authority)) {
|
||||
// example: https://u:p@www.company.com:8081/path/a?param=b
|
||||
String host = null;
|
||||
int userInfoIndex = authority.indexOf('@');
|
||||
if (0 <= userInfoIndex) {
|
||||
authority = authority.substring(userInfoIndex + 1);
|
||||
}
|
||||
int portIndex = authority.lastIndexOf(':');
|
||||
if (0 <= portIndex) {
|
||||
host = authority.substring(0, portIndex);
|
||||
}
|
||||
try {
|
||||
uriHostField.set(validatedUri, host);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
if (validatedUri == null) {
|
||||
validatedUri = uri;
|
||||
}
|
||||
}
|
||||
if (printProxyLog) {
|
||||
ExceptionHandler.log("After validate: " + uri + " -> " + validatedUri);
|
||||
}
|
||||
return validatedUri;
|
||||
}
|
||||
|
||||
private List<Proxy> filterProxys(final URI uri, List<Proxy> defaultProxys) {
|
||||
List<Proxy> result = new ArrayList<>();
|
||||
if (defaultProxys != null && !defaultProxys.isEmpty()) {
|
||||
for (Proxy proxy : defaultProxys) {
|
||||
SocketAddress addr = null;
|
||||
Proxy.Type proxyType = null;
|
||||
if (proxy != null) {
|
||||
proxyType = proxy.type();
|
||||
addr = proxy.address();
|
||||
}
|
||||
|
||||
boolean redirect = true;
|
||||
if (!allowProxyRedirect) {
|
||||
String host = uri.getHost();
|
||||
if (host == null) {
|
||||
host = "";
|
||||
}
|
||||
host = StringUtils.strip(host).toLowerCase();
|
||||
if (this.redirectWhiteList.contains(host) || this.redirectWhiteList.contains(KEY_DEFAULT)) {
|
||||
redirect = true;
|
||||
} else if (Proxy.Type.DIRECT == proxyType
|
||||
|| (addr != null && StringUtils.equals(uri.getHost(), ((InetSocketAddress) addr).getHostString()))) {
|
||||
redirect = false;
|
||||
}
|
||||
}
|
||||
if (redirect) {
|
||||
result.add(proxy);
|
||||
} else {
|
||||
result.add(Proxy.NO_PROXY);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private URI getNewUri(URI uri, boolean validateUri) {
|
||||
URI newUri = uri;
|
||||
if (newUri != null) {
|
||||
try {
|
||||
// get host before new URI, because the host may be set manually due to URI issue
|
||||
String host = newUri.getHost();
|
||||
newUri = new URI(newUri.getScheme(), newUri.getAuthority(), newUri.getPath(), newUri.getQuery(),
|
||||
newUri.getFragment());
|
||||
Map<String, String> protocolMap = null;
|
||||
if (StringUtils.isNotBlank(host)) {
|
||||
protocolMap = hostMap.get(host.toLowerCase());
|
||||
}
|
||||
if (protocolMap == null) {
|
||||
protocolMap = hostMap.get(KEY_DEFAULT);
|
||||
}
|
||||
|
||||
if (protocolMap != null) {
|
||||
String schema = newUri.getScheme();
|
||||
if (schema != null) {
|
||||
String lowercasedProtocol = schema.toLowerCase();
|
||||
String preferedProtocol = protocolMap.get(lowercasedProtocol);
|
||||
if (StringUtils.isNotBlank(preferedProtocol)) {
|
||||
/**
|
||||
* Note: MUST use the constructor which requires authority, because some uri may be illegal,
|
||||
* then host info will be stored in authority field instead of host filed
|
||||
*/
|
||||
newUri = new URI(preferedProtocol, newUri.getAuthority(), newUri.getPath(), newUri.getQuery(),
|
||||
newUri.getFragment());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
if (printProxyLog) {
|
||||
ExceptionHandler.process(
|
||||
new Exception(Messages.getString("TalendProxySelector.exception.proxySelectionError", uri), e),
|
||||
Priority.WARN);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (validateUri) {
|
||||
newUri = validateUri(newUri);
|
||||
}
|
||||
return newUri;
|
||||
}
|
||||
|
||||
private Set<Proxy> getProxysFromProviders(final URI uri) {
|
||||
final Set<Proxy> resultFromProviders = new LinkedHashSet<>();
|
||||
Collection<IProxySelectorProvider> providers = getCustomProviders(uri);
|
||||
final Set<Proxy> resultFromProviders = new HashSet<>();
|
||||
List<IProxySelectorProvider> providers = getProxySelectorProviders();
|
||||
if (providers != null) {
|
||||
providers.stream().forEach(p -> {
|
||||
if (instance == p) {
|
||||
@@ -483,126 +100,49 @@ public class TalendProxySelector extends ProxySelector {
|
||||
}
|
||||
});
|
||||
}
|
||||
return resultFromProviders;
|
||||
}
|
||||
List<Proxy> result = new ArrayList<>();
|
||||
|
||||
private Collection<IProxySelectorProvider> getCustomProviders(final URI uri) {
|
||||
Collection<IProxySelectorProvider> providers = Collections.EMPTY_LIST;
|
||||
Collection<Object> possibleKeys = getPossibleKeys(uri);
|
||||
for (Object key : possibleKeys) {
|
||||
providers = this.selectorProviders.get(key);
|
||||
if (providers != null) {
|
||||
break;
|
||||
if (resultFromProviders != null && !resultFromProviders.isEmpty()) {
|
||||
result.addAll(resultFromProviders);
|
||||
}
|
||||
|
||||
ProxySelector defaultProxySelector = getDefaultProxySelector();
|
||||
if (defaultProxySelector != null) {
|
||||
List<Proxy> defaultProxys = defaultProxySelector.select(uri);
|
||||
if (defaultProxys != null && !defaultProxys.isEmpty()) {
|
||||
result.addAll(defaultProxys);
|
||||
}
|
||||
}
|
||||
return providers;
|
||||
}
|
||||
|
||||
public PasswordAuthentication getHttpPasswordAuthentication() {
|
||||
String[] schemas = new String[] { "http", "https" };
|
||||
for (String schema : schemas) {
|
||||
String proxyUser = System.getProperty(schema + ".proxyUser");
|
||||
String proxyPassword = System.getProperty(schema + ".proxyPassword");
|
||||
|
||||
if (StringUtils.isNotBlank(proxyUser)) {
|
||||
char[] pwdChars = new char[0];
|
||||
if (proxyPassword != null && !proxyPassword.isEmpty()) {
|
||||
pwdChars = proxyPassword.toCharArray();
|
||||
}
|
||||
return new PasswordAuthentication(proxyUser, pwdChars);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean addProxySelectorProvider(IProxySelectorProvider provider) {
|
||||
try {
|
||||
Object key = provider.getKey();
|
||||
Collection<IProxySelectorProvider> collection = this.selectorProviders.get(key);
|
||||
if (collection == null) {
|
||||
synchronized (this.selectorProviders) {
|
||||
collection = this.selectorProviders.get(key);
|
||||
if (collection == null) {
|
||||
collection = Collections.synchronizedList(new LinkedList<>());
|
||||
this.selectorProviders.put(key, collection);
|
||||
}
|
||||
}
|
||||
}
|
||||
collection.add(provider);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
List<IProxySelectorProvider> proxySelectorProviders = getProxySelectorProviders();
|
||||
if (!proxySelectorProviders.contains(provider)) {
|
||||
return proxySelectorProviders.add(provider);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removeProxySelectorProvider(IProxySelectorProvider provider) {
|
||||
try {
|
||||
Object key = provider.getKey();
|
||||
Collection<IProxySelectorProvider> collection = this.selectorProviders.get(key);
|
||||
if (collection != null) {
|
||||
synchronized (this.selectorProviders) {
|
||||
collection = this.selectorProviders.get(key);
|
||||
if (collection != null) {
|
||||
collection.remove(provider);
|
||||
if (collection.isEmpty()) {
|
||||
this.selectorProviders.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
return false;
|
||||
return getProxySelectorProviders().remove(provider);
|
||||
}
|
||||
|
||||
private List<IProxySelectorProvider> getProxySelectorProviders() {
|
||||
return selectorProviders;
|
||||
}
|
||||
|
||||
public ProxySelector getDefaultProxySelector() {
|
||||
switch (eProxySelector) {
|
||||
case jre:
|
||||
return getJreProxySelector();
|
||||
default:
|
||||
return eclipseDefaultSelector;
|
||||
}
|
||||
return defaultSelector;
|
||||
}
|
||||
|
||||
private ProxySelector getJreProxySelector() {
|
||||
try {
|
||||
/**
|
||||
* for tcompv0, daikon may create an isolated system properties for it, so proxies may be ignored in the new
|
||||
* system properties; here we try to call the method to add proxies into the isolated system properties
|
||||
*/
|
||||
if (updateSystemPropertiesForJre && ClassLoaderIsolatedSystemProperties.getInstance()
|
||||
.isIsolated(Thread.currentThread().getContextClassLoader())) {
|
||||
if (printProxyLog) {
|
||||
ExceptionHandler.log("Before update jre proxy system properties for the isolated classloader, http.proxyHost="
|
||||
+ System.getProperty("http.proxyHost"));
|
||||
}
|
||||
IProxyService proxyService = CommonsPlugin.getProxyService();
|
||||
proxyManagerUpdateSystemPropertiesFunc.invoke(proxyService);
|
||||
if (printProxyLog) {
|
||||
ExceptionHandler.log("After updated jre proxy system properties for the isolated classloader, http.proxyHost="
|
||||
+ System.getProperty("http.proxyHost"));
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
return this.jreDefaultSelector;
|
||||
}
|
||||
|
||||
public ProxySelector getEclipseDefaultSelector() {
|
||||
return eclipseDefaultSelector;
|
||||
}
|
||||
|
||||
public void setEclipseDefaultSelector(ProxySelector eclipseDefaultSelector) {
|
||||
this.eclipseDefaultSelector = eclipseDefaultSelector;
|
||||
public void setDefaultProxySelector(final ProxySelector selector) {
|
||||
defaultSelector = selector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectFailed(final URI uri, final SocketAddress sa, final IOException ioe) {
|
||||
Collection<IProxySelectorProvider> providers = getCustomProviders(uri);
|
||||
List<IProxySelectorProvider> providers = getProxySelectorProviders();
|
||||
if (providers != null) {
|
||||
providers.stream().forEach(p -> {
|
||||
if (p.canHandle(uri)) {
|
||||
@@ -611,35 +151,23 @@ public class TalendProxySelector extends ProxySelector {
|
||||
});
|
||||
}
|
||||
|
||||
if (executeConnectionFailed) {
|
||||
/**
|
||||
* Just try to make the behavior of jre proxy selector same like eclipse proxy selector
|
||||
*/
|
||||
ProxySelector defaultProxySelector = getDefaultProxySelector();
|
||||
if (defaultProxySelector != null) {
|
||||
defaultProxySelector.connectFailed(uri, sa, ioe);
|
||||
}
|
||||
ProxySelector defaultProxySelector = getDefaultProxySelector();
|
||||
if (defaultProxySelector != null) {
|
||||
defaultProxySelector.connectFailed(uri, sa, ioe);
|
||||
}
|
||||
}
|
||||
|
||||
public IProxySelectorProvider createDefaultProxySelectorProvider() {
|
||||
if (disableDefaultSelectorProvider) {
|
||||
return null;
|
||||
}
|
||||
return new DefaultProxySelectorProvider(Thread.currentThread());
|
||||
}
|
||||
public static abstract class AbstractProxySelectorProvider implements IProxySelectorProvider {
|
||||
|
||||
public IProxySelectorProvider createDefaultProxySelectorProvider(String host) {
|
||||
if (disableDefaultSelectorProvider) {
|
||||
return null;
|
||||
@Override
|
||||
public void connectFailed(final URI uri, final SocketAddress sa, final IOException ioe) {
|
||||
// nothing to do
|
||||
}
|
||||
return new DefaultProxySelectorProvider(host);
|
||||
|
||||
}
|
||||
|
||||
public static interface IProxySelectorProvider {
|
||||
|
||||
Object getKey();
|
||||
|
||||
boolean canHandle(final URI uri);
|
||||
|
||||
List<Proxy> select(final URI uri);
|
||||
@@ -648,120 +176,4 @@ public class TalendProxySelector extends ProxySelector {
|
||||
|
||||
}
|
||||
|
||||
public static abstract class AbstractProxySelectorProvider implements IProxySelectorProvider {
|
||||
|
||||
private boolean isDebugMode = CommonsPlugin.isDebugMode();
|
||||
|
||||
@Override
|
||||
public Object getKey() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectFailed(final URI uri, final SocketAddress sa, final IOException ioe) {
|
||||
if (isDebugMode) {
|
||||
ExceptionHandler.process(ioe);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Collection<Object> getPossibleKeys(URI uri) {
|
||||
Collection<Object> possibleKeys = new ArrayList<>();
|
||||
possibleKeys.add(Thread.currentThread());
|
||||
if (uri != null) {
|
||||
String uriHost = uri.getHost();
|
||||
if (StringUtils.isNotBlank(uriHost)) {
|
||||
possibleKeys.add(uriHost);
|
||||
}
|
||||
}
|
||||
return possibleKeys;
|
||||
}
|
||||
|
||||
private enum EProxySelector {
|
||||
eclipse_default,
|
||||
jre
|
||||
}
|
||||
|
||||
private class DefaultProxySelectorProvider extends TalendProxySelector.AbstractProxySelectorProvider {
|
||||
|
||||
private Thread currentThread = null;
|
||||
|
||||
private String host = null;
|
||||
|
||||
public DefaultProxySelectorProvider(Thread thread) {
|
||||
this.currentThread = thread;
|
||||
}
|
||||
|
||||
public DefaultProxySelectorProvider(String host) {
|
||||
this.host = host;
|
||||
if (StringUtils.isNotBlank(this.host)) {
|
||||
this.host = this.host.toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKey() {
|
||||
if (this.currentThread != null) {
|
||||
return currentThread;
|
||||
}
|
||||
if (this.host != null) {
|
||||
return this.host;
|
||||
}
|
||||
return super.getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(URI uri) {
|
||||
if (disableDefaultSelectorProvider) {
|
||||
return false;
|
||||
}
|
||||
if (currentThread != null && Thread.currentThread() == currentThread) {
|
||||
return true;
|
||||
}
|
||||
if (host != null) {
|
||||
if (uri == null) {
|
||||
return false;
|
||||
}
|
||||
String uriHost = uri.getHost();
|
||||
if (StringUtils.isNotBlank(uriHost)) {
|
||||
return this.host.equals(uriHost.toLowerCase());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Proxy> select(URI uri) {
|
||||
List<Proxy> result = new ArrayList<>();
|
||||
try {
|
||||
ProxySelector defaultProxySelector = getDefaultProxySelector();
|
||||
if (defaultProxySelector != null) {
|
||||
List<Proxy> defaultProxys = defaultProxySelector.select(uri);
|
||||
if (defaultProxys != null && !defaultProxys.isEmpty()) {
|
||||
for (Proxy proxy : defaultProxys) {
|
||||
SocketAddress addr = null;
|
||||
Proxy.Type proxyType = null;
|
||||
if (proxy != null) {
|
||||
proxyType = proxy.type();
|
||||
addr = proxy.address();
|
||||
}
|
||||
if (Proxy.Type.DIRECT == proxyType || (addr != null
|
||||
&& StringUtils.equals(uri.getHost(), ((InetSocketAddress) addr).getHostString()))) {
|
||||
result.add(Proxy.NO_PROXY);
|
||||
} else {
|
||||
result.add(proxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ import org.eclipse.swt.widgets.TreeItem;
|
||||
import org.talend.commons.ui.runtime.i18n.Messages;
|
||||
import org.talend.commons.ui.runtime.utils.TableUtils;
|
||||
import org.talend.commons.ui.runtime.ws.WindowSystem;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.AbstractDataTableEditorView;
|
||||
import org.talend.commons.ui.swt.drawing.background.IBackgroundRefresher;
|
||||
import org.talend.commons.ui.swt.drawing.background.IBgDrawableComposite;
|
||||
import org.talend.commons.ui.swt.drawing.link.BezierHorizontalLink;
|
||||
@@ -465,19 +464,4 @@ public class TreeToTablesLinker<D1, D2> extends BgDrawableComposite implements I
|
||||
}
|
||||
}
|
||||
|
||||
protected <B> void loadItemDataForLazyLoad(AbstractDataTableEditorView<B> tableEditorView) {
|
||||
if (!tableEditorView.getTableViewerCreator().isLazyLoad()) {
|
||||
return;
|
||||
}
|
||||
List<B> beansList = tableEditorView.getExtendedTableModel().getBeansList();
|
||||
Table table = tableEditorView.getTable();
|
||||
for (TableItem tableItem : table.getItems()) {
|
||||
if (tableItem.getData() == null) {
|
||||
int index = table.indexOf(tableItem);
|
||||
B schemaTarget = beansList.get(index);
|
||||
tableItem.setData(schemaTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,8 +29,6 @@ public interface FileConstants {
|
||||
|
||||
String RELATIONSHIP_FILE_NAME = "relationship.index"; //$NON-NLS-1$
|
||||
|
||||
String COMPONENT_FILE_NAME = "component.index"; //$NON-NLS-1$
|
||||
|
||||
String TALEND_RECYCLE_BIN_INDEX = "recycle_bin.index"; //$NON-NLS-1$
|
||||
|
||||
String MIGRATION_TASK_FILE_NAME = "migration_task.index"; //$NON-NLS-1$
|
||||
|
||||
@@ -71,7 +71,6 @@ import org.talend.commons.ui.runtime.CommonUIPlugin;
|
||||
import org.talend.commons.ui.runtime.exception.MessageBoxExceptionHandler;
|
||||
import org.talend.commons.utils.data.container.RootContainer;
|
||||
import org.talend.commons.utils.generation.JavaUtils;
|
||||
import org.talend.commons.utils.network.TalendProxySelector;
|
||||
import org.talend.commons.utils.time.TimeMeasure;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.AbstractDQModelService;
|
||||
@@ -1897,11 +1896,6 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
|
||||
TimeMeasure.begin("logOnProject"); //$NON-NLS-1$
|
||||
try {
|
||||
/**
|
||||
* init/check proxy selector, in case default proxy selector is not registed yet
|
||||
*/
|
||||
TalendProxySelector.checkProxy();
|
||||
|
||||
System.getProperties().put("ReadOnlyUser", Boolean.FALSE.toString()); //$NON-NLS-1$
|
||||
|
||||
// remove the auto-build to enhance the build speed and application's use
|
||||
@@ -2100,7 +2094,7 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
*/
|
||||
try {
|
||||
ITaCoKitService tacokitService = ITaCoKitService.getInstance();
|
||||
if (tacokitService != null && tacokitService.isNeedMigration(project.getTechnicalLabel())) {
|
||||
if (tacokitService != null) {
|
||||
tacokitService.checkMigration(monitor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -2273,14 +2267,9 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void executeRepositoryWorkUnit(RepositoryWorkUnit workUnit) {
|
||||
checkProxySettings();
|
||||
this.repositoryFactoryFromProvider.executeRepositoryWorkUnit(workUnit);
|
||||
}
|
||||
|
||||
private void checkProxySettings() {
|
||||
TalendProxySelector.checkProxy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unloadResources(Property property) throws PersistenceException {
|
||||
repositoryFactoryFromProvider.unloadResources(property);
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2018 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.core.repository.utils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* DOC jding class global comment. Detailled comment
|
||||
*/
|
||||
public class ComponentsJsonModel {
|
||||
|
||||
@JsonProperty("id")
|
||||
private String id;
|
||||
|
||||
@JsonProperty("version")
|
||||
private String version;
|
||||
|
||||
@JsonProperty("parentId")
|
||||
private String parentId;
|
||||
|
||||
@JsonProperty("configurationType")
|
||||
private String configurationType;
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
@JsonProperty("displayName")
|
||||
private String displayName;
|
||||
|
||||
@JsonProperty("edges")
|
||||
private Set edges;
|
||||
|
||||
@JsonProperty("properties")
|
||||
private List properties;
|
||||
|
||||
@JsonProperty("actions")
|
||||
private Object actions;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public String getConfigurationType() {
|
||||
return configurationType;
|
||||
}
|
||||
|
||||
public void setConfigurationType(String configurationType) {
|
||||
this.configurationType = configurationType;
|
||||
}
|
||||
|
||||
public Set getEdges() {
|
||||
return edges;
|
||||
}
|
||||
|
||||
public void setEdges(Set edges) {
|
||||
this.edges = edges;
|
||||
}
|
||||
|
||||
public List getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(List properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public Object getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
public void setActions(Object actions) {
|
||||
this.actions = actions;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,14 +18,8 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
@@ -79,12 +73,6 @@ public class ProjectDataJsonProvider {
|
||||
return strBuilder.toString();
|
||||
}
|
||||
|
||||
public static String getMigrationTaskIndexPath() {
|
||||
StringBuilder strBuilder = new StringBuilder();
|
||||
strBuilder.append(FileConstants.SETTINGS_FOLDER_NAME).append("/").append(FileConstants.MIGRATION_TASK_FILE_NAME); //$NON-NLS-1$
|
||||
return strBuilder.toString();
|
||||
}
|
||||
|
||||
public static void saveProjectData(Project project) throws PersistenceException {
|
||||
saveProjectData(project, CONTENT_ALL);
|
||||
}
|
||||
@@ -110,54 +98,6 @@ public class ProjectDataJsonProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveConfigComponent(String projectLabel, List<ComponentsJsonModel> componentJsons)
|
||||
throws PersistenceException {
|
||||
Collections.sort(componentJsons, new Comparator<ComponentsJsonModel>() {
|
||||
|
||||
@Override
|
||||
public int compare(ComponentsJsonModel configTypeNode1, ComponentsJsonModel configTypeNode2) {
|
||||
return configTypeNode1.getId().compareTo(configTypeNode2.getId());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
File file = getSavingConfigurationFile(projectLabel, FileConstants.COMPONENT_FILE_NAME);
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.writerWithDefaultPrettyPrinter().writeValue(file, componentJsons);
|
||||
ResourceUtils.getProject(projectLabel).getFolder(FileConstants.SETTINGS_FOLDER_NAME).refreshLocal(1, null);
|
||||
} catch (Exception e) {
|
||||
throw new PersistenceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, String[]> getLastConfigComponent(String projectLabel) throws PersistenceException {
|
||||
Map<String, String[]> componentMap = new HashMap<>();
|
||||
File file = getSavingConfigurationFile(projectLabel, FileConstants.COMPONENT_FILE_NAME);
|
||||
TypeReference<List<ComponentsJsonModel>> typeReference = new TypeReference<List<ComponentsJsonModel>>() {
|
||||
};
|
||||
List<ComponentsJsonModel> componentsJsons = null;
|
||||
if (file != null && file.exists()) {
|
||||
try {
|
||||
FileInputStream input = new FileInputStream(file);
|
||||
componentsJsons = new ObjectMapper().readValue(input, typeReference);
|
||||
} catch (IOException e) {
|
||||
throw new PersistenceException(e);
|
||||
}
|
||||
if (componentsJsons != null && componentsJsons.size() > 0) {
|
||||
for (ComponentsJsonModel component : componentsJsons) {
|
||||
String[] content = new String[] { component.getName(), component.getVersion(), component.getDisplayName() };
|
||||
componentMap.put(component.getId(), content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return componentMap;
|
||||
}
|
||||
|
||||
public static void loadProjectData(Project project, IPath projectFolderPath, int loadContent) throws PersistenceException {
|
||||
if ((loadContent & CONTENT_PROJECTSETTING) > 0) {
|
||||
loadProjectSettings(project, projectFolderPath);
|
||||
@@ -281,37 +221,20 @@ public class ProjectDataJsonProvider {
|
||||
|
||||
public static void loadMigrationTaskSetting(Project project, InputStream input) throws PersistenceException {
|
||||
try {
|
||||
project.eSetDeliver(false);
|
||||
MigrationTaskSetting migrationTaskSetting = null;
|
||||
if (input != null) {
|
||||
migrationTaskSetting = new ObjectMapper().readValue(input, MigrationTaskSetting.class);
|
||||
}
|
||||
if (migrationTaskSetting != null) {
|
||||
MigrationTask fakeTask = createFakeMigrationTask();
|
||||
MigrationTask existingFakeTask = null;
|
||||
List<MigrationTask> allRealTask = new ArrayList<MigrationTask>();
|
||||
for (int i = 0; i < project.getMigrationTask().size(); i++) {
|
||||
MigrationTask task = (MigrationTask) project.getMigrationTask().get(i);
|
||||
if (StringUtils.equals(fakeTask.getId(), task.getId())) {
|
||||
existingFakeTask = task;
|
||||
break;
|
||||
if (!StringUtils.equals(fakeTask.getId(), task.getId())) {
|
||||
allRealTask.add(task);
|
||||
}
|
||||
}
|
||||
// remove all the migrations from the project
|
||||
project.getMigrationTask().clear();
|
||||
if (existingFakeTask != null) {
|
||||
// keep only the fake migration task of 7.1.1 with new migration index
|
||||
// re-use the same instance to make sure we keep the same emf id.
|
||||
project.getMigrationTask().add(existingFakeTask);
|
||||
}
|
||||
Set<String> tasksIds = new HashSet<>();
|
||||
Iterator<MigrationTaskJson> it = migrationTaskSetting.getMigrationTaskList().iterator();
|
||||
while (it.hasNext()) { // remove duplicates to fix issues found in TUP-22735
|
||||
MigrationTaskJson task = it.next();
|
||||
if (tasksIds.contains(task.getId())) {
|
||||
it.remove();
|
||||
}
|
||||
tasksIds.add(task.getId());
|
||||
}
|
||||
project.getMigrationTask().removeAll(allRealTask);
|
||||
project.getMigrationTasks().clear();
|
||||
if (migrationTaskSetting.getMigrationTaskList() != null) {
|
||||
for (MigrationTaskJson json : migrationTaskSetting.getMigrationTaskList()) {
|
||||
@@ -329,7 +252,6 @@ public class ProjectDataJsonProvider {
|
||||
} catch (Exception e) {
|
||||
throw new PersistenceException(e);
|
||||
} finally {
|
||||
project.eSetDeliver(true);
|
||||
closeInputStream(input);
|
||||
}
|
||||
}
|
||||
@@ -1183,4 +1105,4 @@ class MigrationTaskJson {
|
||||
return task;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,22 +131,4 @@ public class ProjectHelper {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* define the different value for the project types the string value in the licence files Matcht the java enum name
|
||||
* this is a copy of org.talend.commons.model.KeyConstants.ProjectType to avoid adding the all library
|
||||
*
|
||||
*/
|
||||
public static enum ProjectType {
|
||||
DI,
|
||||
DQ,
|
||||
MDM;
|
||||
}
|
||||
|
||||
public static int getProjectTypeOrdinal(org.talend.core.model.properties.Project project) {
|
||||
if (project != null && project.getType() != null) {
|
||||
return ProjectType.valueOf(project.getType()).ordinal();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,18 +202,6 @@ public interface ILibraryManagerService extends IService {
|
||||
*/
|
||||
public boolean isJarNeedToBeDeployed(File jarFile);
|
||||
|
||||
public boolean isSameFile(File f1, File f2);
|
||||
|
||||
public void checkModuleStatus(ModuleNeeded module);
|
||||
|
||||
public void guessMavenRUIFromIndex(File jarFile, Map<String, String> sourceAndMavenUri);
|
||||
|
||||
public static ILibraryManagerService get() {
|
||||
GlobalServiceRegister register = GlobalServiceRegister.getDefault();
|
||||
if (register.isServiceRegistered(ILibraryManagerService.class)) {
|
||||
return (ILibraryManagerService) register.getService(ILibraryManagerService.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -162,10 +162,9 @@ public enum EDatabaseVersion4Drivers {
|
||||
|
||||
MAPRDB(new DbVersion4Drivers(EDatabaseTypeName.MAPRDB, new String[] {})),
|
||||
|
||||
REDSHIFT(new DbVersion4Drivers(EDatabaseTypeName.REDSHIFT, "redshift", "REDSHIFT", //$NON-NLS-1$
|
||||
"redshiftJDBC42-no-awssdk-1.2.16.1027.jar")),
|
||||
REDSHIFT(new DbVersion4Drivers(EDatabaseTypeName.REDSHIFT,"redshift","REDSHIFT", "RedshiftJDBC42-no-awssdk-1.2.16.1027.jar")), //$NON-NLS-1$
|
||||
REDSHIFT_SSO(new DbVersion4Drivers(EDatabaseTypeName.REDSHIFT_SSO,"redshift sso","REDSHIFT_SSO",
|
||||
new String[] { "redshiftJDBC42-no-awssdk-1.2.16.1027.jar", "aws-java-sdk-1.11.406.jar", "jackson-core-2.9.5.jar",
|
||||
new String[] { "RedshiftJDBC42-no-awssdk-1.2.16.1027.jar", "aws-java-sdk-1.11.406.jar", "jackson-core-2.9.5.jar",
|
||||
"jackson-databind-2.9.5.jar", "jackson-annotations-2.9.0.jar", "httpcore-4.4.9.jar", "httpclient-4.5.5.jar",
|
||||
"joda-time-2.8.1.jar", "commons-logging-1.1.3.jar" })),
|
||||
|
||||
|
||||
@@ -55,8 +55,6 @@ public interface IComponentsFactory {
|
||||
*/
|
||||
public Set<IComponent> getComponents();
|
||||
|
||||
public boolean isInitialising();
|
||||
|
||||
/**
|
||||
* Get a readonly components collection to avoid ConcurrentModificationException caused by multiple thread
|
||||
* access;<br/>
|
||||
|
||||
@@ -56,7 +56,6 @@ public class ConnectionBean implements Cloneable {
|
||||
|
||||
private static final String TOKEN = "token"; //$NON-NLS-1$
|
||||
|
||||
private static final String URL = "url"; //$NON-NLS-1$
|
||||
/**
|
||||
* DOC smallet ConnectionBean constructor comment.
|
||||
*/
|
||||
@@ -397,15 +396,4 @@ public class ConnectionBean implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
try {
|
||||
if (conDetails.has(URL)) {
|
||||
return conDetails.getString(URL);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -85,13 +85,6 @@ public class ModuleNeeded {
|
||||
|
||||
public static final String UNKNOWN = "Unknown";
|
||||
|
||||
/**
|
||||
* TODO This is a hot fix for 7.2.1 . if the maven url is not specified in component/extension point , we will
|
||||
* generate a release version with this flag=true .Need to improve it after release ,normally the studio should use
|
||||
* all jars with release version by default if maven url is not specified.
|
||||
*/
|
||||
private boolean useReleaseVersion = false;
|
||||
|
||||
ILibraryManagerService libManagerService = (ILibraryManagerService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibraryManagerService.class);
|
||||
|
||||
@@ -200,7 +193,6 @@ public class ModuleNeeded {
|
||||
cloned.required = required;
|
||||
cloned.requiredIf = requiredIf;
|
||||
cloned.status = status;
|
||||
cloned.useReleaseVersion = useReleaseVersion;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
@@ -442,9 +434,9 @@ public class ModuleNeeded {
|
||||
if (this.getModuleLocaion() != null) {
|
||||
hashCode *= this.getModuleLocaion().hashCode();
|
||||
}
|
||||
if(this.getDefaultMavenURI() != null){
|
||||
hashCode *= this.getDefaultMavenURI().hashCode();
|
||||
}
|
||||
|
||||
hashCode *= this.getDefaultMavenURI().hashCode();
|
||||
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
@@ -527,16 +519,8 @@ public class ModuleNeeded {
|
||||
}
|
||||
|
||||
// maven uri
|
||||
if (other.getDefaultMavenURI() == null) {
|
||||
if (this.getDefaultMavenURI() != null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (this.getDefaultMavenURI() == null) {
|
||||
return false;
|
||||
} else if (!other.getDefaultMavenURI().equals(this.getDefaultMavenURI())) {
|
||||
return false;
|
||||
}
|
||||
if (!other.getDefaultMavenURI().equals(this.getDefaultMavenURI())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -586,7 +570,7 @@ public class ModuleNeeded {
|
||||
if (mvnUrisFromIndex != null) {
|
||||
mavenUri = MavenUrlHelper.addTypeForMavenUri(mvnUrisFromIndex, getModuleName());
|
||||
} else {
|
||||
mavenUri = MavenUrlHelper.generateMvnUrlForJarName(getModuleName(), true, !useReleaseVersion);
|
||||
mavenUri = MavenUrlHelper.generateMvnUrlForJarName(getModuleName(), true, true);
|
||||
}
|
||||
} else {
|
||||
mavenUri = mavenUriFromConfiguration;
|
||||
@@ -693,8 +677,4 @@ public class ModuleNeeded {
|
||||
this.excludeDependencies = excludeDependencies;
|
||||
}
|
||||
|
||||
public void setUseReleaseVersion(boolean useReleaseVersion) {
|
||||
this.useReleaseVersion = useReleaseVersion;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,14 +45,6 @@ public interface ISAPConstant {
|
||||
|
||||
public static final String CHANGING = "CHANGING";//$NON-NLS-1$
|
||||
|
||||
public static final String PARAMETER_TYPE = "PARAMETER_TYPE";//$NON-NLS-1$
|
||||
|
||||
public static final String PARAMETER_TYPE_IMPORT = "IMPORT";//$NON-NLS-1$
|
||||
|
||||
public static final String PARAMETER_TYPE_CHANGING = "CHANGING";//$NON-NLS-1$
|
||||
|
||||
public static final String PARAMETER_TYPE_TABLES = "TABLES";//$NON-NLS-1$
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -153,7 +153,7 @@ public class MetadataTable implements IMetadataTable, Cloneable {
|
||||
List<IMetadataColumn> temp = new ArrayList<IMetadataColumn>();
|
||||
temp.addAll(this.listColumns);
|
||||
temp.addAll(this.unusedColumns);
|
||||
if (originalColumns != null && isRepository) {
|
||||
if (isRepository && originalColumns != null) {
|
||||
Collections.sort(temp, new Comparator<IMetadataColumn>() {
|
||||
|
||||
@Override
|
||||
@@ -213,9 +213,8 @@ public class MetadataTable implements IMetadataTable, Cloneable {
|
||||
}
|
||||
if (originalColumns != null) {
|
||||
List<String> clonedOriginalColumns = new ArrayList<String>(originalColumns);
|
||||
if(clonedMetadata.getOriginalColumns() == null || clonedMetadata.getOriginalColumns().isEmpty()) {
|
||||
clonedMetadata.setOriginalColumns(clonedOriginalColumns);
|
||||
}
|
||||
clonedMetadata.setOriginalColumns(clonedOriginalColumns);
|
||||
|
||||
}
|
||||
clonedMetadata.setTableName(this.getTableName());
|
||||
clonedMetadata.setLabel(this.getLabel());
|
||||
|
||||
@@ -211,7 +211,6 @@ public final class MetadataToolAvroHelper {
|
||||
//ignore it now as we can't process the complex expression for the default value, and the default value is not useful for runtime like the old javajet tjdbcxxx
|
||||
//TODO support the expression calculate, not sure it's necessary and sometimes, more complex like globalMap.get(xxx) which only have meaning after running the job.
|
||||
ExceptionHandler.process(e, Level.WARN);
|
||||
defaultValue = null;
|
||||
}
|
||||
|
||||
// Types with Document/Unknown elements, store as binary
|
||||
|
||||
@@ -15,7 +15,6 @@ package org.talend.core.model.metadata;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -615,71 +614,13 @@ public final class MetadataToolHelper {
|
||||
target.getListColumns().addAll(columnsTAdd);
|
||||
target.sortCustomColumns();
|
||||
target.setLabel(source.getLabel());
|
||||
target.setDbms(source.getDbms());
|
||||
setTargetOriginalColumns(source, target);
|
||||
// List<String> originalColumnsList = null;
|
||||
// if (source.getOriginalColumns() != null) {
|
||||
// originalColumnsList = new ArrayList<String>();
|
||||
// originalColumnsList.addAll(source.getOriginalColumns());
|
||||
// }
|
||||
// target.setOriginalColumns(originalColumnsList);
|
||||
target.setOriginalColumns(source.getOriginalColumns());
|
||||
Map<String, String> targetProperties = target.getAdditionalProperties();
|
||||
Map<String, String> sourceProperties = source.getAdditionalProperties();
|
||||
for (Entry<String, String> entry : sourceProperties.entrySet()) {
|
||||
targetProperties.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public static void setTargetOriginalColumns(IMetadataTable source, IMetadataTable target) {
|
||||
List<String> sColumns = source.getOriginalColumns();
|
||||
List<String> tColumns = target.getOriginalColumns();
|
||||
if(sColumns == null) {
|
||||
return;
|
||||
}
|
||||
if(tColumns == null) {
|
||||
target.setOriginalColumns(sColumns);
|
||||
return;
|
||||
}
|
||||
|
||||
if(sColumns.size() == tColumns.size()) {
|
||||
boolean same = true;
|
||||
for(int i = 0;i<sColumns.size();i++) {
|
||||
if(!sColumns.get(i).equals(tColumns.get(i))) {
|
||||
same = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(same) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for(String sColumn : sColumns) {
|
||||
if(tColumns.contains(sColumn)) {
|
||||
continue;
|
||||
}
|
||||
tColumns.add(sColumn);
|
||||
}
|
||||
|
||||
List<IMetadataColumn> targetColumns = target.getListColumns();
|
||||
List<String> temp = new ArrayList<String>(tColumns);
|
||||
if (targetColumns != null) {
|
||||
List<String> columnNames = new ArrayList<String>();
|
||||
for(IMetadataColumn column : targetColumns){
|
||||
columnNames.add(column.getLabel());
|
||||
}
|
||||
Collections.sort(temp, new Comparator<String>() {
|
||||
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
int index1 = columnNames.indexOf(o1);
|
||||
int index2 = columnNames.indexOf(o2);
|
||||
return index1 - index2;
|
||||
}
|
||||
});
|
||||
}
|
||||
target.setOriginalColumns(temp);
|
||||
}
|
||||
|
||||
public static void copyTable(List<IMetadataColumn> sourceColumns, IMetadataTable target, List<IMetadataColumn> targetColumns) {
|
||||
if (sourceColumns == null || target == null || targetColumns == null) {
|
||||
|
||||
@@ -146,7 +146,7 @@ public abstract class AbstractItemMigrationTask extends AbstractMigrationTask im
|
||||
* this returns all type handled by this migration task even the extended type that could benefit from this
|
||||
* migrations
|
||||
* */
|
||||
protected List<ERepositoryObjectType> getAllTypes() {
|
||||
List<ERepositoryObjectType> getAllTypes() {
|
||||
List<ERepositoryObjectType> declaredTypes = getTypes();
|
||||
ArrayList<ERepositoryObjectType> allTypes = new ArrayList<ERepositoryObjectType>(declaredTypes.size());
|
||||
allTypes.addAll(declaredTypes);
|
||||
|
||||
@@ -308,8 +308,7 @@ public abstract class AbstractNode implements INode {
|
||||
return mapMerge.keySet().iterator().next().getSubProcessStartNode(withConditions);
|
||||
}
|
||||
}
|
||||
if ((getCurrentActiveLinksNbInput(EConnectionType.MAIN) == 0)
|
||||
&& !checkIfCurrentActiveLinksIsLookup()) {
|
||||
if ((getCurrentActiveLinksNbInput(EConnectionType.MAIN) == 0)) {
|
||||
return this; // main branch here, so we got the correct sub
|
||||
// process start.
|
||||
}
|
||||
@@ -328,13 +327,9 @@ public abstract class AbstractNode implements INode {
|
||||
|
||||
for (IConnection connec : getIncomingConnections()) {
|
||||
if (((AbstractNode) connec.getSource()).isOnMainMergeBranch()) {
|
||||
// with lookup, tMap incoming connection contains FLOW_MAIN and FLOW_REF,
|
||||
// should take care of FLOW_MAIN only
|
||||
if (!connec.getLineStyle().equals(EConnectionType.FLOW_REF)) {
|
||||
return connec.getSource().getSubProcessStartNode(withConditions);
|
||||
}
|
||||
} else if (connec.getLineStyle().equals(EConnectionType.RUN_AFTER)) {
|
||||
return connec.getSource().getSubProcessStartNode(withConditions);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -350,27 +345,6 @@ public abstract class AbstractNode implements INode {
|
||||
return nb;
|
||||
}
|
||||
|
||||
private boolean checkIfCurrentActiveLinksIsLookup() {
|
||||
boolean flag = false;
|
||||
int input = 0;
|
||||
for (IConnection inConnection : getIncomingConnections()) {
|
||||
// refer to DataProcess.checkFlowRefLink() added RUN_AFTER for incoming connection
|
||||
if (inConnection.isActivate() && inConnection.getLineStyle().getId() == EConnectionType.RUN_AFTER.getId()) {
|
||||
input++;
|
||||
}
|
||||
}
|
||||
// check if run_after is for lookup
|
||||
if (input > 0) {
|
||||
for (IConnection outConnection : getOutgoingConnections()) {
|
||||
if (outConnection.isActivate() && outConnection.getLineStyle().getId() == EConnectionType.FLOW_REF.getId()) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
@@ -20,11 +20,11 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.IESBService;
|
||||
import org.talend.core.ITDQItemService;
|
||||
import org.talend.core.PluginChecker;
|
||||
import org.talend.core.hadoop.IHadoopClusterService;
|
||||
@@ -33,6 +33,7 @@ import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.JobletProcessItem;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.properties.ProjectReference;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.properties.SQLPatternItem;
|
||||
import org.talend.core.model.relationship.Relation;
|
||||
@@ -52,6 +53,7 @@ import org.talend.core.utils.BitwiseOptionUtils;
|
||||
import org.talend.designer.core.IDesignerCoreService;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.MetadataType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
@@ -895,14 +897,33 @@ public final class ProcessUtils {
|
||||
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(property.getItem());
|
||||
// route job
|
||||
if (itemType != null && (itemType.equals(ERepositoryObjectType.PROCESS_ROUTE)
|
||||
|| itemType.equals(ERepositoryObjectType.PROCESS_ROUTELET)
|
||||
|| "CAMEL".equals(process.getComponentsType()))) {
|
||||
|| itemType.equals(ERepositoryObjectType.PROCESS_ROUTELET))) {
|
||||
needBeans = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return needBeans && GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class);
|
||||
|
||||
if (needBeans && GlobalServiceRegister.getDefault().isServiceRegistered(IProxyRepositoryService.class)) {
|
||||
IProxyRepositoryService service = (IProxyRepositoryService) GlobalServiceRegister.getDefault()
|
||||
.getService(IProxyRepositoryService.class);
|
||||
ERepositoryObjectType beansType = ERepositoryObjectType.valueOf("BEANS"); //$NON-NLS-1$
|
||||
try {
|
||||
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
|
||||
List<IRepositoryViewObject> all = factory.getAll(project, beansType);
|
||||
List<ProjectReference> references = ProjectManager.getInstance().getCurrentProject()
|
||||
.getProjectReferenceList(true);
|
||||
for (ProjectReference ref : references) {
|
||||
all.addAll(factory.getAll(new Project(ref.getReferencedProject()), beansType));
|
||||
}
|
||||
if (!all.isEmpty()) { // has bean
|
||||
return true;
|
||||
}
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isRequiredPigUDFs(IProcess process) {
|
||||
@@ -953,17 +974,5 @@ public final class ProcessUtils {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isChildRouteProcess(IProcess process) {
|
||||
if (process != null) {
|
||||
for (INode node : process.getGraphicalNodes()) {
|
||||
if ((node.getComponent().getName() != null) &&
|
||||
(node.getComponent().getName().compareTo("tRouteInput") == 0)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Level;
|
||||
@@ -129,6 +128,8 @@ public class RelationshipItemBuilder {
|
||||
|
||||
private Map<Relation, Set<Relation>> referencesItemsRelations;
|
||||
|
||||
private Map<String, String> hadoopItemReferences = new HashMap<String, String>();
|
||||
|
||||
private boolean loaded = false;
|
||||
|
||||
private boolean loading = false;
|
||||
@@ -642,8 +643,8 @@ public class RelationshipItemBuilder {
|
||||
return;
|
||||
}
|
||||
loading = true;
|
||||
currentProjectItemsRelations = new ConcurrentHashMap<Relation, Set<Relation>>();
|
||||
referencesItemsRelations = new ConcurrentHashMap<Relation, Set<Relation>>();
|
||||
currentProjectItemsRelations = new HashMap<Relation, Set<Relation>>();
|
||||
referencesItemsRelations = new HashMap<Relation, Set<Relation>>();
|
||||
|
||||
loadRelations(currentProjectItemsRelations, getAimProject());
|
||||
|
||||
@@ -1096,11 +1097,10 @@ public class RelationshipItemBuilder {
|
||||
Map<Relation, Set<Relation>> relations = handler.find(item);
|
||||
mergeRelationship(itemRelations, relations);
|
||||
}
|
||||
// check if there is any changes on the relations.
|
||||
Set<Relation> newProjectRelations = currentProjectItemsRelations.get(relation);
|
||||
if (oldProjectRelations == null && newProjectRelations == null) {
|
||||
relationsModified = false;
|
||||
} else if (oldProjectRelations != null) {
|
||||
|
||||
if (oldProjectRelations != null) {
|
||||
// check if there is any changes on the relations.
|
||||
Set<Relation> newProjectRelations = currentProjectItemsRelations.get(relation);
|
||||
if (oldProjectRelations.size() == newProjectRelations.size()) {
|
||||
relationsModified = false;
|
||||
for (Relation newRelation : newProjectRelations) {
|
||||
|
||||
@@ -427,11 +427,6 @@ public class ERepositoryObjectType extends DynaEnum<ERepositoryObjectType> {
|
||||
*/
|
||||
public final static ERepositoryObjectType JOBLET = ERepositoryObjectType.valueOf("JOBLET"); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* <font color="red">This value may be <b>null</b> in some products, <b>should add NPE check</b></font>
|
||||
*/
|
||||
public final static ERepositoryObjectType SERVICES = ERepositoryObjectType.valueOf("SERVICES"); //$NON-NLS-1$
|
||||
|
||||
public final static ERepositoryObjectType JOBLET_DESIGNS = ERepositoryObjectType.valueOf("JOBLET_DESIGNS"); //$NON-NLS-1$
|
||||
|
||||
public final static ERepositoryObjectType SPARK_JOBLET = ERepositoryObjectType.valueOf("SPARK_JOBLET"); //$NON-NLS-1$
|
||||
@@ -444,8 +439,6 @@ public class ERepositoryObjectType extends DynaEnum<ERepositoryObjectType> {
|
||||
|
||||
public final static ERepositoryObjectType ROUTINES = ERepositoryObjectType.valueOf("ROUTINES"); //$NON-NLS-1$
|
||||
|
||||
public final static ERepositoryObjectType BEANS = ERepositoryObjectType.valueOf("BEANS"); //$NON-NLS-1$
|
||||
|
||||
public final static ERepositoryObjectType METADATA_HEADER_FOOTER = ERepositoryObjectType.valueOf("METADATA_HEADER_FOOTER"); //$NON-NLS-1$
|
||||
|
||||
public final static ERepositoryObjectType JOB_SCRIPT = ERepositoryObjectType.valueOf("JOB_SCRIPT"); //$NON-NLS-1$
|
||||
|
||||
@@ -12,9 +12,6 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.model.routines;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
@@ -32,12 +29,9 @@ import org.osgi.framework.Bundle;
|
||||
import org.talend.commons.utils.resource.FileExtensions;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ILibraryManagerService;
|
||||
import org.talend.core.ISVNProviderServiceInCoreRuntime;
|
||||
import org.talend.core.PluginChecker;
|
||||
import org.talend.core.model.general.LibraryInfo;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.nexus.TalendLibsServerManager;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenConstants;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
|
||||
/**
|
||||
* wchen class global comment. Detailled comment
|
||||
@@ -99,14 +93,7 @@ public class RoutineLibraryMananger {
|
||||
if (entry != null && libManagerService != null) {
|
||||
try {
|
||||
URL fileUrl = FileLocator.toFileURL(entry);
|
||||
if(fileUrl != null){
|
||||
if (!"file".equals(fileUrl.getProtocol())) throw new IllegalArgumentException();
|
||||
File file = new File(fileUrl.getFile());
|
||||
if (needDeploy(fileUrl)) {
|
||||
URI fileUri = file.toURI();
|
||||
libManagerService.deploy(fileUri);
|
||||
}
|
||||
}
|
||||
libManagerService.deploy(fileUrl.toURI());
|
||||
} catch (Exception e) {
|
||||
log.warn("Cannot deploy: " + bundleName + path);
|
||||
continue;
|
||||
@@ -121,56 +108,6 @@ public class RoutineLibraryMananger {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean needDeploy(URL fileUrl) throws IOException, Exception {
|
||||
File file = new File(fileUrl.getFile());
|
||||
ILibraryManagerService libManagerService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
|
||||
libManagerService = (ILibraryManagerService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibraryManagerService.class);
|
||||
}
|
||||
if (libManagerService != null) {
|
||||
Map<String, String> sourceAndMavenUri = new HashMap<>();
|
||||
libManagerService.guessMavenRUIFromIndex(file, sourceAndMavenUri);
|
||||
String mavUri = null;
|
||||
boolean isSnapshot = false;
|
||||
for (String key : sourceAndMavenUri.keySet()) {
|
||||
if (sourceAndMavenUri.get(key).equals(file.getPath())) {
|
||||
mavUri = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mavUri == null) {
|
||||
return true;
|
||||
}
|
||||
final MavenArtifact parseMvnUrl = MavenUrlHelper.parseMvnUrl(mavUri);
|
||||
if (parseMvnUrl != null) {
|
||||
if (parseMvnUrl.getVersion() != null && parseMvnUrl.getVersion().endsWith(MavenConstants.SNAPSHOT)) {
|
||||
isSnapshot = true;
|
||||
}
|
||||
}
|
||||
TalendLibsServerManager manager = TalendLibsServerManager.getInstance();
|
||||
ArtifactRepositoryBean customNexusServer = manager.getCustomNexusServer();
|
||||
File jarFile = null;
|
||||
try {
|
||||
jarFile = libManagerService.resolveJar(customNexusServer, mavUri);
|
||||
} catch (Exception ex) {
|
||||
// Ignore here
|
||||
}
|
||||
boolean exist = (jarFile != null && jarFile.exists());
|
||||
if (exist) {
|
||||
if (isSnapshot) {
|
||||
boolean isSame = libManagerService.isSameFile(jarFile, file);
|
||||
if (!isSame) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Map<String, List<LibraryInfo>> getRoutineAndJars() {
|
||||
if (routineAndJars == null) {
|
||||
routineAndJars = new HashMap<String, List<LibraryInfo>>();
|
||||
|
||||
@@ -681,15 +681,16 @@ public class NodeUtil {
|
||||
}
|
||||
List<? extends IConnection> listInConns = node.getIncomingConnections();
|
||||
if (listInConns != null && listInConns.size() > 0) {
|
||||
for (IConnection connection : listInConns) {
|
||||
if (EConnectionType.FLOW_REF != connection.getLineStyle()) {
|
||||
String retResult = getPrivateConnClassName(connection);
|
||||
return retResult != null ? retResult : conn.getName();
|
||||
}
|
||||
String retResult = getPrivateConnClassName(listInConns.get(0));
|
||||
if (retResult == null) {
|
||||
return conn.getName();
|
||||
} else {
|
||||
return retResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -79,11 +79,6 @@ public class ArtifactRepositoryBean implements Cloneable {
|
||||
if (index > 0) {
|
||||
nexusUrl = url.substring(0, index + ARTIFACT_MIDDLE_PATH.length());
|
||||
repoId = StringUtilities.removeEndingString(url.substring(index + ARTIFACT_MIDDLE_PATH.length()), "/");
|
||||
} else {
|
||||
// can be non-default contextpath or root
|
||||
String tempurl = StringUtilities.removeEndingString(url, "/");
|
||||
repoId = tempurl.substring(tempurl.lastIndexOf("/") + 1);
|
||||
nexusUrl = url.substring(0, url.indexOf(repoId));
|
||||
}
|
||||
}
|
||||
return new String[] { nexusUrl, repoId };
|
||||
|
||||
@@ -12,12 +12,14 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.nexus;
|
||||
|
||||
import java.net.Authenticator;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.PasswordAuthentication;
|
||||
import java.net.Proxy;
|
||||
import java.net.Proxy.Type;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -35,6 +37,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.talend.commons.exception.BusinessException;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.network.TalendProxySelector;
|
||||
import org.talend.commons.utils.network.TalendProxySelector.IProxySelectorProvider;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
@@ -120,7 +123,7 @@ public abstract class HttpClientTransport {
|
||||
}
|
||||
}
|
||||
|
||||
public static IProxySelectorProvider addProxy(final DefaultHttpClient httpClient, URI requestURI) {
|
||||
private IProxySelectorProvider addProxy(final DefaultHttpClient httpClient, URI requestURI) {
|
||||
IProxySelectorProvider proxySelectorProvider = null;
|
||||
try {
|
||||
if (Boolean.valueOf(System.getProperty(PROP_PROXY_HTTP_CLIENT_USE_DEFAULT_SETTINGS, Boolean.FALSE.toString()))) {
|
||||
@@ -138,10 +141,10 @@ public abstract class HttpClientTransport {
|
||||
}
|
||||
final Proxy finalProxy = usedProxy;
|
||||
InetSocketAddress address = (InetSocketAddress) finalProxy.address();
|
||||
String proxyServer = address.getHostString();
|
||||
String proxyServer = address.getHostName();
|
||||
int proxyPort = address.getPort();
|
||||
TalendProxySelector proxySelector = TalendProxySelector.getInstance();
|
||||
PasswordAuthentication proxyAuthentication = proxySelector.getHttpPasswordAuthentication();
|
||||
PasswordAuthentication proxyAuthentication = Authenticator.requestPasswordAuthentication(proxyServer,
|
||||
address.getAddress(), proxyPort, "Http Proxy", "Http proxy authentication", null);
|
||||
if (proxyAuthentication != null) {
|
||||
String proxyUser = proxyAuthentication.getUserName();
|
||||
String proxyPassword = "";
|
||||
@@ -154,7 +157,7 @@ public abstract class HttpClientTransport {
|
||||
}
|
||||
HttpHost proxyHost = new HttpHost(proxyServer, proxyPort);
|
||||
httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxyHost);
|
||||
proxySelectorProvider = proxySelector.createDefaultProxySelectorProvider();
|
||||
proxySelectorProvider = createProxySelectorProvider();
|
||||
}
|
||||
return proxySelectorProvider;
|
||||
} finally {
|
||||
@@ -164,12 +167,61 @@ public abstract class HttpClientTransport {
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeProxy(IProxySelectorProvider proxySelectorProvider) {
|
||||
private void removeProxy(IProxySelectorProvider proxySelectorProvider) {
|
||||
if (proxySelectorProvider != null) {
|
||||
TalendProxySelector.getInstance().removeProxySelectorProvider(proxySelectorProvider);
|
||||
}
|
||||
}
|
||||
|
||||
private IProxySelectorProvider createProxySelectorProvider() {
|
||||
IProxySelectorProvider proxySelectorProvider = new TalendProxySelector.AbstractProxySelectorProvider() {
|
||||
|
||||
private Thread currentThread = Thread.currentThread();
|
||||
|
||||
@Override
|
||||
public List<Proxy> select(URI uri) {
|
||||
// return Collections.EMPTY_LIST;
|
||||
|
||||
List<Proxy> newProxys = new ArrayList<>();
|
||||
if (uri == null) {
|
||||
return newProxys;
|
||||
}
|
||||
String schema = uri.getScheme();
|
||||
if (schema != null && schema.toLowerCase().startsWith("socket")) { //$NON-NLS-1$
|
||||
try {
|
||||
URI newUri = new URI("https", uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath(),
|
||||
uri.getQuery(), uri.getFragment());
|
||||
List<Proxy> proxys = TalendProxySelector.getInstance().getDefaultProxySelector().select(newUri);
|
||||
if (proxys != null && !proxys.isEmpty()) {
|
||||
newProxys.addAll(proxys);
|
||||
} else {
|
||||
newUri = new URI("http", uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath(),
|
||||
uri.getQuery(), uri.getFragment());
|
||||
proxys = TalendProxySelector.getInstance().getDefaultProxySelector().select(newUri);
|
||||
if (proxys != null && !proxys.isEmpty()) {
|
||||
newProxys.addAll(proxys);
|
||||
}
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
return newProxys;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(URI uri) {
|
||||
if (Thread.currentThread() == currentThread) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
return proxySelectorProvider;
|
||||
}
|
||||
|
||||
public void processResponseCode(HttpResponse response) throws BusinessException {
|
||||
StatusLine statusLine = response.getStatusLine();
|
||||
int responseCode = statusLine.getStatusCode();
|
||||
|
||||
@@ -61,7 +61,5 @@ public interface IRepositoryArtifactHandler {
|
||||
public IRepositoryArtifactHandler clone();
|
||||
|
||||
public String getRepositoryURL(boolean isRelease);
|
||||
|
||||
public String resolveRemoteSha1(MavenArtifact artifact, boolean fromRelease) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,5 @@ public class NexusConstants {
|
||||
|
||||
public static final String SLASH = "/";//$NON-NLS-1$
|
||||
|
||||
public static final String SNAPSHOTS = "@snapshots";//$NON-NLS-1$
|
||||
|
||||
public static final String DISALLOW_RELEASES = "@noreleases";//$NON-NLS-1$
|
||||
public static final String SNAPSHOTS = "@snapshots";
|
||||
}
|
||||
|
||||
@@ -23,9 +23,6 @@ import org.osgi.framework.ServiceReference;
|
||||
import org.osgi.service.cm.ManagedService;
|
||||
import org.osgi.util.tracker.ServiceTracker;
|
||||
import org.osgi.util.tracker.ServiceTrackerCustomizer;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.network.TalendProxySelector;
|
||||
import org.talend.commons.utils.network.TalendProxySelector.IProxySelectorProvider;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
|
||||
/**
|
||||
@@ -101,24 +98,7 @@ public class TalendMavenResolver {
|
||||
}
|
||||
|
||||
public static File resolve(String mvnUri) throws IOException, RuntimeException {
|
||||
TalendProxySelector selectorInstance = null;
|
||||
IProxySelectorProvider proxySelector = null;
|
||||
try {
|
||||
try {
|
||||
selectorInstance = TalendProxySelector.getInstance();
|
||||
proxySelector = selectorInstance.createDefaultProxySelectorProvider();
|
||||
if (proxySelector != null) {
|
||||
selectorInstance.addProxySelectorProvider(proxySelector);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
return getMavenResolver().resolve(mvnUri);
|
||||
} finally {
|
||||
if (proxySelector != null && selectorInstance != null) {
|
||||
selectorInstance.removeProxySelectorProvider(proxySelector);
|
||||
}
|
||||
}
|
||||
return getMavenResolver().resolve(mvnUri);
|
||||
}
|
||||
|
||||
public static void upload(String groupId, String artifactId, String classifier, String extension, String version,
|
||||
|
||||
@@ -192,10 +192,6 @@ public interface ITalendCorePrefConstants {
|
||||
|
||||
public static final String NEXUS_REFRESH_FREQUENCY = "NEXUS_REFRESH_FREQUENCY"; //$NON-NLS-1$
|
||||
|
||||
public static final String NEXUS_SHARE_LIBS = "NEXUS_SHARE_LIBS";
|
||||
|
||||
public static final boolean NEXUS_SHARE_LIBS_DEFAULT = true;
|
||||
|
||||
/**
|
||||
* AutoMap algorithm weight
|
||||
*/
|
||||
|
||||
@@ -24,7 +24,7 @@ public class MavenArtifact implements Cloneable {
|
||||
private static final char ARTIFACT_SEPARATOR = '-';
|
||||
|
||||
private String repositoryUrl, groupId, artifactId, version, type, classifier, description, url, license, licenseUrl,
|
||||
distribution, username, password, lastUpdated, sha1, md5;
|
||||
distribution, username, password, lastUpdated;
|
||||
|
||||
public String getLastUpdated() {
|
||||
return this.lastUpdated;
|
||||
@@ -138,22 +138,6 @@ public class MavenArtifact implements Cloneable {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getSha1() {
|
||||
return sha1;
|
||||
}
|
||||
|
||||
public void setSha1(String sha1) {
|
||||
this.sha1 = sha1;
|
||||
}
|
||||
|
||||
public String getMd5() {
|
||||
return md5;
|
||||
}
|
||||
|
||||
public void setMd5(String md5) {
|
||||
this.md5 = md5;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* DOC ggu Comment method "getFileName".
|
||||
|
||||
@@ -42,8 +42,6 @@ public interface MavenConstants {
|
||||
|
||||
static final String POM_FILTER = "POM_FILTER";
|
||||
|
||||
static final String USE_PROFILE_MODULE = "USE_PROFILE_MODULE";
|
||||
|
||||
/*
|
||||
* for lib
|
||||
*/
|
||||
@@ -69,5 +67,4 @@ public interface MavenConstants {
|
||||
|
||||
static final String PACKAGING_POM = "pom";
|
||||
|
||||
static final String SKIP_FOLDERS = "SKIP_FOLDERS";
|
||||
}
|
||||
|
||||
@@ -352,15 +352,6 @@ public class LastGenerationInfo {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear modules per job cache, not thread safe
|
||||
*/
|
||||
public void clearModulesNeededPerJob() {
|
||||
if (!modulesNeededPerJob.isEmpty()) {
|
||||
modulesNeededPerJob.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void clean() {
|
||||
modulesNeededPerJob.clear();
|
||||
routinesNeededPerJob.clear();
|
||||
|
||||
@@ -62,8 +62,6 @@ public interface TalendProcessArgumentConstant {
|
||||
|
||||
static final String ARG_LAUNCHER_NAME = "LAUNCHER_NAME";
|
||||
|
||||
static final String ARG_AVOID_BRANCH_NAME = "AVOID_BRANCH_NAME";
|
||||
|
||||
static final String CMD_ARG_STATS_PORT_PARAM = "stat_port";
|
||||
|
||||
static final String CMD_ARG_TRACE_PORT_PARAM = "trace_port";
|
||||
|
||||
@@ -17,7 +17,6 @@ import java.util.Map;
|
||||
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.model.process.INode;
|
||||
|
||||
/**
|
||||
* created by ycbai on 2016年3月24日 Detailled comment
|
||||
@@ -39,7 +38,5 @@ public interface IGenericService extends IService {
|
||||
*
|
||||
*/
|
||||
public List<Map<String, String>> getAllGenericComponentsInfo();
|
||||
|
||||
public void resetReferenceValue(INode curNode, String oldConnectionName, String newConnectionName);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
// Copyright (C) 2006-2018 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
@@ -19,9 +19,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
@@ -81,8 +79,6 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
}
|
||||
|
||||
private Collection<RoutineItem> getAll(ERepositoryObjectType type, boolean syncRef) throws SystemException {
|
||||
// init code project
|
||||
getRunProcessService().getTalendCodeJavaProject(type);
|
||||
// remove routine with same name in reference project
|
||||
final Map<String, RoutineItem> beansList = new HashMap<String, RoutineItem>();
|
||||
for (IRepositoryViewObject obj : getRepositoryService().getProxyRepositoryFactory().getAll(type)) {
|
||||
@@ -99,37 +95,27 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
return (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
}
|
||||
|
||||
private Set<IRepositoryViewObject> getReferencedProjectRoutine(final Map<String, RoutineItem> beansList,
|
||||
final Project project, ERepositoryObjectType routineType, boolean syncRef) throws SystemException {
|
||||
// init ref code project
|
||||
if (syncRef) {
|
||||
getRunProcessService().getTalendCodeJavaProject(routineType, project.getTechnicalLabel());
|
||||
}
|
||||
Set<IRepositoryViewObject> routines = new HashSet<>();
|
||||
routines.addAll(getRepositoryService().getProxyRepositoryFactory().getAll(project, routineType));
|
||||
for (IRepositoryViewObject obj : routines) {
|
||||
private void getReferencedProjectRoutine(final Map<String, RoutineItem> beansList, final Project project,
|
||||
ERepositoryObjectType routineType, boolean syncRef) throws SystemException {
|
||||
for (IRepositoryViewObject obj : getRepositoryService().getProxyRepositoryFactory().getAll(project, routineType)) {
|
||||
final String key = obj.getProperty().getLabel();
|
||||
// it does not have a routine with same name
|
||||
if (!beansList.containsKey(key)) {
|
||||
beansList.put(key, (RoutineItem) obj.getProperty().getItem());
|
||||
}
|
||||
}
|
||||
for (ProjectReference projectReference : project.getProjectReferenceList()) {
|
||||
routines.addAll(getReferencedProjectRoutine(beansList, new Project(projectReference.getReferencedProject()),
|
||||
routineType, syncRef));
|
||||
if (syncRef) {
|
||||
// sync routine
|
||||
syncRoutine((RoutineItem) obj.getProperty().getItem(), false, true, true);
|
||||
}
|
||||
}
|
||||
if (syncRef) {
|
||||
routines.stream().forEach(obj -> {
|
||||
try {
|
||||
syncRoutine((RoutineItem) obj.getProperty().getItem(), project.getTechnicalLabel(), true, true);
|
||||
} catch (SystemException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
});
|
||||
// sync system routine
|
||||
syncSystemRoutine(project);
|
||||
}
|
||||
return routines;
|
||||
|
||||
for (ProjectReference projectReference : project.getProjectReferenceList()) {
|
||||
getReferencedProjectRoutine(beansList, new Project(projectReference.getReferencedProject()), routineType, syncRef);
|
||||
}
|
||||
}
|
||||
|
||||
protected void syncSystemRoutine(Project project) throws SystemException {
|
||||
@@ -142,17 +128,24 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
}
|
||||
|
||||
protected IFile getRoutineFile(RoutineItem routineItem) throws SystemException {
|
||||
return getRoutineFile(routineItem, ProjectManager.getInstance().getCurrentProject().getTechnicalLabel());
|
||||
return getRoutineFile(routineItem, true);
|
||||
}
|
||||
|
||||
protected IFile getRoutineFile(RoutineItem routineItem, String projectTechName) throws SystemException {
|
||||
protected IFile getRoutineFile(RoutineItem routineItem, boolean currentProject) throws SystemException {
|
||||
String projectTechName;
|
||||
if (currentProject) {
|
||||
projectTechName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
} else {
|
||||
projectTechName = ProjectManager.getInstance().getProject(routineItem).getTechnicalLabel();
|
||||
}
|
||||
ITalendProcessJavaProject talendProcessJavaProject = getRunProcessService()
|
||||
.getTalendCodeJavaProject(ERepositoryObjectType.getItemType(routineItem), projectTechName);
|
||||
if (talendProcessJavaProject == null) {
|
||||
return null;
|
||||
}
|
||||
IFolder routineFolder = talendProcessJavaProject.getSrcSubFolder(null, routineItem.getPackageType());
|
||||
return routineFolder.getFile(routineItem.getProperty().getLabel() + JavaUtils.JAVA_EXTENSION);
|
||||
IFile file = routineFolder.getFile(routineItem.getProperty().getLabel() + JavaUtils.JAVA_EXTENSION);
|
||||
return file;
|
||||
}
|
||||
|
||||
private IFile getProcessFile(ProcessItem item) throws SystemException {
|
||||
@@ -200,31 +193,30 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
|
||||
@Override
|
||||
public void syncRoutine(RoutineItem routineItem, boolean copyToTemp) throws SystemException {
|
||||
syncRoutine(routineItem, ProjectManager.getInstance().getCurrentProject().getTechnicalLabel(), copyToTemp, false);
|
||||
syncRoutine(routineItem, true, copyToTemp, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncRoutine(RoutineItem routineItem, boolean copyToTemp, boolean forceUpdate) throws SystemException {
|
||||
syncRoutine(routineItem, ProjectManager.getInstance().getCurrentProject().getTechnicalLabel(), copyToTemp, forceUpdate);
|
||||
syncRoutine(routineItem, true, copyToTemp, forceUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncRoutine(RoutineItem routineItem, String projectTechName, boolean copyToTemp, boolean forceUpdate)
|
||||
throws SystemException {
|
||||
public void syncRoutine(RoutineItem routineItem, boolean currentProject, boolean copyToTemp, boolean forceUpdate) throws SystemException {
|
||||
boolean needSync = false;
|
||||
if (routineItem != null) {
|
||||
if (forceUpdate || !isRoutineUptodate(routineItem)) {
|
||||
needSync = true;
|
||||
} else {
|
||||
IFile file = getRoutineFile(routineItem, projectTechName);
|
||||
IFile file = getRoutineFile(routineItem, currentProject);
|
||||
if (file != null && !file.exists()) {
|
||||
needSync = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (needSync) {
|
||||
doSyncRoutine(routineItem, projectTechName, copyToTemp);
|
||||
if (ProjectManager.getInstance().getCurrentProject().getTechnicalLabel().equals(projectTechName)) {
|
||||
doSyncRoutine(routineItem, currentProject, copyToTemp);
|
||||
if (currentProject) {
|
||||
setRoutineAsUptodate(routineItem);
|
||||
}
|
||||
}
|
||||
@@ -232,14 +224,14 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
|
||||
public void syncRoutine(RoutineItem routineItem) throws SystemException {
|
||||
if (routineItem != null) {
|
||||
doSyncRoutine(routineItem, ProjectManager.getInstance().getCurrentProject().getTechnicalLabel(), true);
|
||||
doSyncRoutine(routineItem, true, true);
|
||||
setRoutineAsUptodate(routineItem);
|
||||
}
|
||||
}
|
||||
|
||||
private void doSyncRoutine(RoutineItem routineItem, String projectTechName, boolean copyToTemp) throws SystemException {
|
||||
private void doSyncRoutine(RoutineItem routineItem, boolean currentProject, boolean copyToTemp) throws SystemException {
|
||||
try {
|
||||
IFile file = getRoutineFile(routineItem, projectTechName);
|
||||
IFile file = getRoutineFile(routineItem, currentProject);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
@@ -366,7 +358,7 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.talend.designer.codegen.ITalendSynchronizer#syncAllPigudf()
|
||||
*/
|
||||
@Override
|
||||
@@ -382,7 +374,7 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
@Override
|
||||
public void syncAllBeansForLogOn() throws SystemException {
|
||||
for (RoutineItem beanItem : getBeans(true)) {
|
||||
syncRoutine(beanItem, true, true);
|
||||
syncRoutine(beanItem, true, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,8 +45,7 @@ public interface ITalendSynchronizer {
|
||||
|
||||
void syncRoutine(RoutineItem routineItem, boolean copyToTemp, boolean forceUpdate) throws SystemException;
|
||||
|
||||
void syncRoutine(RoutineItem routineItem, String projectTechName, boolean copyToTemp, boolean forceUpdate)
|
||||
throws SystemException;
|
||||
void syncRoutine(RoutineItem routineItem, boolean currentProject, boolean copyToTemp, boolean forceUpdate) throws SystemException;
|
||||
|
||||
IFile getFile(Item item) throws SystemException;
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
// ============================================================================
|
||||
package org.talend.designer.core;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.dom4j.Element;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.process.EConnectionType;
|
||||
@@ -62,12 +60,4 @@ public interface ICamelDesignerCoreService extends IService {
|
||||
|
||||
public FileItem newRouteDocumentationItem();
|
||||
|
||||
/**
|
||||
* DOC sunchaoqun Comment method "getUnselectDependenciesBundle".
|
||||
*
|
||||
* @param processItem
|
||||
* @return
|
||||
*/
|
||||
Collection<String> getUnselectDependenciesBundle(ProcessItem processItem);
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.eclipse.jdt.core.IJavaProject;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.language.ECodeLanguage;
|
||||
import org.talend.core.language.ICodeProblemsChecker;
|
||||
@@ -217,8 +216,6 @@ public interface IRunProcessService extends IService {
|
||||
|
||||
ITalendProcessJavaProject getTalendJobJavaProject(Property property);
|
||||
|
||||
IFolder getCodeSrcFolder(ERepositoryObjectType type, String projectTechName);
|
||||
|
||||
ITalendProcessJavaProject getTempJavaProject();
|
||||
|
||||
void clearProjectRelatedSettings();
|
||||
@@ -238,11 +235,4 @@ public interface IRunProcessService extends IService {
|
||||
public void handleJobDependencyLoop(JobInfo mainJobInfo, List<JobInfo> listJobs, IProgressMonitor progressMonitor)
|
||||
throws Exception;
|
||||
|
||||
public static IRunProcessService get() {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
return (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,9 +20,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
@@ -93,16 +91,11 @@ public final class ProjectManager {
|
||||
|
||||
private Set<Object> updatedRemoteHandlerRecords;
|
||||
|
||||
private Set<Project> tempProjects;
|
||||
|
||||
private WeakHashMap<IRepositoryViewObject, Boolean> cachedObjects = new WeakHashMap<IRepositoryViewObject, Boolean>();
|
||||
|
||||
private ProjectManager() {
|
||||
beforeLogonRecords = new HashSet<String>();
|
||||
logonRecords = new HashSet<String>();
|
||||
migrationRecords = new HashSet<String>();
|
||||
updatedRemoteHandlerRecords = new HashSet<Object>();
|
||||
tempProjects = new HashSet<>();
|
||||
initCurrentProject();
|
||||
}
|
||||
|
||||
@@ -113,18 +106,6 @@ public final class ProjectManager {
|
||||
return singleton;
|
||||
}
|
||||
|
||||
public void clearTempProjects() {
|
||||
tempProjects.clear();
|
||||
}
|
||||
|
||||
public boolean removeTempProject(Project project) {
|
||||
return tempProjects.remove(project);
|
||||
}
|
||||
|
||||
public boolean addTempProject(Project project) {
|
||||
return tempProjects.add(project);
|
||||
}
|
||||
|
||||
public Project getProjectFromProjectLabel(String label) {
|
||||
if (currentProject == null) {
|
||||
initCurrentProject();
|
||||
@@ -138,12 +119,6 @@ public final class ProjectManager {
|
||||
return project;
|
||||
}
|
||||
}
|
||||
|
||||
for (Project project : tempProjects) {
|
||||
if (StringUtils.equals(project.getLabel(), label)) {
|
||||
return project;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -161,11 +136,6 @@ public final class ProjectManager {
|
||||
return project;
|
||||
}
|
||||
}
|
||||
for (Project project : tempProjects) {
|
||||
if (StringUtils.equals(project.getTechnicalLabel(), label)) {
|
||||
return project;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -186,7 +156,7 @@ public final class ProjectManager {
|
||||
Set<String> resolvedProjectLabels, boolean force) {
|
||||
if (p != null) {
|
||||
String parentBranch = ProjectManager.getInstance().getMainProjectBranch(p);
|
||||
if ((!p.isLocal() || parentBranch != null) || force) {
|
||||
if (parentBranch != null || force) {
|
||||
resolvedProjectLabels.add(p.getTechnicalLabel());
|
||||
for (ProjectReference pr : new Project(p).getProjectReferenceList()) {
|
||||
if (ProjectManager.validReferenceProject(p, pr)
|
||||
@@ -230,10 +200,6 @@ public final class ProjectManager {
|
||||
* return all the referenced projects of current project.
|
||||
*/
|
||||
public List<Project> getAllReferencedProjects(boolean force) {
|
||||
return getAllReferencedProjects(getCurrentProject(), force);
|
||||
}
|
||||
|
||||
public List<Project> getAllReferencedProjects(Project targetProject, boolean force) {
|
||||
List<Project> allReferencedprojects = new ArrayList<Project>();
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IProxyRepositoryService.class)) {
|
||||
if (this.getCurrentProject() == null) {
|
||||
@@ -246,7 +212,7 @@ public final class ProjectManager {
|
||||
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
|
||||
if (factory != null) {
|
||||
List<org.talend.core.model.properties.Project> rProjects = factory
|
||||
.getReferencedProjects(targetProject);
|
||||
.getReferencedProjects(this.getCurrentProject());
|
||||
if (rProjects != null) {
|
||||
for (org.talend.core.model.properties.Project p : rProjects) {
|
||||
Project project = new Project(p);
|
||||
@@ -454,14 +420,9 @@ public final class ProjectManager {
|
||||
if (object == null) {
|
||||
return true;
|
||||
}
|
||||
if (cachedObjects.containsKey(object)) {
|
||||
return cachedObjects.get(object);
|
||||
}
|
||||
org.talend.core.model.properties.Project emfProject = getProject(object.getProperty().getItem());
|
||||
org.talend.core.model.properties.Project curProject = curP.getEmfProject();
|
||||
boolean ret = emfProject.equals(curProject);
|
||||
cachedObjects.put(object, ret);
|
||||
return ret;
|
||||
return emfProject.equals(curProject);
|
||||
|
||||
} else {
|
||||
IProjectRepositoryNode root = node.getRoot();
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
// ============================================================================
|
||||
package org.talend.repository;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.talend.commons.exception.LoginException;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.model.general.Project;
|
||||
@@ -47,8 +45,6 @@ public abstract class RepositoryWorkUnit<T> {
|
||||
|
||||
private boolean refreshRepository = true; // added for TDI-27085
|
||||
|
||||
private Set<String> specifiedCommitFiles;
|
||||
|
||||
/**
|
||||
* Usefull for some save only actions, where we're sure everything is up to date.
|
||||
*/
|
||||
@@ -198,14 +194,7 @@ public abstract class RepositoryWorkUnit<T> {
|
||||
this.refreshRepository = refreshRepository;
|
||||
}
|
||||
|
||||
public Set<String> getSpecifiedCommitFiles() {
|
||||
return specifiedCommitFiles;
|
||||
}
|
||||
|
||||
public void setSpecifiedCommitFiles(Set<String> specifiedCommitFiles) {
|
||||
this.specifiedCommitFiles = specifiedCommitFiles;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Getter for avoidUpdateLocks.
|
||||
* @return the avoidUpdateLocks
|
||||
|
||||
@@ -33,8 +33,6 @@ public class RepositoryConstants {
|
||||
|
||||
public static final String PROJECT_BRANCH_ID = "repository.project.branch"; //$NON-NLS-1$
|
||||
|
||||
public static final String PROJECT_ID = "repository.project.id";
|
||||
|
||||
public static final String IMG_DIRECTORY = "images"; //$NON-NLS-1$
|
||||
|
||||
public static final String IMG_DIRECTORY_OF_JOB_OUTLINE = "images/job_outlines"; //$NON-NLS-1$
|
||||
|
||||
@@ -17,7 +17,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.common.util.EMap;
|
||||
import org.eclipse.gef.commands.Command;
|
||||
@@ -153,8 +152,8 @@ public class RepositoryChangeMetadataForSAPBapi extends Command {
|
||||
|
||||
String uinqueTableName = node.getProcess().generateUniqueConnectionName(
|
||||
MultiSchemasUtil.getConnectionBaseName(newMetadatTable.getLabel()));
|
||||
String type = getType(newMetadatTable, isInput);
|
||||
if (type == null) {
|
||||
String paramType = getParamType(newMetadatTable, isInput);
|
||||
if (paramType == null) {
|
||||
return;
|
||||
}
|
||||
if (selectionIndex != null && selectionIndex < paramValues.size()) {
|
||||
@@ -166,19 +165,18 @@ public class RepositoryChangeMetadataForSAPBapi extends Command {
|
||||
paramValues.add(valueMap);
|
||||
}
|
||||
valueMap.put(ISAPConstant.NAME, TalendQuoteUtils.addQuotes(newMetadatTable.getLabel()));
|
||||
valueMap.put(ISAPConstant.TYPE, type);
|
||||
valueMap.put(ISAPConstant.TYPE, paramType);
|
||||
valueMap.put(ISAPConstant.FIELD_SCHEMA, uinqueTableName);
|
||||
if (isInput) {
|
||||
valueMap.put(ISAPConstant.PARENT_ROW, ""); //$NON-NLS-1$
|
||||
|
||||
String inputParameterType = getInputParameterType(functionUnit, newMetadatTable);
|
||||
if (StringUtils.isBlank(inputParameterType)) {
|
||||
inputParameterType = ISAPConstant.PARAMETER_TYPE_IMPORT;
|
||||
if (functionUnit != null && functionUnit.getParamData() != null
|
||||
&& functionUnit.getParamData().getInputRoot() != null) {
|
||||
for (SAPFunctionParameter param : functionUnit.getParamData().getInputRoot().getChildren()) {
|
||||
if (param.getName().equals(newMetadatTable.getTableName())) {
|
||||
valueMap.put(ISAPConstant.CHANGING, param.isChanging());
|
||||
}
|
||||
}
|
||||
}
|
||||
valueMap.put(ISAPConstant.PARAMETER_TYPE, inputParameterType);
|
||||
|
||||
valueMap.put(ISAPConstant.CHANGING, ISAPConstant.PARAMETER_TYPE_CHANGING.equals(inputParameterType));
|
||||
|
||||
Map<String, String> properties = newMetadatTable.getAdditionalProperties();
|
||||
if (properties != null) {
|
||||
properties.put(ISINPUT, TRUE);
|
||||
@@ -197,37 +195,7 @@ public class RepositoryChangeMetadataForSAPBapi extends Command {
|
||||
}
|
||||
}
|
||||
|
||||
private String getInputParameterType(SAPFunctionUnit funcUnit, IMetadataTable newMetadatTable) {
|
||||
String parameterType = "";
|
||||
if (funcUnit != null && funcUnit.getParamData() != null && funcUnit.getParamData().getInputRoot() != null) {
|
||||
SAPFunctionParameter foundParam = null;
|
||||
String tableName = newMetadatTable.getTableName();
|
||||
for (SAPFunctionParameter param : funcUnit.getParamData().getInputRoot().getChildren()) {
|
||||
if (tableName.equals(param.getName())) {
|
||||
foundParam = param;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (foundParam != null) {
|
||||
if (foundParam.isChanging()) {
|
||||
parameterType = ISAPConstant.PARAMETER_TYPE_CHANGING;
|
||||
} else {
|
||||
if (ISAPConstant.PARAM_TABLE.equals(foundParam.getType())) {
|
||||
if (foundParam.isTableResideInTables()) {
|
||||
parameterType = ISAPConstant.PARAMETER_TYPE_TABLES;
|
||||
} else {
|
||||
parameterType = ISAPConstant.PARAMETER_TYPE_IMPORT;
|
||||
}
|
||||
} else {
|
||||
parameterType = ISAPConstant.PARAMETER_TYPE_IMPORT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return parameterType;
|
||||
}
|
||||
|
||||
private String getType(IMetadataTable table, boolean isInput) {
|
||||
private String getParamType(IMetadataTable table, boolean isInput) {
|
||||
if (functionUnit == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -725,8 +725,6 @@ public class MetadataDialog extends Dialog {
|
||||
}
|
||||
|
||||
IDesignerCoreService designerCoreService = CoreUIPlugin.getDefault().getDesignerCoreService();
|
||||
updateTableOriginalColumns(outputTable);
|
||||
updateTableOriginalColumns(inputTable);
|
||||
designerCoreService.setTraceFilterParameters(outputNode, outputTable, preOutputColumnSet, changedNameColumnsForOutput);
|
||||
designerCoreService.setTraceFilterParameters(inputNode, inputTable, preInputColumnSet, changedNameColumnsForInput);
|
||||
if (outputTable != null && inputTable != null) {
|
||||
@@ -747,18 +745,6 @@ public class MetadataDialog extends Dialog {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTableOriginalColumns(IMetadataTable table) {
|
||||
if (table != null && table.getListColumns() != null) {
|
||||
List<String> columnNames = new ArrayList<String>();
|
||||
for (IMetadataColumn column : table.getListColumns()) {
|
||||
columnNames.add(column.getLabel());
|
||||
}
|
||||
if(table.getOriginalColumns() == null || table.getOriginalColumns().isEmpty()) {
|
||||
table.setOriginalColumns(columnNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC wzhang Comment method "getPreColumnsSet".
|
||||
|
||||
@@ -72,20 +72,10 @@ public class JavaSimpleDateFormatProposalProvider implements IContentProposalPro
|
||||
"\"dd/MM/yyyy\" : common format", "dd/MM/yyyy", "Date\n Examples : \n 01/01/2007\n 31/12/2007"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
new DateFormatContentProposal(
|
||||
"\"MM/dd/yyyy\" : common format", "MM/dd/yyyy", "Date\n Examples : \n 01/01/2007\n 12/31/2007"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
new DateFormatContentProposal(
|
||||
"\"yyyy-MM-dd\" : common format", "yyyy-MM-dd", "Date\n Examples : \n 2007-01-01\n 2007-12-31"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
new DateFormatContentProposal("\"yyyy-MM-dd HH:mm:ss\" : common format", "yyyy-MM-dd HH:mm:ss",
|
||||
"Date\n Examples : \n 2014-08-19 07:41:35\n 2014-12-31 07:41:35"),//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
new DateFormatContentProposal("\"yyyy-MM-dd'T'HH:mm:ss\" : common format", "yyyy-MM-dd'T'HH:mm:ss",
|
||||
new DateFormatContentProposal("\"yyyy-MM-dd'T'HH:mm:ss\" : common format", "yyyy-MM-dd'T'HH:mm:ss", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
"Date\n Examples : \n 2007-01-01T00:00:00\n 2007-12-31T23:59:59"), // hywang //$NON-NLS-1$
|
||||
new DateFormatContentProposal("\"yyyy-MM-dd'T'HH:mm:ss'000Z'\" : common format", "yyyy-MM-dd'T'HH:mm:ss'000Z'", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
"Date\n Examples : \n 2007-01-01T00:00:00000Z\n 2007-12-31T23:59:59000Z"), // hywang //$NON-NLS-1$
|
||||
new DateFormatContentProposal("\"yyyy-MM-dd'T'HH:mm:ss.SSSSSS\" : common format", "yyyy-MM-dd'T'HH:mm:ss.SSSSSS",
|
||||
"Date\n Examples : \n 2019-04-18T09:47:49.568095"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
new DateFormatContentProposal("\"yyyy-MM-dd HH:mm:ss zzz\" : common format", "yyyy-MM-dd HH:mm:ss zzz", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
"Date\n Examples : \n 2008-01-01 00:00:00 UTC\n 2008-12-31 04:08:00 PDT"),
|
||||
new DateFormatContentProposal("\"yyyy-MM-dd HH:mm:ss.SSSXXX\" : common format", "yyyy-MM-dd HH:mm:ss.SSSXXX", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
"Date\n Examples : \n 2014-08-19 07:41:35.220 -05:00"),
|
||||
new DateFormatContentProposal(
|
||||
"\"HH:mm:ss\" : common format", "HH:mm:ss", "Date\n Examples : \n 00:00:00 \n 23:59:59"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
new DateFormatContentProposal("\"yy\" : Year (00-99)", "yy", "Year \nExamples : \n 98\n 07"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
||||
@@ -54,7 +54,6 @@ import org.talend.core.model.metadata.QueryUtil;
|
||||
import org.talend.core.model.metadata.builder.ConvertionHelper;
|
||||
import org.talend.core.model.metadata.builder.connection.MetadataTable;
|
||||
import org.talend.core.model.process.ElementParameterParser;
|
||||
import org.talend.core.model.process.ProcessUtils;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.relationship.RelationshipItemBuilder;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
@@ -280,10 +279,9 @@ public class CoreService implements ICoreService {
|
||||
ICodeGeneratorService codeGenService = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(
|
||||
ICodeGeneratorService.class);
|
||||
codeGenService.createRoutineSynchronizer().syncAllRoutinesForLogOn();
|
||||
if (ProcessUtils.isRequiredPigUDFs(null)) {
|
||||
codeGenService.createRoutineSynchronizer().syncAllPigudfForLogOn();
|
||||
}
|
||||
codeGenService.createRoutineSynchronizer().syncAllPigudfForLogOn();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.WarningException;
|
||||
|
||||
/**
|
||||
* cli class global comment. Detailled comment
|
||||
@@ -104,31 +104,26 @@ public final class ProcessStreamTrashReaderUtil {
|
||||
|
||||
public static void readAndForget(final Process process) {
|
||||
try {
|
||||
final String encoding = "UTF-8";
|
||||
// input stream thread
|
||||
new Thread() {
|
||||
|
||||
public void run() {
|
||||
InputStream is = process.getInputStream();
|
||||
InputStreamReader din = new InputStreamReader(is);
|
||||
BufferedReader reader = new BufferedReader(din);
|
||||
try {
|
||||
InputStream is = process.getInputStream();
|
||||
InputStreamReader din = new InputStreamReader(is, encoding);
|
||||
BufferedReader reader = new BufferedReader(din);
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println("getInputStream " + line); //$NON-NLS-1$
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// nothing to do
|
||||
} finally {
|
||||
try {
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println("getInputStream " + line); //$NON-NLS-1$
|
||||
}
|
||||
is.close();
|
||||
} catch (Exception ex) {
|
||||
// nothing to do
|
||||
} finally {
|
||||
try {
|
||||
is.close();
|
||||
} catch (Exception ex) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
@@ -137,31 +132,23 @@ public final class ProcessStreamTrashReaderUtil {
|
||||
new Thread() {
|
||||
|
||||
public void run() {
|
||||
InputStream is = process.getErrorStream();
|
||||
InputStreamReader din = new InputStreamReader(is);
|
||||
BufferedReader reader = new BufferedReader(din);
|
||||
try {
|
||||
InputStream is = process.getErrorStream();
|
||||
InputStreamReader din = new InputStreamReader(is, encoding);
|
||||
BufferedReader reader = new BufferedReader(din);
|
||||
StringBuilder strBuilder = new StringBuilder();
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println("getErrorStream " + line); //$NON-NLS-1$
|
||||
throw new WarningException("AAAAA");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// nothing to do
|
||||
} finally {
|
||||
try {
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println("getErrorStream " + line); //$NON-NLS-1$
|
||||
strBuilder.append(line).append("\n");
|
||||
}
|
||||
is.close();
|
||||
} catch (Exception ex) {
|
||||
// nothing to do
|
||||
} finally {
|
||||
try {
|
||||
is.close();
|
||||
} catch (Exception ex) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
if (!strBuilder.toString().replaceAll("[\n]", " ").trim().isEmpty()) {
|
||||
throw new Exception(strBuilder.toString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
@@ -217,7 +204,7 @@ public final class ProcessStreamTrashReaderUtil {
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println("getErrorStream " + line); //$NON-NLS-1$
|
||||
if(line.startsWith("log4j:WARN") || line.startsWith("SLF4J:")){
|
||||
if(line.startsWith("log4j:WARN")){
|
||||
continue;
|
||||
}
|
||||
buffer.append(line);
|
||||
|
||||
@@ -19,14 +19,11 @@ import org.eclipse.emf.common.util.URI;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.exception.SystemException;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.updatesite.IUpdateSiteBean;
|
||||
|
||||
|
||||
/**
|
||||
* wchen class global comment. Detailled comment
|
||||
*/
|
||||
@@ -65,17 +62,4 @@ public interface ICoreTisService extends IService {
|
||||
public File getLicenseFile();
|
||||
|
||||
public String generateSignerSessionId();
|
||||
|
||||
public void afterImport (Property property) throws PersistenceException;
|
||||
|
||||
void updateSignature();
|
||||
|
||||
public static ICoreTisService get() {
|
||||
GlobalServiceRegister register = GlobalServiceRegister.getDefault();
|
||||
if (register.isServiceRegistered(ICoreTisService.class)) {
|
||||
return (ICoreTisService) register.getService(ICoreTisService.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -167,8 +167,6 @@ public class ProcessorUtilities {
|
||||
|
||||
private static boolean isDebug = false;
|
||||
|
||||
private static JobInfo mainJobInfo;
|
||||
|
||||
public static void addOpenEditor(IEditorPart editor) {
|
||||
openedEditors.add(editor);
|
||||
}
|
||||
@@ -437,7 +435,6 @@ public class ProcessorUtilities {
|
||||
|
||||
isMainJob = true;
|
||||
codeModified = false;
|
||||
mainJobInfo = jobInfo;
|
||||
|
||||
// this cache only keep the last main job's generation, so clear it since we regenerate a new job.
|
||||
LastGenerationInfo.getInstance().getLastGeneratedjobs().clear();
|
||||
@@ -510,7 +507,7 @@ public class ProcessorUtilities {
|
||||
mainRelation.setId(jobInfo.getJobId());
|
||||
mainRelation.setVersion(jobInfo.getJobVersion());
|
||||
mainRelation.setType(RelationshipItemBuilder.JOB_RELATION);
|
||||
hasLoopDependency = checkLoopDependencies(mainRelation, new HashMap<String, String>());
|
||||
hasLoopDependency = checkLoopDependencies(mainRelation);
|
||||
// clean the previous code in case it has deleted subjob
|
||||
cleanSourceFolder(progressMonitor, currentProcess, processor);
|
||||
}
|
||||
@@ -610,29 +607,28 @@ public class ProcessorUtilities {
|
||||
return processor;
|
||||
}
|
||||
|
||||
private static boolean checkLoopDependencies(Relation mainJobInfo, Map<String, String> idToLastestVersionMap)
|
||||
throws ProcessorException {
|
||||
List<Relation> itemsJobRelatedTo = getItemsRelation(mainJobInfo, idToLastestVersionMap);
|
||||
private static boolean checkLoopDependencies(Relation mainJobInfo) throws ProcessorException {
|
||||
List<Relation> itemsJobRelatedTo = getItemsRelation(mainJobInfo);
|
||||
List<Relation> relationChecked = new ArrayList<>();
|
||||
relationChecked.add(mainJobInfo);
|
||||
return checkLoopDependencies(mainJobInfo, itemsJobRelatedTo, relationChecked, idToLastestVersionMap);
|
||||
return checkLoopDependencies(mainJobInfo, itemsJobRelatedTo, relationChecked);
|
||||
}
|
||||
|
||||
private static boolean checkLoopDependencies(Relation mainRelation, List<Relation> itemsJobRelatedTo,
|
||||
List<Relation> relationChecked, Map<String, String> idToLastestVersionMap) throws ProcessorException {
|
||||
List<Relation> relationChecked) throws ProcessorException {
|
||||
boolean hasDependency = false;
|
||||
for (Relation relation : itemsJobRelatedTo) {
|
||||
hasDependency = relation.getId().equals(mainRelation.getId())
|
||||
&& relation.getVersion().equals(mainRelation.getVersion());
|
||||
if (!hasDependency) {
|
||||
List<Relation> itemsChildJob = getItemsRelation(relation, idToLastestVersionMap);
|
||||
List<Relation> itemsChildJob = getItemsRelation(relation);
|
||||
if (!relationChecked.contains(relation)) {
|
||||
relationChecked.add(relation);
|
||||
hasDependency = checkLoopDependencies(mainRelation, itemsChildJob, relationChecked, idToLastestVersionMap);
|
||||
hasDependency = checkLoopDependencies(mainRelation, itemsChildJob, relationChecked);
|
||||
}
|
||||
if (!hasDependency) {
|
||||
for (Relation childRelation : itemsChildJob) {
|
||||
hasDependency = checkLoopDependencies(childRelation, idToLastestVersionMap);
|
||||
hasDependency = checkLoopDependencies(childRelation);
|
||||
if (hasDependency) {
|
||||
break;
|
||||
}
|
||||
@@ -647,7 +643,7 @@ public class ProcessorUtilities {
|
||||
return hasDependency;
|
||||
}
|
||||
|
||||
private static List<Relation> getItemsRelation(Relation mainJobInfo, Map<String, String> idToLastestVersionMap) throws ProcessorException {
|
||||
private static List<Relation> getItemsRelation(Relation mainJobInfo) throws ProcessorException {
|
||||
List<Relation> itemsJobRelatedTo = new ArrayList<Relation>();
|
||||
try {
|
||||
List<Project> allProjects = new ArrayList<Project>();
|
||||
@@ -661,17 +657,12 @@ public class ProcessorUtilities {
|
||||
mainJobInfo.getType(), RelationshipItemBuilder.JOBLET_RELATION));
|
||||
for (Relation relation : itemsJobRelatedTo) {
|
||||
if (relation.getVersion().equals(RelationshipItemBuilder.LATEST_VERSION)) {
|
||||
if (idToLastestVersionMap.containsKey(relation.getId())) {
|
||||
relation.setVersion(idToLastestVersionMap.get(relation.getId()));
|
||||
} else {
|
||||
for (Project project : allProjects) {
|
||||
IRepositoryViewObject lastVersion =
|
||||
ProxyRepositoryFactory.getInstance().getLastVersion(project, relation.getId());
|
||||
if (lastVersion != null) {
|
||||
relation.setVersion(lastVersion.getVersion());
|
||||
idToLastestVersionMap.put(relation.getId(), relation.getVersion());
|
||||
break;
|
||||
}
|
||||
for (Project project : allProjects) {
|
||||
IRepositoryViewObject lastVersion =
|
||||
ProxyRepositoryFactory.getInstance().getLastVersion(project, relation.getId());
|
||||
if (lastVersion != null) {
|
||||
relation.setVersion(lastVersion.getVersion());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -959,7 +950,6 @@ public class ProcessorUtilities {
|
||||
if (jobInfo.getFatherJobInfo() == null) {
|
||||
isMainJob = true;
|
||||
codeModified = false;
|
||||
mainJobInfo = jobInfo;
|
||||
|
||||
// this cache only keep the last main job's generation, so clear it since we regenerate a new job.
|
||||
LastGenerationInfo.getInstance().getLastGeneratedjobs().clear();
|
||||
@@ -1027,7 +1017,7 @@ public class ProcessorUtilities {
|
||||
mainRelation.setId(jobInfo.getJobId());
|
||||
mainRelation.setVersion(jobInfo.getJobVersion());
|
||||
mainRelation.setType(RelationshipItemBuilder.JOB_RELATION);
|
||||
hasLoopDependency = checkLoopDependencies(mainRelation, new HashMap<String, String>());
|
||||
hasLoopDependency = checkLoopDependencies(mainRelation);
|
||||
// clean the previous code in case it has deleted subjob
|
||||
cleanSourceFolder(progressMonitor, currentProcess, processor);
|
||||
}
|
||||
@@ -1194,9 +1184,10 @@ public class ProcessorUtilities {
|
||||
IFolder srcFolder = processor.getTalendJavaProject().getProject().getFolder(codePath);
|
||||
String jobPackageFolder = JavaResourcesHelper.getJobClassPackageFolder(currentProcess);
|
||||
for (IResource resource : srcFolder.members()) {
|
||||
if (!resource.getProjectRelativePath().toPortableString().endsWith(jobPackageFolder)) {
|
||||
resource.delete(true, progressMonitor);
|
||||
if (resource.getProjectRelativePath().toPortableString().endsWith(jobPackageFolder)) {
|
||||
break;
|
||||
}
|
||||
resource.delete(true, progressMonitor);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
ExceptionHandler.process(e);
|
||||
@@ -1608,12 +1599,10 @@ public class ProcessorUtilities {
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
JobInfo jobInfo = new JobInfo(processName, contextName, version);
|
||||
IProcessor process = generateCode(jobInfo, contextName, statistics, trace, true, GENERATE_ALL_CHILDS, monitor);
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return process;
|
||||
}
|
||||
|
||||
@@ -1636,11 +1625,9 @@ public class ProcessorUtilities {
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor process = generateCode(jobInfo, contextName, statistics, trace, true, GENERATE_ALL_CHILDS, monitor);
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return process;
|
||||
}
|
||||
|
||||
@@ -1658,11 +1645,9 @@ public class ProcessorUtilities {
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor result = generateCode(jobInfo, contextName, statistics, trace, true, GENERATE_ALL_CHILDS, monitor);
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1680,12 +1665,10 @@ public class ProcessorUtilities {
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor result =
|
||||
generateCode(jobInfo, contextName, statistics, trace, needContext, GENERATE_ALL_CHILDS, monitor);
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1712,11 +1695,9 @@ public class ProcessorUtilities {
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor result = generateCode(jobInfo, contextName, statistics, trace, needContext, option, monitor);
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1737,11 +1718,9 @@ public class ProcessorUtilities {
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
result = generateCode(jobInfo, contextName, statistics, trace, true, GENERATE_ALL_CHILDS, monitor);
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1751,11 +1730,9 @@ public class ProcessorUtilities {
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor returnValue = generateCode(process, contextName, statistics, trace, false);
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@@ -1787,12 +1764,10 @@ public class ProcessorUtilities {
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor genCode = generateCode(jobInfo, context.getName(), statistics, trace, contextProperties,
|
||||
GENERATE_ALL_CHILDS, new NullProgressMonitor());
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return genCode;
|
||||
}
|
||||
|
||||
@@ -1801,12 +1776,10 @@ public class ProcessorUtilities {
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor returnValue =
|
||||
generateCode(process, context, statistics, trace, properties, new NullProgressMonitor());
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@@ -1838,12 +1811,10 @@ public class ProcessorUtilities {
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor genCode = generateCode(jobInfo, context.getName(), statistics, trace, properties,
|
||||
GENERATE_ALL_CHILDS, progressMonitor);
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return genCode;
|
||||
}
|
||||
|
||||
@@ -1889,12 +1860,10 @@ public class ProcessorUtilities {
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor genCode = generateCode(processor, jobInfo, context.getName(), statistics, trace, properties,
|
||||
GENERATE_ALL_CHILDS, progressMonitor);
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
|
||||
TimeMeasure.end(timeMeasureGenerateCodesId);
|
||||
// if active before, not disable and active still.
|
||||
@@ -1921,12 +1890,10 @@ public class ProcessorUtilities {
|
||||
jobList.clear();
|
||||
esbJobs.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
IProcessor genCode = generateCode(jobInfo, context.getName(), statistics, trace, properties, option,
|
||||
new NullProgressMonitor());
|
||||
jobList.clear();
|
||||
hasLoopDependency = false;
|
||||
mainJobInfo = null;
|
||||
return genCode;
|
||||
}
|
||||
|
||||
@@ -2183,7 +2150,7 @@ public class ProcessorUtilities {
|
||||
EList<NodeType> nodes = ptype.getNode();
|
||||
String jobletPaletteType = null;
|
||||
String frameWork = ptype.getFramework();
|
||||
if (StringUtils.isBlank(frameWork)) {
|
||||
if (frameWork == null) {
|
||||
jobletPaletteType = ComponentCategory.CATEGORY_4_DI.getName();
|
||||
} else if (frameWork.equals(HadoopConstants.FRAMEWORK_SPARK)) {
|
||||
jobletPaletteType = ComponentCategory.CATEGORY_4_SPARK.getName();
|
||||
@@ -2228,14 +2195,12 @@ public class ProcessorUtilities {
|
||||
ProcessItem processItem = ItemCacheManager.getProcessItem(jobId, jobVersion);
|
||||
if (processItem != null) {
|
||||
JobInfo jobInfo = new JobInfo(processItem, jobContext);
|
||||
jobInfos.add(jobInfo);
|
||||
JobInfo jobInfoFromSet = findJobInfo(jobInfos, jobInfo);
|
||||
boolean hasLoop = hasLoop(jobInfoFromSet);
|
||||
|
||||
jobInfo.setFatherJobInfo(parentJobInfo);
|
||||
jobInfoFromSet.setFatherJobInfo(parentJobInfo);
|
||||
if (!firstChildOnly && !hasLoop) {
|
||||
getAllJobInfo(processItem.getProcess(), jobInfo, jobInfos, firstChildOnly);
|
||||
if (!jobInfos.contains(jobInfo)) {
|
||||
jobInfos.add(jobInfo);
|
||||
jobInfo.setFatherJobInfo(parentJobInfo);
|
||||
if (!firstChildOnly) {
|
||||
getAllJobInfo(processItem.getProcess(), jobInfo, jobInfos, firstChildOnly);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2316,35 +2281,7 @@ public class ProcessorUtilities {
|
||||
return jobInfos;
|
||||
}
|
||||
|
||||
private static JobInfo findJobInfo(Set<JobInfo> jobInfos, JobInfo jobInfoToFind) {
|
||||
for (JobInfo jobInfo : jobInfos) {
|
||||
if (jobInfo.equals(jobInfoToFind)) {
|
||||
return jobInfo;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean hasLoop(JobInfo jobInfo) {
|
||||
|
||||
Set<String> jobInfoIds = new HashSet<String>();
|
||||
|
||||
JobInfo jobInfoCurr = jobInfo;
|
||||
|
||||
while(jobInfoCurr != null) {
|
||||
if (jobInfoIds.contains(jobInfoCurr.getJobId())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
jobInfoIds.add(jobInfoCurr.getJobId());
|
||||
|
||||
jobInfoCurr = jobInfoCurr.getFatherJobInfo();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isRouteletNode(NodeType node) {
|
||||
private static boolean isRouteletNode(NodeType node) {
|
||||
String jobIds = getParameterValue(node.getElementParameter(), "PROCESS_TYPE:PROCESS_TYPE_PROCESS");
|
||||
String jobVersion = getParameterValue(node.getElementParameter(), "PROCESS_TYPE:PROCESS_TYPE_VERSION"); //$NON-NLS-1$
|
||||
ProcessItem processItem = ItemCacheManager.getProcessItem(jobIds, jobVersion);
|
||||
@@ -2499,14 +2436,6 @@ public class ProcessorUtilities {
|
||||
return hasLoopDependency;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for mainJobInfo. <font color="red">Need to check null</font>
|
||||
*
|
||||
* @return the mainJobInfo
|
||||
*/
|
||||
public static JobInfo getMainJobInfo() {
|
||||
return mainJobInfo;
|
||||
}
|
||||
/**
|
||||
* The dynamic loading of the hadoop configuration library is supported in DI, MapReduce and Spark (batch and
|
||||
* streaming).
|
||||
@@ -2538,44 +2467,15 @@ public class ProcessorUtilities {
|
||||
return doSupportDynamicHadoopConfLoading(property) && !isExportAsOSGI();
|
||||
}
|
||||
|
||||
public static boolean isEsbJob(IProcess process) {
|
||||
return isEsbJob(process, false);
|
||||
}
|
||||
|
||||
public static boolean isEsbJob(String processId, String version) {
|
||||
return esbJobs.contains(esbJobKey(processId, version));
|
||||
}
|
||||
|
||||
public static boolean isEsbJob(IProcess process, boolean checkCurrentProcess) {
|
||||
|
||||
if (process instanceof IProcess2) {
|
||||
|
||||
if (checkCurrentProcess) {
|
||||
for (INode n : process.getGraphicalNodes()) {
|
||||
if (isEsbComponentName(n.getComponent().getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Set<JobInfo> infos = ProcessorUtilities.getChildrenJobInfo(((IProcess2) process).getProperty().getItem(), false);
|
||||
|
||||
for (JobInfo jobInfo : infos) {
|
||||
ProcessType processType = jobInfo.getProcessItem().getProcess();
|
||||
EList<NodeType> nodes = processType.getNode();
|
||||
for (NodeType nodeType : nodes) {
|
||||
if (isEsbComponentName(nodeType.getComponentName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void addEsbJob(JobInfo jobInfo) {
|
||||
if (esbJobs.contains(esbJobKey(jobInfo.getJobId(), jobInfo.getJobVersion()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
esbJobs.add(esbJobKey(jobInfo.getJobId(), jobInfo.getJobVersion()));
|
||||
if (jobInfo.getFatherJobInfo() != null) {
|
||||
addEsbJob(jobInfo.getFatherJobInfo());
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.eclipse.aether.util.artifact.SubArtifact;
|
||||
import org.eclipse.aether.util.listener.ChainedRepositoryListener;
|
||||
import org.eclipse.aether.util.listener.ChainedTransferListener;
|
||||
import org.eclipse.aether.util.repository.AuthenticationBuilder;
|
||||
import org.talend.designer.maven.aether.util.TalendAetherProxySelector;
|
||||
|
||||
/**
|
||||
* created by wchen on Aug 10, 2017 Detailled comment
|
||||
@@ -73,8 +72,6 @@ public class RepositorySystemFactory {
|
||||
.setLocalRepositoryManager(system.newLocalRepositoryManager(repositorySystemSession, localRepo));
|
||||
repositorySystemSession.setTransferListener(new ChainedTransferListener());
|
||||
repositorySystemSession.setRepositoryListener(new ChainedRepositoryListener());
|
||||
repositorySystemSession.setProxySelector(new TalendAetherProxySelector());
|
||||
sessions.put(localRepo, repositorySystemSession);
|
||||
}
|
||||
|
||||
return repositorySystemSession;
|
||||
@@ -110,7 +107,6 @@ public class RepositorySystemFactory {
|
||||
Authentication auth = new AuthenticationBuilder().addUsername(userName).addPassword(password).build();
|
||||
RemoteRepository distRepo = new RemoteRepository.Builder(repositoryId, "default", repositoryUrl).setAuthentication(auth)
|
||||
.build();
|
||||
distRepo = new RemoteRepository.Builder(distRepo).setProxy(new TalendAetherProxySelector().getProxy(distRepo)).build();
|
||||
|
||||
deployRequest.setRepository(distRepo);
|
||||
|
||||
|
||||
@@ -129,7 +129,6 @@ public class DynamicDistributionAetherUtils {
|
||||
builder = builder.setAuthentication(auth);
|
||||
}
|
||||
RemoteRepository central = builder.build();
|
||||
central = new RemoteRepository.Builder(central).setProxy(new TalendAetherProxySelector().getProxy(central)).build();
|
||||
|
||||
CollectRequest collectRequest = new CollectRequest();
|
||||
collectRequest.setRoot(dependency);
|
||||
@@ -181,7 +180,6 @@ public class DynamicDistributionAetherUtils {
|
||||
builder = builder.setAuthentication(auth);
|
||||
}
|
||||
RemoteRepository central = builder.build();
|
||||
central = new RemoteRepository.Builder(central).setProxy(new TalendAetherProxySelector().getProxy(central)).build();
|
||||
|
||||
VersionRangeRequest verRangeRequest = new VersionRangeRequest();
|
||||
verRangeRequest.addRepository(central);
|
||||
@@ -228,7 +226,6 @@ public class DynamicDistributionAetherUtils {
|
||||
builder = builder.setAuthentication(auth);
|
||||
}
|
||||
RemoteRepository central = builder.build();
|
||||
central = new RemoteRepository.Builder(central).setProxy(new TalendAetherProxySelector().getProxy(central)).build();
|
||||
|
||||
VersionRangeRequest verRangeRequest = new VersionRangeRequest();
|
||||
verRangeRequest.addRepository(central);
|
||||
@@ -302,7 +299,6 @@ public class DynamicDistributionAetherUtils {
|
||||
|
||||
LocalRepository localRepo = new LocalRepository(repositoryPath);
|
||||
session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
|
||||
session.setProxySelector(new TalendAetherProxySelector());
|
||||
|
||||
updateDependencySelector(session, monitor);
|
||||
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.maven.aether.util;
|
||||
|
||||
import org.eclipse.aether.repository.Authentication;
|
||||
import org.eclipse.aether.repository.Proxy;
|
||||
import org.eclipse.aether.repository.ProxySelector;
|
||||
import org.eclipse.aether.repository.RemoteRepository;
|
||||
import org.eclipse.aether.util.repository.AuthenticationBuilder;
|
||||
import org.eclipse.aether.util.repository.DefaultProxySelector;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.network.TalendProxySelector;
|
||||
|
||||
|
||||
/**
|
||||
* DOC cmeng class global comment. Detailled comment
|
||||
*/
|
||||
public class TalendAetherProxySelector implements ProxySelector {
|
||||
|
||||
private boolean isTalendDebug = false;
|
||||
|
||||
public TalendAetherProxySelector() {
|
||||
isTalendDebug = Boolean.valueOf(System.getProperty(TalendProxySelector.PROP_PRINT_LOGS, "false"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Proxy getProxy(RemoteRepository repository) {
|
||||
/**
|
||||
* Update each time in case the settings are changed
|
||||
*/
|
||||
Proxy proxy = createProxySelector().getProxy(repository);
|
||||
if (isTalendDebug) {
|
||||
try {
|
||||
if (repository != null) {
|
||||
String proxyStr = "";
|
||||
if (proxy != null) {
|
||||
proxyStr = proxy.getType() + " " + proxy.toString() + ", proxy user: "
|
||||
+ (proxy.getAuthentication() != null ? "..." : "<empty>");
|
||||
}
|
||||
ExceptionHandler.log("Aether proxy> host: " + repository.getHost() + ", proxy: " + proxyStr);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
|
||||
private DefaultProxySelector createProxySelector() {
|
||||
DefaultProxySelector proxySelector = new DefaultProxySelector();
|
||||
javaDefaultProxy(proxySelector);
|
||||
return proxySelector;
|
||||
}
|
||||
|
||||
private void javaDefaultProxy(DefaultProxySelector proxySelector) {
|
||||
String[] schemas = new String[] { "http", "https" };
|
||||
for (String schema : schemas) {
|
||||
Proxy proxy = createProxy(schema);
|
||||
if (proxy != null) {
|
||||
proxySelector.add(proxy, System.getProperty(schema + ".nonProxyHosts"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private org.eclipse.aether.repository.Proxy createProxy(String schema) {
|
||||
String proxyHost = System.getProperty(schema + ".proxyHost");
|
||||
if (proxyHost == null) {
|
||||
return null;
|
||||
}
|
||||
String proxyUser = System.getProperty(schema + ".proxyUser");
|
||||
String proxyPassword = System.getProperty(schema + ".proxyPassword");
|
||||
int proxyPort = Integer.parseInt(System.getProperty(schema + ".proxyPort", "8080"));
|
||||
|
||||
Authentication authentication = createAuthentication(proxyUser, proxyPassword);
|
||||
org.eclipse.aether.repository.Proxy proxyObj = new org.eclipse.aether.repository.Proxy(schema, proxyHost, proxyPort,
|
||||
authentication);
|
||||
return proxyObj;
|
||||
}
|
||||
|
||||
private Authentication createAuthentication(String proxyUser, String proxyPassword) {
|
||||
Authentication authentication = null;
|
||||
if (proxyUser != null) {
|
||||
authentication = new AuthenticationBuilder().addUsername(proxyUser).addPassword(proxyPassword).build();
|
||||
}
|
||||
return authentication;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,4 @@ ProjectPomProjectSettingPage_FilterPomLabel=Filter to use to generate poms:
|
||||
ProjectPomProjectSettingPage_FilterErrorMessage=Invalid filter: {0}
|
||||
ProjectPomProjectSettingPage.syncAllPomsButtonText=Force full re-synchronize poms
|
||||
AbstractPersistentProjectSettingPage.syncAllPoms=Do you want to update all poms? \n This operation might take long time depends on your project size.
|
||||
MavenProjectSettingPage.filterExampleMessage=Filter examples:\nlabel=myJob \t\t\t\t=> Generate only the job named "myJob"\n!(label=myJob) \t\t\t\t=> Generate any job except the one named "myJob"\n(path=folder1/folder2) \t\t\t=> Generate any job in the folder "folder1/folder2"\n(path=folder1/folder2)or(label=myJob)\t=> Generate any job in the folder "folder1/folder2" or named "myJob"\n(label=myJob)and(version=0.2) \t=> Generate only the job named "myJob" with version 0.2\n!((label=myJob)and(version=0.1)) \t=> Generate every jobs except the "myJob" version 0.1
|
||||
MavenProjectSettingPage.refModuleText=Set reference project modules in profile
|
||||
MavenProjectSettingPage.syncAllPomsWarning=Click the Force full re-synchronize poms button to apply the new settings.
|
||||
MavenProjectSettingPage.skipFolders=Skip folders
|
||||
MavenProjectSettingPage.filterExampleMessage=Filter examples:\nlabel=myJob \t\t\t\t=> Generate only the job named "myJob"\n!(label=myJob) \t\t\t\t=> Generate any job except the one named "myJob"\n(path=folder1/folder2) \t\t\t=> Generate any job in the folder "folder1/folder2"\n(path=folder1/folder2)or(label=myJob)\t=> Generate any job in the folder "folder1/folder2" or named "myJob"\n(label=myJob)and(version=0.2) \t=> Generate only the job named "myJob" with version 0.2\n!((label=myJob)and(version=0.1)) \t=> Generate every jobs except the "myJob" version 0.1
|
||||
@@ -14,7 +14,6 @@ package org.talend.designer.maven.ui;
|
||||
|
||||
import java.util.Dictionary;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
@@ -119,17 +118,6 @@ public class MavenUIService implements IMavenUIService {
|
||||
String studioUserSettingsFile = MavenPlugin.getMavenConfiguration().getUserSettingsFile();
|
||||
// apply the user settings to MavenResolver
|
||||
Dictionary<String, String> props = new Hashtable<String, String>();
|
||||
Set<Object> keySet = System.getProperties().keySet();
|
||||
if (keySet != null) {
|
||||
for (Object keyObj : keySet) {
|
||||
if (keyObj instanceof String) {
|
||||
String key = keyObj.toString();
|
||||
if (key.startsWith("org.ops4j.pax.url.mvn.")) {
|
||||
props.put(key, System.getProperty(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (studioUserSettingsFile != null && !"".equals(studioUserSettingsFile)) {
|
||||
// change back to use the user settings after Pax-url-eather fix the space bug
|
||||
props.put("org.ops4j.pax.url.mvn.settings", studioUserSettingsFile);
|
||||
|
||||
@@ -46,7 +46,6 @@ import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.commons.utils.time.TimeMeasure;
|
||||
import org.talend.core.runtime.projectsetting.IProjectSettingTemplateConstants;
|
||||
import org.talend.core.services.ICoreTisService;
|
||||
import org.talend.designer.maven.DesignerMavenPlugin;
|
||||
import org.talend.designer.maven.repository.DefaultMavenRepositoryProvider;
|
||||
import org.talend.designer.maven.template.MavenTemplateManager;
|
||||
@@ -230,14 +229,6 @@ public class M2eUserSettingForTalendLoginTask extends AbstractLoginTask {
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
} finally {
|
||||
try {
|
||||
ICoreTisService tisService = ICoreTisService.get();
|
||||
if (tisService != null) {
|
||||
tisService.updateSignature();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
TimeMeasure.end("M2eUserSettingForTalendLoginTask"); //$NON-NLS-1$
|
||||
TimeMeasure.display = false;
|
||||
TimeMeasure.displaySteps = false;
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.forms.IMessage;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.PluginChecker;
|
||||
@@ -47,10 +46,6 @@ public class MavenProjectSettingPage extends AbstractProjectSettingPage {
|
||||
|
||||
private IPreferenceStore preferenceStore;
|
||||
|
||||
private Button useProfileModuleCheckbox;
|
||||
|
||||
private Button skipFoldersCheckbox;
|
||||
|
||||
public MavenProjectSettingPage() {
|
||||
noDefaultAndApplyButton();
|
||||
}
|
||||
@@ -84,28 +79,6 @@ public class MavenProjectSettingPage extends AbstractProjectSettingPage {
|
||||
filterExampleLable.setText(Messages.getString("MavenProjectSettingPage.filterExampleMessage")); //$NON-NLS-1$
|
||||
filterExampleLable.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
||||
|
||||
useProfileModuleCheckbox = new Button(parent, SWT.CHECK);
|
||||
useProfileModuleCheckbox.setText(Messages.getString("MavenProjectSettingPage.refModuleText")); //$NON-NLS-1$
|
||||
useProfileModuleCheckbox.setSelection(preferenceStore.getBoolean(MavenConstants.USE_PROFILE_MODULE));
|
||||
useProfileModuleCheckbox.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
addSyncWarning();
|
||||
}
|
||||
});
|
||||
|
||||
skipFoldersCheckbox = new Button(parent, SWT.CHECK);
|
||||
skipFoldersCheckbox.setText(Messages.getString("MavenProjectSettingPage.skipFolders")); //$NON-NLS-1$
|
||||
skipFoldersCheckbox.setSelection(preferenceStore.getBoolean(MavenConstants.SKIP_FOLDERS));
|
||||
skipFoldersCheckbox.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
addSyncWarning();
|
||||
}
|
||||
});
|
||||
|
||||
filterText.setText(filter);
|
||||
filterText.addModifyListener(new ModifyListener() {
|
||||
|
||||
@@ -136,7 +109,6 @@ public class MavenProjectSettingPage extends AbstractProjectSettingPage {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
try {
|
||||
preferenceStore.setValue(MavenConstants.POM_FILTER, filter);
|
||||
preferenceStore.setValue(MavenConstants.USE_PROFILE_MODULE, useProfileModuleCheckbox.getSelection());
|
||||
new AggregatorPomsHelper().syncAllPoms();
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
@@ -150,17 +122,11 @@ public class MavenProjectSettingPage extends AbstractProjectSettingPage {
|
||||
|
||||
}
|
||||
|
||||
private void addSyncWarning() {
|
||||
setMessage(Messages.getString("MavenProjectSettingPage.syncAllPomsWarning"), IMessage.WARNING); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performOk() {
|
||||
boolean ok = super.performOk();
|
||||
if (preferenceStore != null) {
|
||||
preferenceStore.setValue(MavenConstants.POM_FILTER, filter);
|
||||
preferenceStore.setValue(MavenConstants.USE_PROFILE_MODULE, useProfileModuleCheckbox.getSelection());
|
||||
preferenceStore.setValue(MavenConstants.SKIP_FOLDERS, skipFoldersCheckbox.getSelection());
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -393,13 +393,8 @@ public abstract class MavenCommandLauncher {
|
||||
public void waitFinish(ILaunch launch) {
|
||||
|
||||
try {
|
||||
boolean isCommandLine = CommonsPlugin.isHeadless();
|
||||
while (!launchFinished) {
|
||||
if (isCommandLine) {
|
||||
Thread.sleep(100);
|
||||
} else {
|
||||
waitStudioFinish();
|
||||
}
|
||||
Thread.sleep(100);
|
||||
// if terminated also
|
||||
if (launch.getProcesses() != null && launch.getProcesses().length > 0) {
|
||||
if (launch.getProcesses()[0].isTerminated()) {
|
||||
@@ -414,16 +409,5 @@ public abstract class MavenCommandLauncher {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void waitStudioFinish() throws InterruptedException {
|
||||
org.eclipse.swt.widgets.Display display = org.eclipse.swt.widgets.Display.getCurrent();
|
||||
if (display != null) {
|
||||
if (!display.readAndDispatch()) {
|
||||
display.sleep();
|
||||
}
|
||||
} else {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,29 +12,17 @@
|
||||
// ============================================================================
|
||||
package org.talend.designer.maven.tools;
|
||||
|
||||
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_AGGREGATORS;
|
||||
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_BEANS;
|
||||
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_CODES;
|
||||
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_JOBS;
|
||||
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_PIGUDFS;
|
||||
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_POMS;
|
||||
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_ROUTINES;
|
||||
import static org.talend.designer.maven.model.TalendJavaProjectConstants.*;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.maven.model.Activation;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
@@ -61,6 +49,7 @@ import org.talend.core.context.Context;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
import org.talend.core.model.general.ILibrariesService;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.process.ProcessUtils;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.ProjectReference;
|
||||
@@ -81,7 +70,6 @@ import org.talend.core.runtime.services.IFilterService;
|
||||
import org.talend.core.ui.ITestContainerProviderService;
|
||||
import org.talend.designer.core.ICamelDesignerCoreService;
|
||||
import org.talend.designer.maven.launch.MavenPomCommandLauncher;
|
||||
import org.talend.designer.maven.model.MavenSystemFolders;
|
||||
import org.talend.designer.maven.model.TalendJavaProjectConstants;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.template.MavenTemplateManager;
|
||||
@@ -115,25 +103,27 @@ public class AggregatorPomsHelper {
|
||||
return projectTechName;
|
||||
}
|
||||
|
||||
public void createRootPom(Model model, boolean force, IProgressMonitor monitor)
|
||||
throws Exception {
|
||||
public void createRootPom(List<String> modules, boolean force, IProgressMonitor monitor) throws Exception {
|
||||
IFile pomFile = getProjectRootPom();
|
||||
if (force || !pomFile.exists()) {
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
parameters.put(MavenTemplateManager.KEY_PROJECT_NAME, projectTechName);
|
||||
Model model = MavenTemplateManager.getCodeProjectTemplateModel(parameters);
|
||||
if (modules != null && !modules.isEmpty()) {
|
||||
model.setModules(modules);
|
||||
}
|
||||
PomUtil.savePom(monitor, model, pomFile);
|
||||
}
|
||||
}
|
||||
|
||||
public void createRootPom(IProgressMonitor monitor) throws Exception {
|
||||
Model newModel = getCodeProjectTemplateModel();
|
||||
IFile pomFile = getProjectRootPom();
|
||||
List<String> modules = null;
|
||||
if (pomFile != null && pomFile.exists()) {
|
||||
Model oldModel = MavenPlugin.getMavenModelManager().readMavenModel(pomFile);
|
||||
List<Profile> profiles = oldModel.getProfiles().stream()
|
||||
.filter(profile -> matchModuleProfile(profile.getId(), projectTechName)).collect(Collectors.toList());
|
||||
newModel.setModules(oldModel.getModules());
|
||||
newModel.getProfiles().addAll(profiles);
|
||||
Model model = MavenPlugin.getMavenModelManager().readMavenModel(pomFile);
|
||||
modules = model.getModules();
|
||||
}
|
||||
createRootPom(newModel, true, monitor);
|
||||
createRootPom(modules, true, monitor);
|
||||
}
|
||||
|
||||
public void installRootPom(boolean force) throws Exception {
|
||||
@@ -192,14 +182,7 @@ public class AggregatorPomsHelper {
|
||||
private void updateCodeProject(IProgressMonitor monitor, ERepositoryObjectType codeType, boolean forceBuild) {
|
||||
try {
|
||||
ITalendProcessJavaProject codeProject = getCodesProject(codeType);
|
||||
IFile pomFile;
|
||||
if (codeProject == null) {
|
||||
// try to recover from any damage of pom.
|
||||
pomFile = getCodeFolder(codeType).getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
} else {
|
||||
pomFile = codeProject.getProjectPom();
|
||||
}
|
||||
updateCodeProjectPom(monitor, codeType, pomFile);
|
||||
updateCodeProjectPom(monitor, codeType, codeProject.getProjectPom());
|
||||
buildAndInstallCodesProject(monitor, codeType, true, forceBuild);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
@@ -300,40 +283,37 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRefProjectModules(List<ProjectReference> references, IProgressMonitor monitor) {
|
||||
public void updateRefProjectModules(List<ProjectReference> references) {
|
||||
if (!needUpdateRefProjectModules()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Model model = MavenPlugin.getMavenModelManager().readMavenModel(getProjectRootPom());
|
||||
if (PomIdsHelper.useProfileModule()) {
|
||||
List<Profile> profiles = collectRefProjectProfiles(references);
|
||||
Iterator<Profile> iterator = model.getProfiles().listIterator();
|
||||
while (iterator.hasNext()) {
|
||||
Profile profile = iterator.next();
|
||||
if (matchModuleProfile(profile.getId(), projectTechName)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
model.getProfiles().addAll(profiles);
|
||||
} else {
|
||||
List<String> refPrjectModules = new ArrayList<>();
|
||||
references.forEach(reference -> {
|
||||
String refProjectTechName = reference.getReferencedProject().getTechnicalLabel();
|
||||
String modulePath = "../../" + refProjectTechName + "/" + TalendJavaProjectConstants.DIR_POMS; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
refPrjectModules.add(modulePath);
|
||||
});
|
||||
List<String> modules = model.getModules();
|
||||
Iterator<String> iterator = modules.listIterator();
|
||||
while (iterator.hasNext()) {
|
||||
String modulePath = iterator.next();
|
||||
if (modulePath.startsWith("../../")) { //$NON-NLS-1$
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
modules.addAll(refPrjectModules);
|
||||
List<String> modules = new ArrayList<>();
|
||||
for (ProjectReference reference : references) {
|
||||
String refProjectTechName = reference.getReferencedProject().getTechnicalLabel();
|
||||
String modulePath = "../../" + refProjectTechName + "/" + TalendJavaProjectConstants.DIR_POMS; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
modules.add(modulePath);
|
||||
}
|
||||
createRootPom(model, true, monitor);
|
||||
|
||||
Project mainProject = ProjectManager.getInstance().getCurrentProject();
|
||||
IFolder mainPomsFolder = new AggregatorPomsHelper(mainProject.getTechnicalLabel()).getProjectPomsFolder();
|
||||
IFile mainPomFile = mainPomsFolder.getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
|
||||
Model model = MavenPlugin.getMavenModelManager().readMavenModel(mainPomFile);
|
||||
List<String> oldModules = model.getModules();
|
||||
if (oldModules == null) {
|
||||
oldModules = new ArrayList<>();
|
||||
}
|
||||
ListIterator<String> iterator = oldModules.listIterator();
|
||||
while (iterator.hasNext()) {
|
||||
String modulePath = iterator.next();
|
||||
if (modulePath.startsWith("../../")) { //$NON-NLS-1$
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
oldModules.addAll(modules);
|
||||
|
||||
PomUtil.savePom(null, model, mainPomFile);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
@@ -507,10 +487,6 @@ public class AggregatorPomsHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
public IFolder getCodeSrcFolder(ERepositoryObjectType codeType) {
|
||||
return getCodeFolder(codeType).getFolder(MavenSystemFolders.JAVA.getPath());
|
||||
}
|
||||
|
||||
public IFolder getProcessFolder(ERepositoryObjectType type) {
|
||||
return getProjectPomsFolder().getFolder(DIR_JOBS).getFolder(type.getFolder());
|
||||
}
|
||||
@@ -541,16 +517,9 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* without create/open project<br/>
|
||||
* Use Function to get the relativePath from property at realtime, since the property may be changed
|
||||
* without create/open project
|
||||
*/
|
||||
public static IFolder getItemPomFolder(Property property, String realVersion, Function<Property, IPath> getItemRelativePath) {
|
||||
return getItemPomFolder(property, ProjectManager.getInstance().getProject(property).getTechnicalLabel(), realVersion,
|
||||
getItemRelativePath);
|
||||
}
|
||||
|
||||
public static IFolder getItemPomFolder(Property property, String projectTechName, String realVersion,
|
||||
Function<Property, IPath> getItemRelativePath) {
|
||||
public static IFolder getItemPomFolder(Property property, String realVersion) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
|
||||
ITestContainerProviderService testContainerService =
|
||||
(ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(
|
||||
@@ -566,25 +535,17 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
String projectTechName = ProjectManager.getInstance().getProject(property).getTechnicalLabel();
|
||||
AggregatorPomsHelper helper = new AggregatorPomsHelper(projectTechName);
|
||||
IPath itemRelativePath = getItemRelativePath.apply(property);
|
||||
IPath itemRelativePath = ItemResourceUtil.getItemRelativePath(property);
|
||||
String version = realVersion == null ? property.getVersion() : realVersion;
|
||||
String jobFolderName = getJobProjectFolderName(property.getLabel(), version);
|
||||
ERepositoryObjectType type = ERepositoryObjectType.getItemType(property.getItem());
|
||||
IFolder jobFolder = null;
|
||||
if (PomIdsHelper.skipFolders()) {
|
||||
jobFolder = helper.getProcessFolder(type).getFolder(jobFolderName);
|
||||
} else {
|
||||
jobFolder = helper.getProcessFolder(type).getFolder(itemRelativePath).getFolder(jobFolderName);
|
||||
}
|
||||
IFolder jobFolder = helper.getProcessFolder(type).getFolder(itemRelativePath).getFolder(jobFolderName);
|
||||
createFoldersIfNeeded(jobFolder);
|
||||
return jobFolder;
|
||||
}
|
||||
|
||||
public static IFolder getItemPomFolder(Property property, String realVersion) {
|
||||
return getItemPomFolder(property, realVersion, p -> ItemResourceUtil.getItemRelativePath(p));
|
||||
}
|
||||
|
||||
private static void createFoldersIfNeeded(IFolder folder) {
|
||||
if (!folder.exists()) {
|
||||
if (folder.getParent() instanceof IFolder) {
|
||||
@@ -710,23 +671,6 @@ public class AggregatorPomsHelper {
|
||||
new ProgressMonitorDialog(Display.getDefault().getActiveShell()).run(true, true, runnableWithProgress);
|
||||
}
|
||||
|
||||
public void syncParentJobPomsForPropertyChange(Property property) {
|
||||
IRunProcessService runProcessService = getRunProcessService();
|
||||
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
List<Relation> itemsHaveRelationWith = RelationshipItemBuilder.getInstance().getItemsHaveRelationWith(property.getId(),
|
||||
property.getVersion());
|
||||
try {
|
||||
for (Relation relation : itemsHaveRelationWith) {
|
||||
IRepositoryViewObject object = factory.getSpecificVersion(relation.getId(), relation.getVersion(), true);
|
||||
if (runProcessService != null) {
|
||||
runProcessService.generatePom(object.getProperty().getItem());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String getModulePath(IFile pomFile) {
|
||||
IFile parentPom = getProjectRootPom();
|
||||
if (parentPom != null) {
|
||||
@@ -736,48 +680,47 @@ public class AggregatorPomsHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<Profile> collectRefProjectProfiles(List<ProjectReference> references) throws CoreException {
|
||||
if (!needUpdateRefProjectModules()) {
|
||||
Model model = MavenPlugin.getMavenModelManager().readMavenModel(getProjectRootPom());
|
||||
List<Profile> profiles = model.getProfiles();
|
||||
return profiles.stream().filter(profile -> matchModuleProfile(profile.getId(), projectTechName))
|
||||
.collect(Collectors.toList());
|
||||
private void collectModules(List<String> modules) {
|
||||
IRunProcessService service = getRunProcessService();
|
||||
if (service != null) {
|
||||
modules.add(
|
||||
getModulePath(service.getTalendCodeJavaProject(ERepositoryObjectType.ROUTINES).getProjectPom()));
|
||||
if (ProcessUtils.isRequiredPigUDFs(null)) {
|
||||
modules.add(
|
||||
getModulePath(service.getTalendCodeJavaProject(ERepositoryObjectType.PIG_UDF).getProjectPom()));
|
||||
}
|
||||
if (ProcessUtils.isRequiredBeans(null)) {
|
||||
modules.add(getModulePath(service
|
||||
.getTalendCodeJavaProject(ERepositoryObjectType.valueOf("BEANS")) //$NON-NLS-1$
|
||||
.getProjectPom()));
|
||||
}
|
||||
}
|
||||
if (references == null) {
|
||||
references = ProjectManager.getInstance().getCurrentProject().getProjectReferenceList(true);
|
||||
if (needUpdateRefProjectModules()) {
|
||||
List<ProjectReference> references =
|
||||
ProjectManager.getInstance().getCurrentProject().getProjectReferenceList(true);
|
||||
for (ProjectReference reference : references) {
|
||||
String refProjectTechName = reference.getReferencedProject().getTechnicalLabel();
|
||||
String modulePath = "../../" + refProjectTechName + "/" + TalendJavaProjectConstants.DIR_POMS; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
modules.add(modulePath);
|
||||
}
|
||||
} else {
|
||||
Project mainProject = ProjectManager.getInstance().getCurrentProject();
|
||||
IFolder mainPomsFolder = new AggregatorPomsHelper(mainProject.getTechnicalLabel()).getProjectPomsFolder();
|
||||
IFile mainPomFile = mainPomsFolder.getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
try {
|
||||
Model model = MavenPlugin.getMavenModelManager().readMavenModel(mainPomFile);
|
||||
List<String> oldModules = model.getModules();
|
||||
if (oldModules != null) {
|
||||
for (String modulePath : oldModules) {
|
||||
if (modulePath.startsWith("../../")) { //$NON-NLS-1$
|
||||
modules.add(modulePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
List<Profile> profiles = new ArrayList<>();
|
||||
references.forEach(reference -> {
|
||||
String refProjectTechName = reference.getReferencedProject().getTechnicalLabel();
|
||||
String modulePath = "../../" + refProjectTechName + "/" + TalendJavaProjectConstants.DIR_POMS; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
Profile profile = new Profile();
|
||||
profile.setId((projectTechName + "_" + refProjectTechName).toLowerCase()); //$NON-NLS-1$
|
||||
Activation activation = new Activation();
|
||||
activation.setActiveByDefault(true);
|
||||
profile.setActivation(activation);
|
||||
profile.getModules().add(modulePath);
|
||||
profiles.add(profile);
|
||||
});
|
||||
return profiles;
|
||||
}
|
||||
|
||||
private List<String> collectRefProjectModules(List<ProjectReference> references) throws CoreException {
|
||||
if (!needUpdateRefProjectModules()) {
|
||||
Model model = MavenPlugin.getMavenModelManager().readMavenModel(getProjectRootPom());
|
||||
return model.getModules().stream().filter(modulePath -> modulePath.startsWith("../../")) //$NON-NLS-1$
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
if (references == null) {
|
||||
references = ProjectManager.getInstance().getCurrentProject().getProjectReferenceList(true);
|
||||
}
|
||||
List<String> modules = new ArrayList<>();
|
||||
references.forEach(reference -> {
|
||||
String refProjectTechName = reference.getReferencedProject().getTechnicalLabel();
|
||||
String modulePath = "../../" + refProjectTechName + "/" + TalendJavaProjectConstants.DIR_POMS; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
modules.add(modulePath);
|
||||
});
|
||||
return modules;
|
||||
|
||||
}
|
||||
|
||||
public boolean needUpdateRefProjectModules() {
|
||||
@@ -815,13 +758,7 @@ public class AggregatorPomsHelper {
|
||||
monitor.beginTask("", size); //$NON-NLS-1$
|
||||
// project pom
|
||||
monitor.subTask("Synchronize project pom"); //$NON-NLS-1$
|
||||
Model model = getCodeProjectTemplateModel();
|
||||
if (PomIdsHelper.useProfileModule()) {
|
||||
model.getProfiles().addAll(collectRefProjectProfiles(null));
|
||||
} else {
|
||||
model.getModules().addAll(collectRefProjectModules(null));
|
||||
}
|
||||
createRootPom(model, true, monitor);
|
||||
createRootPom(null, true, monitor);
|
||||
installRootPom(true);
|
||||
monitor.worked(1);
|
||||
if (monitor.isCanceled()) {
|
||||
@@ -874,9 +811,8 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
// sync project pom again with all modules.
|
||||
monitor.subTask("Synchronize project pom with modules"); //$NON-NLS-1$
|
||||
collectCodeModules(modules);
|
||||
model.getModules().addAll(modules);
|
||||
createRootPom(model, true, monitor);
|
||||
collectModules(modules);
|
||||
createRootPom(modules, true, monitor);
|
||||
installRootPom(true);
|
||||
monitor.worked(1);
|
||||
if (monitor.isCanceled()) {
|
||||
@@ -885,21 +821,6 @@ public class AggregatorPomsHelper {
|
||||
monitor.done();
|
||||
}
|
||||
|
||||
private void collectCodeModules(List<String> modules) {
|
||||
// collect codes modules
|
||||
IRunProcessService service = getRunProcessService();
|
||||
if (service != null) {
|
||||
modules.add(getModulePath(service.getTalendCodeJavaProject(ERepositoryObjectType.ROUTINES).getProjectPom()));
|
||||
if (ProcessUtils.isRequiredPigUDFs(null)) {
|
||||
modules.add(getModulePath(service.getTalendCodeJavaProject(ERepositoryObjectType.PIG_UDF).getProjectPom()));
|
||||
}
|
||||
if (ProcessUtils.isRequiredBeans(null)) {
|
||||
modules.add(getModulePath(service.getTalendCodeJavaProject(ERepositoryObjectType.valueOf("BEANS")) //$NON-NLS-1$
|
||||
.getProjectPom()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if is a esb data service job
|
||||
*
|
||||
@@ -928,18 +849,6 @@ public class AggregatorPomsHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Model getCodeProjectTemplateModel() {
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
parameters.put(MavenTemplateManager.KEY_PROJECT_NAME, projectTechName);
|
||||
return MavenTemplateManager.getCodeProjectTemplateModel(parameters);
|
||||
}
|
||||
|
||||
public static boolean matchModuleProfile(String profileId, String projectTechName) {
|
||||
// FIXME get profile id from extension point.
|
||||
List<String> otherProfiles = Arrays.asList("docker", "cloud-publisher", "nexus"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
return !otherProfiles.contains(profileId) && StringUtils.startsWithIgnoreCase(profileId, projectTechName + "_");
|
||||
}
|
||||
|
||||
private static IRunProcessService getRunProcessService() {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
IRunProcessService runProcessService =
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Set;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
@@ -46,6 +47,7 @@ import org.talend.designer.maven.utils.MavenProjectUtils;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
import org.talend.designer.runprocess.IRunProcessService;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.model.IRepositoryService;
|
||||
|
||||
/**
|
||||
* DOC zwxue class global comment. Detailled comment
|
||||
@@ -269,7 +271,6 @@ public class BuildCacheManager {
|
||||
|
||||
public void clearAllCaches() {
|
||||
jobCache.clear();
|
||||
clearCurrentJobletCache();
|
||||
jobletCache.clear();
|
||||
codesLastBuildCache.clear();
|
||||
}
|
||||
@@ -329,9 +330,38 @@ public class BuildCacheManager {
|
||||
}
|
||||
|
||||
private String getModulePath(Property property) {
|
||||
String modulePath = null;
|
||||
IPath basePath = null;
|
||||
IPath jobProjectPath = AggregatorPomsHelper.getItemPomFolder(property).getLocation();
|
||||
IPath basePath = getAggregatorPomsHelper().getProjectPomsFolder().getLocation();
|
||||
String modulePath = jobProjectPath.makeRelativeTo(basePath).toPortableString();
|
||||
ProjectManager proManager = ProjectManager.getInstance();
|
||||
if (!proManager.isInCurrentMainProject(property)) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRepositoryService.class)) {
|
||||
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault()
|
||||
.getService(IRepositoryService.class);
|
||||
if (service.isGIT()) {
|
||||
String refProjectTechName = proManager.getCurrentProject().getTechnicalLabel();
|
||||
String mainProjectBranch = proManager.getMainProjectBranch(refProjectTechName);
|
||||
if ("master".equals(mainProjectBranch)) {
|
||||
modulePath = "../../../../"; //$NON-NLS-1$
|
||||
} else {
|
||||
modulePath = "../../../../../"; //$NON-NLS-1$
|
||||
}
|
||||
basePath = ResourcesPlugin.getWorkspace().getRoot().getLocation().append("/.repositories"); //$NON-NLS-1$
|
||||
} else if (service.isSVN()) {
|
||||
modulePath = "../../"; //$NON-NLS-1$
|
||||
basePath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
|
||||
}
|
||||
}
|
||||
if (modulePath == null || basePath == null) {
|
||||
throw new RuntimeException("modulePath or basePath can not be null!"); //$NON-NLS-1$
|
||||
}
|
||||
} else {
|
||||
modulePath = ""; //$NON-NLS-1$
|
||||
basePath = getAggregatorPomsHelper().getProjectPomsFolder().getLocation();
|
||||
}
|
||||
jobProjectPath = jobProjectPath.makeRelativeTo(basePath);
|
||||
modulePath += jobProjectPath.toPortableString();
|
||||
|
||||
return modulePath;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,13 @@ public class ProjectPomManager {
|
||||
if (monitor == null) {
|
||||
monitor = new NullProgressMonitor();
|
||||
}
|
||||
new AggregatorPomsHelper().createRootPom(monitor);
|
||||
Model projectModel = MODEL_MANAGER.readMavenModel(projectPomFile);
|
||||
Model templateModel = MavenTemplateManager.getCodeProjectTemplateModel();
|
||||
for (String module : projectModel.getModules()) {
|
||||
templateModel.addModule(module);
|
||||
}
|
||||
|
||||
PomUtil.savePom(monitor, templateModel, projectPomFile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,14 +45,12 @@ import org.talend.core.model.utils.JavaResourcesHelper;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenConstants;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
import org.talend.core.runtime.process.LastGenerationInfo;
|
||||
import org.talend.core.runtime.projectsetting.IProjectSettingTemplateConstants;
|
||||
import org.talend.core.runtime.repository.build.IMavenPomCreator;
|
||||
import org.talend.core.ui.ITestContainerProviderService;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.template.ETalendMavenVariables;
|
||||
import org.talend.designer.maven.tools.ProcessorDependenciesManager;
|
||||
import org.talend.designer.maven.utils.JobUtils;
|
||||
import org.talend.designer.maven.utils.PomIdsHelper;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
import org.talend.designer.runprocess.IBigDataProcessor;
|
||||
@@ -135,15 +133,9 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
|
||||
|
||||
Map<ETalendMavenVariables, String> variablesValuesMap = new HashMap<ETalendMavenVariables, String>();
|
||||
// no need check property is null or not, because if null, will get default ids.
|
||||
JobInfo lastMainJob = LastGenerationInfo.getInstance().getLastMainJob();
|
||||
if (JobUtils.isJob(property) && ProcessUtils.isChildRouteProcess(process) && lastMainJob != null) {
|
||||
variablesValuesMap.put(ETalendMavenVariables.JobGroupId, PomIdsHelper.getJobGroupId(lastMainJob.getProcessor().getProperty()));
|
||||
variablesValuesMap.put(ETalendMavenVariables.JobVersion, PomIdsHelper.getJobVersion(lastMainJob.getProcessor().getProperty()));
|
||||
}else {
|
||||
variablesValuesMap.put(ETalendMavenVariables.JobGroupId, PomIdsHelper.getJobGroupId(property));
|
||||
variablesValuesMap.put(ETalendMavenVariables.JobVersion, PomIdsHelper.getJobVersion(property));
|
||||
}
|
||||
variablesValuesMap.put(ETalendMavenVariables.JobGroupId, PomIdsHelper.getJobGroupId(property));
|
||||
variablesValuesMap.put(ETalendMavenVariables.JobArtifactId, PomIdsHelper.getJobArtifactId(property));
|
||||
variablesValuesMap.put(ETalendMavenVariables.JobVersion, PomIdsHelper.getJobVersion(property));
|
||||
variablesValuesMap.put(ETalendMavenVariables.TalendJobVersion, property.getVersion());
|
||||
final String jobName = JavaResourcesHelper.escapeFileName(process.getName());
|
||||
variablesValuesMap.put(ETalendMavenVariables.JobName, jobName);
|
||||
@@ -290,15 +282,9 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
|
||||
String type = null;
|
||||
if (!jobInfo.isJoblet()) {
|
||||
property = jobInfo.getProcessItem().getProperty();
|
||||
groupId = PomIdsHelper.getJobGroupId(property);
|
||||
artifactId = PomIdsHelper.getJobArtifactId(jobInfo);
|
||||
JobInfo lastMainJob = LastGenerationInfo.getInstance().getLastMainJob();
|
||||
if (lastMainJob != null && JobUtils.isJob(jobInfo) && JobUtils.isRoute(getJobProcessor().getProperty())) {
|
||||
groupId = PomIdsHelper.getJobGroupId(lastMainJob.getProcessor().getProperty());
|
||||
version = PomIdsHelper.getJobVersion(lastMainJob.getProcessor().getProperty());
|
||||
} else {
|
||||
groupId = PomIdsHelper.getJobGroupId(property);
|
||||
version = PomIdsHelper.getJobVersion(property);
|
||||
}
|
||||
version = PomIdsHelper.getJobVersion(property);
|
||||
// try to get the pom version of children job and load from the pom file.
|
||||
String childPomFileName = PomUtil.getPomFileName(jobInfo.getJobName(), jobInfo.getJobVersion());
|
||||
IProject codeProject = getJobProcessor().getCodeProject();
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
@@ -56,7 +55,6 @@ import org.talend.core.model.process.ProcessUtils;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.properties.Project;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.utils.JavaResourcesHelper;
|
||||
import org.talend.core.repository.utils.ItemResourceUtil;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
@@ -77,7 +75,6 @@ import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.template.ETalendMavenVariables;
|
||||
import org.talend.designer.maven.template.MavenTemplateManager;
|
||||
import org.talend.designer.maven.utils.JobUtils;
|
||||
import org.talend.designer.maven.utils.PomIdsHelper;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
import org.talend.designer.runprocess.IProcessor;
|
||||
@@ -206,12 +203,15 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
}
|
||||
}
|
||||
|
||||
// same as JavaProcessor.initCodePath
|
||||
String jobClassPackageFolder = JavaResourcesHelper.getJobClassPackageFolder(property.getItem());
|
||||
|
||||
Project project = ProjectManager.getInstance().getProject(property);
|
||||
if (project == null) { // current project
|
||||
project = ProjectManager.getInstance().getCurrentProject().getEmfProject();
|
||||
}
|
||||
String talendJobPath = project.getTechnicalLabel().toLowerCase();
|
||||
checkPomProperty(properties, "talend.job.path", ETalendMavenVariables.JobPath, talendJobPath);
|
||||
|
||||
checkPomProperty(properties, "talend.job.path", ETalendMavenVariables.JobPath, jobClassPackageFolder);
|
||||
IPath jobFolderPath = ItemResourceUtil.getItemRelativePath(property);
|
||||
String jobFolder = "";
|
||||
if (jobFolderPath != null && !StringUtils.isEmpty(jobFolderPath.toPortableString())) {
|
||||
@@ -561,7 +561,6 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
"${talend.job.bat.addition}" },
|
||||
new String[] { jvmArgsStr.toString().trim(), getWindowsClasspath(), jobClass,
|
||||
windowsScriptAdditionValue.toString() });
|
||||
batContent = normalizeSpaces(batContent);
|
||||
|
||||
String shContent = MavenTemplateManager.getProjectSettingValue(IProjectSettingPreferenceConstants.TEMPLATE_SH,
|
||||
templateParameters);
|
||||
@@ -570,7 +569,6 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
"${talend.job.sh.addition}" },
|
||||
new String[] { jvmArgsStr.toString().trim(), getUnixClasspath(), jobClass,
|
||||
unixScriptAdditionValue.toString() });
|
||||
shContent = normalizeSpaces(shContent);
|
||||
|
||||
String psContent = MavenTemplateManager.getProjectSettingValue(IProjectSettingPreferenceConstants.TEMPLATE_PS,
|
||||
templateParameters);
|
||||
@@ -579,7 +577,6 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
"${talend.job.bat.addition}" },
|
||||
new String[] { jvmArgsStrPs1.toString().trim(), getWindowsClasspathForPs1(), jobClass,
|
||||
windowsScriptAdditionValue.toString() });
|
||||
psContent = normalizeSpaces(psContent);
|
||||
|
||||
String jobInfoContent = MavenTemplateManager
|
||||
.getProjectSettingValue(IProjectSettingPreferenceConstants.TEMPLATE_JOB_INFO, templateParameters);
|
||||
@@ -598,10 +595,7 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
mainProjectBranch = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isOptionChecked(TalendProcessArgumentConstant.ARG_AVOID_BRANCH_NAME)) {
|
||||
jobInfoContent = StringUtils.replace(jobInfoContent, "${talend.project.branch}", mainProjectBranch);
|
||||
}
|
||||
jobInfoContent = StringUtils.replace(jobInfoContent, "${talend.project.branch}", mainProjectBranch);
|
||||
|
||||
IFolder templateFolder = codeProject.getTemplatesFolder();
|
||||
IFile shFile = templateFolder.getFile(IProjectSettingTemplateConstants.JOB_RUN_SH_TEMPLATE_FILE_NAME);
|
||||
@@ -614,66 +608,31 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
MavenTemplateManager.saveContent(psFile, psContent, overwrite);
|
||||
MavenTemplateManager.saveContent(infoFile, jobInfoContent, overwrite);
|
||||
}
|
||||
|
||||
// https://jira.talendforge.org/browse/TUP-27053
|
||||
// https://jira.talendforge.org/browse/TUP-24422(Also fix the carriage return issue in Windows)
|
||||
public static String normalizeSpaces(String src) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
try (Scanner scanner = new Scanner(src)) {
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
line = StringUtils.normalizeSpace(line.trim());
|
||||
if (!line.isEmpty()) {
|
||||
sb.append(line);
|
||||
}
|
||||
sb.append('\n');
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected void updateDependencySet(IFile assemblyFile) {
|
||||
Map<String, Dependency> jobCoordinateMap = new HashMap<String, Dependency>();
|
||||
Set<String> jobCoordinate = new HashSet<>();
|
||||
Set<JobInfo> childrenJobInfo = new HashSet<>();
|
||||
childrenJobInfo = getJobProcessor().getBuildChildrenJobs();
|
||||
if (!hasLoopDependency()) {
|
||||
// add children jobs
|
||||
for (JobInfo jobInfo : childrenJobInfo) {
|
||||
Property property = jobInfo.getProcessItem().getProperty();
|
||||
String coordinate = getCoordinate(PomIdsHelper.getJobGroupId(property), PomIdsHelper.getJobArtifactId(jobInfo),
|
||||
MavenConstants.PACKAGING_JAR, PomIdsHelper.getJobVersion(property), null);
|
||||
String groupId = null;
|
||||
String version = null;
|
||||
IProcessor jobProcessor = getJobProcessor();
|
||||
if (JobUtils.isJob(jobInfo) && jobProcessor !=null && JobUtils.isRoute(getJobProcessor().getProperty())) {
|
||||
groupId = PomIdsHelper.getJobGroupId(jobProcessor.getProperty());
|
||||
version = PomIdsHelper.getJobVersion(jobProcessor.getProperty());
|
||||
}else {
|
||||
groupId = PomIdsHelper.getJobGroupId(property);
|
||||
version = PomIdsHelper.getJobVersion(property);
|
||||
}
|
||||
Dependency dependency = PomUtil.createDependency(groupId,
|
||||
PomIdsHelper.getJobArtifactId(jobInfo), version,
|
||||
MavenConstants.PACKAGING_JAR);
|
||||
jobCoordinateMap.put(coordinate, dependency);
|
||||
}
|
||||
childrenJobInfo = getJobProcessor().getBuildChildrenJobs();
|
||||
}
|
||||
|
||||
// add children jobs
|
||||
for (JobInfo jobInfo : childrenJobInfo) {
|
||||
Property property = jobInfo.getProcessItem().getProperty();
|
||||
String coordinate = getCoordinate(PomIdsHelper.getJobGroupId(property), PomIdsHelper.getJobArtifactId(jobInfo),
|
||||
MavenConstants.PACKAGING_JAR, PomIdsHelper.getJobVersion(property));
|
||||
jobCoordinate.add(coordinate);
|
||||
}
|
||||
|
||||
// add parent job
|
||||
Property parentProperty = this.getJobProcessor().getProperty();
|
||||
String parentCoordinate =
|
||||
getCoordinate(PomIdsHelper.getJobGroupId(parentProperty), PomIdsHelper.getJobArtifactId(parentProperty),
|
||||
MavenConstants.PACKAGING_JAR, PomIdsHelper.getJobVersion(parentProperty), null);
|
||||
Dependency parentDependency = PomUtil.createDependency(PomIdsHelper.getJobGroupId(parentProperty),
|
||||
PomIdsHelper.getJobArtifactId(parentProperty), PomIdsHelper.getJobVersion(parentProperty),
|
||||
MavenConstants.PACKAGING_JAR);
|
||||
jobCoordinateMap.put(parentCoordinate, parentDependency);
|
||||
String parentCoordinate = getCoordinate(PomIdsHelper.getJobGroupId(parentProperty),
|
||||
PomIdsHelper.getJobArtifactId(parentProperty), MavenConstants.PACKAGING_JAR,
|
||||
PomIdsHelper.getJobVersion(parentProperty));
|
||||
jobCoordinate.add(parentCoordinate);
|
||||
|
||||
// add talend libraries and codes
|
||||
Map<String, Dependency> talendLibCoordinateMap = new HashMap<String, Dependency>();
|
||||
Set<String> talendLibCoordinate = new HashSet<>();
|
||||
String projectTechName = ProjectManager.getInstance().getProject(parentProperty).getTechnicalLabel();
|
||||
String projectGroupId = PomIdsHelper.getProjectGroupId(projectTechName);
|
||||
|
||||
@@ -681,7 +640,7 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
List<Dependency> dependencies = new ArrayList<>();
|
||||
addCodesDependencies(dependencies);
|
||||
for (Dependency dependency : dependencies) {
|
||||
talendLibCoordinateMap.put(getCoordinate(dependency), dependency);
|
||||
talendLibCoordinate.add(getCoordinate(dependency));
|
||||
}
|
||||
|
||||
// libraries
|
||||
@@ -700,23 +659,23 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
}
|
||||
String dependencyGroupId = dependency.getGroupId();
|
||||
String coordinate = getCoordinate(dependency);
|
||||
if (!jobCoordinateMap.containsKey(coordinate)) {
|
||||
if (!jobCoordinate.contains(coordinate)) {
|
||||
if (MavenConstants.DEFAULT_LIB_GROUP_ID.equals(dependencyGroupId)) {
|
||||
talendLibCoordinateMap.put(coordinate, dependency);
|
||||
talendLibCoordinate.add(coordinate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add 3rd party libraries
|
||||
Map<String, Dependency> _3rdDepLibMap = new HashMap<String, Dependency>();
|
||||
Set<String> _3rdDepLib = new HashSet<>();
|
||||
Map<String, Set<Dependency>> duplicateLibs = new HashMap<>();
|
||||
for (Dependency dependency : dependencies) {
|
||||
if (MavenConstants.PACKAGING_POM.equals(dependency.getType())) {
|
||||
continue;
|
||||
}
|
||||
String coordinate = getCoordinate(dependency);
|
||||
if (!jobCoordinateMap.containsKey(coordinate) && !talendLibCoordinateMap.containsKey(coordinate)) {
|
||||
_3rdDepLibMap.put(coordinate, dependency);
|
||||
if (!jobCoordinate.contains(coordinate) && !talendLibCoordinate.contains(coordinate)) {
|
||||
_3rdDepLib.add(coordinate);
|
||||
addToDuplicateLibs(duplicateLibs, dependency);
|
||||
}
|
||||
}
|
||||
@@ -733,40 +692,20 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
}
|
||||
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(moduleNeeded.getMavenUri());
|
||||
String coordinate = getCoordinate(artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(),
|
||||
artifact.getVersion(), artifact.getClassifier());
|
||||
if (!jobCoordinateMap.containsKey(coordinate) && !talendLibCoordinateMap.containsKey(coordinate)
|
||||
&& !_3rdDepLibMap.containsKey(coordinate)) {
|
||||
Dependency dependencyObject = PomUtil.createDependency(artifact.getGroupId(), artifact.getArtifactId(),
|
||||
artifact.getVersion(), artifact.getType(), artifact.getClassifier());
|
||||
artifact.getVersion());
|
||||
if (!jobCoordinate.contains(coordinate) && !talendLibCoordinate.contains(coordinate)
|
||||
&& !_3rdDepLib.contains(coordinate)) {
|
||||
if (MavenConstants.DEFAULT_LIB_GROUP_ID.equals(artifact.getGroupId())
|
||||
|| artifact.getGroupId().startsWith(projectGroupId)) {
|
||||
talendLibCoordinateMap.put(coordinate, dependencyObject);
|
||||
talendLibCoordinate.add(coordinate);
|
||||
} else {
|
||||
_3rdDepLibMap.put(coordinate, dependencyObject);
|
||||
Dependency dependency = PomUtil
|
||||
.createDependency(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
|
||||
artifact.getType(), artifact.getClassifier());
|
||||
_3rdDepLib.add(coordinate);
|
||||
Dependency dependency = PomUtil.createDependency(artifact.getGroupId(), artifact.getArtifactId(),
|
||||
artifact.getVersion(), artifact.getType(), artifact.getClassifier());
|
||||
addToDuplicateLibs(duplicateLibs, dependency);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Set<Dependency> codesDependencies = new HashSet<Dependency>();
|
||||
for (ERepositoryObjectType type : ERepositoryObjectType.getAllTypesOfCodes()) {
|
||||
codesDependencies.addAll(PomUtil.getCodesDependencies(type));
|
||||
}
|
||||
for (Dependency codeDependency : codesDependencies) {
|
||||
Dependency dependency = PomUtil.createDependency(codeDependency.getGroupId(), codeDependency.getArtifactId(),
|
||||
codeDependency.getVersion(), codeDependency.getType(), codeDependency.getClassifier());
|
||||
if (dependency != null) {
|
||||
addToDuplicateLibs(duplicateLibs, dependency);
|
||||
}
|
||||
}
|
||||
} catch (CoreException e1) {
|
||||
ExceptionHandler.process(e1);
|
||||
}
|
||||
|
||||
|
||||
Iterator<String> iterator = duplicateLibs.keySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
@@ -778,7 +717,7 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
} else {
|
||||
// remove duplicated dependencies from 3rd lib list
|
||||
for (Dependency dependency : dupDependencies) {
|
||||
_3rdDepLibMap.remove(getCoordinate(dependency));
|
||||
_3rdDepLib.remove(getCoordinate(dependency));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -786,13 +725,12 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
try {
|
||||
Document document = PomUtil.loadAssemblyFile(null, assemblyFile);
|
||||
// add talend libs & codes
|
||||
setupDependencySetNode(document, talendLibCoordinateMap, "lib", "${artifact.artifactId}.${artifact.extension}",
|
||||
false, false);
|
||||
setupDependencySetNode(document, talendLibCoordinate, "lib", "${artifact.artifactId}.${artifact.extension}", false);
|
||||
// add 3rd party libs <dependencySet>
|
||||
setupDependencySetNode(document, _3rdDepLibMap, "lib", null, false, false);
|
||||
setupDependencySetNode(document, _3rdDepLib, "lib", null, false);
|
||||
// add jobs
|
||||
setupDependencySetNode(document, jobCoordinateMap, "${talend.job.name}",
|
||||
"${artifact.build.finalName}.${artifact.extension}", true, false);
|
||||
setupDependencySetNode(document, jobCoordinate, "${talend.job.name}",
|
||||
"${artifact.build.finalName}.${artifact.extension}", true);
|
||||
// add duplicate dependencies if exists
|
||||
setupFileNode(document, duplicateLibs);
|
||||
|
||||
@@ -803,50 +741,24 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
}
|
||||
|
||||
private String getCoordinate(Dependency dependency) {
|
||||
return getCoordinate(dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(),
|
||||
dependency.getVersion(), dependency.getClassifier());
|
||||
return getCoordinate(dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(), dependency.getVersion());
|
||||
}
|
||||
|
||||
protected String getCoordinate(String groupId, String artifactId, String type, String version, String classifier) {
|
||||
protected String getCoordinate(String groupId, String artifactId, String type, String version) {
|
||||
String separator = ":"; //$NON-NLS-1$
|
||||
String coordinate = groupId + separator;
|
||||
coordinate += artifactId + separator;
|
||||
if (type != null) {
|
||||
coordinate += type;
|
||||
}
|
||||
|
||||
if (version != null) {
|
||||
coordinate += separator + version;
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(classifier)) {
|
||||
coordinate += separator + classifier;
|
||||
}
|
||||
|
||||
return coordinate;
|
||||
}
|
||||
|
||||
protected String getAssemblyCoordinate(Dependency dependency) {
|
||||
String separator = ":"; //$NON-NLS-1$
|
||||
String coordinate = dependency.getGroupId() + separator;
|
||||
coordinate += dependency.getArtifactId() + separator;
|
||||
if (dependency.getType() != null) {
|
||||
coordinate += dependency.getType();
|
||||
}
|
||||
if (dependency.getClassifier() != null) {
|
||||
coordinate += separator + "*";
|
||||
}
|
||||
if (dependency.getVersion() != null) {
|
||||
coordinate += separator + dependency.getVersion();
|
||||
}
|
||||
|
||||
return coordinate;
|
||||
}
|
||||
|
||||
private void addToDuplicateLibs(Map<String, Set<Dependency>> map, Dependency dependency) {
|
||||
String coordinate =
|
||||
getCoordinate(dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(), null,
|
||||
dependency.getClassifier());
|
||||
String coordinate = getCoordinate(dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(), null);
|
||||
if (!map.containsKey(coordinate)) {
|
||||
Set<Dependency> set = new HashSet<>();
|
||||
map.put(coordinate, set);
|
||||
@@ -854,8 +766,8 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
map.get(coordinate).add(dependency);
|
||||
}
|
||||
|
||||
protected void setupDependencySetNode(Document document, Map<String, Dependency> libIncludes, String outputDir,
|
||||
String fileNameMapping, boolean useProjectArtifact, boolean unpack) {
|
||||
protected void setupDependencySetNode(Document document, Set<String> libIncludes, String outputDir, String fileNameMapping,
|
||||
boolean useProjectArtifact) {
|
||||
if (libIncludes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -866,18 +778,16 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
Node dependencySetNode = document.createElement("dependencySet");
|
||||
dependencySetsNode.appendChild(dependencySetNode);
|
||||
|
||||
if (StringUtils.isNotBlank(outputDir)) {
|
||||
Node outputDirNode = document.createElement("outputDirectory");
|
||||
outputDirNode.setTextContent(outputDir);
|
||||
dependencySetNode.appendChild(outputDirNode);
|
||||
}
|
||||
Node outputDirNode = document.createElement("outputDirectory");
|
||||
outputDirNode.setTextContent(outputDir);
|
||||
dependencySetNode.appendChild(outputDirNode);
|
||||
|
||||
Node includesNode = document.createElement("includes");
|
||||
dependencySetNode.appendChild(includesNode);
|
||||
|
||||
for (Dependency dependency : libIncludes.values()) {
|
||||
for (String include : libIncludes) {
|
||||
Node includeNode = document.createElement("include");
|
||||
includeNode.setTextContent(getAssemblyCoordinate(dependency));
|
||||
includeNode.setTextContent(include);
|
||||
includesNode.appendChild(includeNode);
|
||||
}
|
||||
|
||||
@@ -891,12 +801,6 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
useProjectArtifactNode.setTextContent(Boolean.toString(useProjectArtifact));
|
||||
dependencySetNode.appendChild(useProjectArtifactNode);
|
||||
|
||||
if (unpack) {
|
||||
Node unpackNode = document.createElement("unpack");
|
||||
unpackNode.setTextContent(Boolean.TRUE.toString());
|
||||
dependencySetNode.appendChild(unpackNode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setupFileNode(Document document, Map<String, Set<Dependency>> duplicateDependencies) {
|
||||
|
||||
@@ -123,9 +123,7 @@ public class CreateMavenJobletPom extends AbstractMavenProcessorPom {
|
||||
@Override
|
||||
protected void addDependencies(Model model) {
|
||||
try {
|
||||
if (ERepositoryObjectType.JOBLET == ERepositoryObjectType.getType(getJobProcessor().getProperty())) {
|
||||
getProcessorDependenciesManager().updateDependencies(null, model);
|
||||
}
|
||||
getProcessorDependenciesManager().updateDependencies(null, model);
|
||||
addChildrenDependencies(model.getDependencies());
|
||||
} catch (ProcessorException e) {
|
||||
ExceptionHandler.process(e);
|
||||
|
||||
@@ -18,12 +18,12 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.PluginExecution;
|
||||
@@ -213,34 +213,28 @@ public class CreateMavenStandardJobOSGiPom extends CreateMavenJobPom {
|
||||
|
||||
@Override
|
||||
protected void updateDependencySet(IFile assemblyFile) {
|
||||
Map<String, Dependency> jobCoordinateMap = new HashMap<String, Dependency>();
|
||||
Set<String> jobCoordinate = new HashSet<>();
|
||||
if (!hasLoopDependency()) {
|
||||
// add children jobs
|
||||
Set<JobInfo> childrenJobInfo = getJobProcessor().getBuildChildrenJobs();
|
||||
for (JobInfo jobInfo : childrenJobInfo) {
|
||||
Property property = jobInfo.getProcessItem().getProperty();
|
||||
String coordinate = getCoordinate(PomIdsHelper.getJobGroupId(property), PomIdsHelper.getJobArtifactId(jobInfo),
|
||||
MavenConstants.PACKAGING_JAR, PomIdsHelper.getJobVersion(property), null);
|
||||
Dependency dependency = PomUtil.createDependency(PomIdsHelper.getJobGroupId(property),
|
||||
PomIdsHelper.getJobArtifactId(jobInfo), PomIdsHelper.getJobVersion(property),
|
||||
MavenConstants.PACKAGING_JAR);
|
||||
jobCoordinateMap.put(coordinate, dependency);
|
||||
MavenConstants.PACKAGING_JAR, PomIdsHelper.getJobVersion(property));
|
||||
jobCoordinate.add(coordinate);
|
||||
}
|
||||
}
|
||||
// add parent job
|
||||
Property parentProperty = this.getJobProcessor().getProperty();
|
||||
String parentCoordinate = getCoordinate(PomIdsHelper.getJobGroupId(parentProperty),
|
||||
PomIdsHelper.getJobArtifactId(parentProperty), MavenConstants.PACKAGING_JAR,
|
||||
PomIdsHelper.getJobVersion(parentProperty), null);
|
||||
Dependency parentDependency = PomUtil.createDependency(PomIdsHelper.getJobGroupId(parentProperty),
|
||||
PomIdsHelper.getJobArtifactId(parentProperty), PomIdsHelper.getJobVersion(parentProperty),
|
||||
MavenConstants.PACKAGING_JAR);
|
||||
jobCoordinateMap.put(parentCoordinate, parentDependency);
|
||||
PomIdsHelper.getJobVersion(parentProperty));
|
||||
jobCoordinate.add(parentCoordinate);
|
||||
try {
|
||||
Document document = PomUtil.loadAssemblyFile(null, assemblyFile);
|
||||
// add jobs
|
||||
setupDependencySetNode(document, jobCoordinateMap, null, "${artifact.build.finalName}.${artifact.extension}", true,
|
||||
true);
|
||||
setupDependencySetNode(document, jobCoordinate, "${talend.job.name}",
|
||||
"${artifact.build.finalName}.${artifact.extension}", true);
|
||||
PomUtil.saveAssemblyFile(assemblyFile, document);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
|
||||
@@ -24,8 +24,6 @@ import org.talend.core.model.process.JobInfo;
|
||||
import org.talend.core.model.process.ProcessUtils;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.model.utils.JavaResourcesHelper;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
@@ -100,28 +98,4 @@ public class JobUtils {
|
||||
return clonedJobInfos;
|
||||
}
|
||||
|
||||
public static boolean isRoute(Property p) {
|
||||
if (p != null) {
|
||||
return ERepositoryObjectType.getType(p).equals(ERepositoryObjectType.PROCESS_ROUTE);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isJob(JobInfo job) {
|
||||
if (job != null && job.getProcessItem() != null) {
|
||||
Property p = job.getProcessItem().getProperty();
|
||||
if (p != null) {
|
||||
return isJob(p);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isJob(Property p) {
|
||||
if (p != null) {
|
||||
return ERepositoryObjectType.getType(p).equals(ERepositoryObjectType.PROCESS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -260,12 +260,6 @@ public class PomIdsHelper {
|
||||
return manager.getValue(MavenConstants.POM_FILTER);
|
||||
}
|
||||
|
||||
public static boolean useProfileModule() {
|
||||
String projectTechName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
ProjectPreferenceManager manager = getPreferenceManager(projectTechName);
|
||||
return manager.getBoolean(MavenConstants.USE_PROFILE_MODULE);
|
||||
}
|
||||
|
||||
private static String getGroupId(String projectTechName, String baseName, Property property) {
|
||||
if (projectTechName == null) {
|
||||
projectTechName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
@@ -304,12 +298,6 @@ public class PomIdsHelper {
|
||||
return PREFIX_DEFAULT_GROUPID + projectName.toLowerCase();
|
||||
}
|
||||
|
||||
public static boolean skipFolders() {
|
||||
String projectTechName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
ProjectPreferenceManager manager = getPreferenceManager(projectTechName);
|
||||
return manager.getBoolean(MavenConstants.SKIP_FOLDERS);
|
||||
}
|
||||
|
||||
public static boolean isValidGroupId(String text) {
|
||||
if (text != null && text.matches("[\\w\\.]+")) { //$NON-NLS-1$
|
||||
return true;
|
||||
|
||||
@@ -27,12 +27,10 @@ import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
@@ -80,7 +78,6 @@ import org.talend.core.model.process.JobInfo;
|
||||
import org.talend.core.model.process.ProcessUtils;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.utils.JavaResourcesHelper;
|
||||
import org.talend.core.nexus.TalendMavenResolver;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
@@ -93,7 +90,6 @@ import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.template.MavenTemplateManager;
|
||||
import org.talend.designer.maven.tools.ProcessorDependenciesManager;
|
||||
import org.talend.designer.runprocess.IProcessor;
|
||||
import org.talend.designer.runprocess.IRunProcessService;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
@@ -120,9 +116,7 @@ public class PomUtil {
|
||||
if (pomFile == null) {
|
||||
throw new NullPointerException("the output file is null.");
|
||||
}
|
||||
Properties properties = new Properties();
|
||||
properties.putAll(model.getProperties());
|
||||
model.setProperties(properties);
|
||||
|
||||
/*
|
||||
* copied the codes from createMavenModel of MavenModelManager
|
||||
*/
|
||||
@@ -144,9 +138,7 @@ public class PomUtil {
|
||||
if (pomFile == null) {
|
||||
throw new NullPointerException("the output file is null.");
|
||||
}
|
||||
Properties properties = new Properties();
|
||||
properties.putAll(model.getProperties());
|
||||
model.setProperties(properties);
|
||||
|
||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||
MavenPlugin.getMaven().writeModel(model, buf);
|
||||
|
||||
@@ -1025,34 +1017,4 @@ public class PomUtil {
|
||||
|| pathname.getName().equals("m2e-lastUpdated.properties"); //$NON-NLS-1$
|
||||
}
|
||||
};
|
||||
|
||||
public static boolean checkIfJobDependencyExist(IFile parentJobPom, Property property) throws Exception {
|
||||
boolean found = false;
|
||||
Model model = MavenPlugin.getMavenModelManager().readMavenModel(parentJobPom);
|
||||
String groupId = PomIdsHelper.getJobGroupId(property);
|
||||
String artifactId = PomIdsHelper.getJobArtifactId(property);
|
||||
String version = PomIdsHelper.getJobVersion(property);
|
||||
for (Dependency dependency : model.getDependencies()) {
|
||||
if (dependency.getGroupId().equals(groupId) && dependency.getArtifactId().equals(artifactId)
|
||||
&& dependency.getVersion().equals(version)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
public static Set<Dependency> getCodesDependencies(ERepositoryObjectType codeType) throws CoreException {
|
||||
Set<Dependency> dependencies = new HashSet<Dependency>();
|
||||
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
IRunProcessService runProcessService = (IRunProcessService) GlobalServiceRegister.getDefault()
|
||||
.getService(IRunProcessService.class);
|
||||
ITalendProcessJavaProject talendCodeJavaProject = runProcessService.getTalendCodeJavaProject(codeType);
|
||||
IFile projectPom = talendCodeJavaProject.getProjectPom();
|
||||
Model model = MODEL_MANAGER.readMavenModel(projectPom);
|
||||
dependencies.addAll(model.getDependencies());
|
||||
}
|
||||
return dependencies;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,37 +10,4 @@ public class SortableDependency extends Dependency implements Comparable<Sortabl
|
||||
return getArtifactId().compareTo(o.getArtifactId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
result = 31 * result + (getGroupId() == null ? 0 : getGroupId().hashCode());
|
||||
result = 31 * result + (getArtifactId() == null ? 0 : getArtifactId().hashCode());
|
||||
result = 31 * result + (getVersion() == null ? 0 : getVersion().hashCode());
|
||||
result = 31 * result + (getType() == null ? 0 : getType().hashCode());
|
||||
result = 31 * result + (getClassifier() == null ? 0 : getClassifier().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof SortableDependency)) {
|
||||
return false;
|
||||
}
|
||||
SortableDependency caseobj = (SortableDependency) obj;
|
||||
|
||||
return (getGroupId() == caseobj.getGroupId() || (getGroupId() != null && getGroupId().equals(caseobj.getGroupId())))
|
||||
&& (getArtifactId() == caseobj.getArtifactId()
|
||||
|| (getArtifactId() != null && getArtifactId().equals(caseobj.getArtifactId())))
|
||||
&& (getVersion() == caseobj.getVersion() || (getVersion() != null && getVersion().equals(caseobj.getVersion())))
|
||||
&& (getType() == caseobj.getType() || (getType() != null && getType().equals(caseobj.getType())))
|
||||
&& (getClassifier() == caseobj.getClassifier()
|
||||
|| (getClassifier() != null && getClassifier().equals(caseobj.getClassifier())));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,17 +14,12 @@ package org.talend.librariesmanager.ui.startup;
|
||||
|
||||
import org.eclipse.ui.IStartup;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import org.talend.librariesmanager.prefs.LibrariesManagerUtils;
|
||||
|
||||
/**
|
||||
* created by wchen on 2015-6-15 Detailled comment
|
||||
*
|
||||
*/
|
||||
public class ShareLibsSynchronizer implements IStartup {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(ShareLibsSynchronizer.class.getCanonicalName());
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -32,11 +27,8 @@ public class ShareLibsSynchronizer implements IStartup {
|
||||
*/
|
||||
@Override
|
||||
public void earlyStartup() {
|
||||
if (LibrariesManagerUtils.shareLibsAtStartup()) {
|
||||
ShareLibsJob job = new ShareLibsJob();
|
||||
job.schedule();
|
||||
} else {
|
||||
LOGGER.info("Skip sharing libraries");
|
||||
}
|
||||
ShareLibsJob job = new ShareLibsJob();
|
||||
job.schedule();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
@@ -41,7 +40,6 @@ import org.talend.utils.io.FilesUtils;
|
||||
*/
|
||||
public class ShareMavenArtifactsOnStartup extends ShareLibrareisHelper {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(ShareMavenArtifactsOnStartup.class);
|
||||
@Override
|
||||
public Map<ModuleNeeded, File> getFilesToShare(IProgressMonitor monitor) {
|
||||
Map<ModuleNeeded, File> files = new HashMap<ModuleNeeded, File>();
|
||||
@@ -94,7 +92,6 @@ public class ShareMavenArtifactsOnStartup extends ShareLibrareisHelper {
|
||||
FilesUtils.copyFile(generatedPom, pomFile);
|
||||
FilesUtils.deleteFolder(generatedPom.getParentFile(), true);
|
||||
}
|
||||
LOGGER.info("ShareMavenArtifactsOnStartup, shareToRepository, file: " + file);
|
||||
deployer.deploy(file, artifact);
|
||||
// artifact.setType(MavenConstants.PACKAGING_POM);
|
||||
// deployer.deploy(pomFile, artifact);
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
package org.talend.librariesmanager.utils;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -48,8 +47,6 @@ abstract public class DownloadModuleRunnable implements IRunnableWithProgress {
|
||||
|
||||
private boolean checkLibraries;
|
||||
|
||||
private boolean showErrorInDialog = true;
|
||||
|
||||
/**
|
||||
* DOC sgandon DownloadModuleRunnable constructor comment.
|
||||
*
|
||||
@@ -133,13 +130,6 @@ abstract public class DownloadModuleRunnable implements IRunnableWithProgress {
|
||||
downloadFailed.add(module.getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (showErrorInDialog && !downloadFailed.isEmpty()) {
|
||||
Exception ex = new Exception(Messages.getString("DownloadModuleRunnable.jar.download.failed",
|
||||
Arrays.toString(downloadFailed.toArray(new String[downloadFailed.size()]))));
|
||||
MessageBoxExceptionHandler.process(ex);
|
||||
}
|
||||
|
||||
if (checkLibraries) {
|
||||
ILibrariesService librariesService = (ILibrariesService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibrariesService.class);
|
||||
|
||||
@@ -58,22 +58,11 @@ public class JDBCUtil {
|
||||
}
|
||||
|
||||
public static Date getDate(ResultSet rs, int index) throws java.sql.SQLException {
|
||||
Date result = null;
|
||||
try {
|
||||
if(rs.getTimestamp(index) != null) {
|
||||
result = new Date(rs.getTimestamp(index).getTime());
|
||||
return result;
|
||||
}
|
||||
} catch (java.sql.SQLException e) {
|
||||
if(rs.getTimestamp(index) != null) {
|
||||
return new Date(rs.getTimestamp(index).getTime());
|
||||
}
|
||||
try {
|
||||
if(rs.getDate(index) != null) {
|
||||
result = new Date(rs.getDate(index).getTime());
|
||||
return result;
|
||||
}
|
||||
} catch (java.sql.SQLException e) {
|
||||
}
|
||||
return result;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//decrease the get method call number
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
// Copyright (C) 2006-2018 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
@@ -75,6 +75,4 @@ public class PasswordEncryptUtil {
|
||||
return input;
|
||||
}
|
||||
|
||||
public static final String PASSWORD_FOR_LOGS_VALUE = "...";
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,5 @@ ModulesNeededProvider.Module.Exception=Needed module list do not contains this m
|
||||
|
||||
ShareLibsJob.message=Share libraries from maven to {0} server
|
||||
ShareLibsJob.sharingLibraries=Sharing libraries : {0}
|
||||
ShareLibsJob.monitor.cancelled=User cancelled.
|
||||
|
||||
ExtensionModuleManager.moduleGroup.cycleReference=Module group {0} was cycle referenced!
|
||||
@@ -14,30 +14,25 @@ package org.talend.librariesmanager.maven;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.nexus.IRepositoryArtifactHandler;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.nexus.RepositoryArtifactHandlerManager;
|
||||
import org.talend.core.nexus.TalendLibsServerManager;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
import org.talend.librariesmanager.i18n.Messages;
|
||||
import org.talend.librariesmanager.model.service.LocalLibraryManager;
|
||||
import org.talend.librariesmanager.nexus.utils.ShareLibrariesUtil;
|
||||
|
||||
/**
|
||||
* created by Talend on 2015年7月31日 Detailled comment
|
||||
@@ -47,7 +42,6 @@ public abstract class ShareLibrareisHelper {
|
||||
|
||||
private final String TYPE_NEXUS = "nexus";
|
||||
|
||||
private final Logger LOGGER = Logger.getLogger(ShareLibrareisHelper.class);
|
||||
protected MavenArtifactsHandler deployer = new MavenArtifactsHandler();
|
||||
|
||||
public IStatus shareLibs(Job job, IProgressMonitor monitor) {
|
||||
@@ -55,126 +49,80 @@ public abstract class ShareLibrareisHelper {
|
||||
IStatus status = Status.OK_STATUS;
|
||||
// deploy to maven if needed and share to custom nexus
|
||||
try {
|
||||
int searchLimit = 50;
|
||||
setJobName(job, Messages.getString("ShareLibsJob.message", TYPE_NEXUS));
|
||||
final List<MavenArtifact> searchResults = new ArrayList<MavenArtifact>();
|
||||
ArtifactRepositoryBean customNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer();
|
||||
IRepositoryArtifactHandler customerRepHandler = RepositoryArtifactHandlerManager
|
||||
.getRepositoryHandler(customNexusServer);
|
||||
if (customerRepHandler != null) {
|
||||
filesToShare = getFilesToShare(monitor);
|
||||
LOGGER.info("filesToShare size: " + (filesToShare == null ? 0 : filesToShare.size()));
|
||||
if (filesToShare == null) {
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
SubMonitor mainSubMonitor = SubMonitor.convert(monitor, filesToShare.size());
|
||||
|
||||
// collect groupId to search
|
||||
Set<String> groupIds = new HashSet<String>();
|
||||
Map<String, List<MavenArtifact>> snapshotArtifactMap = new HashMap<String, List<MavenArtifact>>();
|
||||
Map<String, List<MavenArtifact>> releaseArtifactMap = new HashMap<String, List<MavenArtifact>>();
|
||||
Set<String> snapshotGroupIdSet = new HashSet<String>();
|
||||
Set<String> releaseGroupIdSet = new HashSet<String>();
|
||||
for (ModuleNeeded module : filesToShare.keySet()) {
|
||||
checkCancel(monitor);
|
||||
if (module.getMavenUri() != null) {
|
||||
MavenArtifact parseMvnUrl = MavenUrlHelper.parseMvnUrl(module.getMavenUri());
|
||||
if (parseMvnUrl != null) {
|
||||
groupIds.add(parseMvnUrl.getGroupId());
|
||||
if (isSnapshotVersion(parseMvnUrl.getVersion())) {
|
||||
snapshotGroupIdSet.add(parseMvnUrl.getGroupId());
|
||||
} else {
|
||||
releaseGroupIdSet.add(parseMvnUrl.getGroupId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LOGGER.info("snapshotGroupIdSet size: " + snapshotGroupIdSet.size() + ", releaseGroupIdSet size: "
|
||||
+ releaseGroupIdSet.size());
|
||||
List<MavenArtifact> searchResults = new ArrayList<MavenArtifact>();
|
||||
for (String groupId : groupIds) {
|
||||
if (releaseGroupIdSet.contains(groupId)) {
|
||||
searchResults = customerRepHandler.search(groupId, null, null, true, false);
|
||||
LOGGER.info("release searchResults size: " + (searchResults == null ? 0 : searchResults.size())
|
||||
+ ", groupId: "
|
||||
+ groupId);
|
||||
if (searchResults != null) {
|
||||
for (MavenArtifact result : searchResults) {
|
||||
checkCancel(monitor);
|
||||
ShareLibrariesUtil.putArtifactToMap(result, releaseArtifactMap, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (snapshotGroupIdSet.contains(groupId)) {
|
||||
searchResults = customerRepHandler.search(groupId, null, null, false, true);
|
||||
LOGGER.info("snapshot searchResults size: " + (searchResults == null ? 0 : searchResults.size())
|
||||
+ ", groupId: " + groupId);
|
||||
if (searchResults != null) {
|
||||
for (MavenArtifact result : searchResults) {
|
||||
checkCancel(monitor);
|
||||
ShareLibrariesUtil.putArtifactToMap(result, snapshotArtifactMap, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
searchResults.addAll(customerRepHandler.search(groupId, null, null, true, true));
|
||||
}
|
||||
|
||||
int limit = searchLimit;
|
||||
int shareIndex = 0;
|
||||
Iterator<ModuleNeeded> iterator = filesToShare.keySet().iterator();
|
||||
Map<File, MavenArtifact> shareFiles = new HashMap<>();
|
||||
while (iterator.hasNext()) {
|
||||
if (monitor.isCanceled()) {
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
shareIndex++;
|
||||
if (shareIndex == limit) {
|
||||
limit += searchLimit;
|
||||
}
|
||||
|
||||
ModuleNeeded next = iterator.next();
|
||||
File file = filesToShare.get(next);
|
||||
String name = file.getName();
|
||||
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(next.getMavenUri());
|
||||
if (artifact == null) {
|
||||
continue;
|
||||
}
|
||||
// If from custom component definition file
|
||||
if (LocalLibraryManager.isSystemCacheFile(file.getName())
|
||||
|| (LocalLibraryManager.isComponentDefinitionFileType(file.getName())
|
||||
&& isTalendLibraryGroupId(artifact))) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
Integer.parseInt(artifact.getType());
|
||||
// FIXME unexpected type if it's an integer, should fix it in component module definition.
|
||||
continue;
|
||||
} catch (NumberFormatException e) {
|
||||
//
|
||||
}
|
||||
boolean isSnapshotVersion = isSnapshotVersion(artifact.getVersion());
|
||||
String key = ShareLibrariesUtil.getArtifactKey(artifact, isSnapshotVersion);
|
||||
List<MavenArtifact> artifactList = null;
|
||||
if (isSnapshotVersion) {
|
||||
artifactList = snapshotArtifactMap.get(key);
|
||||
} else {
|
||||
artifactList = releaseArtifactMap.get(key);
|
||||
// skip checksum for release artifact.
|
||||
if (artifactList != null && artifactList.contains(artifact)
|
||||
&& !Boolean.getBoolean("force_libs_release_update")) {
|
||||
continue;
|
||||
|
||||
boolean eixst = false;
|
||||
String groupId = artifact.getGroupId();
|
||||
String artifactId = artifact.getArtifactId();
|
||||
String version = artifact.getVersion();
|
||||
for (MavenArtifact remoteAtifact : searchResults) {
|
||||
String rGroup = remoteAtifact.getGroupId();
|
||||
String rArtifact = remoteAtifact.getArtifactId();
|
||||
String rVersion = remoteAtifact.getVersion();
|
||||
if (groupId != null && artifactId != null && version != null && groupId.equals(rGroup)
|
||||
&& artifactId.equals(rArtifact) && version.equals(rVersion)) {
|
||||
eixst = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (artifactList != null && artifactList.size() > 0) {
|
||||
if (ShareLibrariesUtil.isSameFileWithRemote(file, artifactList, customNexusServer, customerRepHandler,
|
||||
isSnapshotVersion)) {
|
||||
continue;
|
||||
}
|
||||
if (eixst) {
|
||||
continue;
|
||||
}
|
||||
shareFiles.put(file, artifact);
|
||||
}
|
||||
LOGGER.info("shareFiles size: " + shareFiles.size());
|
||||
SubMonitor mainSubMonitor = SubMonitor.convert(monitor, shareFiles.size());
|
||||
shareFiles.forEach((k, v) -> {
|
||||
mainSubMonitor.setTaskName(Messages.getString("ShareLibsJob.sharingLibraries", name));
|
||||
|
||||
try {
|
||||
mainSubMonitor.setTaskName(Messages.getString("ShareLibsJob.sharingLibraries", k.getName()));
|
||||
shareToRepository(k, v);
|
||||
shareToRepository(file, artifact);
|
||||
mainSubMonitor.worked(1);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
continue;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
ExceptionHandler.process(e);
|
||||
status = Status.CANCEL_STATUS;
|
||||
} catch (Exception e) {
|
||||
status = new Status(IStatus.ERROR, "unknown", IStatus.ERROR, "Share libraries failed !", e);
|
||||
}
|
||||
@@ -183,31 +131,12 @@ public abstract class ShareLibrareisHelper {
|
||||
|
||||
}
|
||||
|
||||
private boolean isTalendLibraryGroupId(MavenArtifact artifact) {
|
||||
if ("org.talend.libraries".equalsIgnoreCase(artifact.getGroupId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isSnapshotVersion(String version) {
|
||||
if (version != null && version.toUpperCase().endsWith(MavenUrlHelper.VERSION_SNAPSHOT)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private void setJobName(Job job, String jobName) {
|
||||
if (job != null) {
|
||||
job.setName(jobName);
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkCancel(IProgressMonitor monitor) throws InterruptedException {
|
||||
if (monitor.isCanceled()) {
|
||||
throw new InterruptedException(Messages.getString("ShareLibsJob.monitor.cancelled"));
|
||||
}
|
||||
}
|
||||
|
||||
public abstract Map<ModuleNeeded, File> getFilesToShare(IProgressMonitor monitor);
|
||||
|
||||
public abstract void shareToRepository(File jarFile, MavenArtifact module) throws Exception;
|
||||
|
||||
@@ -397,7 +397,6 @@ public class ModulesNeededProvider {
|
||||
List<String> list = getInstallURL(importType);
|
||||
ModuleNeeded moduleNeeded = new ModuleNeeded(context, importType.getMODULE(), msg, importType.isREQUIRED(), list,
|
||||
importType.getREQUIREDIF(), importType.getMVN());
|
||||
moduleNeeded.setUseReleaseVersion(true);
|
||||
initBundleID(importType, moduleNeeded);
|
||||
moduleNeeded.setMrRequired(importType.isMRREQUIRED());
|
||||
moduleNeeded.setShow(importType.isSHOW());
|
||||
@@ -544,9 +543,9 @@ public class ModulesNeededProvider {
|
||||
Property property = findRoutinesPropery(infor.getId(), infor.getName(), routines, type);
|
||||
if (property != null) {
|
||||
if (((RoutineItem) property.getItem()).isBuiltIn()) {
|
||||
systemRoutines.add(property.getId());
|
||||
systemRoutines.add(infor.getId());
|
||||
} else {
|
||||
userRoutines.add(property.getId());
|
||||
userRoutines.add(infor.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -821,7 +820,6 @@ public class ModulesNeededProvider {
|
||||
uripath = ExtensionModuleManager.getInstance().getFormalModulePath(uripath, current);
|
||||
String mvn_rui = current.getAttribute(ExtensionModuleManager.MVN_URI_ATTR);
|
||||
ModuleNeeded module = new ModuleNeeded(context, name, message, required);
|
||||
module.setUseReleaseVersion(true);
|
||||
if (uripath != null && libManagerService.checkJarInstalledFromPlatform(uripath)) {
|
||||
module.setModuleLocaion(uripath);
|
||||
}
|
||||
|
||||
@@ -29,12 +29,9 @@ import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
@@ -64,10 +61,10 @@ import org.talend.core.model.components.ComponentProviderInfo;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.components.IComponentsService;
|
||||
import org.talend.core.model.general.ILibrariesService;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.general.ModuleStatusProvider;
|
||||
import org.talend.core.model.general.ILibrariesService.IChangedLibrariesListener;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.general.ModuleNeeded.ELibraryInstallStatus;
|
||||
import org.talend.core.model.general.ModuleStatusProvider;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.nexus.IRepositoryArtifactHandler;
|
||||
import org.talend.core.nexus.NexusServerUtils;
|
||||
@@ -83,7 +80,6 @@ import org.talend.designer.maven.utils.PomUtil;
|
||||
import org.talend.librariesmanager.maven.MavenArtifactsHandler;
|
||||
import org.talend.librariesmanager.model.ExtensionModuleManager;
|
||||
import org.talend.librariesmanager.model.ModulesNeededProvider;
|
||||
import org.talend.librariesmanager.nexus.utils.ShareLibrariesUtil;
|
||||
import org.talend.librariesmanager.prefs.LibrariesManagerUtils;
|
||||
import org.talend.osgi.hook.notification.JarMissingObservable;
|
||||
|
||||
@@ -112,17 +108,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
private JarMissingObservable missingJarObservable;
|
||||
|
||||
private MavenArtifactsHandler deployer;
|
||||
|
||||
private static final List<String> COMPONENT_DEFINITION_FILE_TYPE_LIST = new ArrayList<String>() {
|
||||
{
|
||||
add(".javajet");
|
||||
add(".png");
|
||||
add(".jpg");
|
||||
add("_java.xml");
|
||||
add(".properties");
|
||||
add(".txt");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* DOC nrousseau LocalLibraryManager constructor comment.
|
||||
*/
|
||||
@@ -169,7 +155,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
if (file == null || !file.exists()) {
|
||||
return;
|
||||
}
|
||||
install(file, mavenUri, updateNexusJar, false, monitorWrap);
|
||||
install(file, mavenUri, updateNexusJar, monitorWrap);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,8 +166,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
* @param mavenUri snaopshot mvn uri
|
||||
* @param monitorWrap
|
||||
*/
|
||||
private void install(File file, String mavenRUI, boolean updateRemoteJar, boolean useReleaseVersion,
|
||||
IProgressMonitor... monitorWrap) {
|
||||
private void install(File file, String mavenRUI, boolean updateRemoteJar, IProgressMonitor... monitorWrap) {
|
||||
try {
|
||||
if (file.isDirectory()) {
|
||||
List<File> jarFiles = FilesUtils.getJarFilesFromFolder(file, null);
|
||||
@@ -189,7 +174,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
if (!jarFiles.isEmpty()) {
|
||||
for (File jarFile : jarFiles) {
|
||||
if (mavenRUI == null) {
|
||||
guessMavenRUIFromIndex(jarFile, useReleaseVersion, sourceAndMavenUri);
|
||||
guessMavenRUIFromIndex(jarFile, sourceAndMavenUri);
|
||||
} else {
|
||||
sourceAndMavenUri.put(mavenRUI, jarFile.getAbsolutePath());
|
||||
}
|
||||
@@ -201,7 +186,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
} else {
|
||||
Map<String, String> sourceAndMavenUri = new HashMap<String, String>();
|
||||
if (mavenRUI == null) {
|
||||
guessMavenRUIFromIndex(file, useReleaseVersion, sourceAndMavenUri);
|
||||
guessMavenRUIFromIndex(file, sourceAndMavenUri);
|
||||
} else {
|
||||
sourceAndMavenUri.put(mavenRUI, file.getAbsolutePath());
|
||||
}
|
||||
@@ -216,19 +201,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
}
|
||||
}
|
||||
|
||||
public void guessMavenRUIFromIndex(File jarFile, Map<String, String> sourceAndMavenUri) {
|
||||
guessMavenRUIFromIndex(jarFile, false, sourceAndMavenUri);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* DOC wchen Comment method "guessMavenRUIFromIndex".
|
||||
*
|
||||
* @param jarFile jar file to guess maven url
|
||||
* @param useReleaseVersion generate release version if not find from index
|
||||
*/
|
||||
private void guessMavenRUIFromIndex(File jarFile, boolean useReleaseVersion, Map<String, String> sourceAndMavenUri) {
|
||||
private void guessMavenRUIFromIndex(File jarFile, Map<String, String> sourceAndMavenUri) {
|
||||
// TODO????? should deploy with all versions
|
||||
String urisFromIndex = LibrariesIndexManager.getInstance().getMavenLibIndex().getJarsToRelativePath()
|
||||
.get(jarFile.getName());
|
||||
@@ -253,7 +226,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
// deploy as defaultMavenUri in case jar name is diffrent from artifactId in mvnuri from
|
||||
// index
|
||||
if (deployAsDefault) {
|
||||
String defaultMavenUri = MavenUrlHelper.generateMvnUrlForJarName(jarFile.getName(), true, !useReleaseVersion);
|
||||
String defaultMavenUri = MavenUrlHelper.generateMvnUrlForJarName(jarFile.getName());
|
||||
String customMavenURI = getCustomMavenURI(defaultMavenUri);
|
||||
if (customMavenURI != null) {
|
||||
defaultMavenUri = customMavenURI;
|
||||
@@ -383,24 +356,6 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isComponentDefinitionFileType(String fileName) {
|
||||
if (fileName != null) {
|
||||
for (String type : COMPONENT_DEFINITION_FILE_TYPE_LIST) {
|
||||
if (fileName.toLowerCase().endsWith(type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isSystemCacheFile(String fileName) {
|
||||
if ("Thumbs.db".equals(fileName)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private File retrieveJarFromLocal(ModuleNeeded module) {
|
||||
File jarFile = null;
|
||||
Set<String> toResolve = guessMavenURI(module);
|
||||
@@ -870,7 +825,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
ExceptionHandler.log("missing jar:" + module.getModuleName());
|
||||
}
|
||||
if (fileToDeploy != null) {
|
||||
install(fileToDeploy, mavenUri, false, false, monitorWrap);
|
||||
install(fileToDeploy, mavenUri, false, monitorWrap);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -964,9 +919,6 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
if (ModuleStatusProvider.getDeployStatus(mvnUriStatusKey) == ELibraryInstallStatus.NOT_DEPLOYED) {
|
||||
return null;
|
||||
}
|
||||
if(mvnUriStatusKey == null){
|
||||
return null;
|
||||
}
|
||||
// then try to resolve locally
|
||||
String localMavenUri = mvnUriStatusKey.replace("mvn:", "mvn:" + MavenConstants.LOCAL_RESOLUTION_URL + "!"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
try {
|
||||
@@ -1165,35 +1117,51 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
}
|
||||
|
||||
if (service != null) {
|
||||
calculateModulesIndexFromComponentFolder(service, platformURLMap);
|
||||
deployLibsFromComponentFolder(service, platformURLMap);
|
||||
}
|
||||
|
||||
saveMavenIndex(mavenURIMap, monitorWrap);
|
||||
savePlatfromURLIndex(platformURLMap, monitorWrap);
|
||||
|
||||
if (service != null) {
|
||||
deployLibsFromCustomComponents(service, platformURLMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* The old components might use some jars in component folder and theres jars are not configured with platfrom URL
|
||||
*
|
||||
*
|
||||
* @param service
|
||||
* @param libsWithoutUri
|
||||
* @param platformURLMap
|
||||
*/
|
||||
private void calculateModulesIndexFromComponentFolder(IComponentsService service, Map<String, String> platformURLMap) {
|
||||
private void deployLibsFromComponentFolder(IComponentsService service, Map<String, String> platformURLMap) {
|
||||
Set<File> needToDeploy = new HashSet<File>();
|
||||
List<ComponentProviderInfo> componentsFolders = service.getComponentsFactory().getComponentsProvidersInfo();
|
||||
for (ComponentProviderInfo providerInfo : componentsFolders) {
|
||||
String contributeID = providerInfo.getContributer();
|
||||
String id = providerInfo.getId();
|
||||
try {
|
||||
if (!"org.talend.designer.components.model.UserComponentsProvider".equals(id)
|
||||
&& !"org.talend.designer.components.exchange.ExchangeComponentsProvider".equals(id)) {
|
||||
File file = new File(providerInfo.getLocation());
|
||||
File file = new File(providerInfo.getLocation());
|
||||
if ("org.talend.designer.components.model.UserComponentsProvider".equals(id)
|
||||
|| "org.talend.designer.components.exchange.ExchangeComponentsProvider".equals(id)) {
|
||||
if (file.isDirectory()) {
|
||||
List<File> jarFiles = FilesUtils.getJarFilesFromFolder(file, null);
|
||||
if (jarFiles.size() > 0) {
|
||||
for (File jarFile : jarFiles) {
|
||||
String name = jarFile.getName();
|
||||
if (platformURLMap.get(name) != null) {
|
||||
continue;
|
||||
}
|
||||
needToDeploy.add(jarFile);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (platformURLMap.get(file.getName()) != null) {
|
||||
continue;
|
||||
}
|
||||
needToDeploy.add(file);
|
||||
}
|
||||
} else {
|
||||
// for other component provider ,add jars to the platform url index
|
||||
List<File> jarFiles = FilesUtils.getJarFilesFromFolder(file, null, "ext");
|
||||
if (jarFiles.size() > 0) {
|
||||
for (File jarFile : jarFiles) {
|
||||
@@ -1223,156 +1191,41 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deployLibsFromCustomComponents(IComponentsService service, Map<String, String> platformURLMap) {
|
||||
boolean deployToRemote = true;
|
||||
if (!LibrariesManagerUtils.shareLibsAtStartup()) {
|
||||
log.info("Skip deploying libs from custom components");
|
||||
deployToRemote = false;
|
||||
}
|
||||
Set<File> needToDeploy = new HashSet<>();
|
||||
List<ComponentProviderInfo> componentsFolders = service.getComponentsFactory().getComponentsProvidersInfo();
|
||||
for (ComponentProviderInfo providerInfo : componentsFolders) {
|
||||
String id = providerInfo.getId();
|
||||
try {
|
||||
File file = new File(providerInfo.getLocation());
|
||||
if ("org.talend.designer.components.model.UserComponentsProvider".equals(id)
|
||||
|| "org.talend.designer.components.exchange.ExchangeComponentsProvider".equals(id)) {
|
||||
if (file.isDirectory()) {
|
||||
List<File> jarFiles = FilesUtils.getJarFilesFromFolder(file, null);
|
||||
if (jarFiles.size() > 0) {
|
||||
for (File jarFile : jarFiles) {
|
||||
String name = jarFile.getName();
|
||||
if (!canDeployFromCustomComponentFolder(name)
|
||||
|| platformURLMap.get(name) != null) {
|
||||
continue;
|
||||
}
|
||||
needToDeploy.add(jarFile);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (platformURLMap.get(file.getName()) != null) {
|
||||
continue;
|
||||
}
|
||||
needToDeploy.add(file);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!deployToRemote) {
|
||||
needToDeploy.forEach(libFile -> {
|
||||
try {
|
||||
// install as release version if can't find mvn url from index
|
||||
install(libFile, null, false, true);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// deploy needed jars for User and Exchange component providers
|
||||
Map<String, List<MavenArtifact>> snapshotArtifactMap = new HashMap<String, List<MavenArtifact>>();
|
||||
Map<String, List<MavenArtifact>> releaseArtifactMap = new HashMap<String, List<MavenArtifact>>();
|
||||
if (!needToDeploy.isEmpty()) {
|
||||
// search on nexus to avoid deploy the jar many times
|
||||
Set<File> existFiles = new HashSet<>();
|
||||
ArtifactRepositoryBean customNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer();
|
||||
IRepositoryArtifactHandler customerRepHandler = RepositoryArtifactHandlerManager
|
||||
.getRepositoryHandler(customNexusServer);
|
||||
List<MavenArtifact> snapshotResult = new ArrayList<>();
|
||||
List<MavenArtifact> releaseResult = new ArrayList<>();
|
||||
// deploy needed jars for User and Exchange component providers
|
||||
if (!needToDeploy.isEmpty()) {
|
||||
// search on nexus to avoid deploy the jar many times
|
||||
Set<File> existFiles = new HashSet<File>();
|
||||
ArtifactRepositoryBean customNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer();
|
||||
IRepositoryArtifactHandler customerRepHandler = RepositoryArtifactHandlerManager
|
||||
.getRepositoryHandler(customNexusServer);
|
||||
if (customerRepHandler != null) {
|
||||
List<MavenArtifact> searchResult = new ArrayList<>();
|
||||
try {
|
||||
snapshotResult = customerRepHandler.search(MavenConstants.DEFAULT_LIB_GROUP_ID, null, null, false, true);
|
||||
if (snapshotResult != null) {
|
||||
for (MavenArtifact result : snapshotResult) {
|
||||
ShareLibrariesUtil.putArtifactToMap(result, snapshotArtifactMap, true);
|
||||
}
|
||||
}
|
||||
releaseResult = customerRepHandler.search(MavenConstants.DEFAULT_LIB_GROUP_ID, null, null, true, false);
|
||||
if (releaseResult != null) {
|
||||
for (MavenArtifact result : releaseResult) {
|
||||
ShareLibrariesUtil.putArtifactToMap(result, releaseArtifactMap, false);
|
||||
}
|
||||
}
|
||||
searchResult = customerRepHandler.search(MavenConstants.DEFAULT_LIB_GROUP_ID, null, null, true, true);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
for (File exsitFile : needToDeploy) {
|
||||
if (customerRepHandler != null) {
|
||||
try {
|
||||
String name = exsitFile.getName();
|
||||
String mvnUrlSnapshot = MavenUrlHelper.generateMvnUrlForJarName(name, true, true);
|
||||
MavenArtifact artifactSnapshot = MavenUrlHelper.parseMvnUrl(mvnUrlSnapshot);
|
||||
String keySnapshot = ShareLibrariesUtil.getArtifactKey(artifactSnapshot, true);
|
||||
List<MavenArtifact> artifactListSnapshot = null;
|
||||
artifactListSnapshot = snapshotArtifactMap.get(keySnapshot);
|
||||
// snapshot
|
||||
if (artifactListSnapshot != null && artifactListSnapshot.size() > 0) {
|
||||
if (ShareLibrariesUtil.isSameFileWithRemote(exsitFile, artifactListSnapshot, customNexusServer,
|
||||
customerRepHandler, true)) {
|
||||
existFiles.add(exsitFile);
|
||||
}
|
||||
}
|
||||
// release
|
||||
String mvnUrlRelease = MavenUrlHelper.generateMvnUrlForJarName(name, true, false);
|
||||
MavenArtifact artifactRelease = MavenUrlHelper.parseMvnUrl(mvnUrlRelease);
|
||||
String keyRelease = ShareLibrariesUtil.getArtifactKey(artifactRelease, false);
|
||||
List<MavenArtifact> artifactListRelease = null;
|
||||
artifactListRelease = releaseArtifactMap.get(keyRelease);
|
||||
if (artifactListRelease != null && artifactListRelease.size() > 0) {
|
||||
if (ShareLibrariesUtil.isSameFileWithRemote(exsitFile, artifactListRelease, customNexusServer,
|
||||
customerRepHandler, false)) {
|
||||
existFiles.add(exsitFile);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
for (MavenArtifact artifact : searchResult) {
|
||||
for (File file : needToDeploy) {
|
||||
if (artifact.getFileName().equals(file.getName())) {
|
||||
existFiles.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
needToDeploy.removeAll(existFiles);
|
||||
// check sha code to avoid same jar in diff component depoly multi times
|
||||
Map<String, File> shaMap = new HashMap<>();
|
||||
Iterator<File> it = needToDeploy.iterator();
|
||||
while (it.hasNext()) {
|
||||
try {
|
||||
File dupFile = it.next();
|
||||
String localFileShaCode = DigestUtils.shaHex(new FileInputStream(dupFile));
|
||||
if (shaMap.get(localFileShaCode) == null) {
|
||||
shaMap.put(localFileShaCode, dupFile);
|
||||
} else {
|
||||
it.remove();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
for (File file : needToDeploy) {
|
||||
try {
|
||||
// deploy as release version if can't find mvn url from index
|
||||
install(file, null, true, true);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
needToDeploy.removeAll(existFiles);
|
||||
for (File file : needToDeploy) {
|
||||
try {
|
||||
deploy(file.toURI());
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canDeployFromCustomComponentFolder(String fileName) {
|
||||
if (isSystemCacheFile(fileName) || isComponentDefinitionFileType(fileName)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void warnDuplicated(List<ModuleNeeded> modules, Set<String> duplicates, String type) {
|
||||
for (String lib : duplicates) {
|
||||
Set<String> components = new HashSet<String>();
|
||||
@@ -1641,7 +1494,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
return isSameFile(jarFile, jarInLib);
|
||||
}
|
||||
|
||||
public boolean isSameFile(File f1, File f2) {
|
||||
private boolean isSameFile(File f1, File f2) {
|
||||
if (f1 == null || f2 == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -13,18 +13,13 @@
|
||||
package org.talend.librariesmanager.nexus;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Dictionary;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.nexus.IRepositoryArtifactHandler;
|
||||
import org.talend.core.nexus.NexusConstants;
|
||||
import org.talend.core.nexus.TalendMavenResolver;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.utils.string.StringUtilities;
|
||||
|
||||
/**
|
||||
@@ -67,22 +62,10 @@ public abstract class AbstractArtifactRepositoryHandler implements IRepositoryAr
|
||||
if (props == null) {
|
||||
props = new Hashtable<String, String>();
|
||||
}
|
||||
|
||||
String custom_user = serverBean.getUserName();
|
||||
String custom_pass = serverBean.getPassword();
|
||||
try {
|
||||
if (StringUtils.isNotBlank(custom_user)) {
|
||||
custom_user = URLEncoder.encode(custom_user, StandardCharsets.UTF_8.toString());
|
||||
}
|
||||
if (StringUtils.isNotBlank(custom_pass)) {
|
||||
custom_pass = URLEncoder.encode(custom_pass, StandardCharsets.UTF_8.toString());
|
||||
}
|
||||
} catch (UnsupportedEncodingException e1) {
|
||||
throw new RuntimeException(e1);
|
||||
}
|
||||
|
||||
String repositories = null;
|
||||
String custom_server = serverBean.getServer();
|
||||
String custom_user = serverBean.getUserName();
|
||||
String custom_pass = serverBean.getPassword();
|
||||
String release_rep = serverBean.getRepositoryId();
|
||||
String snapshot_rep = serverBean.getSnapshotRepId();
|
||||
if (custom_server.endsWith(NexusConstants.SLASH)) {
|
||||
@@ -100,8 +83,7 @@ public abstract class AbstractArtifactRepositoryHandler implements IRepositoryAr
|
||||
repositories = releaseUrl;
|
||||
}
|
||||
if (snapshot_rep != null) {
|
||||
String snapshotUrl = custom_server + snapshot_rep + "@id=" + snapshot_rep + NexusConstants.SNAPSHOTS //$NON-NLS-1$
|
||||
+ NexusConstants.DISALLOW_RELEASES;
|
||||
String snapshotUrl = custom_server + snapshot_rep + "@id=" + snapshot_rep + NexusConstants.SNAPSHOTS;//$NON-NLS-1$
|
||||
if (repositories != null) {
|
||||
repositories = repositories + "," + snapshotUrl;
|
||||
} else {
|
||||
@@ -178,10 +160,4 @@ public abstract class AbstractArtifactRepositoryHandler implements IRepositoryAr
|
||||
|
||||
@Override
|
||||
public abstract IRepositoryArtifactHandler clone();
|
||||
|
||||
@Override
|
||||
public String resolveRemoteSha1(MavenArtifact artifact, boolean fromRelease) throws Exception {
|
||||
return artifact.getSha1();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ package org.talend.librariesmanager.nexus;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -26,15 +25,11 @@ import org.apache.http.client.fluent.Request;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.params.CoreConnectionPNames;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.eclipse.m2e.core.MavenPlugin;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.network.TalendProxySelector.IProxySelectorProvider;
|
||||
import org.talend.core.nexus.HttpClientTransport;
|
||||
import org.talend.core.nexus.IRepositoryArtifactHandler;
|
||||
import org.talend.core.nexus.NexusConstants;
|
||||
import org.talend.core.nexus.NexusServerUtils;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
import org.talend.designer.maven.aether.RepositorySystemFactory;
|
||||
@@ -48,7 +43,9 @@ import net.sf.json.JSONObject;
|
||||
*/
|
||||
public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandler {
|
||||
|
||||
private String SEARCH_SERVICE = "api/search/gavc?"; //$NON-NLS-1$
|
||||
private String SEARCH_SERVICE = "api/search/gavc?";
|
||||
|
||||
private String SEARCH_RESULT_PREFIX = "api/storage/";
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -83,30 +80,17 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
|
||||
}
|
||||
|
||||
private boolean doConnectionCheck(String repositoryUrl) throws ClientProtocolException, IOException {
|
||||
String userPass = serverBean.getUserName() + ":" + serverBean.getPassword(); //$NON-NLS-1$
|
||||
String basicAuth = "Basic " + new String(new Base64().encode(userPass.getBytes())); //$NON-NLS-1$
|
||||
Header authority = new BasicHeader("Authorization", basicAuth); //$NON-NLS-1$
|
||||
String userPass = serverBean.getUserName() + ":" + serverBean.getPassword();
|
||||
String basicAuth = "Basic " + new String(new Base64().encode(userPass.getBytes()));
|
||||
Header authority = new BasicHeader("Authorization", basicAuth);
|
||||
HttpGet get = new HttpGet(repositoryUrl);
|
||||
get.addHeader(authority);
|
||||
DefaultHttpClient httpclient = new DefaultHttpClient();
|
||||
httpclient.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, NexusServerUtils.getTimeout());
|
||||
httpclient.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, NexusServerUtils.getTimeout());
|
||||
IProxySelectorProvider proxySelector = null;
|
||||
try {
|
||||
try {
|
||||
proxySelector = HttpClientTransport.addProxy(httpclient, new URI(repositoryUrl));
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
HttpResponse response = httpclient.execute(get);
|
||||
if (response.getStatusLine().getStatusCode() == 200) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} finally {
|
||||
HttpClientTransport.removeProxy(proxySelector);
|
||||
httpclient.getConnectionManager().shutdown();
|
||||
HttpResponse response = httpclient.execute(get);
|
||||
if (response.getStatusLine().getStatusCode() == 200) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -119,53 +103,51 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
|
||||
public List<MavenArtifact> search(String groupIdToSearch, String artifactId, String versionToSearch, boolean fromRelease,
|
||||
boolean fromSnapshot) throws Exception {
|
||||
String serverUrl = serverBean.getServer();
|
||||
if (!serverUrl.endsWith("/")) { //$NON-NLS-1$
|
||||
serverUrl = serverUrl + "/"; //$NON-NLS-1$
|
||||
if (!serverUrl.endsWith("/")) {
|
||||
serverUrl = serverUrl + "/";
|
||||
}
|
||||
String searchUrl = serverUrl + SEARCH_SERVICE;
|
||||
|
||||
String repositoryId = ""; //$NON-NLS-1$
|
||||
String repositoryId = "";
|
||||
if (fromRelease) {
|
||||
repositoryId = serverBean.getRepositoryId();
|
||||
}
|
||||
if (fromSnapshot) {
|
||||
if ("".equals(repositoryId)) { //$NON-NLS-1$
|
||||
if ("".equals(repositoryId)) {
|
||||
repositoryId = serverBean.getSnapshotRepId();
|
||||
} else {
|
||||
repositoryId = repositoryId + "," + serverBean.getSnapshotRepId(); //$NON-NLS-1$
|
||||
repositoryId = repositoryId + "," + serverBean.getSnapshotRepId();
|
||||
}
|
||||
}
|
||||
String query = "";//$NON-NLS-1$
|
||||
if (!"".equals(repositoryId)) { //$NON-NLS-1$
|
||||
if (!"".equals(repositoryId)) {
|
||||
query = "repos=" + repositoryId;//$NON-NLS-1$
|
||||
}
|
||||
if (groupIdToSearch != null) {
|
||||
if (!"".equals(query)) { //$NON-NLS-1$
|
||||
query = query + "&"; //$NON-NLS-1$
|
||||
if (!"".equals(query)) {
|
||||
query = query + "&";
|
||||
}
|
||||
query = query + "g=" + groupIdToSearch;//$NON-NLS-1$
|
||||
}
|
||||
if (artifactId != null) {
|
||||
if (!"".equals(query)) { //$NON-NLS-1$
|
||||
query = query + "&"; //$NON-NLS-1$
|
||||
if (!"".equals(query)) {
|
||||
query = query + "&";
|
||||
}
|
||||
query = query + "a=" + artifactId;//$NON-NLS-1$
|
||||
}
|
||||
|
||||
if (versionToSearch != null) {
|
||||
if (!"".equals(query)) { //$NON-NLS-1$
|
||||
query = query + "&"; //$NON-NLS-1$
|
||||
if (!"".equals(query)) {
|
||||
query = query + "&";
|
||||
}
|
||||
query = query + "v=" + versionToSearch;//$NON-NLS-1$
|
||||
}
|
||||
searchUrl = searchUrl + query;
|
||||
Request request = Request.Get(searchUrl);
|
||||
String userPass = serverBean.getUserName() + ":" + serverBean.getPassword(); //$NON-NLS-1$
|
||||
String basicAuth = "Basic " + new String(new Base64().encode(userPass.getBytes())); //$NON-NLS-1$
|
||||
Header authority = new BasicHeader("Authorization", basicAuth); //$NON-NLS-1$
|
||||
String userPass = serverBean.getUserName() + ":" + serverBean.getPassword();
|
||||
String basicAuth = "Basic " + new String(new Base64().encode(userPass.getBytes()));
|
||||
Header authority = new BasicHeader("Authorization", basicAuth);
|
||||
request.addHeader(authority);
|
||||
Header resultDetailHeader = new BasicHeader("X-Result-Detail", "info"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
request.addHeader(resultDetailHeader);
|
||||
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
|
||||
|
||||
HttpResponse response = request.execute().returnResponse();
|
||||
@@ -173,65 +155,56 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
|
||||
if (content.isEmpty()) {
|
||||
return resultList;
|
||||
}
|
||||
JSONObject responseObject = JSONObject.fromObject(content);
|
||||
String resultStr = responseObject.getString("results"); //$NON-NLS-1$
|
||||
JSONObject responseObject = new JSONObject().fromObject(content);
|
||||
String resultStr = responseObject.getString("results");
|
||||
JSONArray resultArray = null;
|
||||
try {
|
||||
resultArray = JSONArray.fromObject(resultStr);
|
||||
resultArray = new JSONArray().fromObject(resultStr);
|
||||
} catch (Exception e) {
|
||||
throw new Exception(resultStr);
|
||||
}
|
||||
if (resultArray != null) {
|
||||
String resultUrl = serverUrl + SEARCH_RESULT_PREFIX;
|
||||
for (int i = 0; i < resultArray.size(); i++) {
|
||||
JSONObject jsonObject = resultArray.getJSONObject(i);
|
||||
String artifactPath = jsonObject.getString("path"); //$NON-NLS-1$
|
||||
String[] split = artifactPath.split("/"); //$NON-NLS-1$
|
||||
String lastUpdated = jsonObject.getString("lastUpdated"); //$NON-NLS-1$
|
||||
String uri = jsonObject.getString("uri");
|
||||
uri = uri.substring(resultUrl.length(), uri.length());
|
||||
String[] split = uri.split("/");
|
||||
if (split.length > 4) {
|
||||
String fileName = split[split.length - 1];
|
||||
if (!fileName.endsWith("pom")) { //$NON-NLS-1$
|
||||
if (!fileName.endsWith("pom")) {
|
||||
String type = null;
|
||||
int dotIndex = fileName.lastIndexOf('.');
|
||||
if (dotIndex > 0) {
|
||||
type = fileName.substring(dotIndex + 1);
|
||||
|
||||
}
|
||||
if (type != null) {
|
||||
MavenArtifact artifact = new MavenArtifact();
|
||||
String v = split[split.length - 2];
|
||||
String a = split[split.length - 3];
|
||||
String g = ""; //$NON-NLS-1$
|
||||
String g = "";
|
||||
for (int j = 1; j < split.length - 3; j++) {
|
||||
if ("".equals(g)) { //$NON-NLS-1$
|
||||
if ("".equals(g)) {
|
||||
g = split[j];
|
||||
} else {
|
||||
g = g + "." + split[j]; //$NON-NLS-1$
|
||||
g = g + "." + split[j];
|
||||
}
|
||||
}
|
||||
artifact.setGroupId(g);
|
||||
artifact.setArtifactId(a);
|
||||
artifact.setVersion(v);
|
||||
artifact.setType(type);
|
||||
artifact.setLastUpdated(lastUpdated);
|
||||
fillChecksumData(jsonObject, artifact);
|
||||
resultList.add(artifact);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
private void fillChecksumData(JSONObject responseObject, MavenArtifact artifact) {
|
||||
if (responseObject.containsKey("checksums")) { //$NON-NLS-1$
|
||||
JSONObject checkSum = responseObject.getJSONObject("checksums"); //$NON-NLS-1$
|
||||
if (checkSum != null && checkSum.containsKey("sha1")) { //$NON-NLS-1$
|
||||
artifact.setSha1(checkSum.getString("sha1")); //$NON-NLS-1$
|
||||
}
|
||||
if (checkSum != null && checkSum.containsKey("md5")) { //$NON-NLS-1$
|
||||
artifact.setMd5(checkSum.getString("md5")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -243,7 +216,7 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
|
||||
@Override
|
||||
public void deploy(File content, String groupId, String artifactId, String classifier, String extension, String version)
|
||||
throws Exception {
|
||||
String repositoryId = ""; //$NON-NLS-1$
|
||||
String repositoryId = "";
|
||||
boolean isRelease = !version.endsWith(MavenUrlHelper.VERSION_SNAPSHOT);
|
||||
if (isRelease) {
|
||||
repositoryId = serverBean.getRepositoryId();
|
||||
@@ -265,7 +238,7 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
|
||||
@Override
|
||||
public void deployWithPOM(File content, File pomFile, String groupId, String artifactId, String classifier, String extension,
|
||||
String version) throws Exception {
|
||||
String repositoryId = ""; //$NON-NLS-1$
|
||||
String repositoryId = "";
|
||||
boolean isRelease = !version.endsWith(MavenUrlHelper.VERSION_SNAPSHOT);
|
||||
if (isRelease) {
|
||||
repositoryId = serverBean.getRepositoryId();
|
||||
|
||||
@@ -137,12 +137,5 @@ public class Nexus2RepositoryHandler extends AbstractArtifactRepositoryHandler {
|
||||
RepositorySystemFactory.deployWithPOM(content, pomFile, localRepository, repositoryId, repositoryurl,
|
||||
serverBean.getUserName(), serverBean.getPassword(), groupId, artifactId, classifier, extension, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resolveRemoteSha1(MavenArtifact artifact, boolean fromRelease) throws Exception {
|
||||
return NexusServerUtils.resolveSha1(serverBean.getServer(), serverBean.getUserName(), serverBean.getPassword(),
|
||||
fromRelease ? serverBean.getRepositoryId() : serverBean.getSnapshotRepId(), artifact.getGroupId(),
|
||||
artifact.getArtifactId(), artifact.getVersion(), artifact.getType());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,35 +14,29 @@ package org.talend.librariesmanager.nexus;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.fluent.Request;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.params.CoreConnectionPNames;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.eclipse.m2e.core.MavenPlugin;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.network.TalendProxySelector.IProxySelectorProvider;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.nexus.HttpClientTransport;
|
||||
import org.talend.core.nexus.IRepositoryArtifactHandler;
|
||||
import org.talend.core.nexus.NexusServerUtils;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
import org.talend.designer.maven.aether.RepositorySystemFactory;
|
||||
import org.talend.librariesmanager.nexus.nexus3.handler.AbsNexus3SearchHandler;
|
||||
import org.talend.librariesmanager.nexus.nexus3.handler.INexus3SearchHandler;
|
||||
import org.talend.librariesmanager.nexus.nexus3.handler.Nexus3BetaSearchHandler;
|
||||
import org.talend.librariesmanager.nexus.nexus3.handler.Nexus3ScriptSearchHandler;
|
||||
import org.talend.librariesmanager.nexus.nexus3.handler.Nexus3V1SearchHandler;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
/**
|
||||
* created by wchen on Aug 2, 2017 Detailled comment
|
||||
@@ -50,14 +44,10 @@ import org.talend.librariesmanager.nexus.nexus3.handler.Nexus3V1SearchHandler;
|
||||
*/
|
||||
public class Nexus3RepositoryHandler extends AbstractArtifactRepositoryHandler {
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(Nexus3RepositoryHandler.class);
|
||||
private String SEARCH_SERVICE = "service/rest/v1/script/search/run";
|
||||
|
||||
private String REP_PREFIX_PATH = "/repository/";
|
||||
|
||||
private ThreadLocal<INexus3SearchHandler> currentQueryHandlerCopy = new ThreadLocal<INexus3SearchHandler>();
|
||||
|
||||
private static final ConcurrentHashMap<ArtifactRepositoryBean, INexus3SearchHandler> LAST_HANDLER_MAP = new ConcurrentHashMap<ArtifactRepositoryBean, INexus3SearchHandler>();
|
||||
|
||||
@Override
|
||||
public IRepositoryArtifactHandler clone() {
|
||||
return new Nexus3RepositoryHandler();
|
||||
@@ -102,25 +92,11 @@ public class Nexus3RepositoryHandler extends AbstractArtifactRepositoryHandler {
|
||||
HttpGet get = new HttpGet(repositoryUrl);
|
||||
get.addHeader(authority);
|
||||
DefaultHttpClient httpclient = new DefaultHttpClient();
|
||||
|
||||
httpclient.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, NexusServerUtils.getTimeout());
|
||||
httpclient.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, NexusServerUtils.getTimeout());
|
||||
IProxySelectorProvider proxySelector = null;
|
||||
try {
|
||||
try {
|
||||
proxySelector = HttpClientTransport.addProxy(httpclient, new URI(repositoryUrl));
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
HttpResponse response = httpclient.execute(get);
|
||||
if (response.getStatusLine().getStatusCode() == 200) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} finally {
|
||||
HttpClientTransport.removeProxy(proxySelector);
|
||||
httpclient.getConnectionManager().shutdown();
|
||||
HttpResponse response = httpclient.execute(get);
|
||||
if (response.getStatusLine().getStatusCode() == 200) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -132,64 +108,75 @@ public class Nexus3RepositoryHandler extends AbstractArtifactRepositoryHandler {
|
||||
@Override
|
||||
public List<MavenArtifact> search(String groupIdToSearch, String artifactId, String versionToSearch, boolean fromRelease,
|
||||
boolean fromSnapshot) throws Exception {
|
||||
|
||||
String serverUrl = serverBean.getServer();
|
||||
if (!serverUrl.endsWith("/")) {
|
||||
serverUrl = serverUrl + "/";
|
||||
}
|
||||
String searchUrl = serverUrl + SEARCH_SERVICE;
|
||||
Request request = Request.Post(searchUrl);
|
||||
String userPass = serverBean.getUserName() + ":" + serverBean.getPassword();
|
||||
String basicAuth = "Basic " + new String(new Base64().encode(userPass.getBytes()));
|
||||
Header authority = new BasicHeader("Authorization", basicAuth);
|
||||
Header contentType = new BasicHeader("Content-Type", "text/plain");
|
||||
request.addHeader(contentType);
|
||||
request.addHeader(authority);
|
||||
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
|
||||
if (fromRelease) {
|
||||
resultList.addAll(doSearch(serverBean.getRepositoryId(), groupIdToSearch, artifactId, versionToSearch));
|
||||
resultList.addAll(doSearch(request, serverBean.getRepositoryId(), groupIdToSearch, artifactId, versionToSearch));
|
||||
}
|
||||
if (fromSnapshot) {
|
||||
resultList.addAll(doSearch(serverBean.getSnapshotRepId(), groupIdToSearch, artifactId, versionToSearch));
|
||||
resultList.addAll(doSearch(request, serverBean.getSnapshotRepId(), groupIdToSearch, artifactId, versionToSearch));
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
private List<MavenArtifact> doSearch(String repositoryId, String groupIdToSearch, String artifactId, String versionToSearch)
|
||||
throws Exception {
|
||||
INexus3SearchHandler currentQueryHandler = currentQueryHandlerCopy.get();
|
||||
if (currentQueryHandler == null) {
|
||||
currentQueryHandler = LAST_HANDLER_MAP.get(serverBean);
|
||||
if (currentQueryHandler == null) {
|
||||
currentQueryHandler = createQueryHandler(0);
|
||||
}
|
||||
private List<MavenArtifact> doSearch(Request request, String repositoryId, String groupIdToSearch, String artifactId,
|
||||
String versionToSearch) throws Exception {
|
||||
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
|
||||
JSONObject body = new JSONObject();
|
||||
body.put("repositoryId", repositoryId);
|
||||
if (groupIdToSearch != null) {
|
||||
body.put("g", groupIdToSearch);
|
||||
}
|
||||
List<MavenArtifact> result = new ArrayList<MavenArtifact>();
|
||||
if (artifactId != null) {
|
||||
body.put("a", artifactId);
|
||||
}
|
||||
if (versionToSearch != null) {
|
||||
body.put("v", versionToSearch);
|
||||
}
|
||||
request.bodyString(body.toString(),
|
||||
ContentType.create(ContentType.APPLICATION_JSON.getMimeType(), StandardCharsets.UTF_8));
|
||||
HttpResponse response = request.execute().returnResponse();
|
||||
String content = EntityUtils.toString(response.getEntity());
|
||||
if (content.isEmpty()) {
|
||||
return resultList;
|
||||
}
|
||||
JSONObject responseObject = new JSONObject().fromObject(content);
|
||||
String resultStr = responseObject.getString("result");
|
||||
JSONArray resultArray = null;
|
||||
try {
|
||||
result = currentQueryHandler.search(repositoryId, groupIdToSearch, artifactId, versionToSearch);
|
||||
} catch (Exception ex) {
|
||||
for (int i = 0; i < 3; i++) {// Try to other version
|
||||
INexus3SearchHandler handler = createQueryHandler(i);
|
||||
if (handler != currentQueryHandler) {
|
||||
try {
|
||||
result = handler.search(repositoryId, groupIdToSearch, artifactId, versionToSearch);
|
||||
currentQueryHandler = handler;
|
||||
LOGGER.info(
|
||||
"Switch to new search handler,the handler version is:" + currentQueryHandler.getHandlerVersion());
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
LOGGER.info("Try to switch search handler failed" + e.getMessage());
|
||||
}
|
||||
}
|
||||
resultArray = new JSONArray().fromObject(resultStr);
|
||||
} catch (Exception e) {
|
||||
throw new Exception(resultStr);
|
||||
}
|
||||
if (resultArray != null) {
|
||||
for (int i = 0; i < resultArray.size(); i++) {
|
||||
JSONObject jsonObject = resultArray.getJSONObject(i);
|
||||
MavenArtifact artifact = new MavenArtifact();
|
||||
artifact.setGroupId(jsonObject.getString("groupId"));
|
||||
artifact.setArtifactId(jsonObject.getString("artifactId"));
|
||||
artifact.setVersion(jsonObject.getString("version"));
|
||||
artifact.setType(jsonObject.getString("extension"));
|
||||
artifact.setDescription(jsonObject.getString("description"));
|
||||
artifact.setLastUpdated(jsonObject.getString("last_updated"));
|
||||
// artifact.setLicense(jsonObject.getString("license"));
|
||||
// artifact.setLicenseUrl(jsonObject.getString("licenseUrl"));
|
||||
// artifact.setUrl(jsonObject.getString("url"));
|
||||
resultList.add(artifact);
|
||||
}
|
||||
}
|
||||
currentQueryHandlerCopy.set(currentQueryHandler);
|
||||
LAST_HANDLER_MAP.put(serverBean, currentQueryHandler);
|
||||
return result;
|
||||
}
|
||||
|
||||
private AbsNexus3SearchHandler createQueryHandler(int seq) {
|
||||
AbsNexus3SearchHandler retHandler;
|
||||
switch (seq) {
|
||||
case 1:
|
||||
retHandler = new Nexus3BetaSearchHandler(serverBean);
|
||||
break;
|
||||
case 2:
|
||||
retHandler = new Nexus3ScriptSearchHandler(serverBean);
|
||||
break;
|
||||
default:
|
||||
retHandler = new Nexus3V1SearchHandler(serverBean);
|
||||
}
|
||||
return retHandler;
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,248 +0,0 @@
|
||||
package org.talend.librariesmanager.nexus.nexus3.handler;
|
||||
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2018 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.HttpHeaders;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.nexus.HttpClientTransport;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
public abstract class AbsNexus3SearchHandler implements INexus3SearchHandler {
|
||||
private static Logger log = Logger.getLogger(AbsNexus3SearchHandler.class);
|
||||
protected ArtifactRepositoryBean serverBean;
|
||||
|
||||
/**
|
||||
* {@value}
|
||||
* <p>
|
||||
* System property of nexus3 socket timeout, the unit is second.
|
||||
*/
|
||||
private final String KEY_NEXUS3_SOCKET_TIMEOUT = "nexus3.socket.timeout";
|
||||
|
||||
private final int DEFAULT_SOCKET_TIMEOUT = 10 * 1000; // The default value is 10S
|
||||
|
||||
public AbsNexus3SearchHandler(ArtifactRepositoryBean serverBean) {
|
||||
this.serverBean = serverBean;
|
||||
}
|
||||
|
||||
protected String getServerUrl() {
|
||||
String serverUrl = serverBean.getServer();
|
||||
if (!serverUrl.endsWith("/")) { //$NON-NLS-1$
|
||||
serverUrl = serverUrl + "/"; //$NON-NLS-1$
|
||||
}
|
||||
return serverUrl;
|
||||
}
|
||||
|
||||
protected abstract String getSearchUrl();
|
||||
|
||||
@Override
|
||||
public List<MavenArtifact> search(String repositoryId, String groupIdToSearch, String artifactId, String versionToSearch)
|
||||
throws Exception {
|
||||
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
|
||||
String searchUrl = getSearchUrl();
|
||||
String continuationToken = null;
|
||||
while (true) {
|
||||
String query = getQueryParameter(repositoryId, groupIdToSearch, artifactId, versionToSearch, continuationToken);
|
||||
String content = doRequest(searchUrl + query);
|
||||
continuationToken = parseResult(content, resultList);
|
||||
if (continuationToken == null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
protected String doRequest(final String url) throws URISyntaxException, Exception {
|
||||
final StringBuffer sb = new StringBuffer();
|
||||
new HttpClientTransport(url, serverBean.getUserName(), serverBean.getPassword()) {
|
||||
|
||||
@Override
|
||||
protected HttpResponse execute(IProgressMonitor monitor, DefaultHttpClient httpClient, URI targetURI)
|
||||
throws Exception {
|
||||
HttpGet httpGet = new HttpGet(targetURI);
|
||||
String userName = serverBean.getUserName();
|
||||
if (StringUtils.isNotBlank(userName) && !Boolean.getBoolean("talend.studio.search.nexus3.disableBasicAuth")) {
|
||||
String auth = userName + ":" + serverBean.getPassword();
|
||||
String authHeader = "Basic " + new String(Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8)));
|
||||
httpGet.setHeader(HttpHeaders.AUTHORIZATION, authHeader);
|
||||
httpClient.setCredentialsProvider(null);
|
||||
}
|
||||
HttpResponse response = httpClient.execute(httpGet);
|
||||
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
|
||||
sb.append(EntityUtils.toString(response.getEntity()));
|
||||
} else {
|
||||
throw new Exception(response.toString());
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
}.doRequest(null, new URI(url));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected String parseResult(String content, List<MavenArtifact> resultList) throws Exception {
|
||||
if (StringUtils.isEmpty(content)) {
|
||||
return null;
|
||||
}
|
||||
JSONObject responseObject = JSONObject.fromObject(content);
|
||||
String resultStr = responseObject.getString("items"); //$NON-NLS-1$
|
||||
String continuationToken = responseObject.getString("continuationToken");
|
||||
if (StringUtils.isEmpty(continuationToken) || "null".equalsIgnoreCase(continuationToken)) {
|
||||
continuationToken = null;
|
||||
}
|
||||
JSONArray resultArray = null;
|
||||
try {
|
||||
resultArray = JSONArray.fromObject(resultStr);
|
||||
} catch (Exception e) {
|
||||
throw new Exception(resultStr);
|
||||
}
|
||||
if (resultArray != null) {
|
||||
for (int i = 0; i < resultArray.size(); i++) {
|
||||
JSONObject jsonObject = resultArray.getJSONObject(i);
|
||||
MavenArtifact artifact = new MavenArtifact();
|
||||
artifact.setGroupId(jsonObject.getString("group")); //$NON-NLS-1$
|
||||
artifact.setArtifactId(jsonObject.getString("name")); //$NON-NLS-1$
|
||||
artifact.setVersion(jsonObject.getString("version")); //$NON-NLS-1$
|
||||
JSONArray assertsArray = jsonObject.getJSONArray("assets"); //$NON-NLS-1$
|
||||
artifact.setType(getPackageType(assertsArray));
|
||||
if (artifact.getType() != null) {
|
||||
fillCheckSumData(assertsArray, artifact);
|
||||
resultList.add(artifact);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return continuationToken;
|
||||
}
|
||||
|
||||
protected String getPackageType(JSONArray assertsArray) {
|
||||
String type = null;
|
||||
if (assertsArray != null) {
|
||||
for (int i = 0; i < assertsArray.size(); i++) {
|
||||
JSONObject jsonObject = assertsArray.getJSONObject(i);
|
||||
String path = jsonObject.getString("path"); //$NON-NLS-1$
|
||||
if (path != null && path.endsWith(".exe")) { //$NON-NLS-1$
|
||||
return "exe"; //$NON-NLS-1$
|
||||
}
|
||||
if (path != null && path.endsWith(".zip")) { //$NON-NLS-1$
|
||||
return "zip"; //$NON-NLS-1$
|
||||
}
|
||||
if (path != null && path.endsWith(".jar")) { //$NON-NLS-1$
|
||||
return "jar"; //$NON-NLS-1$
|
||||
}
|
||||
if (path != null && path.endsWith(".pom")) { //$NON-NLS-1$
|
||||
type = "pom"; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
private void fillCheckSumData(JSONArray assertsArray, MavenArtifact artifact) {
|
||||
if (assertsArray != null) {
|
||||
for (int i = 0; i < assertsArray.size(); i++) {
|
||||
JSONObject jsonObject = assertsArray.getJSONObject(i);
|
||||
if (jsonObject.containsKey("path")) { //$NON-NLS-1$
|
||||
String path = jsonObject.getString("path"); //$NON-NLS-1$
|
||||
if (path != null && path.endsWith(artifact.getType())) { // $NON-NLS-1$
|
||||
if (jsonObject.containsKey("checksum")) {
|
||||
JSONObject checksumObject = jsonObject.getJSONObject("checksum"); //$NON-NLS-1$
|
||||
if (checksumObject != null && checksumObject.containsKey("sha1")) {//$NON-NLS-1$
|
||||
artifact.setSha1(checksumObject.getString("sha1")); //$NON-NLS-1$
|
||||
artifact.setMd5(checksumObject.getString("md5")); //$NON-NLS-1$
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String getQueryParameter(String repositoryId, String groupIdToSearch, String artifactId, String versionToSearch,
|
||||
String continuationToken) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
boolean hasParameter = false;
|
||||
if (StringUtils.isNoneEmpty(repositoryId)) {
|
||||
sb.append("repository=").append(repositoryId); //$NON-NLS-1$
|
||||
hasParameter = true;
|
||||
}
|
||||
if (StringUtils.isNoneEmpty(groupIdToSearch)) {
|
||||
if (hasParameter) {
|
||||
sb.append("&"); //$NON-NLS-1$
|
||||
}
|
||||
sb.append("group=").append(groupIdToSearch); //$NON-NLS-1$
|
||||
hasParameter = true;
|
||||
}
|
||||
if (StringUtils.isNoneEmpty(artifactId)) {
|
||||
if (hasParameter) {
|
||||
sb.append("&"); //$NON-NLS-1$
|
||||
}
|
||||
sb.append("name=").append(artifactId); //$NON-NLS-1$
|
||||
hasParameter = true;
|
||||
}
|
||||
if (StringUtils.isNoneEmpty(versionToSearch)) {
|
||||
if (hasParameter) {
|
||||
sb.append("&"); //$NON-NLS-1$
|
||||
}
|
||||
sb.append("version=").append(versionToSearch); //$NON-NLS-1$
|
||||
hasParameter = true;
|
||||
}
|
||||
if (StringUtils.isNoneEmpty(continuationToken)) {
|
||||
if (hasParameter) {
|
||||
sb.append("&"); //$NON-NLS-1$
|
||||
}
|
||||
sb.append("continuationToken=").append(continuationToken); //$NON-NLS-1$
|
||||
hasParameter = true;
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected String getAuthenticationItem() {
|
||||
String userPass = serverBean.getUserName() + ":" + serverBean.getPassword(); //$NON-NLS-1$
|
||||
String basicAuth = "Basic " + new String(new Base64().encode(userPass.getBytes())); //$NON-NLS-1$
|
||||
return basicAuth;
|
||||
}
|
||||
|
||||
protected int getNexus3SocketTimeout() {
|
||||
int socketTimeout = DEFAULT_SOCKET_TIMEOUT;
|
||||
String strValue = System.getProperty(KEY_NEXUS3_SOCKET_TIMEOUT);
|
||||
if (StringUtils.isNotEmpty(strValue)) {
|
||||
try {
|
||||
int value = Integer.parseInt(strValue);
|
||||
socketTimeout = value * 1000;
|
||||
} catch (NumberFormatException ex) {
|
||||
log.error("Parse nexus3 socket timeout error:" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
return socketTimeout;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package org.talend.librariesmanager.nexus.nexus3.handler;
|
||||
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2018 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
|
||||
public interface INexus3SearchHandler {
|
||||
|
||||
public List<MavenArtifact> search(String repositoryId, String groupIdToSearch, String artifactId, String versionToSearch)
|
||||
throws Exception;
|
||||
|
||||
public String getHandlerVersion();
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package org.talend.librariesmanager.nexus.nexus3.handler;
|
||||
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
|
||||
public class Nexus3BetaSearchHandler extends AbsNexus3SearchHandler {
|
||||
|
||||
private String SEARCH_SERVICE = "service/rest/beta/search?"; //$NON-NLS-1$
|
||||
|
||||
public Nexus3BetaSearchHandler(ArtifactRepositoryBean serverBean) {
|
||||
super(serverBean);
|
||||
}
|
||||
|
||||
protected String getSearchUrl() {
|
||||
return this.getServerUrl() + SEARCH_SERVICE;
|
||||
}
|
||||
|
||||
public String getHandlerVersion() {
|
||||
return "Nexus3.beta"; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
package org.talend.librariesmanager.nexus.nexus3.handler;
|
||||
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2018 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.fluent.Request;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
public class Nexus3ScriptSearchHandler extends AbsNexus3SearchHandler {
|
||||
|
||||
private String SEARCH_SERVICE = "service/rest/v1/script/search/run"; //$NON-NLS-1$
|
||||
|
||||
public Nexus3ScriptSearchHandler(ArtifactRepositoryBean serverBean) {
|
||||
super(serverBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MavenArtifact> search(String repositoryId, String groupIdToSearch, String artifactId, String versionToSearch)
|
||||
throws Exception {
|
||||
String searchUrl = getSearchUrl();
|
||||
Request request = this.getRequest(searchUrl);
|
||||
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
|
||||
JSONObject body = new JSONObject();
|
||||
body.put("repositoryId", repositoryId); //$NON-NLS-1$
|
||||
if (groupIdToSearch != null) {
|
||||
body.put("g", groupIdToSearch); //$NON-NLS-1$
|
||||
}
|
||||
if (artifactId != null) {
|
||||
body.put("a", artifactId); //$NON-NLS-1$
|
||||
}
|
||||
if (versionToSearch != null) {
|
||||
body.put("v", versionToSearch); //$NON-NLS-1$
|
||||
}
|
||||
request.bodyString(body.toString(),
|
||||
ContentType.create(ContentType.APPLICATION_JSON.getMimeType(), StandardCharsets.UTF_8));
|
||||
HttpResponse response = request.execute().returnResponse();
|
||||
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
|
||||
String content = EntityUtils.toString(response.getEntity());
|
||||
if (content.isEmpty()) {
|
||||
return resultList;
|
||||
}
|
||||
JSONObject responseObject = JSONObject.fromObject(content);
|
||||
String resultStr = responseObject.getString("result"); //$NON-NLS-1$
|
||||
JSONArray resultArray = null;
|
||||
try {
|
||||
resultArray = JSONArray.fromObject(resultStr);
|
||||
} catch (Exception e) {
|
||||
throw new Exception(resultStr);
|
||||
}
|
||||
if (resultArray != null) {
|
||||
for (int i = 0; i < resultArray.size(); i++) {
|
||||
JSONObject jsonObject = resultArray.getJSONObject(i);
|
||||
MavenArtifact artifact = new MavenArtifact();
|
||||
artifact.setGroupId(jsonObject.getString("groupId")); //$NON-NLS-1$
|
||||
artifact.setArtifactId(jsonObject.getString("artifactId")); //$NON-NLS-1$
|
||||
artifact.setVersion(jsonObject.getString("version")); //$NON-NLS-1$
|
||||
artifact.setType(jsonObject.getString("extension")); //$NON-NLS-1$
|
||||
artifact.setDescription(jsonObject.getString("description")); //$NON-NLS-1$
|
||||
artifact.setLastUpdated(jsonObject.getString("last_updated")); //$NON-NLS-1$
|
||||
resultList.add(artifact);
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
} else {
|
||||
throw new Exception(response.toString());
|
||||
}
|
||||
}
|
||||
|
||||
protected Request getRequest(String searchUrl) {
|
||||
Request request = Request.Post(searchUrl);
|
||||
Header authority = new BasicHeader("Authorization", getAuthenticationItem()); //$NON-NLS-1$
|
||||
Header contentType = new BasicHeader("Content-Type", "text/plain"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
request.addHeader(contentType);
|
||||
request.addHeader(authority);
|
||||
request.socketTimeout(this.getNexus3SocketTimeout());
|
||||
return request;
|
||||
}
|
||||
|
||||
protected String getSearchUrl() {
|
||||
return this.getServerUrl() + SEARCH_SERVICE;
|
||||
}
|
||||
|
||||
public String getHandlerVersion() {
|
||||
return "Nexus3.script"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package org.talend.librariesmanager.nexus.nexus3.handler;
|
||||
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
|
||||
public class Nexus3V1SearchHandler extends AbsNexus3SearchHandler {
|
||||
|
||||
private String SEARCH_SERVICE = "service/rest/v1/search?";
|
||||
|
||||
public Nexus3V1SearchHandler(ArtifactRepositoryBean serverBean) {
|
||||
super(serverBean);
|
||||
}
|
||||
|
||||
protected String getSearchUrl() {
|
||||
return this.getServerUrl() + SEARCH_SERVICE;
|
||||
}
|
||||
|
||||
public String getHandlerVersion() {
|
||||
return "Nexus3.V1"; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.librariesmanager.nexus.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.codehaus.jackson.map.util.ISO8601Utils;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.nexus.IRepositoryArtifactHandler;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
|
||||
public class ShareLibrariesUtil {
|
||||
|
||||
public static boolean isSameFileWithRemote(File localFile, List<MavenArtifact> artifactList,
|
||||
ArtifactRepositoryBean customNexusServer, IRepositoryArtifactHandler customerRepHandler, boolean isSnapshotVersion)
|
||||
throws Exception {
|
||||
String localFileShaCode = "";
|
||||
|
||||
try (FileInputStream fi = new FileInputStream(localFile)) {
|
||||
|
||||
localFileShaCode = DigestUtils.shaHex(fi);
|
||||
|
||||
}
|
||||
String remoteSha1 = null;
|
||||
if (ArtifactRepositoryBean.NexusType.ARTIFACTORY.name().equalsIgnoreCase(customNexusServer.getType())) {
|
||||
MavenArtifact lastUpdatedArtifact = getLateUpdatedMavenArtifact(artifactList);
|
||||
if (lastUpdatedArtifact != null) {
|
||||
remoteSha1 = lastUpdatedArtifact.getSha1();
|
||||
}
|
||||
} else if (ArtifactRepositoryBean.NexusType.NEXUS_3.name().equalsIgnoreCase(customNexusServer.getType())) {
|
||||
MavenArtifact lastUpdatedArtifact = artifactList.stream().max(Comparator.comparing(e -> e.getVersion())).get();
|
||||
if (lastUpdatedArtifact != null) {
|
||||
remoteSha1 = lastUpdatedArtifact.getSha1();
|
||||
}
|
||||
} else {
|
||||
if (!isSnapshotVersion && !Boolean.getBoolean("force_libs_release_update")) {
|
||||
return true;
|
||||
}
|
||||
MavenArtifact lastUpdatedArtifact = artifactList.get(0);
|
||||
if (lastUpdatedArtifact != null) {
|
||||
remoteSha1 = customerRepHandler.resolveRemoteSha1(lastUpdatedArtifact, !isSnapshotVersion);
|
||||
}
|
||||
}
|
||||
if (StringUtils.equals(localFileShaCode, remoteSha1)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static MavenArtifact getLateUpdatedMavenArtifact(List<MavenArtifact> artifactList) {
|
||||
if (artifactList.size() == 1) {
|
||||
return artifactList.get(0);
|
||||
}
|
||||
MavenArtifact latestVersion = null;
|
||||
Date lastUpdate = null;
|
||||
for (MavenArtifact art : artifactList) {
|
||||
if (latestVersion == null) {
|
||||
if (art.getLastUpdated() != null) {
|
||||
latestVersion = art;
|
||||
lastUpdate = parsetDate(art.getLastUpdated());
|
||||
}
|
||||
} else if (art.getLastUpdated() != null && lastUpdate != null) {
|
||||
Date artLastUpdate = parsetDate(art.getLastUpdated());
|
||||
if (artLastUpdate != null && lastUpdate.getTime() < artLastUpdate.getTime()) {
|
||||
latestVersion = art;
|
||||
lastUpdate = artLastUpdate;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (latestVersion != null) {
|
||||
return latestVersion;
|
||||
} else {
|
||||
return artifactList.get(artifactList.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private static Date parsetDate(String strDate) {
|
||||
Date date = null;
|
||||
if (strDate != null) {
|
||||
try {
|
||||
date = ISO8601Utils.parse(strDate);
|
||||
} catch (Exception ex) {
|
||||
ExceptionHandler.process(ex);
|
||||
}
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
public static void putArtifactToMap(MavenArtifact artifact, Map<String, List<MavenArtifact>> map, boolean isShapshot) {
|
||||
String key = getArtifactKey(artifact, isShapshot);
|
||||
List<MavenArtifact> list = map.get(key);
|
||||
if (list == null) {
|
||||
list = new ArrayList<MavenArtifact>();
|
||||
map.put(key, list);
|
||||
}
|
||||
list.add(artifact);
|
||||
}
|
||||
|
||||
public static String getArtifactKey(MavenArtifact artifact, boolean isShapshot) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(artifact.getGroupId()).append("-");
|
||||
sb.append(artifact.getArtifactId()).append("-");
|
||||
String version = artifact.getVersion();
|
||||
if (isShapshot) {
|
||||
version = VersionUtil.getSNAPSHOTVersion(version);
|
||||
}
|
||||
sb.append(version);
|
||||
if (StringUtils.isNotEmpty(artifact.getClassifier())) {
|
||||
sb.append("-").append(artifact.getClassifier());
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.librariesmanager.nexus.utils;
|
||||
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
|
||||
/**
|
||||
* DOC hwang class global comment. Detailled comment
|
||||
*/
|
||||
public class VersionUtil {
|
||||
|
||||
public static String getSNAPSHOTVersion(String rVersion) {
|
||||
if(rVersion == null) {
|
||||
return rVersion;
|
||||
}
|
||||
if(rVersion.contains("-")) {
|
||||
return rVersion.substring(0, rVersion.indexOf("-") + 1) + MavenUrlHelper.VERSION_SNAPSHOT;
|
||||
}
|
||||
return rVersion;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,16 +18,11 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.network.NetworkUtil;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.language.ECodeLanguage;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.general.ModuleNeeded.ELibraryInstallStatus;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.core.prefs.ITalendCorePrefConstants;
|
||||
import org.talend.designer.core.IDesignerCoreService;
|
||||
import org.talend.librariesmanager.model.ModulesNeededProvider;
|
||||
|
||||
@@ -108,15 +103,4 @@ public class LibrariesManagerUtils {
|
||||
}
|
||||
return updatedModules;
|
||||
}
|
||||
|
||||
public static boolean shareLibsAtStartup() {
|
||||
boolean ret = ITalendCorePrefConstants.NEXUS_SHARE_LIBS_DEFAULT;
|
||||
try {
|
||||
IEclipsePreferences node = InstanceScope.INSTANCE.getNode(NetworkUtil.ORG_TALEND_DESIGNER_CORE);
|
||||
ret = node.getBoolean(ITalendCorePrefConstants.NEXUS_SHARE_LIBS, ITalendCorePrefConstants.NEXUS_SHARE_LIBS_DEFAULT);
|
||||
} catch (Throwable e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.layout.RowLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.commons.ui.swt.formtools.Form;
|
||||
@@ -633,8 +634,4 @@ public abstract class AbstractForm extends Composite {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ConnectionItem getConnectionItem() {
|
||||
return this.connectionItem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,12 +376,11 @@ public class ExtractManager {
|
||||
|
||||
// StringUtils.trimToEmpty(name) is because bug 4547
|
||||
if (name != null && StringUtils.trimToEmpty(name).equals(ETableTypes.TABLETYPE_SYNONYM.getName())) {
|
||||
String nodeValue = newNode.getValue();
|
||||
String tableName = getTableNameBySynonyms(extractMeta.getConn(), nodeValue);
|
||||
String tableName = getTableNameBySynonyms(extractMeta.getConn(), newNode.getValue());
|
||||
if (tableName != null && tableName.contains("/")) {
|
||||
tableName = tableName.replace("/", "");
|
||||
}
|
||||
fillSynonyms(metadataConnection, metadataColumns, table, tableName, nodeValue, dbMetaData);
|
||||
fillSynonyms(metadataConnection, metadataColumns, table, tableName, dbMetaData);
|
||||
} else {
|
||||
EDatabaseTypeName currentEDatabaseType = EDatabaseTypeName.getTypeFromDbType(metadataConnection.getDbType());
|
||||
metadataColumns = MetadataFillFactory.getDBInstance(currentEDatabaseType).fillColumns(table, metadataConnection,
|
||||
@@ -466,7 +465,7 @@ public class ExtractManager {
|
||||
* @throws SQLException
|
||||
*/
|
||||
protected void fillSynonyms(IMetadataConnection metadataConnection, List<TdColumn> metadataColumns, NamedColumnSet table,
|
||||
String tableName, String synonymName, DatabaseMetaData dbMetaData) throws SQLException {
|
||||
String tableName, DatabaseMetaData dbMetaData) throws SQLException {
|
||||
// nothing to do by default
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.talend.cwm.helper.ColumnHelper;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
import org.talend.cwm.relational.TdColumn;
|
||||
import org.talend.metadata.managment.utils.ManagementTextUtils;
|
||||
|
||||
import orgomg.cwm.resource.relational.NamedColumnSet;
|
||||
|
||||
/**
|
||||
@@ -103,7 +102,7 @@ public class IBMDB2ExtractManager extends ExtractManager {
|
||||
|
||||
@Override
|
||||
protected void fillSynonyms(IMetadataConnection metadataConnection, List<TdColumn> metadataColumns, NamedColumnSet table,
|
||||
String tableName, String synonymName, DatabaseMetaData dbMetaData) throws SQLException {
|
||||
String tableName, DatabaseMetaData dbMetaData) throws SQLException {
|
||||
if (metadataConnection == null || dbMetaData == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import org.talend.cwm.helper.ConnectionHelper;
|
||||
import org.talend.cwm.relational.TdColumn;
|
||||
import org.talend.metadata.managment.utils.ManagementTextUtils;
|
||||
import org.talend.utils.sql.metadata.constants.GetColumn;
|
||||
|
||||
import orgomg.cwm.resource.relational.NamedColumnSet;
|
||||
|
||||
/**
|
||||
@@ -91,7 +90,7 @@ public class MSSQLExtractManager extends ExtractManager {
|
||||
|
||||
@Override
|
||||
protected void fillSynonyms(IMetadataConnection metadataConnection, List<TdColumn> metadataColumns, NamedColumnSet table,
|
||||
String tableName, String synonymName, DatabaseMetaData dbMetaData) throws SQLException {
|
||||
String tableName, DatabaseMetaData dbMetaData) throws SQLException {
|
||||
if (metadataConnection == null || dbMetaData == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user