1 package org
.argeo
.cms
.maintenance
;
3 import java
.util
.GregorianCalendar
;
4 import java
.util
.TimeZone
;
6 import org
.argeo
.cms
.auth
.AuthConstants
;
7 import org
.argeo
.cms
.auth
.CurrentUser
;
8 import org
.argeo
.cms
.util
.CmsUtils
;
9 import org
.argeo
.node
.NodeConstants
;
10 import org
.argeo
.node
.NodeDeployment
;
11 import org
.argeo
.node
.NodeState
;
12 import org
.eclipse
.rap
.rwt
.application
.AbstractEntryPoint
;
13 import org
.eclipse
.swt
.SWT
;
14 import org
.eclipse
.swt
.layout
.FillLayout
;
15 import org
.eclipse
.swt
.layout
.GridData
;
16 import org
.eclipse
.swt
.layout
.GridLayout
;
17 import org
.eclipse
.swt
.widgets
.Composite
;
18 import org
.eclipse
.swt
.widgets
.Group
;
19 import org
.eclipse
.swt
.widgets
.Label
;
20 import org
.osgi
.framework
.BundleContext
;
21 import org
.osgi
.framework
.FrameworkUtil
;
22 import org
.osgi
.framework
.ServiceReference
;
24 class DeploymentEntryPoint
extends AbstractEntryPoint
{
25 private static final long serialVersionUID
= -881152502968982437L;
26 private final BundleContext bc
= FrameworkUtil
.getBundle(getClass()).getBundleContext();
29 protected void createContents(Composite parent
) {
30 if (!CurrentUser
.roles().contains(AuthConstants
.ROLE_ADMIN
))
33 // parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
35 parent
.setLayout(new GridLayout(2, true));
38 parent
.setLayout(new GridLayout(1, true));
41 initHighLevelSummary(parent
);
43 Group securityGroup
= createHighLevelGroup(parent
, "Security");
44 securityGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, false));
45 new SecurityDeploymentUi(securityGroup
, SWT
.NONE
);
47 Group dataGroup
= createHighLevelGroup(parent
, "Data");
48 dataGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, false));
49 new DataDeploymentUi(dataGroup
, SWT
.NONE
);
51 Group logGroup
= createHighLevelGroup(parent
, "Notifications");
52 logGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, true));
53 new LogDeploymentUi(logGroup
, SWT
.NONE
);
55 Group connectivityGroup
= createHighLevelGroup(parent
, "Connectivity");
56 new ConnectivityDeploymentUi(connectivityGroup
, SWT
.NONE
);
57 connectivityGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, true));
61 private void initHighLevelSummary(Composite parent
) {
62 Composite composite
= new Composite(parent
, SWT
.NONE
);
63 GridData gridData
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false);
65 gridData
.horizontalSpan
= 3;
66 composite
.setLayoutData(gridData
);
67 composite
.setLayout(new FillLayout());
69 ServiceReference
<NodeState
> nodeStateRef
= bc
.getServiceReference(NodeState
.class);
70 if (nodeStateRef
== null)
71 throw new IllegalStateException("No CMS state available");
72 NodeState nodeState
= bc
.getService(nodeStateRef
);
73 ServiceReference
<NodeDeployment
> nodeDeploymentRef
= bc
.getServiceReference(NodeDeployment
.class);
74 Label label
= new Label(composite
, SWT
.WRAP
);
75 CmsUtils
.markup(label
);
76 if (nodeDeploymentRef
== null) {
77 label
.setText("Not yet deployed on <br>" + nodeState
.getHostname() + "</br>, please configure below.");
79 Object stateUuid
= nodeStateRef
.getProperty(NodeConstants
.CN
);
80 NodeDeployment nodeDeployment
= bc
.getService(nodeDeploymentRef
);
81 GregorianCalendar calendar
= new GregorianCalendar();
82 calendar
.setTimeInMillis(nodeDeployment
.getAvailableSince());
83 calendar
.setTimeZone(TimeZone
.getDefault());
84 label
.setText("[" + "<b>" + nodeState
.getHostname() + "</b>]# " + "Deployment state " + stateUuid
85 + ", available since <b>" + calendar
.getTime() + "</b>");
89 private static Group
createHighLevelGroup(Composite parent
, String text
) {
90 Group group
= new Group(parent
, SWT
.NONE
);
92 CmsUtils
.markup(group
);
96 private boolean isDesktop() {