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
b6d0ff62
Commit
b6d0ff62
authored
14 years ago
by
david_williams
Browse files
Options
Downloads
Patches
Plain Diff
add ability to write stats URI
parent
0eae2a9b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/AddMirrorsURL.java
+134
-48
134 additions, 48 deletions
...tools/src/org/eclipse/wtp/releng/tools/AddMirrorsURL.java
with
134 additions
and
48 deletions
plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/AddMirrorsURL.java
+
134
−
48
View file @
b6d0ff62
...
@@ -18,10 +18,13 @@ import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
...
@@ -18,10 +18,13 @@ import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
public
class
AddMirrorsURL
extends
Task
{
public
class
AddMirrorsURL
extends
Task
{
private
static
final
String
ARTIFACT_REPO_DIRECTORY
=
"artifactRepoDirectory"
;
private
static
final
String
IREPOSITORY_P2_STATS_URI
=
"p2.statsURI"
;
private
static
final
String
P2_MIRRORS_URL
=
"p2MirrorsURL"
;
private
static
final
String
ARTIFACT_REPO_DIRECTORY
=
"artifactRepoDirectory"
;
private
static
final
String
P2_MIRRORS_URL
=
"p2MirrorsURL"
;
private
static
final
String
P2_STATS_URI
=
"p2StatsURI"
;
private
String
artifactRepoDirectory
;
private
String
artifactRepoDirectory
;
private
String
p2MirrorsURL
;
private
String
p2MirrorsURL
;
private
String
p2StatsURI
;
public
void
rewriteMirrorURL
()
throws
ProvisionException
,
URISyntaxException
{
public
void
rewriteMirrorURL
()
throws
ProvisionException
,
URISyntaxException
{
try
{
try
{
...
@@ -51,7 +54,7 @@ public class AddMirrorsURL extends Task {
...
@@ -51,7 +54,7 @@ public class AddMirrorsURL extends Task {
String
pathPart
=
getArtifactRepoDirectory
();
String
pathPart
=
getArtifactRepoDirectory
();
if
((
pathPart
==
null
)
||
(
pathPart
.
length
()
==
0
))
{
if
((
pathPart
==
null
)
||
(
pathPart
.
length
()
==
0
))
{
infoOutput
(
"The repository direc
o
try needs to be specified for this task. Try setting system property '"
+
ARTIFACT_REPO_DIRECTORY
+
"'?"
);
infoOutput
(
"The repository direct
o
ry needs to be specified for this task. Try setting system property '"
+
ARTIFACT_REPO_DIRECTORY
+
"'?"
);
}
}
else
{
else
{
String
repoURI
=
"file:/"
+
pathPart
;
String
repoURI
=
"file:/"
+
pathPart
;
...
@@ -59,54 +62,15 @@ public class AddMirrorsURL extends Task {
...
@@ -59,54 +62,15 @@ public class AddMirrorsURL extends Task {
SimpleArtifactRepositoryFactory
simpleArtifactRepositoryFactory
=
new
SimpleArtifactRepositoryFactory
();
SimpleArtifactRepositoryFactory
simpleArtifactRepositoryFactory
=
new
SimpleArtifactRepositoryFactory
();
// NPE is thrown during "reload" if repository is written, and
// NPE is thrown during "reload" if repository is written, and
// agent
// agent is not set
// is not set
simpleArtifactRepositoryFactory
.
setAgent
(
Activator
.
getProvisioningAgent
());
simpleArtifactRepositoryFactory
.
setAgent
(
Activator
.
getProvisioningAgent
());
IArtifactRepository
artifactRepository
=
simpleArtifactRepositoryFactory
.
load
(
new
URI
(
repoURI
),
IRepositoryManager
.
REPOSITORY_HINT_MODIFIABLE
,
new
NullProgressMonitor
());
IArtifactRepository
artifactRepository
=
simpleArtifactRepositoryFactory
.
load
(
new
URI
(
repoURI
),
IRepositoryManager
.
REPOSITORY_HINT_MODIFIABLE
,
new
NullProgressMonitor
());
if
(
artifactRepository
!=
null
)
{
if
(
artifactRepository
!=
null
)
{
String
existingMirrorURL
=
artifactRepository
.
getProperty
(
IRepository
.
PROP_MIRRORS_URL
);
if
(
existingMirrorURL
!=
null
)
{
infoOutput
(
"the repository had existing mirrorURL: "
+
existingMirrorURL
);
}
result
=
processMirrorsURL
(
result
,
artifactRepository
);
else
{
result
=
processStatsURI
(
result
,
artifactRepository
);
infoOutput
(
"the repository had no existing mirrorURL"
);
}
String
newMirrorURL
=
null
;
newMirrorURL
=
getP2MirrorsURL
();
// if property given to us is empty string, assume that is
// the same as "removal" which is done by passing in null.
if
((
newMirrorURL
!=
null
)
&&
(
newMirrorURL
.
length
()
==
0
))
{
newMirrorURL
=
null
;
}
boolean
needrewrite
=
false
;
String
reasonForNoWrite
=
null
;
if
(
newMirrorURL
!=
null
)
{
// if they are the same, don't bother
if
(!
newMirrorURL
.
equals
(
existingMirrorURL
))
{
needrewrite
=
true
;
}
else
{
reasonForNoWrite
=
"new value and existing value of mirrorURL are the same"
;
}
}
else
{
// newMirror is null, means removal is desired
if
(
existingMirrorURL
!=
null
)
{
needrewrite
=
true
;
}
else
{
reasonForNoWrite
=
"removal of mirrorURL was indicated, but repository has no existing value."
;
}
}
if
(
needrewrite
)
{
result
=
new
PublisherInfo
();
artifactRepository
.
setProperty
(
IRepository
.
PROP_MIRRORS_URL
,
newMirrorURL
);
result
.
setArtifactRepository
(
artifactRepository
);
result
.
setArtifactOptions
(
IPublisherInfo
.
A_OVERWRITE
);
}
else
{
infoOutput
(
reasonForNoWrite
);
}
}
}
else
{
else
{
infoOutput
(
"repository was null, not local, or otherwise not modifiable"
);
infoOutput
(
"repository was null, not local, or otherwise not modifiable"
);
...
@@ -115,6 +79,54 @@ public class AddMirrorsURL extends Task {
...
@@ -115,6 +79,54 @@ public class AddMirrorsURL extends Task {
return
result
;
return
result
;
}
}
private
PublisherInfo
processMirrorsURL
(
PublisherInfo
result
,
IArtifactRepository
artifactRepository
)
{
String
existingMirrorURL
=
artifactRepository
.
getProperty
(
IRepository
.
PROP_MIRRORS_URL
);
if
(
existingMirrorURL
!=
null
)
{
infoOutput
(
"the repository had existing mirrorURL: "
+
existingMirrorURL
);
}
else
{
infoOutput
(
"the repository had no existing mirrorURL"
);
}
String
newMirrorURL
=
getP2MirrorsURL
();
// if property given to us is empty string, assume that is
// the same as "removal" which is done by passing in null.
if
((
newMirrorURL
!=
null
)
&&
(
newMirrorURL
.
length
()
==
0
))
{
newMirrorURL
=
null
;
}
boolean
needrewrite
=
false
;
String
reasonForNoWrite
=
null
;
if
(
newMirrorURL
!=
null
)
{
// if they are the same, don't bother
if
(!
newMirrorURL
.
equals
(
existingMirrorURL
))
{
needrewrite
=
true
;
}
else
{
reasonForNoWrite
=
"new value and existing value of mirrorURL are the same"
;
}
}
else
{
// newMirror is null, means removal is desired
if
(
existingMirrorURL
!=
null
)
{
needrewrite
=
true
;
}
else
{
reasonForNoWrite
=
"removal of mirrorURL was indicated, but repository has no existing value."
;
}
}
if
(
needrewrite
)
{
if
(
result
==
null
)
{
result
=
initRepoOverwrite
(
artifactRepository
);
}
artifactRepository
.
setProperty
(
IRepository
.
PROP_MIRRORS_URL
,
newMirrorURL
);
}
else
{
infoOutput
(
reasonForNoWrite
);
}
return
result
;
}
private
IPublisherAction
[]
createActions
()
{
private
IPublisherAction
[]
createActions
()
{
IPublisherAction
[]
result
=
new
IPublisherAction
[
0
];
IPublisherAction
[]
result
=
new
IPublisherAction
[
0
];
return
result
;
return
result
;
...
@@ -155,6 +167,10 @@ public class AddMirrorsURL extends Task {
...
@@ -155,6 +167,10 @@ public class AddMirrorsURL extends Task {
this
.
p2MirrorsURL
=
mirrorURLString
;
this
.
p2MirrorsURL
=
mirrorURLString
;
}
}
public
void
setP2StatsURI
(
String
statsURIString
)
{
this
.
p2StatsURI
=
statsURIString
;
}
@Override
@Override
public
void
execute
()
throws
BuildException
{
public
void
execute
()
throws
BuildException
{
try
{
try
{
...
@@ -171,4 +187,74 @@ public class AddMirrorsURL extends Task {
...
@@ -171,4 +187,74 @@ public class AddMirrorsURL extends Task {
}
}
}
}
private
PublisherInfo
processStatsURI
(
PublisherInfo
result
,
IArtifactRepository
artifactRepository
)
{
/*
* <property name='p2.statsURI'
* value='http://your.stats.server/stats'/>
*/
String
existingStatsURI
=
artifactRepository
.
getProperty
(
IREPOSITORY_P2_STATS_URI
);
if
(
existingStatsURI
!=
null
)
{
infoOutput
(
"the repository had existing statsURI: "
+
existingStatsURI
);
}
else
{
infoOutput
(
"the repository had no existing statsURI"
);
}
String
newStatsURI
=
getP2StatsURI
();
// if property given to us is empty string, assume that is
// the same as "removal" which is done by passing in null.
if
((
newStatsURI
!=
null
)
&&
(
newStatsURI
.
length
()
==
0
))
{
newStatsURI
=
null
;
}
boolean
needrewrite
=
false
;
String
reasonForNoWrite
=
null
;
if
(
newStatsURI
!=
null
)
{
// if they are the same, don't bother
if
(!
newStatsURI
.
equals
(
existingStatsURI
))
{
needrewrite
=
true
;
}
else
{
reasonForNoWrite
=
"new value and existing value of statsURI are the same"
;
}
}
else
{
// newStatsURI is null, means removal is desired
if
(
existingStatsURI
!=
null
)
{
needrewrite
=
true
;
}
else
{
reasonForNoWrite
=
"removal of statusURI was indicated, but repository has no existing value."
;
}
}
if
(
needrewrite
)
{
if
(
result
==
null
)
{
result
=
initRepoOverwrite
(
artifactRepository
);
}
artifactRepository
.
setProperty
(
IREPOSITORY_P2_STATS_URI
,
newStatsURI
);
}
else
{
infoOutput
(
reasonForNoWrite
);
}
return
result
;
}
public
String
getP2StatsURI
()
{
if
(
p2StatsURI
==
null
)
{
p2StatsURI
=
System
.
getProperty
(
P2_STATS_URI
);
infoOutput
(
"stats URI value set from '"
+
P2_STATS_URI
+
"': "
+
p2StatsURI
);
}
return
p2StatsURI
;
}
private
PublisherInfo
initRepoOverwrite
(
IArtifactRepository
artifactRepository
)
{
PublisherInfo
result
;
result
=
new
PublisherInfo
();
result
.
setArtifactRepository
(
artifactRepository
);
result
.
setArtifactOptions
(
IPublisherInfo
.
A_OVERWRITE
);
return
result
;
}
}
}
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