|
1 /* |
|
2 * CDDL HEADER START |
|
3 * |
|
4 * The contents of this file are subject to the terms of the |
|
5 * Common Development and Distribution License (the "License"). |
|
6 * You may not use this file except in compliance with the License. |
|
7 * |
|
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 * or http://www.opensolaris.org/os/licensing. |
|
10 * See the License for the specific language governing permissions |
|
11 * and limitations under the License. |
|
12 * |
|
13 * When distributing Covered Code, include this CDDL HEADER in each |
|
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 * If applicable, add the following below this CDDL HEADER, with the |
|
16 * fields enclosed by brackets "[]" replaced with your own identifying |
|
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 * |
|
19 * CDDL HEADER END |
|
20 */ |
|
21 |
|
22 /* |
|
23 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. |
|
24 */ |
|
25 |
|
26 package com.oracle.solaris.vp.panels.apache.client.swing; |
|
27 |
|
28 import java.util.Map; |
|
29 import com.oracle.solaris.vp.panel.common.control.*; |
|
30 import com.oracle.solaris.vp.panel.swing.control.TabbedControl; |
|
31 |
|
32 public class VirtualHostControl extends TabbedControl<ApachePanelDescriptor> { |
|
33 // |
|
34 // Static data |
|
35 // |
|
36 |
|
37 public static final String ID = "vhost"; |
|
38 public static final String PARAM_ID = "id"; |
|
39 public static final String PARAM_DOMAIN = "domain"; |
|
40 |
|
41 // |
|
42 // Instance data |
|
43 // |
|
44 |
|
45 private VirtualHost vHost; |
|
46 |
|
47 // |
|
48 // Constructors |
|
49 // |
|
50 |
|
51 public VirtualHostControl(ApachePanelDescriptor descriptor) { |
|
52 super(ID, null, descriptor); |
|
53 } |
|
54 |
|
55 // |
|
56 // Control methods |
|
57 // |
|
58 |
|
59 @Override |
|
60 public boolean isBrowsable() { |
|
61 // This Control requires init parameters |
|
62 return false; |
|
63 } |
|
64 |
|
65 @Override |
|
66 public void start(Navigator navigator, Map<String, String> parameters) |
|
67 throws NavigationAbortedException, InvalidParameterException, |
|
68 NavigationFailedException { |
|
69 |
|
70 VirtualHost vHost; |
|
71 |
|
72 try { |
|
73 String param = getParameter(parameters, PARAM_ID); |
|
74 vHost = getPanelDescriptor().getVirtualHost(param); |
|
75 if (vHost == null) { |
|
76 throw new InvalidParameterException(getId(), PARAM_ID, param); |
|
77 } |
|
78 } catch (MissingParameterException e) { |
|
79 try { |
|
80 String param = getParameter(parameters, PARAM_DOMAIN); |
|
81 vHost = getPanelDescriptor().getVirtualHostByDomain(param); |
|
82 if (vHost == null) { |
|
83 throw new InvalidParameterException(getId(), PARAM_DOMAIN, |
|
84 param); |
|
85 } |
|
86 } catch (MissingParameterException e2) { |
|
87 throw e; |
|
88 } |
|
89 } |
|
90 |
|
91 setVirtualHost(vHost); |
|
92 |
|
93 super.start(navigator, parameters); |
|
94 } |
|
95 |
|
96 @Override |
|
97 public void stop(boolean isCancel) throws NavigationAbortedException { |
|
98 super.stop(isCancel); |
|
99 |
|
100 // Remove reference so it can be garbage collected if deleted |
|
101 setVirtualHost(null); |
|
102 } |
|
103 |
|
104 // |
|
105 // DefaultControl methods |
|
106 // |
|
107 |
|
108 @Override |
|
109 protected void ensureChildrenCreated() { |
|
110 if (children.size() == 0) { |
|
111 addChildren(new VirtualHostGeneralControl(this)); |
|
112 addChildren(new VirtualHostSSLControl(this)); |
|
113 } |
|
114 } |
|
115 |
|
116 // |
|
117 // VirtualHostControl methods |
|
118 // |
|
119 |
|
120 public VirtualHost getVirtualHost() { |
|
121 return vHost; |
|
122 } |
|
123 |
|
124 // |
|
125 // Private methods |
|
126 // |
|
127 |
|
128 private void setVirtualHost(VirtualHost vHost) { |
|
129 this.vHost = vHost; |
|
130 setName(vHost == null ? null : vHost.getName()); |
|
131 } |
|
132 } |