Compare commits
1 Commits
patch/8.0.
...
wwang-tale
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c663af8e56 |
@@ -207,13 +207,9 @@ public interface ILibraryManagerService extends IService {
|
||||
* @return
|
||||
*/
|
||||
public boolean isJarNeedToBeDeployed(File jarFile);
|
||||
|
||||
public boolean isSameFile(File f1, File f2);
|
||||
|
||||
public void checkModuleStatus(ModuleNeeded module);
|
||||
|
||||
public String getJarNameFromMavenuri(String mavenURI);
|
||||
|
||||
public void guessMavenRUIFromIndex(File jarFile, Map<String, String> sourceAndMavenUri);
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
package org.talend.core.model.routines;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@@ -35,11 +34,6 @@ import org.talend.core.ILibraryManagerService;
|
||||
import org.talend.core.ISVNProviderServiceInCoreRuntime;
|
||||
import org.talend.core.PluginChecker;
|
||||
import org.talend.core.model.general.LibraryInfo;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.nexus.TalendLibsServerManager;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenConstants;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
|
||||
/**
|
||||
* wchen class global comment. Detailled comment
|
||||
@@ -103,11 +97,8 @@ public class RoutineLibraryMananger {
|
||||
URL fileUrl = FileLocator.toFileURL(entry);
|
||||
if(fileUrl != null){
|
||||
if (!"file".equals(fileUrl.getProtocol())) throw new IllegalArgumentException();
|
||||
File file = new File(fileUrl.getFile());
|
||||
if(needDeploy(fileUrl)) {
|
||||
URI fileUri = file.toURI();
|
||||
libManagerService.deploy(fileUri);
|
||||
}
|
||||
URI fileUri = new File(fileUrl.getFile()).toURI();
|
||||
libManagerService.deploy(fileUri);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("Cannot deploy: " + bundleName + path);
|
||||
@@ -122,55 +113,6 @@ public class RoutineLibraryMananger {
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean needDeploy(URL fileUrl) throws IOException, Exception {
|
||||
File file = new File(fileUrl.getFile());
|
||||
ILibraryManagerService libManagerService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
|
||||
libManagerService = (ILibraryManagerService) GlobalServiceRegister.getDefault().getService(
|
||||
ILibraryManagerService.class);
|
||||
}
|
||||
|
||||
if(libManagerService != null) {
|
||||
|
||||
Map<String, String> sourceAndMavenUri = new HashMap<>();
|
||||
libManagerService.guessMavenRUIFromIndex(file, sourceAndMavenUri);
|
||||
String mavUri = null;
|
||||
boolean isSnapshot = false;
|
||||
for(String key : sourceAndMavenUri.keySet()) {
|
||||
if(sourceAndMavenUri.get(key).equals(file.getPath())) {
|
||||
mavUri = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(mavUri == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final MavenArtifact parseMvnUrl = MavenUrlHelper.parseMvnUrl(mavUri);
|
||||
if (parseMvnUrl != null) {
|
||||
if (parseMvnUrl.getVersion() != null && parseMvnUrl.getVersion().endsWith(MavenConstants.SNAPSHOT)) {
|
||||
isSnapshot = true;
|
||||
}
|
||||
}
|
||||
TalendLibsServerManager manager = TalendLibsServerManager.getInstance();
|
||||
ArtifactRepositoryBean customNexusServer = manager.getCustomNexusServer();
|
||||
File jarFile = libManagerService.resolveJar(customNexusServer, mavUri);
|
||||
boolean exist = (jarFile != null && jarFile.exists());
|
||||
if(exist) {
|
||||
if(isSnapshot) {
|
||||
boolean isSame = libManagerService.isSameFile(jarFile, file);
|
||||
if(!isSame) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Map<String, List<LibraryInfo>> getRoutineAndJars() {
|
||||
if (routineAndJars == null) {
|
||||
|
||||
@@ -33,7 +33,6 @@ import org.talend.core.nexus.TalendLibsServerManager;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
import org.talend.librariesmanager.i18n.Messages;
|
||||
import org.talend.librariesmanager.nexus.utils.VersionUtil;
|
||||
|
||||
/**
|
||||
* created by Talend on 2015年7月31日 Detailled comment
|
||||
@@ -62,7 +61,6 @@ public abstract class ShareLibrareisHelper {
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
SubMonitor mainSubMonitor = SubMonitor.convert(monitor, filesToShare.size());
|
||||
VersionUtil versionUtil = new VersionUtil();
|
||||
|
||||
// collect groupId to search
|
||||
Set<String> groupIds = new HashSet<String>();
|
||||
@@ -107,8 +105,7 @@ public abstract class ShareLibrareisHelper {
|
||||
String rArtifact = remoteAtifact.getArtifactId();
|
||||
String rVersion = remoteAtifact.getVersion();
|
||||
if (groupId != null && artifactId != null && version != null && groupId.equals(rGroup)
|
||||
&& artifactId.equals(rArtifact) && (version.equals(rVersion)
|
||||
|| version.equals(versionUtil.getSNAPSHOTVersion(rVersion)))) {
|
||||
&& artifactId.equals(rArtifact) && version.equals(rVersion)) {
|
||||
eixst = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
}
|
||||
}
|
||||
|
||||
public void guessMavenRUIFromIndex(File jarFile, Map<String, String> sourceAndMavenUri) {
|
||||
private void guessMavenRUIFromIndex(File jarFile, Map<String, String> sourceAndMavenUri) {
|
||||
// TODO????? should deploy with all versions
|
||||
String urisFromIndex = LibrariesIndexManager.getInstance().getMavenLibIndex().getJarsToRelativePath()
|
||||
.get(jarFile.getName());
|
||||
@@ -1613,7 +1613,7 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
return isSameFile(jarFile, jarInLib);
|
||||
}
|
||||
|
||||
public boolean isSameFile(File f1, File f2) {
|
||||
private boolean isSameFile(File f1, File f2) {
|
||||
if (f1 == null || f2 == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,32 +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.librariesmanager.nexus.utils;
|
||||
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
|
||||
/**
|
||||
* DOC hwang class global comment. Detailled comment
|
||||
*/
|
||||
public class VersionUtil {
|
||||
|
||||
public String getSNAPSHOTVersion(String rVersion) {
|
||||
if(rVersion == null) {
|
||||
return rVersion;
|
||||
}
|
||||
if(rVersion.contains("-")) {
|
||||
return rVersion.substring(0, rVersion.indexOf("-") + 1) + MavenUrlHelper.VERSION_SNAPSHOT;
|
||||
}
|
||||
return rVersion;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,38 +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.librariesmanager.nexus.utils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* DOC hwang class global comment. Detailled comment
|
||||
*/
|
||||
public class VersionUtilTest {
|
||||
|
||||
@Test
|
||||
public void testGetSNAPSHOTVersion() {
|
||||
VersionUtil util = new VersionUtil();
|
||||
String rVersion = "6.0.0-20191015.030844-1";
|
||||
String result = util.getSNAPSHOTVersion(rVersion);
|
||||
Assert.assertEquals(result, "6.0.0-SNAPSHOT");
|
||||
|
||||
rVersion = null;
|
||||
result = util.getSNAPSHOTVersion(rVersion);
|
||||
Assert.assertNull(result);
|
||||
|
||||
rVersion = "6.0.0";
|
||||
result = util.getSNAPSHOTVersion(rVersion);
|
||||
Assert.assertEquals(result, "6.0.0");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user