Compare commits

...

42 Commits

Author SHA1 Message Date
Chao MENG
6775da2599 chore: fix customURIObject null issue 2020-11-20 10:08:39 +08:00
cbadillo1603
9a219873f1 fix(TBD-11038): The distribution AMAZON_EMR with the version APACHE_2_4_0_EMR doesn't exist (#3694)
* fix(TBD-11038): The distribution AMAZON_EMR with the version APACHE_2_4_0_EMR doesn't exist

* fix(TBD-11038): The distribution AMAZON_EMR with the version APACHE_2_4_0_EMR doesn't exist

* fix(TBD-11038): The distribution AMAZON_EMR with the version APACHE_2_4_0_EMR doesn't exist
2020-11-19 08:59:05 +01:00
bhe-talendbj
d013d08bdc fix(TUP-29227): Set prompt value if it is null (#3811) 2020-11-19 10:44:21 +08:00
apoltavtsev
761dcc7902 fix(TESB-29553, TESB-31088) Could not generate ctalenjob microservice jar 2020-11-18 13:27:36 +01:00
zyuan-talend
0a85c8056c TUP-28024: add automatic Nexus3 testing (#3843) 2020-11-17 10:03:29 +08:00
kjwang
3df4cf1348 Fix TUP-29290 "Detect and Update all jobs " is not identifying the changes in imported projects. (#3833)
* Fix TUP-29290 "Detect and Update all jobs " is not identifying the
changes in imported projects.
https://jira.talendforge.org/browse/TUP-29290
2020-11-16 17:33:58 +08:00
apoltavtsev
c7965cf552 fix(TESB-29553) Publishing a route with cTalendJob from Studio and commandline gives different results 2020-11-12 11:06:44 +01:00
Chao MENG
61b55c0d2a fix(TUP-29285): Improve reloading logic of Custom Uri Mapping (#3830)
https://jira.talendforge.org/browse/TUP-29285
2020-11-12 17:09:53 +08:00
bhe-talendbj
be41bcbef3 feat(TESB-28330): remove workaround for cConfig (#3754)
* feat(TESB-28330): remove workaround for cConfig

* TESB-28330:cConfig/Beans - Support customer groupid and artifact name
(additional to custom version)

* TESB-28330:cConfig/Beans - Support customer groupid and artifact name
(additional to custom version)

Co-authored-by: SunChaoqun <csun@talend.com>
2020-11-12 16:31:56 +08:00
Zhiwei Xue
2827919dae fix(TUP-29265):"<routine_name> cannot be resolved" error after (#3825)
installing latest R2020-10 patch
2020-11-12 09:55:16 +08:00
jiezhang-tlnd
33848db788 Jzhang/bufix/73/tup 28893 support more typesfor share libs1 (#3816)
* fix(TUP-28893)Support more types of artifact for share libs
https://jira.talendforge.org/browse/TUP-28893

* ignore snapshot

* Maintenance/7.3 (#3774)

* fix(TUP-28983):Can't switch to another version on Impala connection (#3741) (#3758)

* fix(TUP-28846): Export Type Dropdown is empty when publishing Big Data (#3703)

Batch jobs job into Artifact Repository for Talend Studio 7.2 and 7.3

* bugfix(TESB-30661) Wrong artifact version of the job called by a route

* bugfix(TESB-30661) Wrong artifact version of the job called by a route

* Revert bugfix(TESB-30661) Wrong artifact version of the job called by a route

* Revert bugfix(TESB-30661) Wrong artifact version of the job called by a route

Co-authored-by: hcyi <hcyi@talend.com>
Co-authored-by: Zhiwei Xue <zwxue@talend.com>
Co-authored-by: apoltavtsev <apoltavtsev@gmail.com>

* Maintenance/7.3 (#3775)

* fix(TUP-28983):Can't switch to another version on Impala connection (#3741) (#3758)

* fix(TUP-28846): Export Type Dropdown is empty when publishing Big Data (#3703)

Batch jobs job into Artifact Repository for Talend Studio 7.2 and 7.3

* bugfix(TESB-30661) Wrong artifact version of the job called by a route

* bugfix(TESB-30661) Wrong artifact version of the job called by a route

* Revert bugfix(TESB-30661) Wrong artifact version of the job called by a route

* Revert bugfix(TESB-30661) Wrong artifact version of the job called by a route

Co-authored-by: hcyi <hcyi@talend.com>
Co-authored-by: Zhiwei Xue <zwxue@talend.com>
Co-authored-by: apoltavtsev <apoltavtsev@gmail.com>

* Maintenance/7.3 (#3776)

* fix(TUP-28983):Can't switch to another version on Impala connection (#3741) (#3758)

* fix(TUP-28846): Export Type Dropdown is empty when publishing Big Data (#3703)

Batch jobs job into Artifact Repository for Talend Studio 7.2 and 7.3

* bugfix(TESB-30661) Wrong artifact version of the job called by a route

* bugfix(TESB-30661) Wrong artifact version of the job called by a route

* Revert bugfix(TESB-30661) Wrong artifact version of the job called by a route

* Revert bugfix(TESB-30661) Wrong artifact version of the job called by a route

Co-authored-by: hcyi <hcyi@talend.com>
Co-authored-by: Zhiwei Xue <zwxue@talend.com>
Co-authored-by: apoltavtsev <apoltavtsev@gmail.com>

* bugfix(TESB-30661) Wrong artifact version of the job called by a route

* bugfix(TESB-30661) Wrong artifact version of the job called by a route

* Revert bugfix(TESB-30661) Wrong artifact version of the job called by a route

* Revert bugfix(TESB-30661) Wrong artifact version of the job called by a route

* modify for nexus2

* support classifier for artifact repository

* add getClassifier and junits

* remove snapshot judgment

* fix(TUP-28893)Support more types of artifact for share libs

* fix(TUP-28893)Support more types of artifact for share libs

* fix(TUP-28893)Support more types of artifact for share libs

* fix pom deploy fail on artifactory

* revert the fix of redeploy pom file

* revert the fix of redeploy pom file

Co-authored-by: hcyi <hcyi@talend.com>
Co-authored-by: Zhiwei Xue <zwxue@talend.com>
Co-authored-by: apoltavtsev <apoltavtsev@gmail.com>
2020-11-11 13:00:41 +08:00
apoltavtsev
ac359e295a fix(TESB-30691) Incorrect Route version in Runtime after sequential publish from Studio 2020-11-10 16:45:36 +01:00
apoltavtsev
6965eb79fa bugfix(TESB-30661) Wrong artifact version of the job called by a route 2020-11-10 15:59:21 +01:00
apoltavtsev
80f02ef1e7 feat(TESB-29949) Pass the data source to a job using a context variable 2020-11-10 15:58:06 +01:00
hzhao-talendbj
7c50efdf21 bugfix(TUP-26868):xmlMapping file are not correctly add to class path in (#3229) (#3810)
bugfix(TUP-26868):xmlMapping file are not correctly add to class path in debug mode

Co-authored-by: hwang-talend <hwang@talend.com>
2020-11-10 15:38:16 +08:00
chmyga
7f40393753 chore(TDI-45157): bump TCK components version (#3821)
Co-authored-by: Dmytro Chmyga <dmytro.chmyga@synapse.com>
2020-11-10 08:44:41 +02:00
Jane Ding
356dba9940 Fix junit failure (#3820)
Signed-off-by: jding-tlnd <jding@talend.com>
2020-11-09 19:24:48 +08:00
Chao MENG
83f7a577d9 feat(TUP-28790): Enhance detection of localhost (#3729)
* feat(TUP-28790): Enhance detection of localhost

https://jira.talendforge.org/browse/TUP-28790

* feat(TUP-28790): Enhance detection of localhost

https://jira.talendforge.org/browse/TUP-28790

* feat(TUP-28790): Enhance detection of localhost

https://jira.talendforge.org/browse/TUP-28790

* feat(TUP-28790): Enhance detection of localhost

https://jira.talendforge.org/browse/TUP-28790

* feat(TUP-28790): Enhance detection of localhost

https://jira.talendforge.org/browse/TUP-28790
2020-11-09 17:32:13 +08:00
Chao MENG
e87f557a49 feat(TUP-29126): Github Renaming the default branch from master (#3793)
* feat(TUP-29126): Github Renaming the default branch from master
https://jira.talendforge.org/browse/TUP-29126

* feat(TUP-29126): Github Renaming the default branch from master
https://jira.talendforge.org/browse/TUP-29126
2020-11-09 10:10:52 +08:00
Zhiwei Xue
a51b3316d3 fix(TUP-28852):Keytab fields missing for impala metadata (#3743) 2020-11-07 15:44:29 +08:00
bkatiukhov
46a22c4ad0 TESB-30649 Fix NPE for bean relation (#3805)
Co-authored-by: bohdan.katiukhov <bohdan.katiukhov@KBP1-LHP-A00322.synapse.com>
2020-11-06 16:52:05 +02:00
sbliu
f8cc600d06 TUP-28904 CI/CD build for DI jobs that contain 2 different versions of httpcore and httpclient are inconsistent with Studio build。
Add dependency jars from parent job, child job to ci job dependencies, the dependency jars is the latest version in parent and the latest version in child job, others is optional.
2020-11-06 17:22:16 +08:00
bhe-talendbj
3146ed307f fix(TUP-29208): add warning message for checking remote artifactory (#3803)
* fix(TUP-29208): add warning message for checking remote artifactory

* fix(TUP-29208): share module based on gavtc and sha1

* fix(TUP-29208): resolve comments
2020-11-06 15:40:57 +08:00
kjwang
f4f91a5323 TUP-28833 Multi-User: support custom javajet component in shared studio
TUP-28833 Multi-User: support custom javajet component in shared studio
https://jira.talendforge.org/browse/TUP-28833
2020-11-06 15:02:50 +08:00
Jane Ding
2aee38595f feat(TUP-29076):support memsql in studio metadata and components (#3779)
https://jira.talendforge.org/browse/TUP-29076

Signed-off-by: jding-tlnd <jding@talend.com>
2020-11-06 10:52:43 +08:00
wang wei
dde32c8b49 fix(TDI-44910): add memsql mapping (#3757)
* fix(TDI-44910): add memsql mapping

* rename it
2020-11-06 10:51:56 +08:00
jiezhang-tlnd
563b69231f Jzhang/bufix/73/tup 28893 support more typesfor share libs1 (#3777)
* fix(TUP-28893)Support more types of artifact for share libs
https://jira.talendforge.org/browse/TUP-28893

* ignore snapshot

* Maintenance/7.3 (#3774)

* fix(TUP-28983):Can't switch to another version on Impala connection (#3741) (#3758)

* fix(TUP-28846): Export Type Dropdown is empty when publishing Big Data (#3703)

Batch jobs job into Artifact Repository for Talend Studio 7.2 and 7.3

* bugfix(TESB-30661) Wrong artifact version of the job called by a route

* bugfix(TESB-30661) Wrong artifact version of the job called by a route

* Revert bugfix(TESB-30661) Wrong artifact version of the job called by a route

* Revert bugfix(TESB-30661) Wrong artifact version of the job called by a route

Co-authored-by: hcyi <hcyi@talend.com>
Co-authored-by: Zhiwei Xue <zwxue@talend.com>
Co-authored-by: apoltavtsev <apoltavtsev@gmail.com>

* Maintenance/7.3 (#3775)

* fix(TUP-28983):Can't switch to another version on Impala connection (#3741) (#3758)

* fix(TUP-28846): Export Type Dropdown is empty when publishing Big Data (#3703)

Batch jobs job into Artifact Repository for Talend Studio 7.2 and 7.3

* bugfix(TESB-30661) Wrong artifact version of the job called by a route

* bugfix(TESB-30661) Wrong artifact version of the job called by a route

* Revert bugfix(TESB-30661) Wrong artifact version of the job called by a route

* Revert bugfix(TESB-30661) Wrong artifact version of the job called by a route

Co-authored-by: hcyi <hcyi@talend.com>
Co-authored-by: Zhiwei Xue <zwxue@talend.com>
Co-authored-by: apoltavtsev <apoltavtsev@gmail.com>

* Maintenance/7.3 (#3776)

* fix(TUP-28983):Can't switch to another version on Impala connection (#3741) (#3758)

* fix(TUP-28846): Export Type Dropdown is empty when publishing Big Data (#3703)

Batch jobs job into Artifact Repository for Talend Studio 7.2 and 7.3

* bugfix(TESB-30661) Wrong artifact version of the job called by a route

* bugfix(TESB-30661) Wrong artifact version of the job called by a route

* Revert bugfix(TESB-30661) Wrong artifact version of the job called by a route

* Revert bugfix(TESB-30661) Wrong artifact version of the job called by a route

Co-authored-by: hcyi <hcyi@talend.com>
Co-authored-by: Zhiwei Xue <zwxue@talend.com>
Co-authored-by: apoltavtsev <apoltavtsev@gmail.com>

* bugfix(TESB-30661) Wrong artifact version of the job called by a route

* bugfix(TESB-30661) Wrong artifact version of the job called by a route

* Revert bugfix(TESB-30661) Wrong artifact version of the job called by a route

* Revert bugfix(TESB-30661) Wrong artifact version of the job called by a route

* modify for nexus2

* support classifier for artifact repository

* add getClassifier and junits

* remove snapshot judgment

Co-authored-by: hcyi <hcyi@talend.com>
Co-authored-by: Zhiwei Xue <zwxue@talend.com>
Co-authored-by: apoltavtsev <apoltavtsev@gmail.com>
2020-11-05 14:19:31 +08:00
bhe-talendbj
1ea6227f59 bugfix(TUP-26278): Validate table name before persisting (#3108) (#3789)
* fix(TUP-26278): Validate table name before persisting

* fix(TUP-26278): Remove validating table name
2020-11-03 17:28:20 +08:00
kjwang
148e9e9253 Fix a NPE issue (#3795)
Fix TUP-28050 Multi-User: Avoid possible actions that are not supported on shared studio (Fix a NPE issue)
https://jira.talendforge.org/browse/TUP-28050
2020-11-03 15:25:25 +08:00
kjwang
1e6a43650f Kjwang/fix tup 28050 avoid possible actions (#3683)
* TUP-28274 Shared Studio: Can't find EMR 5.29 option in Hadoop Cluster
wizard after enable shared studio mode
https://jira.talendforge.org/browse/TUP-28274
2020-11-03 11:21:43 +08:00
jiezhang-tlnd
67616537b2 fix(TUP-28839)NPE when retrieve schema for JDBC connection of postgresql (#3700) (#3745)
https://jira.talendforge.org/browse/TUP-28839
2020-11-03 09:08:31 +08:00
bhe-talendbj
1df4e819e0 fix(TUP-29170): Fix jarpath change (#3786) 2020-11-02 17:30:12 +08:00
sbliu
b3d6c45f2d TUP-29059 Add logon project name to performance log. 2020-11-02 16:49:09 +08:00
wang wei
f1341cd69f fix(TDI-45038): add "timestamp" info for component start event for studio audit log(#3742) 2020-11-02 09:36:06 +08:00
bhe-talendbj
a64bcecb0c bugfix(TUP-28978): Add migration and make module name consistent (#3753)
* fix(TUP-28978): search local support other type and strip snapshot version

* fix(TUP-28978): Fix strip timestamp

* fix(TUP-2897): search remote dll, strip timestamp

* fix(TUP-28978): search local filtering timestamp

* fix(TUP-28978): Revert unnecessary changed files
2020-10-29 15:55:58 +08:00
apoltavtsev
5707d4db94 Revert bugfix(TESB-30661) Wrong artifact version of the job called by a route 2020-10-27 14:00:05 +01:00
apoltavtsev
5e20a78752 Revert bugfix(TESB-30661) Wrong artifact version of the job called by a route 2020-10-27 13:59:10 +01:00
apoltavtsev
85e44cd5c6 bugfix(TESB-30661) Wrong artifact version of the job called by a route 2020-10-27 13:53:20 +01:00
apoltavtsev
8582c20f1a bugfix(TESB-30661) Wrong artifact version of the job called by a route 2020-10-27 13:52:46 +01:00
Zhiwei Xue
6216fd76ea fix(TUP-28846): Export Type Dropdown is empty when publishing Big Data (#3703)
Batch jobs job into Artifact Repository for Talend Studio 7.2 and 7.3
2020-10-27 18:18:36 +08:00
hcyi
71d339fc0a fix(TUP-28983):Can't switch to another version on Impala connection (#3741) (#3758) 2020-10-27 15:54:23 +08:00
Jane Ding
d286276e6d fix(TUP-28952):TOS: NPE when delete items to recycle bin (#3737)
https://jira.talendforge.org/browse/TUP-28952

Signed-off-by: jding-tlnd <jding@talend.com>
2020-10-20 10:15:38 +08:00
71 changed files with 2369 additions and 390 deletions

View File

@@ -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;
@@ -232,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; // ?

View File

@@ -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);
}

View File

@@ -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$
}
}

View File

@@ -2090,7 +2090,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
@@ -2141,12 +2141,18 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
ProjectDataJsonProvider.checkAndRectifyRelationShipSetting(project.getEmfProject());
// load additional jdbc
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
IGenericWizardService service = GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
if (service != null) {
service.loadAdditionalJDBC();
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.

View File

@@ -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>

View File

@@ -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);
}
}
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -111,4 +111,6 @@ public interface IComponentsFactory {
public Map<String, File> getComponentsProvidersFolder();
public List<ComponentProviderInfo> getComponentsProvidersInfo();
public String getCustomComponentBundlePath();
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}
}

View File

@@ -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));
}

View File

@@ -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,

View File

@@ -1003,4 +1003,12 @@ 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;
}
}

View File

@@ -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")) {

View File

@@ -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);
}

View File

@@ -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$
/*

View File

@@ -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);
}

View File

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

View File

@@ -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;
}
}

View File

@@ -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 {
}

View File

@@ -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();
}

View File

@@ -15,10 +15,14 @@ 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;
@@ -27,7 +31,8 @@ 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$
@@ -60,6 +65,9 @@ public class SharedStudioUtils {
}
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
@@ -69,6 +77,13 @@ public class SharedStudioUtils {
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);
@@ -80,4 +95,17 @@ public class SharedStudioUtils {
}
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;
}
}

View File

@@ -22,5 +22,7 @@ public interface IUpdateService extends IService {
void syncComponentM2Jars(IProgressMonitor monitor);
public boolean syncSharedStudioLibraryInPatch(IProgressMonitor monitor) throws Exception;
public String getSharedStudioMissingPatchVersion();
}

View File

@@ -606,7 +606,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 +650,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;

View File

@@ -125,7 +125,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);

View File

@@ -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$

View File

@@ -36,8 +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.maven.MavenArtifact;
import org.talend.core.runtime.maven.MavenUrlHelper;
import org.talend.core.ui.CoreUIPlugin;
import org.talend.core.ui.process.IGEFProcess;
import org.talend.core.ui.services.IDesignerCoreUIService;
@@ -192,33 +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);
}
}
// cConfig
if (!isNotCConfig) {
if (newValue.startsWith(MavenUrlHelper.MVN_PROTOCOL)) {
MavenArtifact art = MavenUrlHelper.parseMvnUrl(newValue);
newValue = art.getFileName();
}
}
//
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);

View File

@@ -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)) {

View File

@@ -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.15.0</tacokit.components.version>
</properties>
<repositories>
<repository>

View File

@@ -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);
@@ -98,12 +107,13 @@ public class CodeM2CacheManager {
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;
}
}

View File

@@ -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)) {
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();

View File

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

View File

@@ -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;
}
}

View File

@@ -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.

View File

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

View File

@@ -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,6 +72,7 @@ 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;
@@ -583,7 +583,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 +595,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 +604,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 +622,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);

View File

@@ -126,6 +126,7 @@ 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 ?

View File

@@ -21,7 +21,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.TimeoutException;
@@ -58,8 +57,6 @@ import org.talend.commons.ui.gmf.util.DisplayUtils;
import org.talend.commons.ui.runtime.image.EImage;
import org.talend.commons.ui.runtime.image.ImageProvider;
import org.talend.commons.ui.swt.dialogs.IConfigModuleDialog;
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.ModuleToInstall;
@@ -103,8 +100,6 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
private Button useCustomBtn;
private boolean useCustom;
private String urlToUse;
private String defaultURI;
@@ -131,6 +126,12 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
private String initValue;
private Label warningLabel;
private GridData warningLayoutData;
private Composite warningComposite;
/**
* DOC wchen InstallModuleDialog constructor comment.
*
@@ -152,15 +153,17 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
protected Control createDialogArea(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginTop = 10;
layout.marginTop = 20;
layout.marginLeft = 20;
layout.marginRight = 20;
layout.marginBottom = 40;
layout.marginBottom = 60;
layout.marginHeight = 0;
container.setLayout(layout);
GridData data = new GridData(GridData.FILL_BOTH);
container.setLayoutData(data);
createWarningLabel(container);
Composite radioContainer = new Composite(container, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
@@ -175,6 +178,36 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
return parent;
}
private void createWarningLabel(Composite container) {
warningComposite = new Composite(container, SWT.NONE);
warningComposite.setBackground(warningColor);
warningLayoutData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
warningLayoutData.horizontalSpan = ((GridLayout) container.getLayout()).numColumns;
warningComposite.setLayoutData(warningLayoutData);
GridLayout layout = new GridLayout();
layout.marginTop = 0;
layout.marginLeft = 0;
layout.marginRight = 0;
layout.numColumns = 2;
warningComposite.setLayout(layout);
Label imageLabel = new Label(warningComposite, SWT.NONE);
imageLabel.setImage(ImageProvider.getImage(EImage.WARNING_ICON));
imageLabel.setBackground(warningColor);
warningLabel = new Label(warningComposite, SWT.WRAP);
warningLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
warningLabel.setBackground(warningColor);
warningLayoutData.exclude = true;
}
private void layoutWarningComposite(boolean exclude) {
warningComposite.setVisible(!exclude);
warningLayoutData.exclude = exclude;
warningLabel.setText(Messages.getString("ConfigModuleDialog.warn.artifactory"));
warningLabel.getParent().getParent().layout();
warningLabel.getParent().getParent().getParent().getParent().getParent().pack();
}
private void createMavenURIGroup(Composite parent) {
Composite mvnContainer = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
@@ -302,6 +335,13 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
jarPathTxt = new Text(repGroupSubComp, SWT.BORDER);
jarPathTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
jarPathTxt.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
handJarPathChanged();
}
});
browseButton = new Button(repGroupSubComp, SWT.PUSH);
browseButton.setText("...");//$NON-NLS-1$
@@ -316,7 +356,7 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
@Override
public void widgetSelected(SelectionEvent e) {
setInstallNewGroupEnabled(true);
setInstallNewGroupEnabled(installRadioBtn.getSelection());
setPlatformGroupEnabled(false);
setRepositoryGroupEnabled(false);
}
@@ -394,6 +434,10 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
if (useCustomBtn.getSelection()) {
customUriText.setEnabled(true);
}
boolean canConnectRemoteArtifactory = ConfigModuleHelper.notShowConnectionWarning();
layoutWarningComposite(canConnectRemoteArtifactory);
} else {
layoutWarningComposite(true);
}
}
@@ -489,7 +533,10 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
return;
}
this.jarPathTxt.setText(result);
File file = new File(result);
}
private void handJarPathChanged() {
File file = new File(this.jarPathTxt.getText());
moduleName = file.getName();
final IRunnableWithProgress detectProgress = new IRunnableWithProgress() {
@@ -537,15 +584,11 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
ret = ConfigModuleHelper.searchRemoteArtifacts(name);
}
String[] items = ConfigModuleHelper.toArray(ret);
Map<String, MavenArtifact> data = new HashMap<String, MavenArtifact>();
for (MavenArtifact art : ret) {
data.put(art.getFileName(false), art);
}
searchResultCombo.setData(data);
searchResultCombo.setData(ret);
if (items.length > 0) {
searchResultCombo.setItems(items);
searchResultCombo.setText(searchResultCombo.getItem(0));
resultField.setProposals(items);
resultField.setProposals(ConfigModuleHelper.toArrayUnique(items));
} else {
searchResultCombo.setText("");
searchResultCombo.setItems(new String[0]);
@@ -608,7 +651,6 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
}
String originalText = defaultUriTxt.getText().trim();
String customURIWithType = MavenUrlHelper.addTypeForMavenUri(customUriText.getText(), moduleName);
useCustom = useCustomBtn.getSelection();
if (useCustomBtn.getSelection()) {
// if use custom uri:validate custom uri + check deploy status
String errorMessage = ModuleMavenURIUtils.validateCustomMvnURI(originalText, customURIWithType);
@@ -700,6 +742,7 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
if (installRadioBtn.getSelection()) {
File jarFile = new File(jarPathTxt.getText().trim());
MavenArtifact art = MavenUrlHelper.parseMvnUrl(urlToUse);
moduleName = art.getFileName();
String sha1New = ConfigModuleHelper.getSHA1(jarFile);
art.setSha1(sha1New);
// resolve jar locally
@@ -732,7 +775,7 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
List<MavenArtifact> remoteArtifacts = null;
try {
remoteArtifacts = ConfigModuleHelper.searchRemoteArtifacts(art.getGroupId(),
art.getArtifactId(), art.getVersion());
art.getArtifactId(), null);
} catch (Exception e) {
ExceptionHandler.process(e);
}
@@ -741,9 +784,15 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
if (ConfigModuleHelper.canFind(new HashSet<MavenArtifact>(remoteArtifacts), art)) {
deploy = false;
} else {
// popup and ask, reinstall?
deploy = MessageDialog.open(MessageDialog.CONFIRM, getShell(), "",
Messages.getString("ConfigModuleDialog.shareInfo"), SWT.NONE);
if (art.getVersion() != null
&& art.getVersion().endsWith(MavenUrlHelper.VERSION_SNAPSHOT)) {
// snapshot
deploy = true;
} else {
// popup and ask, reinstall?
deploy = MessageDialog.open(MessageDialog.CONFIRM, getShell(), "",
Messages.getString("ConfigModuleDialog.shareInfo"), SWT.NONE);
}
}
}
@@ -771,8 +820,8 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
// check sha1
String sha1Local = ConfigModuleHelper.getSHA1(localFile);
@SuppressWarnings("unchecked")
Map<String, MavenArtifact> data = (Map<String, MavenArtifact>) searchResultCombo.getData();
MavenArtifact art = data.get(moduleName);
List<MavenArtifact> data = (List<MavenArtifact>) searchResultCombo.getData();
MavenArtifact art = data.get(this.searchResultCombo.getSelectionIndex());
try {
// for nexus2 only
ConfigModuleHelper.resolveSha1(art);
@@ -796,6 +845,7 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
DownloadModuleRunnableWithLicenseDialog downloadModuleRunnable = new DownloadModuleRunnableWithLicenseDialog(
toInstall, getShell());
runProgress(downloadModuleRunnable);
this.updateIndex(defaultURI);
}
}
}
@@ -837,9 +887,19 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
private void setupMavenURIforSearch() {
if (validateInputFields()) {
@SuppressWarnings("unchecked")
Map<String, MavenArtifact> data = (Map<String, MavenArtifact>) searchResultCombo.getData();
if (data != null && data.get(moduleName) != null) {
MavenArtifact art = data.get(moduleName);
List<MavenArtifact> data = (List<MavenArtifact>) searchResultCombo.getData();
if (data != null && !data.isEmpty()) {
if (this.searchResultCombo.getSelectionIndex() < 0) {
int i = 0;
for (MavenArtifact temp : data) {
if (temp.getFileName().equals(this.searchResultCombo.getText())) {
this.searchResultCombo.select(i);
break;
}
i++;
}
}
MavenArtifact art = data.get(this.searchResultCombo.getSelectionIndex());
defaultURIValue = MavenUrlHelper.generateMvnUrl(art);
defaultUriTxt.setText(defaultURIValue);
}

View File

@@ -16,6 +16,7 @@ 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;
@@ -35,6 +36,7 @@ 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;
/*
@@ -45,6 +47,16 @@ 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() {
}
@@ -54,7 +66,8 @@ public class ConfigModuleHelper {
IRepositoryArtifactHandler customerRepHandler = RepositoryArtifactHandlerManager.getRepositoryHandler(customNexusServer);
if (customerRepHandler != null) {
List<MavenArtifact> ret = customerRepHandler.search(name, true);
return ret;
return VersionUtil.filterSnapshotArtifacts(ret);
}
return new ArrayList<MavenArtifact>();
}
@@ -66,7 +79,19 @@ public class ConfigModuleHelper {
List<String> ret = new ArrayList<String>();
for (MavenArtifact art : artifacts) {
ret.add(art.getFileName(false));
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]);
}
@@ -78,7 +103,8 @@ public class ConfigModuleHelper {
search(name, m2Dir, ret);
}
return ret;
return VersionUtil.filterSnapshotArtifacts(ret);
}
private static void search(String name, File dir, List<MavenArtifact> ret) throws Exception {
@@ -87,11 +113,16 @@ public class ConfigModuleHelper {
if (f.isDirectory()) {
search(name, f, ret);
} else {
if (f.isFile() && f.getName().endsWith(".jar")
&& StringUtils.containsIgnoreCase(FilenameUtils.getBaseName(f.getName()), name)) {
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);
MavenArtifact art = parse(path, ext);
if (art != null) {
ret.add(art);
}
@@ -100,7 +131,7 @@ public class ConfigModuleHelper {
}
}
public static MavenArtifact parse(String path) {
public static MavenArtifact parse(String path, String ext) {
MavenArtifact art = new MavenArtifact();
if (path == null || StringUtils.isEmpty(path)) {
return null;
@@ -127,14 +158,19 @@ public class ConfigModuleHelper {
art.setGroupId(sb.toString());
art.setArtifactId(a);
art.setVersion(v);
art.setType("jar");
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;
}
@@ -185,8 +221,8 @@ public class ConfigModuleHelper {
for (MavenArtifact art : artifacts) {
if (StringUtils.equals(art.getGroupId(), artifact.getGroupId())
&& StringUtils.equals(art.getArtifactId(), artifact.getArtifactId())
&& StringUtils.equals(art.getVersion(), artifact.getVersion())
&& 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;
@@ -199,22 +235,24 @@ public class ConfigModuleHelper {
ArtifactRepositoryBean customNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer();
IRepositoryArtifactHandler customerRepHandler = RepositoryArtifactHandlerManager.getRepositoryHandler(customNexusServer);
if (customerRepHandler != null) {
boolean fromSnapshot = false;
if (v != null && v.endsWith(MavenUrlHelper.VERSION_SNAPSHOT)) {
fromSnapshot = true;
}
List<MavenArtifact> ret = customerRepHandler.search(g, a, v, true, fromSnapshot);
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, !fromSnapshot);
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 ret;
return VersionUtil.filterSnapshotArtifacts(ret);
}
return new ArrayList<MavenArtifact>();
}
@@ -291,4 +329,20 @@ public class ConfigModuleHelper {
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;
}
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -13,25 +13,38 @@
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.Assert;
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,17 +56,30 @@ 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() {
IFolder resourcePath = getResourcePath();
try {
customURIObject = loadResources(getResourcePath(), CUSTOM_URI_MAP);
Assert.isNotNull(resourcePath);
customURIObject = loadResources(resourcePath, RepositoryConstants.PROJECT_SETTINGS_CUSTOM_URI_MAP);
} catch (Exception e) {
ExceptionHandler.process(e);
try {
if (resourcePath != null) {
customURIObject = loadResources(resourcePath.getLocation().toPortableString(),
RepositoryConstants.PROJECT_SETTINGS_CUSTOM_URI_MAP);
}
} catch (Exception e1) {
ExceptionHandler.process(e1);
/**
* Seems dangrous to load an empty json here, because it may overwrite the existing one
*/
// customURIObject = new JSONObject();
}
}
}
@@ -61,34 +87,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 +213,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 +224,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 +236,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 +249,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 +279,22 @@ 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 || customURIObject == null) {
synchronized (reloadingLock) {
if (isNeedReload || customURIObject == null) {
if (customURIObject == null) {
customURIObject = new JSONObject();
} else {
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);
}
}

View File

@@ -1315,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) {
@@ -1348,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>>();

View File

@@ -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;
@@ -259,6 +260,9 @@ 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);
}
@@ -353,6 +357,9 @@ 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);
}

View File

@@ -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) {

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -131,6 +131,11 @@ public final class DBConnectionContextUtils {
Znode_Parent,
// impala
ImpalaPrincipal,
ImpalaKeyTabPrincipal,
ImpalaKeyTab,
ImpalaUseSSL,
ImpalaSSLTrustStorePath,
ImpalaSSLTrustStorePassword,
// Oracle Custom SSL Encryption
SSLTrustStorePath,
@@ -265,10 +270,16 @@ public final class DBConnectionContextUtils {
ConnectionContextHelper.createParameters(varList, paramName, value, JavaTypesManager.PASSWORD);
break;
case HiveKeyTabPrincipal:
case HbaseKeyTabPrincipal:
case MaprdbKeyTabPrincipal:
case ImpalaKeyTabPrincipal:
value = conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
ConnectionContextHelper.createParameters(varList, paramName, value);
break;
case HiveKeyTab:
case ImpalaKeyTab:
case HbaseKeyTab:
case MaprdbKeyTab:
value = conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
ConnectionContextHelper.createParameters(varList, paramName, value);
break;
@@ -285,10 +296,14 @@ public final class DBConnectionContextUtils {
ConnectionContextHelper.createParameters(varList, paramName, value);
break;
case hiveSSLTrustStorePath:
case ImpalaSSLTrustStorePath:
case SSLTrustStorePath:
value = conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH);
ConnectionContextHelper.createParameters(varList, paramName, value);
break;
case hiveSSLTrustStorePassword:
case ImpalaSSLTrustStorePassword:
case SSLTrustStorePassword:
value = conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD);
value = conn.getValue(value, false);
ConnectionContextHelper.createParameters(varList, paramName, value, JavaTypesManager.PASSWORD);
@@ -321,16 +336,6 @@ public final class DBConnectionContextUtils {
value = conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HBASE_ZNODE_PARENT);
ConnectionContextHelper.createParameters(varList, paramName, value);
break;
case HbaseKeyTabPrincipal:
case MaprdbKeyTabPrincipal:
value = conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
ConnectionContextHelper.createParameters(varList, paramName, value);
break;
case HbaseKeyTab:
case MaprdbKeyTab:
value = conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
ConnectionContextHelper.createParameters(varList, paramName, value);
break;
case ImpalaPrincipal:
value = conn.getParameters().get(ConnParameterKeys.IMPALA_AUTHENTICATION_PRINCIPLA);
ConnectionContextHelper.createParameters(varList, paramName, value);
@@ -375,15 +380,6 @@ public final class DBConnectionContextUtils {
value = conn.getParameters().get(key);
ConnectionContextHelper.createParameters(varList, paramName, value, JavaTypesManager.LONG);
break;
case SSLTrustStorePath:
value = conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH);
ConnectionContextHelper.createParameters(varList, paramName, value);
break;
case SSLTrustStorePassword:
value = conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD);
value = conn.getValue(value, false);
ConnectionContextHelper.createParameters(varList, paramName, value, JavaTypesManager.PASSWORD);
break;
case SSLKeyStorePath:
value = conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_KEY_STORE_PATH);
ConnectionContextHelper.createParameters(varList, paramName, value);
@@ -664,10 +660,16 @@ public final class DBConnectionContextUtils {
ContextParameterUtils.getNewScriptCode(originalVariableName, LANGUAGE));
break;
case HiveKeyTabPrincipal:
case ImpalaKeyTabPrincipal:
case HbaseKeyTabPrincipal:
case MaprdbKeyTabPrincipal:
conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL,
ContextParameterUtils.getNewScriptCode(originalVariableName, LANGUAGE));
break;
case HiveKeyTab:
case ImpalaKeyTab:
case HbaseKeyTab:
case MaprdbKeyTab:
conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB,
ContextParameterUtils.getNewScriptCode(originalVariableName, LANGUAGE));
break;
@@ -684,10 +686,14 @@ public final class DBConnectionContextUtils {
ContextParameterUtils.getNewScriptCode(originalVariableName, LANGUAGE));
break;
case hiveSSLTrustStorePath:
case SSLTrustStorePath:
case ImpalaSSLTrustStorePath:
conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH,
ContextParameterUtils.getNewScriptCode(originalVariableName, LANGUAGE));
break;
case hiveSSLTrustStorePassword:
case SSLTrustStorePassword:
case ImpalaSSLTrustStorePassword:
conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD,
ContextParameterUtils.getNewScriptCode(originalVariableName, LANGUAGE));
break;
@@ -716,16 +722,6 @@ public final class DBConnectionContextUtils {
conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_ZNODE_PARENT,
ContextParameterUtils.getNewScriptCode(originalVariableName, LANGUAGE));
break;
case HbaseKeyTabPrincipal:
case MaprdbKeyTabPrincipal:
conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL,
ContextParameterUtils.getNewScriptCode(originalVariableName, LANGUAGE));
break;
case HbaseKeyTab:
case MaprdbKeyTab:
conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB,
ContextParameterUtils.getNewScriptCode(originalVariableName, LANGUAGE));
break;
case Username:
key = ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USERNAME;
if (EDatabaseTypeName.HBASE.getDisplayName().equals(conn.getDatabaseType())) {
@@ -766,14 +762,6 @@ public final class DBConnectionContextUtils {
conn.getParameters().put(ConnParameterKeys.IMPALA_AUTHENTICATION_PRINCIPLA,
ContextParameterUtils.getNewScriptCode(originalVariableName, LANGUAGE));
break;
case SSLTrustStorePath:
conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH,
ContextParameterUtils.getNewScriptCode(originalVariableName, LANGUAGE));
break;
case SSLTrustStorePassword:
conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD,
ContextParameterUtils.getNewScriptCode(originalVariableName, LANGUAGE));
break;
case SSLKeyStorePath:
conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_SSL_KEY_STORE_PATH,
ContextParameterUtils.getNewScriptCode(originalVariableName, LANGUAGE));
@@ -1288,6 +1276,35 @@ public final class DBConnectionContextUtils {
cloneConn.getParameters().put(ConnParameterKeys.IMPALA_AUTHENTICATION_PRINCIPLA,
ContextParameterUtils.getOriginalValue(contextType, impalaAuthPrinciple));
}
String keyTabPrin = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
if (keyTabPrin != null) {
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL,
getOriginalValue(hadoopClusterContextType, contextType, keyTabPrin));
}
String keyTab = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
if (keyTab != null) {
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB,
getOriginalValue(hadoopClusterContextType, contextType, keyTab));
}
String additionalJDBCSettings = cloneConn.getParameters()
.get(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS);
if (additionalJDBCSettings != null) {
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS,
getOriginalValue(hadoopClusterContextType, contextType, additionalJDBCSettings));
}
String trustStorePath = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH);
if (trustStorePath != null) {
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH,
getOriginalValue(hadoopClusterContextType, contextType, trustStorePath));
}
String trustStorePassword = cloneConn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD);
if (trustStorePassword != null) {
cloneConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD, cloneConn.getValue(
cloneConn.getValue(getOriginalValue(hadoopClusterContextType, contextType, trustStorePassword), false),
true));
}
}
if (EDatabaseTypeName.ORACLE_CUSTOM.equals(EDatabaseTypeName.getTypeFromDbType(dbConn.getDatabaseType()))) {
@@ -1638,6 +1655,22 @@ public final class DBConnectionContextUtils {
.get(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS);
conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS,
ContextParameterUtils.getOriginalValue(contextType, addtionalJDBCParameters));
String ktPrincipal = conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL,
ContextParameterUtils.getOriginalValue(contextType, ktPrincipal));
String keytab = conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB,
ContextParameterUtils.getOriginalValue(contextType, keytab));
String sslTrustStorePath = conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH);
conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH,
ContextParameterUtils.getOriginalValue(contextType, sslTrustStorePath));
String sslTrustStorePassword = conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD);
conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD,
conn.getValue(ContextParameterUtils.getOriginalValue(contextType, sslTrustStorePassword), true));
}
if (EDatabaseTypeName.ORACLE_CUSTOM.equals(EDatabaseTypeName.getTypeFromDbType(conn.getDatabaseType()))) {

View File

@@ -83,24 +83,23 @@ public class ImpalaConnectionManager extends DataBaseConnectionManager {
Map<String, Object> otherParametersMap = metadataConn.getOtherParameters();
if (otherParametersMap != null) {
boolean useKerb = Boolean
.valueOf((String) otherParametersMap.get(ConnParameterKeys.CONN_PARA_KEY_USE_KRB));
if (useKerb) {
Object conf = Class.forName("org.apache.hadoop.conf.Configuration", true, impalaClassLoader) //$NON-NLS-1$
.newInstance();
EHadoopConfProperties.AUTHENTICATION.set(conf, "KERBEROS"); //$NON-NLS-1$
ReflectionUtils.invokeStaticMethod("org.apache.hadoop.security.UserGroupInformation", //$NON-NLS-1$
impalaClassLoader, "setConfiguration", new Object[] { conf }); //$NON-NLS-1$
}
// addtional jdbc settings
Object jdbcObj = otherParametersMap.get(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS);
if (jdbcObj != null) {
String addJDBCSetting = String.valueOf(jdbcObj);
if (!"".equals(addJDBCSetting.trim())) {
if (!addJDBCSetting.startsWith(";")) {
addJDBCSetting = ";" + addJDBCSetting;
if (Boolean.valueOf((String) otherParametersMap.get(ConnParameterKeys.CONN_PARA_KEY_USE_KRB))) {
if (Boolean.valueOf((String) metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_USEKEYTAB))) {
String principal = (String) metadataConn
.getParameter(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
String keytabPath = (String) metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
try {
ReflectionUtils.invokeStaticMethod("org.apache.hadoop.security.UserGroupInformation", //$NON-NLS-1$
impalaClassLoader, "loginUserFromKeytab", new String[] { principal, keytabPath });
} catch (Exception e) {
throw new SQLException(e);
}
connURL += addJDBCSetting;
} else {
Object conf = Class.forName("org.apache.hadoop.conf.Configuration", true, impalaClassLoader) //$NON-NLS-1$
.newInstance();
EHadoopConfProperties.AUTHENTICATION.set(conf, "KERBEROS"); //$NON-NLS-1$
ReflectionUtils.invokeStaticMethod("org.apache.hadoop.security.UserGroupInformation", //$NON-NLS-1$
impalaClassLoader, "setConfiguration", new Object[] { conf }); //$NON-NLS-1$
}
}
IHadoopDistributionService hadoopService = getHadoopDistributionService();

View File

@@ -675,8 +675,14 @@ public class DBConnectionFillerImpl extends MetadataFillerImpl<DatabaseConnectio
String catalogName = getDatabaseName(dbConn);
if (StringUtils.isEmpty(catalogName)) {
String url = null;
if (metaConnection != null) {
url = metaConnection.getUrl();
} else {
url = dbConn.getURL();
}
// TDQ-16020 msjian: should get the correct catalog name
catalogName = getPostgresqlCatalogFromUrl(metaConnection.getUrl(), dbConn.getUsername());
catalogName = getPostgresqlCatalogFromUrl(url, dbConn.getUsername());
}
if (StringUtils.isNotEmpty(catalogName)) {

View File

@@ -44,6 +44,7 @@ import org.talend.core.language.ECodeLanguage;
import org.talend.core.language.LanguageManager;
import org.talend.core.model.utils.TalendPropertiesUtil;
import org.talend.core.repository.model.ProxyRepositoryFactory;
import org.talend.core.runtime.util.SharedStudioUtils;
import org.talend.core.ui.branding.IActionBarHelper;
import org.talend.core.ui.branding.IBrandingService;
import org.talend.core.ui.perspective.PerspectiveMenuManager;
@@ -433,6 +434,10 @@ public class ActionBarBuildHelper implements IActionBarHelper {
for (String id : removeIds) {
helpMenu.remove(id);
}
// Remove unsupported action on shared mode
if (SharedStudioUtils.isSharedStudioMode()) {
helpMenu.remove("org.eclipse.equinox.p2.ui.sdk.install"); //$NON-NLS-1$
}
}
private void printItemId(IContributionManager menuBar) {

View File

@@ -163,10 +163,12 @@ public class Application implements IApplication {
service.executeWorspaceTasks();
// saveConnectionBean(email);
boolean needRelaunch = installLocalPatches();
if (needRelaunch) {
setRelaunchData();
return IApplication.EXIT_RELAUNCH;
if (!SharedStudioUtils.isSharedStudioMode()) {
boolean needRelaunch = installLocalPatches();
if (needRelaunch) {
setRelaunchData();
return IApplication.EXIT_RELAUNCH;
}
}
boolean logUserOnProject = logUserOnProject(display.getActiveShell());

View File

@@ -1308,7 +1308,7 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
try {
Property property = importItem.getProperty();
boolean isReloaded = false;
if (property == null) {
if (property == null || property.eResource() == null) {
object = factory.getSpecificVersion(importItem.getItemId(), importItem.getItemVersion(), true);
property = object.getProperty();
isReloaded = true;

View File

@@ -399,6 +399,14 @@ public class DatabaseForm extends AbstractForm {
private LabelledText impalaPrincipalTxt;
private Button useKeyTabForImpala;
private Composite keyTabCompoisteForImpala;
private LabelledText principalForImpalaTxt;
private LabelledFileField keytabForImpalaTxt;
private LabelledText hbaseMasterPrincipalTxt;
private LabelledText hbaseRSPrincipalTxt;
@@ -1270,6 +1278,28 @@ public class DatabaseForm extends AbstractForm {
impalaPrincipalTxt = new LabelledText(authenticationComForImpala, Messages.getString("DatabaseForm.impalaPrincipal"), 2); //$NON-NLS-1$
// keytab
useKeyTabForImpala = new Button(authenticationComForImpala, SWT.CHECK);
useKeyTabForImpala.setText(Messages.getString("DatabaseForm.hiveEmbedded.useKeyTab")); //$NON-NLS-1$
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 4;
useKeyTabForImpala.setLayoutData(data);
keyTabCompoisteForImpala = new Composite(authenticationComForImpala, SWT.NONE);
data = new GridData(GridData.FILL_BOTH);
data.horizontalSpan = 4;
data.exclude = true;
keyTabCompoisteForImpala.setLayoutData(data);
keyTabCompoisteForImpala.setVisible(false);
keyTabCompoisteForImpala.setLayout(new GridLayout(5, false));
principalForImpalaTxt = new LabelledText(keyTabCompoisteForImpala,
Messages.getString("DatabaseForm.hiveEmbedded.principal"), 1); //$NON-NLS-1$
String[] extensions = { "*.*" }; //$NON-NLS-1$
keytabForImpalaTxt = new LabelledFileField(keyTabCompoisteForImpala,
Messages.getString("DatabaseForm.hiveEmbedded.keytab"), //$NON-NLS-1$
extensions);
addListenerForImpalaAuthentication();
initForImpalaAuthentication();
}
@@ -1930,14 +1960,14 @@ public class DatabaseForm extends AbstractForm {
}
return true;
}
} else if (isOracleCustomDBConnSelected()) {
} else if (isOracleCustomDBConnSelected() || isImpalaDBConnSelected()) {
return true;
}
return false;
}
private boolean isSupportSSLTrustStore() {
if (isHiveDBConnSelected()) {
if (isHiveDBConnSelected() || isImpalaDBConnSelected()) {
// if (!useSSLEncryption.isVisible()) {
// return false;
// }
@@ -2072,6 +2102,45 @@ public class DatabaseForm extends AbstractForm {
});
useKeyTabForImpala.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (useKeyTabForImpala.getSelection()) {
hideControl(keyTabCompoisteForImpala, false);
getConnection().getParameters().put(ConnParameterKeys.CONN_PARA_KEY_USEKEYTAB, "true"); //$NON-NLS-1$
} else {
hideControl(keyTabCompoisteForImpala, true);
getConnection().getParameters().put(ConnParameterKeys.CONN_PARA_KEY_USEKEYTAB, "false"); //$NON-NLS-1$
}
authenticationComForImpala.layout();
authenticationComForImpala.getParent().layout();
authenticationGrpForImpala.layout();
authenticationGrpForImpala.getParent().layout();
adjustScrolledComHeight();
}
});
principalForImpalaTxt.getTextControl().addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (!isContextMode()) {
getConnection().getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL,
principalForImpalaTxt.getText());
}
}
});
keytabForImpalaTxt.getTextControl().addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (!isContextMode()) {
getConnection().getParameters().put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB, keytabForImpalaTxt.getText());
}
}
});
impalaPrincipalTxt.getTextControl().addModifyListener(new ModifyListener() {
@Override
@@ -3329,6 +3398,14 @@ public class DatabaseForm extends AbstractForm {
private void adaptImpalaHadoopPartEditable() {
useKerberosForImpala.setEnabled(!isContextMode());
impalaPrincipalTxt.setEditable(!isContextMode());
useKeyTabForImpala.setEnabled(!isContextMode());
keytabForImpalaTxt.setEditable(!isContextMode());
principalForImpalaTxt.setEditable(!isContextMode());
useSSLEncryption.setEnabled(!isContextMode());
trustStorePath.setEditable(!isContextMode());
trustStorePassword.setEditable(!isContextMode());
}
private void adaptOracleCustomPartEditable() {
@@ -3688,6 +3765,44 @@ public class DatabaseForm extends AbstractForm {
impalaDistributionCombo.select(0);
}
boolean useSSL = Boolean.parseBoolean(connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USE_SSL));
String trustStorePathStr = connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH);
String trustStorePasswordStr = connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD);
useSSLEncryption.setSelection(useSSL);
trustStorePath.setText(trustStorePathStr == null ? "" : trustStorePathStr);
if (trustStorePasswordStr == null) {
trustStorePasswordStr = "";
} else {
trustStorePasswordStr = connection.getValue(trustStorePasswordStr, false);
}
trustStorePassword.setText(trustStorePasswordStr);
String useKrbString = connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USE_KRB);
String useKeytabString = connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USEKEYTAB);
String keytabPrincipal = connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
String keytab = connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
if (!connection.isContextMode() && ContextParameterUtils.isContainContextParam(keytabPrincipal)) {
keytabPrincipal = (String) metadataconnection.getParameter(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
}
if (!connection.isContextMode() && ContextParameterUtils.isContainContextParam(keytab)) {
keytab = (String) metadataconnection.getParameter(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
}
String masterPrincipal = connection.getParameters().get(ConnParameterKeys.IMPALA_AUTHENTICATION_PRINCIPLA);
boolean useKrb = Boolean.valueOf(useKrbString);
boolean useKeytab = Boolean.valueOf(useKeytabString);
useKerberosForImpala.setSelection(useKrb);
if (useKrb) {
useKeyTabForImpala.setSelection(useKeytab);
if (useKeytab) {
principalForImpalaTxt.setText(StringUtils.trimToEmpty(keytabPrincipal));
keytabForImpalaTxt.setText(StringUtils.trimToEmpty(keytab));
}
impalaPrincipalTxt.setText(StringUtils.trimToEmpty(masterPrincipal));
}
hideControl(keyTabCompoisteForImpala, !useKeytab);
hideControl(authenticationComForImpala, !useKrb);
hideControl(authenticationGrpForImpala, false);
authenticationGrpForImpala.setVisible(true);
authenticationGrpForImpala.getParent().layout();
}
@@ -6763,6 +6878,14 @@ public class DatabaseForm extends AbstractForm {
addContextParams(EDBParamName.ImpalaPrincipal, useKerberosForImpala.getSelection());
addContextParams(EDBParamName.Password, true);
addContextParams(EDBParamName.hiveAdditionalJDBCParameters, isSupportImpalaAdditionalSettings());
addContextParams(EDBParamName.ImpalaKeyTabPrincipal, useKeyTabForImpala.getSelection());
addContextParams(EDBParamName.ImpalaKeyTab, useKeyTabForImpala.getSelection());
boolean addSSLEncryptionContext = isSupportSSLEncryption() && isSupportSSLTrustStore();
addContextParams(EDBParamName.ImpalaSSLTrustStorePath, addSSLEncryptionContext);
addContextParams(EDBParamName.ImpalaSSLTrustStorePassword, addSSLEncryptionContext);
}
}
@@ -7142,13 +7265,18 @@ public class DatabaseForm extends AbstractForm {
if (impalaDistribution != null) {
hdVersion = impalaDistribution.getHDVersion(impalaVersion, false);
}
updateImpalaVersionPart(impalaDistribution);
if (!isCreation) {
updateImpalaVersionPart(impalaDistribution);
}
updateImpalaDriverAndMakeSelection(impalaDistribution, hdVersion);
}
// addtional jdbc setting
String additionalJDBCSettings = connection.getParameters()
.get(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS);
additionalJDBCSettingsText.setText(additionalJDBCSettings == null ? "" : additionalJDBCSettings);
showIfSupportEncryption();
updateSSLEncryptionDetailsDisplayStatus();
}
/**

View File

@@ -450,7 +450,7 @@ public class DatabaseTableForm extends AbstractForm {
// init the fields
// nameText.setText(MetadataToolHelper.validateValue(metadataTable.getLabel()));
nameText.setText(MetadataToolHelper.validateTableName(metadataTable.getLabel()));
nameText.setText(metadataTable.getLabel());
commentText.setText(metadataTable.getComment());
if (metadataTable.getTableType() != null) {
typeText.setText(Messages.getString("DatabaseTableForm.type", metadataTable.getTableType())); //$NON-NLS-1$
@@ -1071,9 +1071,6 @@ public class DatabaseTableForm extends AbstractForm {
} else if (existNames.contains(table.getLabel())) {
updateStatus(IStatus.ERROR, Messages.getString("CommonWizard.nameAlreadyExist") + " \"" + table.getLabel() + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return false;
} else if (!MetadataToolHelper.isValidSchemaName(table.getLabel())) {
updateStatus(IStatus.ERROR, Messages.getString("DatabaseTableForm.illegalChar", table.getLabel())); //$NON-NLS-1$
return false;
}
// if (table.getColumns().size() == 0) {// this one has been removed,see bug 0016029

View File

@@ -17,6 +17,7 @@ import java.util.Set;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.core.runtime.util.SharedStudioUtils;
import org.talend.updates.runtime.engine.factory.AbstractExtraUpdatesFactory;
import org.talend.updates.runtime.engine.factory.IComponentUpdatesFactory;
import org.talend.updates.runtime.model.ExtraFeature;
@@ -56,6 +57,9 @@ public class ExtraFeaturesUpdatesFactory {
continue;
}
}
if (SharedStudioUtils.isSharedStudioMode() && !factory.isSupportSharedMode()) {
continue;
}
try {
factory.setCheckUpdateOnLine(isCheckUpdateOnLine);
factory.retrieveUninstalledExtraFeatures(monitor, uninstalledExtraFeatures);

View File

@@ -165,5 +165,9 @@ public abstract class AbstractExtraUpdatesFactory implements IUpdatesFactory {
public void setCheckUpdateOnLine(boolean isCheckUpdateOnLine) {
this.isCheckUpdateOnLine = isCheckUpdateOnLine;
}
public boolean isSupportSharedMode() {
return false;
}
}

View File

@@ -98,4 +98,8 @@ public class PluginOptionalMissingJarsExtraUpdatesFactory extends AbstractExtraU
}
}// else nothing to install so nothing to install ;)
}
public boolean isSupportSharedMode() {
return true;
}
}

View File

@@ -88,5 +88,8 @@ public class PluginRequiredMissingJarsExtraUpdatesFactory extends AbstractExtraU
}
}
public boolean isSupportSharedMode() {
return true;
}
}

View File

@@ -18,7 +18,6 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.eclipse.core.runtime.Platform;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.utils.resource.FileExtensions;
@@ -28,8 +27,8 @@ import org.talend.core.ui.IInstalledPatchService;
import org.talend.updates.runtime.utils.PathUtils;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -37,7 +36,7 @@ public class SharedStudioPatchInfoProvider {
private static final String INSTALLED_PATCH_RECORD_FILE = "installed_patch.json";
private static final String PATCH_TYPE_STUDIO = "studio";
static final String PATCH_TYPE_STUDIO = "studio";
private static final String PATCH_TYPE_CAR = "car";
@@ -94,13 +93,11 @@ public class SharedStudioPatchInfoProvider {
public File getNeedInstallStudioPatchFiles() {
File patchFolder = PathUtils.getPatchesFolder();
String patchName = getStudioInstalledLatestPatch();
String patchName = getStudioInstalledLatestPatchFileName();
if (patchFolder.exists() && patchFolder.isDirectory() && patchName != null) {
for (File file : patchFolder.listFiles()) {
if (file.getName().startsWith(patchName) && file.getName().endsWith(FileExtensions.ZIP_FILE_SUFFIX)
&& !isInstalled(file.getName(), PATCH_TYPE_STUDIO)) {
return file;
}
File patchFile = new File (patchFolder, patchName);
if (patchFile.exists() && !isInstalled(patchFile.getName(), PATCH_TYPE_STUDIO)) {
return patchFile;
}
}
return null;
@@ -119,13 +116,17 @@ public class SharedStudioPatchInfoProvider {
return files;
}
private String getStudioInstalledLatestPatch() {
public String getStudioInstalledLatestPatchFileName() {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IInstalledPatchService.class)) {
IInstalledPatchService installedPatchService = GlobalServiceRegister.getDefault()
.getService(IInstalledPatchService.class);
MavenArtifact artifact = installedPatchService.getLastIntalledP2Patch();
if (artifact != null) {
return artifact.getArtifactId();
String artifactId = artifact.getArtifactId();
if (!artifactId.endsWith(FileExtensions.ZIP_EXTENSION)) {
return artifactId + "." + FileExtensions.ZIP_EXTENSION;
}
return artifactId;
}
}
return null;

View File

@@ -143,5 +143,18 @@ public class UpdateService implements IUpdateService {
}
return isNeedRestart;
}
@Override
public String getSharedStudioMissingPatchVersion() {
File patchFolder = PathUtils.getPatchesFolder();
String patchFileName = SharedStudioPatchInfoProvider.getInstance().getStudioInstalledLatestPatchFileName();
if (patchFileName != null && !SharedStudioPatchInfoProvider.getInstance().isInstalled(patchFileName, SharedStudioPatchInfoProvider.PATCH_TYPE_STUDIO)) {
File studioPatchFile = new File (patchFolder, patchFileName);
if (studioPatchFile != null && !studioPatchFile.exists()) {
return patchFileName;
}
}
return null;
}
}

View File

@@ -13,8 +13,21 @@
package org.talend.designer.maven.tools.creator;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.maven.model.Dependency;
import org.junit.Test;
import org.mockito.Mockito;
import org.talend.designer.runprocess.IProcessor;
/*
* Created by bhe on May 9, 2020
@@ -41,4 +54,85 @@ public class CreateMavenJobPomTest {
}
@Test
public void testIsLatestVersionOrLowerVersionInChildJob() {
CreateMavenJobPom createMavenJobPom = new CreateMavenJobPom(Mockito.mock(IProcessor.class), null);
String httpcomponents = "org.apache.httpcomponents";
String httpclient = "httpclient";
String httpcore = "httpcore";
Dependency depdencyClient4505 = toDepdency(new String[] { httpcomponents, httpclient, "4.5.5" });
Dependency depdencyClient4510 = toDepdency(new String[] { httpcomponents, httpclient, "4.5.10"});
Dependency depdencyClient4512 = toDepdency(new String[]{ httpcomponents, httpclient, "4.5.12"});
Dependency depdencyCore4403 = toDepdency(new String[]{ httpcomponents, httpcore, "4.4.3"});
Dependency depdencyCore4409 = toDepdency(new String[]{ httpcomponents, httpcore, "4.4.9"});
Dependency depdencyCore4413 = toDepdency(new String[]{ httpcomponents, httpcore, "4.4.13"});
// only one parent job,has no duplicated dependencies
Map<String, Set<Dependency>> childJobDependencies = new HashMap<String, Set<Dependency>>(2);
List<Dependency> depList = Arrays.asList(depdencyClient4505,depdencyCore4409);
Set<Dependency> parentJobDependencies = new HashSet<Dependency>(depList);
Map<String, Set<Dependency>> duplicateLibs = new HashMap<String, Set<Dependency>>();
fillDuplicateLibs(createMavenJobPom, duplicateLibs, parentJobDependencies);
// only one job, no children, has not duplicated dependencies
for(Dependency dep:parentJobDependencies) {
assertTrue(createMavenJobPom
.isLatestVersionOrLowerVersionInChildJob(parentJobDependencies, childJobDependencies, duplicateLibs, dep));
}
// only one job, no children, has duplicated dependencies
depList = Arrays.asList(depdencyClient4505,depdencyClient4512,depdencyCore4409,depdencyCore4413);
parentJobDependencies = new HashSet<Dependency>(depList);
fillDuplicateLibs(createMavenJobPom, duplicateLibs, parentJobDependencies);
for(Dependency dep:parentJobDependencies) {
if("4.5.5".equals(dep.getVersion()) || "4.4.9".equals(dep.getVersion())) {
assertFalse(createMavenJobPom
.isLatestVersionOrLowerVersionInChildJob(parentJobDependencies, childJobDependencies, duplicateLibs, dep));
} else {
assertTrue(createMavenJobPom
.isLatestVersionOrLowerVersionInChildJob(parentJobDependencies, childJobDependencies, duplicateLibs, dep));
}
}
// parent job, with children, has duplicated dependencies
duplicateLibs.clear();
depList = Arrays.asList(depdencyClient4512, depdencyCore4413);
parentJobDependencies = new HashSet<Dependency>(depList);
fillDuplicateLibs(createMavenJobPom, duplicateLibs, Arrays.asList(depdencyClient4505, depdencyClient4510,
depdencyClient4512, depdencyCore4403, depdencyCore4409, depdencyCore4413));
childJobDependencies.put("childrenstr1", new HashSet<Dependency>(Arrays.asList(depdencyClient4505,depdencyClient4510,depdencyCore4403)));
childJobDependencies.put("childrenstr2", new HashSet<Dependency>(Arrays.asList(depdencyClient4505,depdencyCore4403,depdencyCore4409)));
for(Dependency dep:Arrays.asList(depdencyClient4512,depdencyCore4413,depdencyClient4505, depdencyClient4510,depdencyCore4403,depdencyCore4409)) {
assertTrue(createMavenJobPom
.isLatestVersionOrLowerVersionInChildJob(parentJobDependencies, childJobDependencies, duplicateLibs, dep));
}
}
private void fillDuplicateLibs(CreateMavenJobPom createMavenJobPom, Map<String, Set<Dependency>> duplicateLibs,
Collection<Dependency> fromJobDependencies) {
for (Dependency dep : fromJobDependencies) {
String coordinate = createMavenJobPom.getCoordinate(dep.getGroupId(), dep.getArtifactId(), dep.getType(), null,
dep.getClassifier());
Set<Dependency> dependencys = duplicateLibs.get(coordinate);
if (dependencys == null) {
dependencys = new HashSet<Dependency>();
duplicateLibs.put(coordinate, dependencys);
}
dependencys.add(dep);
}
}
private Dependency toDepdency(String[] deparr) {
Dependency dep = new Dependency();
dep.setGroupId(deparr[0]);
dep.setArtifactId(deparr[1]);
dep.setVersion(deparr[2]);
if (deparr.length == 4) {
dep.setClassifier(deparr[3]);
}
return dep;
}
}

View File

@@ -1,12 +1,85 @@
<?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.librariesmanager.test</artifactId>
<packaging>eclipse-plugin</packaging>
</project>
<?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.librariesmanager.test</artifactId>
<packaging>eclipse-plugin</packaging>
<dependencies>
<dependency>
<groupId>org.talend.studio.test</groupId>
<artifactId>nexus.upload.test.new</artifactId>
<version>1.0.0</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.talend.studio.test</groupId>
<artifactId>nexus.upload.test.new</artifactId>
<version>1.0.0</version>
<type>dll</type>
</dependency>
<dependency>
<groupId>org.talend.studio.test</groupId>
<artifactId>nexus.upload.test.new</artifactId>
<version>1.0.0</version>
<type>exe</type>
</dependency>
<dependency>
<groupId>org.talend.studio.test</groupId>
<artifactId>nexus.upload.test.new</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.talend.studio.test</groupId>
<artifactId>nexus.upload.test.old</artifactId>
<version>1.0.0</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.talend.studio.test</groupId>
<artifactId>nexus.upload.test.old</artifactId>
<version>1.0.0</version>
<type>dll</type>
</dependency>
<dependency>
<groupId>org.talend.studio.test</groupId>
<artifactId>nexus.upload.test.old</artifactId>
<version>1.0.0</version>
<type>exe</type>
</dependency>
<dependency>
<groupId>org.talend.studio.test</groupId>
<artifactId>nexus.upload.test.old</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>generate-sources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>org.talend.studio.test</includeGroupIds>
<copyPom>true</copyPom>
<includeArtifactIdIds>nexus.upload.test.old,nexus.upload.test.new</includeArtifactIdIds>
<excludeTransitive>true</excludeTransitive>
<outputDirectory>${project.basedir}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,5 @@
rep.create.endpoint=/service/rest/v1/repositories/maven/hosted
rep.list.endpoint=/service/rest/v1/repositories/maven/hosted/{repid}
component.search.endpoint=/service/rest/v1/search
component.delete.endpoint=/service/rest/v1/components/{id}
component.upload.command=curl -v -u {user}:{password} -X POST \"{server}/service/rest/v1/components?repository={repid}\" -F maven2.groupId={groupid} -F maven2.artifactId={artifactid} -F maven2.version={version} -F maven2.asset1=@{filepath} -F maven2.asset1.extension={fileext}

View File

@@ -0,0 +1,18 @@
{
"name": "NEWREPNAME",
"online": true,
"storage": {
"blobStoreName": "default",
"strictContentTypeValidation": false,
"writePolicy": "ALLOW"
},
"cleanup": {
"policyNames": [
"string"
]
},
"maven": {
"versionPolicy": "NEWVERSIONPOLICY",
"layoutPolicy": "STRICT"
}
}

View File

@@ -12,17 +12,72 @@
// ============================================================================
package org.talend.librariesmanager.nexus;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.List;
import java.util.Properties;
import org.apache.commons.codec.digest.DigestUtils;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
import org.talend.core.nexus.ArtifactRepositoryBean;
import org.talend.core.nexus.IRepositoryArtifactHandler;
import org.talend.core.nexus.NexusServerUtils;
import org.talend.core.nexus.RepositoryArtifactHandlerManager;
import org.talend.core.nexus.TalendMavenResolver;
import org.talend.core.nexus.ArtifactRepositoryBean.NexusType;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.core.runtime.maven.MavenArtifact;
import org.talend.core.runtime.maven.MavenUrlHelper;
import org.talend.librariesmanager.model.service.LocalLibraryManager;
import org.talend.librariesmanager.nexus.utils.NexusServerManagerProxy;
import org.talend.librariesmanager.nexus.utils.RestAPIUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
/**
* created by wchen on Aug 18, 2017 Detailled comment
*
*/
public class Nexus3RepositoryHandlerTest {
private static Properties nexusprops = new Properties();
private static ArtifactRepositoryBean customNexusServer;
private static IRepositoryArtifactHandler repHandler;
private static String[] types = new String[] {"jar", "pom", "exe", "zip", "dll"};
@BeforeClass
public static void init() throws FileNotFoundException, IOException {
URL entry = Platform.getBundle("org.talend.librariesmanager.test").getEntry("resources/nexus/nexus3.properties");
nexusprops.load(new FileInputStream(FileLocator.toFileURL(entry).getFile()));
customNexusServer = NexusServerManagerProxy.getInstance().getCustomNexusServer();
repHandler = RepositoryArtifactHandlerManager.getRepositoryHandler(customNexusServer);
createNexusRepository(customNexusServer.getRepositoryId(),"RELEASE");
createNexusRepository(customNexusServer.getSnapshotRepId(),"SNAPSHOT");
}
@Test
public void testGetRepositoryURL() {
ArtifactRepositoryBean serverBean = new ArtifactRepositoryBean();
@@ -37,5 +92,329 @@ public class Nexus3RepositoryHandlerTest {
String snapshotUrl = handler.getRepositoryURL(false);
Assert.assertEquals("http://localhost:8081/repository/snapshot-repository/", snapshotUrl);
}
@Test
public void testCheckConnectionOK() {
Assert.assertTrue(repHandler.checkConnection());
}
@Test
public void testCheckConnectionFalse() {
ArtifactRepositoryBean dummyNexusServer = NexusServerManagerProxy.getInstance().getDummyNexusServer();
IRepositoryArtifactHandler repHandler = RepositoryArtifactHandlerManager.getRepositoryHandler(dummyNexusServer);
Assert.assertFalse(repHandler.checkConnection());
}
@Test
public void testDeployOnSnapshot() throws Exception {
for ( String type : types ) {
String uri = "mvn:org.talend.libraries/test/6.0.0-SNAPSHOT/" + type;
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(uri);
try {
clearLocalFile(uri);
Bundle bundle = Platform.getBundle("org.talend.librariesmanager.test");
URL entry = bundle.getEntry("/lib/nexus.upload.test.old-1.0.0." + type);
File originalJarFile = new File(FileLocator.toFileURL(entry).getFile());
String originalSHA1 = getSha1(originalJarFile);
// deploy the file to nexus
repHandler.deploy(originalJarFile, artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), type, artifact.getVersion());
File reolved = repHandler.resolve(artifact);
assertEquals(originalSHA1,getSha1(reolved));
} finally {
deleteNexusArtifact(artifact, false, true);
}
}
}
@Test
public void testDeployOnRelease() throws Exception {
for ( String type : types ) {
String uri = "mvn:org.talend.libraries/test/6.0.0/" + type ;
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(uri);
try {
clearLocalFile(uri);
Bundle bundle = Platform.getBundle("org.talend.librariesmanager.test");
URL entry = bundle.getEntry("/lib/nexus.upload.test.old-1.0.0." + type);
File originalJarFile = new File(FileLocator.toFileURL(entry).getFile());
String originalSHA1 = getSha1(originalJarFile);
// deploy file to nexus
repHandler.deploy(originalJarFile, artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), type , artifact.getVersion());
File resolved = repHandler.resolve(artifact);
assertEquals(originalSHA1,getSha1(resolved));
} finally {
deleteNexusArtifact(artifact, true, true);
}
}
}
@Test
public void testUpdateOnSnapshot() throws Exception {
for ( String type : types ) {
String uri = "mvn:org.talend.libraries/test/6.0.0-SNAPSHOT/" + type ;
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(uri);
try {
clearLocalFile(uri);
Bundle bundle = Platform.getBundle("org.talend.librariesmanager.test");
URL entry = bundle.getEntry("/lib/nexus.upload.test.old-1.0.0." + type);
File originalJarFile = new File(FileLocator.toFileURL(entry).getFile());
entry = bundle.getEntry("/lib/nexus.upload.test.new-1.0.0." + type);
File newJarFile = new File(FileLocator.toFileURL(entry).getFile());
String originalSHA1 = getSha1(originalJarFile);
String newJarSHA1 = getSha1(newJarFile);
// deploy original jar without resolving
repHandler.deploy(originalJarFile, artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), type, artifact.getVersion());
//deploy new jar
repHandler.deploy(newJarFile, artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), type, artifact.getVersion());
//resolve and check the local file
File resolved = repHandler.resolve(artifact);
assertEquals(newJarSHA1,getSha1(resolved));
} finally {
deleteNexusArtifact(artifact, false, true);
}
}
}
@Test
public void testResolveSha1NotExist() throws Exception {
String uri = "mvn:org.talend.libraries/not-existing/6.0.0-SNAPSHOT/jar";
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(uri);
try {
File f = repHandler.resolve(artifact);
assertNull(f);
} catch (FileNotFoundException fnfe) {
//It is one expected exception.
return;
}
}
@Test
public void testSearchOnRelease() throws Exception {
for (String type: types) {
String uri = "mvn:org.talend.libraries/test/6.0.0/" + type;
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(uri);
try {
//Step1:Prepare the installed artifact
Bundle bundle = Platform.getBundle("org.talend.librariesmanager.test");
final URL entry = bundle.getEntry("/lib/nexus.upload.test.old-1.0.0." + type);
File fileToBeInstalled = new File(FileLocator.toFileURL(entry).getFile());
//Step2:Search empty
List<MavenArtifact> searchRet = repHandler.search(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), true, false);
if ( searchRet != null && searchRet.size() > 0 ) {
Assert.fail("The artifact:" + uri + " is not expected to intalled before the test");
}
//Step3:Deploy the artifact
repHandler.deploy(fileToBeInstalled, artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifact.getType(), artifact.getVersion());
//Step4:Verify the search result
searchRet = repHandler.search(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), true, false);
int i = 30;
while ( searchRet.size() < 1 && i > 0 ) {
Thread.sleep(1000);
searchRet = repHandler.search(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), true, false);
i--;
}
if (NexusServerUtils.IGNORED_TYPES.contains(type)) {
assertEquals("Should get 0 artifact when searching for ignored type of " + uri , 0, searchRet.size());
} else {
assertEquals("Should get 1 artifact when searching for " + uri , 1, searchRet.size());
assertEquals(artifact.getArtifactId(), searchRet.get(0).getArtifactId());
assertEquals(artifact.getGroupId(), searchRet.get(0).getGroupId());
assertEquals(artifact.getVersion(), searchRet.get(0).getVersion());
assertEquals(artifact.getClassifier(), searchRet.get(0).getClassifier());
assertEquals(artifact.getType(), searchRet.get(0).getType());
}
} finally {
deleteNexusArtifact(artifact, true, true);
Thread.sleep(1000);
}
}
}
@Test
public void testSearchOnSnapshot() throws Exception {
String uri = "mvn:org.talend.libraries/test/6.0.0-SNAPSHOT/jar";
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(uri);
try {
//Step1:Prepare the installed artifact
Bundle bundle = Platform.getBundle("org.talend.librariesmanager.test");
final URL entry = bundle.getEntry("/lib/nexus.upload.test.old-1.0.0.jar");
File fileToBeInstalled = new File(FileLocator.toFileURL(entry).getFile());
//Step2:Search empty
List<MavenArtifact> searchRet = repHandler.search(artifact.getGroupId(), artifact.getArtifactId(), null, false, true);
if ( searchRet != null && searchRet.size() > 0 ) {
Assert.fail("The artifact is not expected to intalled before the test");
}
//Step3:Deploy the artifact
repHandler.deploy(fileToBeInstalled, artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), "jar", artifact.getVersion());
//Step4:Verify the search result
//In snapshot repository, Timestamp is added in item version like 6.0.0-20201102.054042-1,
//the search result for given version like 6.0.0 will be empty. Currently the version will not be given in search criteria.
searchRet = repHandler.search(artifact.getGroupId(), artifact.getArtifactId(), null, false, true);
int i = 30;
while ( searchRet.size() < 1 && i > 0 ) {
Thread.sleep(1000);
searchRet = repHandler.search(artifact.getGroupId(), artifact.getArtifactId(), null, false, true);
i--;
}
debug("testSearchSnapshot:" + searchRet);
assertEquals(1, searchRet.size());
assertEquals(artifact.getArtifactId(), searchRet.get(0).getArtifactId());
assertEquals(artifact.getGroupId(), searchRet.get(0).getGroupId());
//assertEquals(artifact.getVersion(), searchRet.get(0).getVersion());
assertEquals(artifact.getClassifier(), searchRet.get(0).getClassifier());
assertEquals(artifact.getType(), searchRet.get(0).getType());
} finally {
deleteNexusArtifact(artifact, false, true);
Thread.sleep(1000);
}
}
@Test
public void testPaginationSearchOnSnapshot() throws Exception {
//Pagination is enabled by Nexus when a search returns 50 results
String uri = "mvn:org.talend.libraries/test/6.0.0-SNAPSHOT/zip";
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(uri);
List<MavenArtifact> searchRet = new ArrayList<MavenArtifact>();
try {
//Step1:Prepare the installed artifact
Bundle bundle = Platform.getBundle("org.talend.librariesmanager.test");
final URL entry = bundle.getEntry("/lib/nexus.upload.test.old-1.0.0.zip");
File fileToBeInstalled = new File(FileLocator.toFileURL(entry).getFile());
//Step2:Deploy the artifacts for 101 times on snapshot repository .
int i = 51;
while ( i> 0 ) {
repHandler.deploy(fileToBeInstalled, artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), "zip", artifact.getVersion());
i--;
}
//Step3:Verify the search result. It will take some time for the deployment and wait for most 60 seconds
searchRet = repHandler.search(artifact.getGroupId(), artifact.getArtifactId(), null, false, true);
i = 6;
while ( searchRet.size() < 51 && i > 0 ) {
Thread.sleep(10000);
searchRet = repHandler.search(artifact.getGroupId(), artifact.getArtifactId(), null, false, true);
i--;
}
assertEquals(51, searchRet.size());
} finally {
deleteNexusArtifacts(searchRet, false, true);
}
}
//@Test
public void testUpdateMavenResolver() throws InvalidSyntaxException, IOException {
Dictionary<String, String> props = new Hashtable<String, String>();
props.put("org.ops4j.pax.url.mvn.socket.readTimeout", "59");
props.put("org.ops4j.pax.url.mvn.socket.connectionTimeout", "119");
repHandler.updateMavenResolver(TalendMavenResolver.TALEND_ARTIFACT_LIBRARIES_RESOLVER, props);
BundleContext context = CoreRuntimePlugin.getInstance().getBundle().getBundleContext();
ServiceReference ca = context.getServiceReference(ConfigurationAdmin.class);
debug("" + ca);
ConfigurationAdmin configAdmin = (ConfigurationAdmin) context.getService(ca);
if ( configAdmin == null ) {
Configuration conf = configAdmin.getConfiguration("(service.pid=org.ops4j.pax.url.mvn)");
assertEquals("59", conf.getProperties().get("org.ops4j.pax.url.mvn.socket.readTimeout"));
assertEquals("119", conf.getProperties().get("org.ops4j.pax.url.mvn.socket.connectionTimeout"));
}
}
@Before
@After
public void cleanup() {
try {
String uri = "mvn:org.talend.libraries/test/6.0.0-SNAPSHOT/jar";
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(uri);
List<MavenArtifact> searchRet = repHandler.search(artifact.getGroupId(), artifact.getArtifactId(), null, false, true);
deleteNexusArtifacts(searchRet,false,true);
uri = "mvn:org.talend.libraries/test/6.0.0/jar";
artifact = MavenUrlHelper.parseMvnUrl(uri);
searchRet = repHandler.search(artifact.getGroupId(), artifact.getArtifactId(), null, true, false);
deleteNexusArtifacts(searchRet,true,true);
} catch ( Exception ex ) {
}
}
private void clearLocalFile(String uri) {
LocalLibraryManager localLibraryManager = new LocalLibraryManager();
String localJarPath = localLibraryManager.getJarPathFromMaven(uri);
debug("localJarPath:" + localJarPath);
// force to delete the file to have a valid test
if (localJarPath != null) {
org.talend.utils.io.FilesUtils.deleteFolder(new File(localJarPath).getParentFile().getParentFile(), true);
}
// file should not exist anymore
assertNull(localLibraryManager.getJarPathFromMaven(uri));
}
private static void createNexusRepository(String repId,String versionPolicy) throws IOException {
if (!"SNAPSHOT".equalsIgnoreCase(versionPolicy) && !"RELEASE".equalsIgnoreCase(versionPolicy)) {
Assert.fail("Repository Version Policy must be SNAPSHOT OR RELEASE, but got " + versionPolicy);
}
String getstmt = customNexusServer.getServer() +
nexusprops.getProperty("rep.list.endpoint").replace("{repid}", repId);
try {
String[] response = RestAPIUtil.doRequest(getstmt, "GET", customNexusServer.getUserName(), customNexusServer.getPassword(), null);
if ( response[0].equals("200")) return;
} catch (Exception ex ) {
//Can not find and will create a new one
debug("Can not find the repository named as " + repId + " and will create a new one :" + ex.getMessage());
}
String createstmt = customNexusServer.getServer() + nexusprops.getProperty("rep.create.endpoint");
String jsonfilepath = FileLocator.toFileURL(Platform.getBundle("org.talend.librariesmanager.test").getEntry("resources/nexus/nexus3_create_rep.json")).getFile();
String data = new String(Files.readAllBytes(new File(jsonfilepath).toPath())).replace("NEWREPNAME", repId).replace("NEWVERSIONPOLICY", versionPolicy.toUpperCase());
try {
String[] response = RestAPIUtil.doRequest(createstmt, "POST", customNexusServer.getUserName(), customNexusServer.getPassword(), data);
if ( response[0].equals("201")) debug("Created the test repository successfully!");
} catch (Exception ex ) {
debug("Exception when create the repository of " + repId + ":" + ex );
}
}
private static void deleteNexusArtifacts( List<MavenArtifact> artifacts,boolean isRelease, boolean skiperror) throws Exception{
if (artifacts == null) return;
for (MavenArtifact artifact : artifacts) {
deleteNexusArtifact(artifact,isRelease,skiperror);
}
}
private static void deleteNexusArtifact(MavenArtifact artifact, boolean fromRelease, boolean skiperror) throws Exception {
try {
StringBuffer searchstmt = new StringBuffer();
searchstmt.append(customNexusServer.getServer())
.append(nexusprops.getProperty("component.search.endpoint"))
.append("?repository=").append( fromRelease ? customNexusServer.getRepositoryId() : customNexusServer.getSnapshotRepId())
.append("&group=").append(artifact.getGroupId())
.append("&name=").append(artifact.getArtifactId());
if ( !artifact.getVersion().endsWith(MavenUrlHelper.VERSION_SNAPSHOT))
searchstmt.append("&version=").append(artifact.getVersion());
String[] resp = RestAPIUtil.doRequest(searchstmt.toString(), "GET", customNexusServer.getUserName(), customNexusServer.getPassword(), null);
if ( !resp[0].equals("200")) return;
JSONObject obj = JSONObject.fromObject(resp[1]);
JSONArray items = obj.getJSONArray("items");
if ( items.size() < 1) return;
JSONObject item = (JSONObject) items.get(0);
String componentid = item.getString("id");
String deltestmt = customNexusServer.getServer() + nexusprops.getProperty("component.delete.endpoint").replace("{id}", componentid);
RestAPIUtil.doRequest(deltestmt, "DELETE", customNexusServer.getUserName(), customNexusServer.getPassword(), null);
} catch (Exception ex) {
if (!skiperror) throw ex;
}
}
private String getSha1(File file) throws IOException {
FileInputStream fis = new FileInputStream(file);
String sha1 = DigestUtils.shaHex(fis);
fis.close();
return sha1;
}
private String getSha1(String file) throws IOException {
return getSha1(new File(file));
}
private static void debug(String message) {
System.out.println("[DEBUG]:" + message);
}
}

View File

@@ -0,0 +1,52 @@
package org.talend.librariesmanager.nexus.utils;
import java.util.Properties;
import org.talend.core.nexus.ArtifactRepositoryBean;
import org.talend.core.nexus.IRepositoryArtifactHandler;
import org.talend.core.nexus.RepositoryArtifactHandlerManager;
public class NexusServerManagerProxy {
private static String NEXUS_USER = "nexus.user";
private static String NEXUS_PASSWORD = "nexus.password";
private static String NEXUS_URL = "nexus.url";
private static String NEXUS_LIB_REPO = "nexus.lib.repo";
private static String NEXUS_LIB_SNAPSHOT_REPO = "nexus.lib.repo.snapshot";
private static String DEFAULT_LIB_REPO = "rep-for-test-releases";
private static String DEFAULT_LIB_SNAPSHOT_REPO = "rep-for-test-snapshots";
private static String NEXUS_LIB_SERVER_TYPE = "nexus.lib.server.type";
private static Properties props;
private static NexusServerManagerProxy manager = null;
public static synchronized NexusServerManagerProxy getInstance() {
if (manager == null) {
manager = new NexusServerManagerProxy();
}
return manager;
}
public ArtifactRepositoryBean getCustomNexusServer() {
String nexus_url = System.getProperty(NEXUS_URL);
String nexus_user = System.getProperty(NEXUS_USER);
String nexus_pass = System.getProperty(NEXUS_PASSWORD);
String repositoryId = System.getProperty(NEXUS_LIB_REPO, DEFAULT_LIB_REPO);
String snapshotRepId = System.getProperty(NEXUS_LIB_SNAPSHOT_REPO, DEFAULT_LIB_SNAPSHOT_REPO);
String serverType = System.getProperty(NEXUS_LIB_SERVER_TYPE, "NEXUS_3");
ArtifactRepositoryBean serverBean = new ArtifactRepositoryBean();
serverBean.setServer(nexus_url);
serverBean.setUserName(nexus_user);
serverBean.setPassword(nexus_pass);
serverBean.setRepositoryId(repositoryId);
serverBean.setSnapshotRepId(snapshotRepId);
serverBean.setType(serverType);
return serverBean;
}
public ArtifactRepositoryBean getDummyNexusServer() {
ArtifactRepositoryBean serverBean = getCustomNexusServer();
serverBean.setServer("http://localhost:0000");
return serverBean;
}
}

View File

@@ -0,0 +1,57 @@
package org.talend.librariesmanager.nexus.utils;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
public class RestAPIUtil {
public static String[] doRequest(String uri, String httpmethod, String user, String password, String data)
throws Exception {
String[] ret = new String[2];
StringBuffer response = new StringBuffer();
URL url = new URL(uri);
String auth = user + ":" + password;
try {
byte[] encodedAuth = Base64.getEncoder().encode((auth.getBytes(StandardCharsets.UTF_8)));
String authHeaderValue = "Basic " + new String(encodedAuth);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("Authorization", authHeaderValue);
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestMethod(httpmethod);
if (data != null) {
conn.setDoOutput(true);
conn.setDoInput(true);
conn.connect();
try (OutputStreamWriter streamWriter = new OutputStreamWriter(conn.getOutputStream());) {
streamWriter.write(data);
streamWriter.flush();
}
}
int responsecode = conn.getResponseCode();
debug(responsecode + " is returned for " + httpmethod + " on the endpoint:" + uri);
ret[0] = Integer.toString(responsecode);
try (BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"))) {
String responseLine = null;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
}
ret[1] = response.toString();
conn.disconnect();
} catch (Exception ex) {
debug(ex.getMessage());
throw ex;
}
return ret;
}
private static void debug(String message) {
System.out.println("[DEBUG]:" + message);
}
}

View File

@@ -0,0 +1,32 @@
package org.talend.librariesmanager.nexus.utils;
import org.junit.Assert;
import org.junit.Test;
public class ShareLibrariesUtilTest {
@Test
public void testGetMavenClassifier() {
String path = "javax/xml/bind/acxb-test/2.2.6/acxb-test-2.2.6-jdk10.dll";
String classifier = ShareLibrariesUtil.getMavenClassifier(path, "acxb-test-2.2.6", "dll");
Assert.assertEquals(classifier, "jdk10");
//
String path1 = "org/talend/libraries/aa/6.0.0-SNAPSHOT/aa-6.0.0-20201027.064528-1.dll";
String classifier1 = ShareLibrariesUtil.getMavenClassifier(path1, "aa-6.0.0-SNAPSHOT", "dll");
Assert.assertNull(classifier1);
String path2 = "org/talend/libraries/ldapjdk/6.0.0/ldapjdk-6.0.0-jdk9.dll";
String classifier2 = ShareLibrariesUtil.getMavenClassifier(path2, "ldapjdk-6.0.0", "dll");
Assert.assertEquals(classifier2, "jdk9");
//
String path3 = "org/talend/libraries/acxb-test-2.2.6-jdk8/6.0.0-SNAPSHOT/acxb-test-2.2.6-jdk8-6.0.0-20201103.062422-1.dll";
String classifier3 = ShareLibrariesUtil.getMavenClassifier(path3, "acxb-test-2.2.6-jdk8-6.0.0-SNAPSHOT", "dll");
Assert.assertNull(classifier3);
String path4 = "org/talend/libraries/acxb-test-2.2.6-jdk8/6.0.0-SNAPSHOT/acxb-test-2.2.6-jdk8-6.0.0-SNAPSHOT-jdk8.dll";
String classifier4 = ShareLibrariesUtil.getMavenClassifier(path4, "acxb-test-2.2.6-jdk8-6.0.0-SNAPSHOT", "dll");
Assert.assertEquals(classifier4, "jdk8");
}
}