Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Webtools Releng
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eclipse Projects
webtools
Releng
Webtools Releng
Commits
a723943b
Commit
a723943b
authored
14 years ago
by
david_williams
Browse files
Options
Downloads
Patches
Plain Diff
small updates
parent
e001a770
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
releng.wtptools/aaa/META-INF/MANIFEST.MF
+9
-9
9 additions, 9 deletions
releng.wtptools/aaa/META-INF/MANIFEST.MF
releng.wtptools/aaa/src/aaa/Application.java
+163
-109
163 additions, 109 deletions
releng.wtptools/aaa/src/aaa/Application.java
with
172 additions
and
118 deletions
releng.wtptools/aaa/META-INF/MANIFEST.MF
+
9
−
9
View file @
a723943b
Manifest-Version: 1.0
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: aaa; singleton:=true
Bundle-SymbolicName: aaa; singleton:=true
Bundle-Version: 1.0.0
Bundle-Version: 1.0.0
Require-Bundle: org.eclipse.core.runtime
Require-Bundle: org.eclipse.core.runtime
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: aaa
Export-Package: aaa
This diff is collapsed.
Click to expand it.
releng.wtptools/aaa/src/aaa/Application.java
+
163
−
109
View file @
a723943b
package
aaa
;
package
aaa
;
import
java.io.*
;
import
java.io.BufferedInputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Enumeration
;
import
java.util.Enumeration
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.jar.JarFile
;
import
java.util.jar.JarFile
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipEntry
;
import
org.eclipse.equinox.app.IApplication
;
import
org.eclipse.equinox.app.IApplication
;
import
org.eclipse.equinox.app.IApplicationContext
;
import
org.eclipse.equinox.app.IApplicationContext
;
import
org.eclipse.osgi.util.ManifestElement
;
import
org.eclipse.osgi.util.ManifestElement
;
import
org.osgi.framework.BundleException
;
import
org.osgi.framework.BundleException
;
/**
/**
* This simple utility was attached to bug
* This simple utility was attached to bug
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=329376
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=329376
and provides a simple
*
and provides a simple
quick check on one form of incorrect headers.
* quick check on one form of incorrect headers.
*/
*/
public
class
Application
implements
IApplication
{
public
class
Application
implements
IApplication
{
private
static
final
boolean
DEBUG
=
false
;
private
static
final
boolean
DEBUG
=
false
;
private
static
final
String
PATH
=
"/Users/equinox/eclipse_ibuild/plugins"
;
private
static
final
String
PATH
=
"/Users/equinox/eclipse_ibuild/plugins"
;
public
Object
start
(
IApplicationContext
context
)
throws
Exception
{
private
String
rootpath
;
File
root
=
new
File
(
PATH
);
private
int
checkedOk
;
File
[]
children
=
root
.
listFiles
();
private
int
failedCount
;
for
(
File
child
:
children
)
{
private
int
errorCount
;
if
(
child
.
isDirectory
())
{
processFolder
(
child
);
public
Object
start
(
IApplicationContext
context
)
throws
Exception
{
}
else
if
(
child
.
getName
().
endsWith
(
".jar"
)
||
child
.
getName
().
endsWith
(
".zip"
))
{
File
root
=
getRoot
(
context
);
processJar
(
child
);
checkBundles
(
root
);
}
else
{
printReport
();
error
(
"Skipping unexpected file type: "
+
child
);
return
IApplication
.
EXIT_OK
;
}
}
}
return
IApplication
.
EXIT_OK
;
private
void
checkBundles
(
File
root
)
throws
BundleException
,
IOException
{
}
File
[]
children
=
root
.
listFiles
();
for
(
File
child
:
children
)
{
private
void
debug
(
String
message
)
{
if
(
child
.
isDirectory
())
{
if
(
DEBUG
)
processFolder
(
child
);
System
.
out
.
println
(
message
);
}
}
else
if
(
child
.
getName
().
endsWith
(
".jar"
)
||
child
.
getName
().
endsWith
(
".zip"
))
{
processJar
(
child
);
private
void
error
(
String
message
)
{
}
System
.
err
.
println
(
message
);
else
{
}
error
(
"Skipping unexpected file type: "
+
child
);
}
private
void
processFolder
(
File
folder
)
throws
BundleException
{
}
debug
(
"Processing: "
+
folder
);
}
File
manifestFile
=
new
File
(
folder
,
"META-INF/MANIFEST.MF"
);
if
(!
manifestFile
.
exists
())
{
private
void
printReport
()
{
error
(
"ERROR: Unable to read manifest at: "
+
manifestFile
.
getAbsolutePath
());
System
.
out
.
println
();
return
;
System
.
out
.
println
(
"Checked bundles under root path: "
+
rootpath
);
}
System
.
out
.
println
(
"Failed to read manifest (may be normal): "
+
failedCount
);
InputStream
input
=
null
;
System
.
out
.
println
(
"Bundles with version attribute errors: "
+
errorCount
);
try
{
System
.
out
.
println
(
"CheckedOk: "
+
checkedOk
);
input
=
new
BufferedInputStream
(
new
FileInputStream
(
manifestFile
));
System
.
out
.
println
();
processStream
(
input
,
manifestFile
.
getAbsolutePath
());
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
private
File
getRoot
(
IApplicationContext
context
)
{
}
finally
{
Map
args
=
context
.
getArguments
();
if
(
input
!=
null
)
{
String
appargskey
=
"application.args"
;
try
{
String
[]
appargs
=
(
String
[])
args
.
get
(
appargskey
);
input
.
close
();
if
(
appargs
.
length
>
0
)
{
}
catch
(
IOException
e
)
{
rootpath
=
appargs
[
0
];
// ignore
System
.
out
.
println
(
"Found path from application arguments: "
+
rootpath
);
}
}
}
else
{
}
rootpath
=
PATH
;
}
System
.
out
.
println
(
"No path was found from application arguments, so using default: "
+
rootpath
);
}
private
void
processJar
(
File
file
)
throws
IOException
,
BundleException
{
debug
(
"Processing: "
+
file
);
File
root
=
new
File
(
rootpath
);
JarFile
jar
=
new
JarFile
(
file
);
return
root
;
ZipEntry
entry
=
jar
.
getEntry
(
"META-INF/MANIFEST.MF"
);
}
if
(
entry
==
null
)
{
error
(
"No manifest found in: "
+
file
.
getAbsolutePath
());
private
void
debug
(
String
message
)
{
return
;
if
(
DEBUG
)
{
}
System
.
out
.
println
(
message
);
InputStream
input
=
null
;
}
try
{
}
input
=
new
BufferedInputStream
(
jar
.
getInputStream
(
entry
));
processStream
(
input
,
file
.
getAbsolutePath
());
private
void
error
(
String
message
)
{
}
catch
(
IOException
e
)
{
System
.
err
.
println
(
message
);
if
(
input
!=
null
)
{
}
try
{
input
.
close
();
private
void
processFolder
(
File
folder
)
throws
BundleException
{
}
catch
(
IOException
e1
)
{
debug
(
"Processing: "
+
folder
);
// ignore
File
manifestFile
=
new
File
(
folder
,
"META-INF/MANIFEST.MF"
);
}
if
(!
manifestFile
.
exists
())
{
}
error
(
"WARNING: Unable to read manifest at: "
+
manifestFile
.
getAbsolutePath
());
}
failedCount
++;
}
return
;
}
private
void
processStream
(
InputStream
input
,
String
filename
)
throws
IOException
,
BundleException
{
InputStream
input
=
null
;
String
[]
KEYS
=
new
String
[]
{
"Require-Bundle"
,
"Fragment-Host"
};
try
{
Map
<
String
,
String
>
manifest
=
getManifest
(
input
);
input
=
new
BufferedInputStream
(
new
FileInputStream
(
manifestFile
));
for
(
String
key
:
KEYS
)
{
processStream
(
input
,
manifestFile
.
getAbsolutePath
());
String
value
=
manifest
.
get
(
key
);
}
if
(
value
==
null
)
catch
(
IOException
e
)
{
continue
;
e
.
printStackTrace
();
ManifestElement
[]
elements
=
ManifestElement
.
parseHeader
(
key
,
value
);
}
if
(
elements
!=
null
)
{
finally
{
for
(
ManifestElement
element
:
elements
)
{
if
(
input
!=
null
)
{
if
(
element
!=
null
)
{
try
{
for
(
Enumeration
<
String
>
e
=
element
.
getKeys
();
e
!=
null
&&
e
.
hasMoreElements
();)
{
input
.
close
();
String
attr
=
e
.
nextElement
();
}
if
(
"version"
.
equals
(
attr
))
{
catch
(
IOException
e
)
{
error
(
filename
);
// ignore
return
;
}
}
}
}
}
}
}
}
}
private
void
processJar
(
File
file
)
throws
IOException
,
BundleException
{
}
debug
(
"Processing: "
+
file
);
}
JarFile
jar
=
new
JarFile
(
file
);
ZipEntry
entry
=
jar
.
getEntry
(
"META-INF/MANIFEST.MF"
);
private
Map
<
String
,
String
>
getManifest
(
InputStream
input
)
throws
IOException
,
BundleException
{
if
(
entry
==
null
)
{
return
ManifestElement
.
parseBundleManifest
(
input
,
null
);
error
(
"WARNING: No manifest found in: "
+
file
.
getAbsolutePath
());
}
failedCount
++;
return
;
public
void
stop
()
{
}
// nothing to do
InputStream
input
=
null
;
}
try
{
input
=
new
BufferedInputStream
(
jar
.
getInputStream
(
entry
));
processStream
(
input
,
file
.
getAbsolutePath
());
}
catch
(
IOException
e
)
{
if
(
input
!=
null
)
{
try
{
input
.
close
();
}
catch
(
IOException
e1
)
{
System
.
out
.
println
(
"Unexpectedly could not close stream?"
);
}
}
}
}
private
void
processStream
(
InputStream
input
,
String
filename
)
throws
IOException
,
BundleException
{
String
[]
KEYS
=
new
String
[]{
"Require-Bundle"
,
"Fragment-Host"
};
Map
<
String
,
String
>
manifest
=
getManifest
(
input
);
for
(
String
key
:
KEYS
)
{
String
value
=
manifest
.
get
(
key
);
if
(
value
==
null
)
{
continue
;
}
ManifestElement
[]
elements
=
ManifestElement
.
parseHeader
(
key
,
value
);
if
(
elements
!=
null
)
{
for
(
ManifestElement
element
:
elements
)
{
if
(
element
!=
null
)
{
for
(
Enumeration
<
String
>
e
=
element
.
getKeys
();
(
e
!=
null
)
&&
e
.
hasMoreElements
();)
{
String
attr
=
e
.
nextElement
();
if
(
"version"
.
equals
(
attr
))
{
error
(
filename
);
errorCount
++;
return
;
}
}
}
}
checkedOk
++;
}
}
}
private
Map
<
String
,
String
>
getManifest
(
InputStream
input
)
throws
IOException
,
BundleException
{
return
ManifestElement
.
parseBundleManifest
(
input
,
null
);
}
public
void
stop
()
{
// nothing to do
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment