18 * |
18 * |
19 * CDDL HEADER END |
19 * CDDL HEADER END |
20 */ |
20 */ |
21 |
21 |
22 /* |
22 /* |
23 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. |
23 * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. |
24 */ |
24 */ |
25 |
25 |
26 package com.oracle.solaris.vp.panels.time.client.swing; |
26 package com.oracle.solaris.vp.panels.time.client.swing; |
27 |
27 |
28 import java.util.*; |
28 import java.util.*; |
29 import com.oracle.solaris.rad.ObjectException; |
29 import com.oracle.solaris.rad.client.RadObjectException; |
|
30 import com.oracle.solaris.rad.client.RadPrivilegeException; |
30 import com.oracle.solaris.scf.common.ScfException; |
31 import com.oracle.solaris.scf.common.ScfException; |
31 import com.oracle.solaris.vp.panel.common.action.*; |
32 import com.oracle.solaris.vp.panel.common.action.*; |
32 import com.oracle.solaris.vp.panel.common.api.smf_old.SmfState; |
33 import com.oracle.solaris.vp.panel.common.api.smf_old.SmfState; |
33 import com.oracle.solaris.vp.panel.common.model.AbstractModel; |
34 import com.oracle.solaris.vp.panel.common.model.AbstractModel; |
34 import com.oracle.solaris.vp.panel.common.smf.*; |
35 import com.oracle.solaris.vp.panel.common.smf.*; |
61 |
62 |
62 public void load() { |
63 public void load() { |
63 // XXX generic NTPModel shouldn't assume a ServicePanelDescriptor |
64 // XXX generic NTPModel shouldn't assume a ServicePanelDescriptor |
64 enabled_ = getSource().isEnabled(); |
65 enabled_ = getSource().isEnabled(); |
65 try { |
66 try { |
66 servers_ = getSource().getTimeMXBean().getntpServers(); |
67 servers_ = getSource().getTimeBean().getntpServers(); |
67 } catch (ObjectException e) { |
68 } catch (RadObjectException e) { |
68 servers_ = Collections.emptyList(); |
69 servers_ = Collections.emptyList(); |
69 } |
70 } |
70 |
71 |
71 // Read only state |
72 // Read only state |
72 ServiceMXBean service = getSource().getService(); |
73 ServiceBean service = getSource().getService(); |
73 try { |
74 try { |
74 state_ = service.getState(); |
75 state_ = service.getState(); |
75 nextState_ = service.getNextState(); |
76 nextState_ = service.getNextState(); |
76 } catch (ScfException ignore) { |
77 } catch (ScfException ignore) { |
77 } |
78 } |
81 ActionUnauthorizedException { |
82 ActionUnauthorizedException { |
82 |
83 |
83 validate(); |
84 validate(); |
84 |
85 |
85 TimePanelDescriptor descriptor = getSource(); |
86 TimePanelDescriptor descriptor = getSource(); |
86 TimeMXBean bean = descriptor.getTimeMXBean(); |
87 Time bean = descriptor.getTimeBean(); |
87 |
88 |
88 try { |
89 try { |
89 bean.setntpServers(servers_); |
90 bean.setntpServers(servers_); |
90 |
91 |
91 } catch (SecurityException e) { |
92 } catch (RadPrivilegeException e) { |
92 throw new ActionUnauthorizedException(e); |
93 throw new ActionUnauthorizedException(e); |
93 |
94 |
94 } catch (ObjectException e) { |
95 } catch (RadObjectException e) { |
95 throw new ActionFailedException( |
96 throw new ActionFailedException( |
96 Finder.getString("ntp.error.syserror"), e); |
97 Finder.getString("ntp.error.syserror"), e); |
97 } |
98 } |
98 |
99 |
99 try { |
100 try { |
100 SmfEnabledProperty smfEnabledProp = descriptor.getEnabledProperty(); |
101 SmfEnabledProperty smfEnabledProp = descriptor.getEnabledProperty(); |
101 |
102 |
102 smfEnabledProp.setValue(enabled_); |
103 smfEnabledProp.setValue(enabled_); |
103 smfEnabledProp.saveToRepo(); |
104 smfEnabledProp.saveToRepo(); |
104 |
105 |
105 } catch (SecurityException e) { |
106 } catch (RadPrivilegeException e) { |
106 throw new ActionUnauthorizedException(e); |
107 throw new ActionUnauthorizedException(e); |
107 |
108 |
108 } catch (ScfException e) { |
109 } catch (ScfException e) { |
109 SmfUtil.throwActionException(e); |
110 SmfUtil.throwActionException(e); |
110 throw new ActionFailedException(Finder.getString( |
111 throw new ActionFailedException(Finder.getString( |