Compare commits
41 Commits
feat/maste
...
release/7.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b9d44f62d | ||
|
|
4f2f4ad5ed | ||
|
|
31e63d367a | ||
|
|
374ef473cd | ||
|
|
39fe107d2b | ||
|
|
655418754a | ||
|
|
bd38f3bb24 | ||
|
|
96a90bc9d4 | ||
|
|
a89a694105 | ||
|
|
c70c995827 | ||
|
|
bc82ca517e | ||
|
|
2c07f47523 | ||
|
|
668fd255c2 | ||
|
|
755fed6f00 | ||
|
|
66c3ce0a83 | ||
|
|
4236b866da | ||
|
|
cbf672ed2c | ||
|
|
01923b38ab | ||
|
|
d530c609b8 | ||
|
|
570338e9ff | ||
|
|
03958a67cb | ||
|
|
bc0926739b | ||
|
|
36f4c0eff3 | ||
|
|
22654e6d4b | ||
|
|
4072bd93e9 | ||
|
|
c4cc17db4d | ||
|
|
c0dc58d18a | ||
|
|
1d266d5488 | ||
|
|
15216b8be3 | ||
|
|
1f385ee333 | ||
|
|
0e4cd386dc | ||
|
|
17d96e1fa5 | ||
|
|
f1ec81bced | ||
|
|
2bcd3b2050 | ||
|
|
132eb3fa3a | ||
|
|
b94b99f1c8 | ||
|
|
64083d1e2e | ||
|
|
7b21c010e2 | ||
|
|
3d08e7a41c | ||
|
|
107c52119a | ||
|
|
992e01de37 |
@@ -21,29 +21,25 @@ import javax.crypto.SecretKeyFactory;
|
||||
import javax.crypto.spec.DESKeySpec;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.talend.utils.security.AESEncryption;
|
||||
import org.talend.utils.security.StudioEncryption;
|
||||
|
||||
/**
|
||||
* DOC chuang class global comment. Detailled comment
|
||||
*/
|
||||
public class PasswordEncryptUtil {
|
||||
|
||||
public static String ENCRYPT_KEY = "Encrypt"; //$NON-NLS-1$
|
||||
public static final String ENCRYPT_KEY = "Encrypt"; //$NON-NLS-1$
|
||||
|
||||
private static String rawKey = "Talend-Key"; //$NON-NLS-1$
|
||||
|
||||
public static String PREFIX_PASSWORD = "ENC:["; //$NON-NLS-1$
|
||||
|
||||
public static String POSTFIX_PASSWORD = "]"; //$NON-NLS-1$
|
||||
private static final String RAWKEY = "Talend-Key"; //$NON-NLS-1$
|
||||
|
||||
private static SecretKey key = null;
|
||||
|
||||
private static SecureRandom secureRandom = new SecureRandom();
|
||||
private static final SecureRandom SECURERANDOM = new SecureRandom();
|
||||
|
||||
private static SecretKey getSecretKey() throws Exception {
|
||||
if (key == null) {
|
||||
|
||||
byte rawKeyData[] = rawKey.getBytes();
|
||||
byte rawKeyData[] = RAWKEY.getBytes();
|
||||
DESKeySpec dks = new DESKeySpec(rawKeyData);
|
||||
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); //$NON-NLS-1$
|
||||
key = keyFactory.generateSecret(dks);
|
||||
@@ -65,7 +61,7 @@ public class PasswordEncryptUtil {
|
||||
|
||||
SecretKey key = getSecretKey();
|
||||
Cipher c = Cipher.getInstance("DES"); //$NON-NLS-1$
|
||||
c.init(Cipher.ENCRYPT_MODE, key, secureRandom);
|
||||
c.init(Cipher.ENCRYPT_MODE, key, SECURERANDOM);
|
||||
byte[] cipherByte = c.doFinal(input.getBytes());
|
||||
String dec = new String(Base64.encodeBase64(cipherByte));
|
||||
return dec;
|
||||
@@ -85,7 +81,7 @@ public class PasswordEncryptUtil {
|
||||
byte[] dec = Base64.decodeBase64(input.getBytes());
|
||||
SecretKey key = getSecretKey();
|
||||
Cipher c = Cipher.getInstance("DES"); //$NON-NLS-1$
|
||||
c.init(Cipher.DECRYPT_MODE, key, secureRandom);
|
||||
c.init(Cipher.DECRYPT_MODE, key, SECURERANDOM);
|
||||
byte[] clearByte = c.doFinal(dec);
|
||||
return new String(clearByte);
|
||||
}
|
||||
@@ -99,7 +95,7 @@ public class PasswordEncryptUtil {
|
||||
if (input == null) {
|
||||
return input;
|
||||
}
|
||||
return PREFIX_PASSWORD + AESEncryption.encryptPassword(input) + POSTFIX_PASSWORD;
|
||||
return StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.ROUTINE).encrypt(input);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Properties;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -192,6 +193,27 @@ public class VersionUtils {
|
||||
return talendVersion;
|
||||
}
|
||||
|
||||
public static String getTalendPureVersion(String fullProductVersion) {
|
||||
String version = fullProductVersion;
|
||||
String[] splitStr = fullProductVersion.split("-"); //$NON-NLS-1$
|
||||
Pattern pattern = Pattern.compile("((\\d+\\.){2}\\d.*)"); //$NON-NLS-1$
|
||||
StringBuffer versionStr = new StringBuffer();
|
||||
boolean find = false;
|
||||
for (String str : splitStr) {
|
||||
if (find) {
|
||||
versionStr.append("-").append(str); //$NON-NLS-1$
|
||||
}else {
|
||||
Matcher matcher = pattern.matcher(str);
|
||||
if (matcher.find()) {
|
||||
find = true;
|
||||
versionStr.append(str); // $NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return getTalendVersion(versionStr.toString());
|
||||
}
|
||||
|
||||
public static String getTalendVersion(String productVersion) {
|
||||
try {
|
||||
org.osgi.framework.Version v = new org.osgi.framework.Version(productVersion);
|
||||
|
||||
@@ -89,6 +89,8 @@ public interface ILibraryManagerService extends IService {
|
||||
* @return
|
||||
*/
|
||||
public boolean retrieve(String jarNeeded, String pathToStore, IProgressMonitor... monitorWrap);
|
||||
|
||||
public boolean retrieve(String jarNeeded, String jarURL, String pathToStore, IProgressMonitor... monitorWrap);
|
||||
|
||||
public boolean retrieve(String jarNeeded, String pathToStore, boolean showDialog, IProgressMonitor... monitorWrap);
|
||||
|
||||
|
||||
@@ -210,4 +210,9 @@ public interface ITDQRepositoryService extends IService {
|
||||
* @param ruManager: RepositoryUpdateManager
|
||||
*/
|
||||
void updateAllContextInAnalysisAndReport(RepositoryUpdateManager ruManager, Object parameter, boolean isUpdated);
|
||||
|
||||
/**
|
||||
* @param chooseContext the context name which want to swtich
|
||||
*/
|
||||
void popupSwitchContextFailedMessage(String chooseContext);
|
||||
}
|
||||
|
||||
@@ -166,9 +166,9 @@ public enum EDatabaseVersion4Drivers {
|
||||
REDSHIFT(new DbVersion4Drivers(EDatabaseTypeName.REDSHIFT, "redshift", "REDSHIFT", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
"redshift-jdbc42-no-awssdk-1.2.32.1056.jar")), //$NON-NLS-1$
|
||||
REDSHIFT_SSO(new DbVersion4Drivers(EDatabaseTypeName.REDSHIFT_SSO, "redshift sso", "REDSHIFT_SSO", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
new String[] { "redshift-jdbc42-no-awssdk-1.2.32.1056.jar", "aws-java-sdk-1.11.406.jar", "jackson-core-2.9.5.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
"jackson-databind-2.9.5.jar", "jackson-annotations-2.9.0.jar", "httpcore-4.4.9.jar", "httpclient-4.5.5.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
|
||||
"joda-time-2.8.1.jar", "commons-logging-1.1.3.jar" })), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
new String[] { "redshift-jdbc42-no-awssdk-1.2.32.1056.jar", "aws-java-sdk-1.11.406.jar", "jackson-core-2.9.9.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
"jackson-databind-2.9.9.jar", "jackson-annotations-2.9.0.jar", "httpcore-4.4.9.jar", "httpclient-4.5.5.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
|
||||
"joda-time-2.8.1.jar", "commons-logging-1.1.3.jar", "commons-codec-1.6.jar" })), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
||||
AMAZON_AURORA(new DbVersion4Drivers(EDatabaseTypeName.AMAZON_AURORA, "mysql-connector-java-5.1.30-bin.jar")); //$NON-NLS-1$
|
||||
|
||||
|
||||
@@ -60,6 +60,15 @@ public interface IComponent {
|
||||
|
||||
public String getOriginalName();
|
||||
|
||||
/**
|
||||
* Only for component display (palette,search)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default public String getDisplayName() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
public String getLongName();
|
||||
|
||||
public String getOriginalFamilyName();
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class AbstractNode implements INode {
|
||||
|
||||
private ComponentProperties componentProperties;
|
||||
|
||||
List<? extends IElementParameter> elementParameters;
|
||||
List<? extends IElementParameter> elementParameters = new ArrayList<IElementParameter>();
|
||||
|
||||
private List<? extends IConnection> outgoingConnections = new ArrayList<IConnection>();
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.IESBService;
|
||||
import org.talend.core.ITDQItemService;
|
||||
import org.talend.core.PluginChecker;
|
||||
import org.talend.core.hadoop.IHadoopClusterService;
|
||||
@@ -33,7 +34,6 @@ import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.JobletProcessItem;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.properties.ProjectReference;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.properties.SQLPatternItem;
|
||||
import org.talend.core.model.relationship.Relation;
|
||||
@@ -904,30 +904,7 @@ public final class ProcessUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (needBeans && GlobalServiceRegister.getDefault().isServiceRegistered(IProxyRepositoryService.class)) {
|
||||
IProxyRepositoryService service = (IProxyRepositoryService) GlobalServiceRegister.getDefault()
|
||||
.getService(IProxyRepositoryService.class);
|
||||
ERepositoryObjectType beansType = ERepositoryObjectType.valueOf("BEANS"); //$NON-NLS-1$
|
||||
try {
|
||||
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
|
||||
List<IRepositoryViewObject> all = factory.getAll(project, beansType);
|
||||
List<ProjectReference> references = ProjectManager.getInstance().getCurrentProject()
|
||||
.getProjectReferenceList(true);
|
||||
for (ProjectReference ref : references) {
|
||||
all.addAll(factory.getAll(new Project(ref.getReferencedProject()), beansType));
|
||||
}
|
||||
// if (!all.isEmpty()) { // has bean
|
||||
// return true;
|
||||
// }
|
||||
|
||||
return true;
|
||||
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return needBeans && GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class);
|
||||
}
|
||||
|
||||
public static boolean isRequiredPigUDFs(IProcess process) {
|
||||
|
||||
@@ -575,6 +575,8 @@ public class ERepositoryObjectType extends DynaEnum<ERepositoryObjectType> {
|
||||
public final static ERepositoryObjectType METADATA_SAP_BW_INFOOBJECT = ERepositoryObjectType
|
||||
.valueOf("METADATA_SAP_BW_INFOOBJECT"); //$NON-NLS-1$
|
||||
|
||||
public final static ERepositoryObjectType JDBC = ERepositoryObjectType.valueOf("JDBC"); //$NON-NLS-1$
|
||||
|
||||
private static Map<String, ERepositoryObjectType> typeCacheById = new HashMap<String, ERepositoryObjectType>();
|
||||
|
||||
ERepositoryObjectType(String key, String folder, String type, boolean isStaticNode, int ordinal, String[] products,
|
||||
|
||||
@@ -684,16 +684,15 @@ public class NodeUtil {
|
||||
}
|
||||
List<? extends IConnection> listInConns = node.getIncomingConnections();
|
||||
if (listInConns != null && listInConns.size() > 0) {
|
||||
String retResult = getPrivateConnClassName(listInConns.get(0));
|
||||
if (retResult == null) {
|
||||
return conn.getName();
|
||||
} else {
|
||||
return retResult;
|
||||
for (IConnection connection : listInConns) {
|
||||
if (EConnectionType.FLOW_REF != connection.getLineStyle()) {
|
||||
String retResult = getPrivateConnClassName(connection);
|
||||
return retResult != null ? retResult : conn.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,11 +41,11 @@ import org.talend.core.model.process.EParameterFieldType;
|
||||
import org.talend.core.model.process.IContextParameter;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.daikon.security.CryptoHelper;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementValueType;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.utils.security.StudioEncryption;
|
||||
|
||||
/**
|
||||
* cli class global comment. Detailled comment
|
||||
@@ -842,7 +842,8 @@ public final class ParameterValueUtil {
|
||||
if (contextParam != null) {
|
||||
String docValue = contextParam.getValue();
|
||||
if (docValue != null) {
|
||||
String encryptValue = CryptoHelper.getDefault().encrypt(docValue);
|
||||
String encryptValue = StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM)
|
||||
.encrypt(docValue);
|
||||
if (encryptValue != null) {
|
||||
return encryptValue;
|
||||
}
|
||||
@@ -878,7 +879,8 @@ public final class ParameterValueUtil {
|
||||
if (param != null) {
|
||||
Object docValue = param.getValue();
|
||||
if (docValue != null && docValue instanceof String) {
|
||||
String encryptValue = CryptoHelper.getDefault().encrypt(docValue.toString());
|
||||
String encryptValue = StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM)
|
||||
.encrypt(docValue.toString());
|
||||
if (encryptValue != null) {
|
||||
return encryptValue;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.net.URLDecoder;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.daikon.security.CryptoHelper;
|
||||
import org.talend.utils.security.StudioEncryption;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
@@ -47,8 +47,6 @@ public class MavenUrlHelper {
|
||||
|
||||
public static final String USER_PASSWORD_SPLITER = ":";
|
||||
|
||||
private static CryptoHelper cryptoHelper;
|
||||
|
||||
public static MavenArtifact parseMvnUrl(String mvnUrl) {
|
||||
return parseMvnUrl(mvnUrl, true);
|
||||
}
|
||||
@@ -332,19 +330,12 @@ public class MavenUrlHelper {
|
||||
return uri;
|
||||
}
|
||||
|
||||
private static CryptoHelper getCryptoHelper() {
|
||||
if (cryptoHelper == null) {
|
||||
cryptoHelper = CryptoHelper.getDefault();
|
||||
}
|
||||
return cryptoHelper;
|
||||
}
|
||||
|
||||
public static String encryptPassword(String password) {
|
||||
return getCryptoHelper().encrypt(password);
|
||||
return StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM).encrypt(password);
|
||||
}
|
||||
|
||||
public static String decryptPassword(String password) {
|
||||
return getCryptoHelper().decrypt(password);
|
||||
return StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM).decrypt(password);
|
||||
}
|
||||
|
||||
public static String generateModuleNameByMavenURI(String uri) {
|
||||
|
||||
@@ -12,13 +12,10 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.service;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.talend.core.IService;
|
||||
|
||||
public interface IUpdateService extends IService {
|
||||
|
||||
boolean checkComponentNexusUpdate();
|
||||
|
||||
boolean checkStudioUpdate(IProgressMonitor monitor);
|
||||
|
||||
}
|
||||
|
||||
@@ -99,6 +99,8 @@ public interface IJobletProviderService extends IService {
|
||||
public IEditorPart openJobletItem(JobletProcessItem item);
|
||||
|
||||
public boolean isJobletItem(Item item);
|
||||
|
||||
public boolean isJobletProcess(IProcess process);
|
||||
|
||||
public Action getMoveToJobletAction(IWorkbenchPart part, INode jobletNode, Map<INode, IConnection> nodeMap);
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.prefs.SSLPreferenceConstants;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.daikon.security.CryptoHelper;
|
||||
import org.talend.daikon.security.SSLContextProvider;
|
||||
import org.talend.utils.security.StudioEncryption;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -34,7 +34,7 @@ public class StudioSSLContextProvider {
|
||||
|
||||
private static SSLContext context;
|
||||
|
||||
private static final IPreferenceStore store = CoreRuntimePlugin.getInstance().getCoreService().getPreferenceStore();
|
||||
private static final IPreferenceStore STORE = CoreRuntimePlugin.getInstance().getCoreService().getPreferenceStore();
|
||||
|
||||
public static synchronized SSLContext getContext() throws Exception {
|
||||
if (null == context) {
|
||||
@@ -44,15 +44,14 @@ public class StudioSSLContextProvider {
|
||||
}
|
||||
|
||||
public static synchronized void buildContext() throws Exception {
|
||||
String keypath = store.getString(SSLPreferenceConstants.KEYSTORE_FILE);
|
||||
String keypass = store.getString(SSLPreferenceConstants.KEYSTORE_PASSWORD);
|
||||
String keytype = store.getString(SSLPreferenceConstants.KEYSTORE_TYPE);
|
||||
String trustpath = store.getString(SSLPreferenceConstants.TRUSTSTORE_FILE);
|
||||
String trustpass = store.getString(SSLPreferenceConstants.TRUSTSTORE_PASSWORD);
|
||||
String trusttype = store.getString(SSLPreferenceConstants.TRUSTSTORE_TYPE);
|
||||
CryptoHelper cryptoHelper = CryptoHelper.getDefault();
|
||||
keypass = cryptoHelper.decrypt(keypass);
|
||||
trustpass = cryptoHelper.decrypt(trustpass);
|
||||
String keypath = STORE.getString(SSLPreferenceConstants.KEYSTORE_FILE);
|
||||
String keypass = STORE.getString(SSLPreferenceConstants.KEYSTORE_PASSWORD);
|
||||
String keytype = STORE.getString(SSLPreferenceConstants.KEYSTORE_TYPE);
|
||||
String trustpath = STORE.getString(SSLPreferenceConstants.TRUSTSTORE_FILE);
|
||||
String trustpass = STORE.getString(SSLPreferenceConstants.TRUSTSTORE_PASSWORD);
|
||||
String trusttype = STORE.getString(SSLPreferenceConstants.TRUSTSTORE_TYPE);
|
||||
keypass = StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM).decrypt(keypass);
|
||||
trustpass = StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM).decrypt(trustpass);
|
||||
try {
|
||||
if (StringUtils.isEmpty(keypath) && StringUtils.isEmpty(trustpath)) {
|
||||
context = null;
|
||||
@@ -88,12 +87,12 @@ public class StudioSSLContextProvider {
|
||||
|
||||
private static void changeProperty() {
|
||||
final IPreferenceStore sslStore = CoreRuntimePlugin.getInstance().getCoreService().getPreferenceStore();
|
||||
CryptoHelper cryptoHelper = CryptoHelper.getDefault();
|
||||
String keyStore = sslStore.getString(SSLPreferenceConstants.KEYSTORE_FILE);
|
||||
if (keyStore != null && !"".equals(keyStore.trim())) {
|
||||
System.setProperty(SSLPreferenceConstants.KEYSTORE_FILE, keyStore);
|
||||
System.setProperty(SSLPreferenceConstants.KEYSTORE_PASSWORD,
|
||||
cryptoHelper.decrypt(sslStore.getString(SSLPreferenceConstants.KEYSTORE_PASSWORD)));
|
||||
StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM)
|
||||
.decrypt(sslStore.getString(SSLPreferenceConstants.KEYSTORE_PASSWORD)));
|
||||
System.setProperty(SSLPreferenceConstants.KEYSTORE_TYPE, sslStore.getString(SSLPreferenceConstants.KEYSTORE_TYPE));
|
||||
} else {
|
||||
System.clearProperty(SSLPreferenceConstants.KEYSTORE_FILE);
|
||||
@@ -104,7 +103,8 @@ public class StudioSSLContextProvider {
|
||||
if (trustStore != null && !"".equals(trustStore.trim())) {
|
||||
System.setProperty(SSLPreferenceConstants.TRUSTSTORE_FILE, trustStore);
|
||||
System.setProperty(SSLPreferenceConstants.TRUSTSTORE_PASSWORD,
|
||||
cryptoHelper.decrypt(sslStore.getString(SSLPreferenceConstants.TRUSTSTORE_PASSWORD)));
|
||||
StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM)
|
||||
.decrypt(sslStore.getString(SSLPreferenceConstants.TRUSTSTORE_PASSWORD)));
|
||||
System.setProperty(SSLPreferenceConstants.TRUSTSTORE_TYPE, sslStore.getString(SSLPreferenceConstants.TRUSTSTORE_TYPE));
|
||||
} else {
|
||||
System.clearProperty(SSLPreferenceConstants.TRUSTSTORE_FILE);
|
||||
|
||||
@@ -19,8 +19,9 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
@@ -80,6 +81,8 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
}
|
||||
|
||||
private Collection<RoutineItem> getAll(ERepositoryObjectType type, boolean syncRef) throws SystemException {
|
||||
// init code project
|
||||
getRunProcessService().getTalendCodeJavaProject(type);
|
||||
// remove routine with same name in reference project
|
||||
final Map<String, RoutineItem> beansList = new HashMap<String, RoutineItem>();
|
||||
for (IRepositoryViewObject obj : getRepositoryService().getProxyRepositoryFactory().getAll(type)) {
|
||||
@@ -96,34 +99,37 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
return (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
}
|
||||
|
||||
private void getReferencedProjectRoutine(final Map<String, RoutineItem> beansList, final Project project,
|
||||
ERepositoryObjectType routineType, boolean syncRef) throws SystemException {
|
||||
List<IRepositoryViewObject> list = getRepositoryService().getProxyRepositoryFactory().getAll(project, routineType);
|
||||
|
||||
if (list.size() == 0) {
|
||||
private Set<IRepositoryViewObject> getReferencedProjectRoutine(final Map<String, RoutineItem> beansList,
|
||||
final Project project, ERepositoryObjectType routineType, boolean syncRef) throws SystemException {
|
||||
// init ref code project
|
||||
if (syncRef) {
|
||||
getRunProcessService().getTalendCodeJavaProject(routineType, project.getTechnicalLabel());
|
||||
} else {
|
||||
for (IRepositoryViewObject obj : list) {
|
||||
final String key = obj.getProperty().getLabel();
|
||||
// it does not have a routine with same name
|
||||
if (!beansList.containsKey(key)) {
|
||||
beansList.put(key, (RoutineItem) obj.getProperty().getItem());
|
||||
}
|
||||
if (syncRef) {
|
||||
// sync routine
|
||||
syncRoutine((RoutineItem) obj.getProperty().getItem(), false, true, true);
|
||||
}
|
||||
}
|
||||
Set<IRepositoryViewObject> routines = new HashSet<>();
|
||||
routines.addAll(getRepositoryService().getProxyRepositoryFactory().getAll(project, routineType));
|
||||
for (IRepositoryViewObject obj : routines) {
|
||||
final String key = obj.getProperty().getLabel();
|
||||
// it does not have a routine with same name
|
||||
if (!beansList.containsKey(key)) {
|
||||
beansList.put(key, (RoutineItem) obj.getProperty().getItem());
|
||||
}
|
||||
}
|
||||
|
||||
for (ProjectReference projectReference : project.getProjectReferenceList()) {
|
||||
routines.addAll(getReferencedProjectRoutine(beansList, new Project(projectReference.getReferencedProject()),
|
||||
routineType, syncRef));
|
||||
}
|
||||
if (syncRef) {
|
||||
routines.stream().forEach(obj -> {
|
||||
try {
|
||||
syncRoutine((RoutineItem) obj.getProperty().getItem(), project.getTechnicalLabel(), true, true);
|
||||
} catch (SystemException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
});
|
||||
// sync system routine
|
||||
syncSystemRoutine(project);
|
||||
}
|
||||
|
||||
for (ProjectReference projectReference : project.getProjectReferenceList()) {
|
||||
getReferencedProjectRoutine(beansList, new Project(projectReference.getReferencedProject()), routineType, syncRef);
|
||||
}
|
||||
return routines;
|
||||
}
|
||||
|
||||
protected void syncSystemRoutine(Project project) throws SystemException {
|
||||
@@ -136,24 +142,17 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
}
|
||||
|
||||
protected IFile getRoutineFile(RoutineItem routineItem) throws SystemException {
|
||||
return getRoutineFile(routineItem, true);
|
||||
return getRoutineFile(routineItem, ProjectManager.getInstance().getCurrentProject().getTechnicalLabel());
|
||||
}
|
||||
|
||||
protected IFile getRoutineFile(RoutineItem routineItem, boolean currentProject) throws SystemException {
|
||||
String projectTechName;
|
||||
if (currentProject) {
|
||||
projectTechName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
} else {
|
||||
projectTechName = ProjectManager.getInstance().getProject(routineItem).getTechnicalLabel();
|
||||
}
|
||||
protected IFile getRoutineFile(RoutineItem routineItem, String projectTechName) throws SystemException {
|
||||
ITalendProcessJavaProject talendProcessJavaProject = getRunProcessService()
|
||||
.getTalendCodeJavaProject(ERepositoryObjectType.getItemType(routineItem), projectTechName);
|
||||
if (talendProcessJavaProject == null) {
|
||||
return null;
|
||||
}
|
||||
IFolder routineFolder = talendProcessJavaProject.getSrcSubFolder(null, routineItem.getPackageType());
|
||||
IFile file = routineFolder.getFile(routineItem.getProperty().getLabel() + JavaUtils.JAVA_EXTENSION);
|
||||
return file;
|
||||
return routineFolder.getFile(routineItem.getProperty().getLabel() + JavaUtils.JAVA_EXTENSION);
|
||||
}
|
||||
|
||||
private IFile getProcessFile(ProcessItem item) throws SystemException {
|
||||
@@ -201,30 +200,31 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
|
||||
@Override
|
||||
public void syncRoutine(RoutineItem routineItem, boolean copyToTemp) throws SystemException {
|
||||
syncRoutine(routineItem, true, copyToTemp, false);
|
||||
syncRoutine(routineItem, ProjectManager.getInstance().getCurrentProject().getTechnicalLabel(), copyToTemp, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncRoutine(RoutineItem routineItem, boolean copyToTemp, boolean forceUpdate) throws SystemException {
|
||||
syncRoutine(routineItem, true, copyToTemp, forceUpdate);
|
||||
syncRoutine(routineItem, ProjectManager.getInstance().getCurrentProject().getTechnicalLabel(), copyToTemp, forceUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncRoutine(RoutineItem routineItem, boolean currentProject, boolean copyToTemp, boolean forceUpdate) throws SystemException {
|
||||
public void syncRoutine(RoutineItem routineItem, String projectTechName, boolean copyToTemp, boolean forceUpdate)
|
||||
throws SystemException {
|
||||
boolean needSync = false;
|
||||
if (routineItem != null) {
|
||||
if (forceUpdate || !isRoutineUptodate(routineItem)) {
|
||||
needSync = true;
|
||||
} else {
|
||||
IFile file = getRoutineFile(routineItem, currentProject);
|
||||
IFile file = getRoutineFile(routineItem, projectTechName);
|
||||
if (file != null && !file.exists()) {
|
||||
needSync = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (needSync) {
|
||||
doSyncRoutine(routineItem, currentProject, copyToTemp);
|
||||
if (currentProject) {
|
||||
doSyncRoutine(routineItem, projectTechName, copyToTemp);
|
||||
if (ProjectManager.getInstance().getCurrentProject().getTechnicalLabel().equals(projectTechName)) {
|
||||
setRoutineAsUptodate(routineItem);
|
||||
}
|
||||
}
|
||||
@@ -232,14 +232,14 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
|
||||
public void syncRoutine(RoutineItem routineItem) throws SystemException {
|
||||
if (routineItem != null) {
|
||||
doSyncRoutine(routineItem, true, true);
|
||||
doSyncRoutine(routineItem, ProjectManager.getInstance().getCurrentProject().getTechnicalLabel(), true);
|
||||
setRoutineAsUptodate(routineItem);
|
||||
}
|
||||
}
|
||||
|
||||
private void doSyncRoutine(RoutineItem routineItem, boolean currentProject, boolean copyToTemp) throws SystemException {
|
||||
private void doSyncRoutine(RoutineItem routineItem, String projectTechName, boolean copyToTemp) throws SystemException {
|
||||
try {
|
||||
IFile file = getRoutineFile(routineItem, currentProject);
|
||||
IFile file = getRoutineFile(routineItem, projectTechName);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
@@ -382,7 +382,7 @@ public abstract class AbstractRoutineSynchronizer implements ITalendSynchronizer
|
||||
@Override
|
||||
public void syncAllBeansForLogOn() throws SystemException {
|
||||
for (RoutineItem beanItem : getBeans(true)) {
|
||||
syncRoutine(beanItem, true, true, true);
|
||||
syncRoutine(beanItem, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,8 @@ public interface ITalendSynchronizer {
|
||||
|
||||
void syncRoutine(RoutineItem routineItem, boolean copyToTemp, boolean forceUpdate) throws SystemException;
|
||||
|
||||
void syncRoutine(RoutineItem routineItem, boolean currentProject, boolean copyToTemp, boolean forceUpdate) throws SystemException;
|
||||
void syncRoutine(RoutineItem routineItem, String projectTechName, boolean copyToTemp, boolean forceUpdate)
|
||||
throws SystemException;
|
||||
|
||||
IFile getFile(Item item) throws SystemException;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// ============================================================================
|
||||
package org.talend.designer.runprocess;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -298,6 +299,8 @@ public interface IProcessor {
|
||||
String[] getJVMArgs();
|
||||
|
||||
Set<ModuleNeeded> getNeededModules(int options);
|
||||
|
||||
public void updateModulesAfterSetLog4j(Collection<ModuleNeeded> modulesNeeded);
|
||||
|
||||
Set<JobInfo> getBuildChildrenJobs();
|
||||
|
||||
|
||||
@@ -216,6 +216,8 @@ public interface IRunProcessService extends IService {
|
||||
|
||||
ITalendProcessJavaProject getTalendJobJavaProject(Property property);
|
||||
|
||||
IFolder getCodeSrcFolder(ERepositoryObjectType type, String projectTechName);
|
||||
|
||||
ITalendProcessJavaProject getTempJavaProject();
|
||||
|
||||
void clearProjectRelatedSettings();
|
||||
|
||||
@@ -200,6 +200,10 @@ public final class ProjectManager {
|
||||
* return all the referenced projects of current project.
|
||||
*/
|
||||
public List<Project> getAllReferencedProjects(boolean force) {
|
||||
return getAllReferencedProjects(getCurrentProject(), force);
|
||||
}
|
||||
|
||||
public List<Project> getAllReferencedProjects(Project targetProject, boolean force) {
|
||||
List<Project> allReferencedprojects = new ArrayList<Project>();
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IProxyRepositoryService.class)) {
|
||||
if (this.getCurrentProject() == null) {
|
||||
@@ -212,7 +216,7 @@ public final class ProjectManager {
|
||||
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
|
||||
if (factory != null) {
|
||||
List<org.talend.core.model.properties.Project> rProjects = factory
|
||||
.getReferencedProjects(this.getCurrentProject());
|
||||
.getReferencedProjects(targetProject);
|
||||
if (rProjects != null) {
|
||||
for (org.talend.core.model.properties.Project p : rProjects) {
|
||||
Project project = new Project(p);
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.talend.core.model.general.ConnectionBean;
|
||||
import org.talend.utils.json.JSONArray;
|
||||
import org.talend.utils.json.JSONException;
|
||||
import org.talend.utils.json.JSONObject;
|
||||
import org.talend.utils.security.EncryptedProperties;
|
||||
|
||||
/**
|
||||
* DOC hwang class global comment. Detailled comment
|
||||
@@ -126,8 +127,8 @@ public class ConnectionUserPerReader {
|
||||
if (!isHaveUserPer()) {
|
||||
createPropertyFile();
|
||||
}
|
||||
try {
|
||||
proper.load(new FileInputStream(perfile));
|
||||
try (FileInputStream fi = new FileInputStream(perfile)) {
|
||||
proper.load(fi);
|
||||
isRead = true;
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
@@ -176,9 +177,7 @@ public class ConnectionUserPerReader {
|
||||
}
|
||||
proper.setProperty("connection.define", usersJsonArray.toString());//$NON-NLS-1$
|
||||
}
|
||||
try {
|
||||
|
||||
FileOutputStream out = new FileOutputStream(perfile);
|
||||
try (FileOutputStream out = new FileOutputStream(perfile)) {
|
||||
proper.store(out, null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -202,9 +201,8 @@ public class ConnectionUserPerReader {
|
||||
proper.remove("connection.lastConnection"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
FileOutputStream out;
|
||||
try {
|
||||
out = new FileOutputStream(perfile);
|
||||
;
|
||||
try (FileOutputStream out = new FileOutputStream(perfile)) {
|
||||
proper.store(out, null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -286,9 +284,7 @@ public class ConnectionUserPerReader {
|
||||
IPreferenceStore prefStore = PlatformUI.getPreferenceStore();
|
||||
proper.setProperty("connection.readRegistration", Integer.toString(prefStore.getInt("REGISTRATION_TRIES")));
|
||||
proper.setProperty("connection.readRegistrationDone", Integer.toString(prefStore.getInt("REGISTRATION_DONE")));
|
||||
try {
|
||||
|
||||
FileOutputStream out = new FileOutputStream(perfile);
|
||||
try (FileOutputStream out = new FileOutputStream(perfile)) {
|
||||
proper.store(out, null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -317,8 +313,7 @@ public class ConnectionUserPerReader {
|
||||
String val = entry.getValue();
|
||||
proper.setProperty(key, val);
|
||||
}
|
||||
try {
|
||||
FileOutputStream out = new FileOutputStream(perfile);
|
||||
try (FileOutputStream out = new FileOutputStream(perfile)) {
|
||||
proper.store(out, null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -334,9 +329,7 @@ public class ConnectionUserPerReader {
|
||||
}
|
||||
IPreferenceStore prefStore = PlatformUI.getPreferenceStore();
|
||||
proper.setProperty("connection.licenseManagement", Integer.toString(prefStore.getInt("LICENSE_VALIDATION_DONE")));
|
||||
try {
|
||||
|
||||
FileOutputStream out = new FileOutputStream(perfile);
|
||||
try (FileOutputStream out = new FileOutputStream(perfile)) {
|
||||
proper.store(out, null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -362,8 +355,7 @@ public class ConnectionUserPerReader {
|
||||
this.readProperties();
|
||||
}
|
||||
proper.setProperty("connection.installDone", Boolean.TRUE.toString()); //$NON-NLS-1$
|
||||
try {
|
||||
FileOutputStream out = new FileOutputStream(perfile);
|
||||
try (FileOutputStream out = new FileOutputStream(perfile)) {
|
||||
proper.store(out, null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -18,8 +18,8 @@ import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.prefs.ITalendCorePrefConstants;
|
||||
import org.talend.core.ui.CoreUIPlugin;
|
||||
import org.talend.core.ui.branding.IBrandingService;
|
||||
import org.talend.daikon.security.CryptoHelper;
|
||||
import org.talend.daikon.token.TokenGenerator;
|
||||
import org.talend.utils.security.StudioEncryption;
|
||||
|
||||
import us.monoid.json.JSONObject;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class DefaultTokenCollector extends AbstractTokenCollector {
|
||||
}
|
||||
|
||||
public static String calcUniqueId() {
|
||||
return TokenGenerator.generateMachineToken(new CryptoHelper(CryptoHelper.PASSPHRASE));
|
||||
return TokenGenerator.generateMachineToken((src) -> StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM).encrypt(src));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -54,6 +54,7 @@ import org.talend.core.model.metadata.QueryUtil;
|
||||
import org.talend.core.model.metadata.builder.ConvertionHelper;
|
||||
import org.talend.core.model.metadata.builder.connection.MetadataTable;
|
||||
import org.talend.core.model.process.ElementParameterParser;
|
||||
import org.talend.core.model.process.ProcessUtils;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.relationship.RelationshipItemBuilder;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
@@ -280,9 +281,10 @@ public class CoreService implements ICoreService {
|
||||
ICodeGeneratorService codeGenService = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(
|
||||
ICodeGeneratorService.class);
|
||||
codeGenService.createRoutineSynchronizer().syncAllRoutinesForLogOn();
|
||||
codeGenService.createRoutineSynchronizer().syncAllPigudfForLogOn();
|
||||
if (ProcessUtils.isRequiredPigUDFs(null)) {
|
||||
codeGenService.createRoutineSynchronizer().syncAllPigudfForLogOn();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2616,20 +2616,32 @@ public class ProcessorUtilities {
|
||||
}
|
||||
|
||||
public static boolean isEsbJob(IProcess process) {
|
||||
return isEsbJob(process, false);
|
||||
}
|
||||
|
||||
public static boolean isEsbJob(IProcess process, boolean checkCurrentProcess) {
|
||||
|
||||
if (process instanceof IProcess2) {
|
||||
Set<JobInfo> infos = ProcessorUtilities.getChildrenJobInfo(((IProcess2) process).getProperty().getItem(), false);
|
||||
|
||||
for (JobInfo jobInfo : infos) {
|
||||
ProcessType processType = jobInfo.getProcessItem().getProcess();
|
||||
EList<NodeType> nodes = processType.getNode();
|
||||
for (NodeType nodeType : nodes) {
|
||||
if (isEsbComponentName(nodeType.getComponentName())) {
|
||||
if (checkCurrentProcess) {
|
||||
for (INode n : process.getGraphicalNodes()) {
|
||||
if (isEsbComponentName(n.getComponent().getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Set<JobInfo> infos = ProcessorUtilities.getChildrenJobInfo(((IProcess2) process).getProperty().getItem(), false);
|
||||
|
||||
for (JobInfo jobInfo : infos) {
|
||||
ProcessType processType = jobInfo.getProcessItem().getProcess();
|
||||
EList<NodeType> nodes = processType.getNode();
|
||||
for (NodeType nodeType : nodes) {
|
||||
if (isEsbComponentName(nodeType.getComponentName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,29 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="lib/commons-codec.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/httpclient.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/httpcore.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jcl-over-slf4j.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-resolver-api.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-resolver-connector-basic.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-resolver-impl.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-resolver-spi.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-resolver-transport-classpath.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-resolver-transport-file.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-resolver-transport-http.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-resolver-transport-wagon.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-resolver-util.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/plexus-utils.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/slf4j-api.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/wagon-provider-api.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-aether-provider-3.2.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-model-3.2.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-model-builder-3.2.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-repository-metadata-3.2.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/plexus-interpolation-1.19.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/plexus-utils-3.0.17.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-resolver-transport-file.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-resolver-transport-http.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/wagon-file.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jsoup.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/wagon-http-shared.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/wagon-http.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/commons-codec.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/httpclient.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/httpcore.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jcl-over-slf4j.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-resolver-api.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-resolver-connector-basic.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-resolver-impl.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-resolver-spi.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-resolver-transport-classpath.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-resolver-transport-wagon.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-resolver-util.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/plexus-utils.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/slf4j-api.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/wagon-provider-api.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-aether-provider-3.2.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-model-3.2.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-model-builder-3.2.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/maven-repository-metadata-3.2.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/plexus-interpolation-1.19.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/plexus-utils-3.0.17.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
||||
@@ -26,13 +26,17 @@ Bundle-ClassPath: .,
|
||||
lib/maven-resolver-impl.jar,
|
||||
lib/maven-resolver-spi.jar,
|
||||
lib/maven-resolver-transport-classpath.jar,
|
||||
lib/maven-resolver-transport-file.jar,
|
||||
lib/maven-resolver-transport-http.jar,
|
||||
lib/maven-resolver-transport-wagon.jar,
|
||||
lib/maven-resolver-util.jar,
|
||||
lib/plexus-utils.jar,
|
||||
lib/slf4j-api.jar,
|
||||
lib/wagon-provider-api.jar
|
||||
lib/wagon-provider-api.jar,
|
||||
lib/jsoup.jar,
|
||||
lib/wagon-http-shared.jar,
|
||||
lib/wagon-http.jar,
|
||||
lib/wagon-file.jar,
|
||||
lib/maven-resolver-transport-file.jar,
|
||||
lib/maven-resolver-transport-http.jar
|
||||
Export-Package: org.talend.designer.maven.aether,
|
||||
org.talend.designer.maven.aether.comparator,
|
||||
org.talend.designer.maven.aether.node,
|
||||
|
||||
@@ -2,4 +2,10 @@ source.. = src/main/java/
|
||||
output.. = target/classes/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
lib/
|
||||
lib/,\
|
||||
lib/jsoup.jar,\
|
||||
lib/wagon-http-shared.jar,\
|
||||
lib/wagon-http.jar,\
|
||||
lib/wagon-file.jar,\
|
||||
lib/maven-resolver-transport-file.jar,\
|
||||
lib/maven-resolver-transport-http.jar
|
||||
|
||||
Binary file not shown.
@@ -11,6 +11,7 @@
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<properties>
|
||||
<maven.resolver.version>1.3.1</maven.resolver.version>
|
||||
<wagon.version>3.0.0</wagon.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -45,10 +46,20 @@
|
||||
<version>${maven.resolver.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.resolver</groupId>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-file</artifactId>
|
||||
<version>${wagon.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-http</artifactId>
|
||||
<version>${wagon.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.resolver</groupId>
|
||||
<artifactId>maven-resolver-transport-file</artifactId>
|
||||
<version>${maven.resolver.version}</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.resolver</groupId>
|
||||
<artifactId>maven-resolver-transport-http</artifactId>
|
||||
|
||||
@@ -17,24 +17,20 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
|
||||
import org.codehaus.plexus.PlexusContainerException;
|
||||
import org.eclipse.aether.DefaultRepositorySystemSession;
|
||||
import org.eclipse.aether.RepositorySystem;
|
||||
import org.eclipse.aether.artifact.Artifact;
|
||||
import org.eclipse.aether.artifact.DefaultArtifact;
|
||||
import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory;
|
||||
import org.eclipse.aether.deployment.DeployRequest;
|
||||
import org.eclipse.aether.impl.DefaultServiceLocator;
|
||||
import org.eclipse.aether.repository.Authentication;
|
||||
import org.eclipse.aether.repository.LocalRepository;
|
||||
import org.eclipse.aether.repository.RemoteRepository;
|
||||
import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
|
||||
import org.eclipse.aether.spi.connector.transport.TransporterFactory;
|
||||
import org.eclipse.aether.transport.file.FileTransporterFactory;
|
||||
import org.eclipse.aether.transport.http.HttpTransporterFactory;
|
||||
import org.eclipse.aether.util.artifact.SubArtifact;
|
||||
import org.eclipse.aether.util.listener.ChainedRepositoryListener;
|
||||
import org.eclipse.aether.util.listener.ChainedTransferListener;
|
||||
import org.eclipse.aether.util.repository.AuthenticationBuilder;
|
||||
import org.talend.designer.maven.aether.util.MavenLibraryResolverProvider;
|
||||
|
||||
/**
|
||||
* created by wchen on Aug 10, 2017 Detailled comment
|
||||
@@ -44,32 +40,16 @@ public class RepositorySystemFactory {
|
||||
|
||||
private static Map<LocalRepository, DefaultRepositorySystemSession> sessions = new HashMap<LocalRepository, DefaultRepositorySystemSession>();
|
||||
|
||||
private static RepositorySystem system;
|
||||
|
||||
private static RepositorySystem newRepositorySystem() {
|
||||
DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
|
||||
locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
|
||||
locator.addService(TransporterFactory.class, FileTransporterFactory.class);
|
||||
locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
|
||||
|
||||
locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
|
||||
|
||||
@Override
|
||||
public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
return locator.getService(RepositorySystem.class);
|
||||
}
|
||||
|
||||
private static DefaultRepositorySystemSession newRepositorySystemSession(String localRepositoryPath) {
|
||||
private static DefaultRepositorySystemSession newRepositorySystemSession(String localRepositoryPath)
|
||||
throws PlexusContainerException {
|
||||
LocalRepository localRepo = new LocalRepository(localRepositoryPath);
|
||||
DefaultRepositorySystemSession repositorySystemSession = sessions.get(localRepo);
|
||||
if (repositorySystemSession == null) {
|
||||
repositorySystemSession = MavenRepositorySystemUtils.newSession();
|
||||
repositorySystemSession
|
||||
.setLocalRepositoryManager(system.newLocalRepositoryManager(repositorySystemSession, localRepo));
|
||||
.setLocalRepositoryManager(
|
||||
MavenLibraryResolverProvider.newRepositorySystem().newLocalRepositoryManager(repositorySystemSession,
|
||||
localRepo));
|
||||
repositorySystemSession.setTransferListener(new ChainedTransferListener());
|
||||
repositorySystemSession.setRepositoryListener(new ChainedRepositoryListener());
|
||||
}
|
||||
@@ -81,9 +61,7 @@ public class RepositorySystemFactory {
|
||||
String userName, String password, String groupId, String artifactId, String classifier, String extension,
|
||||
String version) throws Exception {
|
||||
DefaultRepositorySystemSession session = null;
|
||||
if (system == null) {
|
||||
system = newRepositorySystem();
|
||||
}
|
||||
RepositorySystem system = MavenLibraryResolverProvider.newRepositorySystem();
|
||||
session = newRepositorySystemSession(localRepository);
|
||||
|
||||
DeployRequest deployRequest = new DeployRequest();
|
||||
|
||||
@@ -36,10 +36,11 @@ import org.eclipse.aether.artifact.Artifact;
|
||||
import org.eclipse.aether.artifact.DefaultArtifact;
|
||||
import org.eclipse.aether.collection.CollectRequest;
|
||||
import org.eclipse.aether.collection.DependencySelector;
|
||||
import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory;
|
||||
import org.eclipse.aether.graph.DefaultDependencyNode;
|
||||
import org.eclipse.aether.graph.Exclusion;
|
||||
import org.eclipse.aether.impl.DefaultServiceLocator;
|
||||
import org.eclipse.aether.internal.transport.wagon.PlexusWagonConfigurator;
|
||||
import org.eclipse.aether.internal.transport.wagon.PlexusWagonProvider;
|
||||
import org.eclipse.aether.repository.Authentication;
|
||||
import org.eclipse.aether.repository.LocalRepository;
|
||||
import org.eclipse.aether.repository.RemoteRepository;
|
||||
@@ -48,10 +49,6 @@ import org.eclipse.aether.resolution.ArtifactRequest;
|
||||
import org.eclipse.aether.resolution.ArtifactResult;
|
||||
import org.eclipse.aether.resolution.VersionRangeRequest;
|
||||
import org.eclipse.aether.resolution.VersionRangeResult;
|
||||
import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
|
||||
import org.eclipse.aether.spi.connector.transport.TransporterFactory;
|
||||
import org.eclipse.aether.transport.file.FileTransporterFactory;
|
||||
import org.eclipse.aether.transport.http.HttpTransporterFactory;
|
||||
import org.eclipse.aether.util.artifact.JavaScopes;
|
||||
import org.eclipse.aether.util.graph.selector.AndDependencySelector;
|
||||
import org.eclipse.aether.util.graph.selector.OptionalDependencySelector;
|
||||
@@ -111,11 +108,11 @@ public class DynamicDistributionAetherUtils {
|
||||
|
||||
RepositorySystem repoSystem = null;
|
||||
if (multiThread) {
|
||||
repoSystem = newRepositorySystem();
|
||||
repoSystem = MavenLibraryResolverProvider.newRepositorySystemForResolver();
|
||||
} else {
|
||||
repoSystem = repoSystemMap.get(key);
|
||||
if (repoSystem == null) {
|
||||
repoSystem = newRepositorySystem();
|
||||
repoSystem = MavenLibraryResolverProvider.newRepositorySystemForResolver();
|
||||
repoSystemMap.put(key, repoSystem);
|
||||
}
|
||||
}
|
||||
@@ -283,7 +280,7 @@ public class DynamicDistributionAetherUtils {
|
||||
if (monitor == null) {
|
||||
monitor = new DummyDynamicMonitor();
|
||||
}
|
||||
RepositorySystem repSystem = newRepositorySystem();
|
||||
RepositorySystem repSystem = MavenLibraryResolverProvider.newRepositorySystemForResolver();
|
||||
RepositorySystemSession repSysSession = newSession(repSystem, localPath, monitor);
|
||||
updateDependencySelector((DefaultRepositorySystemSession) repSysSession, monitor);
|
||||
|
||||
@@ -329,7 +326,7 @@ public class DynamicDistributionAetherUtils {
|
||||
if (monitor == null) {
|
||||
monitor = new DummyDynamicMonitor();
|
||||
}
|
||||
RepositorySystem repSystem = newRepositorySystem();
|
||||
RepositorySystem repSystem = MavenLibraryResolverProvider.newRepositorySystemForResolver();
|
||||
RepositorySystemSession repSysSession = newSession(repSystem, localPath, monitor);
|
||||
updateDependencySelector((DefaultRepositorySystemSession) repSysSession, monitor);
|
||||
|
||||
@@ -411,15 +408,6 @@ public class DynamicDistributionAetherUtils {
|
||||
// }
|
||||
// }
|
||||
|
||||
private static RepositorySystem newRepositorySystem() {
|
||||
DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
|
||||
locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
|
||||
locator.addService(TransporterFactory.class, FileTransporterFactory.class);
|
||||
locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
|
||||
|
||||
return locator.getService(RepositorySystem.class);
|
||||
}
|
||||
|
||||
private static RepositorySystemSession newSession(RepositorySystem system, String repositoryPath, IDynamicMonitor monitor)
|
||||
throws CoreException {
|
||||
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
|
||||
|
||||
@@ -18,6 +18,12 @@ import java.util.Map;
|
||||
import org.apache.maven.model.License;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
|
||||
import org.apache.maven.wagon.Wagon;
|
||||
import org.apache.maven.wagon.providers.file.FileWagon;
|
||||
import org.apache.maven.wagon.providers.http.HttpWagon;
|
||||
import org.codehaus.plexus.DefaultPlexusContainer;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.PlexusContainerException;
|
||||
import org.eclipse.aether.DefaultRepositorySystemSession;
|
||||
import org.eclipse.aether.RepositorySystem;
|
||||
import org.eclipse.aether.RepositorySystemSession;
|
||||
@@ -25,6 +31,8 @@ import org.eclipse.aether.artifact.Artifact;
|
||||
import org.eclipse.aether.artifact.DefaultArtifact;
|
||||
import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory;
|
||||
import org.eclipse.aether.impl.DefaultServiceLocator;
|
||||
import org.eclipse.aether.internal.transport.wagon.PlexusWagonConfigurator;
|
||||
import org.eclipse.aether.internal.transport.wagon.PlexusWagonProvider;
|
||||
import org.eclipse.aether.repository.Authentication;
|
||||
import org.eclipse.aether.repository.LocalRepository;
|
||||
import org.eclipse.aether.repository.RemoteRepository;
|
||||
@@ -34,6 +42,7 @@ import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
|
||||
import org.eclipse.aether.spi.connector.transport.TransporterFactory;
|
||||
import org.eclipse.aether.transport.file.FileTransporterFactory;
|
||||
import org.eclipse.aether.transport.http.HttpTransporterFactory;
|
||||
import org.eclipse.aether.transport.wagon.WagonTransporterFactory;
|
||||
import org.eclipse.aether.util.repository.AuthenticationBuilder;
|
||||
import org.eclipse.m2e.core.MavenPlugin;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
@@ -70,8 +79,8 @@ public class MavenLibraryResolverProvider {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private MavenLibraryResolverProvider() {
|
||||
defaultRepoSystem = newRepositorySystem();
|
||||
private MavenLibraryResolverProvider() throws PlexusContainerException {
|
||||
defaultRepoSystem = newRepositorySystemForResolver();
|
||||
defaultRepoSystemSession = newSession(defaultRepoSystem, getLocalMVNRepository());
|
||||
ArtifactRepositoryBean talendServer = TalendLibsServerManager.getInstance().getTalentArtifactServer();
|
||||
if (talendServer.getUserName() == null && talendServer.getPassword() == null) {
|
||||
@@ -146,12 +155,44 @@ public class MavenLibraryResolverProvider {
|
||||
return repository;
|
||||
}
|
||||
|
||||
private RepositorySystem newRepositorySystem() {
|
||||
public static RepositorySystem newRepositorySystem() throws PlexusContainerException {
|
||||
DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
|
||||
locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
|
||||
// TUP-24695 change to wagon transporters
|
||||
locator.addService(TransporterFactory.class, WagonTransporterFactory.class);
|
||||
|
||||
PlexusContainer pc = new DefaultPlexusContainer();
|
||||
|
||||
pc.addComponent(new HttpWagon(), Wagon.class, "http");
|
||||
pc.addComponent(new FileWagon(), Wagon.class, "file");
|
||||
|
||||
WagonTransporterFactory tf = (WagonTransporterFactory) locator.getService(TransporterFactory.class);
|
||||
tf.setWagonConfigurator(new PlexusWagonConfigurator(pc));
|
||||
tf.setWagonProvider(new PlexusWagonProvider(pc));
|
||||
|
||||
locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
|
||||
|
||||
@Override
|
||||
public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
});
|
||||
return locator.getService(RepositorySystem.class);
|
||||
}
|
||||
|
||||
public static RepositorySystem newRepositorySystemForResolver() {
|
||||
DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
|
||||
locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
|
||||
locator.addService(TransporterFactory.class, FileTransporterFactory.class);
|
||||
locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
|
||||
|
||||
locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
|
||||
|
||||
@Override
|
||||
public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
});
|
||||
return locator.getService(RepositorySystem.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<tcomp.version>1.1.10</tcomp.version>
|
||||
<tcomp.version>1.1.14</tcomp.version>
|
||||
<slf4j.version>1.7.25</slf4j.version>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -198,7 +198,6 @@ public class M2eUserSettingForTalendLoginTask extends AbstractLoginTask {
|
||||
// add one marker to check to sync or not.
|
||||
File repoFolder = new File(maven.getLocalRepositoryPath());
|
||||
File markerFile = new File(repoFolder, ".syncMarker"); //$NON-NLS-1$
|
||||
System.setProperty("m2.syncmarker.path", markerFile.getAbsolutePath()); //$NON-NLS-1$
|
||||
Properties prop = new Properties();
|
||||
FileInputStream inStream = null;
|
||||
FileOutputStream outputStream = null;
|
||||
@@ -295,20 +294,25 @@ public class M2eUserSettingForTalendLoginTask extends AbstractLoginTask {
|
||||
boolean isLocal = isLocalRepository();
|
||||
IPath localRepoPath = null;
|
||||
if (!isLocal) {
|
||||
String mvnHome = System.getenv("M2_HOME"); //$NON-NLS-1$
|
||||
if (mvnHome == null) {
|
||||
mvnHome = System.getenv("MAVEN_HOME"); //$NON-NLS-1$
|
||||
}
|
||||
if (StringUtils.isNotBlank(mvnHome)) {
|
||||
File globalSettings = new File(mvnHome).toPath().resolve("conf").resolve("settings.xml").toFile(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (globalSettings.exists()) {
|
||||
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
Document document = builder.parse(globalSettings);
|
||||
Node node = document.getElementsByTagName("localRepository").item(0); //$NON-NLS-1$
|
||||
if (node != null) {
|
||||
String repoPath = node.getTextContent();
|
||||
if (StringUtils.isNotBlank(repoPath)) {
|
||||
localRepoPath = new Path(repoPath);
|
||||
String customMavenRepoistory = System.getProperty("maven.local.repository");
|
||||
if (customMavenRepoistory != null) {
|
||||
localRepoPath = new Path(customMavenRepoistory);
|
||||
} else {
|
||||
String mvnHome = System.getenv("M2_HOME"); //$NON-NLS-1$
|
||||
if (mvnHome == null) {
|
||||
mvnHome = System.getenv("MAVEN_HOME"); //$NON-NLS-1$
|
||||
}
|
||||
if (StringUtils.isNotBlank(mvnHome)) {
|
||||
File globalSettings = new File(mvnHome).toPath().resolve("conf").resolve("settings.xml").toFile(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (globalSettings.exists()) {
|
||||
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
Document document = builder.parse(globalSettings);
|
||||
Node node = document.getElementsByTagName("localRepository").item(0); //$NON-NLS-1$
|
||||
if (node != null) {
|
||||
String repoPath = node.getTextContent();
|
||||
if (StringUtils.isNotBlank(repoPath)) {
|
||||
localRepoPath = new Path(repoPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import static org.talend.designer.maven.model.TalendJavaProjectConstants.*;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -74,6 +75,7 @@ import org.talend.core.runtime.services.IFilterService;
|
||||
import org.talend.core.ui.ITestContainerProviderService;
|
||||
import org.talend.designer.core.ICamelDesignerCoreService;
|
||||
import org.talend.designer.maven.launch.MavenPomCommandLauncher;
|
||||
import org.talend.designer.maven.model.MavenSystemFolders;
|
||||
import org.talend.designer.maven.model.TalendJavaProjectConstants;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.template.MavenTemplateManager;
|
||||
@@ -111,9 +113,6 @@ public class AggregatorPomsHelper {
|
||||
throws Exception {
|
||||
IFile pomFile = getProjectRootPom();
|
||||
if (force || !pomFile.exists()) {
|
||||
if (model == null) {
|
||||
model = getCodeProjectTemplateModel();
|
||||
}
|
||||
PomUtil.savePom(monitor, model, pomFile);
|
||||
}
|
||||
}
|
||||
@@ -124,8 +123,7 @@ public class AggregatorPomsHelper {
|
||||
if (pomFile != null && pomFile.exists()) {
|
||||
Model oldModel = MavenPlugin.getMavenModelManager().readMavenModel(pomFile);
|
||||
List<Profile> profiles = oldModel.getProfiles().stream()
|
||||
.filter(profile -> StringUtils.startsWithIgnoreCase(profile.getId(), projectTechName))
|
||||
.collect(Collectors.toList());
|
||||
.filter(profile -> matchModuleProfile(profile.getId(), projectTechName)).collect(Collectors.toList());
|
||||
newModel.setModules(oldModel.getModules());
|
||||
newModel.getProfiles().addAll(profiles);
|
||||
}
|
||||
@@ -298,11 +296,12 @@ public class AggregatorPomsHelper {
|
||||
if (PomIdsHelper.useProfileModule()) {
|
||||
List<Profile> profiles = collectRefProjectProfiles(references);
|
||||
Iterator<Profile> iterator = model.getProfiles().listIterator();
|
||||
iterator.forEachRemaining(profile -> {
|
||||
if (StringUtils.startsWithIgnoreCase(profile.getId(), projectTechName)) {
|
||||
while (iterator.hasNext()) {
|
||||
Profile profile = iterator.next();
|
||||
if (matchModuleProfile(profile.getId(), projectTechName)) {
|
||||
iterator.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
model.getProfiles().addAll(profiles);
|
||||
} else {
|
||||
List<String> refPrjectModules = new ArrayList<>();
|
||||
@@ -313,11 +312,12 @@ public class AggregatorPomsHelper {
|
||||
});
|
||||
List<String> modules = model.getModules();
|
||||
Iterator<String> iterator = modules.listIterator();
|
||||
iterator.forEachRemaining(modulePath -> {
|
||||
while (iterator.hasNext()) {
|
||||
String modulePath = iterator.next();
|
||||
if (modulePath.startsWith("../../")) { //$NON-NLS-1$
|
||||
iterator.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
modules.addAll(refPrjectModules);
|
||||
}
|
||||
createRootPom(model, true, monitor);
|
||||
@@ -494,6 +494,10 @@ public class AggregatorPomsHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
public IFolder getCodeSrcFolder(ERepositoryObjectType codeType) {
|
||||
return getCodeFolder(codeType).getFolder(MavenSystemFolders.JAVA.getPath());
|
||||
}
|
||||
|
||||
public IFolder getProcessFolder(ERepositoryObjectType type) {
|
||||
return getProjectPomsFolder().getFolder(DIR_JOBS).getFolder(type.getFolder());
|
||||
}
|
||||
@@ -714,7 +718,7 @@ public class AggregatorPomsHelper {
|
||||
if (!needUpdateRefProjectModules()) {
|
||||
Model model = MavenPlugin.getMavenModelManager().readMavenModel(getProjectRootPom());
|
||||
List<Profile> profiles = model.getProfiles();
|
||||
return profiles.stream().filter(profile -> StringUtils.startsWithIgnoreCase(profile.getId(), projectTechName))
|
||||
return profiles.stream().filter(profile -> matchModuleProfile(profile.getId(), projectTechName))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
if (references == null) {
|
||||
@@ -789,7 +793,13 @@ public class AggregatorPomsHelper {
|
||||
monitor.beginTask("", size); //$NON-NLS-1$
|
||||
// project pom
|
||||
monitor.subTask("Synchronize project pom"); //$NON-NLS-1$
|
||||
createRootPom(null, true, monitor);
|
||||
Model model = getCodeProjectTemplateModel();
|
||||
if (PomIdsHelper.useProfileModule()) {
|
||||
model.getProfiles().addAll(collectRefProjectProfiles(null));
|
||||
} else {
|
||||
model.getModules().addAll(collectRefProjectModules(null));
|
||||
}
|
||||
createRootPom(model, true, monitor);
|
||||
installRootPom(true);
|
||||
monitor.worked(1);
|
||||
if (monitor.isCanceled()) {
|
||||
@@ -843,13 +853,7 @@ public class AggregatorPomsHelper {
|
||||
// sync project pom again with all modules.
|
||||
monitor.subTask("Synchronize project pom with modules"); //$NON-NLS-1$
|
||||
collectCodeModules(modules);
|
||||
Model model = getCodeProjectTemplateModel();
|
||||
if (PomIdsHelper.useProfileModule()) {
|
||||
model.getProfiles().addAll(collectRefProjectProfiles(null));
|
||||
} else {
|
||||
modules.addAll(collectRefProjectModules(null));
|
||||
}
|
||||
model.setModules(modules);
|
||||
model.getModules().addAll(modules);
|
||||
createRootPom(model, true, monitor);
|
||||
installRootPom(true);
|
||||
monitor.worked(1);
|
||||
@@ -908,6 +912,12 @@ public class AggregatorPomsHelper {
|
||||
return MavenTemplateManager.getCodeProjectTemplateModel(parameters);
|
||||
}
|
||||
|
||||
public static boolean matchModuleProfile(String profileId, String projectTechName) {
|
||||
// FIXME get profile id from extension point.
|
||||
List<String> otherProfiles = Arrays.asList("docker", "cloud-publisher", "nexus"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
return !otherProfiles.contains(profileId) && StringUtils.startsWithIgnoreCase(profileId, projectTechName + "_");
|
||||
}
|
||||
|
||||
private static IRunProcessService getRunProcessService() {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
IRunProcessService runProcessService =
|
||||
|
||||
@@ -167,6 +167,7 @@ public class ProcessorDependenciesManager {
|
||||
if (modulesNeeded.isEmpty()) {
|
||||
modulesNeeded = processor.getNeededModules(TalendProcessOptionConstants.MODULES_WITH_JOBLET);
|
||||
}
|
||||
processor.updateModulesAfterSetLog4j(modulesNeeded);
|
||||
neededLibraries.addAll(modulesNeeded);
|
||||
|
||||
// add testcase modules
|
||||
|
||||
@@ -69,13 +69,7 @@ public class ProjectPomManager {
|
||||
if (monitor == null) {
|
||||
monitor = new NullProgressMonitor();
|
||||
}
|
||||
Model projectModel = MODEL_MANAGER.readMavenModel(projectPomFile);
|
||||
Model templateModel = MavenTemplateManager.getCodeProjectTemplateModel();
|
||||
for (String module : projectModel.getModules()) {
|
||||
templateModel.addModule(module);
|
||||
}
|
||||
|
||||
PomUtil.savePom(monitor, templateModel, projectPomFile);
|
||||
new AggregatorPomsHelper().createRootPom(monitor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -220,6 +220,29 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
|
||||
MavenArtifact mvnArtifact = MavenUrlHelper.parseMvnUrl(module.getMavenUri());
|
||||
include.setValue(mvnArtifact.getGroupId() + ":" + mvnArtifact.getArtifactId()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
//removing digital signatures from uber jar
|
||||
Xpp3Dom filters = new Xpp3Dom("filters"); //$NON-NLS-1$
|
||||
Xpp3Dom filter = new Xpp3Dom("filter"); //$NON-NLS-1$
|
||||
Xpp3Dom artifact = new Xpp3Dom("artifact"); //$NON-NLS-1$
|
||||
artifact.setValue("*:*");
|
||||
Xpp3Dom filterExcludes = new Xpp3Dom("excludes"); //$NON-NLS-1$
|
||||
Xpp3Dom excludeSF = new Xpp3Dom("exclude");
|
||||
excludeSF.setValue("META-INF/*.SF");
|
||||
Xpp3Dom excludeDSA = new Xpp3Dom("exclude");
|
||||
excludeDSA.setValue("META-INF/*.DSA");
|
||||
Xpp3Dom excludeRSA = new Xpp3Dom("exclude");
|
||||
excludeRSA.setValue("META-INF/*.RSA");
|
||||
|
||||
filterExcludes.addChild(excludeSF);
|
||||
filterExcludes.addChild(excludeDSA);
|
||||
filterExcludes.addChild(excludeRSA);
|
||||
|
||||
filter.addChild(artifact);
|
||||
filter.addChild(filterExcludes);
|
||||
filters.addChild(filter);
|
||||
configuration.addChild(filters);
|
||||
|
||||
plugins.add(shade);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,11 +152,13 @@ public class CreateMavenStandardJobOSGiPom extends CreateMavenJobPom {
|
||||
model.addProperty("talend.job.finalName", "${talend.job.name}-bundle-${project.version}");
|
||||
Build build = model.getBuild();
|
||||
|
||||
IESBService service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
|
||||
IESBService service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
|
||||
|
||||
if (isServiceOperation || service.isRESTService((ProcessItem) getJobProcessor().getProperty().getItem())
|
||||
|| isRouteOperation(getJobProcessor().getProperty())) {
|
||||
build.addPlugin(addSkipDockerMavenPlugin());
|
||||
if (isServiceOperation || service.isRESTService((ProcessItem) getJobProcessor().getProperty().getItem())
|
||||
|| isRouteOperation(getJobProcessor().getProperty())) {
|
||||
build.addPlugin(addSkipDockerMavenPlugin());
|
||||
}
|
||||
}
|
||||
|
||||
if (isServiceOperation) {
|
||||
@@ -283,25 +285,25 @@ public class CreateMavenStandardJobOSGiPom extends CreateMavenJobPom {
|
||||
List<IRepositoryViewObject> serviceRepoList = null;
|
||||
|
||||
boolean isDataServiceOperation = false;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
|
||||
IESBService service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
|
||||
try {
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
serviceRepoList = factory.getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, "SERVICES"));
|
||||
|
||||
IESBService service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
|
||||
|
||||
try {
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
serviceRepoList = factory.getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, "SERVICES"));
|
||||
|
||||
for (IRepositoryViewObject serviceItem : serviceRepoList) {
|
||||
if (service != null) {
|
||||
List<String> jobIds = service.getSerivceRelatedJobIds(serviceItem.getProperty().getItem());
|
||||
if (jobIds.contains(property.getId())) {
|
||||
isDataServiceOperation = true;
|
||||
break;
|
||||
for (IRepositoryViewObject serviceItem : serviceRepoList) {
|
||||
if (service != null) {
|
||||
List<String> jobIds = service.getSerivceRelatedJobIds(serviceItem.getProperty().getItem());
|
||||
if (jobIds.contains(property.getId())) {
|
||||
isDataServiceOperation = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
return isDataServiceOperation;
|
||||
@@ -311,32 +313,33 @@ public class CreateMavenStandardJobOSGiPom extends CreateMavenJobPom {
|
||||
List<IRepositoryViewObject> routeRepoList = null;
|
||||
|
||||
boolean isRouteOperation = false;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
|
||||
|
||||
IESBService service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
|
||||
IESBService service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
|
||||
|
||||
try {
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
routeRepoList = factory.getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, "ROUTE"));
|
||||
try {
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
routeRepoList = factory.getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, "ROUTE"));
|
||||
|
||||
for (IRepositoryViewObject routeItem : routeRepoList) {
|
||||
if (service != null) {
|
||||
for (IRepositoryViewObject routeItem : routeRepoList) {
|
||||
if (service != null) {
|
||||
|
||||
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(routeItem.getId(),
|
||||
routeItem.getVersion(), RelationshipItemBuilder.JOB_RELATION);
|
||||
for (Relation relation : relations) {
|
||||
if (relation.getType() == RelationshipItemBuilder.JOB_RELATION) {
|
||||
if (relation.getId().equals(property.getId())) {
|
||||
isRouteOperation = true;
|
||||
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(routeItem.getId(),
|
||||
routeItem.getVersion(), RelationshipItemBuilder.JOB_RELATION);
|
||||
for (Relation relation : relations) {
|
||||
if (relation.getType() == RelationshipItemBuilder.JOB_RELATION) {
|
||||
if (relation.getId().equals(property.getId())) {
|
||||
isRouteOperation = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
return isRouteOperation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +116,10 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
|
||||
private String defaultURIValue = "";
|
||||
|
||||
private Set<String> jarsAvailable;
|
||||
|
||||
private boolean useCustom = false;
|
||||
|
||||
private String customURI = null;
|
||||
|
||||
/**
|
||||
* DOC wchen InstallModuleDialog constructor comment.
|
||||
@@ -553,11 +557,13 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
|
||||
layoutWarningComposite(false, defaultUriTxt.getText());
|
||||
if (useCustomBtn.getSelection()) {
|
||||
customUriText.setEnabled(true);
|
||||
useCustom = true;
|
||||
if ("".equals(customUriText.getText())) {
|
||||
customUriText.setText(ModuleMavenURIUtils.MVNURI_TEMPLET);
|
||||
}
|
||||
} else {
|
||||
customUriText.setEnabled(false);
|
||||
useCustom = false;
|
||||
}
|
||||
checkFieldsError();
|
||||
}
|
||||
@@ -807,7 +813,6 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
|
||||
@Override
|
||||
protected void okPressed() {
|
||||
String originalURI = null;
|
||||
String customURI = null;
|
||||
originalURI = defaultUriTxt.getText().trim();
|
||||
defaultURI = originalURI;
|
||||
if (useCustomBtn.getSelection()) {
|
||||
@@ -889,6 +894,9 @@ public class ConfigModuleDialog extends TitleAreaDialog implements IConfigModule
|
||||
*/
|
||||
@Override
|
||||
public String getMavenURI() {
|
||||
if (useCustom && customURI != null) {
|
||||
return customURI;
|
||||
}
|
||||
return defaultURI;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -5,6 +5,8 @@
|
||||
// ============================================================================
|
||||
package routines;
|
||||
|
||||
import routines.system.RandomUtils;
|
||||
|
||||
public class Mathematical {
|
||||
|
||||
/**
|
||||
@@ -284,7 +286,7 @@ public class Mathematical {
|
||||
*
|
||||
*/
|
||||
public static double LN(double a) {
|
||||
return Math.log(a) / Math.E;
|
||||
return Math.log(a);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -381,7 +383,7 @@ public class Mathematical {
|
||||
*
|
||||
*/
|
||||
public static double RND(double a) {
|
||||
return Math.random() * a;
|
||||
return RandomUtils.random() * a;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,8 @@ package routines;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import routines.system.RandomUtils;
|
||||
|
||||
public class Numeric {
|
||||
|
||||
private static final java.util.Map<String, Integer> seq_Hash = new ConcurrentHashMap<>();
|
||||
@@ -88,7 +90,7 @@ public class Numeric {
|
||||
if (max < min) {
|
||||
throw new RuntimeException("Max value should be bigger than min value");
|
||||
}
|
||||
return ((Long) Math.round(min - 0.5 + (Math.random() * (max - min + 1)))).intValue();
|
||||
return ((Long) Math.round(min - 0.5 + (RandomUtils.random() * (max - min + 1)))).intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// ============================================================================
|
||||
package routines;
|
||||
|
||||
import routines.system.RandomUtils;
|
||||
|
||||
public class TalendDataGenerator {
|
||||
|
||||
/**
|
||||
@@ -18,7 +20,7 @@ public class TalendDataGenerator {
|
||||
String[] list = { "Abraham", "Andrew", "Benjamin", "Bill", "Calvin", "Chester", "Dwight", "Franklin", "George", "Gerald", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||
"Grover", "Harry", "Herbert", "James", "Jimmy", "John", "Lyndon", "Martin", "Millard", "Richard", "Ronald", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$
|
||||
"Rutherford", "Theodore", "Thomas", "Ulysses", "Warren", "William", "Woodrow", "Zachary" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
|
||||
Integer random = 0 + ((Long) Math.round(Math.random() * (list.length - 1 - 0))).intValue();
|
||||
Integer random = 0 + ((Long) Math.round(RandomUtils.random() * (list.length - 1 - 0))).intValue();
|
||||
return list[random];
|
||||
}
|
||||
|
||||
@@ -35,7 +37,7 @@ public class TalendDataGenerator {
|
||||
"Madison", "Monroe", "Carter", "Adams", "Kennedy", "Quincy", "Adams", "Tyler", "Johnson", "Van Buren", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||
"Fillmore", "Nixon", "Reagan", "Hayes", "Roosevelt", "Jefferson", "Grant", "Harding", "Harrison", "Taft", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||
"McKinley", "Wilson", "Taylor" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
Integer random = 0 + ((Long) Math.round(Math.random() * (list.length - 1 - 0))).intValue();
|
||||
Integer random = 0 + ((Long) Math.round(RandomUtils.random() * (list.length - 1 - 0))).intValue();
|
||||
return list[random];
|
||||
}
|
||||
|
||||
@@ -60,7 +62,7 @@ public class TalendDataGenerator {
|
||||
"San Simeon", "San Ysidro Blvd", "Santa Ana Freeway", "Santa Monica Road", "Santa Rosa North", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
||||
"Santa Rosa South", "South Highway", "South Roosevelt Drive", "Steele Lane", "Tanger Blvd", "Timberlane Drive", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
|
||||
"Tully Road East", "Via Real", "W. Russell St.", "Westside Freeway", "Woodson Rd." }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
||||
Integer random = 0 + ((Long) Math.round(Math.random() * (list.length - 1 - 0))).intValue();
|
||||
Integer random = 0 + ((Long) Math.round(RandomUtils.random() * (list.length - 1 - 0))).intValue();
|
||||
return list[random];
|
||||
}
|
||||
|
||||
@@ -78,7 +80,7 @@ public class TalendDataGenerator {
|
||||
"Saint Paul", "Jackson", "Jefferson City", "Helena", "Lincoln", "Carson City", "Concord", "Trenton", "Santa Fe", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
|
||||
"Albany", "Columbus", "Oklahoma City", "Salem", "Harrisburg", "Providence", "Nashville", "Austin", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
|
||||
"Salt Lake City", "Montpelier", "Richmond", "Charleston", "Olympia", "Madison", "Cheyenne" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
|
||||
Integer random = 0 + ((Long) Math.round(Math.random() * (list.length - 1 - 0))).intValue();
|
||||
Integer random = 0 + ((Long) Math.round(RandomUtils.random() * (list.length - 1 - 0))).intValue();
|
||||
return list[random];
|
||||
}
|
||||
|
||||
@@ -96,7 +98,7 @@ public class TalendDataGenerator {
|
||||
"Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
|
||||
"New Jersey", "New Mexico", "New York", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
|
||||
"Tennessee", "Texas", "Utah", "Vermont", "Virginia", "West Virginia", "Washington", "Wisconsin", "Wyoming" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
|
||||
Integer random = 0 + ((Long) Math.round(Math.random() * (list.length - 1 - 0))).intValue();
|
||||
Integer random = 0 + ((Long) Math.round(RandomUtils.random() * (list.length - 1 - 0))).intValue();
|
||||
return list[random];
|
||||
}
|
||||
|
||||
@@ -111,7 +113,7 @@ public class TalendDataGenerator {
|
||||
String[] list = { "AL", "AK", "AZ", "AR", "CA", "NC", "SC", "CO", "CT", "ND", "SD", "DE", "FL", "GA", "HI", "ID", "IL", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$
|
||||
"IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ //$NON-NLS-18$ //$NON-NLS-19$
|
||||
"OH", "OK", "OR", "PA", "RI", "TN", "TX", "UT", "VT", "VA", "WV", "WA", "WI", "WY" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$
|
||||
Integer random = 0 + ((Long) Math.round(Math.random() * (list.length - 1 - 0))).intValue();
|
||||
Integer random = 0 + ((Long) Math.round(RandomUtils.random() * (list.length - 1 - 0))).intValue();
|
||||
return list[random];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.util.TimeZone;
|
||||
|
||||
import routines.system.FastDateParser;
|
||||
import routines.system.LocaleProvider;
|
||||
import routines.system.RandomUtils;
|
||||
import routines.system.TalendTimestampWithTZ;
|
||||
|
||||
public class TalendDate {
|
||||
@@ -1147,7 +1148,7 @@ public class TalendDate {
|
||||
maxCal.set(Calendar.DAY_OF_MONTH, maxDay);
|
||||
|
||||
long random = minCal.getTimeInMillis()
|
||||
+ (long) ((maxCal.getTimeInMillis() - minCal.getTimeInMillis() + 1) * Math.random());
|
||||
+ (long) ((maxCal.getTimeInMillis() - minCal.getTimeInMillis() + 1) * RandomUtils.random());
|
||||
return new Date(random);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,28 +14,23 @@ package routines.system;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class GlobalResource {
|
||||
|
||||
// let it support the top level Object
|
||||
public static Map<Object, Object> resourceMap = new HashMap<Object, Object>();
|
||||
// let it support the top level Object
|
||||
public static Map<Object, Object> resourceMap = new HashMap<Object, Object>();
|
||||
|
||||
// when there is multiple threads wants to insert stats&logs&meta into DB, it is used as a locker. bug:22677
|
||||
public static TalendMultiThreadLockMap resourceLockMap = new TalendMultiThreadLockMap();
|
||||
// when there is multiple threads wants to insert stats&logs&meta into DB, it is
|
||||
// used as a locker. bug:22677
|
||||
public static TalendMultiThreadLockMap resourceLockMap = new TalendMultiThreadLockMap();
|
||||
|
||||
public static class TalendMultiThreadLockMap {
|
||||
public static class TalendMultiThreadLockMap {
|
||||
|
||||
private Map<Object, Object> tMultiTheadLockMap = new HashMap<Object, Object>();
|
||||
private Map<Object, Object> tMultiTheadLockMap = new ConcurrentHashMap<>();
|
||||
|
||||
public Object get(Object key) {
|
||||
if (tMultiTheadLockMap.get(key) == null) {
|
||||
synchronized (TalendMultiThreadLockMap.this) {
|
||||
if (tMultiTheadLockMap.get(key) == null) {
|
||||
tMultiTheadLockMap.put(key, new Object());
|
||||
}
|
||||
}
|
||||
}
|
||||
return tMultiTheadLockMap.get(key);
|
||||
}
|
||||
}
|
||||
public Object get(Object key) {
|
||||
return tMultiTheadLockMap.computeIfAbsent(key, k -> new Object());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,21 +21,24 @@ import org.talend.daikon.crypto.KeySources;
|
||||
*/
|
||||
public class PasswordEncryptUtil {
|
||||
|
||||
public static String ENCRYPT_KEY = "Encrypt"; //$NON-NLS-1$
|
||||
public static final String ENCRYPT_KEY = "Encrypt"; //$NON-NLS-1$
|
||||
|
||||
private static final String ENCRYPTION_KEY = "Talend_TalendKey";
|
||||
|
||||
public static String PREFIX_PASSWORD = "ENC:["; //$NON-NLS-1$
|
||||
private static final String PREFIX_PASSWORD = "ENC:["; //$NON-NLS-1$
|
||||
|
||||
public static String POSTFIX_PASSWORD = "]"; //$NON-NLS-1$
|
||||
private static final String POSTFIX_PASSWORD = "]"; //$NON-NLS-1$
|
||||
|
||||
private static Encryption defaultEncryption;
|
||||
private static final Encryption ENCRYPTION = new Encryption(KeySources.fixedKey(ENCRYPTION_KEY), CipherSources.getDefault());
|
||||
|
||||
private PasswordEncryptUtil() {
|
||||
}
|
||||
|
||||
public static String encryptPassword(String input) throws Exception {
|
||||
if (input == null) {
|
||||
return input;
|
||||
}
|
||||
return PREFIX_PASSWORD + getEncryption().encrypt(input) + POSTFIX_PASSWORD;
|
||||
return PREFIX_PASSWORD + ENCRYPTION.encrypt(input) + POSTFIX_PASSWORD;
|
||||
}
|
||||
|
||||
public static String decryptPassword(String input) {
|
||||
@@ -44,7 +47,7 @@ public class PasswordEncryptUtil {
|
||||
}
|
||||
if (input.startsWith(PREFIX_PASSWORD) && input.endsWith(POSTFIX_PASSWORD)) {
|
||||
try {
|
||||
return getEncryption()
|
||||
return ENCRYPTION
|
||||
.decrypt(input.substring(PREFIX_PASSWORD.length(), input.length() - POSTFIX_PASSWORD.length()));
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
@@ -53,13 +56,6 @@ public class PasswordEncryptUtil {
|
||||
return input;
|
||||
}
|
||||
|
||||
private static Encryption getEncryption() {
|
||||
if (defaultEncryption == null) {
|
||||
defaultEncryption = new Encryption(KeySources.fixedKey(ENCRYPTION_KEY), CipherSources.aes());
|
||||
}
|
||||
return defaultEncryption;
|
||||
}
|
||||
|
||||
public static final String PASSWORD_FOR_LOGS_VALUE = "...";
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package routines.system;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
|
||||
public class RandomUtils {
|
||||
|
||||
//lazy init, but no meaning now as only one method
|
||||
private static final class RandomNumberGeneratorHolder {
|
||||
static final SecureRandom randomNumberGenerator = new SecureRandom();
|
||||
}
|
||||
|
||||
public static double random() {
|
||||
return RandomNumberGeneratorHolder.randomNumberGenerator.nextDouble();
|
||||
}
|
||||
}
|
||||
@@ -502,6 +502,13 @@ public class RunStat implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TBD-9420 fix
|
||||
*/
|
||||
public synchronized void log(String iterateId, int mode, int nbLine, String connectionUniqueName) {
|
||||
log(connectionUniqueName+iterateId, mode, nbLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* work for avoiding the 65535 issue
|
||||
*/
|
||||
|
||||
@@ -403,8 +403,25 @@ public class StringUtils {
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* check if string contains search string case-insensitivity
|
||||
* the code is copied from apache commons-lang3 StringUtils and do some adjust to avoid the useless code
|
||||
*/
|
||||
public static boolean containsIgnoreCase(final String str, final String searchStr) {
|
||||
if (str == null || searchStr == null) {
|
||||
return false;
|
||||
}
|
||||
final int len = searchStr.length();
|
||||
final int max = str.length() - len;
|
||||
for (int i = 0; i <= max; i++) {
|
||||
if (str.regionMatches(true, i, searchStr, 0, len)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* return null value not "null" String when obj is null that is the only difference with String.valueOf(Object obj)
|
||||
*
|
||||
|
||||
@@ -706,8 +706,13 @@ public class ModulesNeededProvider {
|
||||
ModuleNeeded toAdd = new ModuleNeeded(context, currentImport.getMODULE(), currentImport.getMESSAGE(),
|
||||
isRequired);
|
||||
toAdd.setMavenUri(currentImport.getMVN());
|
||||
if (!isRequired && "BeanItem".equals(routine.eClass().getName())) {
|
||||
toAdd.getExtraAttributes().put("IS_OSGI_EXCLUDED", Boolean.TRUE);
|
||||
if (!isRequired) {
|
||||
if ("BeanItem".equals(routine.eClass().getName())) {
|
||||
toAdd.getExtraAttributes().put("IS_OSGI_EXCLUDED", Boolean.TRUE);
|
||||
}
|
||||
if ("RoutineItem".equals(routine.eClass().getName())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// toAdd.setStatus(ELibraryInstallStatus.INSTALLED);
|
||||
importNeedsList.add(toAdd);
|
||||
|
||||
@@ -299,6 +299,17 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
return retrieve(testModule, pathToStore, popUp, refresh);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retrieve(String jarNeeded, String mavenUri, String pathToStore, IProgressMonitor... monitorWrap) {
|
||||
ModuleNeeded testModule = new ModuleNeeded("", jarNeeded, "", true);
|
||||
if(mavenUri != null) {
|
||||
testModule.setMavenUri(mavenUri);
|
||||
}
|
||||
boolean refresh = true;
|
||||
return retrieve(testModule, pathToStore, true, refresh);
|
||||
}
|
||||
|
||||
|
||||
private boolean retrieve(ModuleNeeded module, String pathToStore, boolean showDialog, boolean refresh) {
|
||||
String jarNeeded = module.getModuleName();
|
||||
String sourcePath = null;
|
||||
|
||||
@@ -13,9 +13,13 @@
|
||||
package org.talend.librariesmanager.nexus;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Dictionary;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.nexus.IRepositoryArtifactHandler;
|
||||
import org.talend.core.nexus.NexusConstants;
|
||||
@@ -62,10 +66,22 @@ public abstract class AbstractArtifactRepositoryHandler implements IRepositoryAr
|
||||
if (props == null) {
|
||||
props = new Hashtable<String, String>();
|
||||
}
|
||||
String repositories = null;
|
||||
String custom_server = serverBean.getServer();
|
||||
|
||||
String custom_user = serverBean.getUserName();
|
||||
String custom_pass = serverBean.getPassword();
|
||||
try {
|
||||
if (StringUtils.isNotBlank(custom_user)) {
|
||||
custom_user = URLEncoder.encode(custom_user, StandardCharsets.UTF_8.toString());
|
||||
}
|
||||
if (StringUtils.isNotBlank(custom_pass)) {
|
||||
custom_pass = URLEncoder.encode(custom_pass, StandardCharsets.UTF_8.toString());
|
||||
}
|
||||
} catch (UnsupportedEncodingException e1) {
|
||||
throw new RuntimeException(e1);
|
||||
}
|
||||
|
||||
String repositories = null;
|
||||
String custom_server = serverBean.getServer();
|
||||
String release_rep = serverBean.getRepositoryId();
|
||||
String snapshot_rep = serverBean.getSnapshotRepId();
|
||||
if (custom_server.endsWith(NexusConstants.SLASH)) {
|
||||
|
||||
@@ -74,6 +74,16 @@ public class SwitchContextGroupNameImpl implements ISwitchContext {
|
||||
*/
|
||||
@Override
|
||||
public boolean updateContextGroup(ConnectionItem connItem, String selectedContext) {
|
||||
return updateContextGroup(connItem, selectedContext, null);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.model.metadata.builder.database.ISwitchContext#updateContextGroup(org.talend.core.model.
|
||||
* properties .ContextItem, org.talend.core.model.metadata.builder.connection.Connection)
|
||||
*/
|
||||
public boolean updateContextGroup(ConnectionItem connItem, String selectedContext, String originalContext) {
|
||||
if (connItem == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -81,9 +91,9 @@ public class SwitchContextGroupNameImpl implements ISwitchContext {
|
||||
// MOD msjian 2012-2-13 TDQ-4559: make it support file/mdm connection
|
||||
if (con != null) {
|
||||
// TDQ-4559~
|
||||
String oldContextName = con.getContextName();
|
||||
String oldContextName = originalContext == null ? con.getContextName() : originalContext;
|
||||
|
||||
if (!isContextIsValid(selectedContext, con)) {
|
||||
if (!isContextIsValid(selectedContext, oldContextName, con)) {
|
||||
return false;
|
||||
}
|
||||
con.setContextName(selectedContext);
|
||||
@@ -112,8 +122,7 @@ public class SwitchContextGroupNameImpl implements ISwitchContext {
|
||||
* @param selectedContext
|
||||
* @paramconn
|
||||
*/
|
||||
private boolean isContextIsValid(String selectedContext, Connection conn) {
|
||||
String oldContextName = conn.getContextName();
|
||||
private boolean isContextIsValid(String selectedContext, String oldContextName, Connection conn) {
|
||||
boolean retCode = false;
|
||||
if (conn instanceof DatabaseConnection) {
|
||||
EDatabaseTypeName dbType = EDatabaseTypeName.getTypeFromDbType(((DatabaseConnection) conn).getDatabaseType());
|
||||
|
||||
@@ -202,5 +202,19 @@ public interface Connection extends AbstractMetadataObject, DataProvider {
|
||||
* @generated NOT
|
||||
*/
|
||||
String getValue(String value, boolean encrypt);
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Set encryption and decryption functions which will be used inside getValue
|
||||
* </p>
|
||||
* <p>
|
||||
* By default, getValue depends on encrypt/decrypt of {@link org.talend.utils.StudioEncryption}.
|
||||
* </p>
|
||||
*
|
||||
* @generated NOT
|
||||
*/
|
||||
void setEncryptAndDecryptFuncPair(java.util.function.Function<String, String> encrypt,
|
||||
java.util.function.Function<String, String> decrypt);
|
||||
|
||||
} // Connection
|
||||
|
||||
@@ -20,7 +20,8 @@ import org.eclipse.emf.ecore.util.InternalEList;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.metadata.builder.connection.ConnectionPackage;
|
||||
import org.talend.core.model.metadata.builder.connection.QueriesConnection;
|
||||
import org.talend.daikon.security.CryptoHelper;
|
||||
import org.talend.utils.security.StudioEncryption;
|
||||
|
||||
import orgomg.cwm.foundation.softwaredeployment.Component;
|
||||
import orgomg.cwm.foundation.softwaredeployment.DataManager;
|
||||
import orgomg.cwm.foundation.softwaredeployment.DataProvider;
|
||||
@@ -292,6 +293,10 @@ public class ConnectionImpl extends AbstractMetadataObjectImpl implements Connec
|
||||
|
||||
protected boolean readOnly = false;
|
||||
|
||||
private java.util.function.Function<String, String> encrypt;
|
||||
|
||||
private java.util.function.Function<String, String> decrypt;
|
||||
|
||||
/**
|
||||
* <!-- begin-user-doc --> <!-- end-user-doc -->
|
||||
* @generated
|
||||
@@ -1196,11 +1201,24 @@ public class ConnectionImpl extends AbstractMetadataObjectImpl implements Connec
|
||||
*/
|
||||
public String getValue(String value, boolean encrypt) {
|
||||
if (!isContextMode() && value != null && value.length() > 0) {
|
||||
StudioEncryption se = StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM);
|
||||
// Set default encrypt and decrypt methods
|
||||
if (this.encrypt == null) {
|
||||
this.encrypt = (src) -> se.encrypt(src);
|
||||
}
|
||||
if (this.decrypt == null) {
|
||||
this.decrypt = (src) -> {
|
||||
if (src != null && StudioEncryption.hasEncryptionSymbol(src)) {
|
||||
return se.decrypt(src);
|
||||
}
|
||||
return src;
|
||||
};
|
||||
}
|
||||
String newValue = null;
|
||||
if (encrypt) {
|
||||
newValue = CryptoHelper.getDefault().encrypt(value);
|
||||
newValue = this.encrypt.apply(value);
|
||||
} else {
|
||||
newValue = CryptoHelper.getDefault().decrypt(value);
|
||||
newValue = this.decrypt.apply(value);
|
||||
}
|
||||
if (newValue != null) { // if enable to encrypt/decrypt will return the new value.
|
||||
return newValue;
|
||||
@@ -1208,4 +1226,14 @@ public class ConnectionImpl extends AbstractMetadataObjectImpl implements Connec
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @generated NOT
|
||||
*/
|
||||
public void setEncryptAndDecryptFuncPair(java.util.function.Function<String, String> encrypt,
|
||||
java.util.function.Function<String, String> decrypt) {
|
||||
this.encrypt = encrypt;
|
||||
this.decrypt = decrypt;
|
||||
|
||||
}
|
||||
} // ConnectionImpl
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.Priority;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
@@ -43,7 +42,8 @@ import org.talend.cwm.relational.TdColumn;
|
||||
import org.talend.cwm.softwaredeployment.TdSoftwareSystem;
|
||||
import org.talend.cwm.xml.TdXmlElementType;
|
||||
import org.talend.cwm.xml.TdXmlSchema;
|
||||
import org.talend.daikon.security.CryptoHelper;
|
||||
import org.talend.utils.security.CryptoMigrationUtil;
|
||||
import org.talend.utils.security.StudioEncryption;
|
||||
|
||||
import orgomg.cwm.foundation.softwaredeployment.Component;
|
||||
import orgomg.cwm.foundation.softwaredeployment.DataManager;
|
||||
@@ -68,14 +68,6 @@ public class ConnectionHelper {
|
||||
|
||||
public static final String DOT_STRING = "."; //$NON-NLS-1$
|
||||
|
||||
// MOD xqliu 2011-07-04 feature 22201
|
||||
// public static final String PASSPHRASE = "99ZwBDt1L9yMX2ApJx fnv94o99OeHbCGuIHTy22
|
||||
// V9O6cZ2i374fVjdV76VX9g49DG1r3n90hT5c1"; //$NON-NLS-1$
|
||||
|
||||
// ~
|
||||
|
||||
private static Logger log = Logger.getLogger(ConnectionHelper.class);
|
||||
|
||||
/**
|
||||
* Method "createTdDataProvider" creates a data provider with the given name.
|
||||
*
|
||||
@@ -1111,8 +1103,8 @@ public class ConnectionHelper {
|
||||
boolean cleanFromNewWay = false;
|
||||
String originalValue = tempValue;
|
||||
try {
|
||||
tempValue = getDecryptPassword(originalValue);
|
||||
String encryptFromTempValue = getEncryptPassword(tempValue);
|
||||
tempValue = CryptoMigrationUtil.decrypt(originalValue);
|
||||
String encryptFromTempValue = CryptoMigrationUtil.encrypt(tempValue);
|
||||
if (!StringUtils.equals(originalValue, encryptFromTempValue)) {
|
||||
cleanFromNewWay = true;
|
||||
}
|
||||
@@ -1164,7 +1156,7 @@ public class ConnectionHelper {
|
||||
* @return
|
||||
*/
|
||||
public static String getDecryptPassword(String password) {
|
||||
return CryptoHelper.getDefault().decrypt(password);
|
||||
return StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM).decrypt(password);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1174,7 +1166,7 @@ public class ConnectionHelper {
|
||||
* @return
|
||||
*/
|
||||
public static String getEncryptPassword(String password) {
|
||||
return CryptoHelper.getDefault().encrypt(password);
|
||||
return StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM).encrypt(password);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,9 +10,9 @@ import org.eclipse.emf.ecore.EClass;
|
||||
import org.eclipse.emf.ecore.impl.ENotificationImpl;
|
||||
import org.eclipse.emf.ecore.impl.EObjectImpl;
|
||||
import org.talend.commons.utils.PasswordEncryptUtil;
|
||||
import org.talend.daikon.security.CryptoHelper;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.TalendFilePackage;
|
||||
import org.talend.utils.security.StudioEncryption;
|
||||
|
||||
/**
|
||||
* <!-- begin-user-doc --> An implementation of the model object '<em><b>Context Parameter Type</b></em>'. <!--
|
||||
@@ -345,7 +345,7 @@ public class ContextParameterTypeImpl extends EObjectImpl implements ContextPara
|
||||
|
||||
public String getRawValue() {
|
||||
if (value != null && value.length() > 0 && PasswordEncryptUtil.isPasswordType(getType())) {
|
||||
String decryptValue = CryptoHelper.getDefault().decrypt(value);
|
||||
String decryptValue = StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM).decrypt(value);
|
||||
if (decryptValue != null) {
|
||||
return decryptValue;
|
||||
}
|
||||
@@ -366,7 +366,8 @@ public class ContextParameterTypeImpl extends EObjectImpl implements ContextPara
|
||||
|
||||
public void setRawValue(String newValue) {
|
||||
if (newValue != null && newValue.length() > 0 && PasswordEncryptUtil.isPasswordType(getType())) {
|
||||
String encryptValue = CryptoHelper.getDefault().encrypt(newValue);
|
||||
String encryptValue = StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM)
|
||||
.encrypt(newValue);
|
||||
if (encryptValue != null) {
|
||||
setValue(encryptValue);
|
||||
return;
|
||||
|
||||
@@ -17,10 +17,11 @@ import org.eclipse.emf.ecore.impl.EObjectImpl;
|
||||
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
|
||||
import org.eclipse.emf.ecore.util.InternalEList;
|
||||
import org.talend.commons.utils.PasswordEncryptUtil;
|
||||
import org.talend.daikon.security.CryptoHelper;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementValueType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.TalendFilePackage;
|
||||
import org.talend.utils.security.CryptoMigrationUtil;
|
||||
import org.talend.utils.security.StudioEncryption;
|
||||
|
||||
/**
|
||||
* <!-- begin-user-doc --> An implementation of the model object '<em><b>Element Parameter Type</b></em>'. <!--
|
||||
@@ -297,7 +298,14 @@ public class ElementParameterTypeImpl extends EObjectImpl implements ElementPara
|
||||
|
||||
public String getRawValue() {
|
||||
if (value != null && value.length() > 0 && PasswordEncryptUtil.isPasswordField(getField())) {
|
||||
String decrypt = CryptoHelper.getDefault().decrypt(value);
|
||||
String decrypt = null;
|
||||
if (StudioEncryption.hasEncryptionSymbol(value)) {
|
||||
decrypt = StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM).decrypt(value);
|
||||
} else {
|
||||
// Some migration task: GenerateJobPomMigrationTask invokes this method
|
||||
decrypt = CryptoMigrationUtil.decrypt(value);
|
||||
}
|
||||
|
||||
if (decrypt != null) {
|
||||
return decrypt;
|
||||
}
|
||||
@@ -318,7 +326,8 @@ public class ElementParameterTypeImpl extends EObjectImpl implements ElementPara
|
||||
|
||||
public void setRawValue(String newValue) {
|
||||
if (newValue != null && newValue.length() > 0 && PasswordEncryptUtil.isPasswordField(getField())) {
|
||||
String encryptValue = CryptoHelper.getDefault().encrypt(newValue);
|
||||
String encryptValue = StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM)
|
||||
.encrypt(newValue);
|
||||
if (encryptValue != null) {
|
||||
setValue(encryptValue);
|
||||
return;
|
||||
|
||||
@@ -9,9 +9,9 @@ import org.eclipse.emf.common.notify.Notification;
|
||||
import org.eclipse.emf.ecore.EClass;
|
||||
import org.eclipse.emf.ecore.impl.ENotificationImpl;
|
||||
import org.eclipse.emf.ecore.impl.EObjectImpl;
|
||||
import org.talend.daikon.security.CryptoHelper;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementValueType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.TalendFilePackage;
|
||||
import org.talend.utils.security.StudioEncryption;
|
||||
|
||||
/**
|
||||
* <!-- begin-user-doc --> An implementation of the model object '<em><b>Element Value Type</b></em>'. <!-- end-user-doc
|
||||
@@ -155,7 +155,7 @@ public class ElementValueTypeImpl extends EObjectImpl implements ElementValueTyp
|
||||
|
||||
public String getRawValue() {
|
||||
if (value != null && value.length() > 0) {
|
||||
String decrypt = CryptoHelper.getDefault().decrypt(value);
|
||||
String decrypt = StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM).decrypt(value);
|
||||
if (decrypt != null) {
|
||||
return decrypt;
|
||||
}
|
||||
@@ -176,7 +176,7 @@ public class ElementValueTypeImpl extends EObjectImpl implements ElementValueTyp
|
||||
|
||||
public void setValue(String value, boolean encrypt) {
|
||||
if (encrypt && value != null && value.length() > 0) {
|
||||
String encryptValue = CryptoHelper.getDefault().encrypt(value);
|
||||
String encryptValue = StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM).encrypt(value);
|
||||
if (encryptValue != null) {
|
||||
setValue(encryptValue);
|
||||
return;
|
||||
|
||||
14
main/plugins/org.talend.platform.logging/src/log4j2.xml
Normal file
14
main/plugins/org.talend.platform.logging/src/log4j2.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration>
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
|
||||
<Loggers>
|
||||
<Root level="info">
|
||||
<AppenderRef ref="Console" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -55,7 +55,6 @@ 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.service.IUpdateService;
|
||||
import org.talend.core.services.ICoreTisService;
|
||||
import org.talend.core.ui.branding.IBrandingService;
|
||||
import org.talend.core.ui.workspace.ChooseWorkspaceData;
|
||||
@@ -70,6 +69,7 @@ import org.talend.registration.wizards.license.LicenseWizardDialog;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.model.IRepositoryService;
|
||||
import org.talend.repository.ui.login.LoginHelper;
|
||||
import org.talend.utils.StudioKeysFileCheck;
|
||||
|
||||
/**
|
||||
* This class controls all aspects of the application's execution.
|
||||
@@ -101,6 +101,8 @@ public class Application implements IApplication {
|
||||
}
|
||||
System.setProperty(TalendPropertiesUtil.PROD_APP, this.getClass().getName());
|
||||
|
||||
StudioKeysFileCheck.check(ConfigurationScope.INSTANCE.getLocation().toFile());
|
||||
|
||||
Display display = PlatformUI.createDisplay();
|
||||
try {
|
||||
// TUP-5816 don't put any code ahead of this part unless you make sure it won't trigger workspace
|
||||
@@ -121,7 +123,7 @@ public class Application implements IApplication {
|
||||
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(EclipseCommandLine.CLEAN, null, false);
|
||||
return IApplication.EXIT_RELAUNCH;
|
||||
}
|
||||
|
||||
|
||||
StudioSSLContextProvider.setSSLSystemProperty();
|
||||
HttpProxyUtil.initializeHttpProxy();
|
||||
TalendProxySelector.getInstance();
|
||||
@@ -157,15 +159,8 @@ public class Application implements IApplication {
|
||||
(IMigrationToolService) GlobalServiceRegister.getDefault().getService(IMigrationToolService.class);
|
||||
service.executeWorspaceTasks();
|
||||
// saveConnectionBean(email);
|
||||
|
||||
boolean needRelaunch = false;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IUpdateService.class)) {
|
||||
IUpdateService updateService = GlobalServiceRegister.getDefault().getService(IUpdateService.class);
|
||||
needRelaunch = updateService.checkStudioUpdate(new NullProgressMonitor());
|
||||
}
|
||||
if (needRelaunch) {
|
||||
setRelaunchData();
|
||||
return IApplication.EXIT_RELAUNCH;
|
||||
}
|
||||
final PatchComponent patchComponent = PatchComponentHelper.getPatchComponent();
|
||||
if (patchComponent != null) {
|
||||
final boolean installed = patchComponent.install();
|
||||
|
||||
@@ -520,10 +520,10 @@ public class ImportItemsWizardPage extends WizardPage {
|
||||
|
||||
regenIdBtn = new Button(internalIdGroup, SWT.RADIO);
|
||||
regenIdBtn.setText(Messages.getString("ImportItemsWizardPage_internalIdGroup_alwaysRegenId"));
|
||||
regenIdBtn.setSelection(true);
|
||||
|
||||
Button keepOrigIdBtn = new Button(internalIdGroup, SWT.RADIO);
|
||||
keepOrigIdBtn.setText(Messages.getString("ImportItemsWizardPage_internalIdGroup_keepOrigId"));
|
||||
keepOrigIdBtn.setSelection(true);
|
||||
|
||||
// see feature 3949
|
||||
this.overwriteButton = new Button(optionsArea, SWT.CHECK);
|
||||
@@ -543,6 +543,7 @@ public class ImportItemsWizardPage extends WizardPage {
|
||||
overwriteLayoutData.left = new FormAttachment(internalIdGroup, 0, SWT.LEFT);
|
||||
this.overwriteButton.setLayoutData(overwriteLayoutData);
|
||||
|
||||
internalIdGroup.setVisible(false);
|
||||
}
|
||||
|
||||
protected boolean isEnableForExchange() {
|
||||
|
||||
@@ -3251,8 +3251,7 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
protected void updatePreferenceProjectVersion(Project project) {
|
||||
String oldProductVersion = project.getEmfProject().getProductVersion();
|
||||
if (StringUtils.isNotBlank(oldProductVersion)) {
|
||||
oldProductVersion = StringUtils.substringAfter(oldProductVersion, "-"); //$NON-NLS-1$
|
||||
String oldVersion = VersionUtils.getTalendVersion(oldProductVersion);
|
||||
String oldVersion = VersionUtils.getTalendPureVersion(oldProductVersion);
|
||||
String currentVersion = VersionUtils.getTalendVersion();
|
||||
if (!currentVersion.equals(oldVersion)) {
|
||||
ProjectPreferenceManager prefManager = new ProjectPreferenceManager(project, "org.talend.designer.maven", false); //$NON-NLS-1$
|
||||
|
||||
@@ -25,7 +25,8 @@ Require-Bundle: org.eclipse.ui.workbench,
|
||||
org.talend.repository.view.di;resolution:=optional,
|
||||
javax.mail,
|
||||
org.talend.repository.items.importexport,
|
||||
org.apache.xerces
|
||||
org.apache.xerces,
|
||||
org.talend.repository
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-Vendor: .Talend SA.
|
||||
Bundle-ClassPath: .
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.talend.core.model.properties.MDMConnectionItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
import org.talend.utils.security.CryptoMigrationUtil;
|
||||
|
||||
/**
|
||||
* created by ggu on Sep 1, 2014 Detailled comment
|
||||
@@ -51,6 +52,7 @@ public class UnifyPasswordEncryption4MDMConnectionMigrationTask extends Abstract
|
||||
public ExecutionResult execute(Item item) {
|
||||
if (item instanceof MDMConnectionItem) {
|
||||
Connection connection = ((MDMConnectionItem) item).getConnection();
|
||||
connection.setEncryptAndDecryptFuncPair(CryptoMigrationUtil.encryptFunc(), CryptoMigrationUtil.decryptFunc());
|
||||
if (connection instanceof MDMConnection) {
|
||||
MDMConnection mdmConn = (MDMConnection) connection;
|
||||
try {
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.ui.swt.formtools.LabelledCombo;
|
||||
import org.talend.commons.ui.swt.formtools.LabelledText;
|
||||
import org.talend.core.model.metadata.builder.connection.Concept;
|
||||
@@ -160,19 +160,7 @@ public class SetNameForm extends AbstractMDMFileStepForm {
|
||||
entityCombo.addModifyListener(new ModifyListener() {
|
||||
|
||||
public void modifyText(ModifyEvent e) {
|
||||
selectedEntity = entityCombo.getText();
|
||||
|
||||
selectedEntity = selectedEntity.trim();
|
||||
|
||||
// if entity name has special char
|
||||
String regex = "[^a-zA-Z&&[^0-9]&&[^\\_]]"; //$NON-NLS-1$
|
||||
selectedEntity = selectedEntity.replaceAll(regex, "_"); //$NON-NLS-1$
|
||||
|
||||
// if entity name don't start with alphabet
|
||||
final char charAt = selectedEntity.charAt(0);
|
||||
if (charAt < 'A' || charAt > 'z' || charAt > 'Z' && charAt < 'a') {
|
||||
selectedEntity = "a" + selectedEntity; //$NON-NLS-1$
|
||||
}
|
||||
selectedEntity = entityCombo.getText().trim();
|
||||
|
||||
String name = getNextName();
|
||||
|
||||
@@ -187,6 +175,16 @@ public class SetNameForm extends AbstractMDMFileStepForm {
|
||||
}
|
||||
|
||||
private String getNextName() {
|
||||
// if entity name has special char
|
||||
String regex = "[[^a-zA-Z]&&[^0-9]&&[^\\_]]"; //$NON-NLS-1$
|
||||
String _selectedEntity = selectedEntity.replaceAll(regex, "_"); //$NON-NLS-1$
|
||||
|
||||
// if entity name don't start with alphabet
|
||||
final char charAt = _selectedEntity.charAt(0);
|
||||
if (charAt < 'A' || charAt > 'z' || charAt > 'Z' && charAt < 'a') {
|
||||
_selectedEntity = "a" + _selectedEntity; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
String type = ""; //$NON-NLS-1$
|
||||
switch (concept.getConceptType()) {
|
||||
case INPUT:
|
||||
@@ -200,7 +198,7 @@ public class SetNameForm extends AbstractMDMFileStepForm {
|
||||
break;
|
||||
}
|
||||
|
||||
String name = selectedEntity + type;
|
||||
String name = _selectedEntity + type;
|
||||
int counter = 0;
|
||||
boolean exists = true;
|
||||
while (exists) {
|
||||
@@ -313,14 +311,9 @@ public class SetNameForm extends AbstractMDMFileStepForm {
|
||||
updateStatus(IStatus.ERROR, Messages.getString("SetNameForm_get_entity_fail")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
} catch (OdaException e) {
|
||||
ExceptionHandler.process(e);
|
||||
} catch (URISyntaxException e) {
|
||||
ExceptionHandler.process(e);
|
||||
} catch (IOException e) {
|
||||
} catch (OdaException | URISyntaxException | IOException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ Require-Bundle: org.apache.commons.lang,
|
||||
org.talend.repository.items.importexport,
|
||||
org.talend.libraries.dom4j-jaxen,
|
||||
org.talend.libraries.jackson,
|
||||
org.apache.xerces
|
||||
org.apache.xerces,
|
||||
org.talend.repository
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-Localization: plugin
|
||||
Export-Package: org.talend.repository.metadata,
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.talend.core.model.properties.LDAPSchemaConnectionItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
import org.talend.utils.security.CryptoMigrationUtil;
|
||||
|
||||
/**
|
||||
* created by ggu on Aug 29, 2014 Detailled comment
|
||||
@@ -51,6 +52,7 @@ public class UnifyPasswordEncryption4LdapConnectionMigrationTask extends Abstrac
|
||||
public ExecutionResult execute(Item item) {
|
||||
if (item instanceof LDAPSchemaConnectionItem) {
|
||||
Connection connection = ((LDAPSchemaConnectionItem) item).getConnection();
|
||||
connection.setEncryptAndDecryptFuncPair(CryptoMigrationUtil.encryptFunc(), CryptoMigrationUtil.decryptFunc());
|
||||
if (connection instanceof LDAPSchemaConnection) {
|
||||
LDAPSchemaConnection ldapConn = (LDAPSchemaConnection) connection;
|
||||
try {
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.talend.core.model.properties.SalesforceSchemaConnectionItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
import org.talend.utils.security.CryptoMigrationUtil;
|
||||
|
||||
/**
|
||||
* created by ggu on Aug 29, 2014 Detailled comment
|
||||
@@ -51,6 +52,7 @@ public class UnifyPasswordEncryption4SalesforceSchemaConnectionMigrationTask ext
|
||||
public ExecutionResult execute(Item item) {
|
||||
if (item instanceof SalesforceSchemaConnectionItem) {
|
||||
Connection connection = ((SalesforceSchemaConnectionItem) item).getConnection();
|
||||
connection.setEncryptAndDecryptFuncPair(CryptoMigrationUtil.encryptFunc(), CryptoMigrationUtil.decryptFunc());
|
||||
if (connection instanceof SalesforceSchemaConnection) {
|
||||
SalesforceSchemaConnection ssConn = (SalesforceSchemaConnection) connection;
|
||||
try {
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.talend.core.model.properties.WSDLSchemaConnectionItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
import org.talend.utils.security.CryptoMigrationUtil;
|
||||
|
||||
/**
|
||||
* created by ggu on Aug 29, 2014 Detailled comment
|
||||
@@ -51,6 +52,7 @@ public class UnifyPasswordEncryption4WsdlConnectionMigrationTask extends Abstrac
|
||||
public ExecutionResult execute(Item item) {
|
||||
if (item instanceof WSDLSchemaConnectionItem) {
|
||||
Connection connection = ((WSDLSchemaConnectionItem) item).getConnection();
|
||||
connection.setEncryptAndDecryptFuncPair(CryptoMigrationUtil.encryptFunc(), CryptoMigrationUtil.decryptFunc());
|
||||
if (connection instanceof WSDLSchemaConnection) {
|
||||
WSDLSchemaConnection wsdlConn = (WSDLSchemaConnection) connection;
|
||||
try {
|
||||
|
||||
@@ -8706,4 +8706,6 @@ public class DatabaseForm extends AbstractForm {
|
||||
private void adjustScrolledComHeight() {
|
||||
scrolledComposite.setMinSize(newParent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ import org.talend.core.database.conn.version.EDatabaseVersion4Drivers;
|
||||
import org.talend.core.hadoop.IHadoopClusterService;
|
||||
import org.talend.core.hadoop.IHadoopDistributionService;
|
||||
import org.talend.core.hadoop.repository.HadoopRepositoryUtil;
|
||||
import org.talend.core.model.context.ContextUtils;
|
||||
import org.talend.core.model.metadata.IMetadataConnection;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.builder.ConvertionHelper;
|
||||
@@ -66,6 +67,7 @@ import org.talend.core.model.metadata.builder.database.PluginConstant;
|
||||
import org.talend.core.model.metadata.builder.database.dburl.SupportDBUrlType;
|
||||
import org.talend.core.model.metadata.connection.hive.HiveModeInfo;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.core.model.properties.ContextItem;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.relationship.RelationshipItemBuilder;
|
||||
@@ -82,10 +84,12 @@ import org.talend.core.runtime.services.IGenericDBService;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
import org.talend.cwm.helper.SwitchHelpers;
|
||||
import org.talend.designer.core.IDesignerCoreService;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.metadata.managment.connection.manager.HiveConnectionManager;
|
||||
import org.talend.metadata.managment.model.MetadataFillFactory;
|
||||
import org.talend.metadata.managment.ui.utils.ConnectionContextHelper;
|
||||
import org.talend.metadata.managment.ui.utils.DBConnectionContextUtils;
|
||||
import org.talend.metadata.managment.ui.utils.SwitchContextGroupNameImpl;
|
||||
import org.talend.metadata.managment.ui.wizard.CheckLastVersionRepositoryWizard;
|
||||
import org.talend.metadata.managment.ui.wizard.PropertiesWizardPage;
|
||||
import org.talend.metadata.managment.ui.wizard.metadata.connection.Step0WizardPage;
|
||||
@@ -149,6 +153,8 @@ public class DatabaseWizard extends CheckLastVersionRepositoryWizard implements
|
||||
|
||||
private ConnectionItem originalConnectionItem;
|
||||
|
||||
private ContextType originalSelectedContextType;
|
||||
|
||||
/**
|
||||
* Constructor for DatabaseWizard. Analyse Iselection to extract DatabaseConnection and the pathToSave. Start the
|
||||
* Lock Strategy.
|
||||
@@ -229,8 +235,13 @@ public class DatabaseWizard extends CheckLastVersionRepositoryWizard implements
|
||||
connection.setId(propertyId);
|
||||
|
||||
// initialize the context mode
|
||||
ConnectionContextHelper.checkContextMode(connectionItem);
|
||||
ContextItem checkContextMode = ConnectionContextHelper.checkContextMode(connectionItem);
|
||||
this.originalConnectionItem = connectionItem;
|
||||
if (checkContextMode != null) {
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(connectionItem.getConnection().getContextId());
|
||||
originalSelectedContextType = ContextUtils
|
||||
.getContextTypeByName(contextItem, connectionItem.getConnection().getContextName(), false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -307,8 +318,13 @@ public class DatabaseWizard extends CheckLastVersionRepositoryWizard implements
|
||||
connection.setId(propertyId);
|
||||
|
||||
// initialize the context mode
|
||||
ConnectionContextHelper.checkContextMode(connectionItem);
|
||||
ContextItem checkContextMode = ConnectionContextHelper.checkContextMode(connectionItem);
|
||||
this.originalConnectionItem = connectionItem;
|
||||
if (checkContextMode != null) {
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(connectionItem.getConnection().getContextId());
|
||||
originalSelectedContextType = ContextUtils
|
||||
.getContextTypeByName(contextItem, connectionItem.getConnection().getContextName(), false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -410,7 +426,7 @@ public class DatabaseWizard extends CheckLastVersionRepositoryWizard implements
|
||||
|
||||
private IHadoopDistributionService getHadoopDistributionService() {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IHadoopDistributionService.class)) {
|
||||
return (IHadoopDistributionService) GlobalServiceRegister.getDefault().getService(IHadoopDistributionService.class);
|
||||
return GlobalServiceRegister.getDefault().getService(IHadoopDistributionService.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -436,7 +452,7 @@ public class DatabaseWizard extends CheckLastVersionRepositoryWizard implements
|
||||
if(isTCOMType(getDBType(connectionItem))){
|
||||
IGenericDBService dbService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericDBService.class)) {
|
||||
dbService = (IGenericDBService) GlobalServiceRegister.getDefault().getService(
|
||||
dbService = GlobalServiceRegister.getDefault().getService(
|
||||
IGenericDBService.class);
|
||||
}
|
||||
if(dbService == null){
|
||||
@@ -447,7 +463,7 @@ public class DatabaseWizard extends CheckLastVersionRepositoryWizard implements
|
||||
boolean isNameModified = propertiesWizardPage.isNameModifiedByUser();
|
||||
if (isNameModified) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
|
||||
IDesignerCoreService service = (IDesignerCoreService) GlobalServiceRegister.getDefault()
|
||||
IDesignerCoreService service = GlobalServiceRegister.getDefault()
|
||||
.getService(IDesignerCoreService.class);
|
||||
if (service != null) {
|
||||
service.refreshComponentView(connectionItem);
|
||||
@@ -524,35 +540,50 @@ public class DatabaseWizard extends CheckLastVersionRepositoryWizard implements
|
||||
ITDQRepositoryService tdqRepService = null;
|
||||
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
|
||||
tdqRepService = (ITDQRepositoryService) GlobalServiceRegister.getDefault()
|
||||
tdqRepService = GlobalServiceRegister.getDefault()
|
||||
.getService(ITDQRepositoryService.class);
|
||||
}
|
||||
|
||||
if (getDatabaseConnection() !=null && !connection.isContextMode()) {
|
||||
handleUppercase(getDatabaseConnection(), metadataConnection);
|
||||
}
|
||||
try {
|
||||
// TODO use seperate subclass to handle the create and update logic , using a varable "creation" is not
|
||||
// a good practice.
|
||||
if (creation && getDatabaseConnection() != null) {
|
||||
handleCreation(getDatabaseConnection(), metadataConnection, tdqRepService);
|
||||
} else {
|
||||
Boolean isSuccess = handleUpdate(metadataConnection, tdqRepService);
|
||||
if (tdqRepService != null) {
|
||||
try {
|
||||
// TODO use seperate subclass to handle the create and update logic , using a varable "creation" is
|
||||
// not
|
||||
// a good practice.
|
||||
Boolean isSuccess = true;
|
||||
if (getDatabaseConnection() != null) {
|
||||
if (creation) {
|
||||
handleCreation(getDatabaseConnection(), metadataConnection, tdqRepService);
|
||||
} else if (connection.isContextMode() && originalSelectedContextType != null) {
|
||||
isSuccess = SwitchContextGroupNameImpl
|
||||
.getInstance()
|
||||
.updateContextGroup(connectionItem, contextName,
|
||||
originalSelectedContextType.getName());
|
||||
if (!isSuccess) {
|
||||
tdqRepService.popupSwitchContextFailedMessage(contextName);
|
||||
}
|
||||
} else {
|
||||
isSuccess = handleUpdate(metadataConnection, tdqRepService);
|
||||
}
|
||||
}
|
||||
if (!isSuccess) {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String detailError = e.toString();
|
||||
new ErrorDialogWidthDetailArea(getShell(), PID,
|
||||
Messages.getString("CommonWizard.persistenceException"), //$NON-NLS-1$
|
||||
detailError);
|
||||
log.error(Messages.getString("CommonWizard.persistenceException") + "\n" + detailError); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String detailError = e.toString();
|
||||
new ErrorDialogWidthDetailArea(getShell(), PID, Messages.getString("CommonWizard.persistenceException"), //$NON-NLS-1$
|
||||
detailError);
|
||||
log.error(Messages.getString("CommonWizard.persistenceException") + "\n" + detailError); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return false;
|
||||
}
|
||||
List<IRepositoryViewObject> list = new ArrayList<IRepositoryViewObject>();
|
||||
list.add(repositoryObject);
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRepositoryService.class)) {
|
||||
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(
|
||||
IRepositoryService service = GlobalServiceRegister.getDefault().getService(
|
||||
IRepositoryService.class);
|
||||
service.notifySQLBuilder(list);
|
||||
}
|
||||
@@ -602,7 +633,7 @@ public class DatabaseWizard extends CheckLastVersionRepositoryWizard implements
|
||||
List<ERepositoryObjectType> extraTypes = new ArrayList<ERepositoryObjectType>();
|
||||
IGenericDBService dbService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericDBService.class)) {
|
||||
dbService = (IGenericDBService) GlobalServiceRegister.getDefault().getService(
|
||||
dbService = GlobalServiceRegister.getDefault().getService(
|
||||
IGenericDBService.class);
|
||||
}
|
||||
if(dbService != null){
|
||||
@@ -662,7 +693,7 @@ public class DatabaseWizard extends CheckLastVersionRepositoryWizard implements
|
||||
ITDQCompareService tdqCompareService = null;
|
||||
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQCompareService.class)) {
|
||||
tdqCompareService = (ITDQCompareService) GlobalServiceRegister.getDefault().getService(ITDQCompareService.class);
|
||||
tdqCompareService = GlobalServiceRegister.getDefault().getService(ITDQCompareService.class);
|
||||
}
|
||||
if (tdqCompareService != null && ConnectionHelper.isUrlChanged(conn)
|
||||
&& MetadataConnectionUtils.isTDQSupportDBTemplate(conn)) {
|
||||
@@ -716,7 +747,7 @@ public class DatabaseWizard extends CheckLastVersionRepositoryWizard implements
|
||||
|
||||
if (isNameModified) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
|
||||
IDesignerCoreService service = (IDesignerCoreService) GlobalServiceRegister.getDefault().getService(
|
||||
IDesignerCoreService service = GlobalServiceRegister.getDefault().getService(
|
||||
IDesignerCoreService.class);
|
||||
if (service != null) {
|
||||
service.refreshComponentView(connectionItem);
|
||||
|
||||
@@ -136,7 +136,7 @@ public class DatabaseWizardPage extends WizardPage {
|
||||
private void createDynamicForm(){
|
||||
IGenericDBService dbService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericDBService.class)) {
|
||||
dbService = (IGenericDBService) GlobalServiceRegister.getDefault().getService(
|
||||
dbService = GlobalServiceRegister.getDefault().getService(
|
||||
IGenericDBService.class);
|
||||
}
|
||||
if(dbService == null){
|
||||
@@ -219,7 +219,7 @@ public class DatabaseWizardPage extends WizardPage {
|
||||
List<ERepositoryObjectType> extraTypes = new ArrayList<ERepositoryObjectType>();
|
||||
IGenericDBService dbService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericDBService.class)) {
|
||||
dbService = (IGenericDBService) GlobalServiceRegister.getDefault().getService(
|
||||
dbService = GlobalServiceRegister.getDefault().getService(
|
||||
IGenericDBService.class);
|
||||
}
|
||||
if(dbService != null){
|
||||
@@ -236,7 +236,7 @@ public class DatabaseWizardPage extends WizardPage {
|
||||
public boolean isGenericConn(ConnectionItem connItem){
|
||||
IGenericWizardService dbService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
dbService = (IGenericWizardService) GlobalServiceRegister.getDefault().getService(
|
||||
dbService = GlobalServiceRegister.getDefault().getService(
|
||||
IGenericWizardService.class);
|
||||
}
|
||||
if(dbService != null){
|
||||
@@ -251,7 +251,7 @@ public class DatabaseWizardPage extends WizardPage {
|
||||
}
|
||||
IGenericDBService dbService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericDBService.class)) {
|
||||
dbService = (IGenericDBService) GlobalServiceRegister.getDefault().getService(
|
||||
dbService = GlobalServiceRegister.getDefault().getService(
|
||||
IGenericDBService.class);
|
||||
}
|
||||
if(dbService != null){
|
||||
@@ -329,11 +329,12 @@ public class DatabaseWizardPage extends WizardPage {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Form getForm(){
|
||||
if(dynamicForm != null){
|
||||
IGenericDBService dbService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericDBService.class)) {
|
||||
dbService = (IGenericDBService) GlobalServiceRegister.getDefault().getService(
|
||||
dbService = GlobalServiceRegister.getDefault().getService(
|
||||
IGenericDBService.class);
|
||||
}
|
||||
if(dbService != null){
|
||||
|
||||
@@ -182,12 +182,4 @@ FeaturesManager.Type.p2.studioPatch=Studio Patch
|
||||
FeaturesManager.Type.plainZip=Plain ZIP
|
||||
FeaturesManager.Category.all=All Categories
|
||||
|
||||
P2UpdateManager.update.product=Updating talend product...
|
||||
P2UpdateManager.p2.uri.null=P2 repository URI is null.
|
||||
P2UpdateManager.p2.feature.null=Feature list is empty.
|
||||
P2UpdateManager.no.iu.available=Could not find any available IU in current profile.
|
||||
P2UpdateManager.user.cancel=User canceled the upgrade of product.
|
||||
P2UpdateManager.update.error=error updating product : {0}
|
||||
P2UpdateManager.update.sucess=Update talend product successfully.
|
||||
|
||||
UIUtils.exception.interrupt=User cancelled.
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.updates.runtime;
|
||||
|
||||
public interface P2UpdateConstants {
|
||||
|
||||
public static final String STUDIO_CORE_FEATURE_ID = "org.talend.tup.feature.feature.group"; //$NON-NLS-1$
|
||||
|
||||
public static final String KEY_UPDATESITE_PATH = "updatesite.path"; //$NON-NLS-1$
|
||||
|
||||
public static final String KEY_FEATURES_TO_INSTALL = "features.to.install"; //$NON-NLS-1$
|
||||
|
||||
public static final String KEY_FEATURES_TO_UPDATE = "features.to.update"; //$NON-NLS-1$
|
||||
|
||||
}
|
||||
@@ -12,8 +12,6 @@
|
||||
// ============================================================================
|
||||
package org.talend.updates.runtime;
|
||||
|
||||
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
|
||||
import org.eclipse.equinox.p2.core.IProvisioningAgent;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
@@ -27,14 +25,10 @@ public class UpdatesRuntimePlugin extends AbstractUIPlugin {
|
||||
|
||||
private static UpdatesRuntimePlugin plugin;
|
||||
|
||||
private IProvisioningAgent agent;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
plugin = this;
|
||||
agent = ServiceHelper.getService(context, IProvisioningAgent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,9 +40,4 @@ public class UpdatesRuntimePlugin extends AbstractUIPlugin {
|
||||
public static UpdatesRuntimePlugin getDefault() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public IProvisioningAgent getProvisioningAgent() {
|
||||
return agent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,11 +32,13 @@ import org.eclipse.equinox.p2.query.QueryUtil;
|
||||
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
|
||||
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
|
||||
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.ui.runtime.update.PreferenceKeys;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.commons.utils.io.FilesUtils;
|
||||
import org.talend.updates.runtime.i18n.Messages;
|
||||
@@ -58,6 +60,8 @@ public class P2Manager {
|
||||
|
||||
private final Object p2ProfileLock = new Object();
|
||||
|
||||
private final Object clearOsgiLock = new Object();
|
||||
|
||||
private P2Manager() {
|
||||
reset();
|
||||
}
|
||||
@@ -239,4 +243,9 @@ public class P2Manager {
|
||||
}
|
||||
}
|
||||
|
||||
public void clearOsgiCache() {
|
||||
synchronized (clearOsgiLock) {
|
||||
PlatformUI.getPreferenceStore().setValue(PreferenceKeys.NEED_OSGI_CLEAN, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,273 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.updates.runtime.engine;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.equinox.p2.core.IProvisioningAgent;
|
||||
import org.eclipse.equinox.p2.core.ProvisionException;
|
||||
import org.eclipse.equinox.p2.engine.IPhaseSet;
|
||||
import org.eclipse.equinox.p2.engine.IProfile;
|
||||
import org.eclipse.equinox.p2.engine.IProfileRegistry;
|
||||
import org.eclipse.equinox.p2.engine.PhaseSetFactory;
|
||||
import org.eclipse.equinox.p2.engine.query.UserVisibleRootQuery;
|
||||
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
|
||||
import org.eclipse.equinox.p2.operations.InstallOperation;
|
||||
import org.eclipse.equinox.p2.operations.ProfileModificationJob;
|
||||
import org.eclipse.equinox.p2.operations.ProvisioningSession;
|
||||
import org.eclipse.equinox.p2.operations.UpdateOperation;
|
||||
import org.eclipse.equinox.p2.query.QueryUtil;
|
||||
import org.eclipse.equinox.p2.repository.IRepositoryManager;
|
||||
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
|
||||
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.updates.runtime.P2UpdateConstants;
|
||||
import org.talend.updates.runtime.UpdatesRuntimePlugin;
|
||||
import org.talend.updates.runtime.i18n.Messages;
|
||||
import org.talend.updates.runtime.model.ExtraFeatureException;
|
||||
import org.talend.updates.runtime.model.P2ExtraFeatureException;
|
||||
import org.talend.updates.runtime.utils.P2UpdateHelper;
|
||||
|
||||
public class P2UpdateManager {
|
||||
|
||||
private Logger logger = Logger.getLogger(P2UpdateManager.class);
|
||||
|
||||
private static P2UpdateManager instance;
|
||||
|
||||
private IProvisioningAgent agent;
|
||||
|
||||
private ProvisioningSession session;
|
||||
|
||||
private IPhaseSet talendPhaseSet;
|
||||
|
||||
private P2UpdateManager() {
|
||||
agent = UpdatesRuntimePlugin.getDefault().getProvisioningAgent();
|
||||
agent.registerService(IProvisioningAgent.INSTALLER_AGENT, agent);
|
||||
// DirectorApplication.PROP_P2_PROFILE
|
||||
agent.registerService("eclipse.p2.profile", IProfileRegistry.SELF);//$NON-NLS-1$
|
||||
talendPhaseSet = PhaseSetFactory.createDefaultPhaseSetExcluding(new String[] { PhaseSetFactory.PHASE_CHECK_TRUST });
|
||||
}
|
||||
|
||||
public static P2UpdateManager getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (P2UpdateManager.class) {
|
||||
if (instance == null) {
|
||||
instance = new P2UpdateManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public IStatus execute(final IProgressMonitor monitor) throws ExtraFeatureException { // check p2 repository url
|
||||
if (P2UpdateHelper.getP2RepositoryURI() == null) {
|
||||
return Messages.createErrorStatus(null, "P2UpdateManager.p2.uri.null"); //$NON-NLS-1$
|
||||
}
|
||||
// check features to install/update or TODO filter available features in license
|
||||
List<String> featuresToInstall = P2UpdateHelper.getConfigFeatures(P2UpdateConstants.KEY_FEATURES_TO_INSTALL);
|
||||
List<String> featuresToUpdate = P2UpdateHelper.getConfigFeatures(P2UpdateConstants.KEY_FEATURES_TO_UPDATE);
|
||||
if (featuresToInstall.isEmpty() && featuresToUpdate.isEmpty()) {
|
||||
return Messages.createErrorStatus(null, "P2UpdateManager.p2.feature.null"); //$NON-NLS-1$
|
||||
}
|
||||
IStatus result = null;
|
||||
File configIniBackupFile = null;
|
||||
try {
|
||||
// backup the config.ini
|
||||
configIniBackupFile = P2UpdateHelper.backupConfigFile();
|
||||
if (!featuresToInstall.isEmpty()) {
|
||||
result = doInstall(monitor, featuresToInstall);
|
||||
return result;
|
||||
}
|
||||
result = doUpdate(monitor, featuresToUpdate);
|
||||
} catch (IOException e) {
|
||||
throw new ExtraFeatureException(
|
||||
new ProvisionException(Messages.createErrorStatus(e, "ExtraFeaturesFactory.restore.config.error"))); //$NON-NLS-1$
|
||||
} finally {
|
||||
boolean success = false;
|
||||
if (result != null) {
|
||||
switch (result.getSeverity()) {
|
||||
case IStatus.OK:
|
||||
case IStatus.INFO:
|
||||
case IStatus.WARNING:
|
||||
success = true;
|
||||
break;
|
||||
default:
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
P2UpdateHelper.clearOsgiCache();
|
||||
if (success) {
|
||||
// restore the config.ini
|
||||
if (configIniBackupFile != null) {
|
||||
try {
|
||||
P2UpdateHelper.restoreConfigFile(configIniBackupFile);
|
||||
} catch (IOException e) {
|
||||
throw new P2ExtraFeatureException(
|
||||
new ProvisionException(Messages.createErrorStatus(e, "ExtraFeaturesFactory.back.config.error"))); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
if (!featuresToInstall.isEmpty()) {
|
||||
P2UpdateHelper.clearConfigFeatures(P2UpdateConstants.KEY_FEATURES_TO_INSTALL);
|
||||
} else if (!featuresToUpdate.isEmpty()) {
|
||||
P2UpdateHelper.clearConfigFeatures(P2UpdateConstants.KEY_FEATURES_TO_UPDATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private IStatus doInstall(IProgressMonitor monitor, List<String> featuresToInstall) throws P2ExtraFeatureException {
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor, 4);
|
||||
subMonitor.setTaskName(Messages.getString("P2UpdateManager.update.product")); //$NON-NLS-1$
|
||||
// reset isInstalled to make is compute the next time is it used
|
||||
List<URI> allRepoUris = new ArrayList<>();
|
||||
allRepoUris.add(P2UpdateHelper.getP2RepositoryURI());
|
||||
subMonitor.setTaskName(Messages.getString("ExtraFeature.searching.talend.features.label")); //$NON-NLS-1$
|
||||
Set<IInstallableUnit> availableIUs = queryFromP2Repository(subMonitor.newChild(1), allRepoUris);
|
||||
// show the installation unit
|
||||
List<IInstallableUnit> toInstall = availableIUs.stream().filter(iu -> featuresToInstall.contains(iu.getId()))
|
||||
.collect(Collectors.toList());
|
||||
logger.debug("IUs to install:" + toInstall); //$NON-NLS-1$
|
||||
if (toInstall.isEmpty()) {
|
||||
return Messages.createErrorStatus(null, "P2UpdateManager.no.iu.available");
|
||||
}
|
||||
if (subMonitor.isCanceled()) {
|
||||
return Messages.createCancelStatus("P2UpdateManager.user.cancel"); //$NON-NLS-1$
|
||||
}
|
||||
InstallOperation installOperation = new InstallOperation(getProvisioningSession(), toInstall);
|
||||
IStatus installResolvedStatus = installOperation.resolveModal(subMonitor.newChild(1));
|
||||
if (installResolvedStatus.getSeverity() == IStatus.ERROR) {
|
||||
return Messages.createErrorStatus(null, "P2UpdateManager.update.error", //$NON-NLS-1$
|
||||
installOperation.getResolutionDetails());
|
||||
}
|
||||
ProfileModificationJob provisioningJob = (ProfileModificationJob) installOperation
|
||||
.getProvisioningJob(subMonitor.newChild(1));
|
||||
if (subMonitor.isCanceled()) {
|
||||
return Messages.createCancelStatus("P2UpdateManager.user.cancel"); //$NON-NLS-1$
|
||||
}
|
||||
provisioningJob.setPhaseSet(talendPhaseSet);
|
||||
IStatus status = provisioningJob.run(subMonitor.newChild(1));
|
||||
logger.debug("installed features with status :" + status); //$NON-NLS-1$
|
||||
return Messages.createOkStatus("P2UpdateManager.update.sucess"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private IStatus doUpdate(IProgressMonitor monitor, List<String> featuresToUpdate) throws P2ExtraFeatureException {
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor, 5);
|
||||
subMonitor.setTaskName(Messages.getString("P2UpdateManager.update.product")); //$NON-NLS-1$
|
||||
// reset isInstalled to make is compute the next time is it used
|
||||
IProfile p2Profile = getProfile(IProfileRegistry.SELF);
|
||||
List<URI> allRepoUris = new ArrayList<>();
|
||||
allRepoUris.add(P2UpdateHelper.getP2RepositoryURI());
|
||||
Set<IInstallableUnit> currentIUs = p2Profile.query(new UserVisibleRootQuery(), subMonitor.newChild(1))
|
||||
.toUnmodifiableSet();
|
||||
// show the installation unit
|
||||
List<IInstallableUnit> iusToUpdate = currentIUs.stream().filter(iu -> featuresToUpdate.contains(iu.getId()))
|
||||
.collect(Collectors.toList());
|
||||
logger.debug("IUs to update:" + iusToUpdate); //$NON-NLS-1$
|
||||
if (iusToUpdate.isEmpty()) {
|
||||
return Messages.createErrorStatus(null, "P2UpdateManager.no.iu.available"); //$NON-NLS-1$
|
||||
}
|
||||
// update
|
||||
UpdateOperation updateOperation = new UpdateOperation(getProvisioningSession(), iusToUpdate);
|
||||
updateOperation.getProvisioningContext().setArtifactRepositories(allRepoUris.toArray(new URI[allRepoUris.size()]));
|
||||
updateOperation.getProvisioningContext().setMetadataRepositories(allRepoUris.toArray(new URI[allRepoUris.size()]));
|
||||
updateOperation.setProfileId(IProfileRegistry.SELF);
|
||||
IStatus result = updateOperation.resolveModal(subMonitor.newChild(1));
|
||||
if (subMonitor.isCanceled()) {
|
||||
return Messages.createCancelStatus("P2UpdateManager.user.cancel"); //$NON-NLS-1$
|
||||
}
|
||||
if (result.getSeverity() == IStatus.ERROR) {
|
||||
return Messages.createErrorStatus(null, "P2UpdateManager.update.error", //$NON-NLS-1$
|
||||
updateOperation.getResolutionDetails());
|
||||
}
|
||||
ProfileModificationJob provisioningJob = (ProfileModificationJob) updateOperation
|
||||
.getProvisioningJob(subMonitor.newChild(1));
|
||||
if (subMonitor.isCanceled()) {
|
||||
return Messages.createCancelStatus("P2UpdateManager.user.cancel"); //$NON-NLS-1$
|
||||
}
|
||||
if (provisioningJob == null) {
|
||||
return Messages.createErrorStatus(null, "P2UpdateManager.update.error", //$NON-NLS-1$
|
||||
updateOperation.getResolutionDetails());
|
||||
}
|
||||
provisioningJob.setPhaseSet(talendPhaseSet);
|
||||
IStatus status = provisioningJob.run(subMonitor.newChild(1));
|
||||
if (subMonitor.isCanceled()) {
|
||||
return Messages.createCancelStatus("P2UpdateManager.user.cancel"); //$NON-NLS-1$
|
||||
}
|
||||
logger.debug("Updated product with status: " + status); //$NON-NLS-1$
|
||||
if (featuresToUpdate.contains(P2UpdateConstants.STUDIO_CORE_FEATURE_ID)) {
|
||||
// TODO change to the new studio.core feature.
|
||||
try {
|
||||
P2UpdateHelper.updateProductVersion(subMonitor.newChild(1), getProfile(IProfileRegistry.SELF));
|
||||
// remove .syncMarker to force to sync maven repository
|
||||
String filePath = System.getProperty("m2.syncmarker.path"); //$NON-NLS-1$
|
||||
if (filePath != null) {
|
||||
File markerFile = new File(filePath);
|
||||
if (markerFile.exists()) {
|
||||
markerFile.delete();
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
return Messages.createOkStatus("P2UpdateManager.update.sucess"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public Set<IInstallableUnit> queryFromP2Repository(IProgressMonitor monitor, List<URI> allRepoUris) {
|
||||
// get the repository managers and add our repository
|
||||
IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) agent
|
||||
.getService(IMetadataRepositoryManager.SERVICE_NAME);
|
||||
IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent
|
||||
.getService(IArtifactRepositoryManager.SERVICE_NAME);
|
||||
// remove existing repositories
|
||||
for (URI existingRepUri : metadataManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL)) {
|
||||
metadataManager.removeRepository(existingRepUri);
|
||||
}
|
||||
for (URI existingRepUri : artifactManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL)) {
|
||||
metadataManager.removeRepository(existingRepUri);
|
||||
}
|
||||
for (URI repoUri : allRepoUris) {
|
||||
metadataManager.addRepository(repoUri);
|
||||
artifactManager.addRepository(repoUri);
|
||||
}
|
||||
return metadataManager.query(QueryUtil.createLatestQuery(QueryUtil.createIUGroupQuery()), monitor).toUnmodifiableSet();
|
||||
}
|
||||
|
||||
public ProvisioningSession getProvisioningSession() {
|
||||
if (session == null) {
|
||||
session = new ProvisioningSession(agent);
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
||||
public IProfileRegistry getProfileRegistry() {
|
||||
return (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
|
||||
}
|
||||
|
||||
public IProfile getProfile(String profilId) {
|
||||
return getProfileRegistry().getProfile(profilId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
package org.talend.updates.runtime.model;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -61,6 +62,9 @@ import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.runtime.utils.io.IOUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.services.ICoreTisService;
|
||||
import org.talend.updates.runtime.engine.P2Manager;
|
||||
import org.talend.updates.runtime.feature.model.Category;
|
||||
import org.talend.updates.runtime.feature.model.Type;
|
||||
@@ -73,7 +77,6 @@ import org.talend.updates.runtime.service.ITaCoKitUpdateService;
|
||||
import org.talend.updates.runtime.service.ITaCoKitUpdateService.ICarInstallationResult;
|
||||
import org.talend.updates.runtime.storage.AbstractFeatureStorage;
|
||||
import org.talend.updates.runtime.storage.IFeatureStorage;
|
||||
import org.talend.updates.runtime.utils.P2UpdateHelper;
|
||||
import org.talend.updates.runtime.utils.PathUtils;
|
||||
import org.talend.updates.runtime.utils.TaCoKitCarUtils;
|
||||
import org.talend.utils.files.FileUtils;
|
||||
@@ -281,7 +284,7 @@ public class P2ExtraFeature extends AbstractExtraFeature implements IP2Feature {
|
||||
try {
|
||||
if (!isUseLegacyP2Install()) {
|
||||
// backup the config.ini
|
||||
configIniBackupFile = P2UpdateHelper.backupConfigFile();
|
||||
configIniBackupFile = backupConfigFile();
|
||||
} // else legacy p2 install will update the config.ini
|
||||
doInstallStatus = installP2(progress, allRepoUris);
|
||||
if (doInstallStatus == null || !doInstallStatus.isOK()) {
|
||||
@@ -331,9 +334,9 @@ public class P2ExtraFeature extends AbstractExtraFeature implements IP2Feature {
|
||||
}
|
||||
}
|
||||
// restore the config.ini
|
||||
if (isInstalled && configIniBackupFile != null) { // must existed backup file.
|
||||
if (configIniBackupFile != null) { // must existed backup file.
|
||||
try {
|
||||
P2UpdateHelper.restoreConfigFile(configIniBackupFile);
|
||||
restoreConfigFile(configIniBackupFile, isInstalled);
|
||||
} catch (IOException e) {
|
||||
throw new P2ExtraFeatureException(
|
||||
new ProvisionException(Messages.createErrorStatus(e, "ExtraFeaturesFactory.back.config.error"))); //$NON-NLS-1$
|
||||
@@ -356,7 +359,7 @@ public class P2ExtraFeature extends AbstractExtraFeature implements IP2Feature {
|
||||
}
|
||||
|
||||
protected void afterInstallP2(IProgressMonitor progress, Map<File, File> unzippedPatchMap) throws P2ExtraFeatureException {
|
||||
P2UpdateHelper.clearOsgiCache();
|
||||
P2Manager.getInstance().clearOsgiCache();
|
||||
}
|
||||
|
||||
protected void afterRestoreConfigFile(IProgressMonitor progress, Map<File, File> unzippedPatchMap)
|
||||
@@ -543,7 +546,6 @@ public class P2ExtraFeature extends AbstractExtraFeature implements IP2Feature {
|
||||
protected void updateRoamingProp(IProvisioningAgent agent, IProvisioningAgentProvider agentProvider)
|
||||
throws ProvisionException {
|
||||
agent.registerService(IProvisioningAgent.INSTALLER_AGENT, agentProvider.createAgent(null));
|
||||
// DirectorApplication.PROP_P2_PROFILE
|
||||
agent.registerService("eclipse.p2.profile", getP2ProfileId());//$NON-NLS-1$
|
||||
}
|
||||
|
||||
@@ -657,6 +659,39 @@ public class P2ExtraFeature extends AbstractExtraFeature implements IP2Feature {
|
||||
}
|
||||
}
|
||||
|
||||
protected File backupConfigFile() throws IOException {
|
||||
try {
|
||||
File configurationFile = PathUtils.getStudioConfigFile();
|
||||
File tempFile = File.createTempFile("config.ini", null); //$NON-NLS-1$
|
||||
FilesUtils.copyFile(new FileInputStream(configurationFile), tempFile);
|
||||
return tempFile;
|
||||
} catch (Exception e) {
|
||||
if (e instanceof IOException) {
|
||||
throw (IOException) e;
|
||||
}
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void restoreConfigFile(File toResore, boolean isInstalled) throws IOException {
|
||||
try {
|
||||
File configurationFile = PathUtils.getStudioConfigFile();
|
||||
if (isInstalled && !IOUtils.contentEquals(new FileInputStream(configurationFile), new FileInputStream(toResore))) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
|
||||
ICoreTisService coreTisService = (ICoreTisService) GlobalServiceRegister.getDefault()
|
||||
.getService(ICoreTisService.class);
|
||||
coreTisService.updateConfiguratorBundles(configurationFile, toResore);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new IOException(e);
|
||||
} finally {
|
||||
if (toResore != null && toResore.exists()) {
|
||||
toResore.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExtraFeature getInstalledFeature(IProgressMonitor progress) throws ExtraFeatureException {
|
||||
ExtraFeature extraFeature = null;
|
||||
|
||||
@@ -19,18 +19,14 @@ import java.util.Set;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.service.IUpdateService;
|
||||
import org.talend.updates.runtime.engine.P2UpdateManager;
|
||||
import org.talend.updates.runtime.engine.component.InstallComponentMessages;
|
||||
import org.talend.updates.runtime.engine.factory.ComponentsNexusInstallFactory;
|
||||
import org.talend.updates.runtime.model.ExtraFeature;
|
||||
import org.talend.updates.runtime.model.ExtraFeatureException;
|
||||
import org.talend.updates.runtime.model.FeatureCategory;
|
||||
import org.talend.updates.runtime.nexus.component.NexusServerManager;
|
||||
|
||||
@@ -104,30 +100,4 @@ public class UpdateService implements IUpdateService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkStudioUpdate(IProgressMonitor monitor) {
|
||||
if (Platform.inDevelopmentMode()) {
|
||||
return false;
|
||||
}
|
||||
if (monitor == null) {
|
||||
monitor = new NullProgressMonitor();
|
||||
}
|
||||
try {
|
||||
IStatus status = P2UpdateManager.getInstance().execute(monitor);
|
||||
if (status != null) {
|
||||
switch (status.getSeverity()) {
|
||||
case IStatus.OK:
|
||||
case IStatus.INFO:
|
||||
case IStatus.WARNING:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (ExtraFeatureException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,158 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.updates.runtime.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.equinox.p2.engine.IProfile;
|
||||
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
|
||||
import org.eclipse.equinox.p2.query.QueryUtil;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.runtime.utils.io.IOUtils;
|
||||
import org.talend.commons.ui.runtime.update.PreferenceKeys;
|
||||
import org.talend.commons.utils.resource.UpdatesHelper;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.runtime.maven.MavenConstants;
|
||||
import org.talend.core.services.ICoreTisService;
|
||||
import org.talend.updates.runtime.P2UpdateConstants;
|
||||
import org.talend.utils.io.FilesUtils;
|
||||
|
||||
public class P2UpdateHelper {
|
||||
|
||||
private static Object clearOsgiLock = new Object();
|
||||
|
||||
public static File backupConfigFile() throws IOException {
|
||||
try {
|
||||
File configurationFile = PathUtils.getStudioConfigFile();
|
||||
File tempFile = File.createTempFile(UpdatesHelper.FILE_CONFIG_INI, null);
|
||||
FilesUtils.copyFile(new FileInputStream(configurationFile), tempFile);
|
||||
return tempFile;
|
||||
} catch (Exception e) {
|
||||
if (e instanceof IOException) {
|
||||
throw (IOException) e;
|
||||
}
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void restoreConfigFile(File toResore) throws IOException {
|
||||
try {
|
||||
File configurationFile = PathUtils.getStudioConfigFile();
|
||||
if (!IOUtils.contentEquals(new FileInputStream(configurationFile), new FileInputStream(toResore))) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
|
||||
ICoreTisService coreTisService = (ICoreTisService) GlobalServiceRegister.getDefault()
|
||||
.getService(ICoreTisService.class);
|
||||
coreTisService.updateConfiguratorBundles(configurationFile, toResore);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new IOException(e);
|
||||
} finally {
|
||||
if (toResore != null && toResore.exists()) {
|
||||
toResore.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static URI getP2RepositoryURI() {
|
||||
String updatesite = null;
|
||||
try (InputStream fis = new FileInputStream(PathUtils.getStudioConfigFile())) {
|
||||
Properties properties = new Properties();
|
||||
properties.load(fis);
|
||||
updatesite = properties.getProperty(P2UpdateConstants.KEY_UPDATESITE_PATH);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
if (updatesite == null) {
|
||||
return null;
|
||||
}
|
||||
File file = new File(updatesite);
|
||||
if (file.isFile() || file.isDirectory()) {
|
||||
return file.toURI();
|
||||
}
|
||||
return URI.create(updatesite);
|
||||
}
|
||||
|
||||
public static List<String> getConfigFeatures(String type) {
|
||||
String targetFeatures = null;
|
||||
try (InputStream fis = new FileInputStream(PathUtils.getStudioConfigFile())) {
|
||||
Properties properties = new Properties();
|
||||
properties.load(fis);
|
||||
targetFeatures = properties.getProperty(type);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
if (StringUtils.isBlank(targetFeatures)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Arrays.asList(targetFeatures.trim().split(",")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public static void clearConfigFeatures(String type) {
|
||||
Properties properties = new Properties();
|
||||
try (InputStream fis = new FileInputStream(PathUtils.getStudioConfigFile())) {
|
||||
properties.load(fis);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
try (OutputStream fos = new FileOutputStream(PathUtils.getStudioConfigFile())) {
|
||||
properties.setProperty(type, StringUtils.EMPTY);
|
||||
properties.store(fos, "Configuration File"); //$NON-NLS-1$
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateProductVersion(IProgressMonitor monitor, IProfile profile) throws IOException {
|
||||
Properties properties = new Properties();
|
||||
File eclipseProductFile = new File(
|
||||
Platform.getInstallLocation().getDataArea(UpdatesHelper.FILE_ECLIPSE_PRODUCT).getPath());
|
||||
try (InputStream in = new FileInputStream(eclipseProductFile)) {
|
||||
properties.load(in);
|
||||
}
|
||||
String oldVersion = properties.getProperty("version"); //$NON-NLS-1$
|
||||
Set<IInstallableUnit> queryResult = profile.query(QueryUtil.createIUQuery(P2UpdateConstants.STUDIO_CORE_FEATURE_ID), monitor)
|
||||
.toUnmodifiableSet();
|
||||
IInstallableUnit newCoreFeature = queryResult.stream().findFirst().get();
|
||||
String newVersion = newCoreFeature.getVersion().toString();
|
||||
if (oldVersion.endsWith(MavenConstants.SNAPSHOT)) {
|
||||
// for nightly build only.
|
||||
newVersion += MavenConstants.SNAPSHOT;
|
||||
}
|
||||
properties.setProperty("version", newVersion); //$NON-NLS-1$
|
||||
try (OutputStream out = new FileOutputStream(eclipseProductFile)) {
|
||||
properties.store(out, "Configuration File"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearOsgiCache() {
|
||||
synchronized (clearOsgiLock) {
|
||||
PlatformUI.getPreferenceStore().setValue(PreferenceKeys.NEED_OSGI_CLEAN, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
<?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="src" path="src/main/java"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
<?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="src" path="src/main/java"/>
|
||||
<classpathentry kind="src" path="src/main/resources"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
||||
@@ -36,7 +36,6 @@ Require-Bundle: org.apache.commons.lang,
|
||||
org.talend.daikon;visibility:=reexport,
|
||||
org.talend.daikon.crypto.utils;visibility:=reexport,
|
||||
org.bouncycastle.bcprov,
|
||||
org.apache.httpcomponents.httpclient,
|
||||
org.slf4j.api
|
||||
Eclipse-BuddyPolicy: registered
|
||||
Eclipse-RegisterBuddy: org.apache.log4j, org.talend.testutils
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
source.. = src/main/java/
|
||||
output.. = class/
|
||||
source.dist/org.talend.utils.jar = src/main/java/
|
||||
output.dist/org.talend.utils.jar = class/
|
||||
source.dist/org.talend.utils.jar = src/main/java/,\
|
||||
src/main/resources/
|
||||
output.dist/org.talend.utils.jar = class
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
dist/
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
<relativePath>../pom_server.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<org.talend.daikon.crypto-utils.version>1.2.0</org.talend.daikon.crypto-utils.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
@@ -86,10 +82,9 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<excludes>
|
||||
<exclude>org/talend/utils/security/*.*</exclude>
|
||||
<exclude>org/talend/utils/sql/*.*</exclude>
|
||||
<exclude>org/talend/utils/ssl/*.*</exclude>
|
||||
</excludes>
|
||||
@@ -98,7 +93,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>2.3.5</version>
|
||||
<version>4.2.1</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
<relativePath>../pom_server.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<org.talend.daikon.crypto-utils.version>1.2.0</org.talend.daikon.crypto-utils.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
@@ -91,14 +87,14 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>2.3.5</version>
|
||||
<version>4.2.1</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/*
|
||||
* Created by bhe on Sep 25, 2019
|
||||
*/
|
||||
public class StudioKeysFileCheck {
|
||||
|
||||
public static final String ENCRYPTION_KEY_FILE_SYS_PROP = "encryption.keys.file";
|
||||
|
||||
public static final String ENCRYPTION_KEY_FILE_NAME = "studio.keys";
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(StudioKeysFileCheck.class);
|
||||
|
||||
private StudioKeysFileCheck() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether system property: encryption.keys.file is set, if not then set value of encryption.keys.file
|
||||
*/
|
||||
public static void check(File confDir) {
|
||||
if (confDir == null) {
|
||||
IllegalArgumentException e = new IllegalArgumentException("Encryption keys file path invalid");
|
||||
LOGGER.error(e);
|
||||
throw e;
|
||||
}
|
||||
String keyFile = System.getProperty(ENCRYPTION_KEY_FILE_SYS_PROP);
|
||||
if (keyFile == null || keyFile.isEmpty() || !new File(keyFile).exists()) {
|
||||
keyFile = Paths.get(confDir.getAbsolutePath(), ENCRYPTION_KEY_FILE_NAME).toString();
|
||||
System.setProperty(ENCRYPTION_KEY_FILE_SYS_PROP, keyFile);
|
||||
}
|
||||
LOGGER.info("encryptionKeyFilePath: " + keyFile);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package org.talend.utils.security;
|
||||
|
||||
// ============================================================================
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// ============================================================================
|
||||
import org.talend.daikon.crypto.CipherSources;
|
||||
import org.talend.daikon.crypto.Encryption;
|
||||
import org.talend.daikon.crypto.KeySources;
|
||||
|
||||
public class AESEncryption {
|
||||
|
||||
//TODO We should remove default key after implements master key encryption algorithm
|
||||
private static final String ENCRYPTION_KEY = "Talend_TalendKey";// The length of key should be 16, 24 or 32.
|
||||
|
||||
private static Encryption defaultEncryption;
|
||||
|
||||
public static String encryptPassword(String input, String key) throws Exception {
|
||||
Encryption encryption = getEncryption(key);
|
||||
return encryption.encrypt(input);
|
||||
}
|
||||
|
||||
public static String encryptPassword(String input) throws Exception {
|
||||
Encryption encryption = getEncryption();
|
||||
return encryption.encrypt(input);
|
||||
}
|
||||
|
||||
public static String decryptPassword(String input, String key) throws Exception {
|
||||
Encryption encryption = getEncryption(key);
|
||||
return encryption.decrypt(input);
|
||||
}
|
||||
|
||||
public static String decryptPassword(String input) throws Exception {
|
||||
Encryption encryption = getEncryption();
|
||||
return encryption.decrypt(input);
|
||||
}
|
||||
|
||||
private static Encryption getEncryption() {
|
||||
if (defaultEncryption == null) {
|
||||
defaultEncryption = getEncryption(ENCRYPTION_KEY);
|
||||
}
|
||||
return defaultEncryption;
|
||||
}
|
||||
|
||||
private static Encryption getEncryption(String key) {
|
||||
return new Encryption(KeySources.fixedKey(key), CipherSources.aes());
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
/**
|
||||
* created by zwli on Feb 27, 2013 Detailed comment
|
||||
*/
|
||||
public class AES {
|
||||
public class BouncyCastleEncryption {
|
||||
|
||||
static {
|
||||
if (null == Security.getProvider("BC")) {
|
||||
@@ -38,7 +38,7 @@ public class AES {
|
||||
}
|
||||
}
|
||||
|
||||
private static Logger log = Logger.getLogger(AES.class);
|
||||
private static final Logger LOGGER = Logger.getLogger(BouncyCastleEncryption.class);
|
||||
|
||||
private static final String RANDOM_SHA1PRNG = "SHA1PRNG";
|
||||
|
||||
@@ -49,18 +49,18 @@ public class AES {
|
||||
private static final String UTF8 = "UTF8";
|
||||
|
||||
// 8-byte
|
||||
private static final byte[] KeyValues = { (byte) 0xA9, (byte) 0x9B, (byte) 0xC8, (byte) 0x32, (byte) 0x56, (byte) 0x35,
|
||||
private static final byte[] SEED = { (byte) 0xA9, (byte) 0x9B, (byte) 0xC8, (byte) 0x32, (byte) 0x56, (byte) 0x35,
|
||||
(byte) 0xE3, (byte) 0x03 };
|
||||
|
||||
private Cipher ecipher;
|
||||
|
||||
private Cipher dcipher;
|
||||
|
||||
public static AES getInstance() {
|
||||
return new AES();
|
||||
public static BouncyCastleEncryption getInstance() {
|
||||
return new BouncyCastleEncryption();
|
||||
}
|
||||
|
||||
public AES() {
|
||||
public BouncyCastleEncryption() {
|
||||
try {
|
||||
// TDI-28380: Database password in tac db configuration page becomes empty once restart tomcat on Solaris.
|
||||
// TDI-30348: Whole tac configuration lost for the passwords.
|
||||
@@ -69,7 +69,7 @@ public class AES {
|
||||
KeyGenerator keyGen = KeyGenerator.getInstance(ENCRYPTION_ALGORITHM, p);
|
||||
|
||||
SecureRandom random = SecureRandom.getInstance(RANDOM_SHA1PRNG);
|
||||
random.setSeed(KeyValues);
|
||||
random.setSeed(SEED);
|
||||
keyGen.init(128, random);
|
||||
|
||||
Key key = keyGen.generateKey();
|
||||
@@ -81,7 +81,7 @@ public class AES {
|
||||
dcipher.init(Cipher.DECRYPT_MODE, key);
|
||||
} catch (Exception e) {
|
||||
// log the error to avoid that break GWT service
|
||||
log.error(e.getMessage(), e);
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,18 +104,4 @@ public class AES {
|
||||
String decryptedData = new String(dec, UTF8);
|
||||
return decryptedData;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
AES aes = new AES();
|
||||
String[] arr = { "bt4AUzTV14kK8FwkcK/BNg==", "3IqdoqEElsy8Dzz9iP3HVQ==", "w4AXOA1a34afqqnlmVLB4A==",
|
||||
"m9Ut0k3oP5pLE2BH1r9xQA==", "zPfoS7aDB2mNUrpRfbfwcOza/VXudqA9QYULYn4xTb8=",
|
||||
"3mTjF2v1D4ZYqnJleFKl/wFybG4/24iyhCFKyEuveDY=" };
|
||||
try {
|
||||
for (String t : arr) {
|
||||
System.out.println(aes.decrypt(t));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.utils.security;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.talend.daikon.security.CryptoHelper;
|
||||
|
||||
/*
|
||||
* Created by bhe on Aug 13, 2019 This class is a wrapper class for CryptoHelper and is intended to be used by Migration
|
||||
* functionality only.
|
||||
*/
|
||||
public class CryptoMigrationUtil {
|
||||
|
||||
private CryptoMigrationUtil() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an encrypt function which depends on CryptoHelper.getDefault().encrypt
|
||||
*/
|
||||
public static Function<String, String> encryptFunc() {
|
||||
return (src) -> new CryptoHelper(CryptoHelper.PASSPHRASE).encrypt(src);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Create an decrypt function which depends on CryptoHelper.getDefault().decrypt
|
||||
*
|
||||
*/
|
||||
public static Function<String, String> decryptFunc() {
|
||||
return (src) -> new CryptoHelper(CryptoHelper.PASSPHRASE).decrypt(src);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt input string with CryptoHelper.getDefault().encrypt
|
||||
*/
|
||||
public static String encrypt(String src) {
|
||||
return new CryptoHelper(CryptoHelper.PASSPHRASE).encrypt(src);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt input string with CryptoHelper.getDefault().decrypt
|
||||
*/
|
||||
public static String decrypt(String src) {
|
||||
return new CryptoHelper(CryptoHelper.PASSPHRASE).decrypt(src);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt input string with given password
|
||||
*/
|
||||
public static String encrypt(String pwd, String src) {
|
||||
CryptoHelper ch = new CryptoHelper(pwd);
|
||||
return ch.encrypt(src);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt input string with given password
|
||||
*/
|
||||
public static String decrypt(String pwd, String src) {
|
||||
CryptoHelper ch = new CryptoHelper(pwd);
|
||||
return ch.decrypt(src);
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,11 @@
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.repository.ui.login.connections;
|
||||
package org.talend.utils.security;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.talend.daikon.security.CryptoHelper;
|
||||
import org.talend.utils.security.StudioEncryption;
|
||||
|
||||
|
||||
/**
|
||||
@@ -22,15 +22,10 @@ import org.talend.daikon.security.CryptoHelper;
|
||||
*/
|
||||
public class EncryptedProperties extends Properties {
|
||||
|
||||
private CryptoHelper crypto;
|
||||
|
||||
public EncryptedProperties() {
|
||||
crypto = new CryptoHelper("Il faudrait trouver une passphrase plus originale que celle-ci!");
|
||||
}
|
||||
|
||||
public String getProperty(String key) {
|
||||
try {
|
||||
return crypto.decrypt(super.getProperty(key));
|
||||
return StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM)
|
||||
.decrypt(super.getProperty(key));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Couldn't decrypt property");
|
||||
}
|
||||
@@ -38,7 +33,8 @@ public class EncryptedProperties extends Properties {
|
||||
|
||||
public synchronized Object setProperty(String key, String value) {
|
||||
try {
|
||||
return super.setProperty(key, crypto.encrypt(value));
|
||||
return super.setProperty(key,
|
||||
StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM).encrypt(value));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Couldn't encrypt property");
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.utils.security;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.talend.daikon.security.CryptoHelper;
|
||||
import org.talend.utils.security.StudioEncryption;
|
||||
|
||||
/*
|
||||
* <p>This class is intended to be used only for migrating old items persisted by studio whose version <=7.3.1</p>
|
||||
* <p>Main purpose of this class is to help migrate password field of connection,context,job,joblet. This class is
|
||||
* referenced by {@link org.talend.repository.model.migration.UpgradePasswordEncryptionAlg4ItemMigrationTask}</p>
|
||||
*/
|
||||
public class PasswordMigrationUtil {
|
||||
|
||||
public static String decryptPassword(String pass) throws Exception {
|
||||
String cleanPass = pass;
|
||||
if (StringUtils.isNotEmpty(pass)) {
|
||||
if (StudioEncryption.hasEncryptionSymbol(pass)) {
|
||||
cleanPass = StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM).decrypt(pass);
|
||||
} else {
|
||||
try {
|
||||
cleanPass = new CryptoHelper(CryptoHelper.PASSPHRASE).decrypt(pass);
|
||||
} catch (Exception e) {
|
||||
// Ignore here
|
||||
}
|
||||
}
|
||||
}
|
||||
return cleanPass;
|
||||
}
|
||||
|
||||
public static String encryptPasswordIfNeeded(String pass) throws Exception {
|
||||
String cleanPass = decryptPassword(pass);
|
||||
return StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM).encrypt(cleanPass);
|
||||
}
|
||||
|
||||
private PasswordMigrationUtil() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.utils.security;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.security.Provider;
|
||||
import java.security.Security;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.talend.daikon.crypto.CipherSource;
|
||||
import org.talend.daikon.crypto.CipherSources;
|
||||
import org.talend.daikon.crypto.Encryption;
|
||||
import org.talend.daikon.crypto.KeySource;
|
||||
import org.talend.daikon.crypto.KeySources;
|
||||
import org.talend.utils.StudioKeysFileCheck;
|
||||
|
||||
public class StudioEncryption {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(StudioEncryption.class);
|
||||
|
||||
// TODO We should remove default key after implements master key encryption algorithm
|
||||
private static final String ENCRYPTION_KEY = "Talend_TalendKey";// The length of key should be 16, 24 or 32.
|
||||
|
||||
private static final String ENCRYPTION_KEY_FILE_NAME = StudioKeysFileCheck.ENCRYPTION_KEY_FILE_NAME;
|
||||
|
||||
private static final String ENCRYPTION_KEY_FILE_SYS_PROP = StudioKeysFileCheck.ENCRYPTION_KEY_FILE_SYS_PROP;
|
||||
|
||||
private static final String PREFIX_PASSWORD = "ENC:["; //$NON-NLS-1$
|
||||
|
||||
private static final String POSTFIX_PASSWORD = "]"; //$NON-NLS-1$
|
||||
|
||||
// Encryption key property names
|
||||
private static final String KEY_SYSTEM = "system.encryption.key.v1";
|
||||
|
||||
private static final String KEY_MIGRATION_TOKEN = "migration.token.encryption.key";
|
||||
|
||||
private static final String KEY_ROUTINE = "routine.encryption.key";
|
||||
|
||||
public enum EncryptionKeyName {
|
||||
SYSTEM(KEY_SYSTEM),
|
||||
ROUTINE(KEY_ROUTINE),
|
||||
MIGRATION_TOKEN(KEY_MIGRATION_TOKEN);
|
||||
|
||||
private final String name;
|
||||
|
||||
EncryptionKeyName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
// set up key file
|
||||
updateConfig();
|
||||
}
|
||||
|
||||
private Encryption encryption;
|
||||
|
||||
private static final ThreadLocal<Map<EncryptionKeyName, KeySource>> LOCALCACHEDKEYSOURCES = ThreadLocal.withInitial(() -> {
|
||||
Map<EncryptionKeyName, KeySource> cachedKeySources = new HashMap<EncryptionKeyName, KeySource>();
|
||||
EncryptionKeyName[] keyNames = { EncryptionKeyName.SYSTEM, EncryptionKeyName.MIGRATION_TOKEN };
|
||||
for (EncryptionKeyName keyName : keyNames) {
|
||||
KeySource ks = loadKeySource(keyName);
|
||||
if (ks != null) {
|
||||
cachedKeySources.put(keyName, ks);
|
||||
}
|
||||
}
|
||||
cachedKeySources.put(EncryptionKeyName.ROUTINE, KeySources.fixedKey(ENCRYPTION_KEY));
|
||||
return cachedKeySources;
|
||||
});
|
||||
|
||||
private StudioEncryption(EncryptionKeyName encryptionKeyName, String providerName) {
|
||||
if (encryptionKeyName == null) {
|
||||
encryptionKeyName = EncryptionKeyName.SYSTEM;
|
||||
}
|
||||
|
||||
KeySource ks = LOCALCACHEDKEYSOURCES.get().get(encryptionKeyName);
|
||||
|
||||
if (ks == null) {
|
||||
ks = loadKeySource(encryptionKeyName);
|
||||
if (ks != null) {
|
||||
LOCALCACHEDKEYSOURCES.get().put(encryptionKeyName, ks);
|
||||
}
|
||||
}
|
||||
if (ks == null) {
|
||||
RuntimeException e = new IllegalArgumentException("Can not load encryption key data: " + encryptionKeyName.name);
|
||||
LOGGER.error(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
CipherSource cs = null;
|
||||
if (providerName != null && !providerName.isEmpty()) {
|
||||
Provider p = Security.getProvider(providerName);
|
||||
cs = CipherSources.aesGcm(12, 16, p);
|
||||
}
|
||||
|
||||
if (cs == null) {
|
||||
cs = CipherSources.getDefault();
|
||||
}
|
||||
|
||||
encryption = new Encryption(ks, cs);
|
||||
}
|
||||
|
||||
private static KeySource loadKeySource(EncryptionKeyName encryptionKeyName) {
|
||||
// EncryptionKeyName.SYSTEM, always load from system property firstly, then load from file
|
||||
if (encryptionKeyName == EncryptionKeyName.SYSTEM) {
|
||||
KeySource ks = KeySources.systemProperty(encryptionKeyName.name);
|
||||
try {
|
||||
if (ks.getKey() != null) {
|
||||
return ks;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug("StudioEncryption, can not get encryption key from system property: " + encryptionKeyName.name);
|
||||
}
|
||||
}
|
||||
// for others, tac,jobserver etc, load default keys from system property file, then load from jars if they are
|
||||
// not found in system properties
|
||||
KeySource ks = ResourceKeyFileSource.file(encryptionKeyName.name);
|
||||
try {
|
||||
if (ks.getKey() != null) {
|
||||
return ks;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("Can not load encryption key from file", e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String encrypt(String src) {
|
||||
// backward compatibility
|
||||
if (src == null) {
|
||||
return src;
|
||||
}
|
||||
try {
|
||||
if (!hasEncryptionSymbol(src)) {
|
||||
return PREFIX_PASSWORD + encryption.encrypt(src) + POSTFIX_PASSWORD;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// backward compatibility
|
||||
LOGGER.error("encrypt error", e);
|
||||
return null;
|
||||
}
|
||||
return src;
|
||||
}
|
||||
|
||||
public String decrypt(String src) {
|
||||
// backward compatibility
|
||||
if (src == null || src.isEmpty()) {
|
||||
return src;
|
||||
}
|
||||
try {
|
||||
if (hasEncryptionSymbol(src)) {
|
||||
return encryption
|
||||
.decrypt(src.substring(PREFIX_PASSWORD.length(), src.length() - POSTFIX_PASSWORD.length()));
|
||||
} else {
|
||||
return encryption.decrypt(src);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// backward compatibility
|
||||
LOGGER.error("decrypt error", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get instance of StudioEncryption with given encryption key name
|
||||
*
|
||||
* keyName - see {@link StudioEncryption.EncryptionKeyName}, {@link StudioEncryption.EncryptionKeyName.SYSTEM} by
|
||||
* default
|
||||
*/
|
||||
public static StudioEncryption getStudioEncryption(EncryptionKeyName keyName) {
|
||||
return new StudioEncryption(keyName, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get instance of StudioEncryption with given encryption key name, security provider is "BC"
|
||||
*
|
||||
* keyName - see {@link StudioEncryption.EncryptionKeyName}
|
||||
*/
|
||||
public static StudioEncryption getStudioBCEncryption(EncryptionKeyName keyName) {
|
||||
return new StudioEncryption(keyName, "BC");
|
||||
}
|
||||
|
||||
public static boolean hasEncryptionSymbol(String input) {
|
||||
if (input == null || input.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
return input.startsWith(PREFIX_PASSWORD) && input.endsWith(POSTFIX_PASSWORD);
|
||||
}
|
||||
|
||||
private static void updateConfig() {
|
||||
String keyPath = System.getProperty(ENCRYPTION_KEY_FILE_SYS_PROP);
|
||||
if (keyPath != null) {
|
||||
File keyFile = new File(keyPath);
|
||||
if (!keyFile.exists()) {
|
||||
if (isStudio()) {
|
||||
// load all keys
|
||||
Properties p = new Properties();
|
||||
try (InputStream fi = StudioEncryption.class.getResourceAsStream(ENCRYPTION_KEY_FILE_NAME)) {
|
||||
p.load(fi);
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("load encryption keys error", e);
|
||||
}
|
||||
// EncryptionKeyName.MIGRATION_TOKEN are not allowed to be updated
|
||||
p.remove(EncryptionKeyName.MIGRATION_TOKEN.name);
|
||||
|
||||
// persist keys to ~configuration/studio.keys
|
||||
try (OutputStream fo = new FileOutputStream(keyFile)) {
|
||||
p.store(fo, "studio encryption keys");
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("persist encryption keys error", e);
|
||||
}
|
||||
LOGGER.info("updateConfig, studio environment, key file setup completed");
|
||||
} else {
|
||||
LOGGER.info("updateConfig, non studio environment, skip setup of key file");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isStudio() {
|
||||
String osgiFramework = System.getProperty("osgi.framework");
|
||||
return osgiFramework != null && osgiFramework.contains("eclipse");
|
||||
}
|
||||
|
||||
private static class ResourceKeyFileSource implements KeySource {
|
||||
|
||||
private final String keyName;
|
||||
|
||||
private final Properties keyProperties = new Properties();
|
||||
|
||||
ResourceKeyFileSource(String keyName) {
|
||||
this.keyName = keyName;
|
||||
// load default keys from jar
|
||||
try (InputStream fi = StudioEncryption.class.getResourceAsStream(ENCRYPTION_KEY_FILE_NAME)) {
|
||||
keyProperties.load(fi);
|
||||
} catch (IOException e) {
|
||||
LOGGER.error(e);
|
||||
}
|
||||
|
||||
// load from file set in system property, so as to override default keys
|
||||
String keyPath = System.getProperty(ENCRYPTION_KEY_FILE_SYS_PROP);
|
||||
if (keyPath != null) {
|
||||
File keyFile = new File(keyPath);
|
||||
if (keyFile.exists()) {
|
||||
try (InputStream fi = new FileInputStream(keyFile)) {
|
||||
keyProperties.load(fi);
|
||||
} catch (IOException e) {
|
||||
LOGGER.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static KeySource file(String keyName) {
|
||||
return new ResourceKeyFileSource(keyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getKey() throws Exception {
|
||||
// load key
|
||||
String key = keyProperties.getProperty(this.keyName);
|
||||
if (key == null) {
|
||||
LOGGER.warn("Can not load " + this.keyName + " from file");
|
||||
throw new IllegalArgumentException("Invalid encryption key");
|
||||
} else {
|
||||
LOGGER.debug("Loaded " + this.keyName + " from file");
|
||||
byte[] keyData = Base64.getDecoder().decode(key.getBytes(StandardCharsets.UTF_8));
|
||||
return keyData;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
#talend OOTB encryption keys
|
||||
#Wed Sep 25 14:58:09 CST 2019
|
||||
migration.token.encryption.key=RuMmdh0ytquXjEyG9kd8HJ++egQA9gm8sTvGEKJctMw\=
|
||||
system.encryption.key.v1=ObIr3Je6QcJuxJEwErWaFWIxBzEjxIlBrtCPilSByJI\=
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<talend.nexus.url>https://artifacts-zl.talend.com</talend.nexus.url>
|
||||
<org.talend.daikon.crypto-utils.version>1.7.0</org.talend.daikon.crypto-utils.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
@@ -57,5 +59,46 @@
|
||||
<url>${tos.snapshots.repo.url}</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>talend_open</id>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<url>${talend.nexus.url}/nexus/content/repositories/TalendOpenSourceRelease/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>talend_open_snapshots</id>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
<url>${talend.nexus.url}/nexus/content/repositories/TalendOpenSourceSnapshot/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>releases</id>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<url>${talend.nexus.url}/nexus/content/repositories/releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>snapshots</id>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
<url>${talend.nexus.url}/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -10,7 +10,7 @@
|
||||
<artifactId>tcommon-studio-se</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<properties>
|
||||
<org.talend.daikon.crypto-utils.version>1.4.0_Studio</org.talend.daikon.crypto-utils.version>
|
||||
<org.talend.daikon.crypto-utils.version>0.31.10-SNAPSHOT</org.talend.daikon.crypto-utils.version>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
|
||||
@@ -118,6 +118,27 @@ public class VersionUtilsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTalendPureVersion() {
|
||||
String expect = "7.2.1";
|
||||
String test = "Talend Cloud Big Data-7.2.1.20190620_1446";
|
||||
String result = VersionUtils.getTalendPureVersion(test);
|
||||
assertEquals(expect,result);
|
||||
|
||||
test = "Talend Cloud Real-Time Big Data Platform-7.2.1.20190620_1446";
|
||||
result = VersionUtils.getTalendPureVersion(test);
|
||||
assertEquals(expect, result);
|
||||
|
||||
expect = "7.3.1";
|
||||
test = "Talend Cloud Big Data-7.3.1.20190917_1941-SNAPSHOT";
|
||||
result = VersionUtils.getTalendPureVersion(test);
|
||||
assertEquals(expect, result);
|
||||
|
||||
test = "Talend Cloud Real-Time Big Data Platform-7.3.1.20190917_1941-SNAPSHOT";
|
||||
result = VersionUtils.getTalendPureVersion(test);
|
||||
assertEquals(expect,result);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (mojo_properties != null && mojo_properties.exists()) {
|
||||
|
||||
@@ -98,7 +98,7 @@ public class ModuleNeededTest {
|
||||
.toURI();
|
||||
ModuleNeeded module1 = new ModuleNeeded("tMysqlInput", "tRowGenerator.xml", "description", false, null, null,
|
||||
"mvn:org.talend.libraries/tRowGenerator/6.0.0");
|
||||
ILibraryManagerService libService = (ILibraryManagerService) GlobalServiceRegister.getDefault().getService(
|
||||
ILibraryManagerService libService = GlobalServiceRegister.getDefault().getService(
|
||||
ILibraryManagerService.class);
|
||||
libService.deploy(testFileToDeploy, module1.getMavenUri());
|
||||
Assert.assertEquals(module1.getStatus(), ELibraryInstallStatus.INSTALLED);
|
||||
@@ -122,12 +122,12 @@ public class ModuleNeededTest {
|
||||
@Test
|
||||
public void testGetStatus1() throws URISyntaxException, IOException {
|
||||
// test jar installed in platform
|
||||
String mavenURI = "mvn:org.talend.libraries/commons-logging-1.1.1-emr-2.4.0/6.0.0/jar";
|
||||
String customURI = "mvn:org.talend.libraries/commons-logging-emr/6.0.0/jar";
|
||||
String platformURL = "platform:/plugin/org.talend.libraries.hadoop/lib/commons-logging-1.1.1-emr-2.4.0.jar";
|
||||
ILibraryManagerService libService = (ILibraryManagerService) GlobalServiceRegister.getDefault().getService(
|
||||
String mavenURI = "mvn:org.talend.libraries/hadoop-core-1.0.0/6.0.0/jar";
|
||||
String customURI = "mvn:org.talend.libraries/hadoop-core/6.0.0/jar";
|
||||
String platformURL = "platform:/plugin/org.talend.libraries.hadoop/lib/hadoop-core-1.0.0.jar";
|
||||
ILibraryManagerService libService = GlobalServiceRegister.getDefault().getService(
|
||||
ILibraryManagerService.class);
|
||||
ModuleNeeded module1 = new ModuleNeeded("", "commons-logging-1.1.1-emr-2.4.0.jar", "description", false, null, null,
|
||||
ModuleNeeded module1 = new ModuleNeeded("", "hadoop-core-1.0.0.jar", "description", false, null, null,
|
||||
mavenURI);
|
||||
module1.setModuleLocaion(platformURL);
|
||||
if (ELibraryInstallStatus.NOT_INSTALLED == module1.getStatus() || !libService.checkJarInstalledFromPlatform(platformURL)) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package org.talend.core.model.metadata.designerproperties;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.talend.core.model.metadata.builder.connection.ConnectionFactory;
|
||||
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
|
||||
import org.talend.daikon.security.CryptoHelper;
|
||||
import org.talend.utils.security.StudioEncryption;
|
||||
|
||||
/**
|
||||
* created by ycbai on 2016年3月11日
|
||||
@@ -20,7 +20,7 @@ public class RepositoryToComponentPropertyForPasswordTest {
|
||||
public void testGetPassword() {
|
||||
DatabaseConnection dbConnection = ConnectionFactory.eINSTANCE.createDatabaseConnection();
|
||||
dbConnection.setContextMode(false);
|
||||
String encryptPassword = CryptoHelper.getDefault().encrypt("thepassword"); //$NON-NLS-1$
|
||||
String encryptPassword = StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM).encrypt("thepassword"); //$NON-NLS-1$
|
||||
dbConnection.setPassword(encryptPassword);
|
||||
Object resultPassword = RepositoryToComponentProperty.getValue(dbConnection, "PASSWORD", null); //$NON-NLS-1$
|
||||
assertEquals("\"thepassword\"", resultPassword); //$NON-NLS-1$
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user