Compare commits
73 Commits
patch/TPS-
...
patch/7.3.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7252412ed | ||
|
|
af38e2a0b6 | ||
|
|
c3d3fcf665 | ||
|
|
987c6667ac | ||
|
|
f0401b97d1 | ||
|
|
26992f7cf9 | ||
|
|
169ab1c4cc | ||
|
|
f04049abc0 | ||
|
|
7e6f2dee19 | ||
|
|
2dd7ce6fac | ||
|
|
be373dd141 | ||
|
|
43876863e6 | ||
|
|
4ac2a830a9 | ||
|
|
3d6d3e77e3 | ||
|
|
71b4ccc531 | ||
|
|
48289a3c72 | ||
|
|
9a219873f1 | ||
|
|
d013d08bdc | ||
|
|
761dcc7902 | ||
|
|
0a85c8056c | ||
|
|
3df4cf1348 | ||
|
|
c7965cf552 | ||
|
|
61b55c0d2a | ||
|
|
be41bcbef3 | ||
|
|
2827919dae | ||
|
|
33848db788 | ||
|
|
ac359e295a | ||
|
|
6965eb79fa | ||
|
|
80f02ef1e7 | ||
|
|
7c50efdf21 | ||
|
|
7f40393753 | ||
|
|
356dba9940 | ||
|
|
83f7a577d9 | ||
|
|
e87f557a49 | ||
|
|
a51b3316d3 | ||
|
|
46a22c4ad0 | ||
|
|
f8cc600d06 | ||
|
|
3146ed307f | ||
|
|
f4f91a5323 | ||
|
|
2aee38595f | ||
|
|
dde32c8b49 | ||
|
|
563b69231f | ||
|
|
1ea6227f59 | ||
|
|
148e9e9253 | ||
|
|
1e6a43650f | ||
|
|
67616537b2 | ||
|
|
1df4e819e0 | ||
|
|
b3d6c45f2d | ||
|
|
f1341cd69f | ||
|
|
a64bcecb0c | ||
|
|
5707d4db94 | ||
|
|
5e20a78752 | ||
|
|
85e44cd5c6 | ||
|
|
8582c20f1a | ||
|
|
6216fd76ea | ||
|
|
71d339fc0a | ||
|
|
d286276e6d | ||
|
|
3996d24893 | ||
|
|
f37b5b6073 | ||
|
|
060a9c7f9e | ||
|
|
789b4c02c0 | ||
|
|
4c3e3dfb2c | ||
|
|
7b3a20a3b3 | ||
|
|
e3880f3904 | ||
|
|
d54ed2a62c | ||
|
|
cde1129ce4 | ||
|
|
1081ae3680 | ||
|
|
3e02adb157 | ||
|
|
c212142789 | ||
|
|
ab67a4cc91 | ||
|
|
675da3fc7d | ||
|
|
6f9ad53b0d | ||
|
|
6cfffe1775 |
@@ -13,7 +13,6 @@
|
||||
<plugin id="org.talend.libraries.jdbc.ingres" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.jdbc.mysql" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.jdbc.paraccel" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.jdbc.postgresql" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.jdbc.sqlite3" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.jdbc.teradata" download-size="0" install-size="0" version="0.0.0"/>
|
||||
</feature>
|
||||
|
||||
@@ -232,10 +232,50 @@ public class VersionUtils {
|
||||
* Check if studio version < other studio version record in remote project.
|
||||
*/
|
||||
public static boolean isInvalidProductVersion(String remoteFullProductVersion) {
|
||||
String localProductVersion = getInternalVersion();
|
||||
return isInvalidProductVersion(localProductVersion, remoteFullProductVersion);
|
||||
}
|
||||
|
||||
protected static boolean isInvalidProductVersion(String localProductVersion, String remoteFullProductVersion) {
|
||||
if (remoteFullProductVersion == null) {
|
||||
return false;
|
||||
}
|
||||
return getInternalVersion().compareTo(getProductVersionWithoutBranding(remoteFullProductVersion)) < 0;
|
||||
if (skipCheckingNightlyBuilds(localProductVersion, remoteFullProductVersion)) {
|
||||
return false;
|
||||
}
|
||||
return localProductVersion.compareTo(getProductVersionWithoutBranding(remoteFullProductVersion)) < 0;
|
||||
}
|
||||
|
||||
public static boolean productVersionIsNewer(String remoteFullProductVersion) {
|
||||
String localProductVersion = getInternalVersion();
|
||||
return productVersionIsNewer(localProductVersion, remoteFullProductVersion);
|
||||
}
|
||||
|
||||
protected static boolean productVersionIsNewer(String localProductVersion, String remoteFullProductVersion) {
|
||||
if (remoteFullProductVersion == null) {
|
||||
return false;
|
||||
}
|
||||
if (skipCheckingNightlyBuilds(localProductVersion, remoteFullProductVersion)) {
|
||||
return false;
|
||||
}
|
||||
return localProductVersion.compareTo(getProductVersionWithoutBranding(remoteFullProductVersion)) > 0;
|
||||
}
|
||||
|
||||
private static boolean skipCheckingNightlyBuilds(String localProductVersion, String remoteFullProductVersion) {
|
||||
String separator = "-"; //$NON-NLS-1$
|
||||
String localSuffix = StringUtils.substringAfterLast(localProductVersion, separator);
|
||||
|
||||
String remoteProductVersion = getProductVersionWithoutBranding(remoteFullProductVersion);
|
||||
String remoteSuffix = StringUtils.substringAfterLast(remoteProductVersion, separator);
|
||||
|
||||
String nightly = "SNAPSHOT"; //$NON-NLS-1$
|
||||
String milestone = "M"; //$NON-NLS-1$
|
||||
if ((localSuffix.equals(nightly) || localSuffix.startsWith(milestone))
|
||||
&& (remoteSuffix.equals(nightly) || remoteSuffix.startsWith(milestone))) {
|
||||
// skip checking between nightly/milestone build.
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getTalendVersion(String productVersion) {
|
||||
@@ -310,4 +350,24 @@ public class VersionUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getSimplifiedPatchName(String projectPatchName) {
|
||||
|
||||
if (projectPatchName != null) {
|
||||
String result = null;
|
||||
if (projectPatchName.contains("_") && projectPatchName.split("_").length >= 3) {
|
||||
result = projectPatchName.split("_")[2];
|
||||
if (!result.startsWith("R")) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (projectPatchName.contains("-")) {
|
||||
String[] split = projectPatchName.split("-");
|
||||
if (split != null && split.length > 0) {
|
||||
return result + "-" + split[split.length - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ package org.talend.commons.utils.network;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.Authenticator;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.PasswordAuthentication;
|
||||
@@ -22,7 +23,11 @@ import java.net.SocketException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -150,6 +155,28 @@ public class NetworkUtil {
|
||||
|
||||
@Override
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
String httpProxyHost = System.getProperty("http.proxyHost"); //$NON-NLS-1$
|
||||
String httpProxyPort = System.getProperty("http.proxyPort"); //$NON-NLS-1$
|
||||
String httpsProxyHost = System.getProperty("https.proxyHost"); //$NON-NLS-1$
|
||||
String httpsProxyPort = System.getProperty("https.proxyPort"); //$NON-NLS-1$
|
||||
String requestingHost = getRequestingHost();
|
||||
int requestingPort = getRequestingPort();
|
||||
String proxyHost = null;
|
||||
String proxyPort = null;
|
||||
boolean isHttp = false;
|
||||
if ("http".equalsIgnoreCase(getRequestingScheme())) {
|
||||
isHttp = true;
|
||||
}
|
||||
if (isHttp && StringUtils.isNotBlank(httpProxyHost)) {
|
||||
proxyHost = httpProxyHost;
|
||||
proxyPort = httpProxyPort;
|
||||
} else {
|
||||
proxyHost = httpsProxyHost;
|
||||
proxyPort = httpsProxyPort;
|
||||
}
|
||||
if (!StringUtils.equals(proxyHost, requestingHost) || !StringUtils.equals(proxyPort, "" + requestingPort)) {
|
||||
return null;
|
||||
}
|
||||
String httpProxyUser = System.getProperty("http.proxyUser"); //$NON-NLS-1$
|
||||
String httpProxyPassword = System.getProperty("http.proxyPassword"); //$NON-NLS-1$
|
||||
String httpsProxyUser = System.getProperty("https.proxyUser"); //$NON-NLS-1$
|
||||
@@ -167,7 +194,11 @@ public class NetworkUtil {
|
||||
proxyPassword = httpsProxyPassword.toCharArray();
|
||||
}
|
||||
}
|
||||
return new PasswordAuthentication(proxyUser, proxyPassword);
|
||||
if (StringUtils.isBlank(proxyUser)) {
|
||||
return null;
|
||||
} else {
|
||||
return new PasswordAuthentication(proxyUser, proxyPassword);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
@@ -206,6 +237,54 @@ public class NetworkUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getLocalLoopbackAddresses(boolean wrapIpV6) {
|
||||
Set<String> addresses = new LinkedHashSet<>();
|
||||
try {
|
||||
addresses.add(getIp(InetAddress.getLoopbackAddress(), wrapIpV6));
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
try {
|
||||
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
|
||||
while (networkInterfaces.hasMoreElements()) {
|
||||
NetworkInterface networkInterface = networkInterfaces.nextElement();
|
||||
Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
|
||||
while (inetAddresses.hasMoreElements()) {
|
||||
InetAddress inetAddress = inetAddresses.nextElement();
|
||||
if (inetAddress != null && inetAddress.isLoopbackAddress()) {
|
||||
addresses.add(getIp(inetAddress, wrapIpV6));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
if (addresses.isEmpty()) {
|
||||
addresses.add("127.0.0.1");
|
||||
String ipv6Loopback = "::1";
|
||||
if (wrapIpV6) {
|
||||
ipv6Loopback = "[" + ipv6Loopback + "]";
|
||||
}
|
||||
addresses.add(ipv6Loopback);
|
||||
}
|
||||
|
||||
return new ArrayList<>(addresses);
|
||||
}
|
||||
|
||||
private static String getIp(InetAddress inetAddress, boolean wrapIpV6) {
|
||||
if (wrapIpV6 && Inet6Address.class.isInstance(inetAddress)) {
|
||||
String addr = inetAddress.getHostAddress();
|
||||
if (!addr.startsWith("[") || !addr.endsWith("]")) {
|
||||
addr = "[" + addr + "]";
|
||||
}
|
||||
return addr;
|
||||
} else {
|
||||
return inetAddress.getHostAddress();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSelfAddress(String addr) {
|
||||
if (addr == null || addr.isEmpty()) {
|
||||
return false; // ?
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.net.URISyntaxException;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -38,6 +39,8 @@ 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.internal.net.ProxyType;
|
||||
import org.eclipse.core.net.proxy.IProxyChangeEvent;
|
||||
import org.eclipse.core.net.proxy.IProxyService;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
@@ -77,6 +80,14 @@ public class TalendProxySelector extends ProxySelector {
|
||||
|
||||
private static final String PROP_DISABLE_DEFAULT_SELECTOR_PROVIDER = "talend.studio.proxy.disableDefaultSelectorProvider";
|
||||
|
||||
private static final String PROP_PROXY_EXCLUDE_LOOPBACK_ADDRESS_AUTOMATICALLY = "talend.studio.proxy.excludeLoopbackAutomatically";
|
||||
|
||||
private static final String PROP_PROXY_EXCLUDE_LOOPBACK_ADDRESS_AUTOMATICALLY_DEFAULT = "true";
|
||||
|
||||
private static final String PROP_PROXY_HTTP_NON_PROXYHOSTS = "http.nonProxyHosts";
|
||||
|
||||
private static final String PROP_PROXY_HTTPS_NON_PROXYHOSTS = "https.nonProxyHosts";
|
||||
|
||||
/**
|
||||
* Example: update.talend.com,socket:http,https:http;nexus.talend.com,socket,http;,socket:http
|
||||
*/
|
||||
@@ -104,6 +115,8 @@ public class TalendProxySelector extends ProxySelector {
|
||||
|
||||
private EProxySelector eProxySelector;
|
||||
|
||||
private IProxyService proxyManager;
|
||||
|
||||
final private Map<Object, Collection<IProxySelectorProvider>> selectorProviders;
|
||||
|
||||
private Map<String, Map<String, String>> hostMap;
|
||||
@@ -114,6 +127,10 @@ public class TalendProxySelector extends ProxySelector {
|
||||
|
||||
private static Object instanceLock = new Object();
|
||||
|
||||
private List<String> localLoopbackAddresses;
|
||||
|
||||
private Object localLoopbackAddressesLock = new Object();
|
||||
|
||||
private boolean printProxyLog = false;
|
||||
|
||||
private boolean allowProxyRedirect = false;
|
||||
@@ -126,6 +143,8 @@ public class TalendProxySelector extends ProxySelector {
|
||||
|
||||
private boolean updateSystemPropertiesForJre = true;
|
||||
|
||||
private boolean excludeLoopbackAddressAutomatically = false;
|
||||
|
||||
private TalendProxySelector(final ProxySelector eclipseDefaultSelector) {
|
||||
this.eclipseDefaultSelector = eclipseDefaultSelector;
|
||||
this.jreDefaultSelector = new DefaultProxySelector();
|
||||
@@ -139,6 +158,8 @@ public class TalendProxySelector extends ProxySelector {
|
||||
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()));
|
||||
excludeLoopbackAddressAutomatically = Boolean.valueOf(System.getProperty(
|
||||
PROP_PROXY_EXCLUDE_LOOPBACK_ADDRESS_AUTOMATICALLY, PROP_PROXY_EXCLUDE_LOOPBACK_ADDRESS_AUTOMATICALLY_DEFAULT));
|
||||
|
||||
switch (System.getProperty(PROP_PROXY_SELECTOR, PROP_PROXY_SELECTOR_DEFAULT).toLowerCase()) {
|
||||
case PROP_PROXY_SELECTOR_JRE:
|
||||
@@ -148,11 +169,83 @@ public class TalendProxySelector extends ProxySelector {
|
||||
this.eProxySelector = EProxySelector.eclipse_default;
|
||||
break;
|
||||
}
|
||||
proxyManager = ProxyManager.getProxyManager();
|
||||
checkProxyManager(IProxyChangeEvent.PROXY_DATA_CHANGED);
|
||||
proxyManager.addProxyChangeListener(event -> checkProxyManager(event.getChangeType()));
|
||||
|
||||
initHostMap();
|
||||
initRedirectList();
|
||||
}
|
||||
|
||||
private void checkProxyManager(int changeEvent) {
|
||||
try {
|
||||
if (IProxyChangeEvent.PROXY_DATA_CHANGED == changeEvent
|
||||
|| IProxyChangeEvent.NONPROXIED_HOSTS_CHANGED == changeEvent) {
|
||||
if (this.excludeLoopbackAddressAutomatically && proxyManager.isProxiesEnabled()) {
|
||||
List<String> addresses = getLocalLoopbackAddresses();
|
||||
if (addresses != null && !addresses.isEmpty()) {
|
||||
if (org.eclipse.core.internal.net.ProxySelector
|
||||
.canSetBypassHosts(org.eclipse.core.internal.net.ProxySelector.getDefaultProvider())) {
|
||||
List<String> configuredProxies = Arrays.asList(proxyManager.getNonProxiedHosts());
|
||||
if (!configuredProxies.containsAll(addresses)) {
|
||||
Set<String> nonProxyHosts = new HashSet<>(addresses);
|
||||
nonProxyHosts.addAll(configuredProxies);
|
||||
ExceptionHandler.log(
|
||||
this.getClass().getName() + ":" + "-D" + PROP_PROXY_EXCLUDE_LOOPBACK_ADDRESS_AUTOMATICALLY
|
||||
+ "=true, adding missing loopback addresses into eclipse nonProxyHosts: "
|
||||
+ nonProxyHosts);
|
||||
proxyManager.setNonProxiedHosts(nonProxyHosts.toArray(new String[0]));
|
||||
}
|
||||
} else {
|
||||
updateNonProxyHosts(addresses, PROP_PROXY_HTTP_NON_PROXYHOSTS);
|
||||
updateNonProxyHosts(addresses, PROP_PROXY_HTTPS_NON_PROXYHOSTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateNonProxyHosts(List<String> localLoopbackAddresses, final String nonProxyProperty) {
|
||||
if (localLoopbackAddresses != null && !localLoopbackAddresses.isEmpty()) {
|
||||
Set<String> nonProxyHosts = new HashSet<>(localLoopbackAddresses);
|
||||
String property = System.getProperty(nonProxyProperty);
|
||||
boolean update = true;
|
||||
if (StringUtils.isNotBlank(property)) {
|
||||
List<String> configuredProxies = Arrays.asList(ProxyType.convertPropertyStringToHosts(property));
|
||||
if (configuredProxies.containsAll(localLoopbackAddresses)) {
|
||||
update = false;
|
||||
} else {
|
||||
nonProxyHosts.addAll(configuredProxies);
|
||||
}
|
||||
}
|
||||
if (update) {
|
||||
ExceptionHandler.log(this.getClass().getName() + ":" + "-D" + PROP_PROXY_EXCLUDE_LOOPBACK_ADDRESS_AUTOMATICALLY
|
||||
+ "=true, adding missing loopback addresses into " + nonProxyProperty + ": " + nonProxyHosts);
|
||||
System.setProperty(nonProxyProperty,
|
||||
ProxyType.convertHostsToPropertyString(nonProxyHosts.toArray(new String[0])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getLocalLoopbackAddresses() {
|
||||
if (this.localLoopbackAddresses == null) {
|
||||
synchronized (localLoopbackAddressesLock) {
|
||||
if (this.localLoopbackAddresses == null) {
|
||||
List<String> addresses = NetworkUtil.getLocalLoopbackAddresses(false);
|
||||
final String localhost = "localhost";
|
||||
if (!addresses.contains(localhost)) {
|
||||
addresses.add(localhost);
|
||||
}
|
||||
this.localLoopbackAddresses = addresses;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.localLoopbackAddresses;
|
||||
}
|
||||
|
||||
private void initHostMap() {
|
||||
try {
|
||||
hostMap = new HashMap<>();
|
||||
@@ -282,7 +375,27 @@ public class TalendProxySelector extends ProxySelector {
|
||||
ExceptionHandler.log("TalendProxySelector.select " + uri);
|
||||
}
|
||||
if (uri == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
List<Proxy> result = new ArrayList<>();
|
||||
result.add(Proxy.NO_PROXY);
|
||||
return result;
|
||||
}
|
||||
try {
|
||||
if (this.excludeLoopbackAddressAutomatically) {
|
||||
List<String> addresses = getLocalLoopbackAddresses();
|
||||
if (addresses != null) {
|
||||
String host = uri.getHost();
|
||||
if (addresses.contains(host)) {
|
||||
if (printProxyLog) {
|
||||
ExceptionHandler.log(uri + " is excluded from proxy");
|
||||
}
|
||||
List<Proxy> result = new ArrayList<>();
|
||||
result.add(Proxy.NO_PROXY);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
URI validatedUri = validateUri(uri);
|
||||
Set<Proxy> results = new LinkedHashSet<>();
|
||||
@@ -332,6 +445,9 @@ public class TalendProxySelector extends ProxySelector {
|
||||
ExceptionHandler.log("Selected proxys for " + uri + ", " + proxys);
|
||||
ExceptionHandler.process(new Exception("Proxy call stacks"), Priority.INFO);
|
||||
}
|
||||
if (results.isEmpty()) {
|
||||
results.add(Proxy.NO_PROXY);
|
||||
}
|
||||
return new LinkedList<Proxy>(results);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.text.DecimalFormat;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Properties;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -36,8 +37,6 @@ import org.talend.commons.exception.CommonExceptionHandler;
|
||||
*/
|
||||
public class PerformanceStatisticUtil {
|
||||
|
||||
private static final DecimalFormat DF = new DecimalFormat("###.##");
|
||||
|
||||
private static final int MEGABYTE = 1024 * 1024;// MB = 1024*1024 byte
|
||||
|
||||
private static final int KILOBYTE = 1024;// kb=1024 byte
|
||||
@@ -250,8 +249,8 @@ public class PerformanceStatisticUtil {
|
||||
digital_ioWAverageMbSec = (digital_ioWAverageMbSec * digital_ioCount + bwMbSec) / (digital_ioCount + 1);
|
||||
digital_ioWMbSec = bwMbSec;
|
||||
|
||||
props.setProperty(StatisticKeys.IO_W_AVERAGE_MB_SEC.get(), "" + DF.format(digital_ioWAverageMbSec));
|
||||
props.setProperty(StatisticKeys.IO_W_MB_SEC.get(), "" + DF.format(digital_ioWMbSec));
|
||||
props.setProperty(StatisticKeys.IO_W_AVERAGE_MB_SEC.get(), format(digital_ioWAverageMbSec));
|
||||
props.setProperty(StatisticKeys.IO_W_MB_SEC.get(), format(digital_ioWMbSec));
|
||||
}
|
||||
|
||||
private static long writeIO(int numOfBlocks, BlockSequence blockSequence, int blockSize, File testFile) {
|
||||
@@ -324,11 +323,15 @@ public class PerformanceStatisticUtil {
|
||||
digital_ioRMbSec = bwMbSec;
|
||||
digital_ioCount++;
|
||||
|
||||
props.setProperty(StatisticKeys.IO_R_AVERAGE_MB_SEC.get(), "" + DF.format(digital_ioRAverageMbSec));
|
||||
props.setProperty(StatisticKeys.IO_R_MB_SEC.get(), "" + DF.format(digital_ioRMbSec));
|
||||
props.setProperty(StatisticKeys.IO_R_AVERAGE_MB_SEC.get(), format(digital_ioRAverageMbSec));
|
||||
props.setProperty(StatisticKeys.IO_R_MB_SEC.get(), format(digital_ioRMbSec));
|
||||
props.setProperty(StatisticKeys.IO_COUNT.get(), "" + digital_ioCount);
|
||||
}
|
||||
|
||||
public static String format(double dvalue) {
|
||||
return BigDecimal.valueOf(dvalue).setScale(2, RoundingMode.HALF_UP).toString();
|
||||
}
|
||||
|
||||
private static long readIO(int numOfBlocks, BlockSequence blockSequence, int blockSize, File testFile) {
|
||||
long totalBytesReadInMark = 0;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public class TimeMeasurePerformance extends TimeMeasure{
|
||||
|
||||
private static int indent = 0;
|
||||
|
||||
public static void begin(String idTimer) {
|
||||
public static void begin(String idTimer, String description) {
|
||||
startTime = System.nanoTime();
|
||||
|
||||
init();
|
||||
@@ -38,7 +38,12 @@ public class TimeMeasurePerformance extends TimeMeasure{
|
||||
indent++;
|
||||
TimeStack times = new TimeStack();
|
||||
timers.put(idTimer, times);
|
||||
log(indent(indent) + "Start '" + idTimer + "' ..."); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
String message = "Start '" + idTimer + "' ...";
|
||||
if (description != null) {
|
||||
message = "Start '" + idTimer + "', " + description + " ...";
|
||||
}
|
||||
log(indent(indent) + message); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -132,8 +132,10 @@ import org.talend.core.repository.utils.RepositoryPathProvider;
|
||||
import org.talend.core.repository.utils.XmiResourceManager;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.runtime.repository.item.ItemProductKeys;
|
||||
import org.talend.core.runtime.services.IGenericWizardService;
|
||||
import org.talend.core.runtime.services.IMavenUIService;
|
||||
import org.talend.core.runtime.util.ItemDateParser;
|
||||
import org.talend.core.runtime.util.SharedStudioUtils;
|
||||
import org.talend.core.service.ICoreUIService;
|
||||
import org.talend.core.service.IUpdateService;
|
||||
import org.talend.cwm.helper.SubItemHelper;
|
||||
@@ -1798,9 +1800,12 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
* @throws PersistenceException
|
||||
*/
|
||||
private void emptyTempFolder(Project project) throws PersistenceException {
|
||||
String str = (System.getProperty("eclipse.home.location") + "temp").substring(5);
|
||||
FilesUtils.deleteFolder(new File(str), false);
|
||||
|
||||
try {
|
||||
String str = SharedStudioUtils.getTempFolderPath().toPortableString();
|
||||
FilesUtils.deleteFolder(new File(str), false);
|
||||
}catch (Exception ex) {
|
||||
ExceptionHandler.process(ex);
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
IProject fsProject = ResourceUtils.getProject(project);
|
||||
IFolder folder = ResourceUtils.getFolder(fsProject, RepositoryConstants.TEMP_DIRECTORY, false);
|
||||
@@ -2089,7 +2094,7 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
*/
|
||||
public void logOnProject(Project project, IProgressMonitor monitor) throws LoginException, PersistenceException {
|
||||
try {
|
||||
TimeMeasurePerformance.begin("logOnProject"); //$NON-NLS-1$
|
||||
TimeMeasurePerformance.begin("logOnProject", "logon project name '" + project.getLabel()+"'"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
try {
|
||||
/**
|
||||
* init/check proxy selector, in case default proxy selector is not registed yet
|
||||
@@ -2140,6 +2145,20 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
|
||||
ProjectDataJsonProvider.checkAndRectifyRelationShipSetting(project.getEmfProject());
|
||||
|
||||
try {
|
||||
// load additional jdbc
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
IGenericWizardService service = GlobalServiceRegister.getDefault()
|
||||
.getService(IGenericWizardService.class);
|
||||
if (service != null) {
|
||||
service.loadAdditionalJDBC();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// in case, to avoid block logon
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
// init dynamic distirbution after `beforeLogon`, before loading libraries.
|
||||
initDynamicDistribution(monitor);
|
||||
|
||||
@@ -2186,6 +2205,14 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
TimeMeasurePerformance.step("logOnProject", "Sync components libraries"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
try {
|
||||
// for new added mapping file, sync to project mapping folder
|
||||
MetadataTalendType.syncNewMappingFileToProject();
|
||||
} catch (SystemException e) {
|
||||
// ignore
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask("Execute before logon migrations tasks", 1); //$NON-NLS-1$
|
||||
ProjectManager.getInstance().getMigrationRecords().clear();
|
||||
@@ -2287,8 +2314,6 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
// set the project mappings url
|
||||
System.setProperty("talend.mappings.url", url.toString()); // $NON-NLS-1$
|
||||
}
|
||||
// for new added mapping file, sync to project mapping folder
|
||||
MetadataTalendType.syncNewMappingFileToProject();
|
||||
} catch (SystemException e) {
|
||||
// ignore
|
||||
ExceptionHandler.process(e);
|
||||
|
||||
@@ -122,7 +122,8 @@ Require-Bundle: org.eclipse.jdt.core,
|
||||
org.talend.components.api,
|
||||
org.apache.servicemix.bundles.avro,
|
||||
jackson-core-asl,
|
||||
org.talend.libraries.jackson
|
||||
org.talend.libraries.jackson,
|
||||
org.talend.libraries.apache.common
|
||||
Bundle-Activator: org.talend.core.runtime.CoreRuntimePlugin
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-ClassPath: .,
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
<?xml version="1.0"?>
|
||||
<mapping>
|
||||
<dbms product="SINGLESTORE" id="singlestore_id" label="Mapping SingleStore"
|
||||
default="true">
|
||||
<dbTypes>
|
||||
<dbType type="BOOL" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="BOOLEAN" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="BIGINT" ignorePre="true"/>
|
||||
<dbType type="BIGINT UNSIGNED" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="BINARY" ignorePre="true"/>
|
||||
<dbType type="BIT" ignorePre="true" />
|
||||
<dbType type="BLOB" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="CHAR" defaultLength="200" ignorePre="true"/>
|
||||
<dbType type="DATE" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="DATETIME" ignoreLen="true" ignorePre="false" />
|
||||
<dbType type="DECIMAL" defaultLength="20" defaultPrecision="10" preBeforelen="false"/>
|
||||
<dbType type="DOUBLE" defaultLength="20" defaultPrecision="10"/>
|
||||
<dbType type="DOUBLE UNSIGNED" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="ENUM" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="FLOAT" defaultPrecision="2"/>
|
||||
<dbType type="FLOAT UNSIGNED" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="GEOGRAPHY" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="GEOGRAPHYPOINT" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="INT" ignorePre="true" />
|
||||
<dbType type="INT UNSIGNED" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="INTEGER" ignorePre="true" />
|
||||
<dbType type="INTEGER UNSIGNED" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="LONGTEXT" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="LONGBLOB" ignoreLen="true" ignorePre="true"/>
|
||||
<dbType type="MEDIUMBLOB" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="MEDIUMINT" ignorePre="true" />
|
||||
<dbType type="MEDIUMINT UNSIGNED" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="MEDIUMTEXT" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="SMALLINT" ignorePre="true" />
|
||||
<dbType type="SMALLINT UNSIGNED" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="SET" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TEXT" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TIME" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TIMESTAMP" ignoreLen="true" ignorePre="false" />
|
||||
<dbType type="TINYBLOB" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TINYINT" ignorePre="true" />
|
||||
<dbType type="TINYINT UNSIGNED" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TINYTEXT" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="VARBINARY" ignorePre="true" />
|
||||
<dbType type="VARCHAR" default="true" defaultLength="100" ignorePre="true"/>
|
||||
<dbType type="YEAR" ignorePre="true"/>
|
||||
<dbType type="JSON" ignoreLen="true" ignorePre="true"/>
|
||||
</dbTypes>
|
||||
|
||||
<language name="java">
|
||||
<talendToDbTypes><!-- Adviced mappings -->
|
||||
<talendType type="id_List"/>
|
||||
<talendType type="id_Boolean">
|
||||
<dbType type="BOOL" default="true" />
|
||||
</talendType>
|
||||
<talendType type="id_Byte">
|
||||
<dbType type="TINYINT" default="true" />
|
||||
<dbType type="BIGINT" />
|
||||
<dbType type="INT" />
|
||||
<dbType type="MEDIUMINT" />
|
||||
<dbType type="SMALLINT" />
|
||||
</talendType>
|
||||
<talendType type="id_byte[]">
|
||||
<dbType type="VARBINARY" default="true" />
|
||||
<dbType type="BINARY" />
|
||||
<dbType type="BIT" />
|
||||
<dbType type="BLOB" />
|
||||
<dbType type="LONGBLOB" />
|
||||
<dbType type="MEDIUMBLOB" />
|
||||
<dbType type="TINYBLOB" />
|
||||
</talendType>
|
||||
<talendType type="id_Character">
|
||||
<dbType type="CHAR" default="true" />
|
||||
<dbType type="VARCHAR"/>
|
||||
</talendType>
|
||||
<talendType type="id_Date">
|
||||
<dbType type="DATE" />
|
||||
<dbType type="DATETIME" default="true" />
|
||||
<dbType type="TIME" />
|
||||
<dbType type="YEAR" />
|
||||
<dbType type="TIMESTAMP" />
|
||||
</talendType>
|
||||
<talendType type="id_BigDecimal">
|
||||
<dbType type="DECIMAL" default="true" />
|
||||
<dbType type="FLOAT"/>
|
||||
<dbType type="DOUBLE" />
|
||||
</talendType>
|
||||
<talendType type="id_Double">
|
||||
<dbType type="DOUBLE" default="true" />
|
||||
<dbType type="FLOAT"/>
|
||||
<dbType type="DECIMAL" />
|
||||
</talendType>
|
||||
<talendType type="id_Float">
|
||||
<dbType type="FLOAT" default="true" />
|
||||
<dbType type="DOUBLE"/>
|
||||
<dbType type="DECIMAL" />
|
||||
</talendType>
|
||||
<talendType type="id_Integer">
|
||||
<dbType type="INT" default="true" />
|
||||
<dbType type="BIGINT" />
|
||||
</talendType>
|
||||
<talendType type="id_Long">
|
||||
<dbType type="BIGINT" default="true" />
|
||||
</talendType>
|
||||
<talendType type="id_Object">
|
||||
<dbType type="BLOB" default="true"/>
|
||||
<dbType type="ENUM" />
|
||||
<dbType type="GEOGRAPHY" />
|
||||
<dbType type="GEOGRAPHYPOINT" />
|
||||
<dbType type="MEDIUMINT" />
|
||||
<dbType type="LONGBLOB" />
|
||||
<dbType type="MEDIUMBLOB" />
|
||||
<dbType type="SET" />
|
||||
<dbType type="TINYBLOB" />
|
||||
</talendType>
|
||||
<talendType type="id_Short">
|
||||
<dbType type="SMALLINT" default="true" />
|
||||
<dbType type="INT" />
|
||||
<dbType type="BIGINT"/>
|
||||
<dbType type="MEDIUMINT" />
|
||||
</talendType>
|
||||
<talendType type="id_String">
|
||||
<dbType type="VARCHAR" default="true" />
|
||||
<dbType type="LONGTEXT"/>
|
||||
<dbType type="MEDIUMTEXT" />
|
||||
<dbType type="TEXT" />
|
||||
<dbType type="TINYTEXT" />
|
||||
<dbType type="CHAR" />
|
||||
<dbType type="JSON" />
|
||||
</talendType>
|
||||
</talendToDbTypes>
|
||||
<dbToTalendTypes>
|
||||
<dbType type="BOOL">
|
||||
<talendType type="id_Boolean" default="true" />
|
||||
</dbType>
|
||||
<dbType type="BOOLEAN">
|
||||
<talendType type="id_Boolean" default="true" />
|
||||
</dbType>
|
||||
<dbType type="BIGINT">
|
||||
<talendType type="id_Long" default="true" />
|
||||
</dbType>
|
||||
<dbType type="BINARY">
|
||||
<talendType type="id_byte[]" />
|
||||
<talendType type="id_Boolean" default="true" />
|
||||
</dbType>
|
||||
<dbType type="BIT">
|
||||
<talendType type="id_byte[]" />
|
||||
<talendType type="id_Boolean" default="true" />
|
||||
</dbType>
|
||||
<dbType type="BLOB">
|
||||
<talendType type="id_byte[]" default="true" />
|
||||
<talendType type="id_Object" />
|
||||
</dbType>
|
||||
<dbType type="CHAR">
|
||||
<talendType type="id_String" default="true" />
|
||||
</dbType>
|
||||
<dbType type="DATE">
|
||||
<talendType type="id_Date" default="true" />
|
||||
</dbType>
|
||||
<dbType type="DATETIME">
|
||||
<talendType type="id_Date" default="true" />
|
||||
</dbType>
|
||||
<dbType type="DECIMAL">
|
||||
<talendType type="id_Float"/>
|
||||
<talendType type="id_Double"/>
|
||||
<talendType type="id_BigDecimal" default="true"/>
|
||||
</dbType>
|
||||
<dbType type="DOUBLE">
|
||||
<talendType type="id_Double" default="true" />
|
||||
<talendType type="id_BigDecimal"/>
|
||||
</dbType>
|
||||
<dbType type="ENUM">
|
||||
<talendType type="id_Object" default="true" />
|
||||
</dbType>
|
||||
<dbType type="FLOAT">
|
||||
<talendType type="id_Float" default="true" />
|
||||
<talendType type="id_Double"/>
|
||||
<talendType type="id_BigDecimal"/>
|
||||
</dbType>
|
||||
<dbType type="GEOGRAPHY">
|
||||
<talendType type="id_Object" default="true" />
|
||||
</dbType>
|
||||
<dbType type="GEOGRAPHYPOINT">
|
||||
<talendType type="id_Object" default="true" />
|
||||
</dbType>
|
||||
<dbType type="JSON">
|
||||
<talendType type="id_String" default="true" />
|
||||
<talendType type="id_Object" />
|
||||
</dbType>
|
||||
<dbType type="INT">
|
||||
<talendType type="id_Integer" default="true" />
|
||||
<talendType type="id_Long"/>
|
||||
</dbType>
|
||||
<dbType type="INTEGER">
|
||||
<talendType type="id_Integer" default="true" />
|
||||
<talendType type="id_Long"/>
|
||||
</dbType>
|
||||
<dbType type="LONGTEXT">
|
||||
<talendType type="id_String" default="true" />
|
||||
</dbType>
|
||||
<dbType type="LONGBLOB">
|
||||
<talendType type="id_byte[]" default="true" />
|
||||
<talendType type="id_Object" />
|
||||
</dbType>
|
||||
<dbType type="MEDIUMBLOB">
|
||||
<talendType type="id_byte[]" default="true" />
|
||||
<talendType type="id_Object" />
|
||||
</dbType>
|
||||
<dbType type="MEDIUMINT">
|
||||
<talendType type="id_Integer" default="true" />
|
||||
<talendType type="id_Long"/>
|
||||
</dbType>
|
||||
<dbType type="MEDIUMTEXT">
|
||||
<talendType type="id_String" default="true" />
|
||||
</dbType>
|
||||
<dbType type="SMALLINT">
|
||||
<talendType type="id_Short" default="true" />
|
||||
<talendType type="id_Long"/>
|
||||
<talendType type="id_Integer"/>
|
||||
</dbType>
|
||||
<dbType type="SET">
|
||||
<talendType type="id_Object" default="true" />
|
||||
</dbType>
|
||||
<dbType type="TEXT">
|
||||
<talendType type="id_String" default="true" />
|
||||
</dbType>
|
||||
<dbType type="TIME">
|
||||
<talendType type="id_Date" default="true" />
|
||||
</dbType>
|
||||
<dbType type="TIMESTAMP">
|
||||
<talendType type="id_Date" default="true" />
|
||||
</dbType>
|
||||
<dbType type="TINYBLOB">
|
||||
<talendType type="id_byte[]" default="true" />
|
||||
<talendType type="id_Object" />
|
||||
</dbType>
|
||||
<dbType type="TINYINT">
|
||||
<talendType type="id_Byte" default="true" />
|
||||
<talendType type="id_Integer"/>
|
||||
<talendType type="id_Long"/>
|
||||
<talendType type="id_Short"/>
|
||||
</dbType>
|
||||
<dbType type="TINYTEXT">
|
||||
<talendType type="id_String" default="true" />
|
||||
</dbType>
|
||||
<dbType type="VARBINARY">
|
||||
<talendType type="id_byte[]" default="true" />
|
||||
</dbType>
|
||||
<dbType type="VARCHAR">
|
||||
<talendType type="id_String" default="true" />
|
||||
</dbType>
|
||||
<dbType type="YEAR">
|
||||
<talendType type="id_Date" default="true" />
|
||||
</dbType>
|
||||
<dbType type="BIGINT UNSIGNED" >
|
||||
</dbType>
|
||||
<dbType type="DOUBLE UNSIGNED" >
|
||||
<talendType type="id_Double" default="true" />
|
||||
<talendType type="id_BigDecimal"/>
|
||||
</dbType>
|
||||
<dbType type="FLOAT UNSIGNED" >
|
||||
<talendType type="id_Double" default="true" />
|
||||
<talendType type="id_BigDecimal"/>
|
||||
</dbType>
|
||||
<dbType type="INT UNSIGNED" >
|
||||
<talendType type="id_Long" default="true" />
|
||||
</dbType>
|
||||
<dbType type="INTEGER UNSIGNED" >
|
||||
<talendType type="id_Long" default="true" />
|
||||
</dbType>
|
||||
<dbType type="MEDIUMINT UNSIGNED" >
|
||||
<talendType type="id_Integer" default="true" />
|
||||
<talendType type="id_Long" />
|
||||
</dbType>
|
||||
<dbType type="SMALLINT UNSIGNED" >
|
||||
<talendType type="id_Integer" default="true" />
|
||||
<talendType type="id_Long" />
|
||||
</dbType>
|
||||
<dbType type="TINYINT UNSIGNED" >
|
||||
<talendType type="id_Short" default="true" />
|
||||
<talendType type="id_Integer" />
|
||||
<talendType type="id_Long" />
|
||||
</dbType>
|
||||
</dbToTalendTypes>
|
||||
</language>
|
||||
</dbms>
|
||||
|
||||
</mapping>
|
||||
@@ -42,6 +42,7 @@ import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
@@ -50,11 +51,16 @@ import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.FileLocator;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.talend.commons.exception.CommonExceptionHandler;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
@@ -1173,4 +1179,33 @@ public class FilesUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void executeFolderAction(IProgressMonitor monitor, IResource parentFolder, IWorkspaceRunnable run)
|
||||
throws CoreException {
|
||||
if (Job.getJobManager().currentRule() == null) {
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
ISchedulingRule defaultRule = workspace.getRuleFactory().modifyRule(parentFolder);
|
||||
ISchedulingRule noBlockRule = new ISchedulingRule() {
|
||||
|
||||
@Override
|
||||
public boolean isConflicting(ISchedulingRule rule) {
|
||||
return this.contains(rule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(ISchedulingRule rule) {
|
||||
if (this.equals(rule)) {
|
||||
return true;
|
||||
}
|
||||
if (defaultRule.contains(rule)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
workspace.run(run, noBlockRule, IWorkspace.AVOID_UPDATE, monitor);
|
||||
} else {
|
||||
run.run(monitor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -94,4 +94,6 @@ public interface IESBService extends IService {
|
||||
* @return
|
||||
*/
|
||||
public IProcessor createOSGIJavaProcessor(IProcess process, Property property, boolean filenameFromLabel);
|
||||
|
||||
public boolean isSOAPServiceProvider(Item item);
|
||||
}
|
||||
|
||||
@@ -126,6 +126,8 @@ public class PluginChecker {
|
||||
|
||||
public static final String BDEE_PLUGIN_ID = "org.talend.designer.bigdata"; //$NON-NLS-1$
|
||||
|
||||
public static final String BD_ROUTINE_PLUGIN_ID = "org.talend.designer.routines.bigdata"; //$NON-NLS-1$
|
||||
|
||||
public static final String DOCKER_PLUGIN_ID = "org.talend.designer.docker"; //$NON-NLS-1$
|
||||
|
||||
public static final String HELP_DI_EE_PLUGIN_ID = "org.talend.help.dataprep"; //$NON-NLS-1$
|
||||
@@ -364,6 +366,10 @@ public class PluginChecker {
|
||||
return isPluginLoaded(ESBSE_PLUGIN_ID);
|
||||
}
|
||||
|
||||
public static boolean isBigdataRoutineLoaded() {
|
||||
return isPluginLoaded(BD_ROUTINE_PLUGIN_ID);
|
||||
}
|
||||
|
||||
public static String getBundlePath(String bundleName) {
|
||||
String bundlePath = ""; //$NON-NLS-1$
|
||||
Bundle refBundle = Platform.getBundle(bundleName);
|
||||
|
||||
@@ -224,6 +224,7 @@ public class DatabaseConnStrUtil {
|
||||
if (template.startsWith(DbConnStrForHive.URL_HIVE_2_TEMPLATE)) {
|
||||
url = getImpalaURLString(false, server, port, sidOrDatabase, impalaPrincipal);
|
||||
}
|
||||
url = attachAdditionalHiveParameters(url, dbConn, false);
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.talend.core.database.EDatabaseTypeName;
|
||||
import org.talend.core.database.conn.version.EDatabaseVersion4Drivers;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.runtime.services.IGenericDBService;
|
||||
import org.talend.core.runtime.services.IGenericWizardService;
|
||||
|
||||
/**
|
||||
* cli class global comment. Detailled comment
|
||||
@@ -326,6 +327,16 @@ public enum EDatabaseConnTemplate {
|
||||
databaseType.add(typeName);
|
||||
}
|
||||
}
|
||||
// add additional jdbc (actually JDBC RepositoryObjectType)
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
IGenericWizardService service = GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
|
||||
if (service != null) {
|
||||
List<String> allAdditionalJDBCTypes = service.getAllAdditionalJDBCTypes();
|
||||
if (!allAdditionalJDBCTypes.isEmpty()) {
|
||||
databaseType.addAll(allAdditionalJDBCTypes);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sort) {
|
||||
String[] sortedArray = databaseType.toArray(new String[0]);
|
||||
Arrays.sort(sortedArray, new Comparator<String>() {
|
||||
|
||||
@@ -102,12 +102,12 @@ public enum EDatabaseVersion4Drivers {
|
||||
|
||||
GREENPLUM(new DbVersion4Drivers(EDatabaseTypeName.GREENPLUM, "postgresql-8.4-703.jdbc4.jar")), //$NON-NLS-1$
|
||||
// PSQL_V10(new DbVersion4Drivers(EDatabaseTypeName.PSQL, "v10", "V10", "postgresql-42.2.5.jar")),
|
||||
PSQL_V9_X(new DbVersion4Drivers(EDatabaseTypeName.PSQL, "v9 and later", "V9_X", "postgresql-42.2.9.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
PSQL_V9_X(new DbVersion4Drivers(EDatabaseTypeName.PSQL, "v9 and later", "V9_X", "postgresql-42.2.14.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
PSQL_PRIOR_TO_V9(new DbVersion4Drivers(EDatabaseTypeName.PSQL, "Prior to v9", "PRIOR_TO_V9", "postgresql-8.4-703.jdbc4.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
||||
PLUSPSQL_PRIOR_TO_V9(new DbVersion4Drivers(EDatabaseTypeName.PLUSPSQL,
|
||||
"Prior to v9", "PRIOR_TO_V9", "postgresql-8.4-703.jdbc4.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
PLUSPSQL_V9_X(new DbVersion4Drivers(EDatabaseTypeName.PLUSPSQL, "v9 and later", "V9_X", "postgresql-9.4-1201.jdbc41.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
PLUSPSQL_V9_X(new DbVersion4Drivers(EDatabaseTypeName.PLUSPSQL, "v9 and later", "V9_X", "postgresql-42.2.14.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
IBMDB2(new DbVersion4Drivers(EDatabaseTypeName.IBMDB2, new String[] { "db2jcc4.jar", "db2jcc_license_cu.jar", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
"db2jcc_license_cisuz.jar" })), //$NON-NLS-1$
|
||||
IBMDB2ZOS(new DbVersion4Drivers(EDatabaseTypeName.IBMDB2ZOS, new String[] { "db2jcc4.jar", "db2jcc_license_cu.jar", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
@@ -81,6 +81,11 @@ public final class ComponentUtilities {
|
||||
|
||||
public static void setNodeValue(NodeType node, String name, String value) {
|
||||
ElementParameterType property = getNodeProperty(node, name);
|
||||
|
||||
if (property == null) {
|
||||
throw new IllegalArgumentException( "The component node "+node.getComponentName()+" doesn't have the property "+name );
|
||||
}
|
||||
|
||||
property.setValue(value);
|
||||
}
|
||||
|
||||
|
||||
@@ -111,4 +111,6 @@ public interface IComponentsFactory {
|
||||
public Map<String, File> getComponentsProvidersFolder();
|
||||
|
||||
public List<ComponentProviderInfo> getComponentsProvidersInfo();
|
||||
|
||||
public String getCustomComponentBundlePath();
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class ContextUtils {
|
||||
"static", "void", "class", "finally", "long", "strictfp", "volatile", "const", "float", "native", "super", "while")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$
|
||||
|
||||
private static final Set<String> SECURE_SENSITIVE_CONTEXT_NAMES_EXP = new HashSet<String>(Arrays.asList("resource_flow_temp_folder", "resource_webhook_payload", "resource_file_[\\w]+",
|
||||
"resource_directory_[\\w]+", "connection_[a-zA-Z0-9]+_[\\w]"));
|
||||
"resource_directory_[\\w]+", "connection_[a-zA-Z0-9]+_[\\w]+"));
|
||||
|
||||
|
||||
/**
|
||||
@@ -594,7 +594,7 @@ public class ContextUtils {
|
||||
return false;
|
||||
}
|
||||
// need check the raw value, because in sourceParam, it's raw
|
||||
if (!sourceParam.getValue().equals(targetParamType.getRawValue())) {
|
||||
if (!StringUtils.equals(sourceParam.getValue(), targetParamType.getRawValue())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -320,7 +320,8 @@ public class JobContextManager implements IContextManager {
|
||||
contextParam = new JobContextParameter();
|
||||
contextParam.setContext(context);
|
||||
contextParam.setName(contextParamType.getName());
|
||||
contextParam.setPrompt(contextParamType.getPrompt());
|
||||
contextParam.setPrompt(
|
||||
contextParamType.getPrompt() == null ? (contextParamType.getName() + "?") : contextParamType.getPrompt());
|
||||
contextParam.setInternalId(contextParamType.getInternalId());
|
||||
originalParamerters.add(contextParam.getName());
|
||||
boolean exists = true;
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.Set;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.talend.commons.exception.BusinessException;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.general.ModuleNeeded.ELibraryInstallStatus;
|
||||
import org.talend.core.model.process.IElement;
|
||||
@@ -133,4 +134,14 @@ public interface ILibrariesService extends IService {
|
||||
public void afterChangingLibraries();
|
||||
}
|
||||
|
||||
public static ILibrariesService get() {
|
||||
GlobalServiceRegister gsr = GlobalServiceRegister.getDefault();
|
||||
if (gsr != null) {
|
||||
if (gsr.isServiceRegistered(ILibrariesService.class)) {
|
||||
return gsr.getService(ILibrariesService.class);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
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.utils.TalendQuoteUtils;
|
||||
|
||||
/**
|
||||
* This bean is use to manage needed moduless (perl) and libraries (java).<br/>
|
||||
@@ -110,6 +111,15 @@ public class ModuleNeeded {
|
||||
|
||||
}
|
||||
|
||||
public static ModuleNeeded newInstance(String context, String value, String informationMsg, boolean required) {
|
||||
String val = TalendQuoteUtils.removeQuotesIfExist(value);
|
||||
if (val.startsWith(MavenUrlHelper.MVN_PROTOCOL)) {
|
||||
return new ModuleNeeded(context, informationMsg, required, val);
|
||||
}
|
||||
// won't do migration for old MODULE_LIST but still make it compatible
|
||||
return new ModuleNeeded(context, val, informationMsg, required);
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC smallet ModuleNeeded constructor comment.
|
||||
*
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.talend.core.database.conn.ConnParameterKeys;
|
||||
import org.talend.core.database.conn.DatabaseConnStrUtil;
|
||||
import org.talend.core.database.conn.version.EDatabaseVersion4Drivers;
|
||||
import org.talend.core.model.components.EComponentType;
|
||||
import org.talend.core.model.metadata.Dbms;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.MetadataTalendType;
|
||||
import org.talend.core.model.metadata.builder.ConvertionHelper;
|
||||
@@ -155,6 +156,17 @@ public class ComponentToRepositoryProperty {
|
||||
conn.setDbmsId(mapping);
|
||||
}
|
||||
}
|
||||
// set default mapping for additional jdbc
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
IGenericWizardService service = GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
|
||||
if (service != null) {
|
||||
Dbms dbms4AdditionalJDBC = service.getDbms4AdditionalJDBC(conn.getProductId());
|
||||
if (dbms4AdditionalJDBC != null) {
|
||||
conn.setDbmsId(dbms4AdditionalJDBC.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for (IElementParameter param : node.getElementParameters()) {
|
||||
String repositoryValue = param.getRepositoryValue();
|
||||
@@ -368,19 +380,18 @@ public class ComponentToRepositoryProperty {
|
||||
if (para.getRepositoryValue().endsWith(EDatabaseTypeName.GENERAL_JDBC.getProduct())) {
|
||||
connection.setDatabaseType(EDatabaseTypeName.GENERAL_JDBC.getProduct());
|
||||
connection.setProductId(EDatabaseTypeName.GENERAL_JDBC.getProduct());
|
||||
if (!node.getComponent().getDisplayName().equals(node.getComponent().getName())) {
|
||||
// additional JDBC e.g. Delta Lake
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
IGenericWizardService service = GlobalServiceRegister.getDefault()
|
||||
.getService(IGenericWizardService.class);
|
||||
if (service != null) {
|
||||
String database = service.getDatabseNameByNode(node);
|
||||
if (StringUtils.isNotBlank(database)) {
|
||||
connection.setProductId(database);
|
||||
}
|
||||
}
|
||||
|
||||
// additional JDBC e.g. Delta Lake
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
IGenericWizardService service = GlobalServiceRegister.getDefault()
|
||||
.getService(IGenericWizardService.class);
|
||||
if (service != null) {
|
||||
String database = service.getDatabseNameByNode(node);
|
||||
if (StringUtils.isNotBlank(database) && service.getIfAdditionalJDBCDBType(database)) {
|
||||
connection.setProductId(database);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1490,21 +1490,24 @@ public class RepositoryToComponentProperty {
|
||||
}
|
||||
|
||||
if (value.equals("USE_SSL") && (EDatabaseTypeName.HIVE.getDisplayName().equals(databaseType)
|
||||
|| EDatabaseTypeName.ORACLE_CUSTOM.getDisplayName().equals(databaseType))) {
|
||||
|| EDatabaseTypeName.ORACLE_CUSTOM.getDisplayName().equals(databaseType)
|
||||
|| EDatabaseTypeName.IMPALA.getDisplayName().equals(databaseType))) {
|
||||
String message = connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USE_SSL);
|
||||
return Boolean.parseBoolean(message);
|
||||
}
|
||||
|
||||
if ((value.equals("SSL_TRUST_STORE") || value.equals("SSL_TRUSTSERVER_TRUSTSTORE"))
|
||||
&& (EDatabaseTypeName.HIVE.getDisplayName().equals(databaseType)
|
||||
|| EDatabaseTypeName.ORACLE_CUSTOM.getDisplayName().equals(databaseType))) {
|
||||
|| EDatabaseTypeName.ORACLE_CUSTOM.getDisplayName().equals(databaseType)
|
||||
|| EDatabaseTypeName.IMPALA.getDisplayName().equals(databaseType))) {
|
||||
return getAppropriateValue(connection,
|
||||
connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH));
|
||||
}
|
||||
|
||||
if ((value.equals("SSL_TRUST_STORE_PASSWORD") || value.equals("SSL_TRUSTSERVER_PASSWORD"))
|
||||
&& (EDatabaseTypeName.HIVE.getDisplayName().equals(databaseType)
|
||||
|| EDatabaseTypeName.ORACLE_CUSTOM.getDisplayName().equals(databaseType))) {
|
||||
|| EDatabaseTypeName.ORACLE_CUSTOM.getDisplayName().equals(databaseType)
|
||||
|| EDatabaseTypeName.IMPALA.getDisplayName().equals(databaseType))) {
|
||||
return getAppropriateValue(connection, connection
|
||||
.getValue(connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD), false));
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ public enum EComponentCategory {
|
||||
DYNAMICS_SETTINGS(Messages.getString("EComponentCategory_dynamicSetting"), 13), //$NON-NLS-1$
|
||||
SQL_PATTERN(Messages.getString("EComponentCategory_sqlTemplate"), 14), //$NON-NLS-1$
|
||||
BREAKPOINT(Messages.getString("EComponentCategory.breakpoint"), 15), //$NON-NLS-1$
|
||||
BREAKPOINT_CAMEL(Messages.getString("EComponentCategory.breakpoint"), 16), //$NON-NLS-1$
|
||||
BASICRUN(Messages.getString("EComponentCategory.basicRun"), 1), //$NON-NLS-1$
|
||||
DEBUGRUN(Messages.getString("EComponentCategory.debugRun"), 2), //$NON-NLS-1$
|
||||
ADVANCESETTING(Messages.getString("EComponentCategory.advancedSettings"), 3), //$NON-NLS-1$
|
||||
|
||||
@@ -113,8 +113,6 @@ public enum EParameterFieldType {
|
||||
|
||||
GROUPING_CAMPAIGN_CHOOSER, // htyin added for DQ Matching components
|
||||
MULTI_PATTERN, // yyin added TDQ-13437
|
||||
SYNC_NEXUS_BUTTON,
|
||||
CHECK_NEXUS_BUTTON,
|
||||
PATTERN_PROPERTY, // yyin, added TDQ-13437
|
||||
|
||||
UNIFIED_COMPONENTS,
|
||||
|
||||
@@ -60,6 +60,7 @@ import org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType
|
||||
import org.talend.designer.runprocess.ItemCacheManager;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
|
||||
/**
|
||||
* DOC bqian class global comment. Detailled comment
|
||||
@@ -1003,4 +1004,17 @@ public final class ProcessUtils {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isChildRouteProcess(IProcess process) {
|
||||
List n = process.getNodesOfType("tRouteInput");
|
||||
if (n!=null && n.size()!=0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String escapeJava(String input) {
|
||||
return StringEscapeUtils.escapeJava(input);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -963,7 +963,7 @@ public class RelationshipItemBuilder {
|
||||
|
||||
Map<Relation, Set<Relation>> itemRelations = getRelatedRelations(item);
|
||||
|
||||
Set<Relation> repositoryNode = (Set<Relation>) itemRelations.get(relation);
|
||||
Set<Relation> repositoryNode = (Set<Relation>) itemRelations.getOrDefault(relation, new HashSet<Relation>());
|
||||
|
||||
for (Relation rel : repositoryNode) {
|
||||
if (rel.getType().equals("Beans")) {
|
||||
|
||||
@@ -1414,12 +1414,8 @@ public class ERepositoryObjectType extends DynaEnum<ERepositoryObjectType> {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<ERepositoryObjectType> getAllTypesOfProcess() {
|
||||
public static List<ERepositoryObjectType> getAllTypesOfBigDataProcess() {
|
||||
List<ERepositoryObjectType> allTypes = new ArrayList<ERepositoryObjectType>();
|
||||
|
||||
if (ERepositoryObjectType.PROCESS != null) {
|
||||
allTypes.add(ERepositoryObjectType.PROCESS);
|
||||
}
|
||||
if (ERepositoryObjectType.PROCESS_MR != null) {
|
||||
allTypes.add(ERepositoryObjectType.PROCESS_MR);
|
||||
}
|
||||
@@ -1432,6 +1428,17 @@ public class ERepositoryObjectType extends DynaEnum<ERepositoryObjectType> {
|
||||
if (ERepositoryObjectType.PROCESS_SPARKSTREAMING != null) {
|
||||
allTypes.add(ERepositoryObjectType.PROCESS_SPARKSTREAMING);
|
||||
}
|
||||
return allTypes;
|
||||
}
|
||||
|
||||
public static List<ERepositoryObjectType> getAllTypesOfProcess() {
|
||||
List<ERepositoryObjectType> allTypes = new ArrayList<ERepositoryObjectType>();
|
||||
|
||||
allTypes.addAll(getAllTypesOfBigDataProcess());
|
||||
|
||||
if (ERepositoryObjectType.PROCESS != null) {
|
||||
allTypes.add(ERepositoryObjectType.PROCESS);
|
||||
}
|
||||
if (ERepositoryObjectType.PROCESS_ROUTE != null) {
|
||||
allTypes.add(ERepositoryObjectType.PROCESS_ROUTE);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ public interface SVNConstant {
|
||||
|
||||
public static final String NAME_MASTER = "master"; //$NON-NLS-1$
|
||||
|
||||
public static final String NAME_MAIN = "main"; //$NON-NLS-1$
|
||||
|
||||
public static final String NAME_ORIGIN = "origin"; //$NON-NLS-1$
|
||||
|
||||
/*
|
||||
|
||||
@@ -320,24 +320,28 @@ public class RepositoryUpdateManagerHelper {
|
||||
|
||||
// all the jobs
|
||||
for (IRepositoryViewObject process : processRep) {
|
||||
Item item = process.getProperty().getItem();
|
||||
boolean found = false;
|
||||
for (IProcess2 open : openedProcessList) {
|
||||
if (open.getId().equals(item.getProperty().getId())) {
|
||||
found = true;
|
||||
try {
|
||||
Item item = process.getProperty().getItem();
|
||||
boolean found = false;
|
||||
for (IProcess2 open : openedProcessList) {
|
||||
if (open.getId().equals(item.getProperty().getId())) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
continue;
|
||||
}
|
||||
checkMonitorCanceled(parentMonitor);
|
||||
parentMonitor.subTask(RepositoryUpdateManager.getUpdateJobInfor(item.getProperty()));
|
||||
if (found) {
|
||||
continue;
|
||||
}
|
||||
checkMonitorCanceled(parentMonitor);
|
||||
parentMonitor.subTask(RepositoryUpdateManager.getUpdateJobInfor(item.getProperty()));
|
||||
|
||||
// List<UpdateResult> resultFromProcess = getResultFromProcess(process, types, onlySimpleShow);
|
||||
// List<UpdateResult> resultFromProcess = getResultFromProcess(process, types, onlySimpleShow);
|
||||
|
||||
List<UpdateResult> resultFromProcess = getUpdatesNeededFromItems(parentMonitor, item, types);
|
||||
if (resultFromProcess != null) {
|
||||
resultList.addAll(resultFromProcess);
|
||||
List<UpdateResult> resultFromProcess = getUpdatesNeededFromItems(parentMonitor, item, types);
|
||||
if (resultFromProcess != null) {
|
||||
resultList.addAll(resultFromProcess);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ExceptionHandler.process(ex);
|
||||
}
|
||||
parentMonitor.worked(1);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ package org.talend.core.model.utils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
|
||||
import org.talend.core.model.metadata.designerproperties.RepositoryToComponentProperty;
|
||||
@@ -23,6 +24,7 @@ import org.talend.core.model.properties.ContextItem;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.update.UpdatesConstants;
|
||||
import org.talend.core.runtime.services.IGenericWizardService;
|
||||
|
||||
/**
|
||||
* ggu class global comment. Detailled comment
|
||||
@@ -47,6 +49,14 @@ public final class UpdateRepositoryHelper {
|
||||
if (connection instanceof DatabaseConnection) {
|
||||
String currentDbType = (String) RepositoryToComponentProperty.getValue(connection, UpdatesConstants.TYPE,
|
||||
null);
|
||||
String productId = ((DatabaseConnection) connection).getProductId();
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
IGenericWizardService service = GlobalServiceRegister.getDefault()
|
||||
.getService(IGenericWizardService.class);
|
||||
if (service != null && service.getIfAdditionalJDBCDBType(productId)) {
|
||||
currentDbType = productId;
|
||||
}
|
||||
}
|
||||
aliasName += " (" + currentDbType + ")"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
if (repositoryObjectType.getType().equals("SERVICES")) {
|
||||
|
||||
@@ -73,4 +73,6 @@ public interface IRepositoryArtifactHandler {
|
||||
|
||||
public String resolveRemoteSha1(MavenArtifact artifact, boolean fromRelease) throws Exception;
|
||||
|
||||
public List<MavenArtifact> search(String name, boolean fromSnapshot) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.HttpEntity;
|
||||
@@ -53,6 +55,14 @@ public class NexusServerUtils {
|
||||
// the max search result is 200 by defult from nexus
|
||||
private static final int MAX_SEARCH_COUNT = 200;
|
||||
|
||||
public static final Set<String> IGNORED_TYPES = new HashSet<String>();
|
||||
|
||||
static {
|
||||
IGNORED_TYPES.add("pom");
|
||||
IGNORED_TYPES.add("sha1");
|
||||
IGNORED_TYPES.add("md5");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* DOC check if the repository exist or not
|
||||
@@ -236,36 +246,36 @@ public class NexusServerUtils {
|
||||
private static int readDocument(Document document, List<MavenArtifact> artifacts) throws Exception {
|
||||
List<Node> list = document.selectNodes("/searchNGResponse/data/artifact");//$NON-NLS-1$
|
||||
for (Node arNode : list) {
|
||||
MavenArtifact artifact = new MavenArtifact();
|
||||
artifacts.add(artifact);
|
||||
artifact.setGroupId(arNode.selectSingleNode("groupId").getText());//$NON-NLS-1$
|
||||
artifact.setArtifactId(arNode.selectSingleNode("artifactId").getText());//$NON-NLS-1$
|
||||
artifact.setVersion(arNode.selectSingleNode("version").getText());//$NON-NLS-1$
|
||||
Node descNode = arNode.selectSingleNode("description");//$NON-NLS-1$
|
||||
if (descNode != null) {
|
||||
artifact.setDescription(descNode.getText());
|
||||
}
|
||||
Node urlNode = arNode.selectSingleNode("url");//$NON-NLS-1$
|
||||
if (urlNode != null) {
|
||||
artifact.setUrl(urlNode.getText());
|
||||
}
|
||||
Node licenseNode = arNode.selectSingleNode("license");//$NON-NLS-1$
|
||||
if (licenseNode != null) {
|
||||
artifact.setLicense(licenseNode.getText());
|
||||
}
|
||||
|
||||
Node licenseUrlNode = arNode.selectSingleNode("licenseUrl");//$NON-NLS-1$
|
||||
if (licenseUrlNode != null) {
|
||||
artifact.setLicenseUrl(licenseUrlNode.getText());
|
||||
}
|
||||
|
||||
List<Node> artLinks = arNode.selectNodes("artifactHits/artifactHit/artifactLinks/artifactLink");//$NON-NLS-1$
|
||||
for (Node link : artLinks) {
|
||||
MavenArtifact artifact = new MavenArtifact();
|
||||
|
||||
artifact.setGroupId(arNode.selectSingleNode("groupId").getText());//$NON-NLS-1$
|
||||
artifact.setArtifactId(arNode.selectSingleNode("artifactId").getText());//$NON-NLS-1$
|
||||
artifact.setVersion(arNode.selectSingleNode("version").getText());//$NON-NLS-1$
|
||||
Node descNode = arNode.selectSingleNode("description");//$NON-NLS-1$
|
||||
if (descNode != null) {
|
||||
artifact.setDescription(descNode.getText());
|
||||
}
|
||||
Node urlNode = arNode.selectSingleNode("url");//$NON-NLS-1$
|
||||
if (urlNode != null) {
|
||||
artifact.setUrl(urlNode.getText());
|
||||
}
|
||||
Node licenseNode = arNode.selectSingleNode("license");//$NON-NLS-1$
|
||||
if (licenseNode != null) {
|
||||
artifact.setLicense(licenseNode.getText());
|
||||
}
|
||||
|
||||
Node licenseUrlNode = arNode.selectSingleNode("licenseUrl");//$NON-NLS-1$
|
||||
if (licenseUrlNode != null) {
|
||||
artifact.setLicenseUrl(licenseUrlNode.getText());
|
||||
}
|
||||
Node extensionElement = link.selectSingleNode("extension");//$NON-NLS-1$
|
||||
String extension = null;
|
||||
String classifier = null;
|
||||
if (extensionElement != null) {
|
||||
if ("pom".equals(extensionElement.getText())) {//$NON-NLS-1$
|
||||
if (IGNORED_TYPES.contains(extensionElement.getText())) {// $NON-NLS-1$
|
||||
continue;
|
||||
}
|
||||
extension = extensionElement.getText();
|
||||
@@ -276,6 +286,7 @@ public class NexusServerUtils {
|
||||
}
|
||||
artifact.setType(extension);
|
||||
artifact.setClassifier(classifier);
|
||||
artifacts.add(artifact);
|
||||
}
|
||||
}
|
||||
return list.size();
|
||||
@@ -370,4 +381,37 @@ public class NexusServerUtils {
|
||||
|
||||
}
|
||||
|
||||
public static List<MavenArtifact> search(String nexusUrl, String userName, String password, String repositoryId, String name)
|
||||
throws Exception {
|
||||
List<MavenArtifact> artifacts = new ArrayList<MavenArtifact>();
|
||||
|
||||
int totalCount = 0;
|
||||
String service = NexusConstants.SERVICES_SEARCH + getSearchQuery(repositoryId, null, null, null, 0, MAX_SEARCH_COUNT)
|
||||
+ "&q=" + name;
|
||||
|
||||
URI requestURI = getSearchURI(nexusUrl, service);
|
||||
Document document = downloadDocument(requestURI, userName, password);
|
||||
if (document != null) {
|
||||
Node countNode = document.selectSingleNode("/searchNGResponse/totalCount");
|
||||
if (countNode != null) {
|
||||
try {
|
||||
totalCount = Integer.parseInt(countNode.getText());
|
||||
} catch (NumberFormatException e) {
|
||||
totalCount = 0;
|
||||
}
|
||||
}
|
||||
int searchDone = readDocument(document, artifacts);
|
||||
while (searchDone < totalCount) {
|
||||
service = NexusConstants.SERVICES_SEARCH
|
||||
+ getSearchQuery(repositoryId, null, null, null, searchDone, MAX_SEARCH_COUNT) + "&q=" + name;
|
||||
requestURI = getSearchURI(nexusUrl, service);
|
||||
|
||||
document = downloadDocument(requestURI, userName, password);
|
||||
searchDone = searchDone + readDocument(document, artifacts);
|
||||
}
|
||||
}
|
||||
|
||||
return artifacts;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ public class MavenUrlHelper {
|
||||
if (jarName != null && jarName.length() > 0) {
|
||||
String artifactId = jarName;
|
||||
String type = null;
|
||||
if (jarName.endsWith(MavenConstants.TYPE_JAR)) { // remove the extension .jar
|
||||
if (jarName.endsWith("." + MavenConstants.TYPE_JAR)) { // remove the extension .jar
|
||||
artifactId = jarName.substring(0, jarName.lastIndexOf(MavenConstants.TYPE_JAR) - 1);
|
||||
if (withPackage) {
|
||||
type = MavenConstants.TYPE_JAR;
|
||||
@@ -380,4 +380,14 @@ public class MavenUrlHelper {
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.eclipse.swt.widgets.Composite;
|
||||
import org.talend.commons.ui.swt.actions.ITreeContextualAction;
|
||||
import org.talend.components.api.properties.ComponentProperties;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.metadata.Dbms;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
|
||||
@@ -149,13 +150,18 @@ public interface IGenericWizardService extends IService {
|
||||
*/
|
||||
public ITreeContextualAction getDefaultAction(RepositoryNode node);
|
||||
|
||||
public void initAdditionalJDBCRepositoryObjType();
|
||||
public void loadAdditionalJDBC();
|
||||
|
||||
public List<String> getAllAdditionalJDBCTypes();
|
||||
|
||||
public boolean getIfAdditionalJDBCDBType(String dbType);
|
||||
|
||||
public void initAdditonalJDBCConnectionValue(DatabaseConnection connection, Composite dynamicForm, String dbType,
|
||||
String propertyId);
|
||||
|
||||
public String getDefinitionName4AdditionalJDBC(IElement element);
|
||||
|
||||
public String getDatabseNameByNode(IElement node);
|
||||
|
||||
public Dbms getDbms4AdditionalJDBC(String typeName);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.talend.core.runtime.util;
|
||||
//============================================================================
|
||||
//
|
||||
//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
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
public interface ComponentsLocationProvider {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.talend.core.runtime.util;
|
||||
//============================================================================
|
||||
//
|
||||
//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
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
public interface SharedStudioInfoProvider {
|
||||
public boolean isSupportCurrentMode();
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.core.runtime.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.components.IComponentsFactory;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.service.IUpdateService;
|
||||
import org.talend.utils.io.FilesUtils;
|
||||
|
||||
public class SharedStudioUtils {
|
||||
|
||||
public static final String FILE_EXTRA_FEATURE_INDEX = "extra_feature.index"; //$NON-NLS-1$
|
||||
|
||||
public static final String SIGNATURE_FILE_NAME_SUFFIX = ".sig"; //$NON-NLS-1$
|
||||
public static final String PROP_DEVMODE = "osgi.dev"; //$NON-NLS-1$
|
||||
|
||||
public static boolean updateExtraFeatureFile() {
|
||||
File userConfigFolder = new File(Platform.getConfigurationLocation().getURL().getPath());
|
||||
File studioConfigFolder = new File(Platform.getInstallLocation().getURL().getPath(), "configuration");//$NON-NLS-1$
|
||||
if (!userConfigFolder.getAbsolutePath().equals(studioConfigFolder.getAbsolutePath())) {
|
||||
File studioExtraFile = new File(studioConfigFolder, FILE_EXTRA_FEATURE_INDEX);
|
||||
File studioExtraSignFile = new File(studioConfigFolder, FILE_EXTRA_FEATURE_INDEX + SIGNATURE_FILE_NAME_SUFFIX);
|
||||
File userExtraFile = new File(userConfigFolder, FILE_EXTRA_FEATURE_INDEX);
|
||||
File userExtraSignFile = new File(userConfigFolder, FILE_EXTRA_FEATURE_INDEX + SIGNATURE_FILE_NAME_SUFFIX);
|
||||
boolean isNeedUpdate = false;
|
||||
if (!studioExtraSignFile.exists() && userExtraSignFile.exists()) {
|
||||
userExtraSignFile.delete();
|
||||
if (userExtraFile.exists()) {
|
||||
userExtraFile.delete();
|
||||
}
|
||||
return true;
|
||||
} else if (studioExtraSignFile.exists()) {
|
||||
isNeedUpdate = true;
|
||||
}
|
||||
if (isNeedUpdate) {
|
||||
try {
|
||||
FilesUtils.copyFile(studioExtraFile, userExtraFile);
|
||||
FilesUtils.copyFile(studioExtraSignFile, userExtraSignFile);
|
||||
} catch (IOException ex) {
|
||||
ExceptionHandler.process(ex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isSharedStudioMode() {
|
||||
if (isDevEnvironment()) {
|
||||
return false;
|
||||
}
|
||||
File configFolder = new File (Platform.getConfigurationLocation().getURL().getFile());
|
||||
File studioFolder = new File (Platform.getInstallLocation().getURL().getFile());
|
||||
if (configFolder != null && studioFolder != null && configFolder.getParentFile() != null
|
||||
&& configFolder.getParentFile().getAbsolutePath().equals(studioFolder.getAbsolutePath())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isDevEnvironment() {
|
||||
if (CoreRuntimePlugin.getInstance().getBundle().getBundleContext().getProperty(PROP_DEVMODE) != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean installedPatch() {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IUpdateService.class)) {
|
||||
IUpdateService updateService = GlobalServiceRegister.getDefault().getService(IUpdateService.class);
|
||||
try {
|
||||
return updateService.syncSharedStudioLibraryInPatch(new NullProgressMonitor());
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static File getSharedStudioComponentsParentFolder() {
|
||||
File configFolder = new File(Platform.getConfigurationLocation().getURL().getFile());
|
||||
return configFolder;
|
||||
}
|
||||
|
||||
public static File getSharedStudioComponentsExtFolder() {
|
||||
File componentFolder = SharedStudioUtils.getSharedStudioComponentsParentFolder();
|
||||
IPath path = new Path(IComponentsFactory.COMPONENTS_INNER_FOLDER);
|
||||
path = path.append(IComponentsFactory.EXTERNAL_COMPONENTS_INNER_FOLDER);
|
||||
File extchangeFolder = new File (componentFolder, path.toOSString());
|
||||
return extchangeFolder;
|
||||
}
|
||||
|
||||
public static IPath getTempFolderPath() {
|
||||
if (SharedStudioUtils.isSharedStudioMode()) {
|
||||
Path wsPath = new Path(Platform.getInstanceLocation().getURL().getPath());
|
||||
return wsPath.append("temp");
|
||||
} else {
|
||||
return new Path(System.getProperty("user.dir")).append("temp");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,4 +38,12 @@ public interface IDQComponentService extends IService {
|
||||
* @param node The node which need to be modified
|
||||
*/
|
||||
void correctlyCustomMatcherParameter(NodeType node);
|
||||
|
||||
/**
|
||||
* Change the attribute of MatchingData and use Integer value instead of double value.
|
||||
*
|
||||
* @param node The node which need to be modified
|
||||
*/
|
||||
void covertConfindWeight2Int(NodeType node);
|
||||
|
||||
}
|
||||
|
||||
@@ -20,5 +20,9 @@ public interface IUpdateService extends IService {
|
||||
boolean checkComponentNexusUpdate();
|
||||
|
||||
void syncComponentM2Jars(IProgressMonitor monitor);
|
||||
|
||||
public boolean syncSharedStudioLibraryInPatch(IProgressMonitor monitor) throws Exception;
|
||||
|
||||
public String getSharedStudioMissingPatchVersion();
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
package org.talend.core.ui;
|
||||
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
|
||||
/**
|
||||
* @author hwang
|
||||
@@ -21,5 +22,7 @@ import org.talend.core.IService;
|
||||
public interface IInstalledPatchService extends IService {
|
||||
|
||||
public String getLatestInstalledVersion(boolean isBar);
|
||||
|
||||
public MavenArtifact getLastIntalledP2Patch();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.talend.core.utils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
|
||||
public class DialogUtils {
|
||||
|
||||
private static ELoginInfoCase finalCase;
|
||||
|
||||
public static void setWarningInfo(ELoginInfoCase warnningInfo) {
|
||||
finalCase = warnningInfo;
|
||||
}
|
||||
|
||||
public static void syncOpenWarningDialog(String title) {
|
||||
if (CommonsPlugin.isHeadless() || DialogUtils.finalCase == null) {
|
||||
return;
|
||||
}
|
||||
int dialogType = DialogUtils.finalCase.getDialogType();
|
||||
String[] contents = DialogUtils.finalCase.getContents();
|
||||
List<String> asList = Arrays.asList(contents);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
asList.forEach(w -> {
|
||||
sb.append(w);
|
||||
sb.append("\n");// $NON-NLS-1$
|
||||
});
|
||||
int[] selectIndex = new int[1];
|
||||
Display.getDefault().syncExec(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
String[] dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL, };
|
||||
|
||||
if (dialogType == MessageDialog.ERROR) {
|
||||
dialogButtonLabels = new String[] { IDialogConstants.CANCEL_LABEL };
|
||||
}
|
||||
int open = MessageDialog.open(dialogType, Display.getDefault().getActiveShell(), title, sb.toString(), SWT.NONE,
|
||||
dialogButtonLabels);
|
||||
selectIndex[0] = open;
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
DialogUtils.finalCase = null;
|
||||
if (dialogType == MessageDialog.ERROR) {
|
||||
throw new OperationCanceledException(""); //$NON-NLS-1$
|
||||
}
|
||||
if (1 == selectIndex[0]) {
|
||||
throw new OperationCanceledException(""); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.talend.core.utils;
|
||||
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
|
||||
public enum ELoginInfoCase {
|
||||
|
||||
STUDIO_LOWER_THAN_PROJECT(MessageDialog.ERROR),
|
||||
|
||||
STUDIO_HIGHER_THAN_PROJECT(MessageDialog.WARNING);
|
||||
|
||||
private int dialogType;
|
||||
|
||||
private String[] contents;
|
||||
|
||||
ELoginInfoCase(int dialogType) {
|
||||
this.dialogType = dialogType;
|
||||
}
|
||||
|
||||
ELoginInfoCase(int dialogType, String[] contents) {
|
||||
this.dialogType = dialogType;
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
public int getDialogType() {
|
||||
return dialogType;
|
||||
}
|
||||
|
||||
public void setDialogType(int dialogType) {
|
||||
this.dialogType = dialogType;
|
||||
}
|
||||
|
||||
public String[] getContents() {
|
||||
return contents;
|
||||
}
|
||||
|
||||
public void setContents(String[] contents) {
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,6 +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;
|
||||
@@ -94,6 +95,8 @@ public final class ProjectManager {
|
||||
|
||||
private Set<Project> tempProjects;
|
||||
|
||||
private WeakHashMap<IRepositoryViewObject, Boolean> cachedObjects = new WeakHashMap<IRepositoryViewObject, Boolean>();
|
||||
|
||||
private ProjectManager() {
|
||||
beforeLogonRecords = new HashSet<String>();
|
||||
logonRecords = new HashSet<String>();
|
||||
@@ -451,9 +454,15 @@ 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();
|
||||
return emfProject.equals(curProject);
|
||||
boolean ret = emfProject.equals(curProject);
|
||||
cachedObjects.put(object, ret);
|
||||
return ret;
|
||||
|
||||
} else {
|
||||
IProjectRepositoryNode root = node.getRoot();
|
||||
@@ -606,7 +615,8 @@ public final class ProjectManager {
|
||||
*/
|
||||
|
||||
if (!branchSelection.contains(NAME_TAGS) && !branchSelection.contains(NAME_BRANCHES)
|
||||
&& !branchSelection.contains(NAME_TRUNK) && !branchSelection.contains("master")) { //$NON-NLS-1$
|
||||
&& !branchSelection.contains(NAME_TRUNK) && !branchSelection.contains(SVNConstant.NAME_MASTER)
|
||||
&& !branchSelection.contains(SVNConstant.NAME_MAIN)) {
|
||||
branchSelection = NAME_BRANCHES + branchSelection;
|
||||
}
|
||||
return branchSelection;
|
||||
@@ -649,7 +659,8 @@ public final class ProjectManager {
|
||||
if (!branchName.startsWith(SVNConstant.NAME_TAGS + SVNConstant.SEP_CHAR)
|
||||
&& !branchName.startsWith(SVNConstant.NAME_BRANCHES + SVNConstant.SEP_CHAR)
|
||||
&& !branchName.startsWith(SVNConstant.NAME_ORIGIN + SVNConstant.SEP_CHAR)
|
||||
&& !branchName.equals(SVNConstant.NAME_TRUNK) && !branchName.equals(SVNConstant.NAME_MASTER)) {
|
||||
&& !branchName.equals(SVNConstant.NAME_TRUNK) && !branchName.equals(SVNConstant.NAME_MASTER)
|
||||
&& !branchName.equals(SVNConstant.NAME_MAIN)) {
|
||||
formatedBranchName = SVNConstant.NAME_BRANCHES + SVNConstant.SEP_CHAR + branchName;
|
||||
}
|
||||
return formatedBranchName;
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.components.IComponentsFactory;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
|
||||
import org.talend.core.model.process.IContextManager;
|
||||
@@ -125,7 +126,16 @@ public interface IRepositoryService extends IService {
|
||||
|
||||
public void openProjectSettingDialog(final String pageId);
|
||||
|
||||
public List<String> getProjectBranch(Project project) throws JSONException;
|
||||
/**
|
||||
*
|
||||
* get branches of project
|
||||
*
|
||||
* @param project
|
||||
* @param onlyLocalIfPossible try to only get branches from local repository to improve performance
|
||||
* @return
|
||||
* @throws JSONException
|
||||
*/
|
||||
public List<String> getProjectBranch(Project project, boolean onlyLocalIfPossible) throws JSONException;
|
||||
|
||||
public boolean askRetryForNetworkIssue(Throwable ex);
|
||||
|
||||
@@ -135,4 +145,8 @@ public interface IRepositoryService extends IService {
|
||||
|
||||
public void setShouldCheckRepoViewCommonNavigatorDirty(IRepositoryView repView, boolean shouldFlag);
|
||||
|
||||
boolean isProjectLevelLog4j2();
|
||||
|
||||
List<ModuleNeeded> getLog4j2Modules();
|
||||
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ public class RepositoryConstants {
|
||||
|
||||
public static final String JOBLET_DOCUMENTATION_PATH = "documentations/generated/joblets"; //$NON-NLS-1$
|
||||
|
||||
public static final String PROJECT_SETTINGS_CUSTOM_URI_MAP = "custom_uri_mapping.json"; //$NON-NLS-1$
|
||||
|
||||
public static final String SYSTEM_DIRECTORY = "system"; //$NON-NLS-1$
|
||||
|
||||
public static final String USER_DEFINED = "UserDefined"; //$NON-NLS-1$
|
||||
|
||||
@@ -497,7 +497,11 @@ public class ContextTreeTable {
|
||||
int max = 0;
|
||||
String text = "";
|
||||
for (int i = 0; i < dataLayer.getPreferredRowCount(); i++) {
|
||||
text = dataLayer.getDataValueByPosition(colPos, i).toString();
|
||||
Object dataValueByPosition = dataLayer.getDataValueByPosition(colPos, i);
|
||||
if (dataValueByPosition == null) {
|
||||
continue;
|
||||
}
|
||||
text = dataValueByPosition.toString();
|
||||
Point size = gc.textExtent(text, SWT.DRAW_MNEMONIC);
|
||||
int temp = size.x;
|
||||
if (temp > max) {
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.eclipse.gef.commands.Command;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.viewers.DialogCellEditor;
|
||||
import org.eclipse.jface.viewers.TableViewer;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.FocusAdapter;
|
||||
import org.eclipse.swt.events.FocusEvent;
|
||||
@@ -37,7 +36,6 @@ import org.talend.core.model.process.IElement;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.core.model.process.IProcess2;
|
||||
import org.talend.core.runtime.services.IGenericDBService;
|
||||
import org.talend.core.ui.CoreUIPlugin;
|
||||
import org.talend.core.ui.process.IGEFProcess;
|
||||
import org.talend.core.ui.services.IDesignerCoreUIService;
|
||||
@@ -171,7 +169,7 @@ public class ModuleListCellEditor extends DialogCellEditor {
|
||||
ILibraryManagerUIService.class);
|
||||
IConfigModuleDialog dialog = libUiService.getConfigModuleDialog(cellEditorWindow.getShell(), "\"newLine\"".equals(value) ? "" : value);
|
||||
if (dialog.open() == IDialogConstants.OK_ID) {
|
||||
String selecteModule = dialog.getModuleName();
|
||||
String selecteModule = dialog.getMavenURI();
|
||||
if (selecteModule != null && (value == null || !value.equals(selecteModule))) {
|
||||
setModuleValue(selecteModule, null, null);
|
||||
return selecteModule;
|
||||
@@ -192,24 +190,16 @@ public class ModuleListCellEditor extends DialogCellEditor {
|
||||
}
|
||||
// enable to refresh component setting after change modules.
|
||||
IElement element = this.tableParam.getElement();
|
||||
boolean isNotCConfig = element.getElementParameter("COMPONENT_NAME") == null ?
|
||||
true : !"cConfig".equals(element.getElementParameter("COMPONENT_NAME").getValue());
|
||||
if (element != null && isNotCConfig) {
|
||||
if (element != null) {
|
||||
IElementParameter updateComponentsParam = element.getElementParameter("UPDATE_COMPONENTS"); //$NON-NLS-1$
|
||||
if (updateComponentsParam != null) {
|
||||
updateComponentsParam.setValue(Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
executeCommand(new ModelChangeCommand(tableParam, param.getName(), newValue, index));
|
||||
|
||||
if (newVal != null) {
|
||||
executeCommand(new ModelChangeCommand(tableParam, "JAR_PATH", newVal, index));
|
||||
}
|
||||
if (nexusVersion != null) {
|
||||
executeCommand(new ModelChangeCommand(tableParam, "JAR_NEXUS_VERSION", nexusVersion, index));
|
||||
}
|
||||
|
||||
oldValue = newValue;
|
||||
if (getTableViewer() != null) {
|
||||
getTableViewer().refresh(true);
|
||||
|
||||
@@ -102,7 +102,9 @@ public class HorizontalTabFactory {
|
||||
* @param descriptors
|
||||
*/
|
||||
public void setInput(List<TalendPropertyTabDescriptor> descriptors) {
|
||||
tabbedPropertyViewer.setInput(descriptors);
|
||||
if (tabbedPropertyViewer != null && tabbedPropertyViewer.getControl() != null && !tabbedPropertyViewer.getControl().isDisposed()) {
|
||||
tabbedPropertyViewer.setInput(descriptors);
|
||||
}
|
||||
}
|
||||
|
||||
public List<TalendPropertyTabDescriptor> getInput() {
|
||||
|
||||
@@ -91,6 +91,10 @@ public class PluginUtil {
|
||||
return "org.talend.camel.testcontainer.ui.editor.CamelTestContainerMultiPageEditor".equals(getActiveEditorId()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public static boolean isRouteletEditor() {
|
||||
return "org.talend.repository.routelets.editor.RouteletMultiPageTalendEditor".equals(getActiveEditorId()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC yyan Get active editor ID.
|
||||
*
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// ============================================================================
|
||||
package org.talend.core;
|
||||
|
||||
import org.apache.logging.log4j.message.ThreadDumpMessage;
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
@@ -208,4 +209,8 @@ public class CorePlugin extends Plugin {
|
||||
return (ICreateXtextProcessService) GlobalServiceRegister.getDefault().getService(ICreateXtextProcessService.class);
|
||||
}
|
||||
|
||||
public static String threadDump(String message) {
|
||||
return new ThreadDumpMessage(message).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
package org.talend.core.model.metadata.query.generator;
|
||||
|
||||
import org.talend.core.database.EDatabaseTypeName;
|
||||
import org.talend.core.model.metadata.QueryUtil;
|
||||
import org.talend.core.model.metadata.query.AbstractQueryGenerator;
|
||||
import org.talend.core.model.process.IElement;
|
||||
|
||||
@@ -38,4 +39,23 @@ public class PostgreQueryGenerator extends AbstractQueryGenerator {
|
||||
}
|
||||
return super.getSchema(elem);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTableNameWithDBAndSchema(final String dbName, final String schema, String tableName) {
|
||||
if (tableName == null || EMPTY.equals(tableName.trim())) {
|
||||
tableName = QueryUtil.DEFAULT_TABLE_NAME;
|
||||
}
|
||||
|
||||
final StringBuffer tableNameWithDBAndSchema = new StringBuffer();
|
||||
|
||||
// postgres do not support db.schema.table_name, so only need schema.table_name
|
||||
if (schema != null && !EMPTY.equals(schema)) {
|
||||
tableNameWithDBAndSchema.append(checkContextAndAddQuote(schema));
|
||||
tableNameWithDBAndSchema.append(getSQLFieldConnector());
|
||||
}
|
||||
//
|
||||
tableNameWithDBAndSchema.append(checkContextAndAddQuote(tableName));
|
||||
|
||||
return tableNameWithDBAndSchema.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@ import java.io.File;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
||||
import org.eclipse.core.runtime.preferences.DefaultScope;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.talend.core.CorePlugin;
|
||||
import org.talend.core.prefs.GeneralParametersProvider.GeneralParameters;
|
||||
import org.talend.core.runtime.util.SharedStudioUtils;
|
||||
|
||||
/**
|
||||
* Intializer of core preferences. <br/>
|
||||
@@ -54,7 +54,7 @@ public class CorePreferenceInitializer extends AbstractPreferenceInitializer {
|
||||
IEclipsePreferences node = new DefaultScope().getNode(CorePlugin.getDefault().getBundle().getSymbolicName());
|
||||
|
||||
// Building temporary files directory path
|
||||
IPath tempPath = new Path(System.getProperty("user.dir")).append("temp"); // NON-NLS-1$// NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-2$
|
||||
IPath tempPath = SharedStudioUtils.getTempFolderPath();
|
||||
File tempFile = tempPath.toFile();
|
||||
if (!tempFile.exists()) {
|
||||
tempFile.mkdirs();
|
||||
|
||||
@@ -34,7 +34,14 @@ public interface IGITProviderService extends IService {
|
||||
|
||||
public String getCurrentGITRevision(Object process);
|
||||
|
||||
public String[] getBranchList(Project project);
|
||||
/**
|
||||
* get project branches
|
||||
*
|
||||
* @param project
|
||||
* @param onlyLocalIfPossible try to only get branches from local repository to improve performance
|
||||
* @return
|
||||
*/
|
||||
public String[] getBranchList(Project project, boolean onlyLocalIfPossible);
|
||||
|
||||
public boolean isGITProject(Project p) throws PersistenceException;
|
||||
|
||||
@@ -48,6 +55,8 @@ public interface IGITProviderService extends IService {
|
||||
|
||||
void createOrUpdateGitIgnoreFile(IProject eclipseProject) throws CoreException;
|
||||
|
||||
String getDefaultBranch(Project project);
|
||||
|
||||
public static IGITProviderService get() {
|
||||
GlobalServiceRegister register = GlobalServiceRegister.getDefault();
|
||||
if (!register.isServiceRegistered(IGITProviderService.class)) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<artifactId>studio-tacokit-dependencies</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<properties>
|
||||
<tacokit.components.version>1.13.0</tacokit.components.version>
|
||||
<tacokit.components.version>1.16.0</tacokit.components.version>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
|
||||
@@ -52,6 +52,7 @@ import org.eclipse.swt.widgets.Display;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.IESBService;
|
||||
import org.talend.core.ILibraryManagerService;
|
||||
import org.talend.core.context.Context;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
@@ -168,6 +169,10 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
|
||||
public void updateCodeProjects(IProgressMonitor monitor, boolean forceBuild) {
|
||||
updateCodeProjects(monitor, forceBuild, false);
|
||||
}
|
||||
|
||||
public void updateCodeProjects(IProgressMonitor monitor, boolean forceBuild, boolean ignoreM2Cache) {
|
||||
RepositoryWorkUnit workUnit = new RepositoryWorkUnit<Object>("update code project") { //$NON-NLS-1$
|
||||
|
||||
@Override
|
||||
@@ -175,8 +180,11 @@ public class AggregatorPomsHelper {
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
for (ERepositoryObjectType codeType : ERepositoryObjectType.getAllTypesOfCodes()) {
|
||||
try {
|
||||
if (CodeM2CacheManager.needUpdateCodeProject(currentProject, codeType)) {
|
||||
ITalendProcessJavaProject codeProject = getCodesProject(codeType);
|
||||
ITalendProcessJavaProject codeProject = getCodesProject(codeType);
|
||||
if (ERepositoryObjectType.ROUTINES == codeType) {
|
||||
PomUtil.checkExistingLog4j2Dependencies4RoutinePom(projectTechName, codeProject.getProjectPom());
|
||||
}
|
||||
if (ignoreM2Cache || CodeM2CacheManager.needUpdateCodeProject(currentProject, codeType)) {
|
||||
updateCodeProjectPom(monitor, codeType, codeProject.getProjectPom());
|
||||
buildAndInstallCodesProject(monitor, codeType, true, forceBuild);
|
||||
CodeM2CacheManager.updateCodeProjectCache(currentProject, codeType);
|
||||
@@ -344,14 +352,9 @@ public class AggregatorPomsHelper {
|
||||
private static boolean checkIfCanAddToParentModules(Property property, boolean checkFilter) {
|
||||
// Check relation for ESB service job, should not be added into main pom
|
||||
if (property != null) {
|
||||
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(property.getId(),
|
||||
property.getVersion(), RelationshipItemBuilder.JOB_RELATION);
|
||||
for (Relation relation : relations) {
|
||||
if (RelationshipItemBuilder.SERVICES_RELATION.equals(relation.getType())) {
|
||||
return false;
|
||||
}
|
||||
if (isSOAPServiceProvider(property)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// for import won't add for exclude option
|
||||
if (property.getItem() != null && property.getItem().getState() != null && property.getItem().getState().isDeleted()
|
||||
&& PomIdsHelper.getIfExcludeDeletedItems(property)) {
|
||||
@@ -860,7 +863,7 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
// codes pom
|
||||
monitor.subTask("Synchronize code poms"); //$NON-NLS-1$
|
||||
updateCodeProjects(monitor, true);
|
||||
updateCodeProjects(monitor, true, true);
|
||||
monitor.worked(1);
|
||||
if (monitor.isCanceled()) {
|
||||
return;
|
||||
@@ -896,7 +899,7 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
IFile pomFile = getItemPomFolder(item.getProperty()).getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
// filter esb data service node
|
||||
if (!isDataServiceOperation(object.getProperty()) && pomFile.exists()) {
|
||||
if (!isSOAPServiceProvider(object.getProperty()) && pomFile.exists()) {
|
||||
modules.add(getModulePath(pomFile));
|
||||
}
|
||||
}
|
||||
@@ -937,7 +940,7 @@ public class AggregatorPomsHelper {
|
||||
* @param property
|
||||
* @return
|
||||
*/
|
||||
private boolean isDataServiceOperation(Property property) {
|
||||
private static boolean isSOAPServiceProvider(Property property) {
|
||||
if (property != null) {
|
||||
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(property.getId(),
|
||||
property.getVersion(), RelationshipItemBuilder.JOB_RELATION);
|
||||
@@ -946,6 +949,14 @@ public class AggregatorPomsHelper {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
|
||||
IESBService service = GlobalServiceRegister.getDefault().getService(IESBService.class);
|
||||
if (service != null) {
|
||||
if (service.isSOAPServiceProvider(property.getItem())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.text.ParseException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
@@ -39,6 +40,14 @@ public class CodeM2CacheManager {
|
||||
|
||||
private static final String KEY_SEPERATOR = "|"; //$NON-NLS-1$
|
||||
|
||||
private static final String EMPTY_DATE;
|
||||
|
||||
static {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTimeInMillis(0);
|
||||
EMPTY_DATE = ResourceHelper.dateFormat().format(c.getTime());
|
||||
}
|
||||
|
||||
public static boolean needUpdateCodeProject(Project project, ERepositoryObjectType codeType) {
|
||||
try {
|
||||
String projectTechName = project.getTechnicalLabel();
|
||||
@@ -56,11 +65,11 @@ public class CodeM2CacheManager {
|
||||
// check M
|
||||
for (IRepositoryViewObject codeItem : allCodes) {
|
||||
Property property = codeItem.getProperty();
|
||||
String key = getCacheKey(projectTechName, property);
|
||||
String cachedTimestamp = cache.getProperty(key);
|
||||
if (cachedTimestamp != null) {
|
||||
Date currentDate = ResourceHelper.dateFormat().parse(getCacheDate(projectTechName, property));
|
||||
Date cachedDate = ResourceHelper.dateFormat().parse(cachedTimestamp);
|
||||
String key = getKey(projectTechName, property);
|
||||
String cacheValue = cache.getProperty(key);
|
||||
if (cacheValue != null) {
|
||||
Date currentDate = ResourceHelper.dateFormat().parse(getModifiedDate(projectTechName, property));
|
||||
Date cachedDate = ResourceHelper.dateFormat().parse(cacheValue);
|
||||
if (currentDate.compareTo(cachedDate) != 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -82,8 +91,8 @@ public class CodeM2CacheManager {
|
||||
Properties cache = new Properties();
|
||||
for (IRepositoryViewObject codeItem : allCodes) {
|
||||
Property property = codeItem.getProperty();
|
||||
String key = getCacheKey(projectTechName, property);
|
||||
String value = getCacheDate(projectTechName, property);
|
||||
String key = getKey(projectTechName, property);
|
||||
String value = getModifiedDate(projectTechName, property);
|
||||
cache.put(key, value);
|
||||
}
|
||||
cache.store(out, StringUtils.EMPTY);
|
||||
@@ -92,18 +101,19 @@ public class CodeM2CacheManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static File getCacheFile(String projectTechName, ERepositoryObjectType codeType) {
|
||||
public static File getCacheFile(String projectTechName, ERepositoryObjectType codeType) {
|
||||
String cacheFileName = PomIdsHelper.getProjectGroupId(projectTechName) + "." + codeType.name().toLowerCase() + "-" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ PomIdsHelper.getCodesVersion(projectTechName) + ".cache"; // $NON-NLS-1$
|
||||
return new File(MavenPlugin.getMaven().getLocalRepositoryPath(), cacheFileName);
|
||||
}
|
||||
|
||||
private static String getCacheKey(String projectTechName, Property property) {
|
||||
private static String getKey(String projectTechName, Property property) {
|
||||
return projectTechName + KEY_SEPERATOR + property.getId() + KEY_SEPERATOR + property.getVersion(); // $NON-NLS-1$
|
||||
}
|
||||
|
||||
private static String getCacheDate(String projectTechName, Property property) {
|
||||
return (String) property.getAdditionalProperties().get(ItemProductKeys.DATE.getModifiedKey());
|
||||
private static String getModifiedDate(String projectTechName, Property property) {
|
||||
String modifiedDate = (String) property.getAdditionalProperties().get(ItemProductKeys.DATE.getModifiedKey());
|
||||
return StringUtils.isNotBlank(modifiedDate) ? modifiedDate : EMPTY_DATE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ 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.process.TalendProcessArgumentConstant;
|
||||
import org.talend.core.runtime.projectsetting.IProjectSettingTemplateConstants;
|
||||
import org.talend.core.runtime.repository.build.IMavenPomCreator;
|
||||
@@ -52,6 +53,7 @@ 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;
|
||||
@@ -134,9 +136,15 @@ 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.
|
||||
variablesValuesMap.put(ETalendMavenVariables.JobGroupId, PomIdsHelper.getJobGroupId(property));
|
||||
variablesValuesMap.put(ETalendMavenVariables.JobArtifactId, PomIdsHelper.getJobArtifactId(property));
|
||||
variablesValuesMap.put(ETalendMavenVariables.JobVersion, PomIdsHelper.getJobVersion(property));
|
||||
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.JobArtifactId, PomIdsHelper.getJobArtifactId(property));
|
||||
variablesValuesMap.put(ETalendMavenVariables.TalendJobVersion, property.getVersion());
|
||||
final String jobName = JavaResourcesHelper.escapeFileName(process.getName());
|
||||
variablesValuesMap.put(ETalendMavenVariables.JobName, jobName);
|
||||
@@ -310,10 +318,18 @@ 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();
|
||||
|
||||
@@ -674,13 +674,17 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
ERepositoryObjectType.getAllTypesOfCodes().forEach(t -> dependencies.addAll(PomUtil.getCodesDependencies(t)));
|
||||
|
||||
// libraries of talend/3rd party
|
||||
dependencies.addAll(processor.getNeededModules(TalendProcessOptionConstants.MODULES_EXCLUDE_SHADED).stream()
|
||||
.filter(m -> !m.isExcluded()).map(m -> createDenpendency(m, false)).collect(Collectors.toSet()));
|
||||
Set<Dependency> parentJobDependencies = processor.getNeededModules(TalendProcessOptionConstants.MODULES_EXCLUDE_SHADED).stream()
|
||||
.filter(m -> !m.isExcluded()).map(m -> createDenpendency(m, false)).collect(Collectors.toSet());
|
||||
dependencies.addAll(parentJobDependencies);
|
||||
|
||||
// missing modules from the job generation of children
|
||||
childrenJobInfo.forEach(j -> dependencies
|
||||
.addAll(LastGenerationInfo.getInstance().getModulesNeededPerJob(j.getJobId(), j.getJobVersion()).stream()
|
||||
.filter(m -> !m.isExcluded()).map(m -> createDenpendency(m, false)).collect(Collectors.toSet())));
|
||||
Map<String, Set<Dependency>> childjobDependencies = new HashMap<String, Set<Dependency>>();
|
||||
childrenJobInfo.forEach(j -> {
|
||||
Set<Dependency> collectDependency = LastGenerationInfo.getInstance().getModulesNeededPerJob(j.getJobId(), j.getJobVersion()).stream()
|
||||
.filter(m -> !m.isExcluded()).map(m -> createDenpendency(m, false)).collect(Collectors.toSet());
|
||||
dependencies.addAll(collectDependency);
|
||||
childjobDependencies.put(j.getJobId(), collectDependency);});
|
||||
|
||||
Set<ModuleNeeded> modules = new HashSet<>();
|
||||
// testcase modules from current job (optional)
|
||||
@@ -749,7 +753,7 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
setupDependencySetNode(document, jobCoordinate, "${talend.job.name}",
|
||||
"${artifact.build.finalName}.${artifact.extension}", true, false);
|
||||
// add duplicate dependencies if exists
|
||||
setupFileNode(document, duplicateLibs.values().stream().flatMap(s -> s.stream()).collect(Collectors.toSet()));
|
||||
setupFileNode(document, parentJobDependencies, childjobDependencies, duplicateLibs);
|
||||
|
||||
PomUtil.saveAssemblyFile(assemblyFile, document);
|
||||
} catch (Exception e) {
|
||||
@@ -886,15 +890,18 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
|
||||
}
|
||||
|
||||
private void setupFileNode(Document document, Set<Dependency> duplicateDependencies) throws CoreException {
|
||||
private void setupFileNode(Document document, Set<Dependency> parentJobDependencies, Map<String, Set<Dependency>> childJobDependencies, Map<String, Set<Dependency>> duplicateLibs) throws CoreException {
|
||||
Node filesNode = document.getElementsByTagName("files").item(0);
|
||||
// TESB-27614:NPE while building a route
|
||||
if (filesNode == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<Dependency> duplicateDependencies = duplicateLibs.values().stream().flatMap(s -> s.stream()).collect(Collectors.toSet());
|
||||
if (duplicateDependencies.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
IMaven maven = MavenPlugin.getMaven();
|
||||
ArtifactRepository repository = maven.getLocalRepository();
|
||||
boolean isDIJob = ERepositoryObjectType.getItemType(getJobProcessor().getProperty().getItem()) == ERepositoryObjectType.PROCESS;
|
||||
@@ -906,10 +913,13 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
dependency.getVersion(), dependency.getType(), dependency.getClassifier());
|
||||
Path path = new File(repository.getBasedir()).toPath().resolve(sourceLocation);
|
||||
sourceLocation = path.toString();
|
||||
if (isDIJob && !new File(sourceLocation).exists()) {
|
||||
|
||||
boolean latestVersionOrLowerVersionInChildJob = isLatestVersionOrLowerVersionInChildJob(parentJobDependencies, childJobDependencies, duplicateLibs, dependency);
|
||||
if (isDIJob && !latestVersionOrLowerVersionInChildJob && !new File(sourceLocation).exists()) {
|
||||
CommonExceptionHandler.warn("Job dependency [" + sourceLocation + "] does not exist!");
|
||||
continue;
|
||||
}
|
||||
|
||||
String destName = path.getFileName().toString();
|
||||
Node fileNode = document.createElement("file");
|
||||
filesNode.appendChild(fileNode);
|
||||
@@ -926,8 +936,49 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
destNameNode.setTextContent(destName);
|
||||
fileNode.appendChild(destNameNode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected boolean isLatestVersionOrLowerVersionInChildJob(Set<Dependency> parentJobDependencies,
|
||||
Map<String, Set<Dependency>> childJobDependencies, Map<String, Set<Dependency>> duplicateLibs,
|
||||
Dependency dependency) {
|
||||
String coordinate = getCheckDupCoordinate(dependency);
|
||||
Set<Dependency> dependencies = duplicateLibs.get(coordinate);
|
||||
if (dependencies.size() == 1) {
|
||||
return true; // latest version
|
||||
}
|
||||
|
||||
boolean latest = false;
|
||||
if (parentJobDependencies.contains(dependency)) {
|
||||
// keep if it's latest version in parent job
|
||||
latest = isTheLatest(dependency, coordinate, parentJobDependencies);
|
||||
if(!latest) {//check if it's the latest in any child job
|
||||
latest = isLatestInAnyChild(dependency, coordinate, childJobDependencies);
|
||||
}
|
||||
} else {//only check if it's the latest in any child job
|
||||
latest = isLatestInAnyChild(dependency, coordinate, childJobDependencies);
|
||||
}
|
||||
|
||||
|
||||
return latest;
|
||||
}
|
||||
|
||||
private boolean isLatestInAnyChild(Dependency dependency, String coordinate,
|
||||
Map<String, Set<Dependency>> childJobDependencies) {
|
||||
return childJobDependencies.entrySet().stream().filter(entry -> entry.getValue().contains(dependency))
|
||||
.anyMatch(entry -> isTheLatest(dependency, coordinate, entry.getValue()));
|
||||
}
|
||||
|
||||
private boolean isTheLatest(Dependency dependency, String coordinate, Set<Dependency> targetSet) {
|
||||
Optional<Dependency> latest = targetSet.stream().filter(d -> getCheckDupCoordinate(d).equals(coordinate))
|
||||
.sorted((d1, d2) -> compareVersion(d2, d1)).findFirst();
|
||||
return latest.isPresent() && dependency.equals(latest.get());
|
||||
}
|
||||
|
||||
private int compareVersion(Dependency dependency, Dependency targetDependency) {
|
||||
return new ComparableVersion(dependency.getVersion()).compareTo(new ComparableVersion(targetDependency.getVersion()));
|
||||
}
|
||||
|
||||
protected Plugin addSkipDockerMavenPlugin() {
|
||||
Plugin plugin = new Plugin();
|
||||
|
||||
|
||||
@@ -12,16 +12,18 @@
|
||||
// ============================================================================
|
||||
package org.talend.designer.maven.tools.creator;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.PluginChecker;
|
||||
import org.talend.core.model.general.ILibrariesService;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.designer.maven.template.MavenTemplateManager;
|
||||
import org.talend.repository.model.IRepositoryService;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
@@ -46,13 +48,18 @@ public class CreateMavenRoutinePom extends AbstractMavenCodesTemplatePom {
|
||||
// Set<ModuleNeeded> runningModules = routiensService.getRunningModules();
|
||||
// return runningModules;
|
||||
// }
|
||||
Set<ModuleNeeded> runningModules = new HashSet<>();
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
|
||||
ILibrariesService libService = (ILibrariesService) GlobalServiceRegister.getDefault().getService(
|
||||
ILibrariesService.class);
|
||||
Set<ModuleNeeded> runningModules = libService.getCodesModuleNeededs(ERepositoryObjectType.ROUTINES);
|
||||
return runningModules;
|
||||
runningModules.addAll(libService.getCodesModuleNeededs(ERepositoryObjectType.ROUTINES));
|
||||
}
|
||||
return Collections.emptySet();
|
||||
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRepositoryService.class)) {
|
||||
IRepositoryService repositoryService = GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
if (PluginChecker.isBigdataRoutineLoaded() && repositoryService.isProjectLevelLog4j2()) {
|
||||
runningModules.addAll(repositoryService.getLog4j2Modules());
|
||||
}
|
||||
}
|
||||
return runningModules;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ 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;
|
||||
@@ -97,5 +99,29 @@ 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -98,12 +98,7 @@ public class MavenProjectUtils {
|
||||
IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault().getDefault()
|
||||
.getService(IRunProcessService.class);
|
||||
|
||||
if (service.isdebug()) {
|
||||
changeClasspath(monitor, project, MavenSystemFolders.ALL_DIRS_EXT);
|
||||
} else {
|
||||
|
||||
changeClasspath(monitor, project);
|
||||
}
|
||||
changeClasspath(monitor, project, MavenSystemFolders.ALL_DIRS_EXT);
|
||||
}
|
||||
|
||||
// only need this when pom has no parent.
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.IESBService;
|
||||
import org.talend.core.PluginChecker;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.process.JobInfo;
|
||||
import org.talend.core.model.properties.Property;
|
||||
@@ -346,7 +347,9 @@ public class PomIdsHelper {
|
||||
if (!preferenceManager.exist()
|
||||
&& StringUtils.isBlank(preferenceStore.getString(MavenConstants.EXCLUDE_DELETED_ITEMS))) {
|
||||
// for new project, set EXCLUDE_DELETED_ITEMS=true as default
|
||||
preferenceStore.setValue(MavenConstants.EXCLUDE_DELETED_ITEMS, true);
|
||||
if (PluginChecker.isTIS()) {
|
||||
preferenceStore.setValue(MavenConstants.EXCLUDE_DELETED_ITEMS, true);
|
||||
}
|
||||
}
|
||||
preferenceManager.save();
|
||||
preferenceManagers.put(projectTechName, preferenceManager);
|
||||
|
||||
@@ -64,7 +64,6 @@ import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.core.runtime.jobs.MultiRule;
|
||||
import org.eclipse.m2e.core.MavenPlugin;
|
||||
import org.eclipse.m2e.core.embedder.MavenModelManager;
|
||||
@@ -73,9 +72,11 @@ import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.runtime.utils.io.IOUtils;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.commons.utils.generation.JavaUtils;
|
||||
import org.talend.commons.utils.io.FilesUtils;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ILibraryManagerService;
|
||||
import org.talend.core.PluginChecker;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
import org.talend.core.model.process.JobInfo;
|
||||
@@ -98,10 +99,12 @@ import org.talend.designer.maven.model.TalendJavaProjectConstants;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.template.MavenTemplateManager;
|
||||
import org.talend.designer.maven.tools.AggregatorPomsHelper;
|
||||
import org.talend.designer.maven.tools.CodeM2CacheManager;
|
||||
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.talend.repository.model.IRepositoryService;
|
||||
import org.talend.utils.xml.XmlUtils;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
@@ -583,7 +586,7 @@ public class PomUtil {
|
||||
IProject fsProject = ResourceUtils.getProject(project);
|
||||
IFolder tmpFolder = fsProject.getFolder("temp");
|
||||
if (!tmpFolder.exists()) {
|
||||
executeFolderAction(monitor, fsProject, new IWorkspaceRunnable() {
|
||||
FilesUtils.executeFolderAction(monitor, fsProject, new IWorkspaceRunnable() {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
@@ -595,7 +598,7 @@ public class PomUtil {
|
||||
createTempFile.delete();
|
||||
String tmpFolderName = createTempFile.getName();
|
||||
IFolder folder = tmpFolder.getFolder(tmpFolderName);
|
||||
executeFolderAction(monitor, tmpFolder, new IWorkspaceRunnable() {
|
||||
FilesUtils.executeFolderAction(monitor, tmpFolder, new IWorkspaceRunnable() {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
@@ -604,7 +607,7 @@ public class PomUtil {
|
||||
});
|
||||
IFile pomFile = folder.getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
|
||||
executeFolderAction(monitor, folder, new IWorkspaceRunnable() {
|
||||
FilesUtils.executeFolderAction(monitor, folder, new IWorkspaceRunnable() {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
@@ -622,35 +625,6 @@ public class PomUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void executeFolderAction(IProgressMonitor monitor, IResource parentFolder, IWorkspaceRunnable run)
|
||||
throws CoreException {
|
||||
if (Job.getJobManager().currentRule() == null) {
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
ISchedulingRule defaultRule = workspace.getRuleFactory().modifyRule(parentFolder);
|
||||
ISchedulingRule noBlockRule = new ISchedulingRule() {
|
||||
|
||||
@Override
|
||||
public boolean isConflicting(ISchedulingRule rule) {
|
||||
return this.contains(rule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(ISchedulingRule rule) {
|
||||
if (this.equals(rule)) {
|
||||
return true;
|
||||
}
|
||||
if (defaultRule.contains(rule)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
workspace.run(run, noBlockRule, IWorkspace.AVOID_UPDATE, monitor);
|
||||
} else {
|
||||
run.run(monitor);
|
||||
}
|
||||
}
|
||||
|
||||
private static Model createModel(MavenArtifact artifact) {
|
||||
Model pomModel = new Model();
|
||||
pomModel.setModelVersion(TalendMavenConstants.POM_VERSION);
|
||||
@@ -1217,4 +1191,49 @@ public class PomUtil {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
public static void checkExistingLog4j2Dependencies4RoutinePom(String projectTechName, IFile pomFile) {
|
||||
if (!PluginChecker.isBigdataRoutineLoaded()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRepositoryService.class)) {
|
||||
Model model = MODEL_MANAGER.readMavenModel(pomFile);
|
||||
IRepositoryService service = GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
boolean isLog4j2 = service.isProjectLevelLog4j2();
|
||||
Map<String, MavenArtifact> GAVMap = service.getLog4j2Modules().stream()
|
||||
.map(m -> MavenUrlHelper.parseMvnUrl(m.getMavenUri()))
|
||||
.collect(Collectors.toMap(MavenArtifact::getArtifactId, MavenArtifact -> MavenArtifact));
|
||||
long existingDependenciesSize = model.getDependencies().stream()
|
||||
.filter(d -> GAVMap.containsKey(d.getArtifactId())
|
||||
&& GAVMap.get(d.getArtifactId()).getGroupId().equals(d.getGroupId())
|
||||
&& GAVMap.get(d.getArtifactId()).getVersion().equals(d.getVersion()))
|
||||
.count();
|
||||
boolean clean = false;
|
||||
// CAUTION
|
||||
// with this fix, project level log4j2 user can use log4j2 api in routine directly in BD project
|
||||
// user should NEVER manually setup log4j2 in routine dependencies
|
||||
// or else routine install cache could always be cleaned
|
||||
if (isLog4j2 && existingDependenciesSize != GAVMap.size()) {
|
||||
// if project level log4j1 -> log4j2
|
||||
// if first time add log4j2 dependencies
|
||||
// if log4j2 upgrade version
|
||||
// then clean cache to add
|
||||
clean = true;
|
||||
} else if (!isLog4j2 && existingDependenciesSize > 0) {
|
||||
// if project level log4j2 -> log4j1
|
||||
// then clean cache to remove
|
||||
clean = true;
|
||||
}
|
||||
if (clean) {
|
||||
File cacheFile = CodeM2CacheManager.getCacheFile(projectTechName, ERepositoryObjectType.ROUTINES);
|
||||
if (cacheFile.exists()) {
|
||||
cacheFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -96,10 +96,14 @@ public final class TalendCodeProjectUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
// because some cases, the project is not opened.
|
||||
if (!codeProject.isOpen()) {
|
||||
// if not opened, will have exception when check nature or such
|
||||
codeProject.open(monitor);
|
||||
try {
|
||||
// because some cases, the project is not opened.
|
||||
if (!codeProject.isOpen()) {
|
||||
// if not opened, will have exception when check nature or such
|
||||
codeProject.open(monitor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return true;
|
||||
}
|
||||
|
||||
codeProject.refreshLocal(IResource.DEPTH_ONE, monitor);
|
||||
|
||||
@@ -44,6 +44,7 @@ Export-Package: org.apache.commons.cli2,
|
||||
org.apache.commons.math3.stat.descriptive;version="3.3.0",
|
||||
org.apache.commons.math3.stat.descriptive.rank;version="3.3.0",
|
||||
org.apache.commons.math3.util;version="3.3.0",
|
||||
org.apache.commons.text,
|
||||
org.apache.commons.text.similarity,
|
||||
org.apache.commons.validator;version="1.5.1",
|
||||
org.apache.commons.validator.routines;version="1.5.1"
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.talend.libraries.jdbc.postgresql</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,7 +0,0 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Postgresql Plug-in
|
||||
Bundle-SymbolicName: org.talend.libraries.jdbc.postgresql
|
||||
Bundle-Version: 7.3.1.qualifier
|
||||
Bundle-Vendor: .Talend SA.
|
||||
Eclipse-BundleShape: dir
|
||||
@@ -1 +0,0 @@
|
||||
jarprocessor.exclude.children=true
|
||||
@@ -1,5 +0,0 @@
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
lib/postgresql-8.4-703.jdbc4.jar,\
|
||||
lib/postgresql-9.4-1201.jdbc41.jar
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,30 +0,0 @@
|
||||
BSD License
|
||||
|
||||
The PostgreSQL JDBC driver is distributed under the BSD license, same as the server. The simplest explanation of the licensing terms is that you can do whatever you want with the product and source code as long as you don't claim you wrote it or sue us. You should give it a read though, it's only half a page.
|
||||
|
||||
Copyright (c) 1997-2008, PostgreSQL Global Development Group
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the PostgreSQL Global Development Group nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.talend.studio</groupId>
|
||||
<artifactId>tcommon-studio-se</artifactId>
|
||||
<version>7.3.1-PATCH</version>
|
||||
<relativePath>../../../</relativePath>
|
||||
</parent>
|
||||
<artifactId>org.talend.libraries.jdbc.postgresql</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
@@ -16,7 +16,10 @@ Require-Bundle: org.eclipse.core.runtime,
|
||||
org.talend.commons.ui,
|
||||
org.talend.core.runtime,
|
||||
org.talend.librariesmanager,
|
||||
org.talend.designer.maven
|
||||
org.talend.designer.maven,
|
||||
org.apache.commons.io,
|
||||
org.eclipse.m2e.core,
|
||||
org.eclipse.m2e.maven.runtime
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: org.talend.librariesmanager.ui,
|
||||
org.talend.librariesmanager.ui.dialogs,
|
||||
|
||||
@@ -117,11 +117,16 @@ ConfigModuleDialog.platfromBtn=Platform
|
||||
ConfigModuleDialog.repositoryBtn=Artifact repository(local m2/nexus)
|
||||
ConfigModuleDialog.installNewBtn=Install a new module
|
||||
ConfigModuleDialog.findExistByNameBtn=Find by name
|
||||
ConfigModuleDialog.findExistByURIBtn=Find by maven URI
|
||||
ConfigModuleDialog.moduleName=Module Name
|
||||
ConfigModuleDialog.shareInfo=The library can't be shared to remote artifact repository if the repository does not allow redeployment, continue to share ?
|
||||
ConfigModuleDialog.moduleName.error=Please input a valid file name !
|
||||
ConfigModuleDialog.jarNotInstalled.error=This jar is not installed in the artifact repository, please install it !
|
||||
|
||||
|
||||
ConfigModuleDialog.searchLocalBtn=Search Local
|
||||
ConfigModuleDialog.searchRemoteBtn=Search Remote
|
||||
ConfigModuleDialog.error.missingName=Please input a module name!
|
||||
ConfigModuleDialog.error.missingModule=Please select a module!
|
||||
ConfigModuleDialog.search.noModules=No modules found for search of: {0} !
|
||||
ConfigModuleDialog.warn.artifactory=User libraries artifact repository can't be connected!
|
||||
|
||||
ImportCustomSettingsAction.title=Import custom settings
|
||||
ImportCustomSettingsAction.warning=Are you sure to overwrite the custom mvn uri settings with the selected file ?
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -55,6 +55,7 @@ import org.talend.core.nexus.TalendLibsServerManager;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
import org.talend.librariesmanager.ui.LibManagerUiPlugin;
|
||||
import org.talend.librariesmanager.ui.i18n.Messages;
|
||||
import org.talend.librariesmanager.utils.ConfigModuleHelper;
|
||||
import org.talend.librariesmanager.utils.ModuleMavenURIUtils;
|
||||
|
||||
/**
|
||||
@@ -399,10 +400,45 @@ public class InstallModuleDialog extends TitleAreaDialog implements ICellEditorD
|
||||
String result = dialog.open();
|
||||
if (result != null) {
|
||||
this.jarPathTxt.setText(result);
|
||||
try {
|
||||
setupMavenURIforInstall();
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean validateInputForInstallPre() {
|
||||
if (!new File(jarPathTxt.getText()).exists()) {
|
||||
setMessage(Messages.getString("InstallModuleDialog.error.jarPath"), IMessageProvider.ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
setMessage(Messages.getString("InstallModuleDialog.message"), IMessageProvider.INFORMATION);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setupMavenURIforInstall() throws Exception {
|
||||
if (validateInputForInstallPre()) {
|
||||
String filePath = jarPathTxt.getText();
|
||||
String detectUri = ConfigModuleHelper.getDetectURI(filePath);
|
||||
|
||||
if (!org.apache.commons.lang3.StringUtils.isEmpty(detectUri)
|
||||
&& !ConfigModuleHelper.isSameUri(this.defaultURIValue, detectUri)) {
|
||||
customUriText.setText(detectUri);
|
||||
useCustomBtn.setSelection(true);
|
||||
customUriText.setEnabled(true);
|
||||
layoutWarningComposite(false, defaultUriTxt.getText());
|
||||
this.detectButton.setEnabled(true);
|
||||
} else {
|
||||
useCustomBtn.setSelection(false);
|
||||
customUriText.setEnabled(false);
|
||||
customUriText.setText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
@@ -0,0 +1,348 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.librariesmanager.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.m2e.core.MavenPlugin;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ILibraryManagerService;
|
||||
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.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.model.ModulesNeededProvider;
|
||||
import org.talend.librariesmanager.nexus.utils.VersionUtil;
|
||||
import org.talend.librariesmanager.ui.LibManagerUiPlugin;
|
||||
|
||||
/*
|
||||
* Created by bhe on Sep 3, 2020
|
||||
*/
|
||||
public class ConfigModuleHelper {
|
||||
|
||||
|
||||
private static final String LOCAL_M2 = MavenPlugin.getMaven().getLocalRepositoryPath();
|
||||
|
||||
private static final Set<String> IGNORED_FILE_EXTS = new HashSet<String>();
|
||||
static {
|
||||
IGNORED_FILE_EXTS.add("repositories");
|
||||
IGNORED_FILE_EXTS.add("lastUpdated");
|
||||
IGNORED_FILE_EXTS.add("sha1");
|
||||
IGNORED_FILE_EXTS.add("md5");
|
||||
IGNORED_FILE_EXTS.add("pom");
|
||||
IGNORED_FILE_EXTS.add("xml");
|
||||
}
|
||||
|
||||
private ConfigModuleHelper() {
|
||||
|
||||
}
|
||||
|
||||
public static List<MavenArtifact> searchRemoteArtifacts(String name) throws Exception {
|
||||
ArtifactRepositoryBean customNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer();
|
||||
IRepositoryArtifactHandler customerRepHandler = RepositoryArtifactHandlerManager.getRepositoryHandler(customNexusServer);
|
||||
if (customerRepHandler != null) {
|
||||
List<MavenArtifact> ret = customerRepHandler.search(name, true);
|
||||
|
||||
return VersionUtil.filterSnapshotArtifacts(ret);
|
||||
}
|
||||
return new ArrayList<MavenArtifact>();
|
||||
}
|
||||
|
||||
public static String[] toArray(List<MavenArtifact> artifacts) {
|
||||
if (artifacts == null || artifacts.isEmpty()) {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
List<String> ret = new ArrayList<String>();
|
||||
for (MavenArtifact art : artifacts) {
|
||||
ret.add(art.getFileName());
|
||||
}
|
||||
return ret.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public static String[] toArrayUnique(String[] arr) {
|
||||
if (arr == null) {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
Set<String> ret = new HashSet<String>();
|
||||
for (String art : arr) {
|
||||
ret.add(art);
|
||||
}
|
||||
return ret.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public static List<MavenArtifact> searchLocalArtifacts(String name) throws Exception {
|
||||
List<MavenArtifact> ret = new ArrayList<MavenArtifact>();
|
||||
File m2Dir = new File(LOCAL_M2);
|
||||
if (m2Dir.exists()) {
|
||||
search(name, m2Dir, ret);
|
||||
}
|
||||
|
||||
return VersionUtil.filterSnapshotArtifacts(ret);
|
||||
|
||||
}
|
||||
|
||||
private static void search(String name, File dir, List<MavenArtifact> ret) throws Exception {
|
||||
File[] fs = dir.listFiles();
|
||||
for (File f : fs) {
|
||||
if (f.isDirectory()) {
|
||||
search(name, f, ret);
|
||||
} else {
|
||||
if (f.isFile() && StringUtils.containsIgnoreCase(FilenameUtils.getName(f.getName()), name)) {
|
||||
|
||||
String ext = FilenameUtils.getExtension(f.getName());
|
||||
if (IGNORED_FILE_EXTS.contains(ext)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String path = f.getPath().substring(LOCAL_M2.length() + 1, f.getPath().length());
|
||||
|
||||
MavenArtifact art = parse(path, ext);
|
||||
if (art != null) {
|
||||
ret.add(art);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static MavenArtifact parse(String path, String ext) {
|
||||
MavenArtifact art = new MavenArtifact();
|
||||
if (path == null || StringUtils.isEmpty(path)) {
|
||||
return null;
|
||||
}
|
||||
String newPath = FilenameUtils.normalize(path, true);
|
||||
String[] segs = newPath.split("/");
|
||||
|
||||
if (segs.length < 4) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String fname = segs[segs.length - 1];
|
||||
String v = segs[segs.length - 2];
|
||||
String a = segs[segs.length - 3];
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
for (int i = 0; i < segs.length - 3; i++) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append(".");
|
||||
}
|
||||
sb.append(segs[i]);
|
||||
}
|
||||
art.setGroupId(sb.toString());
|
||||
art.setArtifactId(a);
|
||||
art.setVersion(v);
|
||||
art.setType(ext);
|
||||
|
||||
String baseName = FilenameUtils.getBaseName(fname);
|
||||
if (!baseName.contains(v)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int endIndex = a.length() + v.length() + 1;
|
||||
if (baseName.length() > endIndex + 1) {
|
||||
String classifier = baseName.substring(endIndex + 1, baseName.length());
|
||||
art.setClassifier(classifier);
|
||||
}
|
||||
|
||||
return art;
|
||||
}
|
||||
|
||||
public static File resolveLocal(String uri) {
|
||||
ILibraryManagerService libManagerService = (ILibraryManagerService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibraryManagerService.class);
|
||||
String jarPathFromMaven = libManagerService.getJarPathFromMaven(uri);
|
||||
if (jarPathFromMaven != null) {
|
||||
File retFile = new File(jarPathFromMaven);
|
||||
if (retFile.exists()) {
|
||||
return retFile;
|
||||
}
|
||||
}
|
||||
|
||||
ModuleStatusProvider.putStatus(uri, ELibraryInstallStatus.NOT_INSTALLED);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getSHA1(File f) {
|
||||
try (InputStream fi = new FileInputStream(f)) {
|
||||
return DigestUtils.shaHex(fi);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void install(File jarFile, String mvnUrl, boolean deploy) throws Exception {
|
||||
LibManagerUiPlugin.getDefault().getLibrariesService().deployLibrary(jarFile.toURL(), mvnUrl, true, deploy);
|
||||
}
|
||||
|
||||
public static boolean canFind(Set<MavenArtifact> artifacts, File jarFile, String mvnUrl) {
|
||||
if (artifacts == null || artifacts.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String jarSha1 = getSHA1(jarFile);
|
||||
MavenArtifact jarArt = MavenUrlHelper.parseMvnUrl(mvnUrl);
|
||||
jarArt.setSha1(jarSha1);
|
||||
|
||||
return canFind(artifacts, jarArt);
|
||||
}
|
||||
|
||||
public static boolean canFind(Set<MavenArtifact> artifacts, MavenArtifact artifact) {
|
||||
if (artifacts == null || artifacts.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (MavenArtifact art : artifacts) {
|
||||
if (StringUtils.equals(art.getGroupId(), artifact.getGroupId())
|
||||
&& StringUtils.equals(art.getArtifactId(), artifact.getArtifactId())
|
||||
&& StringUtils.equals(art.getClassifier(), artifact.getClassifier())
|
||||
&& StringUtils.equals(art.getVersion(), artifact.getVersion())
|
||||
&& StringUtils.equals(art.getType(), artifact.getType())
|
||||
&& StringUtils.equals(art.getSha1(), artifact.getSha1())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<MavenArtifact> searchRemoteArtifacts(String g, String a, String v) throws Exception {
|
||||
ArtifactRepositoryBean customNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer();
|
||||
IRepositoryArtifactHandler customerRepHandler = RepositoryArtifactHandlerManager.getRepositoryHandler(customNexusServer);
|
||||
if (customerRepHandler != null) {
|
||||
List<MavenArtifact> ret = customerRepHandler.search(g, a, v, true, true);
|
||||
|
||||
if (customNexusServer.getType() == ArtifactRepositoryBean.NexusType.NEXUS_2.name()) {
|
||||
// resolve sha1
|
||||
for (MavenArtifact art : ret) {
|
||||
String sha1 = customerRepHandler.resolveRemoteSha1(art, false);
|
||||
if (sha1 != null) {
|
||||
art.setSha1(sha1);
|
||||
}
|
||||
if (StringUtils.isEmpty(art.getSha1())) {
|
||||
sha1 = customerRepHandler.resolveRemoteSha1(art, true);
|
||||
if (sha1 != null) {
|
||||
art.setSha1(sha1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return VersionUtil.filterSnapshotArtifacts(ret);
|
||||
}
|
||||
return new ArrayList<MavenArtifact>();
|
||||
}
|
||||
|
||||
public static void resolveSha1(MavenArtifact art) throws Exception {
|
||||
ArtifactRepositoryBean customNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer();
|
||||
IRepositoryArtifactHandler customerRepHandler = RepositoryArtifactHandlerManager.getRepositoryHandler(customNexusServer);
|
||||
if ((art.getSha1() == null || art.getSha1().trim().isEmpty()) && customerRepHandler != null
|
||||
&& customNexusServer.getType().equals(ArtifactRepositoryBean.NexusType.NEXUS_2.name())) {
|
||||
boolean fromSnapshot = false;
|
||||
if (art.getVersion() != null && art.getVersion().endsWith(MavenUrlHelper.VERSION_SNAPSHOT)) {
|
||||
fromSnapshot = true;
|
||||
}
|
||||
// resolve sha1
|
||||
String sha1 = customerRepHandler.resolveRemoteSha1(art, !fromSnapshot);
|
||||
if (sha1 != null) {
|
||||
art.setSha1(sha1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDetectURI(String jarPath) {
|
||||
String ext = FilenameUtils.getExtension(jarPath);
|
||||
if (ext.equalsIgnoreCase("jar")) {
|
||||
File file = new File(jarPath);
|
||||
try {
|
||||
MavenArtifact art = JarDetector.parse(file);
|
||||
if (art != null) {
|
||||
return MavenUrlHelper.generateMvnUrl(art);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getMavenURI(String jarPath) {
|
||||
String jarName = FilenameUtils.getName(jarPath);
|
||||
ModuleNeeded mod = null;
|
||||
for (ModuleNeeded module : ModulesNeededProvider.getAllManagedModules()) {
|
||||
if (jarName.equals(module.getModuleName())) {
|
||||
mod = module;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mod != null) {
|
||||
return mod.getMavenUri() == null ? "" : mod.getMavenUri();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getGeneratedDefaultURI(String jarPath) {
|
||||
String jarName = FilenameUtils.getName(jarPath);
|
||||
return MavenUrlHelper.generateMvnUrlForJarName(jarName);
|
||||
}
|
||||
|
||||
public static boolean isSameUri(String defaultUri, String detectUri) {
|
||||
detectUri = detectUri.substring(MavenUrlHelper.MVN_PROTOCOL.length());
|
||||
return StringUtils.endsWith(defaultUri, detectUri);
|
||||
}
|
||||
|
||||
public static boolean showRemoteSearch() {
|
||||
ArtifactRepositoryBean customNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer();
|
||||
if (customNexusServer != null) {
|
||||
String repoType = customNexusServer.getType();
|
||||
if (repoType.equals(ArtifactRepositoryBean.NexusType.NEXUS_2.name())
|
||||
|| repoType.equals(ArtifactRepositoryBean.NexusType.NEXUS_3.name())
|
||||
|| repoType.equals(ArtifactRepositoryBean.NexusType.ARTIFACTORY.name())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean notShowConnectionWarning() {
|
||||
try {
|
||||
ArtifactRepositoryBean customNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer();
|
||||
IRepositoryArtifactHandler customerRepHandler = RepositoryArtifactHandlerManager
|
||||
.getRepositoryHandler(customNexusServer);
|
||||
if (customerRepHandler != null) {
|
||||
return customerRepHandler.checkConnection();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
// ignore local
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.librariesmanager.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenConstants;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
import org.talend.utils.xml.XmlUtils;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
/*
|
||||
* Created by bhe on Sep 3, 2020
|
||||
*/
|
||||
public class JarDetector {
|
||||
|
||||
private static final DocumentBuilderFactory docFactory = XmlUtils.getSecureDocumentBuilderFactory(true);
|
||||
|
||||
private JarDetector() {
|
||||
}
|
||||
|
||||
public static MavenArtifact parse(File jarFile) throws Exception {
|
||||
Properties p = new Properties();
|
||||
Document doc = null;
|
||||
try (JarFile jar = new JarFile(jarFile)) {
|
||||
Enumeration<JarEntry> enumEntries = jar.entries();
|
||||
while (enumEntries.hasMoreElements()) {
|
||||
JarEntry file = enumEntries.nextElement();
|
||||
if (!file.isDirectory()) {
|
||||
String fname = file.getName();
|
||||
if (StringUtils.contains(fname, "META-INF") && fname.endsWith("pom.xml")) {
|
||||
try (InputStream fi = jar.getInputStream(file)) {
|
||||
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
||||
Reader reader = new InputStreamReader(fi, "UTF-8");
|
||||
InputSource is = new InputSource(reader);
|
||||
is.setEncoding("UTF-8");
|
||||
doc = docBuilder.parse(is);
|
||||
}
|
||||
}
|
||||
if (StringUtils.contains(fname, "META-INF") && fname.endsWith("pom.properties")) {
|
||||
try (InputStream fi = jar.getInputStream(file)) {
|
||||
p.load(fi);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!p.isEmpty()) {
|
||||
MavenArtifact art = new MavenArtifact();
|
||||
art.setGroupId(p.getProperty("groupId"));
|
||||
art.setArtifactId(p.getProperty("artifactId"));
|
||||
art.setVersion(p.getProperty("version"));
|
||||
art.setType(MavenConstants.TYPE_JAR);
|
||||
return art;
|
||||
}
|
||||
if (doc != null) {
|
||||
PomParser pp = new PomParser(doc);
|
||||
MavenArtifact art = new MavenArtifact();
|
||||
art.setGroupId(pp.getGroupId());
|
||||
art.setArtifactId(pp.getArtifactId());
|
||||
art.setVersion(pp.getVersion());
|
||||
art.setType(pp.getPackaging());
|
||||
return art;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getMavenURL(MavenArtifact art) {
|
||||
if (art == null) {
|
||||
return "";
|
||||
}
|
||||
return String.format("mvn:%s/%s/%s/%s", art.getGroupId(), art.getArtifactId(), art.getVersion(), art.getType());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.oro.text.regex.MalformedPatternException;
|
||||
import org.apache.oro.text.regex.Pattern;
|
||||
import org.apache.oro.text.regex.PatternMatcherInput;
|
||||
@@ -145,8 +146,10 @@ public class ModuleMavenURIUtils {
|
||||
}
|
||||
|
||||
public static void copyDefaultMavenURI(String text) {
|
||||
Clipboard clipBoard = new Clipboard(Display.getCurrent());
|
||||
TextTransfer textTransfer = TextTransfer.getInstance();
|
||||
clipBoard.setContents(new Object[] { text }, new Transfer[] { textTransfer });
|
||||
if (!StringUtils.isEmpty(text)) {
|
||||
Clipboard clipBoard = new Clipboard(Display.getCurrent());
|
||||
TextTransfer textTransfer = TextTransfer.getInstance();
|
||||
clipBoard.setContents(new Object[] { text }, new Transfer[] { textTransfer });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.librariesmanager.utils;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
/*
|
||||
* Created by bhe on Mar 8, 2020
|
||||
*/
|
||||
public class PomParser {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(PomParser.class.getCanonicalName());
|
||||
|
||||
private final Document doc;
|
||||
|
||||
public PomParser(Document doc) {
|
||||
this.doc = doc;
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
String val = "";
|
||||
if (this.doc != null) {
|
||||
XPath path = XPathFactory.newInstance().newXPath();
|
||||
try {
|
||||
String name = path.evaluate("/project/groupId", this.doc);
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
name = path.evaluate("/project/parent/groupId", this.doc);
|
||||
}
|
||||
if (!StringUtils.isEmpty(name)) {
|
||||
val = name;
|
||||
}
|
||||
} catch (XPathExpressionException e) {
|
||||
LOGGER.log(Level.SEVERE, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public String getArtifactId() {
|
||||
String val = "";
|
||||
if (this.doc != null) {
|
||||
XPath path = XPathFactory.newInstance().newXPath();
|
||||
try {
|
||||
String name = path.evaluate("/project/artifactId", this.doc);
|
||||
if (!StringUtils.isEmpty(name)) {
|
||||
val = name;
|
||||
}
|
||||
} catch (XPathExpressionException e) {
|
||||
LOGGER.log(Level.SEVERE, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
String val = "";
|
||||
if (this.doc != null) {
|
||||
XPath path = XPathFactory.newInstance().newXPath();
|
||||
try {
|
||||
String name = path.evaluate("/project/version", this.doc);
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
name = path.evaluate("/project/parent/version", this.doc);
|
||||
}
|
||||
if (!StringUtils.isEmpty(name)) {
|
||||
val = name;
|
||||
}
|
||||
} catch (XPathExpressionException e) {
|
||||
LOGGER.log(Level.SEVERE, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public String getPackaging() {
|
||||
String val = "";
|
||||
if (this.doc != null) {
|
||||
XPath path = XPathFactory.newInstance().newXPath();
|
||||
try {
|
||||
String name = path.evaluate("/project/packaging", this.doc);
|
||||
if (!StringUtils.isEmpty(name)) {
|
||||
val = name;
|
||||
}
|
||||
} catch (XPathExpressionException e) {
|
||||
LOGGER.log(Level.SEVERE, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (val.isEmpty() || val.equals("bundle")) {
|
||||
val = "jar";
|
||||
}
|
||||
return val;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,4 @@ bin.includes = META-INF/,\
|
||||
plugin.properties,\
|
||||
model/,\
|
||||
templates/,\
|
||||
distribution/license.json,\
|
||||
lib/crypto-utils.jar,\
|
||||
lib/slf4j-api-1.7.25.jar
|
||||
distribution/license.json
|
||||
|
||||
@@ -31,6 +31,23 @@
|
||||
type="librariesindex"
|
||||
class="org.talend.librariesmanager.emf.librariesindex.util.LibrariesindexResourceFactoryImpl"/>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.talend.core.runtime.librariesNeeded">
|
||||
<libraryNeeded
|
||||
context="plugin:org.talend.librariesmanager"
|
||||
id="slf4j-api-1.7.25.jar"
|
||||
mvn_uri="mvn:org.slf4j/slf4j-api/1.7.25"
|
||||
name="slf4j-api-1.7.25.jar"
|
||||
required="true">
|
||||
</libraryNeeded>
|
||||
<libraryNeeded
|
||||
context="plugin:org.talend.librariesmanager"
|
||||
id="crypto-utils-0.31.10.jar"
|
||||
mvn_uri="mvn:org.talend.daikon/crypto-utils/0.31.10"
|
||||
name="crypto-utils-0.31.10.jar"
|
||||
required="true">
|
||||
</libraryNeeded>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.talend.core.systemRoutineLibrary">
|
||||
<systemRoutine
|
||||
@@ -42,7 +59,7 @@
|
||||
<systemRoutine
|
||||
name="PasswordEncryptUtil">
|
||||
<library
|
||||
name="crypto-utils.jar">
|
||||
name="crypto-utils-0.31.10.jar">
|
||||
</library>
|
||||
</systemRoutine>
|
||||
</extension>
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
package routines.system;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class BundleUtils {
|
||||
|
||||
@@ -75,6 +78,31 @@ public final class BundleUtils {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> Map<String, T> getServices(List<?> serviceReferences, Class<T> serviceClass ) {
|
||||
|
||||
Map<String, T> services = new HashMap<String, T>();
|
||||
|
||||
if (BUNDLE == null || SERVICE_REFERENCE_CLASS == null ) {
|
||||
return services;
|
||||
}
|
||||
|
||||
try {
|
||||
for (Object serviceRef : serviceReferences) {
|
||||
Object serviceId = serviceRef.getClass().getMethod("getProperty",
|
||||
java.lang.String.class).invoke(serviceRef, "osgi.jndi.service.name");
|
||||
Method getBundleContext = BUNDLE.getClass().getMethod("getBundleContext");
|
||||
Object context = getBundleContext.invoke(BUNDLE);
|
||||
Class<?> ctxClass = context.getClass();
|
||||
Method getService = ctxClass.getMethod("getService", SERVICE_REFERENCE_CLASS);
|
||||
services.put(serviceId.toString(), serviceClass.cast(getService.invoke(context, serviceRef)));
|
||||
}
|
||||
return services;
|
||||
} catch (Exception e) {
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean inOSGi() {
|
||||
return BUNDLE != null;
|
||||
|
||||
@@ -21,14 +21,10 @@
|
||||
// ============================================================================
|
||||
package routines.system;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.RuntimeMXBean;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
//TODO split to several classes by the level when have a clear requirement or design : job, component, connection
|
||||
public class JobStructureCatcherUtils {
|
||||
@@ -193,6 +189,8 @@ public class JobStructureCatcherUtils {
|
||||
|
||||
public void addCM(String component_id, String component_label, String component_name) {
|
||||
JobStructureCatcherMessage scm = new JobStructureCatcherMessage();
|
||||
scm.moment = sdf.format(new Date());
|
||||
|
||||
scm.job_name = this.job_name;
|
||||
scm.job_id = this.job_id;
|
||||
scm.job_version = this.job_version;
|
||||
|
||||
@@ -41,6 +41,7 @@ public class LocaleProvider {
|
||||
|
||||
}
|
||||
|
||||
//though not thread safe here, but we syn in the client side, so ok
|
||||
public static Locale getLocale(String languageOrCountyCode) {
|
||||
if (cache == null) {
|
||||
initCache();
|
||||
@@ -72,7 +73,11 @@ public class LocaleProvider {
|
||||
key = language;
|
||||
}
|
||||
if (key != null) {
|
||||
cache.put(key.toLowerCase(), locale);
|
||||
String k = key.toLowerCase();
|
||||
Locale old = cache.put(k, locale);
|
||||
if(old != null && old.getCountry() !=null && old.getCountry().equalsIgnoreCase(old.getLanguage())) {
|
||||
cache.put(k, old);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,9 +72,6 @@ public class ResumeUtil {
|
||||
if (sharedWriter == null) {
|
||||
this.csvWriter = new SimpleCsvWriter(new FileWriter(logFileName, createNewFile));
|
||||
|
||||
// shared
|
||||
sharedWriterMap.put(this.root_pid, this.csvWriter);
|
||||
|
||||
// output the header part
|
||||
if (file.length() == 0) {
|
||||
if (genDynamicPart) {
|
||||
@@ -100,7 +97,12 @@ public class ResumeUtil {
|
||||
csvWriter.write("dynamicData");// dynamicData
|
||||
csvWriter.endRecord();
|
||||
csvWriter.flush();
|
||||
csvWriter.close();
|
||||
// To avoid use File.delete() as it cannot make sure file being deleted.
|
||||
this.csvWriter = new SimpleCsvWriter(new FileWriter(logFileName, true));
|
||||
}
|
||||
// shared
|
||||
sharedWriterMap.put(this.root_pid, this.csvWriter);
|
||||
} else {
|
||||
csvWriter = sharedWriter;
|
||||
}
|
||||
|
||||
@@ -220,9 +220,16 @@ public class ModulesNeededProvider {
|
||||
|
||||
Set<ModuleNeeded> modulesNeeded = getModulesNeeded();
|
||||
for (ModuleNeeded moduleNeeded : modulesNeeded) {
|
||||
if (id.equals(moduleNeeded.getId())) {
|
||||
result = moduleNeeded;
|
||||
break;
|
||||
if (id.startsWith(MavenUrlHelper.MVN_PROTOCOL)) {
|
||||
if (id.equals(moduleNeeded.getMavenUri())) {
|
||||
result = moduleNeeded;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (id.equals(moduleNeeded.getId())) {
|
||||
result = moduleNeeded;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,25 +13,37 @@
|
||||
package org.talend.librariesmanager.model.service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Set;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.LoginException;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.utils.io.FilesUtils;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.RepositoryWorkUnit;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.model.RepositoryConstants;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
/**
|
||||
* created by wchen on Aug 18, 2017 Detailled comment
|
||||
@@ -43,15 +55,13 @@ public class CustomUriManager {
|
||||
|
||||
private static CustomUriManager manager = new CustomUriManager();;
|
||||
|
||||
private static final String CUSTOM_URI_MAP = "custom_uri_mapping.json";
|
||||
|
||||
private static long lastModified = 0;
|
||||
|
||||
private static boolean isNeedReload = false;
|
||||
|
||||
private final Object reloadingLock = new Object();
|
||||
|
||||
private CustomUriManager() {
|
||||
try {
|
||||
customURIObject = loadResources(getResourcePath(), CUSTOM_URI_MAP);
|
||||
customURIObject = loadResources(getResourcePath(), RepositoryConstants.PROJECT_SETTINGS_CUSTOM_URI_MAP);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
@@ -61,34 +71,121 @@ public class CustomUriManager {
|
||||
return manager;
|
||||
}
|
||||
|
||||
private synchronized JSONObject loadResources(String path, String fileName) throws IOException {
|
||||
BufferedReader br = null;
|
||||
private JSONObject loadResources(String path, String fileName) throws IOException {
|
||||
JSONObject jsonObj = new JSONObject();
|
||||
InputStream in = null;
|
||||
try {
|
||||
File file = new File(path, fileName);
|
||||
if (file.exists()) {
|
||||
br = new BufferedReader(new FileReader(file));
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
String line = null;
|
||||
while ((line = br.readLine()) != null) {
|
||||
buffer.append(line);
|
||||
}
|
||||
jsonObj = JSONObject.fromObject(buffer.toString());
|
||||
jsonObj = loadResources(new FileInputStream(file), fileName);
|
||||
}
|
||||
} finally {
|
||||
if (br != null) {
|
||||
br.close();
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return jsonObj;
|
||||
}
|
||||
|
||||
private JSONObject loadResources(IFolder path, String fileName) throws CoreException, IOException {
|
||||
JSONObject jsonObj = new JSONObject();
|
||||
InputStream in = null;
|
||||
try {
|
||||
IFile file = path.getFile(fileName);
|
||||
FilesUtils.executeFolderAction(new NullProgressMonitor(), path, new IWorkspaceRunnable() {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
file.refreshLocal(IResource.DEPTH_ZERO, monitor);
|
||||
}
|
||||
});
|
||||
if (file.isAccessible()) {
|
||||
in = file.getContents(true);
|
||||
return loadResources(in, fileName);
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return jsonObj;
|
||||
}
|
||||
|
||||
private JSONObject loadResources(InputStream in, String fileName) throws IOException {
|
||||
BufferedReader br = null;
|
||||
JSONObject jsonObj = new JSONObject();
|
||||
try {
|
||||
br = new BufferedReader(new InputStreamReader(in));
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
String line = null;
|
||||
while ((line = br.readLine()) != null) {
|
||||
buffer.append(line);
|
||||
}
|
||||
jsonObj = JSONObject.fromObject(buffer.toString());
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return jsonObj;
|
||||
}
|
||||
|
||||
private void saveResource(JSONObject customMap, IFolder filePath, String fileName, boolean isExport) {
|
||||
ByteArrayOutputStream out = null;
|
||||
ByteArrayInputStream in = null;
|
||||
try {
|
||||
IFile file = filePath.getFile(fileName);
|
||||
out = new ByteArrayOutputStream();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.writerWithDefaultPrettyPrinter().writeValue(out, customMap);
|
||||
in = new ByteArrayInputStream(out.toByteArray());
|
||||
final InputStream fin = in;
|
||||
FilesUtils.executeFolderAction(new NullProgressMonitor(), file.getParent(), new IWorkspaceRunnable() {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
file.refreshLocal(IResource.DEPTH_ZERO, monitor);
|
||||
if (!file.exists()) {
|
||||
file.create(fin, false, monitor);
|
||||
} else {
|
||||
file.setContents(fin, true, false, monitor);
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
} finally {
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException ex) {
|
||||
// ExceptionHandler.process(ex);
|
||||
}
|
||||
}
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException ex) {
|
||||
// ExceptionHandler.process(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveResource(JSONObject customMap, String filePath, String fileName, boolean isExport) {
|
||||
try {
|
||||
File file = new File(filePath, fileName);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.writerWithDefaultPrettyPrinter().writeValue(file, customMap);
|
||||
lastModified = file.lastModified();
|
||||
} catch (IOException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
@@ -100,7 +197,7 @@ public class CustomUriManager {
|
||||
|
||||
@Override
|
||||
public void run() throws PersistenceException, LoginException {
|
||||
saveResource(customURIObject, getResourcePath(), CUSTOM_URI_MAP, false);
|
||||
saveResource(customURIObject, getResourcePath(), RepositoryConstants.PROJECT_SETTINGS_CUSTOM_URI_MAP, false);
|
||||
}
|
||||
};
|
||||
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
@@ -111,12 +208,11 @@ public class CustomUriManager {
|
||||
|
||||
}
|
||||
|
||||
private String getResourcePath() {
|
||||
private IFolder getResourcePath() {
|
||||
try {
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
IProject project = ResourceUtils.getProject(currentProject);
|
||||
IFolder settingsFolder = project.getFolder(".settings");
|
||||
return settingsFolder.getLocation().toPortableString();
|
||||
return project.getFolder(".settings");
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
@@ -124,7 +220,11 @@ public class CustomUriManager {
|
||||
}
|
||||
|
||||
public void put(String key, String value) {
|
||||
reloadCustomMapping();
|
||||
try {
|
||||
reloadCustomMapping();
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
if (value != null) {
|
||||
customURIObject.put(key, value);
|
||||
} else {
|
||||
@@ -133,7 +233,11 @@ public class CustomUriManager {
|
||||
}
|
||||
|
||||
public String get(String key) {
|
||||
reloadCustomMapping();
|
||||
try {
|
||||
reloadCustomMapping();
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
if (customURIObject.containsKey(key)) {
|
||||
return customURIObject.getString(key);
|
||||
}
|
||||
@@ -159,16 +263,18 @@ public class CustomUriManager {
|
||||
|
||||
public void reloadCustomMapping() {
|
||||
try {
|
||||
File file = new File(getResourcePath(), CUSTOM_URI_MAP);
|
||||
long modifyDate = file.lastModified();
|
||||
if (isNeedReload || modifyDate > lastModified) {
|
||||
customURIObject.clear();
|
||||
JSONObject loadResources = loadResources(getResourcePath(), CUSTOM_URI_MAP);
|
||||
customURIObject.putAll(loadResources);
|
||||
lastModified = modifyDate;
|
||||
isNeedReload = false;
|
||||
if (isNeedReload) {
|
||||
synchronized (reloadingLock) {
|
||||
if (isNeedReload) {
|
||||
customURIObject.clear();
|
||||
JSONObject loadResources = loadResources(getResourcePath(),
|
||||
RepositoryConstants.PROJECT_SETTINGS_CUSTOM_URI_MAP);
|
||||
customURIObject.putAll(loadResources);
|
||||
isNeedReload = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -912,7 +912,13 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
fileToDeploy = null;
|
||||
found = false;
|
||||
}
|
||||
if (!found) {
|
||||
boolean isCIMode = false;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
IRunProcessService runProcessService = GlobalServiceRegister.getDefault()
|
||||
.getService(IRunProcessService.class);
|
||||
isCIMode = runProcessService.isCIMode();
|
||||
}
|
||||
if (!found && !isCIMode) {
|
||||
ExceptionHandler.log("missing jar:" + module.getModuleName());
|
||||
}
|
||||
if (fileToDeploy != null) {
|
||||
@@ -1309,8 +1315,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
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)) {
|
||||
if (!isExtComponentProvider(id)) {
|
||||
File file = new File(providerInfo.getLocation());
|
||||
List<File> jarFiles = FilesUtils.getJarFilesFromFolder(file, null, "ext");
|
||||
if (jarFiles.size() > 0) {
|
||||
@@ -1342,40 +1347,48 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isExtComponentProvider(String id) {
|
||||
if ("org.talend.designer.components.model.UserComponentsProvider".equals(id)
|
||||
|| "org.talend.designer.codegen.components.model.SharedStudioUserComponentProvider".equals(id)
|
||||
|| "org.talend.designer.components.exchange.ExchangeComponentsProvider".equals(id)
|
||||
|| "org.talend.designer.components.exchange.SharedStudioExchangeComponentsProvider".equals(id)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void deployLibsFromCustomComponents(IComponentsService service, Map<String, String> platformURLMap) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
private void deployLibsFromCustomComponents(IComponentsService service, Map<String, String> platformURLMap) {
|
||||
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 (isExtComponentProvider(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;
|
||||
}
|
||||
}
|
||||
|
||||
// deploy needed jars for User and Exchange component providers
|
||||
Map<String, List<MavenArtifact>> snapshotArtifactMap = new HashMap<String, List<MavenArtifact>>();
|
||||
@@ -1386,23 +1399,25 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
ArtifactRepositoryBean customNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer();
|
||||
IRepositoryArtifactHandler customerRepHandler = RepositoryArtifactHandlerManager
|
||||
.getRepositoryHandler(customNexusServer);
|
||||
List<MavenArtifact> snapshotResult = new ArrayList<>();
|
||||
List<MavenArtifact> releaseResult = 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);
|
||||
if (customerRepHandler != null) {
|
||||
List<MavenArtifact> snapshotResult = new ArrayList<>();
|
||||
List<MavenArtifact> releaseResult = 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);
|
||||
releaseResult = customerRepHandler.search(MavenConstants.DEFAULT_LIB_GROUP_ID, null, null, true, false);
|
||||
if (releaseResult != null) {
|
||||
for (MavenArtifact result : releaseResult) {
|
||||
ShareLibrariesUtil.putArtifactToMap(result, releaseArtifactMap, false);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
for(File exsitFile:needToDeploy) {
|
||||
if (customerRepHandler != null) {
|
||||
|
||||
@@ -41,6 +41,7 @@ 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.i18n.Messages;
|
||||
import org.talend.librariesmanager.nexus.utils.ShareLibrariesUtil;
|
||||
import org.talend.utils.sugars.TypedReturnCode;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
@@ -54,6 +55,7 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
|
||||
|
||||
private String SEARCH_SERVICE = "api/search/gavc?"; //$NON-NLS-1$
|
||||
|
||||
private static final String SEARCH_NAME = "api/search/artifact?";
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -258,6 +260,106 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
|
||||
artifact.setVersion(v);
|
||||
artifact.setType(type);
|
||||
artifact.setLastUpdated(lastUpdated);
|
||||
String regex = a + "-" + v;
|
||||
String classifier = ShareLibrariesUtil.getMavenClassifier(artifactPath, regex, type);
|
||||
artifact.setClassifier(classifier);
|
||||
fillChecksumData(jsonObject, artifact);
|
||||
resultList.add(artifact);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
protected List<MavenArtifact> doSearch(String query, String apiPath, boolean fromRelease, boolean fromSnapshot)
|
||||
throws Exception {
|
||||
String q = query;
|
||||
if (q == null || q.trim().isEmpty()) {
|
||||
q = "";
|
||||
}
|
||||
String serverUrl = serverBean.getServer();
|
||||
if (!serverUrl.endsWith("/")) { //$NON-NLS-1$
|
||||
serverUrl = serverUrl + "/"; //$NON-NLS-1$
|
||||
}
|
||||
String searchUrl = serverUrl + apiPath;
|
||||
|
||||
String repositoryId = ""; //$NON-NLS-1$
|
||||
if (fromRelease) {
|
||||
repositoryId = serverBean.getRepositoryId();
|
||||
}
|
||||
if (fromSnapshot) {
|
||||
if ("".equals(repositoryId)) { //$NON-NLS-1$
|
||||
repositoryId = serverBean.getSnapshotRepId();
|
||||
} else {
|
||||
repositoryId = repositoryId + "," + serverBean.getSnapshotRepId(); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
if (!"".equals(repositoryId)) { //$NON-NLS-1$
|
||||
if (!q.isEmpty()) {
|
||||
q += "&";
|
||||
}
|
||||
q += "repos=" + repositoryId;//$NON-NLS-1$
|
||||
}
|
||||
|
||||
searchUrl = searchUrl + q;
|
||||
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$
|
||||
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();
|
||||
String content = EntityUtils.toString(response.getEntity());
|
||||
if (content.isEmpty()) {
|
||||
return resultList;
|
||||
}
|
||||
JSONObject responseObject = JSONObject.fromObject(content);
|
||||
String resultStr = responseObject.getString("results"); //$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);
|
||||
String lastUpdated = jsonObject.getString("lastUpdated"); //$NON-NLS-1$
|
||||
String artifactPath = jsonObject.getString("path"); //$NON-NLS-1$
|
||||
String[] split = artifactPath.split("/"); //$NON-NLS-1$
|
||||
if (split.length > 4) {
|
||||
String fileName = split[split.length - 1];
|
||||
if (!fileName.endsWith("pom")) { //$NON-NLS-1$
|
||||
String type = null;
|
||||
int dotIndex = fileName.lastIndexOf('.');
|
||||
if (dotIndex > 0) {
|
||||
type = fileName.substring(dotIndex + 1);
|
||||
}
|
||||
if (type != null) {
|
||||
MavenArtifact artifact = new MavenArtifact();
|
||||
String g = ""; //$NON-NLS-1$
|
||||
String a = split[split.length - 3];
|
||||
String v = split[split.length - 2];
|
||||
for (int j = 1; j < split.length - 3; j++) {
|
||||
if ("".equals(g)) { //$NON-NLS-1$
|
||||
g = split[j];
|
||||
} else {
|
||||
g = g + "." + split[j]; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
artifact.setGroupId(g);
|
||||
artifact.setArtifactId(a);
|
||||
artifact.setVersion(v);
|
||||
artifact.setType(type);
|
||||
artifact.setLastUpdated(lastUpdated);
|
||||
String regex = a + "-" + v;
|
||||
String classifier = ShareLibrariesUtil.getMavenClassifier(artifactPath, regex, type);
|
||||
artifact.setClassifier(classifier);
|
||||
fillChecksumData(jsonObject, artifact);
|
||||
resultList.add(artifact);
|
||||
}
|
||||
@@ -386,4 +488,9 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
|
||||
return rc;
|
||||
}
|
||||
|
||||
public List<MavenArtifact> search(String name, boolean fromSnapshot) throws Exception {
|
||||
String query = "name=" + name;
|
||||
return doSearch(query, SEARCH_NAME, true, fromSnapshot);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -185,4 +185,17 @@ public class Nexus2RepositoryHandler extends AbstractArtifactRepositoryHandler {
|
||||
artifact.getArtifactId(), artifact.getVersion(), artifact.getType());
|
||||
}
|
||||
|
||||
public List<MavenArtifact> search(String name, boolean fromSnapshot) throws Exception {
|
||||
List<MavenArtifact> results = new ArrayList<MavenArtifact>();
|
||||
if (serverBean.getRepositoryId() != null) {
|
||||
results.addAll(NexusServerUtils.search(serverBean.getServer(), serverBean.getUserName(), serverBean.getPassword(),
|
||||
serverBean.getRepositoryId(), name));
|
||||
}
|
||||
if (fromSnapshot && serverBean.getSnapshotRepId() != null) {
|
||||
results.addAll(NexusServerUtils.search(serverBean.getServer(), serverBean.getUserName(), serverBean.getPassword(),
|
||||
serverBean.getSnapshotRepId(), name));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,8 +59,6 @@ public class Nexus3RepositoryHandler extends AbstractArtifactRepositoryHandler {
|
||||
|
||||
private static final ConcurrentHashMap<ArtifactRepositoryBean, INexus3SearchHandler> LAST_HANDLER_MAP = new ConcurrentHashMap<ArtifactRepositoryBean, INexus3SearchHandler>();
|
||||
|
||||
private static List<INexus3SearchHandler> queryHandlerList = new ArrayList<INexus3SearchHandler>();
|
||||
|
||||
@Override
|
||||
public IRepositoryArtifactHandler clone() {
|
||||
return new Nexus3RepositoryHandler();
|
||||
@@ -160,7 +158,7 @@ public class Nexus3RepositoryHandler extends AbstractArtifactRepositoryHandler {
|
||||
try {
|
||||
result = currentQueryHandler.search(repositoryId, groupIdToSearch, artifactId, versionToSearch);
|
||||
} catch (Exception ex) {
|
||||
for (int i = 0; i < queryHandlerList.size(); i++) {// Try to other version
|
||||
for (int i = 0; i < 3; i++) {// Try to other version
|
||||
INexus3SearchHandler handler = createQueryHandler(i);
|
||||
if (handler != currentQueryHandler) {
|
||||
try {
|
||||
@@ -287,4 +285,42 @@ public class Nexus3RepositoryHandler extends AbstractArtifactRepositoryHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public List<MavenArtifact> search(String name, boolean fromSnapshot) throws Exception {
|
||||
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
|
||||
resultList.addAll(doSearch(serverBean.getRepositoryId(), name));
|
||||
if (fromSnapshot) {
|
||||
resultList.addAll(doSearch(serverBean.getSnapshotRepId(), name));
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
private List<MavenArtifact> doSearch(String repositoryId, String name) throws Exception {
|
||||
INexus3SearchHandler currentQueryHandler = currentQueryHandlerCopy.get();
|
||||
if (currentQueryHandler == null) {
|
||||
currentQueryHandler = createQueryHandler(0);
|
||||
}
|
||||
List<MavenArtifact> result = new ArrayList<MavenArtifact>();
|
||||
try {
|
||||
result = currentQueryHandler.search(repositoryId, name);
|
||||
} 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, name);
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
currentQueryHandlerCopy.set(currentQueryHandler);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,13 +30,17 @@ 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.nexus.NexusServerUtils;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.librariesmanager.nexus.utils.ShareLibrariesUtil;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -126,41 +130,54 @@ public abstract class AbsNexus3SearchHandler implements INexus3SearchHandler {
|
||||
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));
|
||||
fillCheckSumData(assertsArray, artifact);
|
||||
resultList.add(artifact);
|
||||
String repository = jsonObject.getString("repository");//$NON-NLS-1$
|
||||
String group = jsonObject.getString("group");//$NON-NLS-1$
|
||||
String name = jsonObject.getString("name");//$NON-NLS-1$
|
||||
String version = jsonObject.getString("version");//$NON-NLS-1$
|
||||
JSONArray assertsArray = jsonObject.getJSONArray("assets");//$NON-NLS-1$
|
||||
|
||||
if (assertsArray != null) {
|
||||
for (int j = 0; j < assertsArray.size(); j++) {
|
||||
JSONObject assertsObject = assertsArray.getJSONObject(j);
|
||||
String packageType = getPackageType(assertsObject);
|
||||
if (packageType != null) {
|
||||
MavenArtifact artifact = new MavenArtifact();
|
||||
String path = assertsObject.getString("path"); //$NON-NLS-1$
|
||||
String regex = name + "-" + version;
|
||||
String classifier = ShareLibrariesUtil.getMavenClassifier(path, regex, packageType);
|
||||
artifact.setGroupId(group);
|
||||
artifact.setArtifactId(name);
|
||||
artifact.setVersion(version);
|
||||
artifact.setType(packageType);
|
||||
artifact.setClassifier(classifier);
|
||||
if (artifact.getType() != null) {
|
||||
fillCheckSumData(assertsArray, artifact);
|
||||
resultList.add(artifact);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return continuationToken;
|
||||
}
|
||||
|
||||
protected String getPackageType(JSONArray assertsArray) {
|
||||
protected String getPackageType(JSONObject jsonObject) {
|
||||
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$
|
||||
}
|
||||
}
|
||||
|
||||
String path = jsonObject.getString("path"); //$NON-NLS-1$
|
||||
int idx = path.lastIndexOf('.');
|
||||
if (idx > -1) {
|
||||
type = path.substring(idx + 1);
|
||||
}
|
||||
return type;
|
||||
if (!NexusServerUtils.IGNORED_TYPES.contains(type)) {
|
||||
return type;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void fillCheckSumData(JSONArray assertsArray, MavenArtifact artifact) {
|
||||
@@ -242,4 +259,20 @@ public abstract class AbsNexus3SearchHandler implements INexus3SearchHandler {
|
||||
}
|
||||
return socketTimeout;
|
||||
}
|
||||
|
||||
public List<MavenArtifact> search(String repositoryId, String name) throws Exception {
|
||||
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
|
||||
String searchUrl = getSearchUrl();
|
||||
String continuationToken = null;
|
||||
while (true) {
|
||||
String query = getQueryParameter(repositoryId, null, null, null, continuationToken);
|
||||
query += "&name=*" + name + "*";
|
||||
String content = doRequest(searchUrl + query);
|
||||
continuationToken = parseResult(content, resultList);
|
||||
if (continuationToken == null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,4 +23,5 @@ public interface INexus3SearchHandler {
|
||||
|
||||
public String getHandlerVersion();
|
||||
|
||||
public List<MavenArtifact> search(String repositoryId, String name) throws Exception;
|
||||
}
|
||||
|
||||
@@ -123,4 +123,17 @@ public class ShareLibrariesUtil {
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String getMavenClassifier(String path, String regex, String packageType) {
|
||||
String classifier = null;
|
||||
// javax/xml/bind/acxb-test/2.2.6/acxb-test-2.2.6-jdk10.dll
|
||||
path = StringUtils.removeEnd(path, "." + packageType);
|
||||
// javax/xml/bind/acxb-test/2.2.6/acxb-test-2.2.6-jdk10
|
||||
path = StringUtils.substringAfter(path, regex);// -jdk10
|
||||
path = StringUtils.stripStart(path, "-");// jdk10
|
||||
if (StringUtils.isNotBlank(path)) {
|
||||
classifier = path;
|
||||
}
|
||||
return classifier;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,14 @@
|
||||
// ============================================================================
|
||||
package org.talend.librariesmanager.nexus.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
|
||||
/**
|
||||
@@ -20,13 +28,60 @@ import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
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;
|
||||
return MavenUrlHelper.getSNAPSHOTVersion(rVersion);
|
||||
}
|
||||
|
||||
public static List<MavenArtifact> filterSnapshotArtifacts(List<MavenArtifact> arts) {
|
||||
List<MavenArtifact> ret = new ArrayList<MavenArtifact>();
|
||||
if (arts == null || arts.isEmpty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
Map<String, List<MavenArtifact>> snapshotArtifacts = new HashMap<String, List<MavenArtifact>>();
|
||||
|
||||
for (MavenArtifact art : arts) {
|
||||
if (isSnapshot(art.getVersion())) {
|
||||
String v = art.getVersion().split("-")[0];
|
||||
String key = art.getGroupId() + ":" + art.getArtifactId() + ":" + v;
|
||||
if (art.getType() != null) {
|
||||
key = key + ":" + art.getType();
|
||||
}
|
||||
if (art.getClassifier() != null) {
|
||||
key = key + ":" + art.getClassifier();
|
||||
}
|
||||
List<MavenArtifact> groupArts = null;
|
||||
if (snapshotArtifacts.containsKey(key)) {
|
||||
groupArts = snapshotArtifacts.get(key);
|
||||
} else {
|
||||
groupArts = new ArrayList<MavenArtifact>();
|
||||
snapshotArtifacts.put(key, groupArts);
|
||||
}
|
||||
groupArts.add(art);
|
||||
} else {
|
||||
ret.add(art);
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, List<MavenArtifact>>> entries = snapshotArtifacts.entrySet();
|
||||
for (Entry<String, List<MavenArtifact>> entry : entries) {
|
||||
if (!entry.getValue().isEmpty()) {
|
||||
MavenArtifact art = entry.getValue().get(0);
|
||||
if (art != null) {
|
||||
art.setVersion(MavenUrlHelper.getSNAPSHOTVersion(art.getVersion()));
|
||||
ret.add(art);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static boolean isSnapshot(String v) {
|
||||
if (v != null && (v.contains("-") || v.toUpperCase().endsWith(MavenUrlHelper.VERSION_SNAPSHOT))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -703,7 +703,7 @@ public final class ConnectionContextHelper {
|
||||
Set<String> addedVars = tempVars;
|
||||
|
||||
if (addedVars != null && !addedVars.isEmpty()
|
||||
&& (isGeneric || !isAddContextVar(contextItem, process.getContextManager(), neededVars))) {
|
||||
&& (isGeneric || !isAddContextVar(contextItem, process.getContextManager(), neededVars, true))) {
|
||||
AtomicBoolean added = new AtomicBoolean();
|
||||
if (ignoreContextMode) {
|
||||
addContextVarForJob(process, contextItem, addedVars);
|
||||
@@ -1591,7 +1591,13 @@ public final class ConnectionContextHelper {
|
||||
}
|
||||
|
||||
public static boolean isAddContextVar(ContextItem contextItem, IContextManager contextManager, Set<String> neededVars) {
|
||||
return isAddContextVar(contextItem, contextManager, neededVars, false);
|
||||
}
|
||||
|
||||
public static boolean isAddContextVar(ContextItem contextItem, IContextManager contextManager, Set<String> neededVars,
|
||||
boolean checkByDefault) {
|
||||
boolean isAdd = true;
|
||||
boolean foundGroup = false;
|
||||
Set<String> addedVars = new HashSet<String>();
|
||||
for (IContext context : contextManager.getListContext()) {
|
||||
ContextType contextType = null;
|
||||
@@ -1599,6 +1605,7 @@ public final class ConnectionContextHelper {
|
||||
for (ContextType contye : contextTypeList) {
|
||||
if (context.getName() != null && contye.getName().toLowerCase().equals(context.getName().toLowerCase())) {
|
||||
contextType = contye;
|
||||
foundGroup = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1615,6 +1622,26 @@ public final class ConnectionContextHelper {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if not found might different groups, check from default context if duplicate var
|
||||
if (checkByDefault && !foundGroup) {
|
||||
IContext jobDefaultContext = contextManager.getDefaultContext();
|
||||
String itemDefaultContextName = contextItem.getDefaultContext();
|
||||
List<ContextType> contextTypeList = contextItem.getContext();
|
||||
ContextType itemDefaultContext = ContextUtils.getContextTypeByName(contextTypeList, itemDefaultContextName);
|
||||
if (itemDefaultContext != null) {
|
||||
for (String var : neededVars) {
|
||||
if (jobDefaultContext.getContextParameter(var) != null) {
|
||||
continue;
|
||||
}
|
||||
ContextParameterType param = ContextUtils.getContextParameterTypeByName(itemDefaultContext, var);
|
||||
if (param != null) {
|
||||
addedVars.add(var);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (addedVars != null && !addedVars.isEmpty()) {
|
||||
isAdd = false;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user