Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
88c44de4
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
88c44de4
编写于
10月 08, 2015
作者:
J
jurgen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Metadata resolution (hack)
上级
1a3824b4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
68 addition
and
32 deletion
+68
-32
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
...e/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
+68
-32
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/registry/maven/MavenArtifact.java
浏览文件 @
88c44de4
...
@@ -23,14 +23,17 @@ import org.jkiss.dbeaver.Log;
...
@@ -23,14 +23,17 @@ import org.jkiss.dbeaver.Log;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.runtime.RuntimeUtils
;
import
org.jkiss.dbeaver.runtime.RuntimeUtils
;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.IOUtils
;
import
org.jkiss.utils.xml.SAXListener
;
import
org.jkiss.utils.xml.SAXListener
;
import
org.jkiss.utils.xml.SAXReader
;
import
org.jkiss.utils.xml.SAXReader
;
import
org.jkiss.utils.xml.XMLException
;
import
org.jkiss.utils.xml.XMLException
;
import
org.xml.sax.Attributes
;
import
org.xml.sax.Attributes
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.util.*
;
import
java.util.*
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
/**
/**
...
@@ -75,46 +78,79 @@ public class MavenArtifact
...
@@ -75,46 +78,79 @@ public class MavenArtifact
monitor
.
subTask
(
"Load metadata "
+
this
+
""
);
monitor
.
subTask
(
"Load metadata "
+
this
+
""
);
try
(
InputStream
mdStream
=
RuntimeUtils
.
openConnectionStream
(
metadataPath
))
{
try
(
InputStream
mdStream
=
RuntimeUtils
.
openConnectionStream
(
metadataPath
))
{
SAXReader
reader
=
new
SAXReader
(
mdStream
);
parseMetadata
(
mdStream
);
reader
.
parse
(
new
SAXListener
()
{
public
String
lastTag
;
@Override
public
void
saxStartElement
(
SAXReader
reader
,
String
namespaceURI
,
String
localName
,
Attributes
atts
)
throws
XMLException
{
lastTag
=
localName
;
}
@Override
public
void
saxText
(
SAXReader
reader
,
String
data
)
throws
XMLException
{
if
(
"version"
.
equals
(
lastTag
))
{
versions
.
add
(
data
);
}
else
if
(
"latest"
.
equals
(
lastTag
))
{
latestVersion
=
data
;
}
else
if
(
"release"
.
equals
(
lastTag
))
{
releaseVersion
=
data
;
}
else
if
(
"lastUpdate"
.
equals
(
lastTag
))
{
try
{
lastUpdate
=
new
Date
(
Long
.
parseLong
(
data
));
}
catch
(
NumberFormatException
e
)
{
log
.
warn
(
e
);
}
}
}
@Override
public
void
saxEndElement
(
SAXReader
reader
,
String
namespaceURI
,
String
localName
)
throws
XMLException
{
lastTag
=
null
;
}
});
}
catch
(
XMLException
e
)
{
}
catch
(
XMLException
e
)
{
log
.
warn
(
"Error parsing artifact metadata"
,
e
);
log
.
warn
(
"Error parsing artifact metadata"
,
e
);
}
catch
(
IOException
e
)
{
// Metadata xml not found. It happens in rare cases. Let's try to get directory listing
try
(
InputStream
dirStream
=
RuntimeUtils
.
openConnectionStream
(
getArtifactURL
()))
{
parseDirectory
(
dirStream
);
}
catch
(
XMLException
e1
)
{
log
.
warn
(
"Error parsing artifact directory"
,
e
);
}
}
finally
{
}
finally
{
monitor
.
worked
(
1
);
monitor
.
worked
(
1
);
}
}
metadataLoaded
=
true
;
metadataLoaded
=
true
;
}
}
private
void
parseDirectory
(
InputStream
dirStream
)
throws
IOException
,
XMLException
{
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
IOUtils
.
copyStream
(
dirStream
,
baos
,
10000
);
String
dir
=
baos
.
toString
();
Pattern
hrefPattern
=
Pattern
.
compile
(
"a href=\"(.+)/?\""
);
Matcher
matcher
=
hrefPattern
.
matcher
(
dir
);
while
(
matcher
.
find
())
{
String
href
=
matcher
.
group
(
1
);
while
(
href
.
endsWith
(
"/"
))
{
href
=
href
.
substring
(
0
,
href
.
length
()
-
1
);
}
int
divPos
=
href
.
lastIndexOf
(
'/'
);
if
(
divPos
!=
-
1
)
{
href
=
href
.
substring
(
divPos
+
1
);
}
if
(
href
.
equals
(
".."
))
{
continue
;
}
versions
.
add
(
href
);
}
}
private
void
parseMetadata
(
InputStream
mdStream
)
throws
IOException
,
XMLException
{
SAXReader
reader
=
new
SAXReader
(
mdStream
);
reader
.
parse
(
new
SAXListener
()
{
public
String
lastTag
;
@Override
public
void
saxStartElement
(
SAXReader
reader
,
String
namespaceURI
,
String
localName
,
Attributes
atts
)
throws
XMLException
{
lastTag
=
localName
;
}
@Override
public
void
saxText
(
SAXReader
reader
,
String
data
)
throws
XMLException
{
if
(
"version"
.
equals
(
lastTag
))
{
versions
.
add
(
data
);
}
else
if
(
"latest"
.
equals
(
lastTag
))
{
latestVersion
=
data
;
}
else
if
(
"release"
.
equals
(
lastTag
))
{
releaseVersion
=
data
;
}
else
if
(
"lastUpdate"
.
equals
(
lastTag
))
{
try
{
lastUpdate
=
new
Date
(
Long
.
parseLong
(
data
));
}
catch
(
NumberFormatException
e
)
{
log
.
warn
(
e
);
}
}
}
@Override
public
void
saxEndElement
(
SAXReader
reader
,
String
namespaceURI
,
String
localName
)
throws
XMLException
{
lastTag
=
null
;
}
});
}
public
MavenRepository
getRepository
()
{
public
MavenRepository
getRepository
()
{
return
repository
;
return
repository
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录