Compare commits

...

3 Commits

Author SHA1 Message Date
zyuan-talend
3293b8f359 feat(TUP-26268): fix the NPE. (#4379) 2021-06-16 18:04:51 +08:00
hcyi
7527dda149 fix(TUP-31238):Library sync with JFrog/Nexus on studio startup doesn'… (#4376)
…t use proxy.
2021-06-11 17:38:28 +08:00
Zhiwei Xue
ddf653b4ea fix(TUP-31759):fix codes install issues on CI (#4372) 2021-06-11 15:26:46 +08:00
5 changed files with 105 additions and 52 deletions

View File

@@ -379,8 +379,11 @@ public class MetadataDialog extends Dialog {
metadataTableEditor = new MetadataTableEditor(outputMetaTable, titleOutput);
}
//enable dbcolumn manipulate feature only on Database output component
String nodeFamily = outputNode.getComponent().getOriginalFamilyName();
String rootFamily = nodeFamily != null ? nodeFamily.split("/")[0] : "";
String nodeFamily = "", rootFamily = "";
if ( outputNode != null && outputNode.getComponent() != null ) {
nodeFamily = outputNode.getComponent().getOriginalFamilyName();
rootFamily = nodeFamily != null ? nodeFamily.split("/")[0] : "";
}
if (rootFamily.equals("Databases")) {
outputMetaView = new DialogMetadataDBOutputTableEditorView(composite, SWT.NONE, metadataTableEditor, outputReadOnly, true,
true, false);
@@ -555,8 +558,11 @@ public class MetadataDialog extends Dialog {
metadataTableEditorForOutput = new MetadataTableEditor(outputMetaTable, titleOutput + " (Output)");
}
//Enable dbcolumn manipulate feature only on Database output component
String nodeFamily = outputNode.getComponent().getOriginalFamilyName();
String rootFamily = nodeFamily != null ? nodeFamily.split("/")[0] : "";
String nodeFamily = "", rootFamily = "";
if ( outputNode != null && outputNode.getComponent() != null ) {
nodeFamily = outputNode.getComponent().getOriginalFamilyName();
rootFamily = nodeFamily != null ? nodeFamily.split("/")[0] : "";
}
if (rootFamily.equals("Databases")) {
outputMetaView = new DialogMetadataDBOutputTableEditorView(compositesSachForm.getRightComposite(), SWT.NONE,
metadataTableEditorForOutput, outputReadOnly, true, true, false);

View File

@@ -891,16 +891,31 @@ public class AggregatorPomsHelper {
} else {
model.getModules().addAll(collectRefProjectModules(null));
}
boolean isCIMode = false;
if (IRunProcessService.get() != null) {
isCIMode = IRunProcessService.get().isCIMode();
}
createRootPom(model, true, monitor);
installRootPom(true);
monitor.worked(1);
if (monitor.isCanceled()) {
return;
}
// codes pom
monitor.subTask("Synchronize code poms"); //$NON-NLS-1$
updateCodeProjects(monitor, true, true);
if (isCIMode) {
System.setProperty("ignore.ci.mode", Boolean.TRUE.toString());
updateCodeProjects(monitor, true, true);
System.setProperty("ignore.ci.mode", Boolean.FALSE.toString());
} else {
updateCodeProjects(monitor, true, true);
}
CodesJarM2CacheManager.updateCodesJarProject(monitor, true, true, true);
monitor.worked(1);
if (monitor.isCanceled()) {
return;
@@ -956,6 +971,15 @@ public class AggregatorPomsHelper {
if (monitor.isCanceled()) {
return;
}
if (isCIMode) {
for (ERepositoryObjectType codeType : ERepositoryObjectType.getAllTypesOfCodes()) {
ITalendProcessJavaProject codeProject = getCodesProject(codeType);
if (codeProject != null) {
updateCodeProjectPom(monitor, codeType, codeProject.getProjectPom());
}
}
}
monitor.done();
}

View File

@@ -102,7 +102,11 @@ public abstract class AbstractMavenCodesTemplatePom extends AbstractMavenGeneral
existedDependencies = new ArrayList<Dependency>();
model.setDependencies(existedDependencies);
}
boolean isCIMode = false;
if (IRunProcessService.get() != null) {
isCIMode = IRunProcessService.get().isCIMode();
}
boolean ignoreCIMode = Boolean.getBoolean("ignore.ci.mode");
for (ModuleNeeded module : needModules) {
Dependency dependency = null;
// TDI-37032 add dependency only if jar available in maven
@@ -117,11 +121,8 @@ public abstract class AbstractMavenCodesTemplatePom extends AbstractMavenGeneral
} else {
isDeployed = true;
}
boolean isCIMode = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService runProcessService = GlobalServiceRegister.getDefault()
.getService(IRunProcessService.class);
isCIMode = runProcessService.isCIMode();
if (!isDeployed && ignoreCIMode) {
continue;
}
if (isCIMode || ignoreModuleInstallationStatus() || isDeployed) {
dependency = PomUtil.createModuleDependency(module.getMavenUri());

View File

@@ -15,6 +15,8 @@ package org.talend.librariesmanager.nexus;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
@@ -22,14 +24,17 @@ import java.util.List;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.Header;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.fluent.Request;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHeader;
import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import org.eclipse.core.runtime.IProgressMonitor;
import org.talend.commons.CommonsPlugin;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.utils.network.IProxySelectorProvider;
@@ -53,6 +58,8 @@ import net.sf.json.JSONObject;
*/
public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandler {
private static Logger LOGGER = Logger.getLogger(ArtifacoryRepositoryHandler.class);
private String SEARCH_SERVICE = "api/search/gavc?"; //$NON-NLS-1$
private static final String SEARCH_NAME = "api/search/artifact?";
@@ -194,18 +201,9 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
}
query = query + "v=" + versionToSearch;//$NON-NLS-1$
}
searchUrl = searchUrl + query;
Request request = Request.Get(searchUrl);
String userPass = serverBean.getUserName() + ":" + serverBean.getPassword(); //$NON-NLS-1$
String basicAuth = "Basic " + new String(new Base64().encode(userPass.getBytes())); //$NON-NLS-1$
Header authority = new BasicHeader("Authorization", basicAuth); //$NON-NLS-1$
request.addHeader(authority);
Header resultDetailHeader = new BasicHeader("X-Result-Detail", "info"); //$NON-NLS-1$ //$NON-NLS-2$
request.addHeader(resultDetailHeader);
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
HttpResponse response = request.execute().returnResponse();
String content = EntityUtils.toString(response.getEntity());
searchUrl = searchUrl + query;
String content = doRequest(searchUrl);//
if (content.isEmpty()) {
return resultList;
}
@@ -302,19 +300,9 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
}
q += "repos=" + repositoryId;//$NON-NLS-1$
}
searchUrl = searchUrl + q;
Request request = Request.Get(searchUrl);
String userPass = serverBean.getUserName() + ":" + serverBean.getPassword(); //$NON-NLS-1$
String basicAuth = "Basic " + new String(new Base64().encode(userPass.getBytes())); //$NON-NLS-1$
Header authority = new BasicHeader("Authorization", basicAuth); //$NON-NLS-1$
request.addHeader(authority);
Header resultDetailHeader = new BasicHeader("X-Result-Detail", "info"); //$NON-NLS-1$ //$NON-NLS-2$
request.addHeader(resultDetailHeader);
List<MavenArtifact> resultList = new ArrayList<MavenArtifact>();
HttpResponse response = request.execute().returnResponse();
String content = EntityUtils.toString(response.getEntity());
searchUrl = searchUrl + q;
String content = doRequest(searchUrl);//
if (content.isEmpty()) {
return resultList;
}
@@ -493,4 +481,34 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
return doSearch(query, SEARCH_NAME, true, fromSnapshot);
}
public String doRequest(final String url) throws URISyntaxException, Exception {
final StringBuffer sb = new StringBuffer();
new HttpClientTransport(url, serverBean.getUserName(), serverBean.getPassword()) {
@Override
protected HttpResponse execute(IProgressMonitor monitor, DefaultHttpClient httpClient, URI targetURI)
throws Exception {
HttpGet httpGet = new HttpGet(targetURI);
String userName = serverBean.getUserName();
if (StringUtils.isNotBlank(userName) && !Boolean.getBoolean("talend.studio.search.nexus3.disableBasicAuth")) {
String auth = userName + ":" + serverBean.getPassword();
String authHeader = "Basic " + new String(Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8)));
httpGet.setHeader(HttpHeaders.AUTHORIZATION, authHeader);
Header resultDetailHeader = new BasicHeader("X-Result-Detail", "info"); //$NON-NLS-1$ //$NON-NLS-2$
httpGet.addHeader(resultDetailHeader);
httpClient.setCredentialsProvider(null);
}
HttpResponse response = httpClient.execute(httpGet);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
sb.append(EntityUtils.toString(response.getEntity()));
} else {
LOGGER.info("Try to search " + url + " failed!");
throw new Exception(response.toString());
}
return response;
}
}.doRequest(null, new URI(url));
return sb.toString();
}
}

View File

@@ -150,28 +150,32 @@ public class ShareLibrariesUtil {
*/
public static void seachArtifacts(IProgressMonitor monitor, IRepositoryArtifactHandler artifactHandler,
Map<String, List<MavenArtifact>> snapshotArtifactMap, Map<String, List<MavenArtifact>> releaseArtifactMap,
Set<String> snapshotGroupIdSet, Set<String> releaseGroupIdSet) throws Exception {
Set<String> snapshotGroupIdSet, Set<String> releaseGroupIdSet) {
if (artifactHandler != null) {
checkCancel(monitor);
List<MavenArtifact> searchResults = new ArrayList<MavenArtifact>();
for (String groupId : releaseGroupIdSet) {
searchResults = artifactHandler.search(groupId, null, null, true, false);
if (searchResults != null) {
for (MavenArtifact result : searchResults) {
checkCancel(monitor);
ShareLibrariesUtil.putArtifactToMap(result, releaseArtifactMap, false);
try {
checkCancel(monitor);
List<MavenArtifact> searchResults = new ArrayList<MavenArtifact>();
for (String groupId : releaseGroupIdSet) {
searchResults = artifactHandler.search(groupId, null, null, true, false);
if (searchResults != null) {
for (MavenArtifact result : searchResults) {
checkCancel(monitor);
ShareLibrariesUtil.putArtifactToMap(result, releaseArtifactMap, false);
}
}
}
}
checkCancel(monitor);
for (String groupId : snapshotGroupIdSet) {
searchResults = artifactHandler.search(groupId, null, null, false, true);
if (searchResults != null) {
for (MavenArtifact result : searchResults) {
checkCancel(monitor);
ShareLibrariesUtil.putArtifactToMap(result, snapshotArtifactMap, true);
checkCancel(monitor);
for (String groupId : snapshotGroupIdSet) {
searchResults = artifactHandler.search(groupId, null, null, false, true);
if (searchResults != null) {
for (MavenArtifact result : searchResults) {
checkCancel(monitor);
ShareLibrariesUtil.putArtifactToMap(result, snapshotArtifactMap, true);
}
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}