Compare commits

...

5 Commits

17 changed files with 171 additions and 165 deletions

View File

@@ -17,9 +17,6 @@ import java.util.Map;
import org.apache.maven.model.License;
import org.apache.maven.model.Model;
import org.apache.maven.model.building.DefaultModelBuilderFactory;
import org.apache.maven.model.building.DefaultModelBuildingRequest;
import org.apache.maven.model.building.ModelBuildingResult;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystem;
@@ -99,16 +96,13 @@ public class MavenLibraryResolverProvider {
}
public Map<String, Object> resolveDescProperties(MavenArtifact aritfact) throws Exception {
Map<String, Object> properties = null;
MavenArtifact clonedArtifact = aritfact.clone();
clonedArtifact.setType("pom"); //$NON-NLS-1$
Map<String, Object> properties = new HashMap<String, Object>();
ArtifactResult result = resolveArtifact(clonedArtifact);
if (result != null && result.isResolved()) {
DefaultModelBuilderFactory factory = new DefaultModelBuilderFactory();
DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
request.setPomFile(result.getArtifact().getFile());
ModelBuildingResult modelResult = factory.newInstance().build(request);
Model model = modelResult.getEffectiveModel();
properties = new HashMap<String, Object>();
Model model = MavenPlugin.getMavenModelManager().readMavenModel(result.getArtifact().getFile());
if (model != null) {
properties.put("type", model.getPackaging()); //$NON-NLS-1$
properties.put("license.count", model.getLicenses().size()); //$NON-NLS-1$

View File

@@ -13,6 +13,11 @@ Bundle-ClassPath: lib/javax.ws.rs-api-2.0-m10.jar,
lib/cxf-rt-transports-http-2.7.7.jar,
lib/stax2-api-3.1.1.jar,
lib/woodstox-core-asl-4.2.0.jar,
lib/javax.activation-1.2.0.jar,
lib/javax.annotation-api-1.3.jar,
lib/jaxb-api-2.2.11.jar,
lib/jaxb-impl-2.1.13.jar,
lib/jaxb-runtime-2.3.2.jar,
.
Export-Package: javax.ws.rs,
javax.ws.rs.client,

View File

@@ -965,7 +965,6 @@ public class ExternalModulesInstallDialog extends TitleAreaDialog implements IMo
protected void launchIndividualDownload(final AtomicInteger enabledButtonCount, final ModuleToInstall data,
final Button button) {
button.setEnabled(false);
enabledButtonCount.decrementAndGet();
final DownloadModuleJob job = new DownloadModuleJob(Collections.singletonList(data));
job.addJobChangeListener(new JobChangeAdapter() {
@@ -983,12 +982,13 @@ public class ExternalModulesInstallDialog extends TitleAreaDialog implements IMo
ImportExternalJarAction.cleanupLib(installedModule);
} else {
message = Messages.getString("ExternalModulesInstallDialog_Download_Fialed", data.getName());; //$NON-NLS-1$
// set enable to let user be able to try download again
button.setEnabled(true);
}
MessageDialog.openInformation(getShell(),
Messages.getString("ExternalModulesInstallDialog.MessageDialog.Infor"), message); //$NON-NLS-1$
// need to force a refresh after install jars of component
if (installedModule.contains(data.getName())) {
enabledButtonCount.decrementAndGet();
}
if (enabledButtonCount.get() == 0) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
IDesignerCoreService service = (IDesignerCoreService) GlobalServiceRegister.getDefault()

View File

@@ -17,8 +17,10 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.lang.ArrayUtils;
@@ -47,6 +49,7 @@ import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.utils.system.EclipseCommandLine;
import org.talend.core.model.general.ModuleNeeded;
import org.talend.core.model.general.ModuleToInstall;
import org.talend.core.runtime.maven.MavenConstants;
import org.talend.librariesmanager.ui.LibManagerUiPlugin;
import org.talend.librariesmanager.utils.DownloadModuleRunnableWithLicenseDialog;
import org.talend.librariesmanager.utils.RemoteModulesHelper;
@@ -272,7 +275,7 @@ public class ExternalModulesInstallDialogWithProgress extends ExternalModulesIns
protected void buttonPressed(int buttonId) {
if (IDialogConstants.CLOSE_ID == buttonId) {
closePressed();
}// else cancel button has a listener already
} // else cancel button has a listener already
}
protected IProgressMonitor getProgressMonitor() {
@@ -557,7 +560,14 @@ public class ExternalModulesInstallDialogWithProgress extends ExternalModulesIns
installAllBtn.setEnabled(false);
try {
run(new DownloadModuleRunnableWithLicenseDialog(toInstall, getShell()));
DownloadModuleRunnableWithLicenseDialog downloadDialog = new DownloadModuleRunnableWithLicenseDialog(
toInstall, getShell());
run(downloadDialog);
Set<String> downloadFailed = downloadDialog.getDownloadFailed();
if (downloadFailed.size() > 0) {
updateFailedButtonStatus(downloadFailed, downloadDialog.getInstalledModules());
return;
}
// close the dialog box when the download is done if it has not been canceled
if (!getProgressMonitor().isCanceled()) {
setReturnCode(CANCEL);
@@ -577,6 +587,26 @@ public class ExternalModulesInstallDialogWithProgress extends ExternalModulesIns
}
});
}
private void updateFailedButtonStatus(Set<String> downloadFailed, Set<String> donwloadSuccessed) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
List<ModuleToInstall> inputList2 = new ArrayList<ModuleToInstall>();
for (ModuleToInstall module : inputList) {
if (downloadFailed.contains(module.getName())) {
module.setDistribution(MavenConstants.DOWNLOAD_MANUAL);
inputList2.add(module);
} else if (!donwloadSuccessed.contains(module.getName())) {
inputList2.add(module);
}
}
inputList = inputList2;
initialRunnableDone();
}
});
}
/**
* start initial runnable and block until is has finished. it then update the dialog window with the retreived data
@@ -615,22 +645,31 @@ public class ExternalModulesInstallDialogWithProgress extends ExternalModulesIns
@Override
protected void launchIndividualDownload(final AtomicInteger enabledButtonCount, ModuleToInstall data, final Button button) {
button.setEnabled(false);
enabledButtonCount.decrementAndGet();
boolean isDownloadSuccess = false;
DownloadModuleRunnableWithLicenseDialog downloadModuleRunnable = new DownloadModuleRunnableWithLicenseDialog(
Collections.singletonList(data), getShell());
try {
run(downloadModuleRunnable);
if (downloadModuleRunnable.getDownloadFailed().size() == 0) {
enabledButtonCount.decrementAndGet();
isDownloadSuccess = true;
}
} catch (InvocationTargetException e) {
individualDownloadFailed(enabledButtonCount, button);
individualDownloadFailed(enabledButtonCount, button, data);
// an error occured when fetching the modules, so report it to the user.
ExceptionHandler.process(e);
} catch (InterruptedException e) {
individualDownloadFailed(enabledButtonCount, button);
individualDownloadFailed(enabledButtonCount, button, null);
// the thread was interupted
ExceptionHandler.process(e);
} finally {// if button canceled then enable button
if (getProgressMonitor().isCanceled()) {
individualDownloadFailed(enabledButtonCount, button);
if (!isDownloadSuccess) {
if (getProgressMonitor().isCanceled()) {
individualDownloadFailed(enabledButtonCount, button, null);
} else {
individualDownloadFailed(enabledButtonCount, button, data);
}
} else {// keep button disabled and make download all button disabled if that was the last
Display.getDefault().syncExec(new Runnable() {
@@ -654,15 +693,21 @@ public class ExternalModulesInstallDialogWithProgress extends ExternalModulesIns
* @param enabledButtonCount
* @param button
*/
protected void individualDownloadFailed(final AtomicInteger enabledButtonCount, final Button button) {
protected void individualDownloadFailed(final AtomicInteger enabledButtonCount, final Button button,
final ModuleToInstall data) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
if (!button.isDisposed()) {
button.setEnabled(true);
enabledButtonCount.incrementAndGet();
installAllBtn.setEnabled(true);
if (data == null) {
if (!button.isDisposed()) {
button.setEnabled(true);
installAllBtn.setEnabled(true);
}
} else {
Set<String> failedSet = new HashSet<String>();
failedSet.add(data.getName());
updateFailedButtonStatus(failedSet, new HashSet<String>());
}
}
});
@@ -699,7 +744,7 @@ public class ExternalModulesInstallDialogWithProgress extends ExternalModulesIns
// remove duplicated
List<ModuleNeeded> required = new ArrayList<ModuleNeeded>(requiredModules);
IRunnableWithProgress notInstalledModulesRunnable = RemoteModulesHelper.getInstance().getNotInstalledModulesRunnable(
required, inputList, true, false);
required, inputList, true, true, false);
setBlockOnOpen(block);
setInitialRunnable(notInstalledModulesRunnable);
open();

View File

@@ -33,6 +33,7 @@ import org.talend.core.model.general.ILibrariesService;
import org.talend.core.model.general.ModuleNeeded.ELibraryInstallStatus;
import org.talend.core.model.general.ModuleStatusProvider;
import org.talend.core.model.general.ModuleToInstall;
import org.talend.librariesmanager.librarydata.LibraryDataService;
import org.talend.librariesmanager.ui.LibManagerUiPlugin;
import org.talend.librariesmanager.ui.i18n.Messages;
import org.talend.librariesmanager.ui.wizards.AcceptModuleLicensesWizard;
@@ -122,6 +123,7 @@ abstract public class DownloadModuleRunnable implements IRunnableWithProgress {
installedModules.add(module.getName());
} catch (Exception e) {
downloadFailed.add(module.getName());
LibraryDataService.getInstance().setJarMissing(module.getMavenUri());
Exception ex = new Exception("Download " + module.getName() + " : " + module.getMavenUri() + " failed!", e);
ExceptionHandler.process(ex);
continue;

View File

@@ -83,6 +83,7 @@ public class RemoteModulesHelper {
private final boolean collectModulesWithJarName;
private volatile boolean useLocalLicenseData;
private volatile boolean onlyUseLocalLicenseData;
/**
*
@@ -102,11 +103,12 @@ public class RemoteModulesHelper {
* @param toInstall
*/
private RemoteModulesFetchRunnable(Map<String, List<ModuleNeeded>> requiredModules, List<ModuleToInstall> toInstall,
boolean collectModulesWithJarName, boolean useLocalLicenseData) {
boolean collectModulesWithJarName, boolean useLocalLicenseData, boolean onlyUseLocalLicenseData) {
this.toInstall = toInstall;
this.contextMap = requiredModules;
this.collectModulesWithJarName = collectModulesWithJarName;
this.useLocalLicenseData = useLocalLicenseData;
this.onlyUseLocalLicenseData = onlyUseLocalLicenseData;
}
@Override
@@ -135,7 +137,7 @@ public class RemoteModulesHelper {
return;
}
if (addCachedModulesToToBeInstallModules(toInstall, mavenUrisTofetch, contextMap, getRemoteCache())) {
if (addCachedModulesToToBeInstallModules(toInstall, mavenUrisTofetch, contextMap, remoteCache)) {
if (collectModulesWithJarName) {
collectModulesWithJarName(toInstall);
}
@@ -154,12 +156,13 @@ public class RemoteModulesHelper {
} else {
if (useLocalLicenseData) {
searchFromLocalDataFile(mavenUrisTofetch, monitor);
} else {
addCachedModulesToToBeInstallModules(toInstall, mavenUrisTofetch, contextMap, remoteCache);
}
if (!onlyUseLocalLicenseData || LibraryDataService.getInstance().isBuildLibrariesData()) {
searchFromRemoteNexus(mavenUrisTofetch, monitor);
addCachedModulesToToBeInstallModules(toInstall, mavenUrisTofetch, contextMap, remoteCache);
}
addCachedModulesToToBeInstallModules(toInstall, mavenUrisTofetch, contextMap, getRemoteCache());
}
unavailableModules.addAll(mavenUrisTofetch);
addUnavailableModulesToToBeInstalledModules(unavailableModules, toInstall, contextMap);
@@ -176,13 +179,6 @@ public class RemoteModulesHelper {
monitor.done();
}
private Map<String, ModuleToInstall> getRemoteCache() {
if (useLocalLicenseData) {
return localLicenseDataCache;
}
return remoteCache;
}
private void searchFromLocalNexus(Set<String> mavenUristoSearch, IProgressMonitor monitor) {
try {
ArtifactRepositoryBean customNexusServer = TalendLibsServerManager.getInstance().getCustomNexusServer();
@@ -232,13 +228,13 @@ public class RemoteModulesHelper {
final MavenArtifact parseMvnUrl = MavenUrlHelper.parseMvnUrl(uriToCheck);
boolean isExist = false;
if (parseMvnUrl != null) {
isExist = service.fillLibraryData(uriToCheck, parseMvnUrl);
isExist = service.fillLibraryDataUseCache(uriToCheck, parseMvnUrl);
}
if (isExist) {
artifactList.add(parseMvnUrl);
}
}
addModulesToCache(mavenUristoSearch, artifactList, getRemoteCache());
addModulesToCache(mavenUristoSearch, artifactList, remoteCache);
}
private void searchFromRemoteNexus(Set<String> mavenUristoSearch, IProgressMonitor monitor) {
@@ -251,20 +247,15 @@ public class RemoteModulesHelper {
}
String uriToCheck = iterator.next();
final MavenArtifact parseMvnUrl = MavenUrlHelper.parseMvnUrl(uriToCheck);
Map<String, Object> properties;
try {
properties = service.resolveDescProperties(parseMvnUrl);
if (properties != null && properties.size() > 0) {
service.fillArtifactPropertyData(properties, parseMvnUrl);
if (!MavenConstants.DOWNLOAD_MANUAL.equals(parseMvnUrl.getDistribution())) {
artifactList.add(parseMvnUrl);
}
if (parseMvnUrl != null) {
service.fillLibraryDataByRemote(uriToCheck, parseMvnUrl);
if (!MavenConstants.DOWNLOAD_MANUAL.equals(parseMvnUrl.getDistribution())) {
artifactList.add(parseMvnUrl);
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
addModulesToCache(mavenUristoSearch, artifactList, getRemoteCache());
service.saveData();
addModulesToCache(mavenUristoSearch, artifactList, remoteCache);
}
private void addModulesToCache(Set<String> mavenUristoSearch, List<MavenArtifact> searchResults,
@@ -529,8 +520,8 @@ public class RemoteModulesHelper {
}
public RemoteModulesFetchRunnable createRemoteModuleFetchRunnable(final Map<String, List<ModuleNeeded>> requiredModules,
final List<ModuleToInstall> toInstall, boolean collectModulesWithJarName, boolean useLocalLicenseData) {
return new RemoteModulesFetchRunnable(requiredModules, toInstall, collectModulesWithJarName, useLocalLicenseData);
final List<ModuleToInstall> toInstall, boolean collectModulesWithJarName, boolean useLocalLicenseData, boolean onlyUseLocalLicenseData) {
return new RemoteModulesFetchRunnable(requiredModules, toInstall, collectModulesWithJarName, useLocalLicenseData, onlyUseLocalLicenseData);
}
private JSONObject readJsonFromUrl(String url) throws IOException {
@@ -626,7 +617,7 @@ public class RemoteModulesHelper {
* ModuleToInstall.mavenUris set to download all needed versions
*/
public RemoteModulesFetchRunnable getNotInstalledModulesRunnable(List<ModuleNeeded> neededModules,
List<ModuleToInstall> toInstall, boolean collectModulesWithJarName, boolean useLocalLicenseData) {
List<ModuleToInstall> toInstall, boolean collectModulesWithJarName, boolean useLocalLicenseData, boolean onlyUseLocalLicenseData) {
Map<String, List<ModuleNeeded>> contextMap = new HashMap<String, List<ModuleNeeded>>();
ILibraryManagerService librairesManagerService = (ILibraryManagerService) GlobalServiceRegister.getDefault()
.getService(ILibraryManagerService.class);
@@ -677,13 +668,13 @@ public class RemoteModulesHelper {
}
}
// fetch the jars which are not in cache.
return createRemoteModuleFetchRunnable(contextMap, toInstall, collectModulesWithJarName, useLocalLicenseData);
return createRemoteModuleFetchRunnable(contextMap, toInstall, collectModulesWithJarName, useLocalLicenseData, onlyUseLocalLicenseData);
}
public RemoteModulesFetchRunnable getNotInstalledModulesRunnable(List<ModuleNeeded> neededModules,
List<ModuleToInstall> toInstall) {
return getNotInstalledModulesRunnable(neededModules, toInstall, false, true);
return getNotInstalledModulesRunnable(neededModules, toInstall, false, true, false);
}
/**

View File

@@ -47,18 +47,6 @@
<library
name="crypto-utils.jar">
</library>
<library
name="slf4j-api-1.7.10.jar">
<bundleId
bundleId="org.talend.libraries.slf4j">
</bundleId>
</library>
<library
name="slf4j-log4j12-1.7.10.jar">
<bundleId
bundleId="org.talend.libraries.slf4j">
</bundleId>
</library>
</systemRoutine>
</extension>
<extension

View File

@@ -13,7 +13,7 @@
package org.talend.librariesmanager.librarydata;
import java.io.File;
import java.util.HashSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -53,13 +53,6 @@ public class LibraryDataService {
*/
public static final String KEY_LIBRARIES_DATA_FOLDER = "talend.libraries.folder"; //$NON-NLS-1$
/**
* {@value}
* <p>
* System property of retrieve library data, the default value is <b>true</b>.
*/
public static final String KEY_BUILD_LIBRARY_IF_MISSING = "talend.libraries.buildIfMissing"; //$NON-NLS-1$
/**
* {@value}
* <p>
@@ -75,8 +68,6 @@ public class LibraryDataService {
private boolean buildLibraryLicense = false;
private boolean buildLibraryIfLibraryMissing = true;
private boolean buildLibraryIfLicenseMissing = false;
private boolean buildLibraryJarFile = false;
@@ -87,7 +78,7 @@ public class LibraryDataService {
private LibraryDataJsonProvider dataProvider;
private Set<String> retievedMissingSet = new HashSet<String>();
private Map<String, Library> retievedCache = new HashMap<String, Library>();
private int repeatTime = 3;
@@ -95,7 +86,6 @@ public class LibraryDataService {
private LibraryDataService() {
buildLibraryLicense = Boolean.valueOf(System.getProperty(KEY_LIBRARIES_BUILD_LICENSE, Boolean.FALSE.toString()));
buildLibraryIfLibraryMissing = Boolean.valueOf(System.getProperty(KEY_BUILD_LIBRARY_IF_MISSING, Boolean.TRUE.toString()));
buildLibraryIfLicenseMissing = Boolean
.valueOf(System.getProperty(KEY_BUILD_LIBRARY_IF_LICENSE_MISSING, Boolean.FALSE.toString()));
buildLibraryJarFile = Boolean.valueOf(System.getProperty(KEY_LIBRARIES_BUILD_JAR, Boolean.FALSE.toString()));
@@ -133,68 +123,99 @@ public class LibraryDataService {
private Library resolve(String mvnUrl) {
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(mvnUrl);
String shourtMvnUrl = getShortMvnUrl(mvnUrl);
Library libraryObj = new Library();
libraryObj.setGroupId(artifact.getGroupId());
libraryObj.setArtifactId(artifact.getArtifactId());
libraryObj.setVersion(artifact.getVersion());
libraryObj.setMvnUrl(getShortMvnUrl(mvnUrl));
libraryObj.setMvnUrl(shourtMvnUrl);
libraryObj.setType(artifact.getType());
libraryObj.setClassifier(artifact.getClassifier());
boolean hasError = false;
logger.debug("Resolving artifact descriptor:" + getShortMvnUrl(mvnUrl)); //$NON-NLS-1$
for (int repeated = 0; repeated < repeatTime; repeated++) {
try {
if (repeated > 0) {
Thread.sleep(1000); // To avoid server connection pool shut down
libraryObj.setPomMissing(true);
boolean isRetry = false;
logger.debug("Resolving artifact descriptor:" + shourtMvnUrl); //$NON-NLS-1$
if (!retievedCache.containsKey(shourtMvnUrl)) {
for (int repeated = 0; repeated < repeatTime; repeated++) {
try {
if (repeated > 0) {
Thread.sleep(1000); // To avoid server connection pool shut down
}
Map<String, Object> properties = resolveDescProperties(artifact);
if (properties != null && properties.size() > 0) {
parseDescriptorResult(libraryObj, properties);
libraryObj.setPomMissing(false);
}
isRetry = false;
} catch (Exception ex) {
if (isBuildLibrariesData()) {
isRetry = true;
}
logger.info(ex);
}
if (!isRetry) {
break;
}
Map<String, Object> properties = resolveDescProperties(artifact);
parseDescriptorResult(libraryObj, properties);
hasError = false;
} catch (Exception e) {
hasError = true;
}
if (!hasError) {
break;
logger.debug("Resolved artifact descriptor:" + getShortMvnUrl(mvnUrl)); //$NON-NLS-1$
if (buildLibraryJarFile) {
boolean jarMissing = false;
try {
MavenLibraryResolverProvider.getInstance().resolveArtifact(artifact);
} catch (Exception ex) {
jarMissing = true;
} finally {
libraryObj.setJarMissing(jarMissing);
}
}
retievedCache.put(shourtMvnUrl, libraryObj);
} else {
libraryObj = retievedCache.get(shourtMvnUrl);
}
logger.debug("Resolved artifact descriptor:" + getShortMvnUrl(mvnUrl)); //$NON-NLS-1$
if (buildLibraryJarFile) {
boolean jarMissing = false;
try {
MavenLibraryResolverProvider.getInstance().resolveArtifact(artifact);
} catch (Exception ex) {
jarMissing = true;
} finally {
libraryObj.setJarMissing(jarMissing);
}
}
return libraryObj;
}
public Map<String, Object> resolveDescProperties(MavenArtifact artifact) throws Exception {
public void setJarMissing(String mvnUrl) {
String shortMvnUrl = getShortMvnUrl(mvnUrl);
Library libraryObj = mvnToLibraryMap.get(shortMvnUrl);
if (libraryObj != null) {
libraryObj.setJarMissing(true);
}
saveData();
}
public void saveData() {
dataProvider.saveLicenseData(mvnToLibraryMap);
}
private Map<String, Object> resolveDescProperties(MavenArtifact artifact) throws Exception {
Map<String, Object> properties = MavenLibraryResolverProvider.getInstance().resolveDescProperties(artifact);
return properties;
}
public void fillArtifactPropertyData(Map<String, Object> properties, MavenArtifact artifact) {
Library libraryObj = new Library();
libraryObj.setGroupId(artifact.getGroupId());
libraryObj.setArtifactId(artifact.getArtifactId());
libraryObj.setVersion(artifact.getVersion());
libraryObj.setMvnUrl(artifact.getUrl());
libraryObj.setType(artifact.getType());
libraryObj.setClassifier(artifact.getClassifier());
parseDescriptorResult(libraryObj, properties);
public void fillLibraryDataByRemote(String mvnUrl, MavenArtifact artifact) {
Library libraryObj = resolve(mvnUrl);
fillLibraryData(libraryObj, artifact);
}
public boolean fillLibraryDataUseCache(String mvnUrl, MavenArtifact artifact) {
boolean isExist = false;
String shortMvnUrl = getShortMvnUrl(mvnUrl);
Library object = mvnToLibraryMap.get(shortMvnUrl);
if (object != null) {
fillLibraryData(object, artifact);
isExist = !isPackagePom(object);
}
return isExist;
}
private boolean isPackagePom(Library libraryObj) {
if (libraryObj != null) {
if ("pom".equalsIgnoreCase(libraryObj.getType())) {
return true;
}
if (libraryObj.isJarMissing() || libraryObj.isPomMissing()) {
return true;
}
for (LibraryLicense license : libraryObj.getLicenses()) {
if (MavenConstants.DOWNLOAD_MANUAL.equalsIgnoreCase(license.getDistribution())) {
return true;
@@ -258,35 +279,7 @@ public class LibraryDataService {
return new File(folder, LIBRARIES_DATA_FILE_NAME);
}
public boolean fillLibraryData(String mvnUrl, MavenArtifact artifact) {
boolean isExist = false;
String shortMvnUrl = getShortMvnUrl(mvnUrl);
Library object = mvnToLibraryMap.get(shortMvnUrl);
if (!retievedMissingSet.contains(mvnUrl) && ((object == null && buildLibraryIfLibraryMissing)
|| (object.isLicenseMissing() && buildLibraryIfLicenseMissing))) {
Library newObject = null;
retievedMissingSet.add(mvnUrl);
try {
newObject = resolve(mvnUrl);
} catch (Exception e) {
logger.warn("Resolve pom failed:" + shortMvnUrl); //$NON-NLS-1$
}
if (newObject != null && (evaluateLibrary(newObject) > evaluateLibrary(object))) {
object = newObject;
mvnToLibraryMap.put(shortMvnUrl, object);
dataProvider.saveLicenseData(mvnToLibraryMap);
}
}
if (object != null) {
if ("jar".equalsIgnoreCase(object.getType()) && !object.isJarMissing() && !object.isPomMissing()) {
isExist = true;
}
fillLibraryData(object, artifact);
}
return isExist;
}
public void fillLibraryData(Library object, MavenArtifact artifact) {
private void fillLibraryData(Library object, MavenArtifact artifact) {
if (object != null && artifact != null) {
List<LibraryLicense> objLicenseList = object.getLicenses();
LibraryLicense bestLicense = null;
@@ -305,6 +298,8 @@ public class LibraryDataService {
if (isPackagePom(object)) {
artifact.setDistribution(MavenConstants.DOWNLOAD_MANUAL);
}
} else {
artifact.setDistribution(MavenConstants.DOWNLOAD_MANUAL);
}
}
@@ -314,18 +309,4 @@ public class LibraryDataService {
}
return mvnUrl;
}
private int evaluateLibrary(Library obj1) {
int score = -1;
if (obj1 != null) {
score++;
if (!obj1.isJarMissing()) {
score++;
}
if (!obj1.isLicenseMissing()) {
score += 2;
}
}
return score;
}
}

View File

@@ -63,7 +63,7 @@ public class PluginOptionalMissingJarsExtraUpdatesFactory extends AbstractExtraU
// jface because it adds graphical
// dependencies.
IRunnableWithProgress notInstalledModulesRunnable = RemoteModulesHelper.getInstance().getNotInstalledModulesRunnable(
unistalledModulesNeeded, modulesRequiredToBeInstalled, true, true);
unistalledModulesNeeded, modulesRequiredToBeInstalled, true, true, true);
if (notInstalledModulesRunnable != null) {// some data need to be fetched
try {
notInstalledModulesRunnable.run(mainSubMonitor.newChild(1));

View File

@@ -59,7 +59,7 @@ public class PluginRequiredMissingJarsExtraUpdatesFactory extends AbstractExtraU
// fetch missing jar information from remote web site.
ArrayList<ModuleToInstall> modulesRequiredToBeInstalled = new ArrayList<ModuleToInstall>();
IRunnableWithProgress notInstalledModulesRunnable = RemoteModulesHelper.getInstance().getNotInstalledModulesRunnable(
allUninstalledModules, modulesRequiredToBeInstalled, true, !isCheckUpdateOnLine);// IRunnableWithProgress should not be part
allUninstalledModules, modulesRequiredToBeInstalled, true, !isCheckUpdateOnLine, false);// IRunnableWithProgress should not be part
// of
// jface because it adds graphical
// dependencies.

View File

@@ -10,7 +10,7 @@
<artifactId>tcommon-studio-se</artifactId>
<packaging>pom</packaging>
<properties>
<org.talend.daikon.crypto-utils.version>1.4.0</org.talend.daikon.crypto-utils.version>
<org.talend.daikon.crypto-utils.version>1.4.0_Studio</org.talend.daikon.crypto-utils.version>
</properties>
<repositories>
<repository>

View File

@@ -60,7 +60,7 @@ public class RemoteModulesHelperTest {
neededModules.add(m5);
List<ModuleToInstall> toInstall1 = new ArrayList<ModuleToInstall>();
IRunnableWithProgress notInstalledModulesRunnable = RemoteModulesHelper.getInstance()
.getNotInstalledModulesRunnable(neededModules, toInstall1, false, false);
.getNotInstalledModulesRunnable(neededModules, toInstall1, false, false, false);
notInstalledModulesRunnable.run(new NullProgressMonitor());
assertEquals(4, toInstall1.size());
@@ -74,7 +74,7 @@ public class RemoteModulesHelperTest {
neededModules.add(m1);
List<ModuleToInstall> toInstall1 = new ArrayList<ModuleToInstall>();
IRunnableWithProgress notInstalledModulesRunnable = RemoteModulesHelper.getInstance()
.getNotInstalledModulesRunnable(neededModules, toInstall1, false, false);
.getNotInstalledModulesRunnable(neededModules, toInstall1, false, false, false);
notInstalledModulesRunnable.run(new NullProgressMonitor());
assertEquals(1, toInstall1.size());
Assert.assertEquals("protobuf-java-2.6.1.jar", toInstall1.get(0).getName());
@@ -86,7 +86,7 @@ public class RemoteModulesHelperTest {
neededModules.add(m2);
toInstall1 = new ArrayList<ModuleToInstall>();
notInstalledModulesRunnable = RemoteModulesHelper.getInstance().getNotInstalledModulesRunnable(neededModules, toInstall1,
false, false);
false, false, false);
notInstalledModulesRunnable.run(new NullProgressMonitor());
assertEquals(1, toInstall1.size());
Assert.assertEquals("protobuf-java.jar", toInstall1.get(0).getName());