提交 153cde55 编写于 作者: J jurgen

Maven dependencies model

Former-commit-id: d8db2561
上级 68e0dfb7
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
package org.jkiss.dbeaver.registry; package org.jkiss.dbeaver.registry;
import org.jkiss.dbeaver.model.DBPDriverFile; import org.jkiss.dbeaver.model.DBPDriverLibrary;
import org.jkiss.utils.CommonUtils; import org.jkiss.utils.CommonUtils;
import java.io.File; import java.io.File;
...@@ -43,8 +43,8 @@ public class DriverClassLoader extends URLClassLoader ...@@ -43,8 +43,8 @@ public class DriverClassLoader extends URLClassLoader
protected String findLibrary(String libname) protected String findLibrary(String libname)
{ {
String nativeName = System.mapLibraryName(libname); String nativeName = System.mapLibraryName(libname);
for (DriverFileDescriptor driverFile : driver.getDriverFiles()) { for (DriverLibraryDescriptor driverFile : driver.getDriverLibraries()) {
if (driverFile.getType() == DBPDriverFile.FileType.lib && driverFile.matchesCurrentPlatform()) { if (driverFile.getType() == DBPDriverLibrary.FileType.lib && driverFile.matchesCurrentPlatform()) {
final File localFile = driverFile.getLocalFile(); final File localFile = driverFile.getLocalFile();
if (localFile != null && localFile.exists()) { if (localFile != null && localFile.exists()) {
final String fileName = localFile.getName(); final String fileName = localFile.getName();
......
...@@ -102,8 +102,8 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver ...@@ -102,8 +102,8 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
private boolean disabled; private boolean disabled;
private final List<String> clientHomeIds = new ArrayList<String>(); private final List<String> clientHomeIds = new ArrayList<String>();
private final List<DriverFileSource> fileSources = new ArrayList<DriverFileSource>(); private final List<DriverFileSource> fileSources = new ArrayList<DriverFileSource>();
private final List<DriverFileDescriptor> files = new ArrayList<DriverFileDescriptor>(); private final List<DriverLibraryDescriptor> files = new ArrayList<DriverLibraryDescriptor>();
private final List<DriverFileDescriptor> origFiles = new ArrayList<DriverFileDescriptor>(); private final List<DriverLibraryDescriptor> origFiles = new ArrayList<DriverLibraryDescriptor>();
private final List<DriverPathDescriptor> pathList = new ArrayList<DriverPathDescriptor>(); private final List<DriverPathDescriptor> pathList = new ArrayList<DriverPathDescriptor>();
private final List<DBPPropertyDescriptor> connectionPropertyDescriptors = new ArrayList<DBPPropertyDescriptor>(); private final List<DBPPropertyDescriptor> connectionPropertyDescriptors = new ArrayList<DBPPropertyDescriptor>();
private final List<OSDescriptor> supportedSystems = new ArrayList<OSDescriptor>(); private final List<OSDescriptor> supportedSystems = new ArrayList<OSDescriptor>();
...@@ -170,7 +170,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver ...@@ -170,7 +170,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
this.isLoaded = false; this.isLoaded = false;
for (IConfigurationElement lib : config.getChildren(RegistryConstants.TAG_FILE)) { for (IConfigurationElement lib : config.getChildren(RegistryConstants.TAG_FILE)) {
this.files.add(new DriverFileDescriptor(this, lib)); this.files.add(new DriverLibraryDescriptor(this, lib));
} }
this.origFiles.addAll(this.files); this.origFiles.addAll(this.files);
...@@ -430,7 +430,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver ...@@ -430,7 +430,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
private boolean hasValidLibraries() private boolean hasValidLibraries()
{ {
for (DriverFileDescriptor lib : files) { for (DriverLibraryDescriptor lib : files) {
File file = lib.getLocalFile(); File file = lib.getLocalFile();
if (file != null && file.exists()) { if (file != null && file.exists()) {
return true; return true;
...@@ -635,14 +635,14 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver ...@@ -635,14 +635,14 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
@NotNull @NotNull
@Override @Override
public Collection<DriverFileDescriptor> getDriverFiles() public Collection<DriverLibraryDescriptor> getDriverLibraries()
{ {
return files; return files;
} }
public DriverFileDescriptor getDriverFile(String path) public DriverLibraryDescriptor getDriverFile(String path)
{ {
for (DriverFileDescriptor lib : files) { for (DriverLibraryDescriptor lib : files) {
if (lib.getPath().equals(path)) { if (lib.getPath().equals(path)) {
return lib; return lib;
} }
...@@ -650,19 +650,19 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver ...@@ -650,19 +650,19 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
return null; return null;
} }
public DriverFileDescriptor addDriverFile(String path, DBPDriverFile.FileType fileType) public DriverLibraryDescriptor addDriverFile(String path, DBPDriverLibrary.FileType fileType)
{ {
for (DriverFileDescriptor lib : files) { for (DriverLibraryDescriptor lib : files) {
if (lib.getPath().equals(path)) { if (lib.getPath().equals(path)) {
return lib; return lib;
} }
} }
DriverFileDescriptor lib = new DriverFileDescriptor(this, fileType, path); DriverLibraryDescriptor lib = new DriverLibraryDescriptor(this, fileType, path);
addDriverFile(lib); addDriverFile(lib);
return lib; return lib;
} }
public boolean addDriverFile(DriverFileDescriptor descriptor) public boolean addDriverFile(DriverLibraryDescriptor descriptor)
{ {
resetDriverInstance(); resetDriverInstance();
if (!files.contains(descriptor)) { if (!files.contains(descriptor)) {
...@@ -672,7 +672,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver ...@@ -672,7 +672,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
return false; return false;
} }
public boolean removeDriverFile(DriverFileDescriptor lib) public boolean removeDriverFile(DriverLibraryDescriptor lib)
{ {
resetDriverInstance(); resetDriverInstance();
if (!lib.isCustom()) { if (!lib.isCustom()) {
...@@ -798,8 +798,8 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver ...@@ -798,8 +798,8 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
public String getLicense() public String getLicense()
{ {
for (DriverFileDescriptor file : files) { for (DriverLibraryDescriptor file : files) {
if (file.getType() == DBPDriverFile.FileType.license) { if (file.getType() == DBPDriverLibrary.FileType.license) {
final File licenseFile = file.getLocalFile(); final File licenseFile = file.getLocalFile();
if (licenseFile != null && licenseFile.exists()) { if (licenseFile != null && licenseFile.exists()) {
try { try {
...@@ -875,8 +875,8 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver ...@@ -875,8 +875,8 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
List<URL> libraryURLs = new ArrayList<URL>(); List<URL> libraryURLs = new ArrayList<URL>();
// Load libraries // Load libraries
for (DriverFileDescriptor file : files) { for (DriverLibraryDescriptor file : files) {
if (file.isDisabled() || file.getType() != DBPDriverFile.FileType.jar) { if (file.isDisabled() || file.getType() != DBPDriverLibrary.FileType.jar) {
continue; continue;
} }
File localFile = file.getLocalFile(); File localFile = file.getLocalFile();
...@@ -902,7 +902,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver ...@@ -902,7 +902,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
@Override @Override
public void validateFilesPresence(final DBRRunnableContext runnableContext) public void validateFilesPresence(final DBRRunnableContext runnableContext)
{ {
for (DriverFileDescriptor file : files) { for (DriverLibraryDescriptor file : files) {
if (file.isCustom()) { if (file.isCustom()) {
File localFile = file.getLocalFile(); File localFile = file.getLocalFile();
if (localFile != null && localFile.exists()) { if (localFile != null && localFile.exists()) {
...@@ -912,8 +912,8 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver ...@@ -912,8 +912,8 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
} }
} }
final List<DriverFileDescriptor> downloadCandidates = new ArrayList<DriverFileDescriptor>(); final List<DriverLibraryDescriptor> downloadCandidates = new ArrayList<DriverLibraryDescriptor>();
for (DriverFileDescriptor file : files) { for (DriverLibraryDescriptor file : files) {
if (file.isDisabled() || !file.isDownloadable()) { if (file.isDisabled() || !file.isDownloadable()) {
// Nothing we can do about it // Nothing we can do about it
continue; continue;
...@@ -938,16 +938,11 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver ...@@ -938,16 +938,11 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
} }
} }
@Override
public void updateFiles(DBRRunnableContext runnableContext) {
}
public boolean acceptDriverLicenses(DBRRunnableContext runnableContext) public boolean acceptDriverLicenses(DBRRunnableContext runnableContext)
{ {
// User must accept all licenses before actual drivers download // User must accept all licenses before actual drivers download
for (final DriverFileDescriptor file : getDriverFiles()) { for (final DriverLibraryDescriptor file : getDriverLibraries()) {
if (file.getType() == DBPDriverFile.FileType.license) { if (file.getType() == DBPDriverLibrary.FileType.license) {
final File libraryFile = file.getLocalFile(); final File libraryFile = file.getLocalFile();
if (libraryFile == null || !libraryFile.exists()) { if (libraryFile == null || !libraryFile.exists()) {
try { try {
...@@ -1019,7 +1014,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver ...@@ -1019,7 +1014,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
return origSampleURL; return origSampleURL;
} }
public List<DriverFileDescriptor> getOrigFiles() public List<DriverLibraryDescriptor> getOrigFiles()
{ {
return origFiles; return origFiles;
} }
...@@ -1059,7 +1054,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver ...@@ -1059,7 +1054,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
} }
// Libraries // Libraries
for (DriverFileDescriptor lib : this.getDriverFiles()) { for (DriverLibraryDescriptor lib : this.getDriverLibraries()) {
if ((export && !lib.isDisabled()) || lib.isCustom() || lib.isDisabled()) { if ((export && !lib.isDisabled()) || lib.isCustom() || lib.isDisabled()) {
xml.startElement(RegistryConstants.TAG_LIBRARY); xml.startElement(RegistryConstants.TAG_LIBRARY);
xml.addAttribute(RegistryConstants.ATTR_TYPE, lib.getType().name()); xml.addAttribute(RegistryConstants.ATTR_TYPE, lib.getType().name());
...@@ -1231,20 +1226,20 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver ...@@ -1231,20 +1226,20 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
log.warn("File outside of driver"); log.warn("File outside of driver");
return; return;
} }
DBPDriverFile.FileType type; DBPDriverLibrary.FileType type;
String typeStr = atts.getValue(RegistryConstants.ATTR_TYPE); String typeStr = atts.getValue(RegistryConstants.ATTR_TYPE);
if (CommonUtils.isEmpty(typeStr)) { if (CommonUtils.isEmpty(typeStr)) {
type = DBPDriverFile.FileType.jar; type = DBPDriverLibrary.FileType.jar;
} else { } else {
try { try {
type = DBPDriverFile.FileType.valueOf(typeStr); type = DBPDriverLibrary.FileType.valueOf(typeStr);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
log.warn(e); log.warn(e);
type = DBPDriverFile.FileType.jar; type = DBPDriverLibrary.FileType.jar;
} }
} }
String path = atts.getValue(RegistryConstants.ATTR_PATH); String path = atts.getValue(RegistryConstants.ATTR_PATH);
DriverFileDescriptor lib = curDriver.getDriverFile(path); DriverLibraryDescriptor lib = curDriver.getDriverFile(path);
String disabledAttr = atts.getValue(RegistryConstants.ATTR_DISABLED); String disabledAttr = atts.getValue(RegistryConstants.ATTR_DISABLED);
if (lib != null && CommonUtils.getBoolean(disabledAttr)) { if (lib != null && CommonUtils.getBoolean(disabledAttr)) {
lib.setDisabled(true); lib.setDisabled(true);
......
...@@ -19,7 +19,6 @@ package org.jkiss.dbeaver.registry; ...@@ -19,7 +19,6 @@ package org.jkiss.dbeaver.registry;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.jkiss.dbeaver.Log; import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.DBPDriverFile;
import org.jkiss.utils.CommonUtils; import org.jkiss.utils.CommonUtils;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -28,7 +27,7 @@ import java.util.List; ...@@ -28,7 +27,7 @@ import java.util.List;
/** /**
* DriverFileSource * DriverFileSource
*/ */
public class DriverFileSource implements DBPDriverFile.FileSource public class DriverFileSource
{ {
static final Log log = Log.getLog(DriverFileSource.class); static final Log log = Log.getLog(DriverFileSource.class);
......
...@@ -23,7 +23,7 @@ import org.eclipse.core.runtime.Platform; ...@@ -23,7 +23,7 @@ import org.eclipse.core.runtime.Platform;
import org.jkiss.code.Nullable; import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.Log; import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.core.DBeaverCore; import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.model.DBPDriverFile; import org.jkiss.dbeaver.model.DBPDriverLibrary;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor; import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.OSDescriptor; import org.jkiss.dbeaver.model.runtime.OSDescriptor;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor; import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
...@@ -38,17 +38,19 @@ import java.io.*; ...@@ -38,17 +38,19 @@ import java.io.*;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.Collection;
/** /**
* DriverFileDescriptor * DriverLibraryDescriptor
*/ */
public class DriverFileDescriptor implements DBPDriverFile public class DriverLibraryDescriptor implements DBPDriverLibrary
{ {
static final Log log = Log.getLog(DriverFileDescriptor.class); static final Log log = Log.getLog(DriverLibraryDescriptor.class);
public static final String FILE_SOURCE_MAVEN = "maven:/"; public static final String FILE_SOURCE_MAVEN = "maven:/";
public static final String FILE_SOURCE_REPO = "repo:/"; public static final String FILE_SOURCE_REPO = "repo:/";
public static final String FILE_SOURCE_PLATFORM = "platform:/"; public static final String FILE_SOURCE_PLATFORM = "platform:/";
public static final String FILE_SOURCE_LOCAL = "file:/";
private final DriverDescriptor driver; private final DriverDescriptor driver;
private final FileType type; private final FileType type;
...@@ -59,7 +61,7 @@ public class DriverFileDescriptor implements DBPDriverFile ...@@ -59,7 +61,7 @@ public class DriverFileDescriptor implements DBPDriverFile
private boolean custom; private boolean custom;
private boolean disabled; private boolean disabled;
public DriverFileDescriptor(DriverDescriptor driver, FileType type, String path) public DriverLibraryDescriptor(DriverDescriptor driver, FileType type, String path)
{ {
this.driver = driver; this.driver = driver;
this.type = type; this.type = type;
...@@ -68,7 +70,7 @@ public class DriverFileDescriptor implements DBPDriverFile ...@@ -68,7 +70,7 @@ public class DriverFileDescriptor implements DBPDriverFile
this.custom = true; this.custom = true;
} }
DriverFileDescriptor(DriverDescriptor driver, IConfigurationElement config) DriverLibraryDescriptor(DriverDescriptor driver, IConfigurationElement config)
{ {
this.driver = driver; this.driver = driver;
this.type = FileType.valueOf(config.getAttribute(RegistryConstants.ATTR_TYPE)); this.type = FileType.valueOf(config.getAttribute(RegistryConstants.ATTR_TYPE));
...@@ -94,23 +96,12 @@ public class DriverFileDescriptor implements DBPDriverFile ...@@ -94,23 +96,12 @@ public class DriverFileDescriptor implements DBPDriverFile
return type; return type;
} }
@Override
public OSDescriptor getSystem()
{
return system;
}
@Override @Override
public String getPath() public String getPath()
{ {
return path; return path;
} }
@Override
public String getFileType() {
return null;
}
@Override @Override
public String getDescription() public String getDescription()
{ {
...@@ -145,7 +136,7 @@ public class DriverFileDescriptor implements DBPDriverFile ...@@ -145,7 +136,7 @@ public class DriverFileDescriptor implements DBPDriverFile
return isRepositoryArtifact() || isMavenArtifact(); return isRepositoryArtifact() || isMavenArtifact();
} }
public boolean isRepositoryArtifact() { private boolean isRepositoryArtifact() {
return path.startsWith(FILE_SOURCE_REPO); return path.startsWith(FILE_SOURCE_REPO);
} }
...@@ -289,6 +280,12 @@ public class DriverFileDescriptor implements DBPDriverFile ...@@ -289,6 +280,12 @@ public class DriverFileDescriptor implements DBPDriverFile
return system == null || system.matches(DBeaverCore.getInstance().getLocalSystem()); return system == null || system.matches(DBeaverCore.getInstance().getLocalSystem());
} }
@Nullable
@Override
public Collection<DBPDriverLibrary> getDependencies() {
return null;
}
/* /*
private String getMavenArtifactFileName() { private String getMavenArtifactFileName() {
String artifactName = path.substring(FILE_SOURCE_MAVEN.length()); String artifactName = path.substring(FILE_SOURCE_MAVEN.length());
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.jkiss.dbeaver.registry.maven;
/**
* Maven artifact license references
*/
public class MavenArtifactDependency
{
private MavenArtifactReference artifactReference;
private String type;
private boolean optional;
public MavenArtifactDependency(MavenArtifactReference artifactReference, String type, boolean optional) {
this.artifactReference = artifactReference;
this.type = type;
this.optional = optional;
}
public MavenArtifactReference getArtifactReference() {
return artifactReference;
}
public String getType() {
return type;
}
public boolean isOptional() {
return optional;
}
@Override
public String toString() {
return artifactReference.toString() + ";type=" + type + "; optional=" + optional;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.jkiss.dbeaver.registry.maven;
/**
* Maven artifact license references
*/
public class MavenArtifactLicense
{
private String name;
private String url;
public MavenArtifactLicense(String name, String url) {
this.name = name;
this.url = url;
}
public String getName() {
return name;
}
public String getUrl() {
return url;
}
@Override
public String toString() {
return name;
}
}
...@@ -26,7 +26,9 @@ import org.xml.sax.Attributes; ...@@ -26,7 +26,9 @@ import org.xml.sax.Attributes;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* Maven artifact version descriptor (POM). * Maven artifact version descriptor (POM).
...@@ -40,8 +42,8 @@ public class MavenArtifactVersion ...@@ -40,8 +42,8 @@ public class MavenArtifactVersion
private String version; private String version;
private String description; private String description;
private String url; private String url;
private List<String> licenses; private List<MavenArtifactLicense> licenses;
private List<MavenArtifactReference> dependencies; private List<MavenArtifactDependency> dependencies;
MavenArtifactVersion(MavenLocalVersion localVersion) throws IOException { MavenArtifactVersion(MavenLocalVersion localVersion) throws IOException {
this.localVersion = localVersion; this.localVersion = localVersion;
...@@ -73,29 +75,52 @@ public class MavenArtifactVersion ...@@ -73,29 +75,52 @@ public class MavenArtifactVersion
return url; return url;
} }
public List<String> getLicenses() { public List<MavenArtifactLicense> getLicenses() {
return licenses; return licenses;
} }
public List<MavenArtifactReference> getDependencies() { public List<MavenArtifactDependency> getDependencies() {
return dependencies; return dependencies;
} }
@Override
public String toString() {
return localVersion.toString();
}
private enum ParserState {
ROOT,
LICENSE,
DEPENDENCIES,
DEPENDENCY
}
private void loadPOM() throws IOException { private void loadPOM() throws IOException {
String pomURL = localVersion.getArtifact().getFileURL(localVersion.getVersion(), MavenArtifact.FILE_POM); String pomURL = localVersion.getArtifact().getFileURL(localVersion.getVersion(), MavenArtifact.FILE_POM);
InputStream mdStream = RuntimeUtils.openConnectionStream(pomURL); InputStream mdStream = RuntimeUtils.openConnectionStream(pomURL);
try { try {
SAXReader reader = new SAXReader(mdStream); SAXReader reader = new SAXReader(mdStream);
reader.parse(new SAXListener() { reader.parse(new SAXListener() {
private boolean inRoot = true; private ParserState state = ParserState.ROOT;
private String lastTag; private String lastTag;
private Map<String, String> attributes = new HashMap<String, String>();
@Override @Override
public void saxStartElement(SAXReader reader, String namespaceURI, String localName, Attributes atts) throws XMLException { public void saxStartElement(SAXReader reader, String namespaceURI, String localName, Attributes atts) throws XMLException {
lastTag = localName; lastTag = localName;
if ("license".equals(localName)) {
state = ParserState.LICENSE;
} else if ("dependencies".equals(localName)) {
state = ParserState.DEPENDENCIES;
} else if ("dependency".equals(localName) && state == ParserState.DEPENDENCIES) {
state = ParserState.DEPENDENCY;
} }
}
@Override @Override
public void saxText(SAXReader reader, String data) throws XMLException { public void saxText(SAXReader reader, String data) throws XMLException {
if (inRoot) { switch (state) {
case ROOT:
if ("name".equals(lastTag)) { if ("name".equals(lastTag)) {
name = data; name = data;
} else if ("version".equals(lastTag)) { } else if ("version".equals(lastTag)) {
...@@ -105,12 +130,40 @@ public class MavenArtifactVersion ...@@ -105,12 +130,40 @@ public class MavenArtifactVersion
} else if ("url".equals(lastTag)) { } else if ("url".equals(lastTag)) {
url = data; url = data;
} }
break;
case LICENSE:
case DEPENDENCY:
attributes.put(lastTag, data);
break;
} }
} }
@Override @Override
public void saxEndElement(SAXReader reader, String namespaceURI, String localName) throws XMLException { public void saxEndElement(SAXReader reader, String namespaceURI, String localName) throws XMLException {
lastTag = null; lastTag = null;
if ("license".equals(localName) && state == ParserState.LICENSE) {
state = ParserState.ROOT;
licenses.add(new MavenArtifactLicense(
attributes.get("name"),
attributes.get("url")
));
attributes.clear();
} else if ("dependencies".equals(localName) && state == ParserState.DEPENDENCIES) {
state = ParserState.ROOT;
dependencies.add(new MavenArtifactDependency(
new MavenArtifactReference(
attributes.get("groupId"),
attributes.get("artifactId"),
attributes.get("version")
),
attributes.get("type"),
Boolean.valueOf(attributes.get("optional"))
));
attributes.clear();
} else if ("dependency".equals(localName) && state == ParserState.DEPENDENCY) {
state = ParserState.DEPENDENCIES;
attributes.clear();
}
} }
}); });
} catch (XMLException e) { } catch (XMLException e) {
...@@ -120,9 +173,4 @@ public class MavenArtifactVersion ...@@ -120,9 +173,4 @@ public class MavenArtifactVersion
} }
} }
@Override
public String toString() {
return localVersion.toString();
}
} }
...@@ -34,7 +34,6 @@ import java.util.Date; ...@@ -34,7 +34,6 @@ import java.util.Date;
public class MavenLocalVersion public class MavenLocalVersion
{ {
static final Log log = Log.getLog(MavenLocalVersion.class); static final Log log = Log.getLog(MavenLocalVersion.class);
private static final java.lang.String FILE_PROTOCOL = "file:/";
private MavenArtifact artifact; private MavenArtifact artifact;
private String version; private String version;
......
...@@ -182,7 +182,7 @@ public class ProjectExportWizard extends Wizard implements IExportWizard { ...@@ -182,7 +182,7 @@ public class ProjectExportWizard extends Wizard implements IExportWizard {
Set<File> libFiles = new HashSet<File>(); Set<File> libFiles = new HashSet<File>();
Map<String, File> libPathMap = new HashMap<String, File>(); Map<String, File> libPathMap = new HashMap<String, File>();
for (DriverDescriptor driver : exportData.usedDrivers) { for (DriverDescriptor driver : exportData.usedDrivers) {
for (DriverFileDescriptor fileDescriptor : driver.getDriverFiles()) { for (DriverLibraryDescriptor fileDescriptor : driver.getDriverLibraries()) {
final File libraryFile = fileDescriptor.getLocalFile(); final File libraryFile = fileDescriptor.getLocalFile();
if (libraryFile != null && !fileDescriptor.isDisabled() && libraryFile.exists()) { if (libraryFile != null && !fileDescriptor.isDisabled() && libraryFile.exists()) {
libFiles.add(libraryFile); libFiles.add(libraryFile);
......
...@@ -29,7 +29,7 @@ import org.eclipse.ui.IWorkbench; ...@@ -29,7 +29,7 @@ import org.eclipse.ui.IWorkbench;
import org.jkiss.dbeaver.DBException; import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.core.CoreMessages; import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.DBeaverCore; import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.model.DBPDriverFile; import org.jkiss.dbeaver.model.DBPDriverLibrary;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor; import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress; import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress;
import org.jkiss.dbeaver.registry.*; import org.jkiss.dbeaver.registry.*;
...@@ -270,7 +270,7 @@ public class ProjectImportWizard extends Wizard implements IImportWizard { ...@@ -270,7 +270,7 @@ public class ProjectImportWizard extends Wizard implements IImportWizard {
} }
// Add libraries (only for managable drivers with empty library list) // Add libraries (only for managable drivers with empty library list)
if (CommonUtils.isEmpty(driver.getDriverFiles())) { if (CommonUtils.isEmpty(driver.getDriverLibraries())) {
List<String> libraryList = new ArrayList<String>(); List<String> libraryList = new ArrayList<String>();
for (Element libElement : XMLUtils.getChildElementList(driverElement, RegistryConstants.TAG_FILE)) { for (Element libElement : XMLUtils.getChildElementList(driverElement, RegistryConstants.TAG_FILE)) {
libraryList.add(libElement.getAttribute(RegistryConstants.ATTR_PATH)); libraryList.add(libElement.getAttribute(RegistryConstants.ATTR_PATH));
...@@ -280,7 +280,7 @@ public class ProjectImportWizard extends Wizard implements IImportWizard { ...@@ -280,7 +280,7 @@ public class ProjectImportWizard extends Wizard implements IImportWizard {
File libFile = new File(libPath); File libFile = new File(libPath);
if (libFile.exists()) { if (libFile.exists()) {
// Just use path as-is (may be it is local re-import or local environments equal to export environment) // Just use path as-is (may be it is local re-import or local environments equal to export environment)
driver.addDriverFile(libPath, DBPDriverFile.FileType.jar); driver.addDriverFile(libPath, DBPDriverLibrary.FileType.jar);
} else { } else {
// Get driver library from archive // Get driver library from archive
String archiveLibEntry = libMap.get(libPath); String archiveLibEntry = libMap.get(libPath);
...@@ -312,7 +312,7 @@ public class ProjectImportWizard extends Wizard implements IImportWizard { ...@@ -312,7 +312,7 @@ public class ProjectImportWizard extends Wizard implements IImportWizard {
while (relativePath.charAt(0) == '/' || relativePath.charAt(0) == '\\') { while (relativePath.charAt(0) == '/' || relativePath.charAt(0) == '\\') {
relativePath = relativePath.substring(1); relativePath = relativePath.substring(1);
} }
driver.addDriverFile(relativePath, DBPDriverFile.FileType.jar); driver.addDriverFile(relativePath, DBPDriverLibrary.FileType.jar);
} }
} }
} }
......
...@@ -21,24 +21,17 @@ import org.eclipse.core.runtime.IStatus; ...@@ -21,24 +21,17 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*; import org.eclipse.swt.widgets.*;
import org.jkiss.dbeaver.core.DBeaverUI; import org.jkiss.dbeaver.model.DBPDriverLibrary;
import org.jkiss.dbeaver.model.DBPDriverFile;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor; import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.DBRRunnableContext; import org.jkiss.dbeaver.model.runtime.DBRRunnableContext;
import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress; import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress;
import org.jkiss.dbeaver.registry.DriverDescriptor; import org.jkiss.dbeaver.registry.DriverDescriptor;
import org.jkiss.dbeaver.registry.DriverFileDescriptor; import org.jkiss.dbeaver.registry.DriverLibraryDescriptor;
import org.jkiss.dbeaver.runtime.RunnableContextDelegate; import org.jkiss.dbeaver.runtime.RunnableContextDelegate;
import org.jkiss.dbeaver.runtime.RuntimeUtils;
import org.jkiss.dbeaver.ui.UIUtils; import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.preferences.PrefPageDrivers;
import org.jkiss.dbeaver.utils.GeneralUtils; import org.jkiss.dbeaver.utils.GeneralUtils;
import org.jkiss.utils.CommonUtils;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
...@@ -75,7 +68,7 @@ class DriverDownloadAutoPage extends DriverDownloadPage { ...@@ -75,7 +68,7 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
filesTable.setHeaderVisible(true); filesTable.setHeaderVisible(true);
filesTable.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); filesTable.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
UIUtils.createTableColumn(filesTable, SWT.LEFT, "File"); UIUtils.createTableColumn(filesTable, SWT.LEFT, "File");
for (DriverFileDescriptor file : wizard.getFiles()) { for (DriverLibraryDescriptor file : wizard.getFiles()) {
new TableItem(filesTable, SWT.NONE).setText(file.getDisplayName()); new TableItem(filesTable, SWT.NONE).setText(file.getDisplayName());
} }
UIUtils.packColumns(filesTable, true); UIUtils.packColumns(filesTable, true);
...@@ -97,14 +90,14 @@ class DriverDownloadAutoPage extends DriverDownloadPage { ...@@ -97,14 +90,14 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
downloadLibraryFiles(new RunnableContextDelegate(getContainer()), getWizard().getFiles()); downloadLibraryFiles(new RunnableContextDelegate(getContainer()), getWizard().getFiles());
} }
private void downloadLibraryFiles(DBRRunnableContext runnableContext, final List<DriverFileDescriptor> files) private void downloadLibraryFiles(DBRRunnableContext runnableContext, final List<DriverLibraryDescriptor> files)
{ {
if (!getWizard().getDriver().acceptDriverLicenses(runnableContext)) { if (!getWizard().getDriver().acceptDriverLicenses(runnableContext)) {
return; return;
} }
for (int i = 0, filesSize = files.size(); i < filesSize; ) { for (int i = 0, filesSize = files.size(); i < filesSize; ) {
DriverFileDescriptor lib = files.get(i); DriverLibraryDescriptor lib = files.get(i);
int result = downloadLibraryFile(runnableContext, lib); int result = downloadLibraryFile(runnableContext, lib);
switch (result) { switch (result) {
case IDialogConstants.CANCEL_ID: case IDialogConstants.CANCEL_ID:
...@@ -120,7 +113,7 @@ class DriverDownloadAutoPage extends DriverDownloadPage { ...@@ -120,7 +113,7 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
} }
} }
private int downloadLibraryFile(DBRRunnableContext runnableContext, final DriverFileDescriptor file) private int downloadLibraryFile(DBRRunnableContext runnableContext, final DriverLibraryDescriptor file)
{ {
try { try {
runnableContext.run(true, true, new DBRRunnableWithProgress() { runnableContext.run(true, true, new DBRRunnableWithProgress() {
...@@ -138,7 +131,7 @@ class DriverDownloadAutoPage extends DriverDownloadPage { ...@@ -138,7 +131,7 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
// User just canceled download // User just canceled download
return IDialogConstants.CANCEL_ID; return IDialogConstants.CANCEL_ID;
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
if (file.getType() == DBPDriverFile.FileType.license) { if (file.getType() == DBPDriverLibrary.FileType.license) {
return IDialogConstants.OK_ID; return IDialogConstants.OK_ID;
} }
DownloadRetry retryConfirm = new DownloadRetry(file, e.getTargetException()); DownloadRetry retryConfirm = new DownloadRetry(file, e.getTargetException());
...@@ -148,11 +141,11 @@ class DriverDownloadAutoPage extends DriverDownloadPage { ...@@ -148,11 +141,11 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
} }
private class DownloadRetry implements Runnable { private class DownloadRetry implements Runnable {
private final DriverFileDescriptor file; private final DriverLibraryDescriptor file;
private final Throwable error; private final Throwable error;
private int result; private int result;
public DownloadRetry(DriverFileDescriptor file, Throwable error) public DownloadRetry(DriverLibraryDescriptor file, Throwable error)
{ {
this.file = file; this.file = file;
this.error = error; this.error = error;
......
...@@ -25,7 +25,7 @@ import org.eclipse.swt.widgets.Control; ...@@ -25,7 +25,7 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.jkiss.dbeaver.core.DBeaverUI; import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.registry.DriverDescriptor; import org.jkiss.dbeaver.registry.DriverDescriptor;
import org.jkiss.dbeaver.registry.DriverFileDescriptor; import org.jkiss.dbeaver.registry.DriverLibraryDescriptor;
import org.jkiss.dbeaver.ui.DBeaverIcons; import org.jkiss.dbeaver.ui.DBeaverIcons;
import org.jkiss.dbeaver.ui.UIIcon; import org.jkiss.dbeaver.ui.UIIcon;
import org.jkiss.dbeaver.ui.UIUtils; import org.jkiss.dbeaver.ui.UIUtils;
...@@ -41,7 +41,7 @@ public class DriverDownloadDialog extends WizardDialog ...@@ -41,7 +41,7 @@ public class DriverDownloadDialog extends WizardDialog
private boolean doDownload = false; private boolean doDownload = false;
DriverDownloadDialog(Shell shell, DriverDescriptor driver, List<DriverFileDescriptor> files, boolean updateVersion, boolean forceDownload) DriverDownloadDialog(Shell shell, DriverDescriptor driver, List<DriverLibraryDescriptor> files, boolean updateVersion, boolean forceDownload)
{ {
super(shell, new DriverDownloadWizard(driver, files, updateVersion, forceDownload)); super(shell, new DriverDownloadWizard(driver, files, updateVersion, forceDownload));
getWizard().init(DBeaverUI.getActiveWorkbenchWindow().getWorkbench(), null); getWizard().init(DBeaverUI.getActiveWorkbenchWindow().getWorkbench(), null);
...@@ -110,18 +110,18 @@ public class DriverDownloadDialog extends WizardDialog ...@@ -110,18 +110,18 @@ public class DriverDownloadDialog extends WizardDialog
super.finishPressed(); super.finishPressed();
} }
public static boolean downloadDriverFiles(Shell shell, DriverDescriptor driver, List<DriverFileDescriptor> files) { public static boolean downloadDriverFiles(Shell shell, DriverDescriptor driver, List<DriverLibraryDescriptor> files) {
return downloadDriverFiles(shell, driver, files, false); return downloadDriverFiles(shell, driver, files, false);
} }
public static boolean downloadDriverFiles(Shell shell, DriverDescriptor driver, List<DriverFileDescriptor> files, boolean forceDownload) { public static boolean downloadDriverFiles(Shell shell, DriverDescriptor driver, List<DriverLibraryDescriptor> files, boolean forceDownload) {
DriverDownloadDialog dialog = new DriverDownloadDialog(shell, driver, files, false, forceDownload); DriverDownloadDialog dialog = new DriverDownloadDialog(shell, driver, files, false, forceDownload);
dialog.setMinimumPageSize(100, 100); dialog.setMinimumPageSize(100, 100);
dialog.open(); dialog.open();
return dialog.doDownload; return dialog.doDownload;
} }
public static boolean updateDriverFiles(Shell shell, DriverDescriptor driver, List<DriverFileDescriptor> files, boolean forceDownload) { public static boolean updateDriverFiles(Shell shell, DriverDescriptor driver, List<DriverLibraryDescriptor> files, boolean forceDownload) {
DriverDownloadDialog dialog = new DriverDownloadDialog(shell, driver, files, true, forceDownload); DriverDownloadDialog dialog = new DriverDownloadDialog(shell, driver, files, true, forceDownload);
dialog.setMinimumPageSize(100, 100); dialog.setMinimumPageSize(100, 100);
dialog.open(); dialog.open();
......
...@@ -24,7 +24,7 @@ import org.eclipse.ui.IExportWizard; ...@@ -24,7 +24,7 @@ import org.eclipse.ui.IExportWizard;
import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbench;
import org.jkiss.code.NotNull; import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.registry.DriverDescriptor; import org.jkiss.dbeaver.registry.DriverDescriptor;
import org.jkiss.dbeaver.registry.DriverFileDescriptor; import org.jkiss.dbeaver.registry.DriverLibraryDescriptor;
import org.jkiss.dbeaver.ui.UIUtils; import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.utils.CommonUtils; import org.jkiss.utils.CommonUtils;
...@@ -35,12 +35,12 @@ public class DriverDownloadWizard extends Wizard implements IExportWizard { ...@@ -35,12 +35,12 @@ public class DriverDownloadWizard extends Wizard implements IExportWizard {
private static final String DRIVER_DOWNLOAD_DIALOG_SETTINGS = "DriverDownload";//$NON-NLS-1$ private static final String DRIVER_DOWNLOAD_DIALOG_SETTINGS = "DriverDownload";//$NON-NLS-1$
private DriverDescriptor driver; private DriverDescriptor driver;
private List<DriverFileDescriptor> files; private List<DriverLibraryDescriptor> files;
private boolean updateVersion; private boolean updateVersion;
private boolean forceDownload; private boolean forceDownload;
private DriverDownloadPage downloadPage; private DriverDownloadPage downloadPage;
public DriverDownloadWizard(@NotNull DriverDescriptor driver, List<DriverFileDescriptor> files, boolean updateVersion, boolean forceDownload) { public DriverDownloadWizard(@NotNull DriverDescriptor driver, List<DriverLibraryDescriptor> files, boolean updateVersion, boolean forceDownload) {
this.driver = driver; this.driver = driver;
this.files = files; this.files = files;
this.updateVersion = updateVersion; this.updateVersion = updateVersion;
...@@ -54,7 +54,7 @@ public class DriverDownloadWizard extends Wizard implements IExportWizard { ...@@ -54,7 +54,7 @@ public class DriverDownloadWizard extends Wizard implements IExportWizard {
return driver; return driver;
} }
List<DriverFileDescriptor> getFiles() { List<DriverLibraryDescriptor> getFiles() {
return files; return files;
} }
......
...@@ -41,7 +41,7 @@ import org.jkiss.dbeaver.core.CoreMessages; ...@@ -41,7 +41,7 @@ import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.DBeaverUI; import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.model.DBIcon; import org.jkiss.dbeaver.model.DBIcon;
import org.jkiss.dbeaver.model.DBPDataSource; import org.jkiss.dbeaver.model.DBPDataSource;
import org.jkiss.dbeaver.model.DBPDriverFile; import org.jkiss.dbeaver.model.DBPDriverLibrary;
import org.jkiss.dbeaver.registry.*; import org.jkiss.dbeaver.registry.*;
import org.jkiss.dbeaver.runtime.RuntimeUtils; import org.jkiss.dbeaver.runtime.RuntimeUtils;
import org.jkiss.dbeaver.runtime.properties.PropertySourceCustom; import org.jkiss.dbeaver.runtime.properties.PropertySourceCustom;
...@@ -102,7 +102,7 @@ public class DriverEditDialog extends HelpEnabledDialog ...@@ -102,7 +102,7 @@ public class DriverEditDialog extends HelpEnabledDialog
private Text driverPortText; private Text driverPortText;
private PropertyTreeViewer parametersEditor; private PropertyTreeViewer parametersEditor;
private ConnectionPropertiesControl connectionPropertiesEditor; private ConnectionPropertiesControl connectionPropertiesEditor;
private List<DriverFileDescriptor> libList = new ArrayList<DriverFileDescriptor>(); private List<DriverLibraryDescriptor> libList = new ArrayList<DriverLibraryDescriptor>();
private PropertySourceCustom driverPropertySource; private PropertySourceCustom driverPropertySource;
private PropertySourceCustom connectionPropertySource; private PropertySourceCustom connectionPropertySource;
private ClientHomesPanel clientHomesPanel; private ClientHomesPanel clientHomesPanel;
...@@ -326,7 +326,7 @@ public class DriverEditDialog extends HelpEnabledDialog ...@@ -326,7 +326,7 @@ public class DriverEditDialog extends HelpEnabledDialog
@Override @Override
public void update(ViewerCell cell) public void update(ViewerCell cell)
{ {
DriverFileDescriptor lib = (DriverFileDescriptor) cell.getElement(); DriverLibraryDescriptor lib = (DriverLibraryDescriptor) cell.getElement();
cell.setText(lib.getDisplayName()); cell.setText(lib.getDisplayName());
File localFile = lib.getLocalFile(); File localFile = lib.getLocalFile();
if (localFile != null && localFile.exists()) { if (localFile != null && localFile.exists()) {
...@@ -431,9 +431,9 @@ public class DriverEditDialog extends HelpEnabledDialog ...@@ -431,9 +431,9 @@ public class DriverEditDialog extends HelpEnabledDialog
File folderFile = new File(curFolder); File folderFile = new File(curFolder);
for (String fileName : fileNames) { for (String fileName : fileNames) {
libList.add( libList.add(
new DriverFileDescriptor( new DriverLibraryDescriptor(
driver, driver,
fileName.endsWith(".jar") || fileName.endsWith(".zip") ? DBPDriverFile.FileType.jar : DBPDriverFile.FileType.lib, fileName.endsWith(".jar") || fileName.endsWith(".zip") ? DBPDriverLibrary.FileType.jar : DBPDriverLibrary.FileType.lib,
new File(folderFile, fileName).getAbsolutePath())); new File(folderFile, fileName).getAbsolutePath()));
} }
changeLibContent(); changeLibContent();
...@@ -452,9 +452,9 @@ public class DriverEditDialog extends HelpEnabledDialog ...@@ -452,9 +452,9 @@ public class DriverEditDialog extends HelpEnabledDialog
String selected = fd.open(); String selected = fd.open();
if (selected != null) { if (selected != null) {
curFolder = fd.getFilterPath(); curFolder = fd.getFilterPath();
libList.add(new DriverFileDescriptor( libList.add(new DriverLibraryDescriptor(
driver, driver,
DBPDriverFile.FileType.jar, DBPDriverLibrary.FileType.jar,
selected)); selected));
changeLibContent(); changeLibContent();
} }
...@@ -467,10 +467,10 @@ public class DriverEditDialog extends HelpEnabledDialog ...@@ -467,10 +467,10 @@ public class DriverEditDialog extends HelpEnabledDialog
{ {
EditMavenArtifactDialog fd = new EditMavenArtifactDialog(getShell(), null); EditMavenArtifactDialog fd = new EditMavenArtifactDialog(getShell(), null);
if (fd.open() == IDialogConstants.OK_ID) { if (fd.open() == IDialogConstants.OK_ID) {
libList.add(new DriverFileDescriptor( libList.add(new DriverLibraryDescriptor(
driver, driver,
DBPDriverFile.FileType.jar, DBPDriverLibrary.FileType.jar,
DriverFileDescriptor.FILE_SOURCE_MAVEN + fd.getArtifact().getPath())); DriverLibraryDescriptor.FILE_SOURCE_MAVEN + fd.getArtifact().getPath()));
changeLibContent(); changeLibContent();
} }
} }
...@@ -498,7 +498,7 @@ public class DriverEditDialog extends HelpEnabledDialog ...@@ -498,7 +498,7 @@ public class DriverEditDialog extends HelpEnabledDialog
@Override @Override
public void widgetSelected(SelectionEvent e) public void widgetSelected(SelectionEvent e)
{ {
DriverFileDescriptor selectedLib = getSelectedLibrary(); DriverLibraryDescriptor selectedLib = getSelectedLibrary();
int selIndex = libList.indexOf(selectedLib); int selIndex = libList.indexOf(selectedLib);
Collections.swap(libList, selIndex, selIndex - 1); Collections.swap(libList, selIndex, selIndex - 1);
changeLibContent(); changeLibContent();
...@@ -511,7 +511,7 @@ public class DriverEditDialog extends HelpEnabledDialog ...@@ -511,7 +511,7 @@ public class DriverEditDialog extends HelpEnabledDialog
@Override @Override
public void widgetSelected(SelectionEvent e) public void widgetSelected(SelectionEvent e)
{ {
DriverFileDescriptor selectedLib = getSelectedLibrary(); DriverLibraryDescriptor selectedLib = getSelectedLibrary();
int selIndex = libList.indexOf(selectedLib); int selIndex = libList.indexOf(selectedLib);
Collections.swap(libList, selIndex, selIndex + 1); Collections.swap(libList, selIndex, selIndex + 1);
changeLibContent(); changeLibContent();
...@@ -615,10 +615,10 @@ public class DriverEditDialog extends HelpEnabledDialog ...@@ -615,10 +615,10 @@ public class DriverEditDialog extends HelpEnabledDialog
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
} }
private DriverFileDescriptor getSelectedLibrary() private DriverLibraryDescriptor getSelectedLibrary()
{ {
IStructuredSelection selection = (IStructuredSelection) libTable.getSelection(); IStructuredSelection selection = (IStructuredSelection) libTable.getSelection();
return selection == null || selection.isEmpty() ? null : (DriverFileDescriptor) selection.getFirstElement(); return selection == null || selection.isEmpty() ? null : (DriverLibraryDescriptor) selection.getFirstElement();
} }
private void changeLibContent() private void changeLibContent()
...@@ -630,7 +630,7 @@ public class DriverEditDialog extends HelpEnabledDialog ...@@ -630,7 +630,7 @@ public class DriverEditDialog extends HelpEnabledDialog
private void changeLibSelection() private void changeLibSelection()
{ {
DriverFileDescriptor selectedLib = getSelectedLibrary(); DriverLibraryDescriptor selectedLib = getSelectedLibrary();
deleteButton.setEnabled(selectedLib != null); deleteButton.setEnabled(selectedLib != null);
upButton.setEnabled(libList.indexOf(selectedLib) > 0); upButton.setEnabled(libList.indexOf(selectedLib) > 0);
downButton.setEnabled(libList.indexOf(selectedLib) < libList.size() - 1); downButton.setEnabled(libList.indexOf(selectedLib) < libList.size() - 1);
...@@ -662,9 +662,9 @@ public class DriverEditDialog extends HelpEnabledDialog ...@@ -662,9 +662,9 @@ public class DriverEditDialog extends HelpEnabledDialog
// anonymousCheck.setSelection(driver.isAnonymousAccess()); // anonymousCheck.setSelection(driver.isAnonymousAccess());
if (libTable != null) { if (libTable != null) {
libList = new ArrayList<DriverFileDescriptor>(); libList = new ArrayList<DriverLibraryDescriptor>();
for (DriverFileDescriptor lib : driver.getDriverFiles()) { for (DriverLibraryDescriptor lib : driver.getDriverLibraries()) {
if (lib.isDisabled() || (lib.getType() != DBPDriverFile.FileType.jar && lib.getType() != DBPDriverFile.FileType.lib) || !lib.matchesCurrentPlatform()) { if (lib.isDisabled() || (lib.getType() != DBPDriverLibrary.FileType.jar && lib.getType() != DBPDriverLibrary.FileType.lib) || !lib.matchesCurrentPlatform()) {
continue; continue;
} }
libList.add(lib); libList.add(lib);
...@@ -706,10 +706,10 @@ public class DriverEditDialog extends HelpEnabledDialog ...@@ -706,10 +706,10 @@ public class DriverEditDialog extends HelpEnabledDialog
driver.setModified(true); driver.setModified(true);
// Set libraries // Set libraries
for (DriverFileDescriptor lib : CommonUtils.safeCollection(libList)) { for (DriverLibraryDescriptor lib : CommonUtils.safeCollection(libList)) {
driver.addDriverFile(lib); driver.addDriverFile(lib);
} }
for (DriverFileDescriptor lib : CommonUtils.copyList(driver.getDriverFiles())) { for (DriverLibraryDescriptor lib : CommonUtils.copyList(driver.getDriverLibraries())) {
if (!libList.contains(lib)) { if (!libList.contains(lib)) {
driver.removeDriverFile(lib); driver.removeDriverFile(lib);
} }
...@@ -781,9 +781,9 @@ public class DriverEditDialog extends HelpEnabledDialog ...@@ -781,9 +781,9 @@ public class DriverEditDialog extends HelpEnabledDialog
{ {
java.util.List<File> libFiles = new ArrayList<File>(); java.util.List<File> libFiles = new ArrayList<File>();
java.util.List<URL> libURLs = new ArrayList<URL>(); java.util.List<URL> libURLs = new ArrayList<URL>();
for (DriverFileDescriptor lib : libList) { for (DriverLibraryDescriptor lib : libList) {
File libFile = lib.getLocalFile(); File libFile = lib.getLocalFile();
if (libFile != null && libFile.exists() && !libFile.isDirectory() && lib.getType() == DBPDriverFile.FileType.jar) { if (libFile != null && libFile.exists() && !libFile.isDirectory() && lib.getType() == DBPDriverLibrary.FileType.jar) {
libFiles.add(libFile); libFiles.add(libFile);
try { try {
libURLs.add(libFile.toURI().toURL()); libURLs.add(libFile.toURI().toURL());
......
...@@ -25,7 +25,7 @@ import org.eclipse.ui.IWorkbench; ...@@ -25,7 +25,7 @@ import org.eclipse.ui.IWorkbench;
import org.jkiss.dbeaver.DBException; import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.core.DBeaverCore; import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.model.DBPConnectionConfiguration; import org.jkiss.dbeaver.model.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.DBPDriverFile; import org.jkiss.dbeaver.model.DBPDriverLibrary;
import org.jkiss.dbeaver.registry.*; import org.jkiss.dbeaver.registry.*;
import org.jkiss.dbeaver.ui.UIUtils; import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.SelectObjectDialog; import org.jkiss.dbeaver.ui.dialogs.SelectObjectDialog;
...@@ -122,7 +122,7 @@ public abstract class ConfigImportWizard extends Wizard implements IImportWizard ...@@ -122,7 +122,7 @@ public abstract class ConfigImportWizard extends Wizard implements IImportWizard
driver.setDescription(driverInfo.getDescription()); driver.setDescription(driverInfo.getDescription());
driver.setDriverDefaultPort(driverInfo.getDefaultPort()); driver.setDriverDefaultPort(driverInfo.getDefaultPort());
for (String path : driverInfo.getLibraries()) { for (String path : driverInfo.getLibraries()) {
driver.addDriverFile(path, DBPDriverFile.FileType.jar); driver.addDriverFile(path, DBPDriverLibrary.FileType.jar);
} }
driver.setModified(true); driver.setModified(true);
genericProvider.addDriver(driver); genericProvider.addDriver(driver);
......
...@@ -79,8 +79,8 @@ public class WMIDataSourceProvider implements DBPDataSourceProvider { ...@@ -79,8 +79,8 @@ public class WMIDataSourceProvider implements DBPDataSourceProvider {
private void loadNativeLib(DBPDriver driver) throws DBException private void loadNativeLib(DBPDriver driver) throws DBException
{ {
for (DBPDriverFile libFile : driver.getDriverFiles()) { for (DBPDriverLibrary libFile : driver.getDriverLibraries()) {
if (libFile.matchesCurrentPlatform() && libFile.getType() == DBPDriverFile.FileType.lib) { if (libFile.matchesCurrentPlatform() && libFile.getType() == DBPDriverLibrary.FileType.lib) {
File localFile = libFile.getLocalFile(); File localFile = libFile.getLocalFile();
if (localFile != null) { if (localFile != null) {
try { try {
......
...@@ -88,17 +88,12 @@ public interface DBPDriver extends DBPObject ...@@ -88,17 +88,12 @@ public interface DBPDriver extends DBPObject
ClassLoader getClassLoader(); ClassLoader getClassLoader();
@NotNull @NotNull
Collection<? extends DBPDriverFile> getDriverFiles(); Collection<? extends DBPDriverLibrary> getDriverLibraries();
@NotNull
Collection<? extends DBPDriverFile.FileSource> getDriverFileSources();
Object getDriverInstance(DBRRunnableContext runnableContext) throws DBException; Object getDriverInstance(DBRRunnableContext runnableContext) throws DBException;
void validateFilesPresence(DBRRunnableContext runnableContext); void validateFilesPresence(DBRRunnableContext runnableContext);
void updateFiles(DBRRunnableContext runnableContext);
void loadDriver(DBRRunnableContext runnableContext) throws DBException; void loadDriver(DBRRunnableContext runnableContext) throws DBException;
} }
...@@ -18,15 +18,16 @@ ...@@ -18,15 +18,16 @@
package org.jkiss.dbeaver.model; package org.jkiss.dbeaver.model;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable; import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.runtime.OSDescriptor;
import java.io.File; import java.io.File;
import java.util.Collection;
/** /**
* DBPDriver local path * Driver library
*/ */
public interface DBPDriverFile public interface DBPDriverLibrary
{ {
/** /**
* Driver file type * Driver file type
...@@ -39,18 +40,13 @@ public interface DBPDriverFile ...@@ -39,18 +40,13 @@ public interface DBPDriverFile
license license
} }
interface FileSource { @NotNull
}
FileType getType(); FileType getType();
OSDescriptor getSystem(); @NotNull
String getPath(); String getPath();
String getFileType(); @Nullable
String getDescription(); String getDescription();
boolean isCustom(); boolean isCustom();
...@@ -64,4 +60,7 @@ public interface DBPDriverFile ...@@ -64,4 +60,7 @@ public interface DBPDriverFile
boolean matchesCurrentPlatform(); boolean matchesCurrentPlatform();
@Nullable
Collection<DBPDriverLibrary> getDependencies();
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册