Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
elexis-server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
elexis
elexis-server
Commits
5d951c09
Commit
5d951c09
authored
Jul 12, 2019
by
Marco Descher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[15349] Update productive target, add p2 feature to check updates
parent
c39fb3c3
Pipeline
#10435
passed with stages
in 2 minutes and 22 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
47 deletions
+63
-47
bundles/es.core.p2/src/info/elexis/server/core/p2/console/ConsoleCommandProvider.java
...elexis/server/core/p2/console/ConsoleCommandProvider.java
+31
-24
bundles/es.core.p2/src/info/elexis/server/core/p2/internal/ProvisioningHelper.java
...fo/elexis/server/core/p2/internal/ProvisioningHelper.java
+30
-21
targets/es.target/elexis-server.target
targets/es.target/elexis-server.target
+2
-2
No files found.
bundles/es.core.p2/src/info/elexis/server/core/p2/console/ConsoleCommandProvider.java
View file @
5d951c09
package
info.elexis.server.core.p2.console
;
package
info.elexis.server.core.p2.console
;
import
java.util.Arrays
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
org.eclipse.equinox.p2.operations.Update
;
import
org.eclipse.osgi.framework.console.CommandInterpreter
;
import
org.eclipse.osgi.framework.console.CommandInterpreter
;
import
org.eclipse.osgi.framework.console.CommandProvider
;
import
org.eclipse.osgi.framework.console.CommandProvider
;
import
org.osgi.service.component.annotations.Activate
;
import
org.osgi.service.component.annotations.Activate
;
...
@@ -14,52 +16,58 @@ import info.elexis.server.core.p2.internal.ProvisioningHelper;
...
@@ -14,52 +16,58 @@ import info.elexis.server.core.p2.internal.ProvisioningHelper;
@Component
(
service
=
CommandProvider
.
class
,
immediate
=
true
)
@Component
(
service
=
CommandProvider
.
class
,
immediate
=
true
)
public
class
ConsoleCommandProvider
extends
AbstractConsoleCommandProvider
{
public
class
ConsoleCommandProvider
extends
AbstractConsoleCommandProvider
{
@Activate
@Activate
public
void
activate
(){
public
void
activate
()
{
register
(
this
.
getClass
());
register
(
this
.
getClass
());
}
}
@CmdAdvisor
(
description
=
"feature de-/installation and update repository management"
)
@CmdAdvisor
(
description
=
"feature de-/installation and update repository management"
)
public
void
_p2
(
CommandInterpreter
ci
){
public
void
_p2
(
CommandInterpreter
ci
)
{
executeCommand
(
"p2"
,
ci
);
executeCommand
(
"p2"
,
ci
);
}
}
@CmdAdvisor
(
description
=
"get possible updates"
)
public
void
__p2_update_check
()
{
Update
[]
possibleUpdates
=
ProvisioningHelper
.
getPossibleUpdates
();
Arrays
.
asList
(
possibleUpdates
).
stream
().
forEach
(
c
->
ci
.
println
(
c
));
}
@CmdAdvisor
(
description
=
"update all installed features"
)
@CmdAdvisor
(
description
=
"update all installed features"
)
public
String
__p2_
executeUpdate
()
{
public
String
__p2_
update_execute
()
{
return
ProvisioningHelper
.
updateAllFeatures
().
getMessage
();
return
ProvisioningHelper
.
updateAllFeatures
().
getMessage
();
}
}
@CmdAdvisor
(
description
=
"list the installed features"
)
@CmdAdvisor
(
description
=
"list the installed features"
)
public
String
__p2_features_listLocal
(){
public
String
__p2_features_listLocal
()
{
return
ProvisioningHelper
return
ProvisioningHelper
.
getAllInstalledFeatures
().
stream
().
map
(
i
->
i
.
getId
()
+
" ("
+
i
.
getVersion
()
+
") "
.
getAllInstalledFeatures
().
stream
().
map
(
i
->
i
.
getId
()
+
" ("
+
i
.
getVersion
()
+
") "
+
i
.
getProperty
(
"git-repo-url"
)
+
" "
+
i
.
getProperty
(
"git-rev"
))
+
i
.
getProperty
(
"git-repo-url"
)
+
" "
+
i
.
getProperty
(
"git-rev"
))
.
reduce
((
u
,
t
)
->
u
+
"\n"
+
t
).
get
();
.
reduce
((
u
,
t
)
->
u
+
"\n"
+
t
).
get
();
}
}
@CmdAdvisor
(
description
=
"install a feature"
)
@CmdAdvisor
(
description
=
"install a feature"
)
public
String
__p2_features_install
(
Iterator
<
String
>
args
){
public
String
__p2_features_install
(
Iterator
<
String
>
args
)
{
if
(
args
.
hasNext
())
{
if
(
args
.
hasNext
())
{
return
ProvisioningHelper
.
unInstallFeature
(
args
.
next
(),
true
);
return
ProvisioningHelper
.
unInstallFeature
(
args
.
next
(),
true
);
}
}
return
missingArgument
(
"featureName"
);
return
missingArgument
(
"featureName"
);
}
}
@CmdAdvisor
(
description
=
"uninstall a feature"
)
@CmdAdvisor
(
description
=
"uninstall a feature"
)
public
String
__p2_features_uninstall
(
Iterator
<
String
>
args
){
public
String
__p2_features_uninstall
(
Iterator
<
String
>
args
)
{
if
(
args
.
hasNext
())
{
if
(
args
.
hasNext
())
{
return
ProvisioningHelper
.
unInstallFeature
(
args
.
next
(),
false
);
return
ProvisioningHelper
.
unInstallFeature
(
args
.
next
(),
false
);
}
}
return
missingArgument
(
"featureName"
);
return
missingArgument
(
"featureName"
);
}
}
@CmdAdvisor
(
description
=
"list configured repositories"
)
@CmdAdvisor
(
description
=
"list configured repositories"
)
public
String
__p2_repo_list
(){
public
String
__p2_repo_list
()
{
return
HTTPServiceHelper
.
getRepoInfo
(
null
).
toString
();
return
HTTPServiceHelper
.
getRepoInfo
(
null
).
toString
();
}
}
public
String
__p2_repo_add
(
Iterator
<
String
>
args
){
public
String
__p2_repo_add
(
Iterator
<
String
>
args
)
{
if
(
args
.
hasNext
())
{
if
(
args
.
hasNext
())
{
final
String
url
=
args
.
next
();
final
String
url
=
args
.
next
();
String
user
=
null
;
String
user
=
null
;
...
@@ -70,18 +78,17 @@ public class ConsoleCommandProvider extends AbstractConsoleCommandProvider {
...
@@ -70,18 +78,17 @@ public class ConsoleCommandProvider extends AbstractConsoleCommandProvider {
if
(
args
.
hasNext
())
{
if
(
args
.
hasNext
())
{
password
=
args
.
next
();
password
=
args
.
next
();
}
}
return
HTTPServiceHelper
.
doRepositoryAdd
(
url
,
user
,
password
).
getStatusInfo
()
return
HTTPServiceHelper
.
doRepositoryAdd
(
url
,
user
,
password
).
getStatusInfo
().
toString
();
.
toString
();
}
}
return
missingArgument
(
"url [user] [password]"
);
return
missingArgument
(
"url [user] [password]"
);
}
}
public
String
__p2_repo_remove
(
Iterator
<
String
>
args
){
public
String
__p2_repo_remove
(
Iterator
<
String
>
args
)
{
if
(
args
.
hasNext
())
{
if
(
args
.
hasNext
())
{
final
String
url
=
args
.
next
();
final
String
url
=
args
.
next
();
return
HTTPServiceHelper
.
doRepositoryRemove
(
url
).
getStatusInfo
().
toString
();
return
HTTPServiceHelper
.
doRepositoryRemove
(
url
).
getStatusInfo
().
toString
();
}
}
return
missingArgument
(
"url"
);
return
missingArgument
(
"url"
);
}
}
}
}
bundles/es.core.p2/src/info/elexis/server/core/p2/internal/ProvisioningHelper.java
View file @
5d951c09
...
@@ -86,7 +86,7 @@ public class ProvisioningHelper {
...
@@ -86,7 +86,7 @@ public class ProvisioningHelper {
IMetadataRepositoryManager
metadataRepoMgr
=
Provisioner
.
getInstance
().
getMetadataRepositoryManager
();
IMetadataRepositoryManager
metadataRepoMgr
=
Provisioner
.
getInstance
().
getMetadataRepositoryManager
();
if
(
metadataRepoMgr
.
contains
(
location
))
{
if
(
metadataRepoMgr
.
contains
(
location
))
{
result
&=
metadataRepoMgr
.
removeRepository
(
location
);
result
&=
metadataRepoMgr
.
removeRepository
(
location
);
log
.
debug
(
"Removed metadata repository {}"
,
location
);
log
.
debug
(
"Removed metadata repository {}"
,
location
);
}
}
return
result
;
return
result
;
...
@@ -107,7 +107,20 @@ public class ProvisioningHelper {
...
@@ -107,7 +107,20 @@ public class ProvisioningHelper {
registerHttpAuthentication
(
location
,
username
,
password
);
registerHttpAuthentication
(
location
,
username
,
password
);
}
}
public
static
IStatus
updateAllFeatures
()
{
public
static
Update
[]
getPossibleUpdates
()
{
UpdateOperation
updateOperation
=
determinePossibleUpdates
();
if
(
updateOperation
!=
null
)
{
return
updateOperation
.
getPossibleUpdates
();
}
return
new
Update
[]
{};
}
/**
*
* @return an {@link UpdateOperation} if updates where found, else
* <code>null</code>
*/
private
static
UpdateOperation
determinePossibleUpdates
()
{
IProvisioningAgent
agent
=
Provisioner
.
getInstance
().
getProvisioningAgent
();
IProvisioningAgent
agent
=
Provisioner
.
getInstance
().
getProvisioningAgent
();
ProvisioningHelper
.
refreshRepositories
();
ProvisioningHelper
.
refreshRepositories
();
...
@@ -121,30 +134,26 @@ public class ProvisioningHelper {
...
@@ -121,30 +134,26 @@ public class ProvisioningHelper {
UpdateOperation
operation
=
new
UpdateOperation
(
session
,
units
.
toUnmodifiableSet
());
UpdateOperation
operation
=
new
UpdateOperation
(
session
,
units
.
toUnmodifiableSet
());
IStatus
status
=
operation
.
resolveModal
(
new
TimeoutProgressMonitor
(
15000
));
IStatus
status
=
operation
.
resolveModal
(
new
TimeoutProgressMonitor
(
15000
));
log
.
info
(
"[UPDATE] Check for updates {} | severity {} | code {}"
,
status
.
getMessage
(),
status
.
getSeverity
(),
if
(
status
.
getSeverity
()
==
Status
.
ERROR
)
{
status
.
getCode
());
StatusUtil
.
logStatus
(
"determine updates"
,
log
,
status
);
}
if
((!
status
.
isOK
()
&&
status
.
getCode
()
==
10000
&&
status
.
getSeverity
()
==
1
))
{
if
((!
status
.
isOK
()
&&
status
.
getCode
()
==
10000
&&
status
.
getSeverity
()
==
1
))
{
// no updates available
// no updates available
return
status
;
return
null
;
}
else
{
}
else
{
Update
[]
possibleUpdates
=
operation
.
getPossibleUpdates
();
return
operation
;
for
(
Update
update
:
possibleUpdates
)
{
log
.
debug
(
"[UPDATE] Found update {}"
,
update
.
replacement
);
}
}
}
}
if
(
status
.
getSeverity
()
!=
IStatus
.
ERROR
)
{
public
static
IStatus
updateAllFeatures
()
{
IStatus
stat
=
ProvisioningHelper
.
performOperation
(
operation
);
UpdateOperation
updateOperation
=
determinePossibleUpdates
();
log
.
info
(
"[UPDATE] Finished {} | severity {} | code {}"
,
stat
.
getMessage
(),
if
(
updateOperation
==
null
)
{
stat
.
getSeverity
(),
stat
.
getCode
());
return
Status
.
OK_STATUS
;
// TODO perform restart
}
else
{
log
.
warn
(
"[UPDATE] FAILED {} | severity {} | code {}"
,
status
.
getMessage
(),
status
.
getSeverity
(),
status
.
getCode
());
StatusUtil
.
logStatus
(
log
,
status
);
}
}
return
status
;
IStatus
stat
=
ProvisioningHelper
.
performOperation
(
updateOperation
);
StatusUtil
.
logStatus
(
"update finished"
,
log
,
stat
);
return
stat
;
}
}
public
static
Collection
<
IInstallableUnit
>
getAllInstalledFeatures
()
{
public
static
Collection
<
IInstallableUnit
>
getAllInstalledFeatures
()
{
...
@@ -204,8 +213,8 @@ public class ProvisioningHelper {
...
@@ -204,8 +213,8 @@ public class ProvisioningHelper {
/**
/**
*
*
* @param featureName
* @param featureName
* @param install
* @param install
<code>true</code> to install, <code>false</code> to
*
<code>true</code> to install, <code>false</code> to
uninstall
*
uninstall
* @return
* @return
*/
*/
public
static
String
unInstallFeature
(
String
featureName
,
boolean
install
)
{
public
static
String
unInstallFeature
(
String
featureName
,
boolean
install
)
{
...
...
targets/es.target/elexis-server.target
View file @
5d951c09
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
<target
name=
"Elexis-Server"
sequenceNumber=
"1562
68130
6"
>
<target
name=
"Elexis-Server"
sequenceNumber=
"1562
91736
6"
>
<locations>
<locations>
<location
includeMode=
"slicer"
includeAllPlatforms=
"true"
includeSource=
"true"
includeConfigurePhase=
"false"
type=
"InstallableUnit"
>
<location
includeMode=
"slicer"
includeAllPlatforms=
"true"
includeSource=
"true"
includeConfigurePhase=
"false"
type=
"InstallableUnit"
>
<unit
id=
"org.osgi.framework.system.packages.extra"
version=
"1.0.0.20190124-1239"
/>
<unit
id=
"org.osgi.framework.system.packages.extra"
version=
"1.0.0.20190124-1239"
/>
...
@@ -77,7 +77,7 @@
...
@@ -77,7 +77,7 @@
<unit
id=
"com.eclipsesource.jaxrs.provider.swagger.feature.feature.group"
version=
"1.1.1.201905211243"
/>
<unit
id=
"com.eclipsesource.jaxrs.provider.swagger.feature.feature.group"
version=
"1.1.1.201905211243"
/>
<unit
id=
"com.eclipsesource.jaxrs.provider.multipart.feature.feature.group"
version=
"2.2.0.201905211243"
/>
<unit
id=
"com.eclipsesource.jaxrs.provider.multipart.feature.feature.group"
version=
"2.2.0.201905211243"
/>
<unit
id=
"ch.rgw.utility"
version=
"3.8.0.20190425-1427"
/>
<unit
id=
"ch.rgw.utility"
version=
"3.8.0.20190425-1427"
/>
<unit
id=
"ch.elexis.core"
version=
"3.8.0.201907
04-0852
"
/>
<unit
id=
"ch.elexis.core"
version=
"3.8.0.201907
12-0701
"
/>
<unit
id=
"ch.elexis.core.l10n"
version=
"3.8.0.20190703-1208"
/>
<unit
id=
"ch.elexis.core.l10n"
version=
"3.8.0.20190703-1208"
/>
<unit
id=
"ch.elexis.core.importer.div"
version=
"3.2.0.20190703-1208"
/>
<unit
id=
"ch.elexis.core.importer.div"
version=
"3.2.0.20190703-1208"
/>
<unit
id=
"ch.elexis.core.hl7.v2x"
version=
"3.2.0.20190416-1216"
/>
<unit
id=
"ch.elexis.core.hl7.v2x"
version=
"3.2.0.20190416-1216"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment