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 // FIXME manage authentication if needed
31 // if (!CurrentUser.roles().contains(AuthConstants.ROLE_ADMIN))
34 // parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
36 parent
.setLayout(new GridLayout(2, true));
39 parent
.setLayout(new GridLayout(1, true));
42 initHighLevelSummary(parent
);
44 Group securityGroup
= createHighLevelGroup(parent
, "Security");
45 securityGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, false));
46 new SecurityDeploymentUi(securityGroup
, SWT
.NONE
);
48 Group dataGroup
= createHighLevelGroup(parent
, "Data");
49 dataGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, false));
50 new DataDeploymentUi(dataGroup
, SWT
.NONE
);
52 Group logGroup
= createHighLevelGroup(parent
, "Notifications");
53 logGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, true));
54 new LogDeploymentUi(logGroup
, SWT
.NONE
);
56 Group connectivityGroup
= createHighLevelGroup(parent
, "Connectivity");
57 new ConnectivityDeploymentUi(connectivityGroup
, SWT
.NONE
);
58 connectivityGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, true));
62 private void initHighLevelSummary(Composite parent
) {
63 Composite composite
= new Composite(parent
, SWT
.NONE
);
64 GridData gridData
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false);
66 gridData
.horizontalSpan
= 3;
67 composite
.setLayoutData(gridData
);
68 composite
.setLayout(new FillLayout());
70 ServiceReference
<NodeState
> nodeStateRef
= bc
.getServiceReference(NodeState
.class);
71 if (nodeStateRef
== null)
72 throw new IllegalStateException("No CMS state available");
73 NodeState nodeState
= bc
.getService(nodeStateRef
);
74 ServiceReference
<NodeDeployment
> nodeDeploymentRef
= bc
.getServiceReference(NodeDeployment
.class);
75 Label label
= new Label(composite
, SWT
.WRAP
);
76 CmsUtils
.markup(label
);
77 if (nodeDeploymentRef
== null) {
78 label
.setText("Not yet deployed on <br>" + nodeState
.getHostname() + "</br>, please configure below.");
80 Object stateUuid
= nodeStateRef
.getProperty(NodeConstants
.CN
);
81 NodeDeployment nodeDeployment
= bc
.getService(nodeDeploymentRef
);
82 GregorianCalendar calendar
= new GregorianCalendar();
83 calendar
.setTimeInMillis(nodeDeployment
.getAvailableSince());
84 calendar
.setTimeZone(TimeZone
.getDefault());
85 label
.setText("[" + "<b>" + nodeState
.getHostname() + "</b>]# " + "Deployment state " + stateUuid
86 + ", available since <b>" + calendar
.getTime() + "</b>");
90 private static Group
createHighLevelGroup(Composite parent
, String text
) {
91 Group group
= new Group(parent
, SWT
.NONE
);
93 CmsUtils
.markup(group
);
97 private boolean isDesktop() {