Compare commits
1 Commits
patch/8.0.
...
jphautin/f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3732127033 |
@@ -12,14 +12,7 @@
|
||||
// ============================================================================
|
||||
package org.talend.librariesmanager.model.service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
@@ -33,6 +26,12 @@ import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.RepositoryWorkUnit;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* created by wchen on Aug 18, 2017 Detailled comment
|
||||
*
|
||||
@@ -112,9 +111,12 @@ public class CustomUriManager {
|
||||
private String getResourcePath() {
|
||||
try {
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
IProject project = ResourceUtils.getProject(currentProject);
|
||||
IFolder settingsFolder = project.getFolder(".settings");
|
||||
return settingsFolder.getLocation().toPortableString();
|
||||
//when starting, the project could not be opened.
|
||||
if (currentProject != null) {
|
||||
IProject project = ResourceUtils.getProject(currentProject);
|
||||
IFolder settingsFolder = project.getFolder(".settings");
|
||||
return settingsFolder.getLocation().toPortableString();
|
||||
}
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
@@ -132,7 +134,7 @@ public class CustomUriManager {
|
||||
|
||||
public String get(String key) {
|
||||
reloadCustomMapping();
|
||||
if (customURIObject.containsKey(key)) {
|
||||
if (customURIObject != null && customURIObject.containsKey(key)) {
|
||||
return customURIObject.getString(key);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -12,11 +12,6 @@
|
||||
// ============================================================================
|
||||
package org.talend.librariesmanager.model.service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
@@ -33,6 +28,11 @@ import org.talend.librariesmanager.emf.librariesindex.LibrariesindexFactory;
|
||||
import org.talend.librariesmanager.emf.librariesindex.LibrariesindexPackage;
|
||||
import org.talend.librariesmanager.emf.librariesindex.util.LibrariesindexResourceFactoryImpl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class LibrariesIndexManager {
|
||||
|
||||
private LibrariesIndex studioLibIndex;
|
||||
@@ -58,6 +58,7 @@ public class LibrariesIndexManager {
|
||||
if (!new File(getStudioIndexPath()).exists()) {
|
||||
studioLibIndex = LibrariesindexFactory.eINSTANCE.createLibrariesIndex();
|
||||
} else {
|
||||
//try to load the existing data
|
||||
Resource resource = createLibrariesIndexResource(getIndexFileInstallFolder(), LIBRARIES_INDEX);
|
||||
Map optionMap = new HashMap();
|
||||
optionMap.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
|
||||
@@ -65,14 +66,22 @@ public class LibrariesIndexManager {
|
||||
optionMap.put(XMLResource.OPTION_USE_PARSER_POOL, new XMLParserPoolImpl());
|
||||
optionMap.put(XMLResource.OPTION_USE_XML_NAME_TO_FEATURE_MAP, new HashMap());
|
||||
optionMap.put(XMLResource.OPTION_USE_DEPRECATED_METHODS, Boolean.FALSE);
|
||||
resource.load(optionMap);
|
||||
studioLibIndex = (LibrariesIndex) EcoreUtil.getObjectByType(resource.getContents(),
|
||||
LibrariesindexPackage.eINSTANCE.getLibrariesIndex());
|
||||
try {
|
||||
resource.load(optionMap);
|
||||
studioLibIndex = (LibrariesIndex) EcoreUtil.getObjectByType(resource.getContents(),
|
||||
LibrariesindexPackage.eINSTANCE.getLibrariesIndex());
|
||||
} catch (Resource.IOWrappedException ioe) {
|
||||
//case of corrupted Index
|
||||
studioLibIndex = LibrariesindexFactory.eINSTANCE.createLibrariesIndex();
|
||||
createStudioIndexResource();
|
||||
throw ioe;
|
||||
}
|
||||
}
|
||||
|
||||
if (!new File(getMavenIndexPath()).exists()) {
|
||||
mavenLibIndex = LibrariesindexFactory.eINSTANCE.createLibrariesIndex();
|
||||
} else {
|
||||
//try to load the existing data
|
||||
Resource resource = createLibrariesIndexResource(getIndexFileInstallFolder(), MAVEN_INDEX);
|
||||
Map optionMap = new HashMap();
|
||||
optionMap.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
|
||||
@@ -80,9 +89,16 @@ public class LibrariesIndexManager {
|
||||
optionMap.put(XMLResource.OPTION_USE_PARSER_POOL, new XMLParserPoolImpl());
|
||||
optionMap.put(XMLResource.OPTION_USE_XML_NAME_TO_FEATURE_MAP, new HashMap());
|
||||
optionMap.put(XMLResource.OPTION_USE_DEPRECATED_METHODS, Boolean.FALSE);
|
||||
resource.load(optionMap);
|
||||
mavenLibIndex = (LibrariesIndex) EcoreUtil.getObjectByType(resource.getContents(),
|
||||
LibrariesindexPackage.eINSTANCE.getLibrariesIndex());
|
||||
try {
|
||||
resource.load(optionMap);
|
||||
mavenLibIndex = (LibrariesIndex) EcoreUtil.getObjectByType(resource.getContents(),
|
||||
LibrariesindexPackage.eINSTANCE.getLibrariesIndex());
|
||||
} catch (Resource.IOWrappedException ioe) {
|
||||
//case of corrupted Index
|
||||
mavenLibIndex = LibrariesindexFactory.eINSTANCE.createLibrariesIndex();
|
||||
createMavenIndexResource();
|
||||
throw ioe;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
@@ -99,6 +115,14 @@ public class LibrariesIndexManager {
|
||||
saveResource(mavenLibIndex, MAVEN_INDEX);
|
||||
}
|
||||
|
||||
public void createMavenIndexResource() {
|
||||
createLibrariesIndexResource(getIndexFileInstallFolder(), MAVEN_INDEX);
|
||||
}
|
||||
|
||||
public void createStudioIndexResource() {
|
||||
createLibrariesIndexResource(getIndexFileInstallFolder(), LIBRARIES_INDEX);
|
||||
}
|
||||
|
||||
private void saveResource(EObject eObject, String fileName) {
|
||||
try {
|
||||
Resource resource = createLibrariesIndexResource(getIndexFileInstallFolder(), fileName);
|
||||
|
||||
@@ -12,29 +12,6 @@
|
||||
// ============================================================================
|
||||
package org.talend.librariesmanager.model.service;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
@@ -66,13 +43,7 @@ import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.general.ModuleNeeded.ELibraryInstallStatus;
|
||||
import org.talend.core.model.general.ModuleStatusProvider;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.nexus.IRepositoryArtifactHandler;
|
||||
import org.talend.core.nexus.NexusConstants;
|
||||
import org.talend.core.nexus.NexusServerUtils;
|
||||
import org.talend.core.nexus.RepositoryArtifactHandlerManager;
|
||||
import org.talend.core.nexus.TalendLibsServerManager;
|
||||
import org.talend.core.nexus.TalendMavenResolver;
|
||||
import org.talend.core.nexus.*;
|
||||
import org.talend.core.prefs.ITalendCorePrefConstants;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenConstants;
|
||||
@@ -81,12 +52,20 @@ import org.talend.core.runtime.services.IMavenUIService;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.designer.maven.tools.BuildCacheManager;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
import org.talend.librariesmanager.emf.librariesindex.LibrariesIndex;
|
||||
import org.talend.librariesmanager.maven.MavenArtifactsHandler;
|
||||
import org.talend.librariesmanager.model.ExtensionModuleManager;
|
||||
import org.talend.librariesmanager.model.ModulesNeededProvider;
|
||||
import org.talend.librariesmanager.prefs.LibrariesManagerUtils;
|
||||
import org.talend.osgi.hook.notification.JarMissingObservable;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import java.io.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* DOC ycbai class global comment. Detailled comment
|
||||
*/
|
||||
@@ -129,7 +108,12 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
File indexFile = new File(LibrariesIndexManager.getInstance().getStudioIndexPath());
|
||||
File mvnIndexFile = new File(LibrariesIndexManager.getInstance().getMavenIndexPath());
|
||||
if (indexFile.exists() && mvnIndexFile.exists()) {
|
||||
return LibrariesIndexManager.getInstance().getStudioLibIndex().isInitialized();
|
||||
//case of corrupted index.
|
||||
if (LibrariesIndexManager.getInstance().getStudioLibIndex() == null) {
|
||||
return false;
|
||||
} else {
|
||||
return LibrariesIndexManager.getInstance().getStudioLibIndex().isInitialized();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1428,7 +1412,17 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
*/
|
||||
@Override
|
||||
public void savePlatfromURLIndex(Map<String, String> libsToRelativePath, IProgressMonitor... monitorWrap) {
|
||||
EMap<String, String> jarsToRelative = LibrariesIndexManager.getInstance().getStudioLibIndex().getJarsToRelativePath();
|
||||
LibrariesIndex studioLibrariesIndex = LibrariesIndexManager.getInstance().getStudioLibIndex();
|
||||
//check the index exists, otherwise create it.
|
||||
if (studioLibrariesIndex == null) {
|
||||
LibrariesIndexManager.getInstance().createStudioIndexResource();
|
||||
}
|
||||
//hope this work or cancel (disk full)
|
||||
studioLibrariesIndex = LibrariesIndexManager.getInstance().getStudioLibIndex();
|
||||
if (studioLibrariesIndex == null) {
|
||||
return;
|
||||
}
|
||||
EMap<String, String> jarsToRelative = studioLibrariesIndex.getJarsToRelativePath();
|
||||
boolean modified = false;
|
||||
for (String key : libsToRelativePath.keySet()) {
|
||||
if (checkJarInstalledFromPlatform(libsToRelativePath.get(key))) {
|
||||
@@ -1449,7 +1443,19 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
*/
|
||||
@Override
|
||||
public void saveMavenIndex(Map<String, String> libsMavenUriToDeploy, IProgressMonitor... monitorWrap) {
|
||||
EMap<String, String> jarsToMavenuri = LibrariesIndexManager.getInstance().getMavenLibIndex().getJarsToRelativePath();
|
||||
|
||||
LibrariesIndex libraryIndex = LibrariesIndexManager.getInstance().getMavenLibIndex();
|
||||
//check the index exists, otherwise create it.
|
||||
if (libraryIndex == null) {
|
||||
LibrariesIndexManager.getInstance().createMavenIndexResource();
|
||||
}
|
||||
//hope this work or cancel (disk full)
|
||||
libraryIndex = LibrariesIndexManager.getInstance().getMavenLibIndex();
|
||||
if (libraryIndex == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
EMap<String, String> jarsToMavenuri = libraryIndex.getJarsToRelativePath();
|
||||
boolean modified = false;
|
||||
for (String key : libsMavenUriToDeploy.keySet()) {
|
||||
String mvnUri = libsMavenUriToDeploy.get(key);
|
||||
@@ -1552,8 +1558,14 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
*/
|
||||
@Override
|
||||
public String getMavenUriFromIndex(String jarName) {
|
||||
EMap<String, String> jarsToMavenuri = LibrariesIndexManager.getInstance().getMavenLibIndex().getJarsToRelativePath();
|
||||
return jarsToMavenuri.get(jarName);
|
||||
LibrariesIndex mavenLibraryIndex = LibrariesIndexManager.getInstance().getMavenLibIndex();
|
||||
if (mavenLibraryIndex != null) {
|
||||
EMap<String, String> jarsToMavenuri = mavenLibraryIndex.getJarsToRelativePath();
|
||||
if (jarsToMavenuri != null) {
|
||||
jarsToMavenuri.get(jarName);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1593,8 +1605,12 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
*/
|
||||
@Override
|
||||
public String getPlatformURLFromIndex(String jarName) {
|
||||
EMap<String, String> platformURLMap = LibrariesIndexManager.getInstance().getStudioLibIndex().getJarsToRelativePath();
|
||||
return platformURLMap.get(jarName);
|
||||
LibrariesIndex librariesIndex = LibrariesIndexManager.getInstance().getStudioLibIndex();
|
||||
if (librariesIndex != null) {
|
||||
EMap<String, String> platformURLMap = librariesIndex.getJarsToRelativePath();
|
||||
return platformURLMap.get(jarName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user