Compare commits

..

81 Commits

Author SHA1 Message Date
AlixMetivier
82b92d8235 fix(TBD-10269): force return in case of bad job design (#3287) 2020-07-22 10:04:57 +02:00
Jane Ding
7988a67216 Temp tps 3856 (#3421)
* fix(TUP-27078): backport

* fix(TUP-27078): Add query header

Co-authored-by: bhe-talendbj <bhe@talend.com>
2020-06-29 10:57:44 +08:00
Chao MENG
fa698ecb8f feat(TUP-26569): merge known conflicts automatically (#3349) (#3407)
https://jira.talendforge.org/browse/TUP-26569
2020-06-29 10:49:53 +08:00
Jane Ding
847c26163e feat(TUP-16546)Prompt users for new password in Studio Connection when (#3119) (#3377)
* feat(TUP-16546)Prompt users for new password in Studio Connection when
AD/LDAP credentials change in TAC
https://jira.talendforge.org/browse/TUP-16546

* feat(TUP-16546)Prompt users for new password in Studio Connection when
AD/LDAP credentials change in TAC
https://jira.talendforge.org/browse/TUP-16546

* feat(TUP-16546)Prompt users for new password in Studio Connection when
AD/LDAP credentials change in TAC
https://jira.talendforge.org/browse/TUP-16546

* feat(TUP-16546)Prompt users for new password in Studio Connection when
AD/LDAP credentials change in TAC
https://jira.talendforge.org/browse/TUP-16546
2020-06-09 16:47:18 +08:00
Mike Yan
f036f04d6b fix(TESB-28762): Fix ProcessorUtilities methods for isESB condition (#3358) 2020-06-02 11:51:00 +02:00
Chao MENG
34798a9a8e fix(TUP-26189): [7.2.1] snowflake metadata connection with proxy
failure

https://jira.talendforge.org/browse/TUP-26189
2020-05-29 19:32:37 +08:00
kjwang
a9d793685e fix(TUP-26189): [7.2.1] snowflake metadata connection with proxy failure
(#3117)

 fix(TUP-26189): [7.2.1] snowflake metadata connection with proxy
failure

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

Conflicts:
	main/plugins/org.talend.commons.runtime/META-INF/MANIFEST.MF
	main/plugins/org.talend.commons.runtime/src/org/talend/commons/CommonsPlugin.java
	main/plugins/org.talend.core.repository/src/main/java/org/talend/core/repository/model/ProxyRepositoryFactory.java
2020-05-29 17:52:28 +08:00
hzhao-talendbj
e2f2e00405 fix(TUP-26081): Share libraries pb (#3063) (#3138)
* fix(TUP-26081): Share libraries pb

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

* fix(TUP-26081): Share libraries pb

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

Co-authored-by: Chao MENG <cmeng@talend.com>

Conflicts:
	main/plugins/org.talend.librariesmanager/src/main/java/org/talend/librariesmanager/maven/ShareLibrareisHelper.java
2020-05-07 17:17:44 +08:00
kjwang-talend
8ef6c46bc7 Kjwang/fix tup 22469 nexus3.15 2 (#2466) (#2477)
* kjwang/Fix TUP-22469 Nexus3.15: studio can't detect patch for 701/711
release (Add socket time for script handler)
https://jira.talendforge.org/browse/TUP-22469

* kjwang/Fix TUP-22469 Nexus3.15: studio can't detect patch for 701/711
release (Add socket time for script handler)
https://jira.talendforge.org/browse/TUP-22469
2020-05-07 16:50:57 +08:00
kjwang-talend
a7edd1c471 Fix TUP-22469 Nexus3.15: studio can't detect patch for 701/711 release
(#2320) (#2323)

* Fix TUP-22469 Nexus3.15: studio can't detect patch for 701/711 release
https://jira.talendforge.org/browse/TUP-22469

* Fix TUP-22469 Nexus3.15: studio can't detect patch for 701/711 release
https://jira.talendforge.org/browse/TUP-22469

* Fix TUP-22469 Nexus3.15: studio can't detect patch for 701/711 release
https://jira.talendforge.org/browse/TUP-22469

* Fix TUP-22469 Nexus3.15: studio can't detect patch for 701/711 release
https://jira.talendforge.org/browse/TUP-22469

Conflicts:
	main/plugins/org.talend.librariesmanager/src/main/java/org/talend/librariesmanager/nexus/Nexus3RepositoryHandler.java
2020-05-07 16:49:59 +08:00
bhe-talendbj
b4cbfeb54d fix(TUP-26539): backport (#3178) (#3241) 2020-04-27 10:31:32 +08:00
Jane Ding
f58174552c fix(TUP-26165):fix jar with classifier missing issue (#3152) (#3170)
* fix(TUP-26165)jar referenced in bat or sh classpath missing in build
ZIP (#3105)

* fix(TUP-26165)jar referenced in bat or sh classpath missing in build
ZIP
file folder lib
https://jira.talendforge.org/browse/TUP-26165

* fix(TUP-26165)jar referenced in bat or sh classpath missing in build
ZIP
file folder lib
https://jira.talendforge.org/browse/TUP-26165

* fix(TUP-26165)jar referenced in bat or sh classpath missing in build
ZIP
file folder lib
https://jira.talendforge.org/browse/TUP-26165

* fix(TUP-26165)jar referenced in bat or sh classpath missing in build
ZIP
file folder lib
https://jira.talendforge.org/browse/TUP-26165

* fix(TUP-26165)jar referenced in bat or sh classpath missing in build
ZIP
file folder lib
https://jira.talendforge.org/browse/TUP-26165

* fix(TUP-26165):fix jar with classifier missing issue

Co-authored-by: Jane Ding <35018295+jding-tlnd@users.noreply.github.com>

Conflicts:
	main/plugins/org.talend.designer.maven/src/main/java/org/talend/designer/maven/tools/creator/CreateMavenJobPom.java
	main/plugins/org.talend.designer.maven/src/main/java/org/talend/designer/maven/utils/PomUtil.java

Co-authored-by: Zhiwei Xue <zwxue@talend.com>
2020-03-30 12:37:34 +08:00
Chao MENG
99ad2f17cc Cmeng/backport/7.1/tup 24942 sapbapi (#2848)
* fix(TUP-24942): need to do studio metadata mapping to tsapbapi (#2843)

fix(TUP-24942): need to do studio metadata mapping to tsapbapi components for the new closedlist when D&D metadata to job
https://jira.talendforge.org/browse/TUP-24942

* fix(TUP-24942): need to do studio metadata mapping to tsapbapi (#2847)

fix(TUP-24942): need to do studio metadata mapping to tsapbapi components for the new closedlist when D&D metadata to job
https://jira.talendforge.org/browse/TUP-24942
2020-03-16 10:15:39 +08:00
hwang-talend
5bbfa19680 bugfix(TUP-26059):tELTPostgresqlMap lost its "DB Type" column for which (#3075)
bugfix(TUP-26059):tELTPostgresqlMap lost its "DB Type" column for which the value should be "BPCHAR"
2020-03-02 17:02:14 +08:00
hwang
515780f2d5 bugfix(TUP-25472):Schema order changes on tFileOutputDelimited 2020-01-07 18:52:19 +08:00
Chao MENG
9dd923e971 fix(TUP-24749): [7.2.1] issue to download component jar via https proxy 2020-01-03 18:38:59 +08:00
hwang-talend
04071c5a6e bugfix(TUP-23228):The order of schema changed when ticked "used column"
(#2457) (#2919)

* bugfix(TUP-23228):The order of schema changed when ticked "used
column"
again

Conflicts:
	main/plugins/org.talend.core.runtime/src/main/java/org/talend/core/model/metadata/MetadataToolHelper.java
2020-01-03 17:38:01 +08:00
Chao MENG
2b5a8b0013 Cmeng/backport/7.1/tup 24749 proxy issue (#2950)
fix(TUP-24749): [7.2.1] issue to download component jar via https
proxy


Conflicts:
	main/plugins/org.talend.core.runtime/src/main/java/org/talend/core/nexus/TalendMavenResolver.java
	main/plugins/org.talend.librariesmanager/src/main/java/org/talend/librariesmanager/nexus/Nexus3RepositoryHandler.java
2020-01-03 17:31:01 +08:00
bhe-talendbj
e976e88569 backport(TUP-25237) backport (#2903) 2020-01-03 17:24:22 +08:00
Zhiwei Xue
dc76ec5abc fix(TUP-25123):Problem of dependencies with spark joblets (#2823) 2019-11-11 10:55:15 +08:00
SunChaoqun
f095a31ddb TESB-26696:Route - Beans package not visible to test cases (#2810) (#2826) 2019-11-08 21:22:30 +08:00
mbasiuk-talend
e0103990f3 fix(TDI-43035): use only main connection category (#2754) (#2778) (#2783)
* fix(TDI-43035): use only main connection category

* fix(TDI-43035): use better condition to catch the issue
2019-10-25 10:28:06 +08:00
mbasiuk-talend
5125c5fd4f Revert "fix(TDI-43035): use only main connection category (#2754) (#2778) (#2780)" (#2782)
This reverts commit 0d0b7115cf.
2019-10-23 10:02:42 +03:00
mbasiuk-talend
0d0b7115cf fix(TDI-43035): use only main connection category (#2754) (#2778) (#2780)
* fix(TDI-43035): use only main connection category

* fix(TDI-43035): use better condition to catch the issue
2019-10-23 08:03:01 +03:00
Zhiwei Xue
198af206a3 fix(TUP-23637):7.x missing local_project for big data spark batch job (#2604) (#2665) 2019-10-18 18:36:44 +08:00
Jane Ding
74e5446d18 fix(TUP-24735)Studio fails to sync jars with Artifactory if password has (#2756) (#2766) (#2772)
* fix(TUP-24735)Studio fails to sync jars with Artifactory if password has
'@' character in it
https://jira.talendforge.org/browse/TUP-24735

* fix(TUP-24735)Studio fails to sync jars with Artifactory if password has
'@' character in it
https://jira.talendforge.org/browse/TUP-24735

* fix(TUP-24735)Studio fails to sync jars with Artifactory if password has
'@' character in it
https://jira.talendforge.org/browse/TUP-24735
2019-10-18 18:12:17 +08:00
Zhiwei Xue
54825cd3a4 fix(TUP-24310):routines is duplicated in the reactor. 2019-09-27 14:53:03 +08:00
Zhiwei Xue
98a21cde8c fix(TUP-24310):routines is duplicated in the reactor 2019-09-26 10:45:29 +08:00
Zhiwei Xue
203da564ec fix(TUP-24310):routines is duplicated in the reactor (#2706) 2019-09-24 16:46:32 +08:00
kjwang
3093ec65b8 kjwang/Fix TUP-24579 MacOS : unable to access remote project after (#2729)
Fix TUP-24579 MacOS : unable to access remote project after applying TPS-3363
https://jira.talendforge.org/browse/TUP-24579
2019-09-18 18:51:01 +08:00
Mike Yan
013442fe55 fix(TESB-26415): beansType is null with pure DI licence (#2723)
fix(TESB-26415): beansType is null with pure DI licence
2019-09-18 18:23:20 +08:00
Chao MENG
2c0c8e520f Cmeng/bugfix/tup 23914 json wizard encoding (#2628) (#2632)
* fix(TUP-23914): JSON with accented characters is not being recognized
when creating a new JSON file in Metadata.
https://jira.talendforge.org/browse/TUP-23914
2019-09-06 17:24:16 +08:00
SunChaoqun
5638eaed70 TESB-26415:Cannot publish Route with Routelet to snapshots when project
has a ref project defined
2019-09-05 19:12:18 +08:00
Chao MENG
29b496023b fix(TUP-24226): Studio doesn't load latest jar for TCOMPv0 update site patch. (#2676)
fix(TUP-24226): Studio doesn't load latest jar for TCOMPv0 update site patch. 
https://jira.talendforge.org/browse/TUP-24226
2019-08-23 18:14:55 +08:00
Zhiwei Xue
cd50c2af34 fix(TUP-22261):Patch (update site format) with multiple plugins is not
(#2471) (#2473)

installed correctly
2019-08-23 18:10:24 +08:00
SunChaoqun
b7aacc12bf TESB-24354:SFTP proxy bean not recognized in runtime only (#2150) 2019-08-23 11:42:59 +08:00
yanbasic
bb100664ec fix(TESB-26174): Adapted 7.1.1 patch changes with code change only 2019-08-22 16:05:39 +08:00
yanbasic
c27ba5e77e Revert "fix(TESB-26174):tRunJob calling another Child job with tESBConsumer"
This reverts commit afbde0f37d.
2019-08-21 17:41:38 +08:00
jiezhang-tlnd
1046b43f9a fix(TUP-24159)XML metadata wizard showing inconsistent view on V711 (#2668)
comparing with V6 Studio
https://jira.talendforge.org/browse/TUP-24159
2019-08-20 10:50:25 +08:00
jiezhang-tlnd
fb1f5a4d91 fix(TUP-24159)XML metadata wizard showing inconsistent view on V711 (#2653)
(#2651)

comparing with V6 Studio
https://jira.talendforge.org/browse/TUP-24159

Conflicts:
	main/plugins/org.talend.repository.metadata/src/main/java/org/talend/repository/ui/wizards/metadata/connection/files/xml/extraction/XmlToXPathLinker.java
2019-08-16 17:46:08 +08:00
Jane Ding
b3b264f814 fix(TUP-23789)Pom files are not generated sometimes for the jobs in (#2610) (#2616)
* fix(TUP-23789)Pom files are not generated sometimes for the jobs in
7.1.1
https://jira.talendforge.org/browse/TUP-23789

* fix(TUP-23789)Pom files are not generated sometimes for the jobs in
7.1.1
https://jira.talendforge.org/browse/TUP-23789
Add a junit.
2019-08-12 10:49:53 +08:00
yanbasic
afbde0f37d fix(TESB-26174):tRunJob calling another Child job with tESBConsumer 2019-08-06 15:39:33 +08:00
hcyi
5a28edafb9 fix(TUP-23743):ERROR when Job in MDM project calling Job in Reference DI (#2598)
project:import routines.DataQuality cannot be resolved.
2019-08-05 11:06:24 +08:00
Zhiwei Xue
a317993da7 fix(TUP-23755):Regression caused by TUP-21532 for ESB test case (#2580) 2019-07-15 10:22:32 +08:00
hwang-talend
cd075577f8 bugfix(TUP-23230):Guess Schema error - SLF4J: Defaulting to no-operation (#2524)
bugfix(TUP-23230):Guess Schema error - SLF4J: Defaulting to no-operation (NOP) logger implementation
2019-07-15 10:14:37 +08:00
Jane Ding
b3e7571846 Jding/backport64/tup 21086 oracle synonym issue (#2590)
* fix(TUP-21086)Unable to retrieve the schema from Synonym but works fine (#2086) (#2089)

for table
https://jira.talendforge.org/browse/TUP-21086

* fix(TUP-21086)Unable to retrieve the schema from Synonym but works fine (#2098) (#2100)

for table
https://jira.talendforge.org/browse/TUP-21086

* fix(TUP-21086)Unable to retrieve the schema from Synonym but works fine (#2105) (#2108)

for table
https://jira.talendforge.org/browse/TUP-21086
2019-07-15 10:06:31 +08:00
Jane Ding
e830653f54 fix(TUP-22490)Unable to transfer JAR file to Nexsus 3 due to repository (#2514) (#2516)
version policy: SNAPSHOT does not allow version
https://jira.talendforge.org/browse/TUP-22490
2019-07-04 16:47:15 +08:00
Zhiwei Xue
ed9b4a892b fix(TUP-22986):Build jobs doesn't creates the java source file for the (#2518)
child jobs
2019-07-04 16:35:00 +08:00
Zhiwei Xue
56538d2cb5 fix(TUP-23452):set component installation restart. 2019-07-01 12:05:16 +08:00
Jane Ding
97ce93a282 fix(TUP-23452)COMPUTE_DEPENDENCIES_FAILED:{path=META-INF/maven/org.talend.components/components-salesforce-runtime/dependencies.txt (#2555) (#2561)
https://jira.talendforge.org/browse/TUP-23452
2019-07-01 12:00:23 +08:00
SunChaoqun
fbf9db3bbd TESB-25769:[7.1.1 only] Not all bundles available in Nexus when publishing webservice(#2560) 2019-06-26 16:10:53 +08:00
kjwang-talend
853f0f1a63 Fix TUP-23170 New branch with name "/" will lead job with reference (#2489)
joblet build failure (Fix can't clean joblet cache problem)
https://jira.talendforge.org/browse/TUP-23170
2019-06-18 10:23:09 +08:00
kjwang-talend
c8f9544669 Fix TUP-23170 New branch with name "/" will lead job with reference (#2480)
joblet build failure
https://jira.talendforge.org/browse/TUP-23170
2019-06-18 10:22:35 +08:00
nrousseau
12a4d97235 fix(TUP-22906)
Change the fix of TUP-22906, since we can't use FLOW_REF in the
generated code.
Use instead of the run_after to find back original nodes
2019-06-14 17:44:58 +08:00
Chao MENG
72d3007836 fix(TUP-22713): Possible thread lock during git update operation (#2392) (#2395)
fix(TUP-22713): Possible thread lock during git update operation 
https://jira.talendforge.org/browse/TUP-22713
2019-05-31 14:57:25 +08:00
hzhao-talendbj
5e10fa5a9d change from https://www.talend.com to https://talend-update.talend.com (#2410) 2019-05-20 11:21:11 +08:00
Jane Ding
1d70b8cf3c fix(TUP-22681)Job in CI Builder gets generated and deployed, but doesn't (#2373) (#2381)
show as a Tag
https://jira.talendforge.org/browse/TUP-22681
2019-05-13 16:05:58 +08:00
Laurent BOURGEOIS
913513fe52 fix(TBD-8573): new date formats suggestions (#2378) (#2407) 2019-05-10 15:41:25 +02:00
hwang
913bb3fd5e bugfix(TUP-21895):An error has occurred. UNEXPECTED_EXCEPTION when
opening job migrated 6.4.1 to 7.1.1 (job using tJDBCInput)
2019-05-06 17:11:16 +08:00
hwang
6739d5d749 bugfix(TUP-21895):An error has occurred. UNEXPECTED_EXCEPTION when
opening job migrated 6.4.1 to 7.1.1 (job using tJDBCInput)
2019-05-06 15:42:39 +08:00
nrousseau
5029936009 fix(TUP-22735) fix wrong project migrations (#2384) 2019-05-05 11:21:02 +08:00
kjwang-talend
592d61efcb TUP-22281 Missing jar in lib folder for Job Server(Solution 2) (#2318)
https://jira.talendforge.org/browse/TUP-22281
2019-05-05 11:17:17 +08:00
Zhiwei Xue
c990b2f122 Delete PATCH_RELEASE_NOTE.md 2019-04-30 11:50:04 +08:00
Zhiwei Xue
718442e759 Update PATCH_RELEASE_NOTE.md 2019-04-30 10:47:23 +08:00
Zhiwei Xue
e8b24e59bb Add PATCH_RELEASE_NOTE.md 2019-04-29 19:24:52 +08:00
Zhiwei Xue
0983f18746 fix(TUP-22438):Null pointer exception when executing the jobs. (#2327) 2019-04-26 14:56:00 +08:00
Jane Ding
dbb993287f feat(TUP-21495):Support MFA on studio for the Cloud. (#2351) 2019-04-15 18:07:56 +08:00
Jane Ding
891db9df9d fix(TUP-22182)Non-default Artifactory context path, not working (#2338) (#2341)
* fix(TUP-22182)Non-default Artifactory context path, not working
https://jira.talendforge.org/browse/TUP-22182

* fix(TUP-22182)Non-default Artifactory context path, not working
https://jira.talendforge.org/browse/TUP-22182
2019-04-15 10:43:09 +08:00
kjwang-talend
8a761ff57a Kjwang/fix tup 22425 stackoverflow (#2322) (#2326)
* Fix TUP-22425 [7.1.1] Stackoverflow issue in studio
https://jira.talendforge.org/browse/TUP-22425

* Fix TUP-22425 [7.1.1] Stackoverflow issue in studio
https://jira.talendforge.org/browse/TUP-22425
2019-04-08 14:26:31 +08:00
Dmytro Sylaiev
d746cea059 Dsylaiev/tdi 41808 fix showing pass nzload (#2276) (#2280)
* fix(TDI-41808): Add password for logging constant

* fix(TDI-41808): Rename constant

* chore(TDI-41808): Update year in copyright
2019-04-01 15:48:50 +03:00
Zhiwei Xue
2cc77d47d9 fix(TUP-22015):fix thread safe problem. (#2249) 2019-04-01 09:45:45 +08:00
dmytroshekera
168c17d65e fix(TDI-41876):Importing job from 6.2.1 to 7.1.1 is throwing error. (#2310) (#2317)
apache AVRO schema have default values. backport from master
2019-03-29 19:14:01 +08:00
jiezhang-tlnd
d1e8f8d768 fix(TUP-21922)Commit to Git frequently without any user action (#2240) (#2241) 2019-03-25 10:41:30 +08:00
kjwang-talend
9928c659f5 Fix TUP-21498 The port of Sybase did not disyplay right on DI side (#2123) (#2130)
https://jira.talendforge.org/browse/TUP-21498
2019-03-25 10:10:16 +08:00
Zhiwei Xue
23614ad8ad fix(TUP-21999):SAP Hana Metadata Wizard does not work properly (#2274) 2019-03-25 09:46:10 +08:00
hwang-talend
b8fce856e5 bugfix(TUP-21105):tDBConnection(Snowflake) issue within joblet. (#2017) (#2041)
bugfix(TUP-21105):tDBConnection(Snowflake) issue within joblet.
2019-03-11 14:08:07 +08:00
Jane Ding
8ef6ea66d5 fix(TUP-21333)OnSubJob Links Not Working (#2093) (#2128)
https://jira.talendforge.org/browse/TUP-21333
2019-03-11 13:01:29 +08:00
kjwang-talend
25123e63e3 kjwang/Fix TUP-22005 Unexpected Empty Contexts Variable Values (#2262) (#2266)
https://jira.talendforge.org/browse/TUP-22005
2019-03-11 12:49:20 +08:00
Zhiwei Xue
60e25a755b fix(TUP-21871):job run well on studio but failed after build. (#2226) 2019-03-11 10:43:35 +08:00
hwang-talend
121f1198e1 bugfix(TDI-41803):Job migrated from 6.5.1 to 7.1.1 throwing (#2257)
bugfix(TDI-41803):Job migrated from 6.5.1 to 7.1.1 throwing UNEXPECTED_EXCEPTION
2019-03-04 11:20:06 +08:00
kjwang-talend
87e73138e6 Fix TUP-21911 Build job takes about 4 minutes while Run job takes > 40 (#2242) (#2244)
minutes to start
https://jira.talendforge.org/browse/TUP-21911
2019-02-25 19:14:34 +08:00
98 changed files with 2902 additions and 604 deletions

View File

@@ -13,7 +13,9 @@ Require-Bundle: org.apache.log4j;visibility:=reexport,
org.talend.libraries.apache,
org.apache.xerces,
com.ibm.icu,
org.apache.commons.io
org.apache.commons.io,
org.talend.utils,
org.eclipse.core.net
Export-Package: org.talend.commons,
org.talend.commons.exception,
org.talend.commons.i18n,

View File

@@ -17,11 +17,13 @@ import java.io.InputStream;
import java.net.URL;
import org.apache.commons.lang.ArrayUtils;
import org.eclipse.core.net.proxy.IProxyService;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
import org.talend.commons.exception.ExceptionService;
import org.talend.commons.runtime.debug.TalendDebugHandler;
@@ -52,6 +54,8 @@ public class CommonsPlugin implements BundleActivator {
// TESB-17856: For commandline builds ESB Micorservice bundle
private static boolean isESBMicorservice = false;
private static ServiceTracker proxyTracker;
public static boolean isWorkbenchCreated() {
return isWorkbenchCreated;
}
@@ -160,4 +164,13 @@ public class CommonsPlugin implements BundleActivator {
InstanceScope.INSTANCE.getNode("org.eclipse.m2e.core").putBoolean("eclipse.m2.offline", state);
}
public static IProxyService getProxyService() {
if (proxyTracker == null) {
proxyTracker = new ServiceTracker(Platform.getBundle(PLUGIN_ID).getBundleContext(), IProxyService.class.getName(),
null);
proxyTracker.open();
}
return (IProxyService) proxyTracker.getService();
}
}

View File

@@ -0,0 +1,58 @@
// ============================================================================
//
// Copyright (C) 2006-2020 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.commons.exception;
public class ClientException extends PersistenceException {
private Integer httpCode;
public ClientException(String message) {
super(message);
}
public ClientException(Integer httpCode, String message) {
super(message);
this.httpCode = httpCode;
}
public ClientException(String message, Throwable cause) {
super(message, cause);
}
public ClientException(Integer httpCode, String message, Throwable cause) {
super(message, cause);
this.httpCode = httpCode;
}
public ClientException(Throwable cause) {
super(cause);
}
public ClientException(Integer httpCode, Throwable cause) {
super(cause);
this.httpCode = httpCode;
}
public Integer getHttpCode() {
return httpCode;
}
public void setHttpCode(Integer httpCode) {
this.httpCode = httpCode;
}
@Override
public String toString() {
return getLocalizedMessage();
}
}

View File

@@ -58,3 +58,6 @@ AS400ResultSet.unknowCloumn=Invalid argument\: unknown column name
AS400ResultSet.parameterIndex=Invalid argument\: parameter index
AS400ResultSet.outofRange=\ is out of range.
ITaCoKitService.exception.multipleInstance=More than one instance found: {0}
TalendProxySelector.exception.badUriMap=Bad uri map: {0}
TalendProxySelector.exception.proxySelectionError=Error occurs when selecting proxy for {0}

View File

@@ -123,6 +123,10 @@ public class FileCopyUtils {
if (!resFolder.exists()) {
return;
}
if (resFolder.getAbsolutePath().equals(destFolder.getAbsolutePath())) {// If the source path and target path are
// same, don't copy
return;
}
destFolder.mkdirs();
String[] file = resFolder.list();
File temp = null;

View File

@@ -120,33 +120,41 @@ public class SAPHanaDataBaseMetadata extends FakeDatabaseMetaData {
public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types)
throws SQLException {
String[] neededTypes = getNeededTypes(types);
ResultSet rs = connection.getMetaData().getTables(catalog, schemaPattern, tableNamePattern, neededTypes);
List<String[]> list = new ArrayList<String[]>();
while (rs.next()) {
String name = rs.getString("TABLE_NAME"); //$NON-NLS-1$
String schema = rs.getString("TABLE_SCHEM"); //$NON-NLS-1$
String type = rs.getString("TABLE_TYPE"); //$NON-NLS-1$
// has other types which is not Calculation View
if (neededTypes.length > 1 || !ArrayUtils.contains(neededTypes, NEEDED_TYPES[3])) {
ResultSet rs = connection.getMetaData().getTables(catalog, schemaPattern, tableNamePattern, neededTypes);
while (rs.next()) {
String name = rs.getString("TABLE_NAME"); //$NON-NLS-1$
String schema = rs.getString("TABLE_SCHEM"); //$NON-NLS-1$
String type = rs.getString("TABLE_TYPE"); //$NON-NLS-1$
String id = ""; //$NON-NLS-1$
String remarks = ""; //$NON-NLS-1$
try {
remarks = rs.getString("REMARKS"); //$NON-NLS-1$
} catch (Exception e) {
// nothing
}
String id = ""; //$NON-NLS-1$
String remarks = ""; //$NON-NLS-1$
try {
remarks = rs.getString("REMARKS"); //$NON-NLS-1$
} catch (Exception e) {
// nothing
}
if (ArrayUtils.contains(neededTypes, type)) {
// check if the type is contained is in the types needed.
// since sybase can return some system views as "SYSTEM VIEW" instead of "VIEW/TABLE" from the request.
String[] r = new String[] { id, schema, name, type, remarks, null };
list.add(r);
if (ArrayUtils.contains(neededTypes, type)) {
// check if the type is contained is in the types needed.
// since sybase can return some system views as "SYSTEM VIEW" instead of "VIEW/TABLE" from the
// request.
String[] r = new String[] { id, schema, name, type, remarks, null };
list.add(r);
}
}
}
// For Calculation View
if (ArrayUtils.contains(neededTypes, NEEDED_TYPES[3])) {
// check if the type is contained is in the types needed.
String sqlcv = "SELECT CATALOG_NAME,SCHEMA_NAME,CUBE_NAME, COLUMN_OBJECT,CUBE_TYPE,DESCRIPTION from _SYS_BI.BIMC_CUBES"; //$NON-NLS-1$
String sqlcv = "SELECT OBJECT_NAME,PACKAGE_ID FROM _SYS_REPO.ACTIVE_OBJECT WHERE OBJECT_SUFFIX = 'calculationview'"; //$NON-NLS-1$
if (tableNamePattern != null && !tableNamePattern.equals("%")) { //$NON-NLS-1$
sqlcv += " AND (OBJECT_NAME LIKE '" + tableNamePattern + "'"; //$NON-NLS-1$ //$NON-NLS-2$
sqlcv += " OR PACKAGE_ID LIKE '" + tableNamePattern + "')"; //$NON-NLS-1$ //$NON-NLS-2$
}
ResultSet rscv = null;
Statement stmtcv = null;
List<String[]> listcv = new ArrayList<String[]>();
@@ -154,25 +162,16 @@ public class SAPHanaDataBaseMetadata extends FakeDatabaseMetaData {
stmtcv = connection.createStatement();
rscv = stmtcv.executeQuery(sqlcv);
while (rscv.next()) {
String catalogName = rscv.getString("CATALOG_NAME"); //$NON-NLS-1$
if (catalogName != null) {
catalogName = catalogName.trim();
String objectName = rscv.getString("OBJECT_NAME"); //$NON-NLS-1$
if (objectName != null) {
objectName = objectName.trim();
}
String schemaName = rscv.getString("SCHEMA_NAME"); //$NON-NLS-1$
if (schemaName != null) {
schemaName = schemaName.trim();
String packageId = rscv.getString("PACKAGE_ID"); //$NON-NLS-1$
if (packageId != null) {
packageId = packageId.trim();
}
String cubeName = rscv.getString("CUBE_NAME"); //$NON-NLS-1$
if (cubeName != null) {
cubeName = cubeName.trim();
}
String id = ""; //$NON-NLS-1$
// String type = rscv.getString("CUBE_TYPE"); //$NON-NLS-1$
String remarks = rscv.getString("DESCRIPTION"); //$NON-NLS-1$
String name = catalogName + "/" + cubeName;//$NON-NLS-1$
String[] r = new String[] { id, schemaName, name, NEEDED_TYPES[3], remarks, catalogName };
String name = packageId + "/" + objectName; //$NON-NLS-1$
String[] r = new String[] { "", "_SYS_BIC", name, NEEDED_TYPES[3], "", packageId }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
listcv.add(r);
}
} catch (SQLException e) {

View File

@@ -42,13 +42,15 @@ public class NetworkUtil {
private static final String TALEND_DISABLE_INTERNET = "talend.disable.internet";//$NON-NLS-1$
private static final String HTTP_NETWORK_URL = "https://talend-update.talend.com";
public static boolean isNetworkValid() {
String disableInternet = System.getProperty(TALEND_DISABLE_INTERNET);
if ("true".equals(disableInternet)) { //$NON-NLS-1$
return false;
}
try {
URL url = new URL("https://www.talend.com"); //$NON-NLS-1$
URL url = new URL(HTTP_NETWORK_URL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(4000);
conn.setReadTimeout(4000);

View File

@@ -13,37 +13,211 @@
package org.talend.commons.utils.network;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.SocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Priority;
import org.eclipse.core.internal.net.ProxyManager;
import org.eclipse.core.net.proxy.IProxyService;
import org.talend.commons.CommonsPlugin;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.i18n.internal.Messages;
import org.talend.daikon.sandbox.properties.ClassLoaderIsolatedSystemProperties;
import sun.net.spi.DefaultProxySelector;
/**
* DOC cmeng class global comment. Detailled comment
*/
public class TalendProxySelector extends ProxySelector {
public static final String PROP_PRINT_LOGS = "talend.studio.proxy.printLogs";
private static final String ECLIPSE_PROXY_SELECTOR = ".EclipseProxySelector"; //$NON-NLS-1$
private ProxySelector defaultSelector;
private static final String PROP_ALLOW_PROXY_REDIRECT = "talend.studio.proxy.allowProxyRedirect";
final private List<IProxySelectorProvider> selectorProviders;
private static final String PROP_ALLOW_PROXY_REDIRECT_EXCLUDE = "talend.studio.proxy.redirect.whiteList";
private static final String PROP_EXECUTE_CONNECTION_FAILED = "talend.studio.proxy.executeConnectionFailed";
private static final String PROP_UPDATE_SYSTEM_PROPERTIES_FOR_JRE = "talend.studio.proxy.jre.updateSystemProperties";
private static final String PROP_CHECK_PROXY = "talend.studio.proxy.checkProxy";
private static final String PROP_VALIDATE_URI = "talend.studio.proxy.validateUri";
private static final String PROP_PROXY_SELECTOR = "talend.studio.proxy.selector";
private static final String PROP_PROXY_SELECTOR_DEFAULT = "default";
private static final String PROP_PROXY_SELECTOR_JRE = "jre";
private static final String PROP_PROXY_HOST_MAP = "talend.studio.proxy.hostMap";
private static final String PROP_DISABLE_DEFAULT_SELECTOR_PROVIDER = "talend.studio.proxy.disableDefaultSelectorProvider";
/**
* Example: update.talend.com,socket:http,https:http;nexus.talend.com,socket,http;,socket:http
*/
private static final String PROP_PROXY_MAP_HOST_DEFAULT = "";
/**
* Example: svn.company.com;nexus.company.com
*/
private static final String PROP_ALLOW_PROXY_REDIRECT_EXCLUDE_DEFAULT = "";
private static final String KEY_DEFAULT = ":default:";
private static Field uriHostField;
private static Method proxyManagerUpdateSystemPropertiesFunc;
private static boolean checkProxy = Boolean.valueOf(System.getProperty(PROP_CHECK_PROXY, Boolean.TRUE.toString()));
/**
* Note: eclipse default selector may be different between TOS and TIS, TOS may use jre one, TIS may use egit one
*/
private ProxySelector eclipseDefaultSelector;
private ProxySelector jreDefaultSelector;
private EProxySelector eProxySelector;
final private Map<Object, Collection<IProxySelectorProvider>> selectorProviders;
private Map<String, Map<String, String>> hostMap;
private Set<String> redirectWhiteList;
private volatile static TalendProxySelector instance;
private static Object instanceLock = new Object();
private TalendProxySelector(final ProxySelector defaultSelector) {
this.defaultSelector = defaultSelector;
selectorProviders = new ArrayList<>();
private boolean printProxyLog = false;
private boolean allowProxyRedirect = false;
private boolean disableDefaultSelectorProvider = false;
private boolean validateUri = true;
private boolean executeConnectionFailed = true;
private boolean updateSystemPropertiesForJre = true;
private TalendProxySelector(final ProxySelector eclipseDefaultSelector) {
this.eclipseDefaultSelector = eclipseDefaultSelector;
this.jreDefaultSelector = new DefaultProxySelector();
selectorProviders = Collections.synchronizedMap(new HashMap<>());
allowProxyRedirect = Boolean.valueOf(System.getProperty(PROP_ALLOW_PROXY_REDIRECT, Boolean.FALSE.toString()));
disableDefaultSelectorProvider = Boolean
.valueOf(System.getProperty(PROP_DISABLE_DEFAULT_SELECTOR_PROVIDER, Boolean.FALSE.toString()));
printProxyLog = Boolean.valueOf(System.getProperty(PROP_PRINT_LOGS, Boolean.FALSE.toString()));
validateUri = Boolean.valueOf(System.getProperty(PROP_VALIDATE_URI, Boolean.TRUE.toString()));
executeConnectionFailed = Boolean.valueOf(System.getProperty(PROP_EXECUTE_CONNECTION_FAILED, Boolean.TRUE.toString()));
updateSystemPropertiesForJre = Boolean
.valueOf(System.getProperty(PROP_UPDATE_SYSTEM_PROPERTIES_FOR_JRE, Boolean.TRUE.toString()));
switch (System.getProperty(PROP_PROXY_SELECTOR, PROP_PROXY_SELECTOR_DEFAULT).toLowerCase()) {
case PROP_PROXY_SELECTOR_JRE:
this.eProxySelector = EProxySelector.jre;
break;
default:
this.eProxySelector = EProxySelector.eclipse_default;
break;
}
initHostMap();
initRedirectList();
}
private void initHostMap() {
try {
hostMap = new HashMap<>();
String property = System.getProperty(PROP_PROXY_HOST_MAP, PROP_PROXY_MAP_HOST_DEFAULT);
if (StringUtils.isEmpty(property)) {
return;
}
String[] splits = property.split(";");
for (String split : splits) {
try {
int index = split.indexOf(',');
String uri = split.substring(0, index);
String key = StringUtils.strip(uri);
if (StringUtils.isBlank(key)) {
key = KEY_DEFAULT;
}
key = key.toLowerCase();
Map<String, String> protocolMap = hostMap.get(key);
if (protocolMap == null) {
protocolMap = new HashMap<>();
hostMap.put(key, protocolMap);
}
int protocolMapIndex = index + 1;
String protocolMapStr = split.substring(protocolMapIndex);
String[] entry = protocolMapStr.split(",");
for (String pMap : entry) {
try {
String[] mapEntry = pMap.split(":");
if (mapEntry.length != 2) {
ExceptionHandler.process(
new Exception(Messages.getString("TalendProxySelector.exception.badUriMap", pMap)));
continue;
}
protocolMap.put(mapEntry[0].toLowerCase(), mapEntry[1].toLowerCase());
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
private void initRedirectList() {
try {
redirectWhiteList = new HashSet<>();
String property = System.getProperty(PROP_ALLOW_PROXY_REDIRECT_EXCLUDE, PROP_ALLOW_PROXY_REDIRECT_EXCLUDE_DEFAULT);
if (StringUtils.isEmpty(property)) {
return;
}
String[] split = property.split(";");
for (String host : split) {
host = StringUtils.strip(host);
if (StringUtils.isBlank(host)) {
host = KEY_DEFAULT;
}
redirectWhiteList.add(host);
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
public static TalendProxySelector getInstance() {
@@ -58,6 +232,18 @@ public class TalendProxySelector extends ProxySelector {
synchronized (instanceLock) {
if (instance == null) {
instance = new TalendProxySelector(proxySelector);
try {
uriHostField = URI.class.getDeclaredField("host");
uriHostField.setAccessible(true);
} catch (Exception e) {
ExceptionHandler.process(e);
}
try {
proxyManagerUpdateSystemPropertiesFunc = ProxyManager.class.getDeclaredMethod("updateSystemProperties");
proxyManagerUpdateSystemPropertiesFunc.setAccessible(true);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
}
@@ -70,19 +256,216 @@ public class TalendProxySelector extends ProxySelector {
return null;
}
});
if (instance.getDefaultProxySelector() == null
if (instance.getEclipseDefaultSelector() == null
|| (proxySelector != null && proxySelector.getClass().getName().endsWith(ECLIPSE_PROXY_SELECTOR))) {
instance.setDefaultProxySelector(proxySelector);
instance.setEclipseDefaultSelector(proxySelector);
}
}
return instance;
}
public static void checkProxy() {
if (!checkProxy) {
return;
}
try {
TalendProxySelector.getInstance();
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
@Override
public List<Proxy> select(final URI uri) {
final Set<Proxy> resultFromProviders = new HashSet<>();
List<IProxySelectorProvider> providers = getProxySelectorProviders();
if (printProxyLog) {
ExceptionHandler.log("TalendProxySelector.select " + uri);
}
if (uri == null) {
return Collections.EMPTY_LIST;
}
URI validatedUri = validateUri(uri);
Set<Proxy> results = new LinkedHashSet<>();
try {
final Set<Proxy> resultFromProviders = getProxysFromProviders(validatedUri);
if (resultFromProviders != null && !resultFromProviders.isEmpty()) {
results.addAll(resultFromProviders);
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
if (printProxyLog) {
ExceptionHandler.log("TalendProxySelector.resultFromProviders " + results);
}
ProxySelector defaultProxySelector = getDefaultProxySelector();
if (printProxyLog) {
ExceptionHandler.log("TalendProxySelector.defaultProxySelector " + defaultProxySelector);
}
if (defaultProxySelector != null) {
/**
* don't validate uri here, so that we can know whether it is an issue uri
*/
URI newUri = getNewUri(validatedUri, false);
List<Proxy> defaultProxys = null;
if (validateUri && StringUtils.isBlank(newUri.getHost())) {
/**
* If host is blank, force to use jre proxy selector to avoid the eclipse proxy selector bug
*/
defaultProxys = getJreProxySelector().select(newUri);
} else {
defaultProxys = defaultProxySelector.select(newUri);
}
if (printProxyLog) {
ExceptionHandler.log("TalendProxySelector.defaultProxys " + defaultProxys);
}
try {
results.addAll(filterProxys(validatedUri, defaultProxys));
} catch (Exception e) {
results.addAll(defaultProxys);
ExceptionHandler.process(e);
}
}
if (printProxyLog) {
String proxys = results.toString();
ExceptionHandler.log("Selected proxys for " + uri + ", " + proxys);
ExceptionHandler.process(new Exception("Proxy call stacks"), Priority.INFO);
}
return new LinkedList<Proxy>(results);
}
private URI validateUri(URI uri) {
if (!validateUri) {
return uri;
}
URI validatedUri = null;
try {
/**
* DON'T use URI.create(), MUST use the conductor which requires authority
*/
validatedUri = new URI(uri.getScheme(), uri.getAuthority(), uri.getPath(), uri.getQuery(), uri.getFragment());
/**
* Validate the host, if the host is empty, it will cause the eclipse selector to return dirrect
*/
if (StringUtils.isBlank(validatedUri.getHost())) {
String authority = validatedUri.getAuthority();
if (StringUtils.isNotBlank(authority)) {
// example: https://u:p@www.company.com:8081/path/a?param=b
String host = null;
int userInfoIndex = authority.indexOf('@');
if (0 <= userInfoIndex) {
authority = authority.substring(userInfoIndex + 1);
}
int portIndex = authority.lastIndexOf(':');
if (0 <= portIndex) {
host = authority.substring(0, portIndex);
}
try {
uriHostField.set(validatedUri, host);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
if (validatedUri == null) {
validatedUri = uri;
}
}
if (printProxyLog) {
ExceptionHandler.log("After validate: " + uri + " -> " + validatedUri);
}
return validatedUri;
}
private List<Proxy> filterProxys(final URI uri, List<Proxy> defaultProxys) {
List<Proxy> result = new ArrayList<>();
if (defaultProxys != null && !defaultProxys.isEmpty()) {
for (Proxy proxy : defaultProxys) {
SocketAddress addr = null;
Proxy.Type proxyType = null;
if (proxy != null) {
proxyType = proxy.type();
addr = proxy.address();
}
boolean redirect = true;
if (!allowProxyRedirect) {
String host = uri.getHost();
if (host == null) {
host = "";
}
host = StringUtils.strip(host).toLowerCase();
if (this.redirectWhiteList.contains(host) || this.redirectWhiteList.contains(KEY_DEFAULT)) {
redirect = true;
} else if (Proxy.Type.DIRECT == proxyType
|| (addr != null && StringUtils.equals(uri.getHost(), ((InetSocketAddress) addr).getHostString()))) {
redirect = false;
}
}
if (redirect) {
result.add(proxy);
} else {
result.add(Proxy.NO_PROXY);
}
}
}
return result;
}
private URI getNewUri(URI uri, boolean validateUri) {
URI newUri = uri;
if (newUri != null) {
try {
// get host before new URI, because the host may be set manually due to URI issue
String host = newUri.getHost();
newUri = new URI(newUri.getScheme(), newUri.getAuthority(), newUri.getPath(), newUri.getQuery(),
newUri.getFragment());
Map<String, String> protocolMap = null;
if (StringUtils.isNotBlank(host)) {
protocolMap = hostMap.get(host.toLowerCase());
}
if (protocolMap == null) {
protocolMap = hostMap.get(KEY_DEFAULT);
}
if (protocolMap != null) {
String schema = newUri.getScheme();
if (schema != null) {
String lowercasedProtocol = schema.toLowerCase();
String preferedProtocol = protocolMap.get(lowercasedProtocol);
if (StringUtils.isNotBlank(preferedProtocol)) {
/**
* Note: MUST use the constructor which requires authority, because some uri may be illegal,
* then host info will be stored in authority field instead of host filed
*/
newUri = new URI(preferedProtocol, newUri.getAuthority(), newUri.getPath(), newUri.getQuery(),
newUri.getFragment());
}
}
}
} catch (URISyntaxException e) {
if (printProxyLog) {
ExceptionHandler.process(
new Exception(Messages.getString("TalendProxySelector.exception.proxySelectionError", uri), e),
Priority.WARN);
}
}
}
if (validateUri) {
newUri = validateUri(newUri);
}
return newUri;
}
private Set<Proxy> getProxysFromProviders(final URI uri) {
final Set<Proxy> resultFromProviders = new LinkedHashSet<>();
Collection<IProxySelectorProvider> providers = getCustomProviders(uri);
if (providers != null) {
providers.stream().forEach(p -> {
if (instance == p) {
@@ -100,49 +483,126 @@ public class TalendProxySelector extends ProxySelector {
}
});
}
List<Proxy> result = new ArrayList<>();
return resultFromProviders;
}
if (resultFromProviders != null && !resultFromProviders.isEmpty()) {
result.addAll(resultFromProviders);
}
ProxySelector defaultProxySelector = getDefaultProxySelector();
if (defaultProxySelector != null) {
List<Proxy> defaultProxys = defaultProxySelector.select(uri);
if (defaultProxys != null && !defaultProxys.isEmpty()) {
result.addAll(defaultProxys);
private Collection<IProxySelectorProvider> getCustomProviders(final URI uri) {
Collection<IProxySelectorProvider> providers = Collections.EMPTY_LIST;
Collection<Object> possibleKeys = getPossibleKeys(uri);
for (Object key : possibleKeys) {
providers = this.selectorProviders.get(key);
if (providers != null) {
break;
}
}
return result;
return providers;
}
public PasswordAuthentication getHttpPasswordAuthentication() {
String[] schemas = new String[] { "http", "https" };
for (String schema : schemas) {
String proxyUser = System.getProperty(schema + ".proxyUser");
String proxyPassword = System.getProperty(schema + ".proxyPassword");
if (StringUtils.isNotBlank(proxyUser)) {
char[] pwdChars = new char[0];
if (proxyPassword != null && !proxyPassword.isEmpty()) {
pwdChars = proxyPassword.toCharArray();
}
return new PasswordAuthentication(proxyUser, pwdChars);
}
}
return null;
}
public boolean addProxySelectorProvider(IProxySelectorProvider provider) {
List<IProxySelectorProvider> proxySelectorProviders = getProxySelectorProviders();
if (!proxySelectorProviders.contains(provider)) {
return proxySelectorProviders.add(provider);
try {
Object key = provider.getKey();
Collection<IProxySelectorProvider> collection = this.selectorProviders.get(key);
if (collection == null) {
synchronized (this.selectorProviders) {
collection = this.selectorProviders.get(key);
if (collection == null) {
collection = Collections.synchronizedList(new LinkedList<>());
this.selectorProviders.put(key, collection);
}
}
}
collection.add(provider);
return true;
} catch (Exception e) {
ExceptionHandler.process(e);
}
return false;
}
public boolean removeProxySelectorProvider(IProxySelectorProvider provider) {
return getProxySelectorProviders().remove(provider);
}
private List<IProxySelectorProvider> getProxySelectorProviders() {
return selectorProviders;
try {
Object key = provider.getKey();
Collection<IProxySelectorProvider> collection = this.selectorProviders.get(key);
if (collection != null) {
synchronized (this.selectorProviders) {
collection = this.selectorProviders.get(key);
if (collection != null) {
collection.remove(provider);
if (collection.isEmpty()) {
this.selectorProviders.remove(key);
}
}
}
}
return true;
} catch (Exception e) {
ExceptionHandler.process(e);
}
return false;
}
public ProxySelector getDefaultProxySelector() {
return defaultSelector;
switch (eProxySelector) {
case jre:
return getJreProxySelector();
default:
return eclipseDefaultSelector;
}
}
public void setDefaultProxySelector(final ProxySelector selector) {
defaultSelector = selector;
private ProxySelector getJreProxySelector() {
try {
/**
* for tcompv0, daikon may create an isolated system properties for it, so proxies may be ignored in the new
* system properties; here we try to call the method to add proxies into the isolated system properties
*/
if (updateSystemPropertiesForJre && ClassLoaderIsolatedSystemProperties.getInstance()
.isIsolated(Thread.currentThread().getContextClassLoader())) {
if (printProxyLog) {
ExceptionHandler.log("Before update jre proxy system properties for the isolated classloader, http.proxyHost="
+ System.getProperty("http.proxyHost"));
}
IProxyService proxyService = CommonsPlugin.getProxyService();
proxyManagerUpdateSystemPropertiesFunc.invoke(proxyService);
if (printProxyLog) {
ExceptionHandler.log("After updated jre proxy system properties for the isolated classloader, http.proxyHost="
+ System.getProperty("http.proxyHost"));
}
}
} catch (Throwable e) {
ExceptionHandler.process(e);
}
return this.jreDefaultSelector;
}
public ProxySelector getEclipseDefaultSelector() {
return eclipseDefaultSelector;
}
public void setEclipseDefaultSelector(ProxySelector eclipseDefaultSelector) {
this.eclipseDefaultSelector = eclipseDefaultSelector;
}
@Override
public void connectFailed(final URI uri, final SocketAddress sa, final IOException ioe) {
List<IProxySelectorProvider> providers = getProxySelectorProviders();
Collection<IProxySelectorProvider> providers = getCustomProviders(uri);
if (providers != null) {
providers.stream().forEach(p -> {
if (p.canHandle(uri)) {
@@ -151,23 +611,35 @@ public class TalendProxySelector extends ProxySelector {
});
}
ProxySelector defaultProxySelector = getDefaultProxySelector();
if (defaultProxySelector != null) {
defaultProxySelector.connectFailed(uri, sa, ioe);
if (executeConnectionFailed) {
/**
* Just try to make the behavior of jre proxy selector same like eclipse proxy selector
*/
ProxySelector defaultProxySelector = getDefaultProxySelector();
if (defaultProxySelector != null) {
defaultProxySelector.connectFailed(uri, sa, ioe);
}
}
}
public static abstract class AbstractProxySelectorProvider implements IProxySelectorProvider {
@Override
public void connectFailed(final URI uri, final SocketAddress sa, final IOException ioe) {
// nothing to do
public IProxySelectorProvider createDefaultProxySelectorProvider() {
if (disableDefaultSelectorProvider) {
return null;
}
return new DefaultProxySelectorProvider(Thread.currentThread());
}
public IProxySelectorProvider createDefaultProxySelectorProvider(String host) {
if (disableDefaultSelectorProvider) {
return null;
}
return new DefaultProxySelectorProvider(host);
}
public static interface IProxySelectorProvider {
Object getKey();
boolean canHandle(final URI uri);
List<Proxy> select(final URI uri);
@@ -176,4 +648,120 @@ public class TalendProxySelector extends ProxySelector {
}
public static abstract class AbstractProxySelectorProvider implements IProxySelectorProvider {
private boolean isDebugMode = CommonsPlugin.isDebugMode();
@Override
public Object getKey() {
return this;
}
@Override
public void connectFailed(final URI uri, final SocketAddress sa, final IOException ioe) {
if (isDebugMode) {
ExceptionHandler.process(ioe);
}
}
}
public static Collection<Object> getPossibleKeys(URI uri) {
Collection<Object> possibleKeys = new ArrayList<>();
possibleKeys.add(Thread.currentThread());
if (uri != null) {
String uriHost = uri.getHost();
if (StringUtils.isNotBlank(uriHost)) {
possibleKeys.add(uriHost);
}
}
return possibleKeys;
}
private enum EProxySelector {
eclipse_default,
jre
}
private class DefaultProxySelectorProvider extends TalendProxySelector.AbstractProxySelectorProvider {
private Thread currentThread = null;
private String host = null;
public DefaultProxySelectorProvider(Thread thread) {
this.currentThread = thread;
}
public DefaultProxySelectorProvider(String host) {
this.host = host;
if (StringUtils.isNotBlank(this.host)) {
this.host = this.host.toLowerCase();
}
}
@Override
public Object getKey() {
if (this.currentThread != null) {
return currentThread;
}
if (this.host != null) {
return this.host;
}
return super.getKey();
}
@Override
public boolean canHandle(URI uri) {
if (disableDefaultSelectorProvider) {
return false;
}
if (currentThread != null && Thread.currentThread() == currentThread) {
return true;
}
if (host != null) {
if (uri == null) {
return false;
}
String uriHost = uri.getHost();
if (StringUtils.isNotBlank(uriHost)) {
return this.host.equals(uriHost.toLowerCase());
}
return false;
}
return false;
}
@Override
public List<Proxy> select(URI uri) {
List<Proxy> result = new ArrayList<>();
try {
ProxySelector defaultProxySelector = getDefaultProxySelector();
if (defaultProxySelector != null) {
List<Proxy> defaultProxys = defaultProxySelector.select(uri);
if (defaultProxys != null && !defaultProxys.isEmpty()) {
for (Proxy proxy : defaultProxys) {
SocketAddress addr = null;
Proxy.Type proxyType = null;
if (proxy != null) {
proxyType = proxy.type();
addr = proxy.address();
}
if (Proxy.Type.DIRECT == proxyType || (addr != null
&& StringUtils.equals(uri.getHost(), ((InetSocketAddress) addr).getHostString()))) {
result.add(Proxy.NO_PROXY);
} else {
result.add(proxy);
}
}
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
return result;
}
}
}

View File

@@ -33,6 +33,7 @@ import org.eclipse.swt.widgets.TreeItem;
import org.talend.commons.ui.runtime.i18n.Messages;
import org.talend.commons.ui.runtime.utils.TableUtils;
import org.talend.commons.ui.runtime.ws.WindowSystem;
import org.talend.commons.ui.swt.advanced.dataeditor.AbstractDataTableEditorView;
import org.talend.commons.ui.swt.drawing.background.IBackgroundRefresher;
import org.talend.commons.ui.swt.drawing.background.IBgDrawableComposite;
import org.talend.commons.ui.swt.drawing.link.BezierHorizontalLink;
@@ -464,4 +465,19 @@ public class TreeToTablesLinker<D1, D2> extends BgDrawableComposite implements I
}
}
protected <B> void loadItemDataForLazyLoad(AbstractDataTableEditorView<B> tableEditorView) {
if (!tableEditorView.getTableViewerCreator().isLazyLoad()) {
return;
}
List<B> beansList = tableEditorView.getExtendedTableModel().getBeansList();
Table table = tableEditorView.getTable();
for (TableItem tableItem : table.getItems()) {
if (tableItem.getData() == null) {
int index = table.indexOf(tableItem);
B schemaTarget = beansList.get(index);
tableItem.setData(schemaTarget);
}
}
}
}

View File

@@ -71,6 +71,7 @@ import org.talend.commons.ui.runtime.CommonUIPlugin;
import org.talend.commons.ui.runtime.exception.MessageBoxExceptionHandler;
import org.talend.commons.utils.data.container.RootContainer;
import org.talend.commons.utils.generation.JavaUtils;
import org.talend.commons.utils.network.TalendProxySelector;
import org.talend.commons.utils.time.TimeMeasure;
import org.talend.commons.utils.workbench.resources.ResourceUtils;
import org.talend.core.AbstractDQModelService;
@@ -1896,6 +1897,11 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
TimeMeasure.begin("logOnProject"); //$NON-NLS-1$
try {
/**
* init/check proxy selector, in case default proxy selector is not registed yet
*/
TalendProxySelector.checkProxy();
System.getProperties().put("ReadOnlyUser", Boolean.FALSE.toString()); //$NON-NLS-1$
// remove the auto-build to enhance the build speed and application's use
@@ -2267,9 +2273,14 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
@Override
@SuppressWarnings("unchecked")
public void executeRepositoryWorkUnit(RepositoryWorkUnit workUnit) {
checkProxySettings();
this.repositoryFactoryFromProvider.executeRepositoryWorkUnit(workUnit);
}
private void checkProxySettings() {
TalendProxySelector.checkProxy();
}
@Override
public void unloadResources(Property property) throws PersistenceException {
repositoryFactoryFromProvider.unloadResources(property);

View File

@@ -19,7 +19,10 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.eclipse.core.resources.IContainer;
@@ -221,20 +224,37 @@ public class ProjectDataJsonProvider {
public static void loadMigrationTaskSetting(Project project, InputStream input) throws PersistenceException {
try {
project.eSetDeliver(false);
MigrationTaskSetting migrationTaskSetting = null;
if (input != null) {
migrationTaskSetting = new ObjectMapper().readValue(input, MigrationTaskSetting.class);
}
if (migrationTaskSetting != null) {
MigrationTask fakeTask = createFakeMigrationTask();
List<MigrationTask> allRealTask = new ArrayList<MigrationTask>();
MigrationTask existingFakeTask = null;
for (int i = 0; i < project.getMigrationTask().size(); i++) {
MigrationTask task = (MigrationTask) project.getMigrationTask().get(i);
if (!StringUtils.equals(fakeTask.getId(), task.getId())) {
allRealTask.add(task);
if (StringUtils.equals(fakeTask.getId(), task.getId())) {
existingFakeTask = task;
break;
}
}
project.getMigrationTask().removeAll(allRealTask);
// remove all the migrations from the project
project.getMigrationTask().clear();
if (existingFakeTask != null) {
// keep only the fake migration task of 7.1.1 with new migration index
// re-use the same instance to make sure we keep the same emf id.
project.getMigrationTask().add(existingFakeTask);
}
Set<String> tasksIds = new HashSet<>();
Iterator<MigrationTaskJson> it = migrationTaskSetting.getMigrationTaskList().iterator();
while (it.hasNext()) { // remove duplicates to fix issues found in TUP-22735
MigrationTaskJson task = it.next();
if (tasksIds.contains(task.getId())) {
it.remove();
}
tasksIds.add(task.getId());
}
project.getMigrationTasks().clear();
if (migrationTaskSetting.getMigrationTaskList() != null) {
for (MigrationTaskJson json : migrationTaskSetting.getMigrationTaskList()) {
@@ -252,6 +272,7 @@ public class ProjectDataJsonProvider {
} catch (Exception e) {
throw new PersistenceException(e);
} finally {
project.eSetDeliver(true);
closeInputStream(input);
}
}

View File

@@ -131,4 +131,22 @@ public class ProjectHelper {
}
return null;
}
/**
* define the different value for the project types the string value in the licence files Matcht the java enum name
* this is a copy of org.talend.commons.model.KeyConstants.ProjectType to avoid adding the all library
*
*/
public static enum ProjectType {
DI,
DQ,
MDM;
}
public static int getProjectTypeOrdinal(org.talend.core.model.properties.Project project) {
if (project != null && project.getType() != null) {
return ProjectType.valueOf(project.getType()).ordinal();
}
return 0;
}
}

View File

@@ -55,6 +55,8 @@ public interface IComponentsFactory {
*/
public Set<IComponent> getComponents();
public boolean isInitialising();
/**
* Get a readonly components collection to avoid ConcurrentModificationException caused by multiple thread
* access;<br/>

View File

@@ -56,6 +56,7 @@ public class ConnectionBean implements Cloneable {
private static final String TOKEN = "token"; //$NON-NLS-1$
private static final String URL = "url"; //$NON-NLS-1$
/**
* DOC smallet ConnectionBean constructor comment.
*/
@@ -396,4 +397,15 @@ public class ConnectionBean implements Cloneable {
}
}
public String getUrl() {
try {
if (conDetails.has(URL)) {
return conDetails.getString(URL);
}
} catch (JSONException e) {
ExceptionHandler.process(e);
}
return "";
}
}

View File

@@ -434,9 +434,9 @@ public class ModuleNeeded {
if (this.getModuleLocaion() != null) {
hashCode *= this.getModuleLocaion().hashCode();
}
hashCode *= this.getDefaultMavenURI().hashCode();
if(this.getDefaultMavenURI() != null){
hashCode *= this.getDefaultMavenURI().hashCode();
}
return hashCode;
}
@@ -519,8 +519,16 @@ public class ModuleNeeded {
}
// maven uri
if (!other.getDefaultMavenURI().equals(this.getDefaultMavenURI())) {
return false;
if (other.getDefaultMavenURI() == null) {
if (this.getDefaultMavenURI() != null) {
return false;
}
} else {
if (this.getDefaultMavenURI() == null) {
return false;
} else if (!other.getDefaultMavenURI().equals(this.getDefaultMavenURI())) {
return false;
}
}
return true;

View File

@@ -45,6 +45,14 @@ public interface ISAPConstant {
public static final String CHANGING = "CHANGING";//$NON-NLS-1$
public static final String PARAMETER_TYPE = "PARAMETER_TYPE";//$NON-NLS-1$
public static final String PARAMETER_TYPE_IMPORT = "IMPORT";//$NON-NLS-1$
public static final String PARAMETER_TYPE_CHANGING = "CHANGING";//$NON-NLS-1$
public static final String PARAMETER_TYPE_TABLES = "TABLES";//$NON-NLS-1$
/*
*
*/

View File

@@ -153,7 +153,7 @@ public class MetadataTable implements IMetadataTable, Cloneable {
List<IMetadataColumn> temp = new ArrayList<IMetadataColumn>();
temp.addAll(this.listColumns);
temp.addAll(this.unusedColumns);
if (isRepository && originalColumns != null) {
if (originalColumns != null && isRepository) {
Collections.sort(temp, new Comparator<IMetadataColumn>() {
@Override
@@ -213,8 +213,9 @@ public class MetadataTable implements IMetadataTable, Cloneable {
}
if (originalColumns != null) {
List<String> clonedOriginalColumns = new ArrayList<String>(originalColumns);
clonedMetadata.setOriginalColumns(clonedOriginalColumns);
if(clonedMetadata.getOriginalColumns() == null || clonedMetadata.getOriginalColumns().isEmpty()) {
clonedMetadata.setOriginalColumns(clonedOriginalColumns);
}
}
clonedMetadata.setTableName(this.getTableName());
clonedMetadata.setLabel(this.getLabel());

View File

@@ -211,6 +211,7 @@ public final class MetadataToolAvroHelper {
//ignore it now as we can't process the complex expression for the default value, and the default value is not useful for runtime like the old javajet tjdbcxxx
//TODO support the expression calculate, not sure it's necessary and sometimes, more complex like globalMap.get(xxx) which only have meaning after running the job.
ExceptionHandler.process(e, Level.WARN);
defaultValue = null;
}
// Types with Document/Unknown elements, store as binary

View File

@@ -15,6 +15,7 @@ package org.talend.core.model.metadata;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -614,13 +615,71 @@ public final class MetadataToolHelper {
target.getListColumns().addAll(columnsTAdd);
target.sortCustomColumns();
target.setLabel(source.getLabel());
target.setOriginalColumns(source.getOriginalColumns());
target.setDbms(source.getDbms());
setTargetOriginalColumns(source, target);
// List<String> originalColumnsList = null;
// if (source.getOriginalColumns() != null) {
// originalColumnsList = new ArrayList<String>();
// originalColumnsList.addAll(source.getOriginalColumns());
// }
// target.setOriginalColumns(originalColumnsList);
Map<String, String> targetProperties = target.getAdditionalProperties();
Map<String, String> sourceProperties = source.getAdditionalProperties();
for (Entry<String, String> entry : sourceProperties.entrySet()) {
targetProperties.put(entry.getKey(), entry.getValue());
}
}
public static void setTargetOriginalColumns(IMetadataTable source, IMetadataTable target) {
List<String> sColumns = source.getOriginalColumns();
List<String> tColumns = target.getOriginalColumns();
if(sColumns == null) {
return;
}
if(tColumns == null) {
target.setOriginalColumns(sColumns);
return;
}
if(sColumns.size() == tColumns.size()) {
boolean same = true;
for(int i = 0;i<sColumns.size();i++) {
if(!sColumns.get(i).equals(tColumns.get(i))) {
same = false;
break;
}
}
if(same) {
return;
}
}
for(String sColumn : sColumns) {
if(tColumns.contains(sColumn)) {
continue;
}
tColumns.add(sColumn);
}
List<IMetadataColumn> targetColumns = target.getListColumns();
List<String> temp = new ArrayList<String>(tColumns);
if (targetColumns != null) {
List<String> columnNames = new ArrayList<String>();
for(IMetadataColumn column : targetColumns){
columnNames.add(column.getLabel());
}
Collections.sort(temp, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
int index1 = columnNames.indexOf(o1);
int index2 = columnNames.indexOf(o2);
return index1 - index2;
}
});
}
target.setOriginalColumns(temp);
}
public static void copyTable(List<IMetadataColumn> sourceColumns, IMetadataTable target, List<IMetadataColumn> targetColumns) {
if (sourceColumns == null || target == null || targetColumns == null) {

View File

@@ -308,7 +308,8 @@ public abstract class AbstractNode implements INode {
return mapMerge.keySet().iterator().next().getSubProcessStartNode(withConditions);
}
}
if ((getCurrentActiveLinksNbInput(EConnectionType.MAIN) == 0)) {
if ((getCurrentActiveLinksNbInput(EConnectionType.MAIN) == 0)
&& !checkIfCurrentActiveLinksIsLookup()) {
return this; // main branch here, so we got the correct sub
// process start.
}
@@ -327,9 +328,13 @@ public abstract class AbstractNode implements INode {
for (IConnection connec : getIncomingConnections()) {
if (((AbstractNode) connec.getSource()).isOnMainMergeBranch()) {
// with lookup, tMap incoming connection contains FLOW_MAIN and FLOW_REF,
// should take care of FLOW_MAIN only
if (!connec.getLineStyle().equals(EConnectionType.FLOW_REF)) {
return connec.getSource().getSubProcessStartNode(withConditions);
}
} else if (connec.getLineStyle().equals(EConnectionType.RUN_AFTER)) {
return connec.getSource().getSubProcessStartNode(withConditions);
}
}
return null;
@@ -345,6 +350,27 @@ public abstract class AbstractNode implements INode {
return nb;
}
private boolean checkIfCurrentActiveLinksIsLookup() {
boolean flag = false;
int input = 0;
for (IConnection inConnection : getIncomingConnections()) {
// refer to DataProcess.checkFlowRefLink() added RUN_AFTER for incoming connection
if (inConnection.isActivate() && inConnection.getLineStyle().getId() == EConnectionType.RUN_AFTER.getId()) {
input++;
}
}
// check if run_after is for lookup
if (input > 0) {
for (IConnection outConnection : getOutgoingConnections()) {
if (outConnection.isActivate() && outConnection.getLineStyle().getId() == EConnectionType.FLOW_REF.getId()) {
flag = true;
break;
}
}
}
return flag;
}
/*
* (non-Javadoc)
*

View File

@@ -20,11 +20,11 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import org.eclipse.emf.common.util.EList;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.exception.PersistenceException;
import org.talend.commons.utils.VersionUtils;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.IESBService;
import org.talend.core.ITDQItemService;
import org.talend.core.PluginChecker;
import org.talend.core.hadoop.IHadoopClusterService;
@@ -33,7 +33,6 @@ import org.talend.core.model.general.Project;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.JobletProcessItem;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.ProjectReference;
import org.talend.core.model.properties.Property;
import org.talend.core.model.properties.SQLPatternItem;
import org.talend.core.model.relationship.Relation;
@@ -53,7 +52,6 @@ import org.talend.core.utils.BitwiseOptionUtils;
import org.talend.designer.core.IDesignerCoreService;
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.MetadataType;
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
@@ -897,33 +895,14 @@ public final class ProcessUtils {
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(property.getItem());
// route job
if (itemType != null && (itemType.equals(ERepositoryObjectType.PROCESS_ROUTE)
|| itemType.equals(ERepositoryObjectType.PROCESS_ROUTELET))) {
|| itemType.equals(ERepositoryObjectType.PROCESS_ROUTELET)
|| "CAMEL".equals(process.getComponentsType()))) {
needBeans = true;
}
}
}
}
if (needBeans && GlobalServiceRegister.getDefault().isServiceRegistered(IProxyRepositoryService.class)) {
IProxyRepositoryService service = (IProxyRepositoryService) GlobalServiceRegister.getDefault()
.getService(IProxyRepositoryService.class);
ERepositoryObjectType beansType = ERepositoryObjectType.valueOf("BEANS"); //$NON-NLS-1$
try {
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
List<IRepositoryViewObject> all = factory.getAll(project, beansType);
List<ProjectReference> references = ProjectManager.getInstance().getCurrentProject()
.getProjectReferenceList(true);
for (ProjectReference ref : references) {
all.addAll(factory.getAll(new Project(ref.getReferencedProject()), beansType));
}
if (!all.isEmpty()) { // has bean
return true;
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
return false;
return needBeans && GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class);
}
public static boolean isRequiredPigUDFs(IProcess process) {

View File

@@ -23,6 +23,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Level;
@@ -128,8 +129,6 @@ public class RelationshipItemBuilder {
private Map<Relation, Set<Relation>> referencesItemsRelations;
private Map<String, String> hadoopItemReferences = new HashMap<String, String>();
private boolean loaded = false;
private boolean loading = false;
@@ -643,8 +642,8 @@ public class RelationshipItemBuilder {
return;
}
loading = true;
currentProjectItemsRelations = new HashMap<Relation, Set<Relation>>();
referencesItemsRelations = new HashMap<Relation, Set<Relation>>();
currentProjectItemsRelations = new ConcurrentHashMap<Relation, Set<Relation>>();
referencesItemsRelations = new ConcurrentHashMap<Relation, Set<Relation>>();
loadRelations(currentProjectItemsRelations, getAimProject());
@@ -1097,10 +1096,11 @@ public class RelationshipItemBuilder {
Map<Relation, Set<Relation>> relations = handler.find(item);
mergeRelationship(itemRelations, relations);
}
if (oldProjectRelations != null) {
// check if there is any changes on the relations.
Set<Relation> newProjectRelations = currentProjectItemsRelations.get(relation);
// check if there is any changes on the relations.
Set<Relation> newProjectRelations = currentProjectItemsRelations.get(relation);
if (oldProjectRelations == null && newProjectRelations == null) {
relationsModified = false;
} else if (oldProjectRelations != null) {
if (oldProjectRelations.size() == newProjectRelations.size()) {
relationsModified = false;
for (Relation newRelation : newProjectRelations) {

View File

@@ -427,6 +427,11 @@ public class ERepositoryObjectType extends DynaEnum<ERepositoryObjectType> {
*/
public final static ERepositoryObjectType JOBLET = ERepositoryObjectType.valueOf("JOBLET"); //$NON-NLS-1$
/**
* <font color="red">This value may be <b>null</b> in some products, <b>should add NPE check</b></font>
*/
public final static ERepositoryObjectType SERVICES = ERepositoryObjectType.valueOf("SERVICES"); //$NON-NLS-1$
public final static ERepositoryObjectType JOBLET_DESIGNS = ERepositoryObjectType.valueOf("JOBLET_DESIGNS"); //$NON-NLS-1$
public final static ERepositoryObjectType SPARK_JOBLET = ERepositoryObjectType.valueOf("SPARK_JOBLET"); //$NON-NLS-1$
@@ -439,6 +444,8 @@ public class ERepositoryObjectType extends DynaEnum<ERepositoryObjectType> {
public final static ERepositoryObjectType ROUTINES = ERepositoryObjectType.valueOf("ROUTINES"); //$NON-NLS-1$
public final static ERepositoryObjectType BEANS = ERepositoryObjectType.valueOf("BEANS"); //$NON-NLS-1$
public final static ERepositoryObjectType METADATA_HEADER_FOOTER = ERepositoryObjectType.valueOf("METADATA_HEADER_FOOTER"); //$NON-NLS-1$
public final static ERepositoryObjectType JOB_SCRIPT = ERepositoryObjectType.valueOf("JOB_SCRIPT"); //$NON-NLS-1$

View File

@@ -681,16 +681,15 @@ public class NodeUtil {
}
List<? extends IConnection> listInConns = node.getIncomingConnections();
if (listInConns != null && listInConns.size() > 0) {
String retResult = getPrivateConnClassName(listInConns.get(0));
if (retResult == null) {
return conn.getName();
} else {
return retResult;
for (IConnection connection : listInConns) {
if (EConnectionType.FLOW_REF != connection.getLineStyle()) {
String retResult = getPrivateConnClassName(connection);
return retResult != null ? retResult : conn.getName();
}
}
}
}
return null;
}
/**

View File

@@ -79,6 +79,11 @@ public class ArtifactRepositoryBean implements Cloneable {
if (index > 0) {
nexusUrl = url.substring(0, index + ARTIFACT_MIDDLE_PATH.length());
repoId = StringUtilities.removeEndingString(url.substring(index + ARTIFACT_MIDDLE_PATH.length()), "/");
} else {
// can be non-default contextpath or root
String tempurl = StringUtilities.removeEndingString(url, "/");
repoId = tempurl.substring(tempurl.lastIndexOf("/") + 1);
nexusUrl = url.substring(0, url.indexOf(repoId));
}
}
return new String[] { nexusUrl, repoId };

View File

@@ -12,14 +12,12 @@
// ============================================================================
package org.talend.core.nexus;
import java.net.Authenticator;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.net.Proxy.Type;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang.StringUtils;
@@ -37,7 +35,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.talend.commons.exception.BusinessException;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.utils.network.TalendProxySelector;
import org.talend.commons.utils.network.TalendProxySelector.IProxySelectorProvider;
import org.talend.core.runtime.maven.MavenArtifact;
@@ -123,7 +120,7 @@ public abstract class HttpClientTransport {
}
}
private IProxySelectorProvider addProxy(final DefaultHttpClient httpClient, URI requestURI) {
public static IProxySelectorProvider addProxy(final DefaultHttpClient httpClient, URI requestURI) {
IProxySelectorProvider proxySelectorProvider = null;
try {
if (Boolean.valueOf(System.getProperty(PROP_PROXY_HTTP_CLIENT_USE_DEFAULT_SETTINGS, Boolean.FALSE.toString()))) {
@@ -141,10 +138,10 @@ public abstract class HttpClientTransport {
}
final Proxy finalProxy = usedProxy;
InetSocketAddress address = (InetSocketAddress) finalProxy.address();
String proxyServer = address.getHostName();
String proxyServer = address.getHostString();
int proxyPort = address.getPort();
PasswordAuthentication proxyAuthentication = Authenticator.requestPasswordAuthentication(proxyServer,
address.getAddress(), proxyPort, "Http Proxy", "Http proxy authentication", null);
TalendProxySelector proxySelector = TalendProxySelector.getInstance();
PasswordAuthentication proxyAuthentication = proxySelector.getHttpPasswordAuthentication();
if (proxyAuthentication != null) {
String proxyUser = proxyAuthentication.getUserName();
String proxyPassword = "";
@@ -157,7 +154,7 @@ public abstract class HttpClientTransport {
}
HttpHost proxyHost = new HttpHost(proxyServer, proxyPort);
httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxyHost);
proxySelectorProvider = createProxySelectorProvider();
proxySelectorProvider = proxySelector.createDefaultProxySelectorProvider();
}
return proxySelectorProvider;
} finally {
@@ -167,61 +164,12 @@ public abstract class HttpClientTransport {
}
}
private void removeProxy(IProxySelectorProvider proxySelectorProvider) {
public static void removeProxy(IProxySelectorProvider proxySelectorProvider) {
if (proxySelectorProvider != null) {
TalendProxySelector.getInstance().removeProxySelectorProvider(proxySelectorProvider);
}
}
private IProxySelectorProvider createProxySelectorProvider() {
IProxySelectorProvider proxySelectorProvider = new TalendProxySelector.AbstractProxySelectorProvider() {
private Thread currentThread = Thread.currentThread();
@Override
public List<Proxy> select(URI uri) {
// return Collections.EMPTY_LIST;
List<Proxy> newProxys = new ArrayList<>();
if (uri == null) {
return newProxys;
}
String schema = uri.getScheme();
if (schema != null && schema.toLowerCase().startsWith("socket")) { //$NON-NLS-1$
try {
URI newUri = new URI("https", uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath(),
uri.getQuery(), uri.getFragment());
List<Proxy> proxys = TalendProxySelector.getInstance().getDefaultProxySelector().select(newUri);
if (proxys != null && !proxys.isEmpty()) {
newProxys.addAll(proxys);
} else {
newUri = new URI("http", uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath(),
uri.getQuery(), uri.getFragment());
proxys = TalendProxySelector.getInstance().getDefaultProxySelector().select(newUri);
if (proxys != null && !proxys.isEmpty()) {
newProxys.addAll(proxys);
}
}
} catch (URISyntaxException e) {
ExceptionHandler.process(e);
}
}
return newProxys;
}
@Override
public boolean canHandle(URI uri) {
if (Thread.currentThread() == currentThread) {
return true;
}
return false;
}
};
return proxySelectorProvider;
}
public void processResponseCode(HttpResponse response) throws BusinessException {
StatusLine statusLine = response.getStatusLine();
int responseCode = statusLine.getStatusCode();

View File

@@ -26,5 +26,7 @@ public class NexusConstants {
public static final String SLASH = "/";//$NON-NLS-1$
public static final String SNAPSHOTS = "@snapshots";
public static final String SNAPSHOTS = "@snapshots";//$NON-NLS-1$
public static final String DISALLOW_RELEASES = "@noreleases";//$NON-NLS-1$
}

View File

@@ -23,6 +23,9 @@ import org.osgi.framework.ServiceReference;
import org.osgi.service.cm.ManagedService;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.utils.network.TalendProxySelector;
import org.talend.commons.utils.network.TalendProxySelector.IProxySelectorProvider;
import org.talend.core.runtime.CoreRuntimePlugin;
/**
@@ -98,7 +101,24 @@ public class TalendMavenResolver {
}
public static File resolve(String mvnUri) throws IOException, RuntimeException {
return getMavenResolver().resolve(mvnUri);
TalendProxySelector selectorInstance = null;
IProxySelectorProvider proxySelector = null;
try {
try {
selectorInstance = TalendProxySelector.getInstance();
proxySelector = selectorInstance.createDefaultProxySelectorProvider();
if (proxySelector != null) {
selectorInstance.addProxySelectorProvider(proxySelector);
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
return getMavenResolver().resolve(mvnUri);
} finally {
if (proxySelector != null && selectorInstance != null) {
selectorInstance.removeProxySelectorProvider(proxySelector);
}
}
}
public static void upload(String groupId, String artifactId, String classifier, String extension, String version,

View File

@@ -42,6 +42,8 @@ public interface MavenConstants {
static final String POM_FILTER = "POM_FILTER";
static final String USE_PROFILE_MODULE = "USE_PROFILE_MODULE";
/*
* for lib
*/

View File

@@ -352,6 +352,15 @@ public class LastGenerationInfo {
}
}
/**
* Clear modules per job cache, not thread safe
*/
public void clearModulesNeededPerJob() {
if (!modulesNeededPerJob.isEmpty()) {
modulesNeededPerJob.clear();
}
}
public void clean() {
modulesNeededPerJob.clear();
routinesNeededPerJob.clear();

View File

@@ -62,6 +62,8 @@ public interface TalendProcessArgumentConstant {
static final String ARG_LAUNCHER_NAME = "LAUNCHER_NAME";
static final String ARG_AVOID_BRANCH_NAME = "AVOID_BRANCH_NAME";
static final String CMD_ARG_STATS_PORT_PARAM = "stat_port";
static final String CMD_ARG_TRACE_PORT_PARAM = "trace_port";

View File

@@ -17,6 +17,7 @@ import java.util.Map;
import org.talend.core.IService;
import org.talend.core.model.process.IElementParameter;
import org.talend.core.model.process.INode;
/**
* created by ycbai on 2016年3月24日 Detailled comment
@@ -38,5 +39,7 @@ public interface IGenericService extends IService {
*
*/
public List<Map<String, String>> getAllGenericComponentsInfo();
public void resetReferenceValue(INode curNode, String oldConnectionName, String newConnectionName);
}

View File

@@ -19,6 +19,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IFile;
@@ -97,17 +98,24 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
private void getReferencedProjectRoutine(final Map<String, RoutineItem> beansList, final Project project,
ERepositoryObjectType routineType, boolean syncRef) throws SystemException {
for (IRepositoryViewObject obj : getRepositoryService().getProxyRepositoryFactory().getAll(project, routineType)) {
final String key = obj.getProperty().getLabel();
// it does not have a routine with same name
if (!beansList.containsKey(key)) {
beansList.put(key, (RoutineItem) obj.getProperty().getItem());
}
if (syncRef) {
// sync routine
syncRoutine((RoutineItem) obj.getProperty().getItem(), false, true, true);
List<IRepositoryViewObject> list = getRepositoryService().getProxyRepositoryFactory().getAll(project, routineType);
if (list.size() == 0) {
getRunProcessService().getTalendCodeJavaProject(routineType, project.getTechnicalLabel());
} else {
for (IRepositoryViewObject obj : list) {
final String key = obj.getProperty().getLabel();
// it does not have a routine with same name
if (!beansList.containsKey(key)) {
beansList.put(key, (RoutineItem) obj.getProperty().getItem());
}
if (syncRef) {
// sync routine
syncRoutine((RoutineItem) obj.getProperty().getItem(), false, true, true);
}
}
}
if (syncRef) {
// sync system routine
syncSystemRoutine(project);

View File

@@ -12,6 +12,8 @@
// ============================================================================
package org.talend.designer.core;
import java.util.Collection;
import org.dom4j.Element;
import org.talend.core.IService;
import org.talend.core.model.process.EConnectionType;
@@ -60,4 +62,12 @@ public interface ICamelDesignerCoreService extends IService {
public FileItem newRouteDocumentationItem();
/**
* DOC sunchaoqun Comment method "getUnselectDependenciesBundle".
*
* @param processItem
* @return
*/
Collection<String> getUnselectDependenciesBundle(ProcessItem processItem);
}

View File

@@ -25,6 +25,7 @@ import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.IService;
import org.talend.core.language.ECodeLanguage;
import org.talend.core.language.ICodeProblemsChecker;
@@ -235,4 +236,11 @@ public interface IRunProcessService extends IService {
public void handleJobDependencyLoop(JobInfo mainJobInfo, List<JobInfo> listJobs, IProgressMonitor progressMonitor)
throws Exception;
public static IRunProcessService get() {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
return (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
}
return null;
}
}

View File

@@ -21,6 +21,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -91,11 +92,14 @@ public final class ProjectManager {
private Set<Object> updatedRemoteHandlerRecords;
private Set<Project> tempProjects;
private ProjectManager() {
beforeLogonRecords = new HashSet<String>();
logonRecords = new HashSet<String>();
migrationRecords = new HashSet<String>();
updatedRemoteHandlerRecords = new HashSet<Object>();
tempProjects = new HashSet<>();
initCurrentProject();
}
@@ -106,6 +110,18 @@ public final class ProjectManager {
return singleton;
}
public void clearTempProjects() {
tempProjects.clear();
}
public boolean removeTempProject(Project project) {
return tempProjects.remove(project);
}
public boolean addTempProject(Project project) {
return tempProjects.add(project);
}
public Project getProjectFromProjectLabel(String label) {
if (currentProject == null) {
initCurrentProject();
@@ -119,6 +135,12 @@ public final class ProjectManager {
return project;
}
}
for (Project project : tempProjects) {
if (StringUtils.equals(project.getLabel(), label)) {
return project;
}
}
return null;
}
@@ -136,6 +158,11 @@ public final class ProjectManager {
return project;
}
}
for (Project project : tempProjects) {
if (StringUtils.equals(project.getTechnicalLabel(), label)) {
return project;
}
}
return null;
}

View File

@@ -33,6 +33,8 @@ public class RepositoryConstants {
public static final String PROJECT_BRANCH_ID = "repository.project.branch"; //$NON-NLS-1$
public static final String PROJECT_ID = "repository.project.id";
public static final String IMG_DIRECTORY = "images"; //$NON-NLS-1$
public static final String IMG_DIRECTORY_OF_JOB_OUTLINE = "images/job_outlines"; //$NON-NLS-1$

View File

@@ -17,6 +17,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.EMap;
import org.eclipse.gef.commands.Command;
@@ -152,8 +153,8 @@ public class RepositoryChangeMetadataForSAPBapi extends Command {
String uinqueTableName = node.getProcess().generateUniqueConnectionName(
MultiSchemasUtil.getConnectionBaseName(newMetadatTable.getLabel()));
String paramType = getParamType(newMetadatTable, isInput);
if (paramType == null) {
String type = getType(newMetadatTable, isInput);
if (type == null) {
return;
}
if (selectionIndex != null && selectionIndex < paramValues.size()) {
@@ -165,18 +166,19 @@ public class RepositoryChangeMetadataForSAPBapi extends Command {
paramValues.add(valueMap);
}
valueMap.put(ISAPConstant.NAME, TalendQuoteUtils.addQuotes(newMetadatTable.getLabel()));
valueMap.put(ISAPConstant.TYPE, paramType);
valueMap.put(ISAPConstant.TYPE, type);
valueMap.put(ISAPConstant.FIELD_SCHEMA, uinqueTableName);
if (isInput) {
valueMap.put(ISAPConstant.PARENT_ROW, ""); //$NON-NLS-1$
if (functionUnit != null && functionUnit.getParamData() != null
&& functionUnit.getParamData().getInputRoot() != null) {
for (SAPFunctionParameter param : functionUnit.getParamData().getInputRoot().getChildren()) {
if (param.getName().equals(newMetadatTable.getTableName())) {
valueMap.put(ISAPConstant.CHANGING, param.isChanging());
}
}
String inputParameterType = getInputParameterType(functionUnit, newMetadatTable);
if (StringUtils.isBlank(inputParameterType)) {
inputParameterType = ISAPConstant.PARAMETER_TYPE_IMPORT;
}
valueMap.put(ISAPConstant.PARAMETER_TYPE, inputParameterType);
valueMap.put(ISAPConstant.CHANGING, ISAPConstant.PARAMETER_TYPE_CHANGING.equals(inputParameterType));
Map<String, String> properties = newMetadatTable.getAdditionalProperties();
if (properties != null) {
properties.put(ISINPUT, TRUE);
@@ -195,7 +197,37 @@ public class RepositoryChangeMetadataForSAPBapi extends Command {
}
}
private String getParamType(IMetadataTable table, boolean isInput) {
private String getInputParameterType(SAPFunctionUnit funcUnit, IMetadataTable newMetadatTable) {
String parameterType = "";
if (funcUnit != null && funcUnit.getParamData() != null && funcUnit.getParamData().getInputRoot() != null) {
SAPFunctionParameter foundParam = null;
String tableName = newMetadatTable.getTableName();
for (SAPFunctionParameter param : funcUnit.getParamData().getInputRoot().getChildren()) {
if (tableName.equals(param.getName())) {
foundParam = param;
break;
}
}
if (foundParam != null) {
if (foundParam.isChanging()) {
parameterType = ISAPConstant.PARAMETER_TYPE_CHANGING;
} else {
if (ISAPConstant.PARAM_TABLE.equals(foundParam.getType())) {
if (foundParam.isTableResideInTables()) {
parameterType = ISAPConstant.PARAMETER_TYPE_TABLES;
} else {
parameterType = ISAPConstant.PARAMETER_TYPE_IMPORT;
}
} else {
parameterType = ISAPConstant.PARAMETER_TYPE_IMPORT;
}
}
}
}
return parameterType;
}
private String getType(IMetadataTable table, boolean isInput) {
if (functionUnit == null) {
return null;
}

View File

@@ -725,6 +725,8 @@ public class MetadataDialog extends Dialog {
}
IDesignerCoreService designerCoreService = CoreUIPlugin.getDefault().getDesignerCoreService();
updateTableOriginalColumns(outputTable);
updateTableOriginalColumns(inputTable);
designerCoreService.setTraceFilterParameters(outputNode, outputTable, preOutputColumnSet, changedNameColumnsForOutput);
designerCoreService.setTraceFilterParameters(inputNode, inputTable, preInputColumnSet, changedNameColumnsForInput);
if (outputTable != null && inputTable != null) {
@@ -745,6 +747,18 @@ public class MetadataDialog extends Dialog {
}
}
}
private void updateTableOriginalColumns(IMetadataTable table) {
if (table != null && table.getListColumns() != null) {
List<String> columnNames = new ArrayList<String>();
for (IMetadataColumn column : table.getListColumns()) {
columnNames.add(column.getLabel());
}
if(table.getOriginalColumns() == null || table.getOriginalColumns().isEmpty()) {
table.setOriginalColumns(columnNames);
}
}
}
/**
* DOC wzhang Comment method "getPreColumnsSet".

View File

@@ -72,10 +72,20 @@ public class JavaSimpleDateFormatProposalProvider implements IContentProposalPro
"\"dd/MM/yyyy\" : common format", "dd/MM/yyyy", "Date\n Examples : \n 01/01/2007\n 31/12/2007"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new DateFormatContentProposal(
"\"MM/dd/yyyy\" : common format", "MM/dd/yyyy", "Date\n Examples : \n 01/01/2007\n 12/31/2007"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new DateFormatContentProposal("\"yyyy-MM-dd'T'HH:mm:ss\" : common format", "yyyy-MM-dd'T'HH:mm:ss", //$NON-NLS-1$ //$NON-NLS-2$
new DateFormatContentProposal(
"\"yyyy-MM-dd\" : common format", "yyyy-MM-dd", "Date\n Examples : \n 2007-01-01\n 2007-12-31"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new DateFormatContentProposal("\"yyyy-MM-dd HH:mm:ss\" : common format", "yyyy-MM-dd HH:mm:ss",
"Date\n Examples : \n 2014-08-19 07:41:35\n 2014-12-31 07:41:35"),//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new DateFormatContentProposal("\"yyyy-MM-dd'T'HH:mm:ss\" : common format", "yyyy-MM-dd'T'HH:mm:ss",
"Date\n Examples : \n 2007-01-01T00:00:00\n 2007-12-31T23:59:59"), // hywang //$NON-NLS-1$
new DateFormatContentProposal("\"yyyy-MM-dd'T'HH:mm:ss'000Z'\" : common format", "yyyy-MM-dd'T'HH:mm:ss'000Z'", //$NON-NLS-1$ //$NON-NLS-2$
"Date\n Examples : \n 2007-01-01T00:00:00000Z\n 2007-12-31T23:59:59000Z"), // hywang //$NON-NLS-1$
new DateFormatContentProposal("\"yyyy-MM-dd'T'HH:mm:ss.SSSSSS\" : common format", "yyyy-MM-dd'T'HH:mm:ss.SSSSSS",
"Date\n Examples : \n 2019-04-18T09:47:49.568095"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new DateFormatContentProposal("\"yyyy-MM-dd HH:mm:ss zzz\" : common format", "yyyy-MM-dd HH:mm:ss zzz", //$NON-NLS-1$ //$NON-NLS-2$
"Date\n Examples : \n 2008-01-01 00:00:00 UTC\n 2008-12-31 04:08:00 PDT"),
new DateFormatContentProposal("\"yyyy-MM-dd HH:mm:ss.SSSXXX\" : common format", "yyyy-MM-dd HH:mm:ss.SSSXXX", //$NON-NLS-1$ //$NON-NLS-2$
"Date\n Examples : \n 2014-08-19 07:41:35.220 -05:00"),
new DateFormatContentProposal(
"\"HH:mm:ss\" : common format", "HH:mm:ss", "Date\n Examples : \n 00:00:00 \n 23:59:59"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new DateFormatContentProposal("\"yy\" : Year (00-99)", "yy", "Year \nExamples : \n 98\n 07"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

View File

@@ -54,6 +54,7 @@ import org.talend.core.model.metadata.QueryUtil;
import org.talend.core.model.metadata.builder.ConvertionHelper;
import org.talend.core.model.metadata.builder.connection.MetadataTable;
import org.talend.core.model.process.ElementParameterParser;
import org.talend.core.model.process.ProcessUtils;
import org.talend.core.model.properties.Item;
import org.talend.core.model.relationship.RelationshipItemBuilder;
import org.talend.core.model.repository.IRepositoryViewObject;
@@ -279,9 +280,10 @@ public class CoreService implements ICoreService {
ICodeGeneratorService codeGenService = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(
ICodeGeneratorService.class);
codeGenService.createRoutineSynchronizer().syncAllRoutinesForLogOn();
codeGenService.createRoutineSynchronizer().syncAllPigudfForLogOn();
if (ProcessUtils.isRequiredPigUDFs(null)) {
codeGenService.createRoutineSynchronizer().syncAllPigudfForLogOn();
}
}
}
@Override

View File

@@ -16,7 +16,7 @@ import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.talend.commons.exception.WarningException;
import org.talend.commons.exception.ExceptionHandler;
/**
* cli class global comment. Detailled comment
@@ -104,26 +104,31 @@ public final class ProcessStreamTrashReaderUtil {
public static void readAndForget(final Process process) {
try {
final String encoding = "UTF-8";
// input stream thread
new Thread() {
public void run() {
InputStream is = process.getInputStream();
InputStreamReader din = new InputStreamReader(is);
BufferedReader reader = new BufferedReader(din);
try {
String line = null;
while ((line = reader.readLine()) != null) {
System.out.println("getInputStream " + line); //$NON-NLS-1$
}
} catch (Exception ex) {
// nothing to do
} finally {
InputStream is = process.getInputStream();
InputStreamReader din = new InputStreamReader(is, encoding);
BufferedReader reader = new BufferedReader(din);
try {
is.close();
String line = null;
while ((line = reader.readLine()) != null) {
System.out.println("getInputStream " + line); //$NON-NLS-1$
}
} catch (Exception ex) {
// nothing to do
} finally {
try {
is.close();
} catch (Exception ex) {
// nothing to do
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}.start();
@@ -132,23 +137,31 @@ public final class ProcessStreamTrashReaderUtil {
new Thread() {
public void run() {
InputStream is = process.getErrorStream();
InputStreamReader din = new InputStreamReader(is);
BufferedReader reader = new BufferedReader(din);
try {
String line = null;
while ((line = reader.readLine()) != null) {
System.out.println("getErrorStream " + line); //$NON-NLS-1$
throw new WarningException("AAAAA");
}
} catch (Exception ex) {
// nothing to do
} finally {
InputStream is = process.getErrorStream();
InputStreamReader din = new InputStreamReader(is, encoding);
BufferedReader reader = new BufferedReader(din);
StringBuilder strBuilder = new StringBuilder();
try {
is.close();
String line = null;
while ((line = reader.readLine()) != null) {
System.out.println("getErrorStream " + line); //$NON-NLS-1$
strBuilder.append(line).append("\n");
}
} catch (Exception ex) {
// nothing to do
} finally {
try {
is.close();
} catch (Exception ex) {
// nothing to do
}
}
if (!strBuilder.toString().replaceAll("[\n]", " ").trim().isEmpty()) {
throw new Exception(strBuilder.toString());
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}.start();
@@ -204,7 +217,7 @@ public final class ProcessStreamTrashReaderUtil {
String line = null;
while ((line = reader.readLine()) != null) {
System.out.println("getErrorStream " + line); //$NON-NLS-1$
if(line.startsWith("log4j:WARN")){
if(line.startsWith("log4j:WARN") || line.startsWith("SLF4J:")){
continue;
}
buffer.append(line);

View File

@@ -507,7 +507,7 @@ public class ProcessorUtilities {
mainRelation.setId(jobInfo.getJobId());
mainRelation.setVersion(jobInfo.getJobVersion());
mainRelation.setType(RelationshipItemBuilder.JOB_RELATION);
hasLoopDependency = checkLoopDependencies(mainRelation);
hasLoopDependency = checkLoopDependencies(mainRelation, new HashMap<String, String>());
// clean the previous code in case it has deleted subjob
cleanSourceFolder(progressMonitor, currentProcess, processor);
}
@@ -607,28 +607,29 @@ public class ProcessorUtilities {
return processor;
}
private static boolean checkLoopDependencies(Relation mainJobInfo) throws ProcessorException {
List<Relation> itemsJobRelatedTo = getItemsRelation(mainJobInfo);
private static boolean checkLoopDependencies(Relation mainJobInfo, Map<String, String> idToLastestVersionMap)
throws ProcessorException {
List<Relation> itemsJobRelatedTo = getItemsRelation(mainJobInfo, idToLastestVersionMap);
List<Relation> relationChecked = new ArrayList<>();
relationChecked.add(mainJobInfo);
return checkLoopDependencies(mainJobInfo, itemsJobRelatedTo, relationChecked);
return checkLoopDependencies(mainJobInfo, itemsJobRelatedTo, relationChecked, idToLastestVersionMap);
}
private static boolean checkLoopDependencies(Relation mainRelation, List<Relation> itemsJobRelatedTo,
List<Relation> relationChecked) throws ProcessorException {
List<Relation> relationChecked, Map<String, String> idToLastestVersionMap) throws ProcessorException {
boolean hasDependency = false;
for (Relation relation : itemsJobRelatedTo) {
hasDependency = relation.getId().equals(mainRelation.getId())
&& relation.getVersion().equals(mainRelation.getVersion());
if (!hasDependency) {
List<Relation> itemsChildJob = getItemsRelation(relation);
List<Relation> itemsChildJob = getItemsRelation(relation, idToLastestVersionMap);
if (!relationChecked.contains(relation)) {
relationChecked.add(relation);
hasDependency = checkLoopDependencies(mainRelation, itemsChildJob, relationChecked);
hasDependency = checkLoopDependencies(mainRelation, itemsChildJob, relationChecked, idToLastestVersionMap);
}
if (!hasDependency) {
for (Relation childRelation : itemsChildJob) {
hasDependency = checkLoopDependencies(childRelation);
hasDependency = checkLoopDependencies(childRelation, idToLastestVersionMap);
if (hasDependency) {
break;
}
@@ -643,7 +644,7 @@ public class ProcessorUtilities {
return hasDependency;
}
private static List<Relation> getItemsRelation(Relation mainJobInfo) throws ProcessorException {
private static List<Relation> getItemsRelation(Relation mainJobInfo, Map<String, String> idToLastestVersionMap) throws ProcessorException {
List<Relation> itemsJobRelatedTo = new ArrayList<Relation>();
try {
List<Project> allProjects = new ArrayList<Project>();
@@ -657,12 +658,17 @@ public class ProcessorUtilities {
mainJobInfo.getType(), RelationshipItemBuilder.JOBLET_RELATION));
for (Relation relation : itemsJobRelatedTo) {
if (relation.getVersion().equals(RelationshipItemBuilder.LATEST_VERSION)) {
for (Project project : allProjects) {
IRepositoryViewObject lastVersion =
ProxyRepositoryFactory.getInstance().getLastVersion(project, relation.getId());
if (lastVersion != null) {
relation.setVersion(lastVersion.getVersion());
break;
if (idToLastestVersionMap.containsKey(relation.getId())) {
relation.setVersion(idToLastestVersionMap.get(relation.getId()));
} else {
for (Project project : allProjects) {
IRepositoryViewObject lastVersion =
ProxyRepositoryFactory.getInstance().getLastVersion(project, relation.getId());
if (lastVersion != null) {
relation.setVersion(lastVersion.getVersion());
idToLastestVersionMap.put(relation.getId(), relation.getVersion());
break;
}
}
}
}
@@ -1017,7 +1023,7 @@ public class ProcessorUtilities {
mainRelation.setId(jobInfo.getJobId());
mainRelation.setVersion(jobInfo.getJobVersion());
mainRelation.setType(RelationshipItemBuilder.JOB_RELATION);
hasLoopDependency = checkLoopDependencies(mainRelation);
hasLoopDependency = checkLoopDependencies(mainRelation, new HashMap<String, String>());
// clean the previous code in case it has deleted subjob
cleanSourceFolder(progressMonitor, currentProcess, processor);
}
@@ -1184,10 +1190,9 @@ public class ProcessorUtilities {
IFolder srcFolder = processor.getTalendJavaProject().getProject().getFolder(codePath);
String jobPackageFolder = JavaResourcesHelper.getJobClassPackageFolder(currentProcess);
for (IResource resource : srcFolder.members()) {
if (resource.getProjectRelativePath().toPortableString().endsWith(jobPackageFolder)) {
break;
if (!resource.getProjectRelativePath().toPortableString().endsWith(jobPackageFolder)) {
resource.delete(true, progressMonitor);
}
resource.delete(true, progressMonitor);
}
} catch (CoreException e) {
ExceptionHandler.process(e);
@@ -2150,7 +2155,7 @@ public class ProcessorUtilities {
EList<NodeType> nodes = ptype.getNode();
String jobletPaletteType = null;
String frameWork = ptype.getFramework();
if (frameWork == null) {
if (StringUtils.isBlank(frameWork)) {
jobletPaletteType = ComponentCategory.CATEGORY_4_DI.getName();
} else if (frameWork.equals(HadoopConstants.FRAMEWORK_SPARK)) {
jobletPaletteType = ComponentCategory.CATEGORY_4_SPARK.getName();
@@ -2467,9 +2472,42 @@ public class ProcessorUtilities {
return doSupportDynamicHadoopConfLoading(property) && !isExportAsOSGI();
}
public static boolean isEsbJob(IProcess process) {
return isEsbJob(process, false);
}
public static boolean isEsbJob(String processId, String version) {
return esbJobs.contains(esbJobKey(processId, version));
}
public static boolean isEsbJob(IProcess process, boolean checkCurrentProcess) {
if (process instanceof IProcess2) {
if (checkCurrentProcess) {
for (INode n : process.getGraphicalNodes()) {
if (isEsbComponentName(n.getComponent().getName())) {
return true;
}
}
} else {
Set<JobInfo> infos = ProcessorUtilities.getChildrenJobInfo(((IProcess2) process).getProperty().getItem(), false);
for (JobInfo jobInfo : infos) {
ProcessType processType = jobInfo.getProcessItem().getProcess();
EList<NodeType> nodes = processType.getNode();
for (NodeType nodeType : nodes) {
if (isEsbComponentName(nodeType.getComponentName())) {
return true;
}
}
}
}
return false;
}
return false;
}
private static void addEsbJob(JobInfo jobInfo) {
if (esbJobs.contains(esbJobKey(jobInfo.getJobId(), jobInfo.getJobVersion()))) {

View File

@@ -35,6 +35,7 @@ import org.eclipse.aether.util.artifact.SubArtifact;
import org.eclipse.aether.util.listener.ChainedRepositoryListener;
import org.eclipse.aether.util.listener.ChainedTransferListener;
import org.eclipse.aether.util.repository.AuthenticationBuilder;
import org.talend.designer.maven.aether.util.TalendAetherProxySelector;
/**
* created by wchen on Aug 10, 2017 Detailled comment
@@ -72,6 +73,8 @@ public class RepositorySystemFactory {
.setLocalRepositoryManager(system.newLocalRepositoryManager(repositorySystemSession, localRepo));
repositorySystemSession.setTransferListener(new ChainedTransferListener());
repositorySystemSession.setRepositoryListener(new ChainedRepositoryListener());
repositorySystemSession.setProxySelector(new TalendAetherProxySelector());
sessions.put(localRepo, repositorySystemSession);
}
return repositorySystemSession;
@@ -107,6 +110,7 @@ public class RepositorySystemFactory {
Authentication auth = new AuthenticationBuilder().addUsername(userName).addPassword(password).build();
RemoteRepository distRepo = new RemoteRepository.Builder(repositoryId, "default", repositoryUrl).setAuthentication(auth)
.build();
distRepo = new RemoteRepository.Builder(distRepo).setProxy(new TalendAetherProxySelector().getProxy(distRepo)).build();
deployRequest.setRepository(distRepo);

View File

@@ -129,6 +129,7 @@ public class DynamicDistributionAetherUtils {
builder = builder.setAuthentication(auth);
}
RemoteRepository central = builder.build();
central = new RemoteRepository.Builder(central).setProxy(new TalendAetherProxySelector().getProxy(central)).build();
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(dependency);
@@ -180,6 +181,7 @@ public class DynamicDistributionAetherUtils {
builder = builder.setAuthentication(auth);
}
RemoteRepository central = builder.build();
central = new RemoteRepository.Builder(central).setProxy(new TalendAetherProxySelector().getProxy(central)).build();
VersionRangeRequest verRangeRequest = new VersionRangeRequest();
verRangeRequest.addRepository(central);
@@ -226,6 +228,7 @@ public class DynamicDistributionAetherUtils {
builder = builder.setAuthentication(auth);
}
RemoteRepository central = builder.build();
central = new RemoteRepository.Builder(central).setProxy(new TalendAetherProxySelector().getProxy(central)).build();
VersionRangeRequest verRangeRequest = new VersionRangeRequest();
verRangeRequest.addRepository(central);
@@ -299,6 +302,7 @@ public class DynamicDistributionAetherUtils {
LocalRepository localRepo = new LocalRepository(repositoryPath);
session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
session.setProxySelector(new TalendAetherProxySelector());
updateDependencySelector(session, monitor);

View File

@@ -0,0 +1,98 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.designer.maven.aether.util;
import org.eclipse.aether.repository.Authentication;
import org.eclipse.aether.repository.Proxy;
import org.eclipse.aether.repository.ProxySelector;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.util.repository.AuthenticationBuilder;
import org.eclipse.aether.util.repository.DefaultProxySelector;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.utils.network.TalendProxySelector;
/**
* DOC cmeng class global comment. Detailled comment
*/
public class TalendAetherProxySelector implements ProxySelector {
private boolean isTalendDebug = false;
public TalendAetherProxySelector() {
isTalendDebug = Boolean.valueOf(System.getProperty(TalendProxySelector.PROP_PRINT_LOGS, "false"));
}
@Override
public Proxy getProxy(RemoteRepository repository) {
/**
* Update each time in case the settings are changed
*/
Proxy proxy = createProxySelector().getProxy(repository);
if (isTalendDebug) {
try {
if (repository != null) {
String proxyStr = "";
if (proxy != null) {
proxyStr = proxy.getType() + " " + proxy.toString() + ", proxy user: "
+ (proxy.getAuthentication() != null ? "..." : "<empty>");
}
ExceptionHandler.log("Aether proxy> host: " + repository.getHost() + ", proxy: " + proxyStr);
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
return proxy;
}
private DefaultProxySelector createProxySelector() {
DefaultProxySelector proxySelector = new DefaultProxySelector();
javaDefaultProxy(proxySelector);
return proxySelector;
}
private void javaDefaultProxy(DefaultProxySelector proxySelector) {
String[] schemas = new String[] { "http", "https" };
for (String schema : schemas) {
Proxy proxy = createProxy(schema);
if (proxy != null) {
proxySelector.add(proxy, System.getProperty(schema + ".nonProxyHosts"));
}
}
}
private org.eclipse.aether.repository.Proxy createProxy(String schema) {
String proxyHost = System.getProperty(schema + ".proxyHost");
if (proxyHost == null) {
return null;
}
String proxyUser = System.getProperty(schema + ".proxyUser");
String proxyPassword = System.getProperty(schema + ".proxyPassword");
int proxyPort = Integer.parseInt(System.getProperty(schema + ".proxyPort", "8080"));
Authentication authentication = createAuthentication(proxyUser, proxyPassword);
org.eclipse.aether.repository.Proxy proxyObj = new org.eclipse.aether.repository.Proxy(schema, proxyHost, proxyPort,
authentication);
return proxyObj;
}
private Authentication createAuthentication(String proxyUser, String proxyPassword) {
Authentication authentication = null;
if (proxyUser != null) {
authentication = new AuthenticationBuilder().addUsername(proxyUser).addPassword(proxyPassword).build();
}
return authentication;
}
}

View File

@@ -11,4 +11,5 @@ ProjectPomProjectSettingPage_FilterPomLabel=Filter to use to generate poms:
ProjectPomProjectSettingPage_FilterErrorMessage=Invalid filter: {0}
ProjectPomProjectSettingPage.syncAllPomsButtonText=Force full re-synchronize poms
AbstractPersistentProjectSettingPage.syncAllPoms=Do you want to update all poms? \n This operation might take long time depends on your project size.
MavenProjectSettingPage.filterExampleMessage=Filter examples:\nlabel=myJob \t\t\t\t=> Generate only the job named "myJob"\n!(label=myJob) \t\t\t\t=> Generate any job except the one named "myJob"\n(path=folder1/folder2) \t\t\t=> Generate any job in the folder "folder1/folder2"\n(path=folder1/folder2)or(label=myJob)\t=> Generate any job in the folder "folder1/folder2" or named "myJob"\n(label=myJob)and(version=0.2) \t=> Generate only the job named "myJob" with version 0.2\n!((label=myJob)and(version=0.1)) \t=> Generate every jobs except the "myJob" version 0.1
MavenProjectSettingPage.filterExampleMessage=Filter examples:\nlabel=myJob \t\t\t\t=> Generate only the job named "myJob"\n!(label=myJob) \t\t\t\t=> Generate any job except the one named "myJob"\n(path=folder1/folder2) \t\t\t=> Generate any job in the folder "folder1/folder2"\n(path=folder1/folder2)or(label=myJob)\t=> Generate any job in the folder "folder1/folder2" or named "myJob"\n(label=myJob)and(version=0.2) \t=> Generate only the job named "myJob" with version 0.2\n!((label=myJob)and(version=0.1)) \t=> Generate every jobs except the "myJob" version 0.1
MavenProjectSettingPage.refModuleText=Set reference project modules in profile

View File

@@ -14,6 +14,7 @@ package org.talend.designer.maven.ui;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -118,6 +119,17 @@ public class MavenUIService implements IMavenUIService {
String studioUserSettingsFile = MavenPlugin.getMavenConfiguration().getUserSettingsFile();
// apply the user settings to MavenResolver
Dictionary<String, String> props = new Hashtable<String, String>();
Set<Object> keySet = System.getProperties().keySet();
if (keySet != null) {
for (Object keyObj : keySet) {
if (keyObj instanceof String) {
String key = keyObj.toString();
if (key.startsWith("org.ops4j.pax.url.mvn.")) {
props.put(key, System.getProperty(key));
}
}
}
}
if (studioUserSettingsFile != null && !"".equals(studioUserSettingsFile)) {
// change back to use the user settings after Pax-url-eather fix the space bug
props.put("org.ops4j.pax.url.mvn.settings", studioUserSettingsFile);

View File

@@ -46,6 +46,8 @@ public class MavenProjectSettingPage extends AbstractProjectSettingPage {
private IPreferenceStore preferenceStore;
private Button useProfileModuleCheckbox;
public MavenProjectSettingPage() {
noDefaultAndApplyButton();
}
@@ -79,6 +81,10 @@ public class MavenProjectSettingPage extends AbstractProjectSettingPage {
filterExampleLable.setText(Messages.getString("MavenProjectSettingPage.filterExampleMessage")); //$NON-NLS-1$
filterExampleLable.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
useProfileModuleCheckbox = new Button(parent, SWT.CHECK);
useProfileModuleCheckbox.setText(Messages.getString("MavenProjectSettingPage.refModuleText")); //$NON-NLS-1$
useProfileModuleCheckbox.setSelection(preferenceStore.getBoolean(MavenConstants.USE_PROFILE_MODULE));
filterText.setText(filter);
filterText.addModifyListener(new ModifyListener() {
@@ -109,6 +115,7 @@ public class MavenProjectSettingPage extends AbstractProjectSettingPage {
public void widgetSelected(SelectionEvent event) {
try {
preferenceStore.setValue(MavenConstants.POM_FILTER, filter);
preferenceStore.setValue(MavenConstants.USE_PROFILE_MODULE, useProfileModuleCheckbox.getSelection());
new AggregatorPomsHelper().syncAllPoms();
} catch (Exception e) {
ExceptionHandler.process(e);
@@ -127,6 +134,7 @@ public class MavenProjectSettingPage extends AbstractProjectSettingPage {
boolean ok = super.performOk();
if (preferenceStore != null) {
preferenceStore.setValue(MavenConstants.POM_FILTER, filter);
preferenceStore.setValue(MavenConstants.USE_PROFILE_MODULE, useProfileModuleCheckbox.getSelection());
}
return ok;
}

View File

@@ -393,8 +393,13 @@ public abstract class MavenCommandLauncher {
public void waitFinish(ILaunch launch) {
try {
boolean isCommandLine = CommonsPlugin.isHeadless();
while (!launchFinished) {
Thread.sleep(100);
if (isCommandLine) {
Thread.sleep(100);
} else {
waitStudioFinish();
}
// if terminated also
if (launch.getProcesses() != null && launch.getProcesses().length > 0) {
if (launch.getProcesses()[0].isTerminated()) {
@@ -409,5 +414,16 @@ public abstract class MavenCommandLauncher {
ExceptionHandler.process(e);
}
}
private void waitStudioFinish() throws InterruptedException {
org.eclipse.swt.widgets.Display display = org.eclipse.swt.widgets.Display.getCurrent();
if (display != null) {
if (!display.readAndDispatch()) {
display.sleep();
}
} else {
Thread.sleep(100);
}
}
}
}

View File

@@ -12,17 +12,29 @@
// ============================================================================
package org.talend.designer.maven.tools;
import static org.talend.designer.maven.model.TalendJavaProjectConstants.*;
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_AGGREGATORS;
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_BEANS;
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_CODES;
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_JOBS;
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_PIGUDFS;
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_POMS;
import static org.talend.designer.maven.model.TalendJavaProjectConstants.DIR_ROUTINES;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.model.Activation;
import org.apache.maven.model.Model;
import org.apache.maven.model.Profile;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -49,7 +61,6 @@ import org.talend.core.context.Context;
import org.talend.core.context.RepositoryContext;
import org.talend.core.model.general.ILibrariesService;
import org.talend.core.model.general.ModuleNeeded;
import org.talend.core.model.general.Project;
import org.talend.core.model.process.ProcessUtils;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.ProjectReference;
@@ -103,27 +114,25 @@ public class AggregatorPomsHelper {
return projectTechName;
}
public void createRootPom(List<String> modules, boolean force, IProgressMonitor monitor) throws Exception {
public void createRootPom(Model model, boolean force, IProgressMonitor monitor)
throws Exception {
IFile pomFile = getProjectRootPom();
if (force || !pomFile.exists()) {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put(MavenTemplateManager.KEY_PROJECT_NAME, projectTechName);
Model model = MavenTemplateManager.getCodeProjectTemplateModel(parameters);
if (modules != null && !modules.isEmpty()) {
model.setModules(modules);
}
PomUtil.savePom(monitor, model, pomFile);
}
}
public void createRootPom(IProgressMonitor monitor) throws Exception {
Model newModel = getCodeProjectTemplateModel();
IFile pomFile = getProjectRootPom();
List<String> modules = null;
if (pomFile != null && pomFile.exists()) {
Model model = MavenPlugin.getMavenModelManager().readMavenModel(pomFile);
modules = model.getModules();
Model oldModel = MavenPlugin.getMavenModelManager().readMavenModel(pomFile);
List<Profile> profiles = oldModel.getProfiles().stream()
.filter(profile -> matchModuleProfile(profile.getId(), projectTechName)).collect(Collectors.toList());
newModel.setModules(oldModel.getModules());
newModel.getProfiles().addAll(profiles);
}
createRootPom(modules, true, monitor);
createRootPom(newModel, true, monitor);
}
public void installRootPom(boolean force) throws Exception {
@@ -182,7 +191,14 @@ public class AggregatorPomsHelper {
private void updateCodeProject(IProgressMonitor monitor, ERepositoryObjectType codeType, boolean forceBuild) {
try {
ITalendProcessJavaProject codeProject = getCodesProject(codeType);
updateCodeProjectPom(monitor, codeType, codeProject.getProjectPom());
IFile pomFile;
if (codeProject == null) {
// try to recover from any damage of pom.
pomFile = getCodeFolder(codeType).getFile(TalendMavenConstants.POM_FILE_NAME);
} else {
pomFile = codeProject.getProjectPom();
}
updateCodeProjectPom(monitor, codeType, pomFile);
buildAndInstallCodesProject(monitor, codeType, true, forceBuild);
} catch (Exception e) {
ExceptionHandler.process(e);
@@ -283,37 +299,40 @@ public class AggregatorPomsHelper {
}
}
public void updateRefProjectModules(List<ProjectReference> references) {
public void updateRefProjectModules(List<ProjectReference> references, IProgressMonitor monitor) {
if (!needUpdateRefProjectModules()) {
return;
}
try {
List<String> modules = new ArrayList<>();
for (ProjectReference reference : references) {
String refProjectTechName = reference.getReferencedProject().getTechnicalLabel();
String modulePath = "../../" + refProjectTechName + "/" + TalendJavaProjectConstants.DIR_POMS; //$NON-NLS-1$ //$NON-NLS-2$
modules.add(modulePath);
}
Project mainProject = ProjectManager.getInstance().getCurrentProject();
IFolder mainPomsFolder = new AggregatorPomsHelper(mainProject.getTechnicalLabel()).getProjectPomsFolder();
IFile mainPomFile = mainPomsFolder.getFile(TalendMavenConstants.POM_FILE_NAME);
Model model = MavenPlugin.getMavenModelManager().readMavenModel(mainPomFile);
List<String> oldModules = model.getModules();
if (oldModules == null) {
oldModules = new ArrayList<>();
}
ListIterator<String> iterator = oldModules.listIterator();
while (iterator.hasNext()) {
String modulePath = iterator.next();
if (modulePath.startsWith("../../")) { //$NON-NLS-1$
iterator.remove();
Model model = MavenPlugin.getMavenModelManager().readMavenModel(getProjectRootPom());
if (PomIdsHelper.useProfileModule()) {
List<Profile> profiles = collectRefProjectProfiles(references);
Iterator<Profile> iterator = model.getProfiles().listIterator();
while (iterator.hasNext()) {
Profile profile = iterator.next();
if (matchModuleProfile(profile.getId(), projectTechName)) {
iterator.remove();
}
}
model.getProfiles().addAll(profiles);
} else {
List<String> refPrjectModules = new ArrayList<>();
references.forEach(reference -> {
String refProjectTechName = reference.getReferencedProject().getTechnicalLabel();
String modulePath = "../../" + refProjectTechName + "/" + TalendJavaProjectConstants.DIR_POMS; //$NON-NLS-1$ //$NON-NLS-2$
refPrjectModules.add(modulePath);
});
List<String> modules = model.getModules();
Iterator<String> iterator = modules.listIterator();
while (iterator.hasNext()) {
String modulePath = iterator.next();
if (modulePath.startsWith("../../")) { //$NON-NLS-1$
iterator.remove();
}
}
modules.addAll(refPrjectModules);
}
oldModules.addAll(modules);
PomUtil.savePom(null, model, mainPomFile);
createRootPom(model, true, monitor);
} catch (Exception e) {
ExceptionHandler.process(e);
}
@@ -517,9 +536,10 @@ public class AggregatorPomsHelper {
}
/**
* without create/open project
* without create/open project<br/>
* Use Function to get the relativePath from property at realtime, since the property may be changed
*/
public static IFolder getItemPomFolder(Property property, String realVersion) {
public static IFolder getItemPomFolder(Property property, String realVersion, Function<Property, IPath> getItemRelativePath) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
ITestContainerProviderService testContainerService =
(ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(
@@ -537,7 +557,7 @@ public class AggregatorPomsHelper {
}
String projectTechName = ProjectManager.getInstance().getProject(property).getTechnicalLabel();
AggregatorPomsHelper helper = new AggregatorPomsHelper(projectTechName);
IPath itemRelativePath = ItemResourceUtil.getItemRelativePath(property);
IPath itemRelativePath = getItemRelativePath.apply(property);
String version = realVersion == null ? property.getVersion() : realVersion;
String jobFolderName = getJobProjectFolderName(property.getLabel(), version);
ERepositoryObjectType type = ERepositoryObjectType.getItemType(property.getItem());
@@ -546,6 +566,10 @@ public class AggregatorPomsHelper {
return jobFolder;
}
public static IFolder getItemPomFolder(Property property, String realVersion) {
return getItemPomFolder(property, realVersion, p -> ItemResourceUtil.getItemRelativePath(p));
}
private static void createFoldersIfNeeded(IFolder folder) {
if (!folder.exists()) {
if (folder.getParent() instanceof IFolder) {
@@ -671,6 +695,23 @@ public class AggregatorPomsHelper {
new ProgressMonitorDialog(Display.getDefault().getActiveShell()).run(true, true, runnableWithProgress);
}
public void syncParentJobPomsForPropertyChange(Property property) {
IRunProcessService runProcessService = getRunProcessService();
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
List<Relation> itemsHaveRelationWith = RelationshipItemBuilder.getInstance().getItemsHaveRelationWith(property.getId(),
property.getVersion());
try {
for (Relation relation : itemsHaveRelationWith) {
IRepositoryViewObject object = factory.getSpecificVersion(relation.getId(), relation.getVersion(), true);
if (runProcessService != null) {
runProcessService.generatePom(object.getProperty().getItem());
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
private String getModulePath(IFile pomFile) {
IFile parentPom = getProjectRootPom();
if (parentPom != null) {
@@ -680,47 +721,48 @@ public class AggregatorPomsHelper {
return null;
}
private void collectModules(List<String> modules) {
IRunProcessService service = getRunProcessService();
if (service != null) {
modules.add(
getModulePath(service.getTalendCodeJavaProject(ERepositoryObjectType.ROUTINES).getProjectPom()));
if (ProcessUtils.isRequiredPigUDFs(null)) {
modules.add(
getModulePath(service.getTalendCodeJavaProject(ERepositoryObjectType.PIG_UDF).getProjectPom()));
}
if (ProcessUtils.isRequiredBeans(null)) {
modules.add(getModulePath(service
.getTalendCodeJavaProject(ERepositoryObjectType.valueOf("BEANS")) //$NON-NLS-1$
.getProjectPom()));
}
private List<Profile> collectRefProjectProfiles(List<ProjectReference> references) throws CoreException {
if (!needUpdateRefProjectModules()) {
Model model = MavenPlugin.getMavenModelManager().readMavenModel(getProjectRootPom());
List<Profile> profiles = model.getProfiles();
return profiles.stream().filter(profile -> matchModuleProfile(profile.getId(), projectTechName))
.collect(Collectors.toList());
}
if (needUpdateRefProjectModules()) {
List<ProjectReference> references =
ProjectManager.getInstance().getCurrentProject().getProjectReferenceList(true);
for (ProjectReference reference : references) {
String refProjectTechName = reference.getReferencedProject().getTechnicalLabel();
String modulePath = "../../" + refProjectTechName + "/" + TalendJavaProjectConstants.DIR_POMS; //$NON-NLS-1$ //$NON-NLS-2$
modules.add(modulePath);
}
} else {
Project mainProject = ProjectManager.getInstance().getCurrentProject();
IFolder mainPomsFolder = new AggregatorPomsHelper(mainProject.getTechnicalLabel()).getProjectPomsFolder();
IFile mainPomFile = mainPomsFolder.getFile(TalendMavenConstants.POM_FILE_NAME);
try {
Model model = MavenPlugin.getMavenModelManager().readMavenModel(mainPomFile);
List<String> oldModules = model.getModules();
if (oldModules != null) {
for (String modulePath : oldModules) {
if (modulePath.startsWith("../../")) { //$NON-NLS-1$
modules.add(modulePath);
}
}
}
} catch (CoreException e) {
ExceptionHandler.process(e);
}
if (references == null) {
references = ProjectManager.getInstance().getCurrentProject().getProjectReferenceList(true);
}
List<Profile> profiles = new ArrayList<>();
references.forEach(reference -> {
String refProjectTechName = reference.getReferencedProject().getTechnicalLabel();
String modulePath = "../../" + refProjectTechName + "/" + TalendJavaProjectConstants.DIR_POMS; //$NON-NLS-1$ //$NON-NLS-2$
Profile profile = new Profile();
profile.setId((projectTechName + "_" + refProjectTechName).toLowerCase()); //$NON-NLS-1$
Activation activation = new Activation();
activation.setActiveByDefault(true);
profile.setActivation(activation);
profile.getModules().add(modulePath);
profiles.add(profile);
});
return profiles;
}
private List<String> collectRefProjectModules(List<ProjectReference> references) throws CoreException {
if (!needUpdateRefProjectModules()) {
Model model = MavenPlugin.getMavenModelManager().readMavenModel(getProjectRootPom());
return model.getModules().stream().filter(modulePath -> modulePath.startsWith("../../")) //$NON-NLS-1$
.collect(Collectors.toList());
}
if (references == null) {
references = ProjectManager.getInstance().getCurrentProject().getProjectReferenceList(true);
}
List<String> modules = new ArrayList<>();
references.forEach(reference -> {
String refProjectTechName = reference.getReferencedProject().getTechnicalLabel();
String modulePath = "../../" + refProjectTechName + "/" + TalendJavaProjectConstants.DIR_POMS; //$NON-NLS-1$ //$NON-NLS-2$
modules.add(modulePath);
});
return modules;
}
public boolean needUpdateRefProjectModules() {
@@ -758,7 +800,13 @@ public class AggregatorPomsHelper {
monitor.beginTask("", size); //$NON-NLS-1$
// project pom
monitor.subTask("Synchronize project pom"); //$NON-NLS-1$
createRootPom(null, true, monitor);
Model model = getCodeProjectTemplateModel();
if (PomIdsHelper.useProfileModule()) {
model.getProfiles().addAll(collectRefProjectProfiles(null));
} else {
model.getModules().addAll(collectRefProjectModules(null));
}
createRootPom(model, true, monitor);
installRootPom(true);
monitor.worked(1);
if (monitor.isCanceled()) {
@@ -811,8 +859,9 @@ public class AggregatorPomsHelper {
}
// sync project pom again with all modules.
monitor.subTask("Synchronize project pom with modules"); //$NON-NLS-1$
collectModules(modules);
createRootPom(modules, true, monitor);
collectCodeModules(modules);
model.getModules().addAll(modules);
createRootPom(model, true, monitor);
installRootPom(true);
monitor.worked(1);
if (monitor.isCanceled()) {
@@ -821,6 +870,21 @@ public class AggregatorPomsHelper {
monitor.done();
}
private void collectCodeModules(List<String> modules) {
// collect codes modules
IRunProcessService service = getRunProcessService();
if (service != null) {
modules.add(getModulePath(service.getTalendCodeJavaProject(ERepositoryObjectType.ROUTINES).getProjectPom()));
if (ProcessUtils.isRequiredPigUDFs(null)) {
modules.add(getModulePath(service.getTalendCodeJavaProject(ERepositoryObjectType.PIG_UDF).getProjectPom()));
}
if (ProcessUtils.isRequiredBeans(null)) {
modules.add(getModulePath(service.getTalendCodeJavaProject(ERepositoryObjectType.valueOf("BEANS")) //$NON-NLS-1$
.getProjectPom()));
}
}
}
/**
* Check if is a esb data service job
*
@@ -849,6 +913,18 @@ public class AggregatorPomsHelper {
return null;
}
private Model getCodeProjectTemplateModel() {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put(MavenTemplateManager.KEY_PROJECT_NAME, projectTechName);
return MavenTemplateManager.getCodeProjectTemplateModel(parameters);
}
public static boolean matchModuleProfile(String profileId, String projectTechName) {
// FIXME get profile id from extension point.
List<String> otherProfiles = Arrays.asList("docker", "cloud-publisher", "nexus"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return !otherProfiles.contains(profileId) && StringUtils.startsWithIgnoreCase(profileId, projectTechName + "_");
}
private static IRunProcessService getRunProcessService() {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService runProcessService =

View File

@@ -24,7 +24,6 @@ import java.util.Set;
import org.apache.maven.model.Model;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -47,7 +46,6 @@ import org.talend.designer.maven.utils.MavenProjectUtils;
import org.talend.designer.maven.utils.PomUtil;
import org.talend.designer.runprocess.IRunProcessService;
import org.talend.repository.ProjectManager;
import org.talend.repository.model.IRepositoryService;
/**
* DOC zwxue class global comment. Detailled comment
@@ -271,6 +269,7 @@ public class BuildCacheManager {
public void clearAllCaches() {
jobCache.clear();
clearCurrentJobletCache();
jobletCache.clear();
codesLastBuildCache.clear();
}
@@ -330,38 +329,9 @@ public class BuildCacheManager {
}
private String getModulePath(Property property) {
String modulePath = null;
IPath basePath = null;
IPath jobProjectPath = AggregatorPomsHelper.getItemPomFolder(property).getLocation();
ProjectManager proManager = ProjectManager.getInstance();
if (!proManager.isInCurrentMainProject(property)) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRepositoryService.class)) {
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault()
.getService(IRepositoryService.class);
if (service.isGIT()) {
String refProjectTechName = proManager.getCurrentProject().getTechnicalLabel();
String mainProjectBranch = proManager.getMainProjectBranch(refProjectTechName);
if ("master".equals(mainProjectBranch)) {
modulePath = "../../../../"; //$NON-NLS-1$
} else {
modulePath = "../../../../../"; //$NON-NLS-1$
}
basePath = ResourcesPlugin.getWorkspace().getRoot().getLocation().append("/.repositories"); //$NON-NLS-1$
} else if (service.isSVN()) {
modulePath = "../../"; //$NON-NLS-1$
basePath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
}
}
if (modulePath == null || basePath == null) {
throw new RuntimeException("modulePath or basePath can not be null!"); //$NON-NLS-1$
}
} else {
modulePath = ""; //$NON-NLS-1$
basePath = getAggregatorPomsHelper().getProjectPomsFolder().getLocation();
}
jobProjectPath = jobProjectPath.makeRelativeTo(basePath);
modulePath += jobProjectPath.toPortableString();
IPath basePath = getAggregatorPomsHelper().getProjectPomsFolder().getLocation();
String modulePath = jobProjectPath.makeRelativeTo(basePath).toPortableString();
return modulePath;
}

View File

@@ -69,13 +69,7 @@ public class ProjectPomManager {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
Model projectModel = MODEL_MANAGER.readMavenModel(projectPomFile);
Model templateModel = MavenTemplateManager.getCodeProjectTemplateModel();
for (String module : projectModel.getModules()) {
templateModel.addModule(module);
}
PomUtil.savePom(monitor, templateModel, projectPomFile);
new AggregatorPomsHelper().createRootPom(monitor);
}
/**

View File

@@ -55,6 +55,7 @@ import org.talend.core.model.process.ProcessUtils;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.Project;
import org.talend.core.model.properties.Property;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.utils.JavaResourcesHelper;
import org.talend.core.repository.utils.ItemResourceUtil;
import org.talend.core.runtime.maven.MavenArtifact;
@@ -203,15 +204,12 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
}
}
// same as JavaProcessor.initCodePath
String jobClassPackageFolder = JavaResourcesHelper.getJobClassPackageFolder(property.getItem());
Project project = ProjectManager.getInstance().getProject(property);
if (project == null) { // current project
project = ProjectManager.getInstance().getCurrentProject().getEmfProject();
}
checkPomProperty(properties, "talend.job.path", ETalendMavenVariables.JobPath, jobClassPackageFolder);
String talendJobPath = project.getTechnicalLabel().toLowerCase();
checkPomProperty(properties, "talend.job.path", ETalendMavenVariables.JobPath, talendJobPath);
IPath jobFolderPath = ItemResourceUtil.getItemRelativePath(property);
String jobFolder = "";
if (jobFolderPath != null && !StringUtils.isEmpty(jobFolderPath.toPortableString())) {
@@ -595,7 +593,10 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
mainProjectBranch = "";
}
}
jobInfoContent = StringUtils.replace(jobInfoContent, "${talend.project.branch}", mainProjectBranch);
if (!isOptionChecked(TalendProcessArgumentConstant.ARG_AVOID_BRANCH_NAME)) {
jobInfoContent = StringUtils.replace(jobInfoContent, "${talend.project.branch}", mainProjectBranch);
}
IFolder templateFolder = codeProject.getTemplatesFolder();
IFile shFile = templateFolder.getFile(IProjectSettingTemplateConstants.JOB_RUN_SH_TEMPLATE_FILE_NAME);
@@ -610,7 +611,7 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
}
protected void updateDependencySet(IFile assemblyFile) {
Set<String> jobCoordinate = new HashSet<>();
Map<String, Dependency> jobCoordinateMap = new HashMap<String, Dependency>();
Set<JobInfo> childrenJobInfo = new HashSet<>();
if (!hasLoopDependency()) {
childrenJobInfo = getJobProcessor().getBuildChildrenJobs();
@@ -619,20 +620,26 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
// add children jobs
for (JobInfo jobInfo : childrenJobInfo) {
Property property = jobInfo.getProcessItem().getProperty();
String coordinate = getCoordinate(PomIdsHelper.getJobGroupId(property), PomIdsHelper.getJobArtifactId(jobInfo),
MavenConstants.PACKAGING_JAR, PomIdsHelper.getJobVersion(property));
jobCoordinate.add(coordinate);
String coordinate =
getCoordinate(PomIdsHelper.getJobGroupId(property), PomIdsHelper.getJobArtifactId(jobInfo),
MavenConstants.PACKAGING_JAR, PomIdsHelper.getJobVersion(property), null);
Dependency dependency = PomUtil.createDependency(PomIdsHelper.getJobGroupId(property),
PomIdsHelper.getJobArtifactId(jobInfo), PomIdsHelper.getJobVersion(property), MavenConstants.PACKAGING_JAR);
jobCoordinateMap.put(coordinate, dependency);
}
// add parent job
Property parentProperty = this.getJobProcessor().getProperty();
String parentCoordinate = getCoordinate(PomIdsHelper.getJobGroupId(parentProperty),
PomIdsHelper.getJobArtifactId(parentProperty), MavenConstants.PACKAGING_JAR,
PomIdsHelper.getJobVersion(parentProperty));
jobCoordinate.add(parentCoordinate);
String parentCoordinate =
getCoordinate(PomIdsHelper.getJobGroupId(parentProperty), PomIdsHelper.getJobArtifactId(parentProperty),
MavenConstants.PACKAGING_JAR, PomIdsHelper.getJobVersion(parentProperty), null);
Dependency parentDependency = PomUtil.createDependency(PomIdsHelper.getJobGroupId(parentProperty),
PomIdsHelper.getJobArtifactId(parentProperty), PomIdsHelper.getJobVersion(parentProperty),
MavenConstants.PACKAGING_JAR);
jobCoordinateMap.put(parentCoordinate, parentDependency);
// add talend libraries and codes
Set<String> talendLibCoordinate = new HashSet<>();
Map<String, Dependency> talendLibCoordinateMap = new HashMap<String, Dependency>();
String projectTechName = ProjectManager.getInstance().getProject(parentProperty).getTechnicalLabel();
String projectGroupId = PomIdsHelper.getProjectGroupId(projectTechName);
@@ -640,7 +647,7 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
List<Dependency> dependencies = new ArrayList<>();
addCodesDependencies(dependencies);
for (Dependency dependency : dependencies) {
talendLibCoordinate.add(getCoordinate(dependency));
talendLibCoordinateMap.put(getCoordinate(dependency), dependency);
}
// libraries
@@ -659,23 +666,23 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
}
String dependencyGroupId = dependency.getGroupId();
String coordinate = getCoordinate(dependency);
if (!jobCoordinate.contains(coordinate)) {
if (!jobCoordinateMap.containsKey(coordinate)) {
if (MavenConstants.DEFAULT_LIB_GROUP_ID.equals(dependencyGroupId)) {
talendLibCoordinate.add(coordinate);
talendLibCoordinateMap.put(coordinate, dependency);
}
}
}
// add 3rd party libraries
Set<String> _3rdDepLib = new HashSet<>();
Map<String, Dependency> _3rdDepLibMap = new HashMap<String, Dependency>();
Map<String, Set<Dependency>> duplicateLibs = new HashMap<>();
for (Dependency dependency : dependencies) {
if (MavenConstants.PACKAGING_POM.equals(dependency.getType())) {
continue;
}
String coordinate = getCoordinate(dependency);
if (!jobCoordinate.contains(coordinate) && !talendLibCoordinate.contains(coordinate)) {
_3rdDepLib.add(coordinate);
if (!jobCoordinateMap.containsKey(coordinate) && !talendLibCoordinateMap.containsKey(coordinate)) {
_3rdDepLibMap.put(coordinate, dependency);
addToDuplicateLibs(duplicateLibs, dependency);
}
}
@@ -692,20 +699,40 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
}
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(moduleNeeded.getMavenUri());
String coordinate = getCoordinate(artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(),
artifact.getVersion());
if (!jobCoordinate.contains(coordinate) && !talendLibCoordinate.contains(coordinate)
&& !_3rdDepLib.contains(coordinate)) {
artifact.getVersion(), artifact.getClassifier());
if (!jobCoordinateMap.containsKey(coordinate) && !talendLibCoordinateMap.containsKey(coordinate)
&& !_3rdDepLibMap.containsKey(coordinate)) {
Dependency dependencyObject = PomUtil.createDependency(artifact.getGroupId(), artifact.getArtifactId(),
artifact.getVersion(), artifact.getType(), artifact.getClassifier());
if (MavenConstants.DEFAULT_LIB_GROUP_ID.equals(artifact.getGroupId())
|| artifact.getGroupId().startsWith(projectGroupId)) {
talendLibCoordinate.add(coordinate);
talendLibCoordinateMap.put(coordinate, dependencyObject);
} else {
_3rdDepLib.add(coordinate);
Dependency dependency = PomUtil.createDependency(artifact.getGroupId(), artifact.getArtifactId(),
artifact.getVersion(), artifact.getType(), artifact.getClassifier());
_3rdDepLibMap.put(coordinate, dependencyObject);
Dependency dependency = PomUtil
.createDependency(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
artifact.getType(), artifact.getClassifier());
addToDuplicateLibs(duplicateLibs, dependency);
}
}
}
try {
Set<Dependency> codesDependencies = new HashSet<Dependency>();
for (ERepositoryObjectType type : ERepositoryObjectType.getAllTypesOfCodes()) {
codesDependencies.addAll(PomUtil.getCodesDependencies(type));
}
for (Dependency codeDependency : codesDependencies) {
Dependency dependency = PomUtil.createDependency(codeDependency.getGroupId(), codeDependency.getArtifactId(),
codeDependency.getVersion(), codeDependency.getType(), codeDependency.getClassifier());
if (dependency != null) {
addToDuplicateLibs(duplicateLibs, dependency);
}
}
} catch (CoreException e1) {
ExceptionHandler.process(e1);
}
Iterator<String> iterator = duplicateLibs.keySet().iterator();
while (iterator.hasNext()) {
@@ -717,7 +744,7 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
} else {
// remove duplicated dependencies from 3rd lib list
for (Dependency dependency : dupDependencies) {
_3rdDepLib.remove(getCoordinate(dependency));
_3rdDepLibMap.remove(getCoordinate(dependency));
}
}
}
@@ -725,12 +752,13 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
try {
Document document = PomUtil.loadAssemblyFile(null, assemblyFile);
// add talend libs & codes
setupDependencySetNode(document, talendLibCoordinate, "lib", "${artifact.artifactId}.${artifact.extension}", false);
setupDependencySetNode(document, talendLibCoordinateMap, "lib", "${artifact.artifactId}.${artifact.extension}",
false, false);
// add 3rd party libs <dependencySet>
setupDependencySetNode(document, _3rdDepLib, "lib", null, false);
setupDependencySetNode(document, _3rdDepLibMap, "lib", null, false, false);
// add jobs
setupDependencySetNode(document, jobCoordinate, "${talend.job.name}",
"${artifact.build.finalName}.${artifact.extension}", true);
setupDependencySetNode(document, jobCoordinateMap, "${talend.job.name}",
"${artifact.build.finalName}.${artifact.extension}", true, false);
// add duplicate dependencies if exists
setupFileNode(document, duplicateLibs);
@@ -741,24 +769,50 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
}
private String getCoordinate(Dependency dependency) {
return getCoordinate(dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(), dependency.getVersion());
return getCoordinate(dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(),
dependency.getVersion(), dependency.getClassifier());
}
protected String getCoordinate(String groupId, String artifactId, String type, String version) {
protected String getCoordinate(String groupId, String artifactId, String type, String version, String classifier) {
String separator = ":"; //$NON-NLS-1$
String coordinate = groupId + separator;
coordinate += artifactId + separator;
if (type != null) {
coordinate += type;
}
if (version != null) {
coordinate += separator + version;
}
if (StringUtils.isNotBlank(classifier)) {
coordinate += separator + classifier;
}
return coordinate;
}
protected String getAssemblyCoordinate(Dependency dependency) {
String separator = ":"; //$NON-NLS-1$
String coordinate = dependency.getGroupId() + separator;
coordinate += dependency.getArtifactId() + separator;
if (dependency.getType() != null) {
coordinate += dependency.getType();
}
if (dependency.getClassifier() != null) {
coordinate += separator + "*";
}
if (dependency.getVersion() != null) {
coordinate += separator + dependency.getVersion();
}
return coordinate;
}
private void addToDuplicateLibs(Map<String, Set<Dependency>> map, Dependency dependency) {
String coordinate = getCoordinate(dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(), null);
String coordinate =
getCoordinate(dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(), null,
dependency.getClassifier());
if (!map.containsKey(coordinate)) {
Set<Dependency> set = new HashSet<>();
map.put(coordinate, set);
@@ -766,8 +820,8 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
map.get(coordinate).add(dependency);
}
protected void setupDependencySetNode(Document document, Set<String> libIncludes, String outputDir, String fileNameMapping,
boolean useProjectArtifact) {
protected void setupDependencySetNode(Document document, Map<String, Dependency> libIncludes, String outputDir,
String fileNameMapping, boolean useProjectArtifact, boolean unpack) {
if (libIncludes.isEmpty()) {
return;
}
@@ -778,16 +832,18 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
Node dependencySetNode = document.createElement("dependencySet");
dependencySetsNode.appendChild(dependencySetNode);
Node outputDirNode = document.createElement("outputDirectory");
outputDirNode.setTextContent(outputDir);
dependencySetNode.appendChild(outputDirNode);
if (StringUtils.isNotBlank(outputDir)) {
Node outputDirNode = document.createElement("outputDirectory");
outputDirNode.setTextContent(outputDir);
dependencySetNode.appendChild(outputDirNode);
}
Node includesNode = document.createElement("includes");
dependencySetNode.appendChild(includesNode);
for (String include : libIncludes) {
for (Dependency dependency : libIncludes.values()) {
Node includeNode = document.createElement("include");
includeNode.setTextContent(include);
includeNode.setTextContent(getAssemblyCoordinate(dependency));
includesNode.appendChild(includeNode);
}
@@ -801,6 +857,12 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
useProjectArtifactNode.setTextContent(Boolean.toString(useProjectArtifact));
dependencySetNode.appendChild(useProjectArtifactNode);
if (unpack) {
Node unpackNode = document.createElement("unpack");
unpackNode.setTextContent(Boolean.TRUE.toString());
dependencySetNode.appendChild(unpackNode);
}
}
private void setupFileNode(Document document, Map<String, Set<Dependency>> duplicateDependencies) {

View File

@@ -123,7 +123,9 @@ public class CreateMavenJobletPom extends AbstractMavenProcessorPom {
@Override
protected void addDependencies(Model model) {
try {
getProcessorDependenciesManager().updateDependencies(null, model);
if (ERepositoryObjectType.JOBLET == ERepositoryObjectType.getType(getJobProcessor().getProperty())) {
getProcessorDependenciesManager().updateDependencies(null, model);
}
addChildrenDependencies(model.getDependencies());
} catch (ProcessorException e) {
ExceptionHandler.process(e);

View File

@@ -18,12 +18,12 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.maven.model.Build;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginExecution;
@@ -213,28 +213,34 @@ public class CreateMavenStandardJobOSGiPom extends CreateMavenJobPom {
@Override
protected void updateDependencySet(IFile assemblyFile) {
Set<String> jobCoordinate = new HashSet<>();
Map<String, Dependency> jobCoordinateMap = new HashMap<String, Dependency>();
if (!hasLoopDependency()) {
// add children jobs
Set<JobInfo> childrenJobInfo = getJobProcessor().getBuildChildrenJobs();
for (JobInfo jobInfo : childrenJobInfo) {
Property property = jobInfo.getProcessItem().getProperty();
String coordinate = getCoordinate(PomIdsHelper.getJobGroupId(property), PomIdsHelper.getJobArtifactId(jobInfo),
MavenConstants.PACKAGING_JAR, PomIdsHelper.getJobVersion(property));
jobCoordinate.add(coordinate);
MavenConstants.PACKAGING_JAR, PomIdsHelper.getJobVersion(property), null);
Dependency dependency = PomUtil.createDependency(PomIdsHelper.getJobGroupId(property),
PomIdsHelper.getJobArtifactId(jobInfo), PomIdsHelper.getJobVersion(property),
MavenConstants.PACKAGING_JAR);
jobCoordinateMap.put(coordinate, dependency);
}
}
// add parent job
Property parentProperty = this.getJobProcessor().getProperty();
String parentCoordinate = getCoordinate(PomIdsHelper.getJobGroupId(parentProperty),
PomIdsHelper.getJobArtifactId(parentProperty), MavenConstants.PACKAGING_JAR,
PomIdsHelper.getJobVersion(parentProperty));
jobCoordinate.add(parentCoordinate);
PomIdsHelper.getJobVersion(parentProperty), null);
Dependency parentDependency = PomUtil.createDependency(PomIdsHelper.getJobGroupId(parentProperty),
PomIdsHelper.getJobArtifactId(parentProperty), PomIdsHelper.getJobVersion(parentProperty),
MavenConstants.PACKAGING_JAR);
jobCoordinateMap.put(parentCoordinate, parentDependency);
try {
Document document = PomUtil.loadAssemblyFile(null, assemblyFile);
// add jobs
setupDependencySetNode(document, jobCoordinate, "${talend.job.name}",
"${artifact.build.finalName}.${artifact.extension}", true);
setupDependencySetNode(document, jobCoordinateMap, null, "${artifact.build.finalName}.${artifact.extension}", true,
true);
PomUtil.saveAssemblyFile(assemblyFile, document);
} catch (Exception e) {
ExceptionHandler.process(e);

View File

@@ -260,6 +260,12 @@ public class PomIdsHelper {
return manager.getValue(MavenConstants.POM_FILTER);
}
public static boolean useProfileModule() {
String projectTechName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
ProjectPreferenceManager manager = getPreferenceManager(projectTechName);
return manager.getBoolean(MavenConstants.USE_PROFILE_MODULE);
}
private static String getGroupId(String projectTechName, String baseName, Property property) {
if (projectTechName == null) {
projectTechName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();

View File

@@ -27,10 +27,12 @@ import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
@@ -78,6 +80,7 @@ import org.talend.core.model.process.JobInfo;
import org.talend.core.model.process.ProcessUtils;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.Property;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.utils.JavaResourcesHelper;
import org.talend.core.nexus.TalendMavenResolver;
import org.talend.core.runtime.maven.MavenArtifact;
@@ -90,6 +93,7 @@ import org.talend.designer.maven.model.TalendMavenConstants;
import org.talend.designer.maven.template.MavenTemplateManager;
import org.talend.designer.maven.tools.ProcessorDependenciesManager;
import org.talend.designer.runprocess.IProcessor;
import org.talend.designer.runprocess.IRunProcessService;
import org.talend.repository.ProjectManager;
import org.w3c.dom.Attr;
import org.w3c.dom.DOMImplementation;
@@ -116,7 +120,9 @@ public class PomUtil {
if (pomFile == null) {
throw new NullPointerException("the output file is null.");
}
Properties properties = new Properties();
properties.putAll(model.getProperties());
model.setProperties(properties);
/*
* copied the codes from createMavenModel of MavenModelManager
*/
@@ -138,7 +144,9 @@ public class PomUtil {
if (pomFile == null) {
throw new NullPointerException("the output file is null.");
}
Properties properties = new Properties();
properties.putAll(model.getProperties());
model.setProperties(properties);
ByteArrayOutputStream buf = new ByteArrayOutputStream();
MavenPlugin.getMaven().writeModel(model, buf);
@@ -1017,4 +1025,34 @@ public class PomUtil {
|| pathname.getName().equals("m2e-lastUpdated.properties"); //$NON-NLS-1$
}
};
public static boolean checkIfJobDependencyExist(IFile parentJobPom, Property property) throws Exception {
boolean found = false;
Model model = MavenPlugin.getMavenModelManager().readMavenModel(parentJobPom);
String groupId = PomIdsHelper.getJobGroupId(property);
String artifactId = PomIdsHelper.getJobArtifactId(property);
String version = PomIdsHelper.getJobVersion(property);
for (Dependency dependency : model.getDependencies()) {
if (dependency.getGroupId().equals(groupId) && dependency.getArtifactId().equals(artifactId)
&& dependency.getVersion().equals(version)) {
found = true;
break;
}
}
return found;
}
public static Set<Dependency> getCodesDependencies(ERepositoryObjectType codeType) throws CoreException {
Set<Dependency> dependencies = new HashSet<Dependency>();
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService runProcessService = (IRunProcessService) GlobalServiceRegister.getDefault()
.getService(IRunProcessService.class);
ITalendProcessJavaProject talendCodeJavaProject = runProcessService.getTalendCodeJavaProject(codeType);
IFile projectPom = talendCodeJavaProject.getProjectPom();
Model model = MODEL_MANAGER.readMavenModel(projectPom);
dependencies.addAll(model.getDependencies());
}
return dependencies;
}
}

View File

@@ -10,4 +10,37 @@ public class SortableDependency extends Dependency implements Comparable<Sortabl
return getArtifactId().compareTo(o.getArtifactId());
}
@Override
public int hashCode() {
int result = 17;
result = 31 * result + (getGroupId() == null ? 0 : getGroupId().hashCode());
result = 31 * result + (getArtifactId() == null ? 0 : getArtifactId().hashCode());
result = 31 * result + (getVersion() == null ? 0 : getVersion().hashCode());
result = 31 * result + (getType() == null ? 0 : getType().hashCode());
result = 31 * result + (getClassifier() == null ? 0 : getClassifier().hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof SortableDependency)) {
return false;
}
SortableDependency caseobj = (SortableDependency) obj;
return (getGroupId() == caseobj.getGroupId() || (getGroupId() != null && getGroupId().equals(caseobj.getGroupId())))
&& (getArtifactId() == caseobj.getArtifactId()
|| (getArtifactId() != null && getArtifactId().equals(caseobj.getArtifactId())))
&& (getVersion() == caseobj.getVersion() || (getVersion() != null && getVersion().equals(caseobj.getVersion())))
&& (getType() == caseobj.getType() || (getType() != null && getType().equals(caseobj.getType())))
&& (getClassifier() == caseobj.getClassifier()
|| (getClassifier() != null && getClassifier().equals(caseobj.getClassifier())));
}
}

View File

@@ -58,11 +58,22 @@ public class JDBCUtil {
}
public static Date getDate(ResultSet rs, int index) throws java.sql.SQLException {
if(rs.getTimestamp(index) != null) {
return new Date(rs.getTimestamp(index).getTime());
Date result = null;
try {
if(rs.getTimestamp(index) != null) {
result = new Date(rs.getTimestamp(index).getTime());
return result;
}
} catch (java.sql.SQLException e) {
}
return null;
try {
if(rs.getDate(index) != null) {
result = new Date(rs.getDate(index).getTime());
return result;
}
} catch (java.sql.SQLException e) {
}
return result;
}
//decrease the get method call number

View File

@@ -1,6 +1,6 @@
// ============================================================================
//
// Copyright (C) 2006-2018 Talend Inc. - www.talend.com
// 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
@@ -75,4 +75,6 @@ public class PasswordEncryptUtil {
return input;
}
public static final String PASSWORD_FOR_LOGS_VALUE = "...";
}

View File

@@ -26,5 +26,6 @@ ModulesNeededProvider.Module.Exception=Needed module list do not contains this m
ShareLibsJob.message=Share libraries from maven to {0} server
ShareLibsJob.sharingLibraries=Sharing libraries : {0}
ShareLibsJob.monitor.cancelled=User cancelled.
ExtensionModuleManager.moduleGroup.cycleReference=Module group {0} was cycle referenced!

View File

@@ -25,6 +25,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.core.model.general.ModuleNeeded;
import org.talend.core.nexus.IRepositoryArtifactHandler;
import org.talend.core.nexus.ArtifactRepositoryBean;
@@ -65,6 +66,7 @@ public abstract class ShareLibrareisHelper {
// collect groupId to search
Set<String> groupIds = new HashSet<String>();
for (ModuleNeeded module : filesToShare.keySet()) {
checkCancel(monitor);
if (module.getMavenUri() != null) {
MavenArtifact parseMvnUrl = MavenUrlHelper.parseMvnUrl(module.getMavenUri());
if (parseMvnUrl != null) {
@@ -73,6 +75,7 @@ public abstract class ShareLibrareisHelper {
}
}
for (String groupId : groupIds) {
checkCancel(monitor);
searchResults.addAll(customerRepHandler.search(groupId, null, null, true, true));
}
@@ -115,6 +118,7 @@ public abstract class ShareLibrareisHelper {
}
mainSubMonitor.setTaskName(Messages.getString("ShareLibsJob.sharingLibraries", name));
checkCancel(monitor);
try {
shareToRepository(file, artifact);
mainSubMonitor.worked(1);
@@ -123,6 +127,9 @@ public abstract class ShareLibrareisHelper {
}
}
}
} catch (InterruptedException e) {
ExceptionHandler.process(e);
status = Status.CANCEL_STATUS;
} catch (Exception e) {
status = new Status(IStatus.ERROR, "unknown", IStatus.ERROR, "Share libraries failed !", e);
}
@@ -137,6 +144,12 @@ public abstract class ShareLibrareisHelper {
}
}
protected void checkCancel(IProgressMonitor monitor) throws InterruptedException {
if (monitor.isCanceled()) {
throw new InterruptedException(Messages.getString("ShareLibsJob.monitor.cancelled"));
}
}
public abstract Map<ModuleNeeded, File> getFilesToShare(IProgressMonitor monitor);
public abstract void shareToRepository(File jarFile, MavenArtifact module) throws Exception;

View File

@@ -919,6 +919,9 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
if (ModuleStatusProvider.getDeployStatus(mvnUriStatusKey) == ELibraryInstallStatus.NOT_DEPLOYED) {
return null;
}
if(mvnUriStatusKey == null){
return null;
}
// then try to resolve locally
String localMavenUri = mvnUriStatusKey.replace("mvn:", "mvn:" + MavenConstants.LOCAL_RESOLUTION_URL + "!"); //$NON-NLS-1$ //$NON-NLS-2$
try {

View File

@@ -13,9 +13,13 @@
package org.talend.librariesmanager.nexus;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Dictionary;
import java.util.Hashtable;
import org.apache.commons.lang.StringUtils;
import org.talend.core.nexus.ArtifactRepositoryBean;
import org.talend.core.nexus.IRepositoryArtifactHandler;
import org.talend.core.nexus.NexusConstants;
@@ -62,10 +66,22 @@ public abstract class AbstractArtifactRepositoryHandler implements IRepositoryAr
if (props == null) {
props = new Hashtable<String, String>();
}
String repositories = null;
String custom_server = serverBean.getServer();
String custom_user = serverBean.getUserName();
String custom_pass = serverBean.getPassword();
try {
if (StringUtils.isNotBlank(custom_user)) {
custom_user = URLEncoder.encode(custom_user, StandardCharsets.UTF_8.toString());
}
if (StringUtils.isNotBlank(custom_pass)) {
custom_pass = URLEncoder.encode(custom_pass, StandardCharsets.UTF_8.toString());
}
} catch (UnsupportedEncodingException e1) {
throw new RuntimeException(e1);
}
String repositories = null;
String custom_server = serverBean.getServer();
String release_rep = serverBean.getRepositoryId();
String snapshot_rep = serverBean.getSnapshotRepId();
if (custom_server.endsWith(NexusConstants.SLASH)) {
@@ -83,7 +99,8 @@ public abstract class AbstractArtifactRepositoryHandler implements IRepositoryAr
repositories = releaseUrl;
}
if (snapshot_rep != null) {
String snapshotUrl = custom_server + snapshot_rep + "@id=" + snapshot_rep + NexusConstants.SNAPSHOTS;//$NON-NLS-1$
String snapshotUrl = custom_server + snapshot_rep + "@id=" + snapshot_rep + NexusConstants.SNAPSHOTS //$NON-NLS-1$
+ NexusConstants.DISALLOW_RELEASES;
if (repositories != null) {
repositories = repositories + "," + snapshotUrl;
} else {

View File

@@ -14,6 +14,7 @@ package org.talend.librariesmanager.nexus;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
@@ -25,11 +26,15 @@ import org.apache.http.client.fluent.Request;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHeader;
import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.util.EntityUtils;
import org.eclipse.m2e.core.MavenPlugin;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.utils.network.TalendProxySelector.IProxySelectorProvider;
import org.talend.core.nexus.HttpClientTransport;
import org.talend.core.nexus.IRepositoryArtifactHandler;
import org.talend.core.nexus.NexusConstants;
import org.talend.core.nexus.NexusServerUtils;
import org.talend.core.runtime.maven.MavenArtifact;
import org.talend.core.runtime.maven.MavenUrlHelper;
import org.talend.designer.maven.aether.RepositorySystemFactory;
@@ -45,8 +50,6 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
private String SEARCH_SERVICE = "api/search/gavc?";
private String SEARCH_RESULT_PREFIX = "api/storage/";
/*
* (non-Javadoc)
*
@@ -86,11 +89,24 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
HttpGet get = new HttpGet(repositoryUrl);
get.addHeader(authority);
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(get);
if (response.getStatusLine().getStatusCode() == 200) {
return true;
httpclient.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, NexusServerUtils.getTimeout());
httpclient.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, NexusServerUtils.getTimeout());
IProxySelectorProvider proxySelector = null;
try {
try {
proxySelector = HttpClientTransport.addProxy(httpclient, new URI(repositoryUrl));
} catch (Exception e) {
ExceptionHandler.process(e);
}
HttpResponse response = httpclient.execute(get);
if (response.getStatusLine().getStatusCode() == 200) {
return true;
}
return false;
} finally {
HttpClientTransport.removeProxy(proxySelector);
httpclient.getConnectionManager().shutdown();
}
return false;
}
/*
@@ -148,6 +164,8 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
String basicAuth = "Basic " + new String(new Base64().encode(userPass.getBytes()));
Header authority = new BasicHeader("Authorization", basicAuth);
request.addHeader(authority);
Header resultDetailHeader = new BasicHeader("X-Result-Detail", "info"); //$NON-NLS-1$ //$NON-NLS-2$
request.addHeader(resultDetailHeader);
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
HttpResponse response = request.execute().returnResponse();
@@ -164,12 +182,10 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
throw new Exception(resultStr);
}
if (resultArray != null) {
String resultUrl = serverUrl + SEARCH_RESULT_PREFIX;
for (int i = 0; i < resultArray.size(); i++) {
JSONObject jsonObject = resultArray.getJSONObject(i);
String uri = jsonObject.getString("uri");
uri = uri.substring(resultUrl.length(), uri.length());
String[] split = uri.split("/");
String artifactPath = jsonObject.getString("path"); //$NON-NLS-1$
String[] split = artifactPath.split("/"); //$NON-NLS-1$
if (split.length > 4) {
String fileName = split[split.length - 1];
if (!fileName.endsWith("pom")) {

View File

@@ -14,7 +14,7 @@ package org.talend.librariesmanager.nexus;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
@@ -22,21 +22,24 @@ import org.apache.commons.codec.binary.Base64;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.fluent.Request;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.entity.ContentType;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHeader;
import org.apache.http.util.EntityUtils;
import org.apache.http.params.CoreConnectionPNames;
import org.apache.log4j.Logger;
import org.eclipse.m2e.core.MavenPlugin;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.utils.network.TalendProxySelector.IProxySelectorProvider;
import org.talend.core.nexus.HttpClientTransport;
import org.talend.core.nexus.IRepositoryArtifactHandler;
import org.talend.core.nexus.NexusServerUtils;
import org.talend.core.runtime.maven.MavenArtifact;
import org.talend.core.runtime.maven.MavenUrlHelper;
import org.talend.designer.maven.aether.RepositorySystemFactory;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.talend.librariesmanager.nexus.nexus3.handler.INexus3SearchHandler;
import org.talend.librariesmanager.nexus.nexus3.handler.Nexus3BetaSearchHandler;
import org.talend.librariesmanager.nexus.nexus3.handler.Nexus3ScriptSearchHandler;
import org.talend.librariesmanager.nexus.nexus3.handler.Nexus3V1SearchHandler;
/**
* created by wchen on Aug 2, 2017 Detailled comment
@@ -44,10 +47,14 @@ import net.sf.json.JSONObject;
*/
public class Nexus3RepositoryHandler extends AbstractArtifactRepositoryHandler {
private String SEARCH_SERVICE = "service/rest/v1/script/search/run";
private static Logger LOGGER = Logger.getLogger(Nexus3RepositoryHandler.class);
private String REP_PREFIX_PATH = "/repository/";
private INexus3SearchHandler currentQueryHandler = null;
private static List<INexus3SearchHandler> queryHandlerList = new ArrayList<INexus3SearchHandler>();
@Override
public IRepositoryArtifactHandler clone() {
return new Nexus3RepositoryHandler();
@@ -92,11 +99,25 @@ public class Nexus3RepositoryHandler extends AbstractArtifactRepositoryHandler {
HttpGet get = new HttpGet(repositoryUrl);
get.addHeader(authority);
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(get);
if (response.getStatusLine().getStatusCode() == 200) {
return true;
httpclient.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, NexusServerUtils.getTimeout());
httpclient.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, NexusServerUtils.getTimeout());
IProxySelectorProvider proxySelector = null;
try {
try {
proxySelector = HttpClientTransport.addProxy(httpclient, new URI(repositoryUrl));
} catch (Exception e) {
ExceptionHandler.process(e);
}
HttpResponse response = httpclient.execute(get);
if (response.getStatusLine().getStatusCode() == 200) {
return true;
}
return false;
} finally {
HttpClientTransport.removeProxy(proxySelector);
httpclient.getConnectionManager().shutdown();
}
return false;
}
/*
@@ -108,75 +129,52 @@ public class Nexus3RepositoryHandler extends AbstractArtifactRepositoryHandler {
@Override
public List<MavenArtifact> search(String groupIdToSearch, String artifactId, String versionToSearch, boolean fromRelease,
boolean fromSnapshot) throws Exception {
String serverUrl = serverBean.getServer();
if (!serverUrl.endsWith("/")) {
serverUrl = serverUrl + "/";
}
String searchUrl = serverUrl + SEARCH_SERVICE;
Request request = Request.Post(searchUrl);
String userPass = serverBean.getUserName() + ":" + serverBean.getPassword();
String basicAuth = "Basic " + new String(new Base64().encode(userPass.getBytes()));
Header authority = new BasicHeader("Authorization", basicAuth);
Header contentType = new BasicHeader("Content-Type", "text/plain");
request.addHeader(contentType);
request.addHeader(authority);
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
if (fromRelease) {
resultList.addAll(doSearch(request, serverBean.getRepositoryId(), groupIdToSearch, artifactId, versionToSearch));
resultList.addAll(doSearch(serverBean.getRepositoryId(), groupIdToSearch, artifactId, versionToSearch));
}
if (fromSnapshot) {
resultList.addAll(doSearch(request, serverBean.getSnapshotRepId(), groupIdToSearch, artifactId, versionToSearch));
resultList.addAll(doSearch(serverBean.getSnapshotRepId(), groupIdToSearch, artifactId, versionToSearch));
}
return resultList;
}
private List<MavenArtifact> doSearch(Request request, String repositoryId, String groupIdToSearch, String artifactId,
String versionToSearch) throws Exception {
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
JSONObject body = new JSONObject();
body.put("repositoryId", repositoryId);
if (groupIdToSearch != null) {
body.put("g", groupIdToSearch);
private List<MavenArtifact> doSearch(String repositoryId, String groupIdToSearch, String artifactId, String versionToSearch)
throws Exception {
if (currentQueryHandler == null) {
currentQueryHandler = getQueryHandler();
}
if (artifactId != null) {
body.put("a", artifactId);
}
if (versionToSearch != null) {
body.put("v", versionToSearch);
}
request.bodyString(body.toString(),
ContentType.create(ContentType.APPLICATION_JSON.getMimeType(), StandardCharsets.UTF_8));
HttpResponse response = request.execute().returnResponse();
String content = EntityUtils.toString(response.getEntity());
if (content.isEmpty()) {
return resultList;
}
JSONObject responseObject = new JSONObject().fromObject(content);
String resultStr = responseObject.getString("result");
JSONArray resultArray = null;
List<MavenArtifact> result = new ArrayList<MavenArtifact>();
try {
resultArray = new JSONArray().fromObject(resultStr);
} catch (Exception e) {
throw new Exception(resultStr);
}
if (resultArray != null) {
for (int i = 0; i < resultArray.size(); i++) {
JSONObject jsonObject = resultArray.getJSONObject(i);
MavenArtifact artifact = new MavenArtifact();
artifact.setGroupId(jsonObject.getString("groupId"));
artifact.setArtifactId(jsonObject.getString("artifactId"));
artifact.setVersion(jsonObject.getString("version"));
artifact.setType(jsonObject.getString("extension"));
artifact.setDescription(jsonObject.getString("description"));
artifact.setLastUpdated(jsonObject.getString("last_updated"));
// artifact.setLicense(jsonObject.getString("license"));
// artifact.setLicenseUrl(jsonObject.getString("licenseUrl"));
// artifact.setUrl(jsonObject.getString("url"));
resultList.add(artifact);
result = currentQueryHandler.search(repositoryId, groupIdToSearch, artifactId, versionToSearch);
} catch (Exception ex) {
for (int i = 0; i < queryHandlerList.size(); i++) {// Try to other version
INexus3SearchHandler handler = queryHandlerList.get(i);
if (handler != currentQueryHandler) {
try {
result = handler.search(repositoryId, groupIdToSearch, artifactId, versionToSearch);
currentQueryHandler = handler;
LOGGER.info(
"Switch to new search handler,the handler version is:" + currentQueryHandler.getHandlerVersion());
break;
} catch (Exception e) {
LOGGER.info("Try to switch search handler failed" + e.getMessage());
}
}
}
}
return resultList;
return result;
}
private INexus3SearchHandler getQueryHandler() {
if (queryHandlerList.size() == 0) {
queryHandlerList.add(new Nexus3V1SearchHandler(serverBean));
queryHandlerList.add(new Nexus3BetaSearchHandler(serverBean));
queryHandlerList.add(new Nexus3ScriptSearchHandler(serverBean));
}
return queryHandlerList.get(0);
}
/*

View File

@@ -0,0 +1,220 @@
package org.talend.librariesmanager.nexus.nexus3.handler;
// ============================================================================
//
// Copyright (C) 2006-2018 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import org.eclipse.core.runtime.IProgressMonitor;
import org.talend.core.nexus.ArtifactRepositoryBean;
import org.talend.core.nexus.HttpClientTransport;
import org.talend.core.runtime.maven.MavenArtifact;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
public abstract class AbsNexus3SearchHandler implements INexus3SearchHandler {
private static Logger log = Logger.getLogger(AbsNexus3SearchHandler.class);
protected ArtifactRepositoryBean serverBean;
/**
* {@value}
* <p>
* System property of nexus3 socket timeout, the unit is second.
*/
private final String KEY_NEXUS3_SOCKET_TIMEOUT = "nexus3.socket.timeout";
private final int DEFAULT_SOCKET_TIMEOUT = 10 * 1000; // The default value is 10S
public AbsNexus3SearchHandler(ArtifactRepositoryBean serverBean) {
this.serverBean = serverBean;
}
protected String getServerUrl() {
String serverUrl = serverBean.getServer();
if (!serverUrl.endsWith("/")) { //$NON-NLS-1$
serverUrl = serverUrl + "/"; //$NON-NLS-1$
}
return serverUrl;
}
protected abstract String getSearchUrl();
@Override
public List<MavenArtifact> search(String repositoryId, String groupIdToSearch, String artifactId, String versionToSearch)
throws Exception {
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
String searchUrl = getSearchUrl();
String continuationToken = null;
while (true) {
String query = getQueryParameter(repositoryId, groupIdToSearch, artifactId, versionToSearch, continuationToken);
String content = doRequest(searchUrl + query);
continuationToken = parseResult(content, resultList);
if (continuationToken == null) {
break;
}
}
return resultList;
}
protected String doRequest(final String url) throws URISyntaxException, Exception {
final StringBuffer sb = new StringBuffer();
new HttpClientTransport(url, serverBean.getUserName(), serverBean.getPassword()) {
@Override
protected HttpResponse execute(IProgressMonitor monitor, DefaultHttpClient httpClient, URI targetURI)
throws Exception {
HttpGet httpGet = new HttpGet(targetURI);
String userName = serverBean.getUserName();
if (StringUtils.isNotBlank(userName) && !Boolean.getBoolean("talend.studio.search.nexus3.disableBasicAuth")) {
String auth = userName + ":" + serverBean.getPassword();
String authHeader = "Basic " + new String(Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8)));
httpGet.setHeader(HttpHeaders.AUTHORIZATION, authHeader);
httpClient.setCredentialsProvider(null);
}
HttpResponse response = httpClient.execute(httpGet);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
sb.append(EntityUtils.toString(response.getEntity()));
} else {
throw new Exception(response.toString());
}
return response;
}
}.doRequest(null, new URI(url));
return sb.toString();
}
protected String parseResult(String content, List<MavenArtifact> resultList) throws Exception {
if (StringUtils.isEmpty(content)) {
return null;
}
JSONObject responseObject = JSONObject.fromObject(content);
String resultStr = responseObject.getString("items"); //$NON-NLS-1$
String continuationToken = responseObject.getString("continuationToken");
if (StringUtils.isEmpty(continuationToken) || "null".equalsIgnoreCase(continuationToken)) {
continuationToken = null;
}
JSONArray resultArray = null;
try {
resultArray = JSONArray.fromObject(resultStr);
} catch (Exception e) {
throw new Exception(resultStr);
}
if (resultArray != null) {
for (int i = 0; i < resultArray.size(); i++) {
JSONObject jsonObject = resultArray.getJSONObject(i);
MavenArtifact artifact = new MavenArtifact();
artifact.setGroupId(jsonObject.getString("group")); //$NON-NLS-1$
artifact.setArtifactId(jsonObject.getString("name")); //$NON-NLS-1$
artifact.setVersion(jsonObject.getString("version")); //$NON-NLS-1$
JSONArray assertsArray = jsonObject.getJSONArray("assets"); //$NON-NLS-1$
artifact.setType(getPackageType(assertsArray));
resultList.add(artifact);
}
}
return continuationToken;
}
protected String getPackageType(JSONArray assertsArray) {
String type = null;
if (assertsArray != null) {
for (int i = 0; i < assertsArray.size(); i++) {
JSONObject jsonObject = assertsArray.getJSONObject(i);
String path = jsonObject.getString("path"); //$NON-NLS-1$
if (path != null && path.endsWith(".zip")) { //$NON-NLS-1$
return "zip"; //$NON-NLS-1$
}
if (path != null && path.endsWith(".jar")) { //$NON-NLS-1$
return "jar"; //$NON-NLS-1$
}
if (path != null && path.endsWith(".pom")) { //$NON-NLS-1$
type = "pom"; //$NON-NLS-1$
}
}
}
return type;
}
protected String getQueryParameter(String repositoryId, String groupIdToSearch, String artifactId, String versionToSearch,
String continuationToken) {
StringBuffer sb = new StringBuffer();
boolean hasParameter = false;
if (StringUtils.isNoneEmpty(repositoryId)) {
sb.append("repository=").append(repositoryId); //$NON-NLS-1$
hasParameter = true;
}
if (StringUtils.isNoneEmpty(groupIdToSearch)) {
if (hasParameter) {
sb.append("&"); //$NON-NLS-1$
}
sb.append("group=").append(groupIdToSearch); //$NON-NLS-1$
hasParameter = true;
}
if (StringUtils.isNoneEmpty(artifactId)) {
if (hasParameter) {
sb.append("&"); //$NON-NLS-1$
}
sb.append("name=").append(artifactId); //$NON-NLS-1$
hasParameter = true;
}
if (StringUtils.isNoneEmpty(versionToSearch)) {
if (hasParameter) {
sb.append("&"); //$NON-NLS-1$
}
sb.append("version=").append(versionToSearch); //$NON-NLS-1$
hasParameter = true;
}
if (StringUtils.isNoneEmpty(continuationToken)) {
if (hasParameter) {
sb.append("&"); //$NON-NLS-1$
}
sb.append("continuationToken=").append(continuationToken); //$NON-NLS-1$
hasParameter = true;
}
return sb.toString();
}
protected String getAuthenticationItem() {
String userPass = serverBean.getUserName() + ":" + serverBean.getPassword(); //$NON-NLS-1$
String basicAuth = "Basic " + new String(new Base64().encode(userPass.getBytes())); //$NON-NLS-1$
return basicAuth;
}
protected int getNexus3SocketTimeout() {
int socketTimeout = DEFAULT_SOCKET_TIMEOUT;
String strValue = System.getProperty(KEY_NEXUS3_SOCKET_TIMEOUT);
if (StringUtils.isNotEmpty(strValue)) {
try {
int value = Integer.parseInt(strValue);
socketTimeout = value * 1000;
} catch (NumberFormatException ex) {
log.error("Parse nexus3 socket timeout error:" + ex.getMessage());
}
}
return socketTimeout;
}
}

View File

@@ -0,0 +1,26 @@
package org.talend.librariesmanager.nexus.nexus3.handler;
// ============================================================================
//
// Copyright (C) 2006-2018 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
import java.util.List;
import org.talend.core.runtime.maven.MavenArtifact;
public interface INexus3SearchHandler {
public List<MavenArtifact> search(String repositoryId, String groupIdToSearch, String artifactId, String versionToSearch)
throws Exception;
public String getHandlerVersion();
}

View File

@@ -0,0 +1,20 @@
package org.talend.librariesmanager.nexus.nexus3.handler;
import org.talend.core.nexus.ArtifactRepositoryBean;
public class Nexus3BetaSearchHandler extends AbsNexus3SearchHandler {
private String SEARCH_SERVICE = "service/rest/beta/search?"; //$NON-NLS-1$
public Nexus3BetaSearchHandler(ArtifactRepositoryBean serverBean) {
super(serverBean);
}
protected String getSearchUrl() {
return this.getServerUrl() + SEARCH_SERVICE;
}
public String getHandlerVersion() {
return "Nexus3.beta"; //$NON-NLS-1$
}
}

View File

@@ -0,0 +1,110 @@
package org.talend.librariesmanager.nexus.nexus3.handler;
// ============================================================================
//
// Copyright (C) 2006-2018 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.fluent.Request;
import org.apache.http.entity.ContentType;
import org.apache.http.message.BasicHeader;
import org.apache.http.util.EntityUtils;
import org.talend.core.nexus.ArtifactRepositoryBean;
import org.talend.core.runtime.maven.MavenArtifact;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
public class Nexus3ScriptSearchHandler extends AbsNexus3SearchHandler {
private String SEARCH_SERVICE = "service/rest/v1/script/search/run"; //$NON-NLS-1$
public Nexus3ScriptSearchHandler(ArtifactRepositoryBean serverBean) {
super(serverBean);
}
@Override
public List<MavenArtifact> search(String repositoryId, String groupIdToSearch, String artifactId, String versionToSearch)
throws Exception {
String searchUrl = getSearchUrl();
Request request = this.getRequest(searchUrl);
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
JSONObject body = new JSONObject();
body.put("repositoryId", repositoryId); //$NON-NLS-1$
if (groupIdToSearch != null) {
body.put("g", groupIdToSearch); //$NON-NLS-1$
}
if (artifactId != null) {
body.put("a", artifactId); //$NON-NLS-1$
}
if (versionToSearch != null) {
body.put("v", versionToSearch); //$NON-NLS-1$
}
request.bodyString(body.toString(),
ContentType.create(ContentType.APPLICATION_JSON.getMimeType(), StandardCharsets.UTF_8));
HttpResponse response = request.execute().returnResponse();
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
String content = EntityUtils.toString(response.getEntity());
if (content.isEmpty()) {
return resultList;
}
JSONObject responseObject = JSONObject.fromObject(content);
String resultStr = responseObject.getString("result"); //$NON-NLS-1$
JSONArray resultArray = null;
try {
resultArray = JSONArray.fromObject(resultStr);
} catch (Exception e) {
throw new Exception(resultStr);
}
if (resultArray != null) {
for (int i = 0; i < resultArray.size(); i++) {
JSONObject jsonObject = resultArray.getJSONObject(i);
MavenArtifact artifact = new MavenArtifact();
artifact.setGroupId(jsonObject.getString("groupId")); //$NON-NLS-1$
artifact.setArtifactId(jsonObject.getString("artifactId")); //$NON-NLS-1$
artifact.setVersion(jsonObject.getString("version")); //$NON-NLS-1$
artifact.setType(jsonObject.getString("extension")); //$NON-NLS-1$
artifact.setDescription(jsonObject.getString("description")); //$NON-NLS-1$
artifact.setLastUpdated(jsonObject.getString("last_updated")); //$NON-NLS-1$
resultList.add(artifact);
}
}
return resultList;
} else {
throw new Exception(response.toString());
}
}
protected Request getRequest(String searchUrl) {
Request request = Request.Post(searchUrl);
Header authority = new BasicHeader("Authorization", getAuthenticationItem()); //$NON-NLS-1$
Header contentType = new BasicHeader("Content-Type", "text/plain"); //$NON-NLS-1$ //$NON-NLS-2$
request.addHeader(contentType);
request.addHeader(authority);
request.socketTimeout(this.getNexus3SocketTimeout());
return request;
}
protected String getSearchUrl() {
return this.getServerUrl() + SEARCH_SERVICE;
}
public String getHandlerVersion() {
return "Nexus3.script"; //$NON-NLS-1$
}
}

View File

@@ -0,0 +1,20 @@
package org.talend.librariesmanager.nexus.nexus3.handler;
import org.talend.core.nexus.ArtifactRepositoryBean;
public class Nexus3V1SearchHandler extends AbsNexus3SearchHandler {
private String SEARCH_SERVICE = "service/rest/v1/search?";
public Nexus3V1SearchHandler(ArtifactRepositoryBean serverBean) {
super(serverBean);
}
protected String getSearchUrl() {
return this.getServerUrl() + SEARCH_SERVICE;
}
public String getHandlerVersion() {
return "Nexus3.V1"; //$NON-NLS-1$
}
}

View File

@@ -36,7 +36,6 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
import org.talend.commons.ui.swt.formtools.Form;
@@ -634,4 +633,8 @@ public abstract class AbstractForm extends Composite {
}
}
}
public ConnectionItem getConnectionItem() {
return this.connectionItem;
}
}

View File

@@ -376,11 +376,12 @@ public class ExtractManager {
// StringUtils.trimToEmpty(name) is because bug 4547
if (name != null && StringUtils.trimToEmpty(name).equals(ETableTypes.TABLETYPE_SYNONYM.getName())) {
String tableName = getTableNameBySynonyms(extractMeta.getConn(), newNode.getValue());
String nodeValue = newNode.getValue();
String tableName = getTableNameBySynonyms(extractMeta.getConn(), nodeValue);
if (tableName != null && tableName.contains("/")) {
tableName = tableName.replace("/", "");
}
fillSynonyms(metadataConnection, metadataColumns, table, tableName, dbMetaData);
fillSynonyms(metadataConnection, metadataColumns, table, tableName, nodeValue, dbMetaData);
} else {
EDatabaseTypeName currentEDatabaseType = EDatabaseTypeName.getTypeFromDbType(metadataConnection.getDbType());
metadataColumns = MetadataFillFactory.getDBInstance(currentEDatabaseType).fillColumns(table, metadataConnection,
@@ -465,7 +466,7 @@ public class ExtractManager {
* @throws SQLException
*/
protected void fillSynonyms(IMetadataConnection metadataConnection, List<TdColumn> metadataColumns, NamedColumnSet table,
String tableName, DatabaseMetaData dbMetaData) throws SQLException {
String tableName, String synonymName, DatabaseMetaData dbMetaData) throws SQLException {
// nothing to do by default
}

View File

@@ -34,6 +34,7 @@ import org.talend.cwm.helper.ColumnHelper;
import org.talend.cwm.helper.ConnectionHelper;
import org.talend.cwm.relational.TdColumn;
import org.talend.metadata.managment.utils.ManagementTextUtils;
import orgomg.cwm.resource.relational.NamedColumnSet;
/**
@@ -102,7 +103,7 @@ public class IBMDB2ExtractManager extends ExtractManager {
@Override
protected void fillSynonyms(IMetadataConnection metadataConnection, List<TdColumn> metadataColumns, NamedColumnSet table,
String tableName, DatabaseMetaData dbMetaData) throws SQLException {
String tableName, String synonymName, DatabaseMetaData dbMetaData) throws SQLException {
if (metadataConnection == null || dbMetaData == null) {
return;
}

View File

@@ -36,6 +36,7 @@ import org.talend.cwm.helper.ConnectionHelper;
import org.talend.cwm.relational.TdColumn;
import org.talend.metadata.managment.utils.ManagementTextUtils;
import org.talend.utils.sql.metadata.constants.GetColumn;
import orgomg.cwm.resource.relational.NamedColumnSet;
/**
@@ -90,7 +91,7 @@ public class MSSQLExtractManager extends ExtractManager {
@Override
protected void fillSynonyms(IMetadataConnection metadataConnection, List<TdColumn> metadataColumns, NamedColumnSet table,
String tableName, DatabaseMetaData dbMetaData) throws SQLException {
String tableName, String synonymName, DatabaseMetaData dbMetaData) throws SQLException {
if (metadataConnection == null || dbMetaData == null) {
return;
}

View File

@@ -45,6 +45,7 @@ import org.talend.cwm.helper.ConnectionHelper;
import org.talend.cwm.relational.TdColumn;
import org.talend.metadata.managment.utils.ManagementTextUtils;
import org.talend.utils.sql.metadata.constants.GetColumn;
import orgomg.cwm.resource.relational.NamedColumnSet;
import orgomg.cwm.resource.relational.Schema;
@@ -163,7 +164,7 @@ public class OracleExtractManager extends ExtractManager {
@Override
protected void fillSynonyms(IMetadataConnection metadataConnection, List<TdColumn> metadataColumns, NamedColumnSet table,
String tableName, DatabaseMetaData dbMetaData) throws SQLException {
String tableName, String synonymName, DatabaseMetaData dbMetaData) throws SQLException {
if (metadataConnection == null || dbMetaData == null) {
return;
}
@@ -172,8 +173,8 @@ public class OracleExtractManager extends ExtractManager {
// need to retrieve columns of synonym by useing sql rather than get them from jdbc metadata
String synSQL = "SELECT all_tab_columns.*\n" + "FROM all_tab_columns\n" + "LEFT OUTER JOIN all_synonyms\n"
+ "ON all_tab_columns.TABLE_NAME = all_synonyms.TABLE_NAME\n"
+ "AND ALL_SYNONYMS.TABLE_OWNER = all_tab_columns.OWNER\n" + "WHERE all_synonyms.SYNONYM_NAME =" + "\'"
+ tableName + "\'\n";
+ "AND ALL_SYNONYMS.TABLE_OWNER = all_tab_columns.OWNER\n" + "WHERE all_synonyms.SYNONYM_NAME =" + "\'"
+ synonymName + "\'\n";
// bug TDI-19382
if (!("").equals(metadataConnection.getSchema())) {
synSQL += "and all_synonyms.OWNER =\'" + metadataConnection.getSchema() + "\'";

View File

@@ -15,5 +15,9 @@
id="org.talend.repository.items.sync.children.contexts"
provider="org.talend.repository.items.importexport.handlers.exports.SyncChildrenContextsResourcesProvider">
</resourcesProvider>
<resourcesProvider
id="org.talend.repository.items.importexport.handlers.exports.SyncChildrenSourceCodeProvider"
provider="org.talend.repository.items.importexport.handlers.exports.SyncChildrenSourceCodeProvider">
</resourcesProvider>
</extension>
</plugin>

View File

@@ -0,0 +1,75 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.repository.items.importexport.handlers.exports;
import java.io.File;
import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.talend.commons.runtime.utils.io.FileCopyUtils;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.runtime.process.ITalendProcessJavaProject;
import org.talend.core.runtime.repository.build.IBuildResourcesProvider;
import org.talend.core.runtime.util.ParametersUtil;
import org.talend.designer.runprocess.IRunProcessService;
public class SyncChildrenSourceCodeProvider implements IBuildResourcesProvider {
@Override
public void prepare(IProgressMonitor monitor, Map<String, Object> parameters) throws Exception {
if (parameters == null) {
return;
}
final ITalendProcessJavaProject processJavaProject = (ITalendProcessJavaProject) ParametersUtil.getObject(parameters,
OBJ_PROCESS_JAVA_PROJECT, ITalendProcessJavaProject.class);
if (processJavaProject == null) {
return;
}
final ProcessItem processItem = (ProcessItem) ParametersUtil.getObject(parameters, OBJ_PROCESS_ITEM, ProcessItem.class);
if (processItem == null) {
return;
}
final List dependenciesItems = (List) ParametersUtil.getObject(parameters, OBJ_ITEM_DEPENDENCIES, List.class);
if (dependenciesItems == null || dependenciesItems.isEmpty()) {
return;
}
if (!GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
return;
}
final IRunProcessService runProcessService = (IRunProcessService) GlobalServiceRegister.getDefault()
.getService(IRunProcessService.class);
final IFolder mainSrcFolder = processJavaProject.getSrcFolder();
final File targetFolder = mainSrcFolder.getLocation().toFile();
for (Object item : dependenciesItems) {
if (item instanceof ProcessItem) {
ITalendProcessJavaProject childJavaProject = runProcessService
.getTalendJobJavaProject(((ProcessItem) item).getProperty());
if (childJavaProject != null) {
final IFolder childSrcFolder = childJavaProject.getSrcFolder();
if (childSrcFolder.exists()) {
FileCopyUtils.syncFolder(childSrcFolder.getLocation().toFile(), targetFolder, false);
}
}
}
}
mainSrcFolder.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
}

View File

@@ -29,6 +29,7 @@ import org.talend.core.PluginChecker;
import org.talend.core.hadoop.IHadoopClusterService;
import org.talend.core.hadoop.repository.HadoopRepositoryUtil;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.ItemState;
import org.talend.core.model.properties.Project;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.ui.ITestContainerProviderService;
@@ -234,9 +235,12 @@ public class ImportNodesBuilder {
parentImportNode = findAndCreateFolderNode(typeImportNode, path);
parentImportNode.setItemRecord(itemRecord);
} else {
String path = item.getState().getPath();
if (StringUtils.isNotEmpty(path)) { // if has path, will find the real path node.
parentImportNode = findAndCreateFolderNode(typeImportNode, new Path(path));
ItemState state = item.getState();
if (state != null) {
String path = state.getPath();
if (StringUtils.isNotEmpty(path)) { // if has path, will find the real path node.
parentImportNode = findAndCreateFolderNode(typeImportNode, new Path(path));
}
}
ItemImportNode itemNode = new ItemImportNode(itemRecord);
parentImportNode.addChild(itemNode);

View File

@@ -349,6 +349,10 @@ public class DatabaseForm extends AbstractForm {
private final String originalUischema;
private final String originalURL;
private final String orginalDBVersion;
private final String originalPort;
private final Boolean originalIsNeedReload;
@@ -558,6 +562,8 @@ public class DatabaseForm extends AbstractForm {
originalUischema = metadataconnection.getUiSchema() == null ? "" : metadataconnection.getUiSchema();
originalURL = metadataconnection.getUrl();
originalPort = metadataconnection.getPort() == null ? "" : metadataconnection.getPort();
orginalDBVersion = metadataconnection.getDbVersionString() == null ? "" : metadataconnection.getDbVersionString();
originalIsNeedReload = ConnectionHelper.getIsConnNeedReload(getConnection());
this.typeName = EDatabaseTypeName.getTypeFromDbType(metadataconnection.getDbType());
@@ -4706,7 +4712,6 @@ public class DatabaseForm extends AbstractForm {
}
}
});
// Db version
dbVersionCombo.addModifyListener(new ModifyListener() {
@@ -4715,14 +4720,17 @@ public class DatabaseForm extends AbstractForm {
if (!isContextMode()) {
EDatabaseVersion4Drivers version = EDatabaseVersion4Drivers.indexOfByVersionDisplay(dbVersionCombo.getText());
if (version != null) {
if(EDatabaseTypeName.SYBASEASE.getDisplayName().equals(getConnectionDBType())) {
if(version.getVersionValue().equals( EDatabaseVersion4Drivers.SYBASEIQ_16_SA.getVersionValue())) {
portText.setText(EDatabaseConnTemplate.SYBASEASE_16_SA.getDefaultPort());
}else {
portText.setText(EDatabaseConnTemplate.SYBASEASE.getDefaultPort());
}
}
if (EDatabaseTypeName.SYBASEASE.getDisplayName().equals(getConnectionDBType())) {
if (version.getVersionValue().equals(orginalDBVersion) && StringUtils.isNotEmpty(originalPort)) {
portText.setText(originalPort);
} else if (version.getVersionValue()
.equals(EDatabaseVersion4Drivers.SYBASEIQ_16_SA.getVersionValue())) {
portText.setText(EDatabaseConnTemplate.SYBASEASE_16_SA.getDefaultPort());
} else {
portText.setText(EDatabaseConnTemplate.SYBASEASE.getDefaultPort());
}
}
getConnection().setDbVersionString(version.getVersionValue());
}

View File

@@ -22,6 +22,8 @@ import org.talend.datatools.xml.utils.ATreeNode;
*/
public abstract class AbstractTreePopulator {
private String encoding;
protected String filePath;
protected static int limit;
@@ -36,6 +38,14 @@ public abstract class AbstractTreePopulator {
abstract public String getAbsoluteXPath(TreeItem treeItem);
public String getEncoding() {
return this.encoding;
}
public void setEncoding(String encoding) {
this.encoding = encoding;
}
/**
* Getter for filePath.
*

View File

@@ -95,7 +95,7 @@ public class JsonTreePopulator extends AbstractTreePopulator {
SchemaPopulationUtil.fetchTreeNode((JsonTreeNode) selectedEntity, 1);
treeNode = (ATreeNode) selectedEntity;
} else {
treeNode = SchemaPopulationUtil.getSchemaTree(fileValue, limit);
treeNode = SchemaPopulationUtil.getSchemaTree(fileValue, getEncoding(), limit);
}
if (treeNode == null) {
return false;

View File

@@ -14,11 +14,15 @@ package org.talend.repository.ui.wizards.metadata.connection.files.json;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Stream;
import org.apache.commons.lang.StringUtils;
import org.talend.commons.exception.CommonExceptionHandler;
import com.fasterxml.jackson.databind.JsonNode;
@@ -65,11 +69,21 @@ public class SchemaPopulationUtil {
return null;
}
public static JsonTreeNode getSchemaTree(File jsonFile, int numberOfElementsAccessiable) {
public static JsonTreeNode getSchemaTree(File jsonFile, String charset, int numberOfElementsAccessiable) {
JsonTreeNode jsonTreeNode = null;
try {
StringBuilder strBuilder = new StringBuilder();
Charset charSet = null;
if (StringUtils.isBlank(charset)) {
charSet = Charset.forName("UTF-8");
} else {
charSet = Charset.forName(charset);
}
try (Stream<String> lines = Files.lines(jsonFile.toPath(), charSet)) {
lines.forEach(line -> strBuilder.append(line).append("\n"));
}
ObjectMapper objMapper = new ObjectMapper();
JsonNode jsonNode = objMapper.readTree(jsonFile);
JsonNode jsonNode = objMapper.readTree(strBuilder.toString());
jsonTreeNode = new JsonTreeNode();
jsonTreeNode.addValue(jsonNode);
String label = "$"; //$NON-NLS-1$

View File

@@ -350,6 +350,7 @@ public class XmlToSchemaDragAndDropHandler {
}
linker.updateLinksStyleAndControlsSelection(control, true);
linker.getFieldsTableEditorView().getTableViewerCreator().getTableViewer().refresh();
}
}

View File

@@ -266,6 +266,7 @@ public class XmlToXPathLinker extends TreeToTablesLinker<Object, Object> {
originalValue = TalendQuoteUtils.removeQuotes(originalValue);
}
if (originalValue != null) {
loadItemDataForLazyLoad(loopTableEditorView);
createLoopLinks(originalValue, tableItem, monitorWrap);
}
@@ -304,7 +305,7 @@ public class XmlToXPathLinker extends TreeToTablesLinker<Object, Object> {
private void createFieldsLinkWithProgressMonitor(IProgressMonitor monitorWrap, int totalWork,
List<SchemaTarget> schemaTargetList, int startTableItem, int tableItemLength) {
monitorWrap.beginTask(Messages.getString("XmlToXPathLinker.beginTask.fieldLinksCreation"), totalWork); //$NON-NLS-1$
loadItemDataForLazyLoad(fieldsTableEditorView);
TableItem[] fieldsTableItems = fieldsTableEditorView.getTable().getItems();
for (int i = startTableItem, indexShemaTarget = 0; i < startTableItem + tableItemLength; i++, indexShemaTarget++) {
@@ -324,6 +325,7 @@ public class XmlToXPathLinker extends TreeToTablesLinker<Object, Object> {
createFieldLinks(relativeXpathQuery, tableItem, monitorWrap, schemaTarget);
monitorWrap.worked(1);
}
fieldsTableEditorView.getTableViewerCreator().getTableViewer().refresh();
getLinksManager().sortLinks(getDrawingLinksComparator());
getBackgroundRefresher().refreshBackground();
}

View File

@@ -450,4 +450,21 @@ public class RepoViewCommonViewer extends CommonViewer implements INavigatorCont
super.dispose();
}
@Override
public void associate(Object element, Item item) {
Object data = item.getData();
if (data != element) {
if (data != null) {
disassociate(item);
}
item.setData(element);
mapElement(element, item);
} else {
// Always map the element, even if data == element,
// since unmapAllElements() can leave the map inconsistent
// See bug 2741 for details.
mapElement(element, item);
}
}
}

View File

@@ -32,11 +32,15 @@ import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.IProvisioningAgentProvider;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.engine.IPhaseSet;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.PhaseSetFactory;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.operations.InstallOperation;
import org.eclipse.equinox.p2.operations.ProfileModificationJob;
import org.eclipse.equinox.p2.operations.ProvisioningSession;
import org.eclipse.equinox.p2.operations.UninstallOperation;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
@@ -135,7 +139,8 @@ public class ComponentP2ExtraFeature extends P2ExtraFeature implements IP2Compon
IProvisioningAgent agent = null;
try {
agent = agentProvider.createAgent(getP2AgentUri());
IProfile profile = getProfile(agentProvider, progress);
agent = profile.getProvisioningAgent();
updateRoamingProp(agent, agentProvider);
@@ -151,27 +156,50 @@ public class ComponentP2ExtraFeature extends P2ExtraFeature implements IP2Compon
getVersion(), Arrays.toString(allRepoUris.toArray(new URI[allRepoUris.size()])));
}
IPhaseSet talendPhaseSet = PhaseSetFactory
.createDefaultPhaseSetExcluding(new String[] { PhaseSetFactory.PHASE_CHECK_TRUST });
// uninstall first
Collection<IInstallableUnit> installedP2Feature = getInstalledP2Feature(profile, toInstall, subMonitor);
ProvisioningSession session = new ProvisioningSession(agent);
if (installedP2Feature != null && !installedP2Feature.isEmpty()) {
UninstallOperation uninstallOperation = new UninstallOperation(session, installedP2Feature);
uninstallOperation.setProfileId(getP2ProfileId());
IStatus resolveModal = uninstallOperation.resolveModal(subMonitor);
if (resolveModal.getSeverity() == IStatus.ERROR) {
return Messages.createErrorStatus(null, "ComponentP2ExtraFeature.error.installing.new.components", //$NON-NLS-1$
uninstallOperation.getResolutionDetails());
}
ProfileModificationJob provisioningJob = (ProfileModificationJob) uninstallOperation
.getProvisioningJob(subMonitor.newChild(1));
if (subMonitor.isCanceled()) {
return Messages.createCancelStatus("ComponentP2ExtraFeature.user.cancel.installation.of.components", //$NON-NLS-1$
getP2IuId(), getVersion());
}
if (provisioningJob == null) {
return Messages.createErrorStatus(null, "ComponentP2ExtraFeature.error.installing.new.components", //$NON-NLS-1$
getP2IuId(), getVersion(), uninstallOperation.getResolutionDetails());
}
provisioningJob.setPhaseSet(talendPhaseSet);
provisioningJob.run(subMonitor.newChild(1));
agent.stop();
// update profile
profile = getProfile(agentProvider, subMonitor);
agent = profile.getProvisioningAgent();
updateRoamingProp(agent, agentProvider);
session = new ProvisioningSession(agent);
}
// install
InstallOperation installOperation = new InstallOperation(new ProvisioningSession(agent), toInstall);
InstallOperation installOperation = new InstallOperation(session, toInstall);
installOperation.setProfileId(getP2ProfileId());
IStatus installResolvedStatus = installOperation.resolveModal(subMonitor.newChild(1));
if (subMonitor.isCanceled()) {
return Messages.createCancelStatus("ComponentP2ExtraFeature.user.cancel.installation.of.components", //$NON-NLS-1$
getP2IuId(), getVersion());
}
if (installResolvedStatus.getSeverity() == IStatus.ERROR) {
return Messages.createErrorStatus(null, "ComponentP2ExtraFeature.error.installing.new.components", getP2IuId(), //$NON-NLS-1$
getVersion(), installOperation.getResolutionDetails());
} // else perform the installlation
IPhaseSet talendPhaseSet = PhaseSetFactory
.createDefaultPhaseSetExcluding(new String[] { PhaseSetFactory.PHASE_CHECK_TRUST });
ProfileModificationJob provisioningJob = (ProfileModificationJob) installOperation.getProvisioningJob(subMonitor
.newChild(1));
if (subMonitor.isCanceled()) {
return Messages.createCancelStatus("ComponentP2ExtraFeature.user.cancel.installation.of.components", //$NON-NLS-1$
getP2IuId(), getVersion());
}
if (provisioningJob == null) {
return Messages.createErrorStatus(null, "ComponentP2ExtraFeature.error.installing.new.components", //$NON-NLS-1$
getP2IuId(), getVersion(), installOperation.getResolutionDetails());
@@ -194,6 +222,9 @@ public class ComponentP2ExtraFeature extends P2ExtraFeature implements IP2Compon
return Messages.createErrorStatus(e,
"ComponentP2ExtraFeature.error.installing.components.uri.exception", getP2IuId(), //$NON-NLS-1$
getVersion());
} catch (Exception e) {
return Messages.createErrorStatus(e, "ComponentP2ExtraFeature.error.installing.components.uri.exception", getP2IuId(), //$NON-NLS-1$
getVersion());
} finally {
if (agent != null) {// agent creation did not fail
removeAllRepositories(agent, allRepoUris);
@@ -203,6 +234,16 @@ public class ComponentP2ExtraFeature extends P2ExtraFeature implements IP2Compon
return Messages.createOkStatus("sucessfull.install.of.components", getP2IuId(), getVersion()); //$NON-NLS-1$
}
@Override
protected IQuery<IInstallableUnit> createQuery() {
return QueryUtil.createLatestQuery(QueryUtil.createIUAnyQuery());
}
@Override
public boolean needRestart() {
return true;
}
@Override
protected void afterInstallP2(IProgressMonitor progress, Map<File, File> unzippedPatchMap) throws P2ExtraFeatureException {
super.afterInstallP2(progress, unzippedPatchMap);

View File

@@ -90,6 +90,7 @@ public abstract class AbstractExtraFeature implements ExtraFeature {
this.degradable = degradable;
this.types = types;
this.categories = categories;
this.share = getRepositoryService().getProxyRepositoryFactory().isFullLogonFinished();
}
@Override

View File

@@ -26,6 +26,8 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.swt.graphics.Image;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.core.GlobalServiceRegister;
import org.talend.repository.model.IRepositoryService;
import org.talend.updates.runtime.feature.model.Category;
import org.talend.updates.runtime.feature.model.Type;
import org.talend.updates.runtime.model.InstallationStatus.Status;
@@ -242,4 +244,7 @@ public interface ExtraFeature extends Comparable<Object> {
return 0;
}
default IRepositoryService getRepositoryService() {
return (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
}
}

View File

@@ -24,6 +24,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -158,28 +159,8 @@ public class P2ExtraFeature extends AbstractExtraFeature implements IP2Feature {
try {
IQuery<IInstallableUnit> iuQuery = QueryUtil.createIUQuery(p2IuId2);
boolean interrupted = false;
IProfile profile = null;
// there seems to be a bug because if the agent is created too quickly then the profile is empty.
// so we loop until we get a proper profile
final String p2ProfileId = getP2ProfileId();
do {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
interrupted = true;
}
if (agent != null) {
agent.stop();
}
agent = agentProvider.createAgent(getP2AgentUri());
IProfileRegistry profRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
profile = profRegistry.getProfile(p2ProfileId);
} while (profile != null && profile.getTimestamp() == 0 && !interrupted && !subMonitor.isCanceled());
if (profile == null || subMonitor.isCanceled()) {
throw new ProvisionException("Could not find the p2 profile named " + p2ProfileId); //$NON-NLS-1$
}
IProfile profile = getProfile(agentProvider, subMonitor);
agent = profile.getProvisioningAgent();
subMonitor.worked(1);
IQueryResult<IInstallableUnit> iuQueryResult = profile.available(iuQuery, subMonitor.newChild(1));
if (subMonitor.isCanceled()) {
@@ -193,6 +174,33 @@ public class P2ExtraFeature extends AbstractExtraFeature implements IP2Feature {
}
}
protected IProfile getProfile(IProvisioningAgentProvider agentProvider, IProgressMonitor progress) throws ProvisionException {
IProvisioningAgent agent = null;
IProfile profile = null;
boolean interrupted = false;
// there seems to be a bug because if the agent is created too quickly then the profile is empty.
// so we loop until we get a proper profile
final String p2ProfileId = getP2ProfileId();
do {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
interrupted = true;
}
if (agent != null) {
agent.stop();
}
agent = agentProvider.createAgent(getP2AgentUri());
IProfileRegistry profRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
profile = profRegistry.getProfile(p2ProfileId);
} while (profile != null && profile.getTimestamp() == 0 && !interrupted && !progress.isCanceled());
if (profile == null || progress.isCanceled()) {
throw new ProvisionException("Could not find the p2 profile named " + p2ProfileId); //$NON-NLS-1$
}
return profile;
}
/**
* created for JUnit test so that profile Id can be changed by overriding
*
@@ -501,7 +509,7 @@ public class P2ExtraFeature extends AbstractExtraFeature implements IP2Feature {
.getService(IArtifactRepositoryManager.SERVICE_NAME);
// create the feature query
IQuery<IInstallableUnit> iuQuery = QueryUtil.createLatestQuery(QueryUtil.createIUQuery(getP2IuId()));
IQuery<IInstallableUnit> iuQuery = createQuery();
// remove existing repositories
for (URI existingRepUri : metadataManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL)) {
@@ -521,6 +529,10 @@ public class P2ExtraFeature extends AbstractExtraFeature implements IP2Feature {
return metadataManager.query(iuQuery, progress).toUnmodifiableSet();
}
protected IQuery<IInstallableUnit> createQuery() {
return QueryUtil.createLatestQuery(QueryUtil.createIUQuery(getP2IuId()));
}
/**
* Created for JUnit test so that external P2 data area does not depend on absolute location
*
@@ -800,4 +812,14 @@ public class P2ExtraFeature extends AbstractExtraFeature implements IP2Feature {
public boolean useP2Cache() {
return this.useP2Cache;
}
protected Collection<IInstallableUnit> getInstalledP2Feature(IProfile profile, Collection<IInstallableUnit> toInstalls,
IProgressMonitor monitor) throws Exception {
Collection<IQuery<IInstallableUnit>> queries = new LinkedList<>();
for (IInstallableUnit toInst : toInstalls) {
queries.add(QueryUtil.createIUQuery(toInst.getId()));
}
return profile.available(QueryUtil.createCompoundQuery(queries, false), monitor).toSet();
}
}

View File

@@ -15,6 +15,8 @@ package org.talend.updates.runtime.nexus.component;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Dictionary;
import java.util.Hashtable;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -27,6 +29,7 @@ import org.talend.core.nexus.IRepositoryArtifactHandler;
import org.talend.core.nexus.RepositoryArtifactHandlerManager;
import org.talend.core.nexus.TalendMavenResolver;
import org.talend.core.runtime.maven.MavenArtifact;
import org.talend.core.runtime.services.IMavenUIService;
import org.talend.updates.runtime.feature.model.Type;
import org.talend.updates.runtime.model.interfaces.ITaCoKitCarFeature;
import org.talend.updates.runtime.service.ITaCoKitUpdateService;
@@ -212,7 +215,15 @@ public class ComponentsDeploymentManager {
artifactRepisotory.setRepositoryId(repositoryId);
if (repositoryHandler == null) {
repositoryHandler = RepositoryArtifactHandlerManager.getRepositoryHandler(artifactRepisotory);
repositoryHandler.updateMavenResolver(TalendMavenResolver.COMPONENT_MANANGER_RESOLVER, null);
Dictionary<String, String> properties = new Hashtable<String, String>();
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMavenUIService.class)) {
IMavenUIService mavenUIService = (IMavenUIService) GlobalServiceRegister.getDefault()
.getService(IMavenUIService.class);
if (mavenUIService != null) {
properties = mavenUIService.getTalendMavenSetting();
}
}
repositoryHandler.updateMavenResolver(TalendMavenResolver.COMPONENT_MANANGER_RESOLVER, properties);
}
return repositoryHandler;
}

View File

@@ -7,4 +7,6 @@ Fragment-Host: org.talend.core.runtime
Require-Bundle: org.junit;bundle-version="4.11.0",
org.talend.utils,
org.talend.testutils,
org.talend.components.common
org.talend.components.common,
javax.xml.soap
Import-Package: org.talend.core.repository.model

View File

@@ -714,4 +714,99 @@ public class MetadataToolHelperTest {
assertEquals("FLOAT4", target.getColumn("S3").getType());
assertEquals("NUMERIC", target.getColumn("S4").getType());
}
@Test
public void testSetTargetOriginalColumns() {
IMetadataTable source = new org.talend.core.model.metadata.MetadataTable();
IMetadataTable target = new org.talend.core.model.metadata.MetadataTable();
IMetadataColumn column = new org.talend.core.model.metadata.MetadataColumn();
column.setLabel("S1"); //$NON-NLS-1$
column.setTalendType(JavaTypesManager.STRING.getId());
column.setType("STRING");
source.getListColumns().add(column);
column = new org.talend.core.model.metadata.MetadataColumn();
column.setLabel("S2"); //$NON-NLS-1$
column.setTalendType(JavaTypesManager.SHORT.getId());
column.setType("SHORT");
source.getListColumns().add(column);
column = new org.talend.core.model.metadata.MetadataColumn();
column.setLabel("S3"); //$NON-NLS-1$
column.setTalendType(JavaTypesManager.FLOAT.getId());
column.setType("FLOAT");
source.getListColumns().add(column);
column = new org.talend.core.model.metadata.MetadataColumn();
column.setLabel("S4"); //$NON-NLS-1$
column.setTalendType(JavaTypesManager.BIGDECIMAL.getId());
column.setType("BIG_DECIMAL");
source.getListColumns().add(column);
MetadataToolHelper.setTargetOriginalColumns(source, target);
assertNull(target.getOriginalColumns());
List<String> sOriColumns = new ArrayList<>();
sOriColumns.add("S1");
sOriColumns.add("S2");
sOriColumns.add("S3");
sOriColumns.add("S4");
source.setOriginalColumns(sOriColumns);
MetadataToolHelper.setTargetOriginalColumns(source, target);
List<String> tCs = target.getOriginalColumns();
List<String> sCs = target.getOriginalColumns();
for(int i=0;i<tCs.size();i++) {
assertEquals(tCs.get(i), sCs.get(i));
}
target.setOriginalColumns(sOriColumns);
MetadataToolHelper.setTargetOriginalColumns(source, target);
tCs = target.getOriginalColumns();
sCs = target.getOriginalColumns();
for(int i=0;i<tCs.size();i++) {
assertEquals(tCs.get(i), sCs.get(i));
}
column = new org.talend.core.model.metadata.MetadataColumn();
column.setLabel("S1"); //$NON-NLS-1$
column.setTalendType(JavaTypesManager.STRING.getId());
column.setType("STRING");
target.getListColumns().add(column);
column = new org.talend.core.model.metadata.MetadataColumn();
column.setLabel("S2"); //$NON-NLS-1$
column.setTalendType(JavaTypesManager.SHORT.getId());
column.setType("SHORT");
target.getListColumns().add(column);
column = new org.talend.core.model.metadata.MetadataColumn();
column.setLabel("S3"); //$NON-NLS-1$
column.setTalendType(JavaTypesManager.FLOAT.getId());
column.setType("FLOAT");
target.getListColumns().add(column);
column = new org.talend.core.model.metadata.MetadataColumn();
column.setLabel("S4"); //$NON-NLS-1$
column.setTalendType(JavaTypesManager.BIGDECIMAL.getId());
column.setType("BIG_DECIMAL");
target.getListColumns().add(column);
column = new org.talend.core.model.metadata.MetadataColumn();
column.setLabel("S5"); //$NON-NLS-1$
column.setTalendType(JavaTypesManager.STRING.getId());
column.setType("STRING");
target.getListColumns().add(column);
column = new org.talend.core.model.metadata.MetadataColumn();
column.setLabel("S6"); //$NON-NLS-1$
column.setTalendType(JavaTypesManager.STRING.getId());
column.setType("STRING");
target.getListColumns().add(column);
sOriColumns = new ArrayList<>();
sOriColumns.add("S5");
sOriColumns.add("S6");
target.setOriginalColumns(sOriColumns);
MetadataToolHelper.setTargetOriginalColumns(source, target);
tCs = target.getOriginalColumns();
for(int i=0;i<target.getListColumns().size();i++) {
assertEquals(tCs.get(i), "S"+(i+1));
}
}
}

View File

@@ -0,0 +1,56 @@
// ============================================================================
//
// Copyright (C) 2006-2020 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.utils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.repository.model.IRepositoryNode.ENodeType;
import org.talend.repository.model.IRepositoryNode.EProperties;
import org.talend.repository.model.RepositoryNode;
/*
* Created by bhe on Mar 30, 2020
*/
public class RepositoryNodeTest {
@Test
public void testEquals() throws Exception {
RepositoryNode parent = new RepositoryNode(null, null, ENodeType.STABLE_SYSTEM_FOLDER);
parent.setProperties(EProperties.LABEL, "system");
parent.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.PROCESS);
parent.setType(ENodeType.STABLE_SYSTEM_FOLDER);
assertNotNull(parent);
RepositoryNode parentNew = new RepositoryNode(null, null, ENodeType.STABLE_SYSTEM_FOLDER);
parentNew.setProperties(EProperties.LABEL, "system");
parentNew.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.PROCESS);
parentNew.setType(ENodeType.STABLE_SYSTEM_FOLDER);
assertEquals(parent, parentNew);
assertEquals(parent.hashCode(), parentNew.hashCode());
RepositoryNode son = new RepositoryNode(null, null, ENodeType.STABLE_SYSTEM_FOLDER);
son.setProperties(EProperties.LABEL, ERepositoryObjectType.PROCESS);
son.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.PROCESS);
assertNotNull(son);
assertFalse(parent.equals(son));
}
}

View File

@@ -0,0 +1,47 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.nexus;
import org.junit.Assert;
import org.junit.Test;
import org.talend.core.nexus.ArtifactRepositoryBean.NexusType;
/**
* DOC jding class global comment. Detailled comment
*/
public class ArtifactRepositoryBeanTest {
@Test
public void testSplitRepositoryUrl() {
String repositoryType = ArtifactRepositoryBean.NexusType.ARTIFACTORY.name();
// default contextpath artifactory
String urlCase = "http://localhost:8081/artifactory/Releases/";
// non-default contextpath
String urlCase1 = "http://localhost:8081/artifacts/Releases/";
// root contextpath
String urlCase2 = "http://localhost:8081/Releases/";
String[] splitedUrl = NexusType.splitRepositoryUrl(urlCase, repositoryType);
Assert.assertEquals("http://localhost:8081/artifactory/", splitedUrl[0]);
Assert.assertEquals("Releases", splitedUrl[1]);
String[] splitedUrl_1 = NexusType.splitRepositoryUrl(urlCase1, repositoryType);
Assert.assertEquals("http://localhost:8081/artifacts/", splitedUrl_1[0]);
Assert.assertEquals("Releases", splitedUrl_1[1]);
String[] splitedUrl_2 = NexusType.splitRepositoryUrl(urlCase2, repositoryType);
Assert.assertEquals("http://localhost:8081/", splitedUrl_2[0]);
Assert.assertEquals("Releases", splitedUrl_2[1]);
}
}

View File

@@ -21,8 +21,10 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.maven.model.Model;
import org.apache.maven.model.Profile;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -280,9 +282,43 @@ public class AggregatorPomsHelperTest {
}
};
_helper.updateRefProjectModules(references);
validatePomContent(helper.getProjectRootPom().getLocation().toFile(), defaultProjectGroupId, defaultProjectVersion,
modules);
_helper.updateRefProjectModules(references, new NullProgressMonitor());
validatePomContent(helper.getProjectRootPom().getLocation().toFile(), defaultProjectGroupId, null, defaultProjectVersion,
null, model.getModules(), null);
}
@Test
public void testUpdateRefProjectProfile() throws Exception {
needResetPom = true;
List<ProjectReference> references = new ArrayList<>();
{
ProjectReference reference = PropertiesFactory.eINSTANCE.createProjectReference();
Project project = PropertiesFactory.eINSTANCE.createProject();
project.setTechnicalLabel("TESTPROJECT1");
reference.setReferencedProject(project);
references.add(reference);
}
{
ProjectReference reference = PropertiesFactory.eINSTANCE.createProjectReference();
Project project = PropertiesFactory.eINSTANCE.createProject();
project.setTechnicalLabel("TESTPROJECT2");
reference.setReferencedProject(project);
references.add(reference);
}
AggregatorPomsHelper _helper = new AggregatorPomsHelper() {
@Override
public boolean needUpdateRefProjectModules() {
return true;
}
};
ProjectPreferenceManager preferenceManager = new ProjectPreferenceManager(
ProjectManager.getInstance().getCurrentProject(), DesignerMavenPlugin.PLUGIN_ID, false);
preferenceManager.setValue(MavenConstants.USE_PROFILE_MODULE, true);
_helper.updateRefProjectModules(references, new NullProgressMonitor());
validatePomContent(helper.getProjectRootPom().getLocation().toFile(), defaultProjectGroupId, null, defaultProjectVersion,
null, null, references);
}
/**
@@ -310,17 +346,17 @@ public class AggregatorPomsHelperTest {
// check project pom.
IFile projectPomFile = new AggregatorPomsHelper().getProjectRootPom();
validatePomContent(projectPomFile.getLocation().toFile(), projectGroupId, projectVersion, modules);
validatePomContent(projectPomFile.getLocation().toFile(), projectGroupId, null, projectVersion, null, modules, null);
// check project pom install result.
File installedProjectPom = getInstalledFileFromLocalRepo(projectGroupId,
TalendMavenConstants.DEFAULT_CODE_PROJECT_ARTIFACT_ID, projectVersion, MavenConstants.PACKAGING_POM);
validatePomContent(installedProjectPom, projectGroupId, projectVersion, modules);
validatePomContent(installedProjectPom, projectGroupId, null, projectVersion, null, modules, null);
// check routine pom.
IFile routinePomFile = runProcessService.getTalendCodeJavaProject(ERepositoryObjectType.ROUTINES).getProjectPom();
String routineGroupId = PomIdsHelper.getCodesGroupId("code");
String routineVersion = PomIdsHelper.getCodesVersion();
validatePomContent(routinePomFile.getLocation().toFile(), routineGroupId, routineVersion);
validatePomContent(routinePomFile.getLocation().toFile(), routineGroupId, null, routineVersion, null, null, null);
// check routine install result.
File installedRoutinePom = getInstalledFileFromLocalRepo(routineGroupId,
@@ -329,7 +365,7 @@ public class AggregatorPomsHelperTest {
// check job pom.
IFile jobPomFile = runProcessService.getTalendJobJavaProject(jobProperty).getProjectPom();
validatePomContent(jobPomFile.getLocation().toFile(), jobGroupId, projectGroupId, jobVersion, projectVersion, null);
validatePomContent(jobPomFile.getLocation().toFile(), jobGroupId, projectGroupId, jobVersion, projectVersion, null, null);
}
@Test
@@ -347,19 +383,11 @@ public class AggregatorPomsHelperTest {
IFile jobPomFile = runProcessService.getTalendJobJavaProject(jobProperty).getProjectPom();
validatePomContent(jobPomFile.getLocation().toFile(), customJobGroupId, defaultProjectGroupId, customJobVersion,
defaultProjectVersion, null);
}
private void validatePomContent(File pomFile, String groupId, String version) throws CoreException {
validatePomContent(pomFile, groupId, null, version, null, null);
}
private void validatePomContent(File pomFile, String groupId, String version, List<String> modules) throws CoreException {
validatePomContent(pomFile, groupId, null, version, null, modules);
defaultProjectVersion, null, null);
}
private void validatePomContent(File pomFile, String groupId, String parentGroupId, String version, String parentVersion,
List<String> modules)
List<String> modules, List<ProjectReference> references)
throws CoreException {
Model model = MavenPlugin.getMaven().readModel(pomFile);
assertEquals(groupId, model.getGroupId());
@@ -376,6 +404,25 @@ public class AggregatorPomsHelperTest {
for (String module : modules) {
assertTrue(currentModules.contains(module));
}
} else {
assertEquals(0, model.getModules().stream().filter(module -> module.startsWith("../../")).count());
}
if (references != null) {
if (PomIdsHelper.useProfileModule()) {
List<Profile> refProjectProfiles = model.getProfiles().stream()
.filter(profile -> AggregatorPomsHelper.matchModuleProfile(profile.getId(), projectTechName))
.collect(Collectors.toList());
assertEquals(references.size(), refProjectProfiles.size());
references.forEach(reference -> {
String profileId = (projectTechName + "_" + reference.getReferencedProject().getTechnicalLabel())
.toLowerCase();
assertTrue(refProjectProfiles.stream().anyMatch(profile -> profile.getId().equals(profileId)));
});
}
} else {
assertEquals(0, model.getProfiles().stream()
.filter(profile -> AggregatorPomsHelper.matchModuleProfile(profile.getId(), projectTechName)).count());
}
}
@@ -428,6 +475,7 @@ public class AggregatorPomsHelperTest {
projectPreferenceManager.setValue(MavenConstants.PROJECT_VERSION, defaultProjectVersion);
projectPreferenceManager.setValue(MavenConstants.NAME_PUBLISH_AS_SNAPSHOT, defaultUseSnapshot);
projectPreferenceManager.setValue(MavenConstants.POM_FILTER, "");
projectPreferenceManager.setValue(MavenConstants.USE_PROFILE_MODULE, false);
// reset all poms.
if (needResetPom) {
helper.syncAllPomsWithoutProgress(new NullProgressMonitor());

View File

@@ -0,0 +1,49 @@
// ============================================================================
//
// Copyright (C) 2006-2020 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.designer.maven.utils;
import java.util.HashSet;
import java.util.Set;
import org.junit.Assert;
import org.junit.Test;
/**
* DOC jding class global comment. Detailled comment
*/
public class SortableDependencyTest {
@Test
public void testEqualsHashcode() {
SortableDependency dependency = new SortableDependency();
dependency.setGroupId("org.example.test");
dependency.setArtifactId("test");
SortableDependency dependency1 = new SortableDependency();
dependency1.setGroupId("org.example.test");
dependency1.setArtifactId("test");
Set<SortableDependency> dependencySet = new HashSet<SortableDependency>();
dependencySet.add(dependency);
dependencySet.add(dependency1);
Assert.assertEquals(1, dependencySet.size());
Assert.assertTrue(dependency.equals(dependency1));
dependency.setVersion("0.1");
dependency1.setVersion("0.2");
dependencySet.add(dependency1);
Assert.assertEquals(2, dependencySet.size());
Assert.assertFalse(dependency.equals(dependency1));
}
}