Compare commits
5 Commits
release/7.
...
patch/7.3.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
649c936898 | ||
|
|
09a0818ab8 | ||
|
|
b993750342 | ||
|
|
6dcee0cd98 | ||
|
|
49aab27be9 |
@@ -126,6 +126,8 @@ public class PluginChecker {
|
||||
|
||||
public static final String BDEE_PLUGIN_ID = "org.talend.designer.bigdata"; //$NON-NLS-1$
|
||||
|
||||
public static final String BD_ROUTINE_PLUGIN_ID = "org.talend.designer.routines.bigdata"; //$NON-NLS-1$
|
||||
|
||||
public static final String DOCKER_PLUGIN_ID = "org.talend.designer.docker"; //$NON-NLS-1$
|
||||
|
||||
public static final String HELP_DI_EE_PLUGIN_ID = "org.talend.help.dataprep"; //$NON-NLS-1$
|
||||
@@ -364,6 +366,10 @@ public class PluginChecker {
|
||||
return isPluginLoaded(ESBSE_PLUGIN_ID);
|
||||
}
|
||||
|
||||
public static boolean isBigdataRoutineLoaded() {
|
||||
return isPluginLoaded(BD_ROUTINE_PLUGIN_ID);
|
||||
}
|
||||
|
||||
public static String getBundlePath(String bundleName) {
|
||||
String bundlePath = ""; //$NON-NLS-1$
|
||||
Bundle refBundle = Platform.getBundle(bundleName);
|
||||
|
||||
@@ -594,7 +594,7 @@ public class ContextUtils {
|
||||
return false;
|
||||
}
|
||||
// need check the raw value, because in sourceParam, it's raw
|
||||
if (!sourceParam.getValue().equals(targetParamType.getRawValue())) {
|
||||
if (!StringUtils.equals(sourceParam.getValue(), targetParamType.getRawValue())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -320,24 +320,28 @@ public class RepositoryUpdateManagerHelper {
|
||||
|
||||
// all the jobs
|
||||
for (IRepositoryViewObject process : processRep) {
|
||||
Item item = process.getProperty().getItem();
|
||||
boolean found = false;
|
||||
for (IProcess2 open : openedProcessList) {
|
||||
if (open.getId().equals(item.getProperty().getId())) {
|
||||
found = true;
|
||||
try {
|
||||
Item item = process.getProperty().getItem();
|
||||
boolean found = false;
|
||||
for (IProcess2 open : openedProcessList) {
|
||||
if (open.getId().equals(item.getProperty().getId())) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
continue;
|
||||
}
|
||||
checkMonitorCanceled(parentMonitor);
|
||||
parentMonitor.subTask(RepositoryUpdateManager.getUpdateJobInfor(item.getProperty()));
|
||||
if (found) {
|
||||
continue;
|
||||
}
|
||||
checkMonitorCanceled(parentMonitor);
|
||||
parentMonitor.subTask(RepositoryUpdateManager.getUpdateJobInfor(item.getProperty()));
|
||||
|
||||
// List<UpdateResult> resultFromProcess = getResultFromProcess(process, types, onlySimpleShow);
|
||||
// List<UpdateResult> resultFromProcess = getResultFromProcess(process, types, onlySimpleShow);
|
||||
|
||||
List<UpdateResult> resultFromProcess = getUpdatesNeededFromItems(parentMonitor, item, types);
|
||||
if (resultFromProcess != null) {
|
||||
resultList.addAll(resultFromProcess);
|
||||
List<UpdateResult> resultFromProcess = getUpdatesNeededFromItems(parentMonitor, item, types);
|
||||
if (resultFromProcess != null) {
|
||||
resultList.addAll(resultFromProcess);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ExceptionHandler.process(ex);
|
||||
}
|
||||
parentMonitor.worked(1);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.components.IComponentsFactory;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
|
||||
import org.talend.core.model.process.IContextManager;
|
||||
@@ -144,4 +145,8 @@ public interface IRepositoryService extends IService {
|
||||
|
||||
public void setShouldCheckRepoViewCommonNavigatorDirty(IRepositoryView repView, boolean shouldFlag);
|
||||
|
||||
boolean isProjectLevelLog4j2();
|
||||
|
||||
List<ModuleNeeded> getLog4j2Modules();
|
||||
|
||||
}
|
||||
|
||||
@@ -168,6 +168,10 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
|
||||
public void updateCodeProjects(IProgressMonitor monitor, boolean forceBuild) {
|
||||
updateCodeProjects(monitor, forceBuild, false);
|
||||
}
|
||||
|
||||
public void updateCodeProjects(IProgressMonitor monitor, boolean forceBuild, boolean ignoreM2Cache) {
|
||||
RepositoryWorkUnit workUnit = new RepositoryWorkUnit<Object>("update code project") { //$NON-NLS-1$
|
||||
|
||||
@Override
|
||||
@@ -175,8 +179,11 @@ public class AggregatorPomsHelper {
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
for (ERepositoryObjectType codeType : ERepositoryObjectType.getAllTypesOfCodes()) {
|
||||
try {
|
||||
if (CodeM2CacheManager.needUpdateCodeProject(currentProject, codeType)) {
|
||||
ITalendProcessJavaProject codeProject = getCodesProject(codeType);
|
||||
ITalendProcessJavaProject codeProject = getCodesProject(codeType);
|
||||
if (ERepositoryObjectType.ROUTINES == codeType) {
|
||||
PomUtil.checkExistingLog4j2Dependencies4RoutinePom(projectTechName, codeProject.getProjectPom());
|
||||
}
|
||||
if (ignoreM2Cache || CodeM2CacheManager.needUpdateCodeProject(currentProject, codeType)) {
|
||||
updateCodeProjectPom(monitor, codeType, codeProject.getProjectPom());
|
||||
buildAndInstallCodesProject(monitor, codeType, true, forceBuild);
|
||||
CodeM2CacheManager.updateCodeProjectCache(currentProject, codeType);
|
||||
@@ -860,7 +867,7 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
// codes pom
|
||||
monitor.subTask("Synchronize code poms"); //$NON-NLS-1$
|
||||
updateCodeProjects(monitor, true);
|
||||
updateCodeProjects(monitor, true, true);
|
||||
monitor.worked(1);
|
||||
if (monitor.isCanceled()) {
|
||||
return;
|
||||
|
||||
@@ -101,7 +101,7 @@ public class CodeM2CacheManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static File getCacheFile(String projectTechName, ERepositoryObjectType codeType) {
|
||||
public static File getCacheFile(String projectTechName, ERepositoryObjectType codeType) {
|
||||
String cacheFileName = PomIdsHelper.getProjectGroupId(projectTechName) + "." + codeType.name().toLowerCase() + "-" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ PomIdsHelper.getCodesVersion(projectTechName) + ".cache"; // $NON-NLS-1$
|
||||
return new File(MavenPlugin.getMaven().getLocalRepositoryPath(), cacheFileName);
|
||||
|
||||
@@ -136,7 +136,7 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
|
||||
|
||||
Map<ETalendMavenVariables, String> variablesValuesMap = new HashMap<ETalendMavenVariables, String>();
|
||||
// no need check property is null or not, because if null, will get default ids.
|
||||
JobInfo lastMainJob = LastGenerationInfo.getInstance().getLastMainJob();
|
||||
JobInfo lastMainJob = LastGenerationInfo.getInstance().getLastMainJob();
|
||||
if (JobUtils.isJob(property) && ProcessUtils.isChildRouteProcess(process) && lastMainJob != null) {
|
||||
variablesValuesMap.put(ETalendMavenVariables.JobGroupId, PomIdsHelper.getJobGroupId(lastMainJob.getProcessor().getProperty()));
|
||||
variablesValuesMap.put(ETalendMavenVariables.JobVersion, PomIdsHelper.getJobVersion(lastMainJob.getProcessor().getProperty()));
|
||||
@@ -318,10 +318,18 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
|
||||
String type = null;
|
||||
if (!jobInfo.isJoblet()) {
|
||||
property = jobInfo.getProcessItem().getProperty();
|
||||
groupId = PomIdsHelper.getJobGroupId(property);
|
||||
artifactId = PomIdsHelper.getJobArtifactId(jobInfo);
|
||||
|
||||
JobInfo lastMainJob = LastGenerationInfo.getInstance().getLastMainJob();
|
||||
if (lastMainJob != null && JobUtils.isJob(jobInfo) && JobUtils.isRoute(getJobProcessor().getProperty())) {
|
||||
groupId = PomIdsHelper.getJobGroupId(lastMainJob.getProcessor().getProperty());
|
||||
version = PomIdsHelper.getJobVersion(lastMainJob.getProcessor().getProperty());
|
||||
} else {
|
||||
groupId = PomIdsHelper.getJobGroupId(property);
|
||||
version = PomIdsHelper.getJobVersion(property);
|
||||
}
|
||||
|
||||
version = PomIdsHelper.getJobVersion(property);
|
||||
|
||||
// try to get the pom version of children job and load from the pom file.
|
||||
String childPomFileName = PomUtil.getPomFileName(jobInfo.getJobName(), jobInfo.getJobVersion());
|
||||
IProject codeProject = getJobProcessor().getCodeProject();
|
||||
|
||||
@@ -12,16 +12,18 @@
|
||||
// ============================================================================
|
||||
package org.talend.designer.maven.tools.creator;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.PluginChecker;
|
||||
import org.talend.core.model.general.ILibrariesService;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.designer.maven.template.MavenTemplateManager;
|
||||
import org.talend.repository.model.IRepositoryService;
|
||||
|
||||
/**
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
@@ -46,13 +48,18 @@ public class CreateMavenRoutinePom extends AbstractMavenCodesTemplatePom {
|
||||
// Set<ModuleNeeded> runningModules = routiensService.getRunningModules();
|
||||
// return runningModules;
|
||||
// }
|
||||
Set<ModuleNeeded> runningModules = new HashSet<>();
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
|
||||
ILibrariesService libService = (ILibrariesService) GlobalServiceRegister.getDefault().getService(
|
||||
ILibrariesService.class);
|
||||
Set<ModuleNeeded> runningModules = libService.getCodesModuleNeededs(ERepositoryObjectType.ROUTINES);
|
||||
return runningModules;
|
||||
runningModules.addAll(libService.getCodesModuleNeededs(ERepositoryObjectType.ROUTINES));
|
||||
}
|
||||
return Collections.emptySet();
|
||||
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRepositoryService.class)) {
|
||||
IRepositoryService repositoryService = GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
if (PluginChecker.isBigdataRoutineLoaded() && repositoryService.isProjectLevelLog4j2()) {
|
||||
runningModules.addAll(repositoryService.getLog4j2Modules());
|
||||
}
|
||||
}
|
||||
return runningModules;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ import org.talend.commons.utils.io.FilesUtils;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ILibraryManagerService;
|
||||
import org.talend.core.PluginChecker;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
import org.talend.core.model.process.JobInfo;
|
||||
@@ -98,10 +99,12 @@ import org.talend.designer.maven.model.TalendJavaProjectConstants;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.template.MavenTemplateManager;
|
||||
import org.talend.designer.maven.tools.AggregatorPomsHelper;
|
||||
import org.talend.designer.maven.tools.CodeM2CacheManager;
|
||||
import org.talend.designer.maven.tools.ProcessorDependenciesManager;
|
||||
import org.talend.designer.runprocess.IProcessor;
|
||||
import org.talend.designer.runprocess.IRunProcessService;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.model.IRepositoryService;
|
||||
import org.talend.utils.xml.XmlUtils;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
@@ -1188,4 +1191,49 @@ public class PomUtil {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
public static void checkExistingLog4j2Dependencies4RoutinePom(String projectTechName, IFile pomFile) {
|
||||
if (!PluginChecker.isBigdataRoutineLoaded()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRepositoryService.class)) {
|
||||
Model model = MODEL_MANAGER.readMavenModel(pomFile);
|
||||
IRepositoryService service = GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
boolean isLog4j2 = service.isProjectLevelLog4j2();
|
||||
Map<String, MavenArtifact> GAVMap = service.getLog4j2Modules().stream()
|
||||
.map(m -> MavenUrlHelper.parseMvnUrl(m.getMavenUri()))
|
||||
.collect(Collectors.toMap(MavenArtifact::getArtifactId, MavenArtifact -> MavenArtifact));
|
||||
long existingDependenciesSize = model.getDependencies().stream()
|
||||
.filter(d -> GAVMap.containsKey(d.getArtifactId())
|
||||
&& GAVMap.get(d.getArtifactId()).getGroupId().equals(d.getGroupId())
|
||||
&& GAVMap.get(d.getArtifactId()).getVersion().equals(d.getVersion()))
|
||||
.count();
|
||||
boolean clean = false;
|
||||
// CAUTION
|
||||
// with this fix, project level log4j2 user can use log4j2 api in routine directly in BD project
|
||||
// user should NEVER manually setup log4j2 in routine dependencies
|
||||
// or else routine install cache could always be cleaned
|
||||
if (isLog4j2 && existingDependenciesSize != GAVMap.size()) {
|
||||
// if project level log4j1 -> log4j2
|
||||
// if first time add log4j2 dependencies
|
||||
// if log4j2 upgrade version
|
||||
// then clean cache to add
|
||||
clean = true;
|
||||
} else if (!isLog4j2 && existingDependenciesSize > 0) {
|
||||
// if project level log4j2 -> log4j1
|
||||
// then clean cache to remove
|
||||
clean = true;
|
||||
}
|
||||
if (clean) {
|
||||
File cacheFile = CodeM2CacheManager.getCacheFile(projectTechName, ERepositoryObjectType.ROUTINES);
|
||||
if (cacheFile.exists()) {
|
||||
cacheFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user