Compare commits

...

17 Commits

Author SHA1 Message Date
Jane Ding
7aaf54dcf7 fix(TUP-28952):TOS: NPE when delete items to recycle bin (#3738)
https://jira.talendforge.org/browse/TUP-28952

Signed-off-by: jding-tlnd <jding@talend.com>
2020-10-20 10:15:51 +08:00
bhe-talendbj
3996d24893 feat(TUP-25246): Automatically detect custom maven URI for external jars (#3636)
* feat(TUP-25246): Automatically detect custom maven URI for external dependencies

* feat(TUP-25246): add Jar detector

* feat(TUP-25246): fix NPE

* feat(TUP-25246): fix NPE

* feat(TUP-25246): refactor

* feat(TUP-25246): fix error selections

* feat(TUP-25246): set default value for custom uri

* feat(TUP-25246): call LibManagerUiPlugin.getDefault().getLibrariesService() to deploy jar

* feat(TUP-25246): fix customuri for tLibraryload

* feat(TUP-25246): autofill custom uri if detected

* feat(TUP-25246): autofill default uri if detected

* feat(TUP-25246): Update metadata driver jar

* feat(TUP-25246): hide remote search if no remote repositoris

* feat(TUP-28342):Save maven url for components with parameter MODULE_LIST

* feat(TUP-25246): Fix dialog and moduleNeed

* feat(TUP-25246): set error message if module was already installed

* feat(TUP-25246): remove error message if module is already installed

* feat(TUP-25246): Fix metadata driver path

* feat(TUP-25246): add check for copy

* feat(TUP-25246): Fix cConfig and UI

* feat(TUP-25246): TUP-28910

* feat(TUP-25246): fix retrieve jar

* feat(TUP-25246): add migration

* feat(TUP-25246): fix diaglog behavior

* feat(TUP-25246): Fix jar path inside context

* feat(TUP-25246): remove quotes for jar

* feat(): Fix config dialog and revert TalendLibsServerManager

* feat(TUP-25246): fix configdialog

* feat(TUP-25246): remove nl plugin

* feat(TUP-25246): fix resolve local jar

* feat(TUP-25246): fix resolve local jar

Co-authored-by: Zhiwei Xue <zwxue@talend.com>
2020-10-16 16:22:56 +08:00
sbliu
f37b5b6073 TUP-28944 Issue with performance tracking with french locale (#3723)
* TUP-28944 fix the number format problem introduced by different locale.

* TUP-28944 make format method suitable to test.

* TUP-28944 add unit test for format a number.

* TUP-28944 fix the unit test.
2020-10-16 10:42:14 +08:00
jiezhang-tlnd
060a9c7f9e feat(TUP-28758)Add a warning when we login to a project and if there is (#3675)
* feat(TUP-28758)Add a warning when we login to a project and if there is
migration to do

* feat(TUP-28758)Add a warning when we login to a project and if there is
migration to do

* update warning info

* format code

* Add a warning when we login to a project and if there is migration to do

* collect warnings in one dialog

* remove nexus warning dialog

* update login info

* adjust warning content

* adjust warning content

* adjust warning content

* remove useless cases

* add junits

* update method and junits

* modify the text

* get right monthly patch name

* modify project patch version name

* remove Talend word in warning message
2020-10-15 15:18:29 +08:00
hzhao-talendbj
789b4c02c0 backport 27849 to 73 (#3707) 2020-10-14 16:52:29 +08:00
Chao MENG
4c3e3dfb2c fix(TUP-28903): NPE exception when clicking on context (#3711)
https://jira.talendforge.org/browse/TUP-28903
2020-10-14 11:40:24 +08:00
bhe-talendbj
7b3a20a3b3 fix(TUP-28659): Remove snapshot version of jars (#3664) 2020-10-14 09:44:21 +08:00
Jane Ding
e3880f3904 feat(TUP-28640):Improve JDBC database support framework to load (#3686)
* feat(TUP-28640):Improve JDBC database support framework to load
supported DBs and components automatically
https://jira.talendforge.org/browse/TUP-28640

* feat(TUP-28640):Improve JDBC database support framework to load
supported DBs and components automatically
https://jira.talendforge.org/browse/TUP-28640
2020-10-13 16:22:28 +08:00
Jane Ding
d54ed2a62c fix(TUP-28618):[Bug] db type dont show Delta in impact page. (#3676)
https://jira.talendforge.org/browse/TUP-28618
2020-10-13 16:20:23 +08:00
Mike Yan
cde1129ce4 Yyan/feat/tesb 29271 route debug 731 (#3709)
* feat(TESB-29271): Add camel breakpoint category

* fix(TESB-30624)[Debugging for Routes] NameAlreadyBoundException when
debug the ctalendjob
2020-10-13 15:15:33 +08:00
kjwang
1081ae3680 Kjwang/feat tup 27762 new version of ci (#3656)
* TUP-28274 Shared Studio: Can't find EMR 5.29 option in Hadoop Cluster
wizard after enable shared studio mode
https://jira.talendforge.org/browse/TUP-28274
2020-10-13 10:41:54 +08:00
chmyga
3e02adb157 fix(TDI-44962): fix stream closed exception (#3692)
* Recreate FileWriter with append after writing header

* Add csv writer to shared writer map

Co-authored-by: Dmytro Chmyga <dmytro.chmyga@synapse.com>
2020-10-12 11:24:55 +03:00
hzhao-talendbj
c212142789 change to filter CI case (#3697) 2020-10-12 12:46:38 +08:00
wang wei
ab67a4cc91 fix(TDI-44937): TalendDate.formatDateLocale()gives random value for FR country code in java 11.(#3679) 2020-10-12 10:20:41 +08:00
Chao MENG
675da3fc7d fix(TUP-27076): Unable to connect to codecommit GIT after the first (#3673)
login.
https://jira.talendforge.org/browse/TUP-27076
2020-10-10 10:40:59 +08:00
hzhao-talendbj
6f9ad53b0d remove exception log (#3688) 2020-10-09 11:10:19 +08:00
Mike Yan
6cfffe1775 feat(TESB-29271): Add camel breakpoint category (#3680) 2020-10-07 21:50:29 +08:00
70 changed files with 2214 additions and 608 deletions

View File

@@ -13,7 +13,6 @@
<plugin id="org.talend.libraries.jdbc.ingres" download-size="0" install-size="0" version="0.0.0"/>
<plugin id="org.talend.libraries.jdbc.mysql" download-size="0" install-size="0" version="0.0.0"/>
<plugin id="org.talend.libraries.jdbc.paraccel" download-size="0" install-size="0" version="0.0.0"/>
<plugin id="org.talend.libraries.jdbc.postgresql" download-size="0" install-size="0" version="0.0.0"/>
<plugin id="org.talend.libraries.jdbc.sqlite3" download-size="0" install-size="0" version="0.0.0"/>
<plugin id="org.talend.libraries.jdbc.teradata" download-size="0" install-size="0" version="0.0.0"/>
</feature>

View File

@@ -232,10 +232,50 @@ public class VersionUtils {
* Check if studio version < other studio version record in remote project.
*/
public static boolean isInvalidProductVersion(String remoteFullProductVersion) {
String localProductVersion = getInternalVersion();
return isInvalidProductVersion(localProductVersion, remoteFullProductVersion);
}
protected static boolean isInvalidProductVersion(String localProductVersion, String remoteFullProductVersion) {
if (remoteFullProductVersion == null) {
return false;
}
return getInternalVersion().compareTo(getProductVersionWithoutBranding(remoteFullProductVersion)) < 0;
if (skipCheckingNightlyBuilds(localProductVersion, remoteFullProductVersion)) {
return false;
}
return localProductVersion.compareTo(getProductVersionWithoutBranding(remoteFullProductVersion)) < 0;
}
public static boolean productVersionIsNewer(String remoteFullProductVersion) {
String localProductVersion = getInternalVersion();
return productVersionIsNewer(localProductVersion, remoteFullProductVersion);
}
protected static boolean productVersionIsNewer(String localProductVersion, String remoteFullProductVersion) {
if (remoteFullProductVersion == null) {
return false;
}
if (skipCheckingNightlyBuilds(localProductVersion, remoteFullProductVersion)) {
return false;
}
return localProductVersion.compareTo(getProductVersionWithoutBranding(remoteFullProductVersion)) > 0;
}
private static boolean skipCheckingNightlyBuilds(String localProductVersion, String remoteFullProductVersion) {
String separator = "-"; //$NON-NLS-1$
String localSuffix = StringUtils.substringAfterLast(localProductVersion, separator);
String remoteProductVersion = getProductVersionWithoutBranding(remoteFullProductVersion);
String remoteSuffix = StringUtils.substringAfterLast(remoteProductVersion, separator);
String nightly = "SNAPSHOT"; //$NON-NLS-1$
String milestone = "M"; //$NON-NLS-1$
if ((localSuffix.equals(nightly) || localSuffix.startsWith(milestone))
&& (remoteSuffix.equals(nightly) || remoteSuffix.startsWith(milestone))) {
// skip checking between nightly/milestone build.
return true;
}
return false;
}
public static String getTalendVersion(String productVersion) {
@@ -310,4 +350,24 @@ public class VersionUtils {
}
}
public static String getSimplifiedPatchName(String projectPatchName) {
if (projectPatchName != null) {
String result = null;
if (projectPatchName.contains("_") && projectPatchName.split("_").length >= 3) {
result = projectPatchName.split("_")[2];
if (!result.startsWith("R")) {
return null;
}
}
if (projectPatchName.contains("-")) {
String[] split = projectPatchName.split("-");
if (split != null && split.length > 0) {
return result + "-" + split[split.length - 1];
}
}
}
return null;
}
}

View File

@@ -150,6 +150,28 @@ public class NetworkUtil {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
String httpProxyHost = System.getProperty("http.proxyHost"); //$NON-NLS-1$
String httpProxyPort = System.getProperty("http.proxyPort"); //$NON-NLS-1$
String httpsProxyHost = System.getProperty("https.proxyHost"); //$NON-NLS-1$
String httpsProxyPort = System.getProperty("https.proxyPort"); //$NON-NLS-1$
String requestingHost = getRequestingHost();
int requestingPort = getRequestingPort();
String proxyHost = null;
String proxyPort = null;
boolean isHttp = false;
if ("http".equalsIgnoreCase(getRequestingScheme())) {
isHttp = true;
}
if (isHttp && StringUtils.isNotBlank(httpProxyHost)) {
proxyHost = httpProxyHost;
proxyPort = httpProxyPort;
} else {
proxyHost = httpsProxyHost;
proxyPort = httpsProxyPort;
}
if (!StringUtils.equals(proxyHost, requestingHost) || !StringUtils.equals(proxyPort, "" + requestingPort)) {
return null;
}
String httpProxyUser = System.getProperty("http.proxyUser"); //$NON-NLS-1$
String httpProxyPassword = System.getProperty("http.proxyPassword"); //$NON-NLS-1$
String httpsProxyUser = System.getProperty("https.proxyUser"); //$NON-NLS-1$
@@ -167,7 +189,11 @@ public class NetworkUtil {
proxyPassword = httpsProxyPassword.toCharArray();
}
}
return new PasswordAuthentication(proxyUser, proxyPassword);
if (StringUtils.isBlank(proxyUser)) {
return null;
} else {
return new PasswordAuthentication(proxyUser, proxyPassword);
}
}
});

View File

@@ -18,7 +18,8 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.text.DecimalFormat;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Properties;
import java.util.Random;
import java.util.concurrent.TimeUnit;
@@ -36,8 +37,6 @@ import org.talend.commons.exception.CommonExceptionHandler;
*/
public class PerformanceStatisticUtil {
private static final DecimalFormat DF = new DecimalFormat("###.##");
private static final int MEGABYTE = 1024 * 1024;// MB = 1024*1024 byte
private static final int KILOBYTE = 1024;// kb=1024 byte
@@ -250,8 +249,8 @@ public class PerformanceStatisticUtil {
digital_ioWAverageMbSec = (digital_ioWAverageMbSec * digital_ioCount + bwMbSec) / (digital_ioCount + 1);
digital_ioWMbSec = bwMbSec;
props.setProperty(StatisticKeys.IO_W_AVERAGE_MB_SEC.get(), "" + DF.format(digital_ioWAverageMbSec));
props.setProperty(StatisticKeys.IO_W_MB_SEC.get(), "" + DF.format(digital_ioWMbSec));
props.setProperty(StatisticKeys.IO_W_AVERAGE_MB_SEC.get(), format(digital_ioWAverageMbSec));
props.setProperty(StatisticKeys.IO_W_MB_SEC.get(), format(digital_ioWMbSec));
}
private static long writeIO(int numOfBlocks, BlockSequence blockSequence, int blockSize, File testFile) {
@@ -324,11 +323,15 @@ public class PerformanceStatisticUtil {
digital_ioRMbSec = bwMbSec;
digital_ioCount++;
props.setProperty(StatisticKeys.IO_R_AVERAGE_MB_SEC.get(), "" + DF.format(digital_ioRAverageMbSec));
props.setProperty(StatisticKeys.IO_R_MB_SEC.get(), "" + DF.format(digital_ioRMbSec));
props.setProperty(StatisticKeys.IO_R_AVERAGE_MB_SEC.get(), format(digital_ioRAverageMbSec));
props.setProperty(StatisticKeys.IO_R_MB_SEC.get(), format(digital_ioRMbSec));
props.setProperty(StatisticKeys.IO_COUNT.get(), "" + digital_ioCount);
}
public static String format(double dvalue) {
return BigDecimal.valueOf(dvalue).setScale(2, RoundingMode.HALF_UP).toString();
}
private static long readIO(int numOfBlocks, BlockSequence blockSequence, int blockSize, File testFile) {
long totalBytesReadInMark = 0;

View File

@@ -132,6 +132,7 @@ import org.talend.core.repository.utils.RepositoryPathProvider;
import org.talend.core.repository.utils.XmiResourceManager;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.core.runtime.repository.item.ItemProductKeys;
import org.talend.core.runtime.services.IGenericWizardService;
import org.talend.core.runtime.services.IMavenUIService;
import org.talend.core.runtime.util.ItemDateParser;
import org.talend.core.service.ICoreUIService;
@@ -2140,6 +2141,14 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
ProjectDataJsonProvider.checkAndRectifyRelationShipSetting(project.getEmfProject());
// load additional jdbc
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
IGenericWizardService service = GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
if (service != null) {
service.loadAdditionalJDBC();
}
}
// init dynamic distirbution after `beforeLogon`, before loading libraries.
initDynamicDistribution(monitor);

View File

@@ -23,6 +23,7 @@ import org.talend.core.database.EDatabaseTypeName;
import org.talend.core.database.conn.version.EDatabaseVersion4Drivers;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.runtime.services.IGenericDBService;
import org.talend.core.runtime.services.IGenericWizardService;
/**
* cli class global comment. Detailled comment
@@ -326,6 +327,16 @@ public enum EDatabaseConnTemplate {
databaseType.add(typeName);
}
}
// add additional jdbc (actually JDBC RepositoryObjectType)
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
IGenericWizardService service = GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
if (service != null) {
List<String> allAdditionalJDBCTypes = service.getAllAdditionalJDBCTypes();
if (!allAdditionalJDBCTypes.isEmpty()) {
databaseType.addAll(allAdditionalJDBCTypes);
}
}
}
if (sort) {
String[] sortedArray = databaseType.toArray(new String[0]);
Arrays.sort(sortedArray, new Comparator<String>() {

View File

@@ -102,12 +102,12 @@ public enum EDatabaseVersion4Drivers {
GREENPLUM(new DbVersion4Drivers(EDatabaseTypeName.GREENPLUM, "postgresql-8.4-703.jdbc4.jar")), //$NON-NLS-1$
// PSQL_V10(new DbVersion4Drivers(EDatabaseTypeName.PSQL, "v10", "V10", "postgresql-42.2.5.jar")),
PSQL_V9_X(new DbVersion4Drivers(EDatabaseTypeName.PSQL, "v9 and later", "V9_X", "postgresql-42.2.9.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
PSQL_V9_X(new DbVersion4Drivers(EDatabaseTypeName.PSQL, "v9 and later", "V9_X", "postgresql-42.2.14.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
PSQL_PRIOR_TO_V9(new DbVersion4Drivers(EDatabaseTypeName.PSQL, "Prior to v9", "PRIOR_TO_V9", "postgresql-8.4-703.jdbc4.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
PLUSPSQL_PRIOR_TO_V9(new DbVersion4Drivers(EDatabaseTypeName.PLUSPSQL,
"Prior to v9", "PRIOR_TO_V9", "postgresql-8.4-703.jdbc4.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
PLUSPSQL_V9_X(new DbVersion4Drivers(EDatabaseTypeName.PLUSPSQL, "v9 and later", "V9_X", "postgresql-9.4-1201.jdbc41.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
PLUSPSQL_V9_X(new DbVersion4Drivers(EDatabaseTypeName.PLUSPSQL, "v9 and later", "V9_X", "postgresql-42.2.14.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
IBMDB2(new DbVersion4Drivers(EDatabaseTypeName.IBMDB2, new String[] { "db2jcc4.jar", "db2jcc_license_cu.jar", //$NON-NLS-1$ //$NON-NLS-2$
"db2jcc_license_cisuz.jar" })), //$NON-NLS-1$
IBMDB2ZOS(new DbVersion4Drivers(EDatabaseTypeName.IBMDB2ZOS, new String[] { "db2jcc4.jar", "db2jcc_license_cu.jar", //$NON-NLS-1$ //$NON-NLS-2$

View File

@@ -28,6 +28,7 @@ import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.core.runtime.maven.MavenArtifact;
import org.talend.core.runtime.maven.MavenConstants;
import org.talend.core.runtime.maven.MavenUrlHelper;
import org.talend.core.utils.TalendQuoteUtils;
/**
* This bean is use to manage needed moduless (perl) and libraries (java).<br/>
@@ -110,6 +111,15 @@ public class ModuleNeeded {
}
public static ModuleNeeded newInstance(String context, String value, String informationMsg, boolean required) {
String val = TalendQuoteUtils.removeQuotesIfExist(value);
if (val.startsWith(MavenUrlHelper.MVN_PROTOCOL)) {
return new ModuleNeeded(context, informationMsg, required, val);
}
// won't do migration for old MODULE_LIST but still make it compatible
return new ModuleNeeded(context, val, informationMsg, required);
}
/**
* DOC smallet ModuleNeeded constructor comment.
*

View File

@@ -31,6 +31,7 @@ import org.talend.core.database.conn.ConnParameterKeys;
import org.talend.core.database.conn.DatabaseConnStrUtil;
import org.talend.core.database.conn.version.EDatabaseVersion4Drivers;
import org.talend.core.model.components.EComponentType;
import org.talend.core.model.metadata.Dbms;
import org.talend.core.model.metadata.IMetadataTable;
import org.talend.core.model.metadata.MetadataTalendType;
import org.talend.core.model.metadata.builder.ConvertionHelper;
@@ -155,6 +156,17 @@ public class ComponentToRepositoryProperty {
conn.setDbmsId(mapping);
}
}
// set default mapping for additional jdbc
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
IGenericWizardService service = GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
if (service != null) {
Dbms dbms4AdditionalJDBC = service.getDbms4AdditionalJDBC(conn.getProductId());
if (dbms4AdditionalJDBC != null) {
conn.setDbmsId(dbms4AdditionalJDBC.getId());
}
}
}
}
for (IElementParameter param : node.getElementParameters()) {
String repositoryValue = param.getRepositoryValue();
@@ -368,19 +380,18 @@ public class ComponentToRepositoryProperty {
if (para.getRepositoryValue().endsWith(EDatabaseTypeName.GENERAL_JDBC.getProduct())) {
connection.setDatabaseType(EDatabaseTypeName.GENERAL_JDBC.getProduct());
connection.setProductId(EDatabaseTypeName.GENERAL_JDBC.getProduct());
if (!node.getComponent().getDisplayName().equals(node.getComponent().getName())) {
// additional JDBC e.g. Delta Lake
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
IGenericWizardService service = GlobalServiceRegister.getDefault()
.getService(IGenericWizardService.class);
if (service != null) {
String database = service.getDatabseNameByNode(node);
if (StringUtils.isNotBlank(database)) {
connection.setProductId(database);
}
}
// additional JDBC e.g. Delta Lake
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
IGenericWizardService service = GlobalServiceRegister.getDefault()
.getService(IGenericWizardService.class);
if (service != null) {
String database = service.getDatabseNameByNode(node);
if (StringUtils.isNotBlank(database) && service.getIfAdditionalJDBCDBType(database)) {
connection.setProductId(database);
}
}
}
}

View File

@@ -44,6 +44,7 @@ public enum EComponentCategory {
DYNAMICS_SETTINGS(Messages.getString("EComponentCategory_dynamicSetting"), 13), //$NON-NLS-1$
SQL_PATTERN(Messages.getString("EComponentCategory_sqlTemplate"), 14), //$NON-NLS-1$
BREAKPOINT(Messages.getString("EComponentCategory.breakpoint"), 15), //$NON-NLS-1$
BREAKPOINT_CAMEL(Messages.getString("EComponentCategory.breakpoint"), 16), //$NON-NLS-1$
BASICRUN(Messages.getString("EComponentCategory.basicRun"), 1), //$NON-NLS-1$
DEBUGRUN(Messages.getString("EComponentCategory.debugRun"), 2), //$NON-NLS-1$
ADVANCESETTING(Messages.getString("EComponentCategory.advancedSettings"), 3), //$NON-NLS-1$

View File

@@ -15,6 +15,7 @@ package org.talend.core.model.utils;
import java.util.ArrayList;
import java.util.List;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
import org.talend.core.model.metadata.designerproperties.RepositoryToComponentProperty;
@@ -23,6 +24,7 @@ import org.talend.core.model.properties.ContextItem;
import org.talend.core.model.properties.Item;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.update.UpdatesConstants;
import org.talend.core.runtime.services.IGenericWizardService;
/**
* ggu class global comment. Detailled comment
@@ -47,6 +49,14 @@ public final class UpdateRepositoryHelper {
if (connection instanceof DatabaseConnection) {
String currentDbType = (String) RepositoryToComponentProperty.getValue(connection, UpdatesConstants.TYPE,
null);
String productId = ((DatabaseConnection) connection).getProductId();
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
IGenericWizardService service = GlobalServiceRegister.getDefault()
.getService(IGenericWizardService.class);
if (service != null && service.getIfAdditionalJDBCDBType(productId)) {
currentDbType = productId;
}
}
aliasName += " (" + currentDbType + ")"; //$NON-NLS-1$ //$NON-NLS-2$
}
if (repositoryObjectType.getType().equals("SERVICES")) {

View File

@@ -73,4 +73,6 @@ public interface IRepositoryArtifactHandler {
public String resolveRemoteSha1(MavenArtifact artifact, boolean fromRelease) throws Exception;
public List<MavenArtifact> search(String name, boolean fromSnapshot) throws Exception;
}

View File

@@ -370,4 +370,37 @@ public class NexusServerUtils {
}
public static List<MavenArtifact> search(String nexusUrl, String userName, String password, String repositoryId, String name)
throws Exception {
List<MavenArtifact> artifacts = new ArrayList<MavenArtifact>();
int totalCount = 0;
String service = NexusConstants.SERVICES_SEARCH + getSearchQuery(repositoryId, null, null, null, 0, MAX_SEARCH_COUNT)
+ "&q=" + name;
URI requestURI = getSearchURI(nexusUrl, service);
Document document = downloadDocument(requestURI, userName, password);
if (document != null) {
Node countNode = document.selectSingleNode("/searchNGResponse/totalCount");
if (countNode != null) {
try {
totalCount = Integer.parseInt(countNode.getText());
} catch (NumberFormatException e) {
totalCount = 0;
}
}
int searchDone = readDocument(document, artifacts);
while (searchDone < totalCount) {
service = NexusConstants.SERVICES_SEARCH
+ getSearchQuery(repositoryId, null, null, null, searchDone, MAX_SEARCH_COUNT) + "&q=" + name;
requestURI = getSearchURI(nexusUrl, service);
document = downloadDocument(requestURI, userName, password);
searchDone = searchDone + readDocument(document, artifacts);
}
}
return artifacts;
}
}

View File

@@ -174,7 +174,7 @@ public class MavenUrlHelper {
if (jarName != null && jarName.length() > 0) {
String artifactId = jarName;
String type = null;
if (jarName.endsWith(MavenConstants.TYPE_JAR)) { // remove the extension .jar
if (jarName.endsWith("." + MavenConstants.TYPE_JAR)) { // remove the extension .jar
artifactId = jarName.substring(0, jarName.lastIndexOf(MavenConstants.TYPE_JAR) - 1);
if (withPackage) {
type = MavenConstants.TYPE_JAR;

View File

@@ -20,6 +20,7 @@ import org.eclipse.swt.widgets.Composite;
import org.talend.commons.ui.swt.actions.ITreeContextualAction;
import org.talend.components.api.properties.ComponentProperties;
import org.talend.core.IService;
import org.talend.core.model.metadata.Dbms;
import org.talend.core.model.metadata.IMetadataTable;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
@@ -149,13 +150,18 @@ public interface IGenericWizardService extends IService {
*/
public ITreeContextualAction getDefaultAction(RepositoryNode node);
public void initAdditionalJDBCRepositoryObjType();
public void loadAdditionalJDBC();
public List<String> getAllAdditionalJDBCTypes();
public boolean getIfAdditionalJDBCDBType(String dbType);
public void initAdditonalJDBCConnectionValue(DatabaseConnection connection, Composite dynamicForm, String dbType,
String propertyId);
public String getDefinitionName4AdditionalJDBC(IElement element);
public String getDatabseNameByNode(IElement node);
public Dbms getDbms4AdditionalJDBC(String typeName);
}

View File

@@ -0,0 +1,83 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.runtime.util;
import java.io.File;
import java.io.IOException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.service.IUpdateService;
import org.talend.utils.io.FilesUtils;
public class SharedStudioUtils {
public static final String FILE_EXTRA_FEATURE_INDEX = "extra_feature.index"; //$NON-NLS-1$
public static final String SIGNATURE_FILE_NAME_SUFFIX = ".sig"; //$NON-NLS-1$
public static boolean updateExtraFeatureFile() {
File userConfigFolder = new File(Platform.getConfigurationLocation().getURL().getPath());
File studioConfigFolder = new File(Platform.getInstallLocation().getURL().getPath(), "configuration");//$NON-NLS-1$
if (!userConfigFolder.getAbsolutePath().equals(studioConfigFolder.getAbsolutePath())) {
File studioExtraFile = new File(studioConfigFolder, FILE_EXTRA_FEATURE_INDEX);
File studioExtraSignFile = new File(studioConfigFolder, FILE_EXTRA_FEATURE_INDEX + SIGNATURE_FILE_NAME_SUFFIX);
File userExtraFile = new File(userConfigFolder, FILE_EXTRA_FEATURE_INDEX);
File userExtraSignFile = new File(userConfigFolder, FILE_EXTRA_FEATURE_INDEX + SIGNATURE_FILE_NAME_SUFFIX);
boolean isNeedUpdate = false;
if (!studioExtraSignFile.exists() && userExtraSignFile.exists()) {
userExtraSignFile.delete();
if (userExtraFile.exists()) {
userExtraFile.delete();
}
return true;
} else if (studioExtraSignFile.exists()) {
isNeedUpdate = true;
}
if (isNeedUpdate) {
try {
FilesUtils.copyFile(studioExtraFile, userExtraFile);
FilesUtils.copyFile(studioExtraSignFile, userExtraSignFile);
} catch (IOException ex) {
ExceptionHandler.process(ex);
}
return true;
}
}
return false;
}
public static boolean isSharedStudioMode() {
File configFolder = new File (Platform.getConfigurationLocation().getURL().getFile());
File studioFolder = new File (Platform.getInstallLocation().getURL().getFile());
if (configFolder != null && studioFolder != null && configFolder.getParentFile() != null
&& configFolder.getParentFile().getAbsolutePath().equals(studioFolder.getAbsolutePath())) {
return false;
}
return true;
}
public static boolean installedPatch() {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IUpdateService.class)) {
IUpdateService updateService = GlobalServiceRegister.getDefault().getService(IUpdateService.class);
try {
return updateService.syncSharedStudioLibraryInPatch(new NullProgressMonitor());
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
return false;
}
}

View File

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

View File

@@ -13,6 +13,7 @@
package org.talend.core.ui;
import org.talend.core.IService;
import org.talend.core.runtime.maven.MavenArtifact;
/**
* @author hwang
@@ -21,5 +22,7 @@ import org.talend.core.IService;
public interface IInstalledPatchService extends IService {
public String getLatestInstalledVersion(boolean isBar);
public MavenArtifact getLastIntalledP2Patch();
}

View File

@@ -0,0 +1,60 @@
package org.talend.core.utils;
import java.util.Arrays;
import java.util.List;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.talend.commons.CommonsPlugin;
public class DialogUtils {
private static ELoginInfoCase finalCase;
public static void setWarningInfo(ELoginInfoCase warnningInfo) {
finalCase = warnningInfo;
}
public static void syncOpenWarningDialog(String title) {
if (CommonsPlugin.isHeadless() || DialogUtils.finalCase == null) {
return;
}
int dialogType = DialogUtils.finalCase.getDialogType();
String[] contents = DialogUtils.finalCase.getContents();
List<String> asList = Arrays.asList(contents);
StringBuffer sb = new StringBuffer();
asList.forEach(w -> {
sb.append(w);
sb.append("\n");// $NON-NLS-1$
});
int[] selectIndex = new int[1];
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
String[] dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL, };
if (dialogType == MessageDialog.ERROR) {
dialogButtonLabels = new String[] { IDialogConstants.CANCEL_LABEL };
}
int open = MessageDialog.open(dialogType, Display.getDefault().getActiveShell(), title, sb.toString(), SWT.NONE,
dialogButtonLabels);
selectIndex[0] = open;
}
});
DialogUtils.finalCase = null;
if (dialogType == MessageDialog.ERROR) {
throw new OperationCanceledException(""); //$NON-NLS-1$
}
if (1 == selectIndex[0]) {
throw new OperationCanceledException(""); //$NON-NLS-1$
}
}
}

View File

@@ -0,0 +1,40 @@
package org.talend.core.utils;
import org.eclipse.jface.dialogs.MessageDialog;
public enum ELoginInfoCase {
STUDIO_LOWER_THAN_PROJECT(MessageDialog.ERROR),
STUDIO_HIGHER_THAN_PROJECT(MessageDialog.WARNING);
private int dialogType;
private String[] contents;
ELoginInfoCase(int dialogType) {
this.dialogType = dialogType;
}
ELoginInfoCase(int dialogType, String[] contents) {
this.dialogType = dialogType;
this.contents = contents;
}
public int getDialogType() {
return dialogType;
}
public void setDialogType(int dialogType) {
this.dialogType = dialogType;
}
public String[] getContents() {
return contents;
}
public void setContents(String[] contents) {
this.contents = contents;
}
}

View File

@@ -497,7 +497,11 @@ public class ContextTreeTable {
int max = 0;
String text = "";
for (int i = 0; i < dataLayer.getPreferredRowCount(); i++) {
text = dataLayer.getDataValueByPosition(colPos, i).toString();
Object dataValueByPosition = dataLayer.getDataValueByPosition(colPos, i);
if (dataValueByPosition == null) {
continue;
}
text = dataValueByPosition.toString();
Point size = gc.textExtent(text, SWT.DRAW_MNEMONIC);
int temp = size.x;
if (temp > max) {

View File

@@ -20,7 +20,6 @@ import org.eclipse.gef.commands.Command;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.DialogCellEditor;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
@@ -37,7 +36,8 @@ import org.talend.core.model.process.IElement;
import org.talend.core.model.process.IElementParameter;
import org.talend.core.model.process.INode;
import org.talend.core.model.process.IProcess2;
import org.talend.core.runtime.services.IGenericDBService;
import org.talend.core.runtime.maven.MavenArtifact;
import org.talend.core.runtime.maven.MavenUrlHelper;
import org.talend.core.ui.CoreUIPlugin;
import org.talend.core.ui.process.IGEFProcess;
import org.talend.core.ui.services.IDesignerCoreUIService;
@@ -171,7 +171,7 @@ public class ModuleListCellEditor extends DialogCellEditor {
ILibraryManagerUIService.class);
IConfigModuleDialog dialog = libUiService.getConfigModuleDialog(cellEditorWindow.getShell(), "\"newLine\"".equals(value) ? "" : value);
if (dialog.open() == IDialogConstants.OK_ID) {
String selecteModule = dialog.getModuleName();
String selecteModule = dialog.getMavenURI();
if (selecteModule != null && (value == null || !value.equals(selecteModule))) {
setModuleValue(selecteModule, null, null);
return selecteModule;
@@ -200,6 +200,15 @@ public class ModuleListCellEditor extends DialogCellEditor {
updateComponentsParam.setValue(Boolean.TRUE);
}
}
// cConfig
if (!isNotCConfig) {
if (newValue.startsWith(MavenUrlHelper.MVN_PROTOCOL)) {
MavenArtifact art = MavenUrlHelper.parseMvnUrl(newValue);
newValue = art.getFileName();
}
}
//
executeCommand(new ModelChangeCommand(tableParam, param.getName(), newValue, index));

View File

@@ -91,6 +91,10 @@ public class PluginUtil {
return "org.talend.camel.testcontainer.ui.editor.CamelTestContainerMultiPageEditor".equals(getActiveEditorId()); //$NON-NLS-1$
}
public static boolean isRouteletEditor() {
return "org.talend.repository.routelets.editor.RouteletMultiPageTalendEditor".equals(getActiveEditorId()); //$NON-NLS-1$
}
/**
* DOC yyan Get active editor ID.
*

View File

@@ -20,6 +20,7 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.talend.commons.utils.VersionUtils;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.IESBService;
import org.talend.core.PluginChecker;
import org.talend.core.model.general.Project;
import org.talend.core.model.process.JobInfo;
import org.talend.core.model.properties.Property;
@@ -346,7 +347,9 @@ public class PomIdsHelper {
if (!preferenceManager.exist()
&& StringUtils.isBlank(preferenceStore.getString(MavenConstants.EXCLUDE_DELETED_ITEMS))) {
// for new project, set EXCLUDE_DELETED_ITEMS=true as default
preferenceStore.setValue(MavenConstants.EXCLUDE_DELETED_ITEMS, true);
if (PluginChecker.isTIS()) {
preferenceStore.setValue(MavenConstants.EXCLUDE_DELETED_ITEMS, true);
}
}
preferenceManager.save();
preferenceManagers.put(projectTechName, preferenceManager);

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.talend.libraries.jdbc.postgresql</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -1,7 +0,0 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Postgresql Plug-in
Bundle-SymbolicName: org.talend.libraries.jdbc.postgresql
Bundle-Version: 7.3.1.qualifier
Bundle-Vendor: .Talend SA.
Eclipse-BundleShape: dir

View File

@@ -1 +0,0 @@
jarprocessor.exclude.children=true

View File

@@ -1,5 +0,0 @@
output.. = bin/
bin.includes = META-INF/,\
.,\
lib/postgresql-8.4-703.jdbc4.jar,\
lib/postgresql-9.4-1201.jdbc41.jar

View File

@@ -1,30 +0,0 @@
BSD License
The PostgreSQL JDBC driver is distributed under the BSD license, same as the server. The simplest explanation of the licensing terms is that you can do whatever you want with the product and source code as long as you don't claim you wrote it or sue us. You should give it a read though, it's only half a page.
Copyright (c) 1997-2008, PostgreSQL Global Development Group
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the PostgreSQL Global Development Group nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-PATCH</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.libraries.jdbc.postgresql</artifactId>
<packaging>eclipse-plugin</packaging>
</project>

View File

@@ -16,7 +16,10 @@ Require-Bundle: org.eclipse.core.runtime,
org.talend.commons.ui,
org.talend.core.runtime,
org.talend.librariesmanager,
org.talend.designer.maven
org.talend.designer.maven,
org.apache.commons.io,
org.eclipse.m2e.core,
org.eclipse.m2e.maven.runtime
Bundle-ActivationPolicy: lazy
Export-Package: org.talend.librariesmanager.ui,
org.talend.librariesmanager.ui.dialogs,

View File

@@ -117,11 +117,15 @@ ConfigModuleDialog.platfromBtn=Platform
ConfigModuleDialog.repositoryBtn=Artifact repository(local m2/nexus)
ConfigModuleDialog.installNewBtn=Install a new module
ConfigModuleDialog.findExistByNameBtn=Find by name
ConfigModuleDialog.findExistByURIBtn=Find by maven URI
ConfigModuleDialog.moduleName=Module Name
ConfigModuleDialog.shareInfo=The library can't be shared to remote artifact repository if the repository does not allow redeployment, continue to share ?
ConfigModuleDialog.moduleName.error=Please input a valid file name !
ConfigModuleDialog.jarNotInstalled.error=This jar is not installed in the artifact repository, please install it !
ConfigModuleDialog.searchLocalBtn=Search Local
ConfigModuleDialog.searchRemoteBtn=Search Remote
ConfigModuleDialog.error.missingName=Please input a module name!
ConfigModuleDialog.error.missingModule=Please select a module!
ConfigModuleDialog.search.noModules=No modules found for search of: {0} !
ImportCustomSettingsAction.title=Import custom settings
ImportCustomSettingsAction.warning=Are you sure to overwrite the custom mvn uri settings with the selected file ?

View File

@@ -55,6 +55,7 @@ import org.talend.core.nexus.TalendLibsServerManager;
import org.talend.core.runtime.maven.MavenUrlHelper;
import org.talend.librariesmanager.ui.LibManagerUiPlugin;
import org.talend.librariesmanager.ui.i18n.Messages;
import org.talend.librariesmanager.utils.ConfigModuleHelper;
import org.talend.librariesmanager.utils.ModuleMavenURIUtils;
/**
@@ -399,10 +400,45 @@ public class InstallModuleDialog extends TitleAreaDialog implements ICellEditorD
String result = dialog.open();
if (result != null) {
this.jarPathTxt.setText(result);
try {
setupMavenURIforInstall();
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
private boolean validateInputForInstallPre() {
if (!new File(jarPathTxt.getText()).exists()) {
setMessage(Messages.getString("InstallModuleDialog.error.jarPath"), IMessageProvider.ERROR);
return false;
}
setMessage(Messages.getString("InstallModuleDialog.message"), IMessageProvider.INFORMATION);
return true;
}
private void setupMavenURIforInstall() throws Exception {
if (validateInputForInstallPre()) {
String filePath = jarPathTxt.getText();
String detectUri = ConfigModuleHelper.getDetectURI(filePath);
if (!org.apache.commons.lang3.StringUtils.isEmpty(detectUri)
&& !ConfigModuleHelper.isSameUri(this.defaultURIValue, detectUri)) {
customUriText.setText(detectUri);
useCustomBtn.setSelection(true);
customUriText.setEnabled(true);
layoutWarningComposite(false, defaultUriTxt.getText());
this.detectButton.setEnabled(true);
} else {
useCustomBtn.setSelection(false);
customUriText.setEnabled(false);
customUriText.setText("");
}
}
}
/*
* (non-Javadoc)
*

View File

@@ -0,0 +1,294 @@
// ============================================================================
//
// Copyright (C) 2006-2020 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.librariesmanager.utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.m2e.core.MavenPlugin;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.ILibraryManagerService;
import org.talend.core.model.general.ModuleNeeded;
import org.talend.core.model.general.ModuleNeeded.ELibraryInstallStatus;
import org.talend.core.model.general.ModuleStatusProvider;
import org.talend.core.nexus.ArtifactRepositoryBean;
import org.talend.core.nexus.IRepositoryArtifactHandler;
import org.talend.core.nexus.RepositoryArtifactHandlerManager;
import org.talend.core.nexus.TalendLibsServerManager;
import org.talend.core.runtime.maven.MavenArtifact;
import org.talend.core.runtime.maven.MavenUrlHelper;
import org.talend.librariesmanager.model.ModulesNeededProvider;
import org.talend.librariesmanager.ui.LibManagerUiPlugin;
/*
* Created by bhe on Sep 3, 2020
*/
public class ConfigModuleHelper {
private static final String LOCAL_M2 = MavenPlugin.getMaven().getLocalRepositoryPath();
private ConfigModuleHelper() {
}
public static List<MavenArtifact> searchRemoteArtifacts(String name) throws Exception {
ArtifactRepositoryBean customNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer();
IRepositoryArtifactHandler customerRepHandler = RepositoryArtifactHandlerManager.getRepositoryHandler(customNexusServer);
if (customerRepHandler != null) {
List<MavenArtifact> ret = customerRepHandler.search(name, true);
return ret;
}
return new ArrayList<MavenArtifact>();
}
public static String[] toArray(List<MavenArtifact> artifacts) {
if (artifacts == null || artifacts.isEmpty()) {
return new String[0];
}
List<String> ret = new ArrayList<String>();
for (MavenArtifact art : artifacts) {
ret.add(art.getFileName(false));
}
return ret.toArray(new String[0]);
}
public static List<MavenArtifact> searchLocalArtifacts(String name) throws Exception {
List<MavenArtifact> ret = new ArrayList<MavenArtifact>();
File m2Dir = new File(LOCAL_M2);
if (m2Dir.exists()) {
search(name, m2Dir, ret);
}
return ret;
}
private static void search(String name, File dir, List<MavenArtifact> ret) throws Exception {
File[] fs = dir.listFiles();
for (File f : fs) {
if (f.isDirectory()) {
search(name, f, ret);
} else {
if (f.isFile() && f.getName().endsWith(".jar")
&& StringUtils.containsIgnoreCase(FilenameUtils.getBaseName(f.getName()), name)) {
String path = f.getPath().substring(LOCAL_M2.length() + 1, f.getPath().length());
MavenArtifact art = parse(path);
if (art != null) {
ret.add(art);
}
}
}
}
}
public static MavenArtifact parse(String path) {
MavenArtifact art = new MavenArtifact();
if (path == null || StringUtils.isEmpty(path)) {
return null;
}
String newPath = FilenameUtils.normalize(path, true);
String[] segs = newPath.split("/");
if (segs.length < 4) {
return null;
}
String fname = segs[segs.length - 1];
String v = segs[segs.length - 2];
String a = segs[segs.length - 3];
StringBuffer sb = new StringBuffer();
for (int i = 0; i < segs.length - 3; i++) {
if (sb.length() > 0) {
sb.append(".");
}
sb.append(segs[i]);
}
art.setGroupId(sb.toString());
art.setArtifactId(a);
art.setVersion(v);
art.setType("jar");
String baseName = FilenameUtils.getBaseName(fname);
int endIndex = a.length() + v.length() + 1;
if (baseName.length() > endIndex + 1) {
String classifier = baseName.substring(endIndex + 1, baseName.length());
art.setClassifier(classifier);
}
return art;
}
public static File resolveLocal(String uri) {
ILibraryManagerService libManagerService = (ILibraryManagerService) GlobalServiceRegister.getDefault()
.getService(ILibraryManagerService.class);
String jarPathFromMaven = libManagerService.getJarPathFromMaven(uri);
if (jarPathFromMaven != null) {
File retFile = new File(jarPathFromMaven);
if (retFile.exists()) {
return retFile;
}
}
ModuleStatusProvider.putStatus(uri, ELibraryInstallStatus.NOT_INSTALLED);
return null;
}
public static String getSHA1(File f) {
try (InputStream fi = new FileInputStream(f)) {
return DigestUtils.shaHex(fi);
} catch (Exception e) {
}
return null;
}
public static void install(File jarFile, String mvnUrl, boolean deploy) throws Exception {
LibManagerUiPlugin.getDefault().getLibrariesService().deployLibrary(jarFile.toURL(), mvnUrl, true, deploy);
}
public static boolean canFind(Set<MavenArtifact> artifacts, File jarFile, String mvnUrl) {
if (artifacts == null || artifacts.isEmpty()) {
return false;
}
String jarSha1 = getSHA1(jarFile);
MavenArtifact jarArt = MavenUrlHelper.parseMvnUrl(mvnUrl);
jarArt.setSha1(jarSha1);
return canFind(artifacts, jarArt);
}
public static boolean canFind(Set<MavenArtifact> artifacts, MavenArtifact artifact) {
if (artifacts == null || artifacts.isEmpty()) {
return false;
}
for (MavenArtifact art : artifacts) {
if (StringUtils.equals(art.getGroupId(), artifact.getGroupId())
&& StringUtils.equals(art.getArtifactId(), artifact.getArtifactId())
&& StringUtils.equals(art.getVersion(), artifact.getVersion())
&& StringUtils.equals(art.getClassifier(), artifact.getClassifier())
&& StringUtils.equals(art.getType(), artifact.getType())
&& StringUtils.equals(art.getSha1(), artifact.getSha1())) {
return true;
}
}
return false;
}
public static List<MavenArtifact> searchRemoteArtifacts(String g, String a, String v) throws Exception {
ArtifactRepositoryBean customNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer();
IRepositoryArtifactHandler customerRepHandler = RepositoryArtifactHandlerManager.getRepositoryHandler(customNexusServer);
if (customerRepHandler != null) {
boolean fromSnapshot = false;
if (v != null && v.endsWith(MavenUrlHelper.VERSION_SNAPSHOT)) {
fromSnapshot = true;
}
List<MavenArtifact> ret = customerRepHandler.search(g, a, v, true, fromSnapshot);
if (customNexusServer.getType() == ArtifactRepositoryBean.NexusType.NEXUS_2.name()) {
// resolve sha1
for (MavenArtifact art : ret) {
String sha1 = customerRepHandler.resolveRemoteSha1(art, !fromSnapshot);
if (sha1 != null) {
art.setSha1(sha1);
}
}
}
return ret;
}
return new ArrayList<MavenArtifact>();
}
public static void resolveSha1(MavenArtifact art) throws Exception {
ArtifactRepositoryBean customNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer();
IRepositoryArtifactHandler customerRepHandler = RepositoryArtifactHandlerManager.getRepositoryHandler(customNexusServer);
if ((art.getSha1() == null || art.getSha1().trim().isEmpty()) && customerRepHandler != null
&& customNexusServer.getType().equals(ArtifactRepositoryBean.NexusType.NEXUS_2.name())) {
boolean fromSnapshot = false;
if (art.getVersion() != null && art.getVersion().endsWith(MavenUrlHelper.VERSION_SNAPSHOT)) {
fromSnapshot = true;
}
// resolve sha1
String sha1 = customerRepHandler.resolveRemoteSha1(art, !fromSnapshot);
if (sha1 != null) {
art.setSha1(sha1);
}
}
}
public static String getDetectURI(String jarPath) {
String ext = FilenameUtils.getExtension(jarPath);
if (ext.equalsIgnoreCase("jar")) {
File file = new File(jarPath);
try {
MavenArtifact art = JarDetector.parse(file);
if (art != null) {
return MavenUrlHelper.generateMvnUrl(art);
}
} catch (Exception e) {
}
}
return "";
}
public static String getMavenURI(String jarPath) {
String jarName = FilenameUtils.getName(jarPath);
ModuleNeeded mod = null;
for (ModuleNeeded module : ModulesNeededProvider.getAllManagedModules()) {
if (jarName.equals(module.getModuleName())) {
mod = module;
break;
}
}
if (mod != null) {
return mod.getMavenUri() == null ? "" : mod.getMavenUri();
}
return "";
}
public static String getGeneratedDefaultURI(String jarPath) {
String jarName = FilenameUtils.getName(jarPath);
return MavenUrlHelper.generateMvnUrlForJarName(jarName);
}
public static boolean isSameUri(String defaultUri, String detectUri) {
detectUri = detectUri.substring(MavenUrlHelper.MVN_PROTOCOL.length());
return StringUtils.endsWith(defaultUri, detectUri);
}
public static boolean showRemoteSearch() {
ArtifactRepositoryBean customNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer();
if (customNexusServer != null) {
String repoType = customNexusServer.getType();
if (repoType.equals(ArtifactRepositoryBean.NexusType.NEXUS_2.name())
|| repoType.equals(ArtifactRepositoryBean.NexusType.NEXUS_3.name())
|| repoType.equals(ArtifactRepositoryBean.NexusType.ARTIFACTORY.name())) {
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,100 @@
// ============================================================================
//
// Copyright (C) 2006-2020 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.librariesmanager.utils;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Enumeration;
import java.util.Properties;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.lang3.StringUtils;
import org.talend.core.runtime.maven.MavenArtifact;
import org.talend.core.runtime.maven.MavenConstants;
import org.talend.core.runtime.maven.MavenUrlHelper;
import org.talend.utils.xml.XmlUtils;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
/*
* Created by bhe on Sep 3, 2020
*/
public class JarDetector {
private static final DocumentBuilderFactory docFactory = XmlUtils.getSecureDocumentBuilderFactory(true);
private JarDetector() {
}
public static MavenArtifact parse(File jarFile) throws Exception {
Properties p = new Properties();
Document doc = null;
try (JarFile jar = new JarFile(jarFile)) {
Enumeration<JarEntry> enumEntries = jar.entries();
while (enumEntries.hasMoreElements()) {
JarEntry file = enumEntries.nextElement();
if (!file.isDirectory()) {
String fname = file.getName();
if (StringUtils.contains(fname, "META-INF") && fname.endsWith("pom.xml")) {
try (InputStream fi = jar.getInputStream(file)) {
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Reader reader = new InputStreamReader(fi, "UTF-8");
InputSource is = new InputSource(reader);
is.setEncoding("UTF-8");
doc = docBuilder.parse(is);
}
}
if (StringUtils.contains(fname, "META-INF") && fname.endsWith("pom.properties")) {
try (InputStream fi = jar.getInputStream(file)) {
p.load(fi);
break;
}
}
}
}
}
if (!p.isEmpty()) {
MavenArtifact art = new MavenArtifact();
art.setGroupId(p.getProperty("groupId"));
art.setArtifactId(p.getProperty("artifactId"));
art.setVersion(p.getProperty("version"));
art.setType(MavenConstants.TYPE_JAR);
return art;
}
if (doc != null) {
PomParser pp = new PomParser(doc);
MavenArtifact art = new MavenArtifact();
art.setGroupId(pp.getGroupId());
art.setArtifactId(pp.getArtifactId());
art.setVersion(pp.getVersion());
art.setType(pp.getPackaging());
return art;
}
return null;
}
public static String getMavenURL(MavenArtifact art) {
if (art == null) {
return "";
}
return String.format("mvn:%s/%s/%s/%s", art.getGroupId(), art.getArtifactId(), art.getVersion(), art.getType());
}
}

View File

@@ -16,6 +16,7 @@ import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.TimeoutException;
import org.apache.commons.lang3.StringUtils;
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.PatternMatcherInput;
@@ -145,8 +146,10 @@ public class ModuleMavenURIUtils {
}
public static void copyDefaultMavenURI(String text) {
Clipboard clipBoard = new Clipboard(Display.getCurrent());
TextTransfer textTransfer = TextTransfer.getInstance();
clipBoard.setContents(new Object[] { text }, new Transfer[] { textTransfer });
if (!StringUtils.isEmpty(text)) {
Clipboard clipBoard = new Clipboard(Display.getCurrent());
TextTransfer textTransfer = TextTransfer.getInstance();
clipBoard.setContents(new Object[] { text }, new Transfer[] { textTransfer });
}
}
}

View File

@@ -0,0 +1,110 @@
// ============================================================================
//
// Copyright (C) 2006-2020 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.librariesmanager.utils;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.apache.commons.lang3.StringUtils;
import org.w3c.dom.Document;
/*
* Created by bhe on Mar 8, 2020
*/
public class PomParser {
private static final Logger LOGGER = Logger.getLogger(PomParser.class.getCanonicalName());
private final Document doc;
public PomParser(Document doc) {
this.doc = doc;
}
public String getGroupId() {
String val = "";
if (this.doc != null) {
XPath path = XPathFactory.newInstance().newXPath();
try {
String name = path.evaluate("/project/groupId", this.doc);
if (StringUtils.isEmpty(name)) {
name = path.evaluate("/project/parent/groupId", this.doc);
}
if (!StringUtils.isEmpty(name)) {
val = name;
}
} catch (XPathExpressionException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
}
return val;
}
public String getArtifactId() {
String val = "";
if (this.doc != null) {
XPath path = XPathFactory.newInstance().newXPath();
try {
String name = path.evaluate("/project/artifactId", this.doc);
if (!StringUtils.isEmpty(name)) {
val = name;
}
} catch (XPathExpressionException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
}
return val;
}
public String getVersion() {
String val = "";
if (this.doc != null) {
XPath path = XPathFactory.newInstance().newXPath();
try {
String name = path.evaluate("/project/version", this.doc);
if (StringUtils.isEmpty(name)) {
name = path.evaluate("/project/parent/version", this.doc);
}
if (!StringUtils.isEmpty(name)) {
val = name;
}
} catch (XPathExpressionException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
}
return val;
}
public String getPackaging() {
String val = "";
if (this.doc != null) {
XPath path = XPathFactory.newInstance().newXPath();
try {
String name = path.evaluate("/project/packaging", this.doc);
if (!StringUtils.isEmpty(name)) {
val = name;
}
} catch (XPathExpressionException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
}
if (val.isEmpty() || val.equals("bundle")) {
val = "jar";
}
return val;
}
}

View File

@@ -8,6 +8,4 @@ bin.includes = META-INF/,\
plugin.properties,\
model/,\
templates/,\
distribution/license.json,\
lib/crypto-utils.jar,\
lib/slf4j-api-1.7.25.jar
distribution/license.json

View File

@@ -31,6 +31,23 @@
type="librariesindex"
class="org.talend.librariesmanager.emf.librariesindex.util.LibrariesindexResourceFactoryImpl"/>
</extension>
<extension
point="org.talend.core.runtime.librariesNeeded">
<libraryNeeded
context="plugin:org.talend.librariesmanager"
id="slf4j-api-1.7.25.jar"
mvn_uri="mvn:org.slf4j/slf4j-api/1.7.25"
name="slf4j-api-1.7.25.jar"
required="true">
</libraryNeeded>
<libraryNeeded
context="plugin:org.talend.librariesmanager"
id="crypto-utils-0.31.10.jar"
mvn_uri="mvn:org.talend.daikon/crypto-utils/0.31.10"
name="crypto-utils-0.31.10.jar"
required="true">
</libraryNeeded>
</extension>
<extension
point="org.talend.core.systemRoutineLibrary">
<systemRoutine
@@ -42,7 +59,7 @@
<systemRoutine
name="PasswordEncryptUtil">
<library
name="crypto-utils.jar">
name="crypto-utils-0.31.10.jar">
</library>
</systemRoutine>
</extension>

View File

@@ -41,6 +41,7 @@ public class LocaleProvider {
}
//though not thread safe here, but we syn in the client side, so ok
public static Locale getLocale(String languageOrCountyCode) {
if (cache == null) {
initCache();
@@ -72,7 +73,11 @@ public class LocaleProvider {
key = language;
}
if (key != null) {
cache.put(key.toLowerCase(), locale);
String k = key.toLowerCase();
Locale old = cache.put(k, locale);
if(old != null && old.getCountry() !=null && old.getCountry().equalsIgnoreCase(old.getLanguage())) {
cache.put(k, old);
}
}
}
}

View File

@@ -72,9 +72,6 @@ public class ResumeUtil {
if (sharedWriter == null) {
this.csvWriter = new SimpleCsvWriter(new FileWriter(logFileName, createNewFile));
// shared
sharedWriterMap.put(this.root_pid, this.csvWriter);
// output the header part
if (file.length() == 0) {
if (genDynamicPart) {
@@ -100,7 +97,12 @@ public class ResumeUtil {
csvWriter.write("dynamicData");// dynamicData
csvWriter.endRecord();
csvWriter.flush();
csvWriter.close();
// To avoid use File.delete() as it cannot make sure file being deleted.
this.csvWriter = new SimpleCsvWriter(new FileWriter(logFileName, true));
}
// shared
sharedWriterMap.put(this.root_pid, this.csvWriter);
} else {
csvWriter = sharedWriter;
}

View File

@@ -220,9 +220,16 @@ public class ModulesNeededProvider {
Set<ModuleNeeded> modulesNeeded = getModulesNeeded();
for (ModuleNeeded moduleNeeded : modulesNeeded) {
if (id.equals(moduleNeeded.getId())) {
result = moduleNeeded;
break;
if (id.startsWith(MavenUrlHelper.MVN_PROTOCOL)) {
if (id.equals(moduleNeeded.getMavenUri())) {
result = moduleNeeded;
break;
}
} else {
if (id.equals(moduleNeeded.getId())) {
result = moduleNeeded;
break;
}
}
}

View File

@@ -912,7 +912,13 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
fileToDeploy = null;
found = false;
}
if (!found) {
boolean isCIMode = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService runProcessService = GlobalServiceRegister.getDefault()
.getService(IRunProcessService.class);
isCIMode = runProcessService.isCIMode();
}
if (!found && !isCIMode) {
ExceptionHandler.log("missing jar:" + module.getModuleName());
}
if (fileToDeploy != null) {

View File

@@ -54,6 +54,7 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
private String SEARCH_SERVICE = "api/search/gavc?"; //$NON-NLS-1$
private static final String SEARCH_NAME = "api/search/artifact?";
/*
* (non-Javadoc)
*
@@ -268,6 +269,100 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
return resultList;
}
protected List<MavenArtifact> doSearch(String query, String apiPath, boolean fromRelease, boolean fromSnapshot)
throws Exception {
String q = query;
if (q == null || q.trim().isEmpty()) {
q = "";
}
String serverUrl = serverBean.getServer();
if (!serverUrl.endsWith("/")) { //$NON-NLS-1$
serverUrl = serverUrl + "/"; //$NON-NLS-1$
}
String searchUrl = serverUrl + apiPath;
String repositoryId = ""; //$NON-NLS-1$
if (fromRelease) {
repositoryId = serverBean.getRepositoryId();
}
if (fromSnapshot) {
if ("".equals(repositoryId)) { //$NON-NLS-1$
repositoryId = serverBean.getSnapshotRepId();
} else {
repositoryId = repositoryId + "," + serverBean.getSnapshotRepId(); //$NON-NLS-1$
}
}
if (!"".equals(repositoryId)) { //$NON-NLS-1$
if (!q.isEmpty()) {
q += "&";
}
q += "repos=" + repositoryId;//$NON-NLS-1$
}
searchUrl = searchUrl + q;
Request request = Request.Get(searchUrl);
String userPass = serverBean.getUserName() + ":" + serverBean.getPassword(); //$NON-NLS-1$
String basicAuth = "Basic " + new String(new Base64().encode(userPass.getBytes())); //$NON-NLS-1$
Header authority = new BasicHeader("Authorization", basicAuth); //$NON-NLS-1$
request.addHeader(authority);
Header resultDetailHeader = new BasicHeader("X-Result-Detail", "info"); //$NON-NLS-1$ //$NON-NLS-2$
request.addHeader(resultDetailHeader);
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
HttpResponse response = request.execute().returnResponse();
String content = EntityUtils.toString(response.getEntity());
if (content.isEmpty()) {
return resultList;
}
JSONObject responseObject = JSONObject.fromObject(content);
String resultStr = responseObject.getString("results"); //$NON-NLS-1$
JSONArray resultArray = null;
try {
resultArray = JSONArray.fromObject(resultStr);
} catch (Exception e) {
throw new Exception(resultStr);
}
if (resultArray != null) {
for (int i = 0; i < resultArray.size(); i++) {
JSONObject jsonObject = resultArray.getJSONObject(i);
String lastUpdated = jsonObject.getString("lastUpdated"); //$NON-NLS-1$
String artifactPath = jsonObject.getString("path"); //$NON-NLS-1$
String[] split = artifactPath.split("/"); //$NON-NLS-1$
if (split.length > 4) {
String fileName = split[split.length - 1];
if (!fileName.endsWith("pom")) { //$NON-NLS-1$
String type = null;
int dotIndex = fileName.lastIndexOf('.');
if (dotIndex > 0) {
type = fileName.substring(dotIndex + 1);
}
if (type != null) {
MavenArtifact artifact = new MavenArtifact();
String g = ""; //$NON-NLS-1$
String a = split[split.length - 3];
String v = split[split.length - 2];
for (int j = 1; j < split.length - 3; j++) {
if ("".equals(g)) { //$NON-NLS-1$
g = split[j];
} else {
g = g + "." + split[j]; //$NON-NLS-1$
}
}
artifact.setGroupId(g);
artifact.setArtifactId(a);
artifact.setVersion(v);
artifact.setType(type);
artifact.setLastUpdated(lastUpdated);
fillChecksumData(jsonObject, artifact);
resultList.add(artifact);
}
}
}
}
}
return resultList;
}
@Override
public File resolve(MavenArtifact ma) throws Exception {
boolean isRelease = true;
@@ -386,4 +481,9 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
return rc;
}
public List<MavenArtifact> search(String name, boolean fromSnapshot) throws Exception {
String query = "name=" + name;
return doSearch(query, SEARCH_NAME, true, fromSnapshot);
}
}

View File

@@ -185,4 +185,17 @@ public class Nexus2RepositoryHandler extends AbstractArtifactRepositoryHandler {
artifact.getArtifactId(), artifact.getVersion(), artifact.getType());
}
public List<MavenArtifact> search(String name, boolean fromSnapshot) throws Exception {
List<MavenArtifact> results = new ArrayList<MavenArtifact>();
if (serverBean.getRepositoryId() != null) {
results.addAll(NexusServerUtils.search(serverBean.getServer(), serverBean.getUserName(), serverBean.getPassword(),
serverBean.getRepositoryId(), name));
}
if (fromSnapshot && serverBean.getSnapshotRepId() != null) {
results.addAll(NexusServerUtils.search(serverBean.getServer(), serverBean.getUserName(), serverBean.getPassword(),
serverBean.getSnapshotRepId(), name));
}
return results;
}
}

View File

@@ -59,8 +59,6 @@ public class Nexus3RepositoryHandler extends AbstractArtifactRepositoryHandler {
private static final ConcurrentHashMap<ArtifactRepositoryBean, INexus3SearchHandler> LAST_HANDLER_MAP = new ConcurrentHashMap<ArtifactRepositoryBean, INexus3SearchHandler>();
private static List<INexus3SearchHandler> queryHandlerList = new ArrayList<INexus3SearchHandler>();
@Override
public IRepositoryArtifactHandler clone() {
return new Nexus3RepositoryHandler();
@@ -160,7 +158,7 @@ public class Nexus3RepositoryHandler extends AbstractArtifactRepositoryHandler {
try {
result = currentQueryHandler.search(repositoryId, groupIdToSearch, artifactId, versionToSearch);
} catch (Exception ex) {
for (int i = 0; i < queryHandlerList.size(); i++) {// Try to other version
for (int i = 0; i < 3; i++) {// Try to other version
INexus3SearchHandler handler = createQueryHandler(i);
if (handler != currentQueryHandler) {
try {
@@ -287,4 +285,42 @@ public class Nexus3RepositoryHandler extends AbstractArtifactRepositoryHandler {
}
}
public List<MavenArtifact> search(String name, boolean fromSnapshot) throws Exception {
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
resultList.addAll(doSearch(serverBean.getRepositoryId(), name));
if (fromSnapshot) {
resultList.addAll(doSearch(serverBean.getSnapshotRepId(), name));
}
return resultList;
}
private List<MavenArtifact> doSearch(String repositoryId, String name) throws Exception {
INexus3SearchHandler currentQueryHandler = currentQueryHandlerCopy.get();
if (currentQueryHandler == null) {
currentQueryHandler = createQueryHandler(0);
}
List<MavenArtifact> result = new ArrayList<MavenArtifact>();
try {
result = currentQueryHandler.search(repositoryId, name);
} catch (Exception ex) {
for (int i = 0; i < 3; i++) {// Try to other version
INexus3SearchHandler handler = createQueryHandler(i);
if (handler != currentQueryHandler) {
try {
result = handler.search(repositoryId, name);
currentQueryHandler = handler;
LOGGER.info(
"Switch to new search handler,the handler version is:" + currentQueryHandler.getHandlerVersion());
break;
} catch (Exception e) {
LOGGER.info("Try to switch search handler failed" + e.getMessage());
}
}
}
}
currentQueryHandlerCopy.set(currentQueryHandler);
return result;
}
}

View File

@@ -242,4 +242,20 @@ public abstract class AbsNexus3SearchHandler implements INexus3SearchHandler {
}
return socketTimeout;
}
public List<MavenArtifact> search(String repositoryId, String name) throws Exception {
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
String searchUrl = getSearchUrl();
String continuationToken = null;
while (true) {
String query = getQueryParameter(repositoryId, null, null, null, continuationToken);
query += "&name=*" + name + "*";
String content = doRequest(searchUrl + query);
continuationToken = parseResult(content, resultList);
if (continuationToken == null) {
break;
}
}
return resultList;
}
}

View File

@@ -23,4 +23,5 @@ public interface INexus3SearchHandler {
public String getHandlerVersion();
public List<MavenArtifact> search(String repositoryId, String name) throws Exception;
}

View File

@@ -12,13 +12,17 @@
// ============================================================================
package org.talend.metadata.managment.ui.wizard.context;
import java.util.ArrayList;
import java.util.List;
import org.apache.avro.Schema;
import org.talend.commons.runtime.model.components.IComponentConstants;
import org.talend.core.model.general.ModuleNeeded;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.model.utils.ContextParameterUtils;
import org.talend.core.runtime.evaluator.AbstractPropertyValueEvaluator;
import org.talend.core.runtime.maven.MavenUrlHelper;
import org.talend.core.utils.TalendQuoteUtils;
import org.talend.daikon.properties.property.Property;
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
import org.talend.metadata.managment.ui.utils.ConnectionContextHelper;
@@ -61,8 +65,37 @@ public class MetadataContextPropertyValueEvaluator extends AbstractPropertyValue
storedValue = ContextParameterUtils.getOriginalValue(contextType, String.valueOf(storedValue));
}
}
if (property.getName() != null && property.getName().equals("drivers")) {
// check driver jar path
if (storedValue instanceof List) {
List<String> vals = (List<String>) storedValue;
List<String> newVals = new ArrayList<String>();
for (String val : vals) {
String uri = getUri(val);
newVals.add(uri);
}
storedValue = newVals;
} else {
String val = String.valueOf(storedValue);
storedValue = getUri(val);
}
}
return getTypedValue(property, currentStoredValue, storedValue);
}
private static String getUri(String jarName) {
if (jarName != null) {
jarName = TalendQuoteUtils.removeQuotes(jarName);
if (!jarName.startsWith(MavenUrlHelper.MVN_PROTOCOL)) {
ModuleNeeded mod = new ModuleNeeded(null, jarName, null, true);
return mod.getMavenUri();
}
}
return jarName;
}
}

View File

@@ -36,6 +36,14 @@
</extension>
<extension
point="org.talend.core.runtime.librariesNeeded">
<libraryNeeded
context="PostgresPlus wizard"
language="java"
message="wizard for PostgresPlus"
mvn_uri="mvn:org.postgresql/postgresql/42.2.14"
name="postgresql-42.2.14.jar"
required="true">
</libraryNeeded>
<libraryNeeded
context="plugin:org.talend.metadata.managment"
language="java"

View File

@@ -67,6 +67,7 @@ import org.talend.core.database.conn.ConnParameterKeys;
import org.talend.core.database.conn.HiveConfKeysForTalend;
import org.talend.core.database.conn.version.EDatabaseVersion4Drivers;
import org.talend.core.language.ECodeLanguage;
import org.talend.core.model.general.ModuleNeeded;
import org.talend.core.model.general.Project;
import org.talend.core.model.metadata.IMetadataConnection;
import org.talend.core.model.metadata.builder.ConvertionHelper;
@@ -76,6 +77,8 @@ import org.talend.core.model.metadata.connection.hive.HiveModeInfo;
import org.talend.core.model.metadata.types.JavaTypesManager;
import org.talend.core.prefs.SSLPreferenceConstants;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.core.runtime.maven.MavenArtifact;
import org.talend.core.runtime.maven.MavenUrlHelper;
import org.talend.core.utils.TalendQuoteUtils;
import org.talend.designer.core.IDesignerCoreService;
import org.talend.metadata.managment.connection.manager.HiveConnectionManager;
@@ -1024,6 +1027,7 @@ public class ExtractMetaDataUtils {
}
}
librairesManagerService.retrieve(jarsToRetreive, getJavaLibPath(), new NullProgressMonitor());
} else {
Path path = new Path(driverJarPathArg);
File driverFile = new File(driverJarPathArg);
@@ -1045,30 +1049,39 @@ public class ExtractMetaDataUtils {
jarPathList.add(driverJarPathArg);
}
}
}else if(driverJarPathArg.contains("/")){
} else if (driverJarPathArg.contains("/")) {
if (driverJarPathArg.contains(";")) {
String jars[] = driverJarPathArg.split(";");
for (String jar : jars) {
String jarName = librairesManagerService.getJarNameFromMavenuri(jar);
// TDQ-16842 msjian:sometimes for the import jdbc connection, the jarName is null
if (jarName == null) {
jarName = jar.split("/")[1] + ".jar";
if (jar.startsWith(MavenUrlHelper.MVN_PROTOCOL)) {
setDriverPath(librairesManagerService, jarPathList, jar);
} else {
String jarName = librairesManagerService.getJarNameFromMavenuri(jar);
// TDQ-16842 msjian:sometimes for the import jdbc connection, the jarName is null
if (jarName == null) {
jarName = jar.split("/")[1] + ".jar";
}
// TDQ-16842~
if (!new File(getJavaLibPath() + jarName).exists()) {
librairesManagerService.retrieve(jarName, getJavaLibPath(), new NullProgressMonitor());
}
jarPathList.add(getJavaLibPath() + jarName);
}
}
} else {
if (driverJarPathArg.startsWith(MavenUrlHelper.MVN_PROTOCOL)) {
setDriverPath(librairesManagerService, jarPathList, driverJarPathArg);
} else {
String jarName = librairesManagerService.getJarNameFromMavenuri(driverJarPathArg);
if (jarName == null) {
jarName = driverJarPathArg.split("/")[1] + ".jar";
}
// TDQ-16842~
if (!new File(getJavaLibPath() + jarName).exists()) {
librairesManagerService.retrieve(jarName, getJavaLibPath(), new NullProgressMonitor());
}
jarPathList.add(getJavaLibPath() + jarName);
}
}else{
String jarName = librairesManagerService.getJarNameFromMavenuri(driverJarPathArg);
if (jarName == null) {
jarName = driverJarPathArg.split("/")[1] + ".jar";
}
if (!new File(getJavaLibPath() + jarName).exists()) {
librairesManagerService.retrieve(jarName, getJavaLibPath(), new NullProgressMonitor());
}
jarPathList.add(getJavaLibPath() + jarName);
}
} else {
if (driverJarPathArg.contains(";")) {
@@ -1205,6 +1218,20 @@ public class ExtractMetaDataUtils {
return conList;
}
private void setDriverPath(ILibraryManagerService librairesManagerService, List<String> jarPathList, String mvnURI)
throws Exception {
if (mvnURI != null) {
MavenArtifact art = MavenUrlHelper.parseMvnUrl(mvnURI);
ModuleNeeded testModule = new ModuleNeeded("", art.getFileName(), "", true);
testModule.setMavenUri(mvnURI);
boolean retrived = librairesManagerService.retrieve(testModule, getJavaLibPath(), true, new NullProgressMonitor());
if (retrived) {
jarPathList.add(getJavaLibPath() + art.getFileName());
}
}
}
/**
* DOC PLV Comment method "setDriverCache".
*

View File

@@ -40,8 +40,8 @@ import org.eclipse.ui.PlatformUI;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
import org.talend.commons.exception.BusinessException;
import org.talend.commons.runtime.helper.LocalComponentInstallHelper;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.runtime.helper.LocalComponentInstallHelper;
import org.talend.commons.runtime.helper.PatchComponentHelper;
import org.talend.commons.runtime.service.ComponentsInstallComponent;
import org.talend.commons.runtime.service.PatchComponent;
@@ -57,6 +57,7 @@ import org.talend.core.model.migration.IMigrationToolService;
import org.talend.core.model.utils.TalendPropertiesUtil;
import org.talend.core.repository.CoreRepositoryPlugin;
import org.talend.core.runtime.services.IMavenUIService;
import org.talend.core.runtime.util.SharedStudioUtils;
import org.talend.core.services.ICoreTisService;
import org.talend.core.ui.branding.IBrandingService;
import org.talend.core.ui.workspace.ChooseWorkspaceData;
@@ -94,7 +95,7 @@ public class Application implements IApplication {
@SuppressWarnings("restriction")
@Override
public Object start(IApplicationContext context) throws Exception {
if (Boolean.getBoolean(EclipseCommandLine.PROP_TALEND_BUNDLES_DO_CLEAN)) {
if (SharedStudioUtils.installedPatch() || Boolean.getBoolean(EclipseCommandLine.PROP_TALEND_BUNDLES_DO_CLEAN)) {
System.setProperty(EclipseCommandLine.PROP_TALEND_BUNDLES_DO_CLEAN, Boolean.FALSE.toString());
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(EclipseCommandLine.CLEAN, null, false);
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(EclipseCommandLine.ARG_TALEND_BUNDLES_CLEANED,

View File

@@ -7,3 +7,12 @@ LocalRepositoryFactory.logRetrievingFiles=Retrieving {0} files in {1} sec
LocalRepositoryFactory.CannotLoadProperty=The Repository local provider was unable to load
LocalRepositoryFactory.UserLoginCannotBeNull=User login cannot be null
LocalRepositoryFactory.Property_File_Broken=The property file {0} is broken.
LocalRepositoryFactory.logonDenyMsg=Product version is out of date.\nPlease install [{0}] first!
LocalRepositoryFactory.productionLower01=The Studio and project versions should match. \nYou need to install Studio [{0}] to be able to open the project.
LocalRepositoryFactory.productionLower02=The Studio and project versions should match. \nYou need to install Studio patch [{0}] to be able to open the project.
LocalRepositoryFactory.productionNewer01=You are about to upgrade to [{1}].\nOnce this new version is applied, you will not be able to open the project in a lower version of Studio.\nMigrate your project anyway?
LocalRepositoryFactory.productionNewer02=You are about to upgrade to [{1}].\nOnce this new version is applied, you will not be able to open the project in a lower version of Studio.\nMigrate your project anyway? \nNote that the current version used on the project is [{0}].
LocalRepositoryFactory.logonWarningTitle=Login information

View File

@@ -90,6 +90,7 @@ import org.talend.commons.utils.data.container.RootContainer;
import org.talend.commons.utils.io.FilesUtils;
import org.talend.commons.utils.workbench.resources.ResourceUtils;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.PluginChecker;
import org.talend.core.context.RepositoryContext;
import org.talend.core.model.context.link.ContextLinkService;
import org.talend.core.model.general.Project;
@@ -168,9 +169,13 @@ import org.talend.core.repository.utils.RoutineUtils;
import org.talend.core.repository.utils.TDQServiceRegister;
import org.talend.core.repository.utils.URIHelper;
import org.talend.core.repository.utils.XmiResourceManager;
import org.talend.core.runtime.constants.UpdateConstants;
import org.talend.core.runtime.maven.MavenConstants;
import org.talend.core.runtime.projectsetting.ProjectPreferenceManager;
import org.talend.core.ui.IInstalledPatchService;
import org.talend.core.ui.branding.IBrandingService;
import org.talend.core.utils.DialogUtils;
import org.talend.core.utils.ELoginInfoCase;
import org.talend.cwm.helper.ConnectionHelper;
import org.talend.cwm.helper.ResourceHelper;
import org.talend.cwm.helper.SubItemHelper;
@@ -3346,9 +3351,71 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
if (!version.equals(project.getEmfProject().getProductVersion())) {
updatePreferenceProjectVersion(project);
}
Project localProject = getRepositoryContext().getProject();
checkProjectVersion(localProject);
}
}
protected void checkProjectVersion(Project localProject) throws PersistenceException {
ProjectPreferenceManager prefManager = new ProjectPreferenceManager(localProject, PluginChecker.CORE_TIS_PLUGIN_ID,
false);
String remoteLastPatchName = prefManager.getValue(UpdateConstants.KEY_PREF_LAST_PATCH);
String toOpenProjectVersion;
if (StringUtils.isEmpty(remoteLastPatchName)) {
if (localProject.getEmfProject().getProductVersion() == null) {
return;
}
toOpenProjectVersion = VersionUtils
.getProductVersionWithoutBranding(localProject.getEmfProject().getProductVersion());
} else {
toOpenProjectVersion = remoteLastPatchName;
String simplifiedPatchName = VersionUtils.getSimplifiedPatchName(remoteLastPatchName);
if (StringUtils.isNotEmpty(simplifiedPatchName)) {
toOpenProjectVersion = simplifiedPatchName;
}
}
String productVersion = VersionUtils.getInternalVersion();
String productLastestPatchVersion = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IInstalledPatchService.class)) {
IInstalledPatchService pachService = (IInstalledPatchService) GlobalServiceRegister.getDefault()
.getService(IInstalledPatchService.class);
if (pachService != null) {
productLastestPatchVersion = pachService.getLatestInstalledVersion(true);
}
}
if (StringUtils.isNotEmpty(productLastestPatchVersion)) {
productVersion = productLastestPatchVersion;
}
if (VersionUtils.isInvalidProductVersion(localProject.getEmfProject().getProductVersion())) {
String[] contents;
if (StringUtils.isEmpty(remoteLastPatchName)) {
contents = new String[] {
Messages.getString("LocalRepositoryFactory.productionLower01", toOpenProjectVersion, productVersion) };
} else {
contents = new String[] {
Messages.getString("LocalRepositoryFactory.productionLower02", toOpenProjectVersion, productVersion) };
}
ELoginInfoCase.STUDIO_LOWER_THAN_PROJECT.setContents(contents);
DialogUtils.setWarningInfo(ELoginInfoCase.STUDIO_LOWER_THAN_PROJECT);
}
if (VersionUtils.productVersionIsNewer(localProject.getEmfProject().getProductVersion())) {
String[] contents;
if (StringUtils.isEmpty(remoteLastPatchName)) {
contents = new String[] {
Messages.getString("LocalRepositoryFactory.productionNewer01", toOpenProjectVersion, productVersion) };
} else {
contents = new String[] {
Messages.getString("LocalRepositoryFactory.productionNewer02", toOpenProjectVersion, productVersion) };
}
ELoginInfoCase.STUDIO_HIGHER_THAN_PROJECT.setContents(contents);
DialogUtils.setWarningInfo(ELoginInfoCase.STUDIO_HIGHER_THAN_PROJECT);// $NON-NLS-1$
}
DialogUtils.syncOpenWarningDialog(Messages.getString("LocalRepositoryFactory.logonWarningTitle"));//$NON-NLS-1$
}
protected void updatePreferenceProjectVersion(Project project) {
String oldProductVersion = project.getEmfProject().getProductVersion();
if (StringUtils.isNotBlank(oldProductVersion)) {

View File

@@ -5736,7 +5736,8 @@ public class DatabaseForm extends AbstractForm {
.getService(ILibraryManagerUIService.class);
IConfigModuleDialog dialog = libUiService.getConfigModuleDialog(getShell(), null);
if (dialog.open() == IDialogConstants.OK_ID) {
String selecteModule = dialog.getModuleName();
// TOS_DQ only
String selecteModule = dialog.getMavenURI();
if (selecteModule != null && !asList.contains(selecteModule)) {
asList.add(selecteModule);
}

View File

@@ -31,7 +31,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui.forms,
org.talend.core.repository,
org.talend.core,
org.talend.utils
org.talend.utils,
org.talend.libraries.jackson
Bundle-ActivationPolicy: lazy
Service-Component: OSGI-INF/components_install.xml
Export-Package: org.talend.updates.runtime,

View File

@@ -25,6 +25,8 @@ public interface ITaCoKitCarFeature extends ExtraFeature {
File getCarFile(IProgressMonitor progress) throws Exception;
void setAutoReloadAfterInstalled(boolean autoReload);
void setDeployCommand(boolean isDeployCommand);
boolean isAutoReloadAfterInstalled();

View File

@@ -38,6 +38,8 @@ public interface ITaCoKitUpdateService extends IService {
ICarInstallationResult installCars(Collection<File> files, boolean share, IProgressMonitor monitor) throws Exception;
ICarInstallationResult deployCars(Collection<File> files, boolean share, IProgressMonitor monitor) throws Exception;
ICarInstallationResult installCarFeatures(Collection<ITaCoKitCarFeature> features, boolean share, IProgressMonitor monitor)
throws Exception;

View File

@@ -0,0 +1,202 @@
// ============================================================================
//
// 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.updates.runtime.service;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.eclipse.core.runtime.Platform;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.utils.resource.FileExtensions;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.runtime.maven.MavenArtifact;
import org.talend.core.ui.IInstalledPatchService;
import org.talend.updates.runtime.utils.PathUtils;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
public class SharedStudioPatchInfoProvider {
private static final String INSTALLED_PATCH_RECORD_FILE = "installed_patch.json";
private static final String PATCH_TYPE_STUDIO = "studio";
private static final String PATCH_TYPE_CAR = "car";
private File dataFile = null;
private InstalledPatchInfo installedPatchInfo;
private static SharedStudioPatchInfoProvider instance;
private SharedStudioPatchInfoProvider() {
File configFolder = new File(Platform.getConfigurationLocation().getURL().getFile());
dataFile = new File(configFolder, INSTALLED_PATCH_RECORD_FILE);
loadData();
}
public static SharedStudioPatchInfoProvider getInstance() {
if (instance == null) {
synchronized (SharedStudioPatchInfoProvider.class) {
if (instance == null) {
instance = new SharedStudioPatchInfoProvider();
}
}
}
return instance;
}
public boolean isInstalled(String patchName, String patchType) {
for (InstalledPatch patchInfo : installedPatchInfo.getInstalledPatchList()) {
if (StringUtils.equals(patchName, patchInfo.getFileName()) && StringUtils.equals(patchType, patchInfo.getType())) {
return true;
}
}
return false;
}
public void installedStudioPatch(String patchName) {
installedPatch(patchName, PATCH_TYPE_STUDIO);
}
public void installedCarPatch(String patchName) {
installedPatch(patchName, PATCH_TYPE_CAR);
}
private void installedPatch(String patchName, String patchType) {
if (!isInstalled(patchName, patchType)) {
InstalledPatch patch = new InstalledPatch();
patch.setFileName(patchName);
patch.setType(patchType);
installedPatchInfo.getInstalledPatchList().add(patch);
saveData();
}
}
public File getNeedInstallStudioPatchFiles() {
File patchFolder = PathUtils.getPatchesFolder();
String patchName = getStudioInstalledLatestPatch();
if (patchFolder.exists() && patchFolder.isDirectory() && patchName != null) {
for (File file : patchFolder.listFiles()) {
if (file.getName().startsWith(patchName) && file.getName().endsWith(FileExtensions.ZIP_FILE_SUFFIX)
&& !isInstalled(file.getName(), PATCH_TYPE_STUDIO)) {
return file;
}
}
}
return null;
}
public List<File> getNeedInstallCarFiles() {
List<File> files = new ArrayList<File>();
File patchFolder = PathUtils.getComponentsInstalledFolder();
if (patchFolder.exists() && patchFolder.isDirectory()) {
for (File file : patchFolder.listFiles()) {
if (file.getName().endsWith(FileExtensions.CAR_EXTENSION) && !isInstalled(file.getName(), PATCH_TYPE_CAR)) {
files.add(file);
}
}
}
return files;
}
private String getStudioInstalledLatestPatch() {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IInstalledPatchService.class)) {
IInstalledPatchService installedPatchService = GlobalServiceRegister.getDefault()
.getService(IInstalledPatchService.class);
MavenArtifact artifact = installedPatchService.getLastIntalledP2Patch();
if (artifact != null) {
return artifact.getArtifactId();
}
}
return null;
}
private void loadData() {
TypeReference<InstalledPatchInfo> typeReference = new TypeReference<InstalledPatchInfo>() {
// no need to overwrite
};
if (dataFile.exists()) {
try {
installedPatchInfo = new ObjectMapper().readValue(dataFile, typeReference);
} catch (IOException e) {
ExceptionHandler.process(e);
}
}
if (installedPatchInfo == null) {
installedPatchInfo = new InstalledPatchInfo();
}
}
private synchronized void saveData() {
ObjectMapper objectMapper = new ObjectMapper();
try {
if (!dataFile.exists()) {
dataFile.createNewFile();
}
objectMapper.writerWithDefaultPrettyPrinter().writeValue(dataFile, installedPatchInfo);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
class InstalledPatchInfo {
@JsonProperty("installedPatch")
private List<InstalledPatch> installedPatchList = new ArrayList<InstalledPatch>();
public List<InstalledPatch> getInstalledPatchList() {
return installedPatchList;
}
public void setInstalledPatchList(List<InstalledPatch> installedPatchList) {
this.installedPatchList = installedPatchList;
}
}
class InstalledPatch {
@JsonInclude(Include.NON_DEFAULT)
@JsonProperty("fileName")
private String fileName;
@JsonInclude(Include.NON_DEFAULT)
@JsonProperty("type")
private String type;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}

View File

@@ -14,13 +14,17 @@ package org.talend.updates.runtime.service;
import java.io.File;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.codehaus.plexus.util.FileUtils;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.talend.commons.utils.resource.FileExtensions;
import org.talend.core.nexus.ArtifactRepositoryBean;
import org.talend.core.runtime.util.SharedStudioUtils;
import org.talend.core.service.IUpdateService;
import org.talend.updates.runtime.engine.component.InstallComponentMessages;
import org.talend.updates.runtime.engine.factory.ComponentsLocalNexusInstallFactory;
@@ -30,12 +34,12 @@ import org.talend.updates.runtime.model.FeatureCategory;
import org.talend.updates.runtime.nexus.component.ComponentIndexManager;
import org.talend.updates.runtime.nexus.component.NexusServerManager;
import org.talend.updates.runtime.utils.PathUtils;
import org.talend.updates.runtime.utils.UpdateTools;
import org.talend.utils.io.FilesUtils;
public class UpdateService implements IUpdateService {
private static Logger log = Logger.getLogger(UpdateService.class);
@Override
public boolean checkComponentNexusUpdate() {
IProgressMonitor monitor = new NullProgressMonitor();
@@ -99,4 +103,45 @@ public class UpdateService implements IUpdateService {
}
}
@Override
public boolean syncSharedStudioLibraryInPatch(IProgressMonitor monitor) throws Exception {
boolean isNeedRestart = false;
if (SharedStudioUtils.isSharedStudioMode()) {
File studioPatch = SharedStudioPatchInfoProvider.getInstance().getNeedInstallStudioPatchFiles();
if (studioPatch != null && studioPatch.getName().endsWith(FileExtensions.ZIP_FILE_SUFFIX)) {
File tmpInstallFolder = File.createTempFile("StudioPatchInstaller", "");
if (tmpInstallFolder.exists()) {
tmpInstallFolder.delete();
}
tmpInstallFolder.mkdirs();
FilesUtils.unzip(studioPatch.getAbsolutePath(), tmpInstallFolder.getAbsolutePath());
UpdateTools.syncLibraries(tmpInstallFolder);
UpdateTools.syncM2Repository(tmpInstallFolder);
File carFolder = new File(tmpInstallFolder, ITaCoKitUpdateService.FOLDER_CAR);
UpdateTools.deployCars(monitor, carFolder, false);
SharedStudioPatchInfoProvider.getInstance().installedStudioPatch(studioPatch.getName());
tmpInstallFolder.delete();
isNeedRestart = true;
}
List<File> carFiles = SharedStudioPatchInfoProvider.getInstance().getNeedInstallCarFiles();
if (carFiles.size() > 0) {
File tmpInstallFolder = File.createTempFile("CarPatchInstaller", "");
if (tmpInstallFolder.exists()) {
tmpInstallFolder.delete();
}
tmpInstallFolder.mkdirs();
for (File carFile : carFiles) {
FileUtils.copyFile(carFile, new File (tmpInstallFolder, carFile.getName()));
SharedStudioPatchInfoProvider.getInstance().installedCarPatch(carFile.getName());
}
UpdateTools.deployCars(monitor, tmpInstallFolder, false);
tmpInstallFolder.delete();
}
if (isNeedRestart) {
SharedStudioUtils.updateExtraFeatureFile();
}
}
return isNeedRestart;
}
}

View File

@@ -81,7 +81,8 @@ public class PathUtils {
}
public static File getComponentsFolder() throws IOException {
File componentsFolder = new File(Platform.getConfigurationLocation().getDataArea(FOLDER_COMPS).getPath());
File configurationFolder = new File(Platform.getInstallLocation().getURL().getPath(), "configuration"); //$NON-NLS-1$
File componentsFolder = new File(configurationFolder, FOLDER_COMPS);
if (!componentsFolder.exists()) {
componentsFolder.mkdirs();
}
@@ -114,7 +115,12 @@ public class PathUtils {
}
public static File getComponentsM2TempFolder() {
return createComponentFolder(FOLDER_M2TEMP);
File componentsFolder = new File(Platform.getConfigurationLocation().getURL().getFile(), FOLDER_COMPS);
File m2TempFolder = new File(componentsFolder, FOLDER_M2TEMP);
if (!m2TempFolder.exists()) {
m2TempFolder.mkdirs();
}
return m2TempFolder;
}
public static File getPatchesFolder() {

View File

@@ -67,10 +67,50 @@ public class TaCoKitCarUtils {
if (proxyMonitor == null) {
proxyMonitor = new NullProgressMonitor();
}
return tckUpdateService.installCars(fileList, false, proxyMonitor);
}
}
return null;
}
public static ICarInstallationResult deployCars(File carFolder, final IProgressMonitor monitor, boolean cancellable)
throws Exception {
if (carFolder.exists()) {
File[] files = carFolder.listFiles();
if (files != null && 0 < files.length) {
ITaCoKitUpdateService tckUpdateService = ITaCoKitUpdateService.getInstance();
if (tckUpdateService == null) {
throw new Exception(Messages.getString("ITaCoKitUpdateService.exception.notFound", //$NON-NLS-1$
ITaCoKitUpdateService.class.getSimpleName()));
}
List<File> fileList = Arrays.asList(files);
IProgressMonitor proxyMonitor = monitor;
if (monitor != null && !cancellable) {
proxyMonitor = (IProgressMonitor) Proxy.newProxyInstance(monitor.getClass().getClassLoader(),
new Class[] { IProgressMonitor.class }, new InvocationHandler() {
@Override
public Object invoke(Object obj, Method method, Object[] args) throws Throwable {
if (method == null) {
return null;
}
if (StringUtils.equals(method.getName(), "isCanceled")) { //$NON-NLS-1$
return Boolean.FALSE;
}
return method.invoke(monitor, args);
}
});
}
if (proxyMonitor == null) {
proxyMonitor = new NullProgressMonitor();
}
return tckUpdateService.deployCars(fileList, false, proxyMonitor);
}
}
return null;
}
}

View File

@@ -206,6 +206,14 @@ public class UpdateTools {
}
return true;
}
public static boolean deployCars(IProgressMonitor monitor, File carFolder, boolean cancellable)
throws Exception {
if (carFolder != null && carFolder.exists()) {
TaCoKitCarUtils.deployCars(carFolder, monitor, cancellable);
}
return true;
}
public static void syncLibraries(File installingPatchFolder) throws IOException {
// sync to product lib/java

View File

@@ -117,7 +117,6 @@
<module>main/plugins/org.talend.libraries.jdbc.ingres</module>
<module>main/plugins/org.talend.libraries.jdbc.mysql</module>
<module>main/plugins/org.talend.libraries.jdbc.paraccel</module>
<module>main/plugins/org.talend.libraries.jdbc.postgresql</module>
<module>main/plugins/org.talend.libraries.jdbc.sqlite3</module>
<module>main/plugins/org.talend.libraries.jdbc.teradata</module>
<module>main/plugins/org.talend.libraries.jexcel</module>

View File

@@ -13,6 +13,8 @@
package org.talend.commons.utils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.util.HashMap;
@@ -162,6 +164,59 @@ public class VersionUtilsTest {
assertEquals(expect, result);
}
@Test
public void testIsInvalidProductVersion() {
assertTrue(VersionUtils.isInvalidProductVersion("7.3.1.20200201_1941-M1",
"Talend Cloud Big Data-7.3.1.20200209_1446-patch"));
assertTrue(
VersionUtils.isInvalidProductVersion("7.3.1.20200201_1941", "Talend Cloud Big Data-7.3.1.20200209_1446-patch"));
assertTrue(VersionUtils.isInvalidProductVersion("7.3.1.20200201_1941-patch",
"Talend Cloud Big Data-7.3.1.20200209_1446-patch"));
assertFalse(
VersionUtils.isInvalidProductVersion("7.3.1.20200209_1941-patch", "Talend Cloud Big Data-7.3.1.20200201_1446"));
// test nightly/milestone build
assertFalse(VersionUtils.isInvalidProductVersion("7.3.1.20200201_1941-SNAPSHOT",
"Talend Cloud Big Data-7.3.1.20200209_1446-SNAPSHOT"));
assertFalse(VersionUtils.isInvalidProductVersion("7.3.1.20200201_1941-M1",
"Talend Cloud Big Data-7.3.1.20200209_1446-SNAPSHOT"));
assertFalse(
VersionUtils.isInvalidProductVersion("7.3.1.20200201_1941-M1", "Talend Cloud Big Data-7.3.1.20200209_1446-M2"));
assertFalse(VersionUtils.isInvalidProductVersion("7.3.1.20200201_1941-SNAPSHOT",
"Talend Cloud Big Data-7.3.1.20200209_1446-M2"));
}
@Test
public void testProductVersionIsNewer() {
assertTrue(
VersionUtils.productVersionIsNewer("7.3.1.20200211_1941-M1", "Talend Cloud Big Data-7.3.1.20200209_1446-patch"));
assertTrue(VersionUtils.productVersionIsNewer("7.3.1.20200211_1941", "Talend Cloud Big Data-7.3.1.20200209_1446-patch"));
assertTrue(VersionUtils.productVersionIsNewer("7.3.1.20200211_1941-patch",
"Talend Cloud Big Data-7.3.1.20200209_1446-patch"));
assertFalse(VersionUtils.productVersionIsNewer("7.3.1.20200219_1941-patch", "Talend Cloud Big Data-7.3.1.20200221_1446"));
// test nightly/milestone build
assertFalse(VersionUtils.productVersionIsNewer("7.3.1.20200201_1941-SNAPSHOT",
"Talend Cloud Big Data-7.3.1.20200209_1446-SNAPSHOT"));
assertFalse(VersionUtils.productVersionIsNewer("7.3.1.20200201_1941-M1",
"Talend Cloud Big Data-7.3.1.20200209_1446-SNAPSHOT"));
assertFalse(
VersionUtils.productVersionIsNewer("7.3.1.20200201_1941-M1", "Talend Cloud Big Data-7.3.1.20200209_1446-M2"));
assertFalse(VersionUtils.productVersionIsNewer("7.3.1.20200201_1941-SNAPSHOT",
"Talend Cloud Big Data-7.3.1.20200209_1446-M2"));
}
@Test
public void testGetSimplifiedPatchName() {
String expect0 = "R2020-11-7.3.1";
assertEquals(expect0, VersionUtils.getSimplifiedPatchName("Patch_20201114_R2020-11_v1-7.3.1"));
String expect1 = "R2020-11-7.3.1";
assertEquals(expect1, VersionUtils.getSimplifiedPatchName("Patch_20201114_R2020-11_v2-7.3.1"));
String expect2 = "R2020-11-7.4.1";
assertEquals(expect2, VersionUtils.getSimplifiedPatchName("Patch_20201114_R2020-11_v1-7.4.1"));
}
@After
public void tearDown() throws Exception {
if (mojo_properties != null && mojo_properties.exists()) {

View File

@@ -0,0 +1,46 @@
// ============================================================================
//
// 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.utils.time;
import static org.junit.Assert.assertEquals;
import java.util.Locale;
import org.junit.Test;
/**
* DOC sbliu class global comment. Detailled comment
*/
public class PerformanceStatisticUtilTest {
@Test
public void testNumberFormat() {
Locale defaultLocale = Locale.getDefault();
double dvalue = 123456123456.789123456789;
try {
Locale.setDefault(new Locale("en","US"));
assertEquals(new Locale("en","US"), Locale.getDefault());
assertEquals("123456123456.79",PerformanceStatisticUtil.format(dvalue));
Locale.setDefault(new Locale("fr","FR"));
assertEquals(new Locale("fr","FR"), Locale.getDefault());
assertEquals("123456123456.79",PerformanceStatisticUtil.format(dvalue));
Locale.setDefault(new Locale("de","DE"));
assertEquals(new Locale("de","DE"), Locale.getDefault());
assertEquals("123456123456.79",PerformanceStatisticUtil.format(dvalue));
} finally {
Locale.setDefault(defaultLocale);
}
}
}