# HG changeset patch # User Dan Labrecque # Date 1337847407 14400 # Node ID 0944d8c0158bb105e71a861687bd0a2024dd7b15 # Parent c6aad84d2493fe09502769625fdb5138a045ddf1 7169052 Integrate Visual Panels into Userland diff -r c6aad84d2493 -r 0944d8c0158b components/Makefile --- a/components/Makefile Wed May 23 11:03:10 2012 -0700 +++ b/components/Makefile Thu May 24 04:16:47 2012 -0400 @@ -89,6 +89,7 @@ $(WS_REPO): $(PKGREPO) create $(PKG_REPO) $(PKGREPO) add-publisher -s $(PKG_REPO) $(PUBLISHER) + $(PKGREPO) add-publisher -s $(PKG_REPO) $(PUBLISHER_LOCALIZABLE) DUMMYPKG = "set name=fmri value=pkg:/dummy@0,$(BUILD_VERSION)\n" DUMMYPKG += "set pkg.summary=dummy\n" diff -r c6aad84d2493 -r 0944d8c0158b components/meta-packages/history/OSOLvpanels-apache.p5m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/meta-packages/history/OSOLvpanels-apache.p5m Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,31 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. +# + +# +# Legacy package information +# + +set name=pkg.fmri value=pkg:/OSOLvpanels-apache@0.5.11,5.11-0.133 +set name=org.opensolaris.consolidation value=$(CONSOLIDATION) +set name=pkg.renamed value=true +depend fmri=system/management/visual-panels/panel-apache@0.5.11-0.133 type=require diff -r c6aad84d2493 -r 0944d8c0158b components/meta-packages/history/OSOLvpanels-firewall.p5m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/meta-packages/history/OSOLvpanels-firewall.p5m Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,30 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. +# + +# +# Legacy package information +# +set name=pkg.fmri value=pkg:/OSOLvpanels-firewall@0.5.11,5.11-0.133 +set name=org.opensolaris.consolidation value=$(CONSOLIDATION) +set name=pkg.renamed value=true +depend fmri=system/management/visual-panels/panel-firewall@0.5.11-0.133 type=require diff -r c6aad84d2493 -r 0944d8c0158b components/meta-packages/history/OSOLvpanels-hypervisor.p5m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/meta-packages/history/OSOLvpanels-hypervisor.p5m Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,29 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. +# + +# +# Legacy package information +# +set name=pkg.fmri value=pkg:/OSOLvpanels-hypervisor@0.5.11,5.11-0.151 +set name=pkg.obsolete value=true +set name=org.opensolaris.consolidation value=$(CONSOLIDATION) diff -r c6aad84d2493 -r 0944d8c0158b components/meta-packages/history/OSOLvpanels-mysql.p5m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/meta-packages/history/OSOLvpanels-mysql.p5m Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,29 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. +# + +# +# Legacy package information +# +set name=pkg.fmri value=pkg:/OSOLvpanels-mysql@0.5.11,5.11-0.130 +set name=pkg.obsolete value=true +set name=org.opensolaris.consolidation value=$(CONSOLIDATION) diff -r c6aad84d2493 -r 0944d8c0158b components/meta-packages/history/OSOLvpanels-sharemgr.p5m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/meta-packages/history/OSOLvpanels-sharemgr.p5m Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,29 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. +# + +# +# Legacy package information +# +set name=pkg.fmri value=pkg:/OSOLvpanels-sharemgr@0.5.11,5.11-0.171 +set name=pkg.obsolete value=true +set name=org.opensolaris.consolidation value=$(CONSOLIDATION) diff -r c6aad84d2493 -r 0944d8c0158b components/meta-packages/history/OSOLvpanels-sysid.p5m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/meta-packages/history/OSOLvpanels-sysid.p5m Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,29 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. +# + +# +# Legacy package information +# +set name=pkg.fmri value=pkg:/OSOLvpanels-sysid@0.5.11,5.11-0.171 +set name=pkg.obsolete value=true +set name=org.opensolaris.consolidation value=$(CONSOLIDATION) diff -r c6aad84d2493 -r 0944d8c0158b components/meta-packages/history/OSOLvpanels.p5m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/meta-packages/history/OSOLvpanels.p5m Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,30 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. +# + +# +# Legacy package information +# +set name=pkg.fmri value=pkg:/OSOLvpanels@0.5.11,5.11-0.133 +set name=pkg.renamed value=true +set name=org.opensolaris.consolidation value=$(CONSOLIDATION) +depend fmri=system/management/visual-panels@0.5.11-0.133 type=require diff -r c6aad84d2493 -r 0944d8c0158b components/meta-packages/history/system-management-rad-module-rad-zones-bridge.p5m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/meta-packages/history/system-management-rad-module-rad-zones-bridge.p5m Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,28 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. +# + +set name=pkg.fmri value=pkg:/system/management/rad/module/rad-zones-bridge@0.5.11,5.11-0.175.1.0.0.14 +set name=pkg.obsolete value=true +set name=org.opensolaris.consolidation value=$(CONSOLIDATION) diff -r c6aad84d2493 -r 0944d8c0158b components/meta-packages/history/system-management-visual-panels-panel-hypervisor.p5m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/meta-packages/history/system-management-visual-panels-panel-hypervisor.p5m Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,28 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. +# + +set name=pkg.fmri value=pkg:/system/management/visual-panels/panel-hypervisor@0.5.11,5.11-0.151 +set name=pkg.obsolete value=true +set name=org.opensolaris.consolidation value=$(CONSOLIDATION) diff -r c6aad84d2493 -r 0944d8c0158b components/meta-packages/history/system-management-visual-panels-panel-sharemgr.p5m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/meta-packages/history/system-management-visual-panels-panel-sharemgr.p5m Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,28 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. +# + +set name=pkg.fmri value=pkg:/system/management/visual-panels/panel-sharemgr@0.5.11,5.11-0.171 +set name=pkg.obsolete value=true +set name=org.opensolaris.consolidation value=$(CONSOLIDATION) diff -r c6aad84d2493 -r 0944d8c0158b components/meta-packages/history/system-management-visual-panels-panel-sysid.p5m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/meta-packages/history/system-management-visual-panels-panel-sysid.p5m Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,28 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. +# + +set name=pkg.fmri value=pkg:/system/management/visual-panels/panel-sysid@0.5.11,5.11-0.171 +set name=pkg.obsolete value=true +set name=org.opensolaris.consolidation value=$(CONSOLIDATION) diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,65 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +include ../../make-rules/shared-macros.mk + +# for now, everything with a Makefile should be built +SUBDIRS = $(shell echo */Makefile | sed -e 's;/Makefile;;g') + +.PHONY: $(SUBDIRS) + +download: TARGET = download +prep: TARGET = prep +build: TARGET = build +install: TARGET = install +publish: TARGET = publish +clean: TARGET = clean +clobber: TARGET = clobber +test: TARGET = test + +.DEFAULT: publish + +download prep build install publish test: $(SUBDIRS) + +clean: $(SUBDIRS) + $(RM) -r prototype build + +clobber: $(SUBDIRS) clean + +$(SUBDIRS): FORCE + @cd $@ && echo "$(TARGET) $@" && $(MAKE) $(TARGET) + +# dependencies +apache: core smf +coreadm: core +examples: core +firewall: core +smf: core +sysmon: core +time: core +usermgr: core +zconsole: core + +FORCE: diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/ant-rules/build-common.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/ant-rules/build-common.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,292 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/ant-rules/build-panels.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/ant-rules/build-panels.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/ant-rules/build-vpanels.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/ant-rules/build-vpanels.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/ant-rules/env-common.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/ant-rules/env-common.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/ant-rules/env-vpanels.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/ant-rules/env-vpanels.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/ant-rules/panel.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/ant-rules/panel.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,31 @@ + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,64 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. +# + +include ../../../make-rules/shared-macros.mk + +GMAKE = /usr/bin/make + +COMPONENT_NAME = visual-panels-apache +COMPONENT_VERSION = 0.5.11 +COMPONENT_SRC = src + +include $(WS_MAKE_RULES)/justmake.mk +include $(WS_MAKE_RULES)/ips.mk + +COMPONENT_BUILD_TARGETS = build +COMPONENT_BUILD_ENV += ROOT=$(BUILD_DIR)/prototype/$(MACH) +COMPONENT_BUILD_ENV += SRC=$(WS_COMPONENTS)/visual-panels +COMPONENT_BUILD_ENV += WS_JAVA=$(BUILD_DIR_32)/java +COMPONENT_BUILD_ENV += JAVA_HOME=/usr/java +COMPONENT_BUILD_ENV += PATH=$(dir $(CC)):/usr/bin +COMPONENT_BUILD_ENV += MACH32=$(MACH32) + +COMPONENT_INSTALL_TARGETS = install +COMPONENT_INSTALL_ENV = $(COMPONENT_BUILD_ENV) + +COMPONENT_TEST_TARGETS = test +COMPONENT_TEST_ENV = $(COMPONENT_BUILD_ENV) + +# common targets +$(SOURCE_DIR)/.prep: + $(TOUCH) $@ + +prep: $(SOURCE_DIR)/.prep + +build: $(BUILD_32) + +install: $(INSTALL_32) + +CLEAN_PATH += $(SOURCE_DIR)/.prep + +BUILD_PKG_DEPENDENCIES = $(BUILD_TOOLS) + +include $(WS_MAKE_RULES)/depend.mk diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/depend.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/depend.mk Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,1 @@ +visual-panels/apache: visual-panels/core visual-panels/smf diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,33 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. +# + +include $(SRC)/make-rules/Makefile.env + +cmd: java + +qinstall: + $(MAKE) install ANT='ant -Dquick=true' + +include $(SRC)/make-rules/Makefile.targ diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/cmd/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/cmd/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,30 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. +# + +include $(SRC)/make-rules/Makefile.env + +.PARALLEL: $(SUBDIRS) + +include $(SRC)/make-rules/Makefile.targ diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/cmd/applications/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/cmd/applications/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,33 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. +# + +include $(SRC)/make-rules/Makefile.env +include $(SRC)/make-rules/Makefile.targ + +APPS= vp-apache.desktop + +INSTAPPS=$(APPS:%=$(PROTO_APPS)/%) + +install: $(INSTAPPS) diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/cmd/applications/vp-apache.desktop --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/cmd/applications/vp-apache.desktop Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=Apache Web Server +Comment=Share files using the Apache HTTP Server +Exec=/usr/bin/vp apache +Icon=/usr/share/vpanels/pixmaps/apache.png +Terminal=false +Type=Application +Categories=GNOME;GTK;Application;System;Settings; +StartupNotify=true +Encoding=UTF-8 diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/cmd/httpd/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/cmd/httpd/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,34 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. +# + +include $(SRC)/make-rules/Makefile.env + +$(PROTO_MTD)/http-vpanels := FILEMODE = 0555 + +install: $(PROTO_MTD)/http-vpanels \ + $(PROTO_MFS_NETWORK)/http-vpanels.xml \ + $(PROTO_ETC_VPANELS)/httpd_conf.templ \ + +include $(SRC)/make-rules/Makefile.targ diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/cmd/httpd/http-vpanels --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/cmd/httpd/http-vpanels Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,334 @@ +#!/sbin/sh +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +. /lib/svc/share/smf_include.sh +. /lib/svc/share/ipf_include.sh + +APACHE_HOME=/usr/apache2/2.2 +CONF_FILE=/etc/vpanels/httpd.conf +PIDFILE=/var/run/apache2/httpd.pid + +TEMPLATE="/etc/vpanels/httpd_conf.templ" +APACHE_CONF="/var/run/httpd.conf" +SERVER_PG="httpd" +LISTEN_PORTS="" + +CAT="/usr/bin/cat" +CMP="/usr/bin/cmp" +CP="/usr/bin/cp" +ECHO="usr/bin/echo" +GREP="/usr/bin/grep" +MKDIR="/usr/bin/mkdir" +MV="/usr/bin/mv" +RM="/usr/bin/rm" +SED="/usr/bin/sed" +SORT="/usr/bin/sort" +SVCPROP="/usr/bin/svcprop" +TR="/usr/bin/tr" +UNIQ="/usr/bin/uniq" + +vhost_is_enabled() +{ + enabled=`$SVCPROP -p ${1}/enabled ${SMF_FMRI}` + if [ "$enabled" = "false" ]; then + return 1; + else + return 0; + fi +} + +# +# Add the given port to LISTEN_PORTS +# +add_listen_port() +{ + LISTEN_PORTS="${LISTEN_PORTS} ${1}" +} + +# Create additional module directives from vhost configurations. Modules +# additions are in server config context so this methods has to run +# before any call to generate_vhost() +# +process_modules() +{ + mods=`mktemp /tmp/apache_mod.XXXXXX` + if [ -z "$mods" ]; then + exit 1 + fi + + # Get a list of enabled virtual host. + list="$SERVER_PG" + for vhost in $1 + do + vhost_is_enabled $vhost && list="$list $vhost" + done + + for pg in $list + do + modules=`$SVCPROP $SMF_FMRI | /usr/xpg4/bin/grep "^$pg\/module" | \ + awk ' { printf("%s ", $1) }'` + + for module in $modules + do + set -- `$SVCPROP -p $module ${SMF_FMRI}` + if echo "$1" | grep "MODULE:" >/dev/null 2>&1; then + modname=`echo $1 | cut -f2 -d ':'` + file=$2 + else + modname=`echo $2 | cut -f2 -d ':'` + file=$1 + fi + echo "LoadModule $modname $file" >>$mods + + done + done + + if [ -f $mods ]; then + $CAT $mods | $SORT -u >$mods + $CAT $mods >>$APACHE_CONF + echo "">>$APACHE_CONF + fi +} + +# Put additional mime definitions into vhost configurations +# +process_mimes() +{ + pg=$1 + mimes=`$SVCPROP $SMF_FMRI | /usr/xpg4/bin/grep "^$pg\/mime" | \ + awk ' { printf("%s ", $1) }'` + + for mime in $mimes + do + Mimetype="" + ext="" + set -- `$SVCPROP -p $mime $SMF_FMRI` + for arg in "$@" + do + if echo "$arg" | grep "MIME:" >/dev/null 2>&1; then + Mimetype=`echo $arg | cut -f2 -d ':'` + else + ext="$ext $arg" + fi + done + ext=`echo "$ext" | sed 's/[,|\\]/ /g'` + echo "AddType $Mimetype $ext" >>$APACHE_CONF + done +} + +# Create vhost configuration in APACHE_CONF for +# named vhost. +# +generate_vhost() +{ + vhost_name="$1" + + # Don't bother if this vhost is disabled + vhost_is_enabled $vhost || return 0 + + sslengine=`$SVCPROP -p ${vhost_name}/sslengine ${SMF_FMRI}` + echo "" >>$APACHE_CONF + if [ "$sslengine" = "true" ]; then + sslcert=`$SVCPROP -p ${vhost_name}/sslcert ${SMF_FMRI}` + sslkey=`$SVCPROP -p ${vhost_name}/sslkey ${SMF_FMRI}` + sslip=`$SVCPROP -p ${vhost_name}/sslip ${SMF_FMRI}` + sslport=`$SVCPROP -p ${vhost_name}/sslport ${SMF_FMRI}` + + echo "Listen ${sslip}:${sslport}" >>$APACHE_CONF + echo "" >>$APACHE_CONF + echo "SSLEngine on" >>$APACHE_CONF + echo "SSLCertificateFile ${sslcert}" >>$APACHE_CONF + echo "SSLCertificateKeyFile ${sslkey}" >>$APACHE_CONF + else + port=`$SVCPROP -p ${vhost_name}/port ${SMF_FMRI}` + add_listen_port $port + echo "" >>$APACHE_CONF + fi + + process_mimes $vhost_name + docroot=`$SVCPROP -p ${vhost_name}/docroot ${SMF_FMRI}` + use_custom=`$SVCPROP -p ${vhost_name}/custom_conf ${SMF_FMRI}` + custom_file=`$SVCPROP -p ${vhost_name}/custom_file ${SMF_FMRI}` + domain=`$SVCPROP -p ${vhost_name}/domain ${SMF_FMRI}` + serve_home_dir=`$SVCPROP -p ${vhost_name}/serve_home_dir ${SMF_FMRI}` + + # Create DocumentRoot directive if it's not empty. Also + # create a Directory section with default permission for + # the specified DocumentRoot directory + # + if [ "$docroot" != "\"\"" ]; then + echo "DocumentRoot ${docroot}" >>$APACHE_CONF + + echo "" >>$APACHE_CONF + echo "Options Indexes Includes FollowSymLinks " \ + "SymLinksifOwnerMatch ExecCGI MultiViews" >>$APACHE_CONF + echo "AllowOverride None" >>$APACHE_CONF + echo "Order allow,deny" >>$APACHE_CONF + echo "Allow from all" >>$APACHE_CONF + echo " " >>$APACHE_CONF + fi + + if [ "$use_custom" = "true" ]; then + if [ "$custom_file" != "\"\"" ]; then + echo "Include ${custom_file}" >>$APACHE_CONF + fi + fi + + if [ "$serve_home_dir" = "true" ]; then + echo "UserDir public_html" >>$APACHE_CONF + + echo "" >>$APACHE_CONF + echo " AllowOverride Options FileInfo AuthConfig Limit" >>$APACHE_CONF + echo " Options Indexes Includes FollowSymLinks " \ + "SymLinksifOwnerMatch ExecCGI MultiViews" >>$APACHE_CONF + echo " " >>$APACHE_CONF + echo " Order allow,deny" >>$APACHE_CONF + echo " Allow from all" >>$APACHE_CONF + echo " " >>$APACHE_CONF + echo " " >>$APACHE_CONF + echo " Order deny,allow" >>$APACHE_CONF + echo " Allow from all" >>$APACHE_CONF + echo " " >>$APACHE_CONF + echo "" >>$APACHE_CONF + fi + + echo "ServerName ${domain}" >>$APACHE_CONF + echo "" >>$APACHE_CONF +} + +get_vhost_list() +{ + svccfg -s $1 listpg | awk ' { + if (($1 ~ /^vhost/) && ($2 == "application")) + printf("%s ", $1) + }' +} + +gen_conf_file() +{ + httpd_custom_file=`$SVCPROP -p ${SERVER_PG}/custom_file ${SMF_FMRI}` + httpd_sslengine=`$SVCPROP -p ${SERVER_PG}/sslengine ${SMF_FMRI}` + httpd_custom_conf=`$SVCPROP -p ${SERVER_PG}/custom_conf ${SMF_FMRI}` + + # Generate general parameters + if [ "$httpd_custom_conf" = "true" ]; then + $RM ${CONF_FILE} >/dev/null 2>&1 + ln -s ${httpd_custom_file} ${CONF_FILE} + exit 0 + else + $CP $TEMPLATE $APACHE_CONF + fi + + if [ "$httpd_sslengine" = "true" ]; then + echo "\n SSLEngine on" >>$APACHE_CONF + fi + + # Get the list of vhost names + vhost_list=`get_vhost_list ${SMF_FMRI}` + + # Add mimes for server and modules for both server and virtual hosts + process_modules "${vhost_list}" + process_mimes "${SERVER_PG}" + + # Make sure root user's home directory is disabled + echo "UserDir disabled root" >>$APACHE_CONF + + # Generate vhost clauses in configuration file + for vhost in $vhost_list + do + generate_vhost $vhost + done + + echo >> $APACHE_CONF + + # Add a "Listen " line for each uniqe port + echo "$LISTEN_PORTS" | "$TR" ' ' '\n' | "$GREP" '^[0-9][0-9]*$' | + "$SORT" | "$UNIQ" | "$SED" 's/^/Listen /' >> $APACHE_CONF + + # Add a "NameVirtualHost: *:" line for each duplicate port + echo "$LISTEN_PORTS" | "$TR" ' ' '\n' | "$GREP" '^[0-9][0-9]*$' | + "$SORT" | "$UNIQ" -d | + "$SED" 's/^/NameVirtualHost *:/' >> $APACHE_CONF + + replace_file $CONF_FILE $APACHE_CONF +} + +gen_ipf_conf() +{ + FMRI=$1 + ipf_file=`fmri_to_file ${FMRI} $IPF_SUFFIX` + policy=`get_policy ${FMRI}` + + echo "# $FMRI" >$ipf_file + # rules for global port + port=`$SVCPROP -p ${SERVER_PG}/port ${FMRI} 2>/dev/null` + generate_rules $FMRI $policy "tcp" "any" $port $ipf_file + + # rules for virtual hosts + vhost_list=`get_vhost_list ${FMRI}` + for vhost in $vhost_list + do + ip="any" + sslengine=`$SVCPROP -p ${vhost}/sslengine ${FMRI} 2>/dev/null` + if [ "$sslengine" = "true" ]; then + ip=`$SVCPROP -p ${vhost}/sslip ${FMRI} 2>/dev/null` + port=`$SVCPROP -p ${vhost}/sslport ${FMRI} 2>/dev/null` + else + port=`$SVCPROP -p ${vhost}/port ${FMRI} 2>/dev/null` + fi + generate_rules $FMRI $policy "tcp" $ip $port $ipf_file + done +} + + + +case "$1" in +start) + gen_conf_file + $RM -f ${PIDFILE} + $MKDIR -p /var/run/apache2 + cmd="-DSSL -k start" + ;; +refresh) + gen_conf_file + cmd="-k graceful" + ;; +stop) + cmd="-k stop" + ;; +ipfilter) + gen_ipf_conf $2 + exit $SMF_EXIT_OK + ;; +*) + echo "Usage: $0 {start|stop|refresh}" + exit 1 + ;; +esac + +[ ! -f ${CONF_FILE} ] && exit $SMF_EXIT_ERR_CONFIG + +exec ${APACHE_HOME}/bin/apachectl -f $CONF_FILE $cmd 2>&1 diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/cmd/httpd/http-vpanels.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/cmd/httpd/http-vpanels.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,309 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/cmd/httpd/httpd_conf.templ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/cmd/httpd/httpd_conf.templ Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,360 @@ +# +# This is the main Apache HTTP server configuration file. It contains the +# configuration directives that give the server its instructions. +# See for detailed information. +# In particular, see +# +# for a discussion of each configuration directive. +# +# Do NOT simply read the instructions in here without understanding +# what they do. They're here only as hints or reminders. If you are unsure +# consult the online docs. You have been warned. +# +# Configuration and logfile names: If the filenames you specify for many +# of the server's control files begin with "/" (or "drive:/" for Win32), the +# server will use that explicit path. If the filenames do *not* begin +# with "/", the value of ServerRoot is prepended -- so "/var/apache2/2.2/logs/foo.log" +# with ServerRoot set to "/usr/apache2/2.2" will be interpreted by the +# server as "/usr/apache2/2.2//var/apache2/2.2/logs/foo.log". + +# +# ServerRoot: The top of the directory tree under which the server's +# configuration, error, and log files are kept. +# +# Do not add a slash at the end of the directory path. If you point +# ServerRoot at a non-local disk, be sure to point the LockFile directive +# at a local disk. If you wish to share the same ServerRoot for multiple +# httpd daemons, you will need to change at least LockFile and PidFile. +# +ServerRoot "/usr/apache2/2.2" + +# +# Dynamic Shared Object (DSO) Support +# +# To be able to use the functionality of a module which was built as a DSO you +# have to place corresponding `LoadModule' lines at this location so the +# directives contained in it are actually available _before_ they are used. +# Statically compiled modules (those listed by `httpd -l') do not need +# to be loaded here. +# + +Include /etc/apache2/2.2/conf.d/modules-64.load +LoadModule perl_module libexec/amd64/mod_perl.so + + +Include /etc/apache2/2.2/conf.d/modules-32.load +LoadModule perl_module libexec/mod_perl.so + + + + +# +# If you wish httpd to run as a different user or group, you must run +# httpd as root initially and it will switch. +# +# User/Group: The name (or #number) of the user/group to run httpd as. +# It is usually good practice to create a dedicated user and group for +# running httpd, as with most system services. +# +User webservd +Group webservd + + +# 'Main' server configuration +# +# The directives in this section set up the values used by the 'main' +# server, which responds to any requests that aren't handled by a +# definition. These values also provide defaults for +# any containers you may define later in the file. +# +# All of these directives may appear inside containers, +# in which case these default settings will be overridden for the +# virtual host being defined. +# + +# +# ServerAdmin: Your address, where problems with the server should be +# e-mailed. This address appears on some server-generated pages, such +# as error documents. e.g. admin@your-domain.com +# +ServerAdmin root@localhost + +# +# ServerName gives the name and port that the server uses to identify itself. +# This can often be determined automatically, but we recommend you specify +# it explicitly to prevent problems during startup. +# +# If your host doesn't have a registered DNS name, enter its IP address here. +# +ServerName 127.0.0.1 + +# +# Each directory to which Apache has access can be configured with respect +# to which services and features are allowed and/or disabled in that +# directory (and its subdirectories). +# +# First, we configure the "default" to be a very restrictive set of +# features. +# + + Options FollowSymLinks + AllowOverride None + Order deny,allow + Deny from all + + +# +# Note that from this point forward you must specifically allow +# particular features to be enabled - so if something's not working as +# you might expect, make sure that you have specifically enabled it +# below. +# + +# +# DirectoryIndex: sets the file that Apache will serve if a directory +# is requested. +# + + DirectoryIndex index.html + + +# +# The following lines prevent .htaccess and .htpasswd files from being +# viewed by Web clients. +# + + Order allow,deny + Deny from all + Satisfy All + + +# +# ErrorLog: The location of the error log file. +# If you do not specify an ErrorLog directive within a +# container, error messages relating to that virtual host will be +# logged here. If you *do* define an error logfile for a +# container, that host's errors will be logged there and not here. +# +ErrorLog /var/apache2/2.2/logs/error_log + +# +# LogLevel: Control the number of messages logged to the error_log. +# Possible values include: debug, info, notice, warn, error, crit, +# alert, emerg. +# +LogLevel warn + + + # + # The following directives define some format nicknames for use with + # a CustomLog directive (see below). + # + LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined + LogFormat "%h %l %u %t \"%r\" %>s %b" common + + + # You need to enable mod_logio.c to use %I and %O + LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio + + + # + # The location and format of the access logfile (Common Logfile Format). + # If you do not define any access logfiles within a + # container, they will be logged here. Contrariwise, if you *do* + # define per- access logfiles, transactions will be + # logged therein and *not* in this file. + # + CustomLog /var/apache2/2.2/logs/access_log common + + # + # If you prefer a logfile with access, agent, and referer information + # (Combined Logfile Format) you can use the following directive. + # + #CustomLog /var/apache2/2.2/logs/access_log combined + + + + # + # Redirect: Allows you to tell clients about documents that used to + # exist in your server's namespace, but do not anymore. The client + # will make a new request for the document at its new location. + # Example: + # Redirect permanent /foo http://www.example.com/bar + + # + # Alias: Maps web paths into filesystem paths and is used to + # access content that does not live under the DocumentRoot. + # Example: + # Alias /webpath /full/filesystem/path + # + # If you include a trailing / on /webpath then the server will + # require it to be present in the URL. You will also likely + # need to provide a section to allow access to + # the filesystem path. + + # + # ScriptAlias: This controls which directories contain server scripts. + # ScriptAliases are essentially the same as Aliases, except that + # documents in the target directory are treated as applications and + # run by the server when requested rather than as documents sent to the + # client. The same rules about trailing "/" apply to ScriptAlias + # directives as to Alias. + # + ScriptAlias /cgi-bin/ "/var/apache2/2.2/cgi-bin/" + + + + + # + # ScriptSock: On threaded servers, designate the path to the UNIX + # socket used to communicate with the CGI daemon of mod_cgid. + # + #Scriptsock /var/run/apache2/2.2/cgisock + + +# +# "/var/apache2/2.2/cgi-bin" should be changed to whatever your ScriptAliased +# CGI directory exists, if you have that configured. +# +# +# AllowOverride None +# Options None +# Order allow,deny +# Allow from all +# + +# +# DefaultType: the default MIME type the server will use for a document +# if it cannot otherwise determine one, such as from filename extensions. +# If your server contains mostly text or HTML documents, "text/plain" is +# a good value. If most of your content is binary, such as applications +# or images, you may want to use "application/octet-stream" instead to +# keep browsers from trying to display binary files as though they are +# text. +# +DefaultType text/plain + + + # + # TypesConfig points to the file containing the list of mappings from + # filename extension to MIME-type. + # + TypesConfig /etc/apache2/2.2/mime.types + + # + # AddType allows you to add to or override the MIME configuration + # file specified in TypesConfig for specific file types. + # + #AddType application/x-gzip .tgz + # + # AddEncoding allows you to have certain browsers uncompress + # information on the fly. Note: Not all browsers support this. + # + #AddEncoding x-compress .Z + #AddEncoding x-gzip .gz .tgz + # + # If the AddEncoding directives above are commented-out, then you + # probably should define those extensions to indicate media types: + # + AddType application/x-compress .Z + AddType application/x-gzip .gz .tgz + + # + # AddHandler allows you to map certain file extensions to "handlers": + # actions unrelated to filetype. These can be either built into the server + # or added with the Action directive (see below) + # + # To use CGI scripts outside of ScriptAliased directories: + # (You will also need to add "ExecCGI" to the "Options" directive.) + # + AddHandler cgi-script .cgi + AddHandler perl-script .pl + + PerlResponseHandler ModPerl::Registry + PerlOptions +ParseHeaders + + # For type maps (negotiated resources): + #AddHandler type-map var + + # + # Filters allow you to process content before it is sent to the client. + # + # To parse .shtml files for server-side includes (SSI): + # (You will also need to add "Includes" to the "Options" directive.) + # + #AddType text/html .shtml + #AddOutputFilter INCLUDES .shtml + + +# +# The mod_mime_magic module allows the server to use various hints from the +# contents of the file itself to determine its type. The MIMEMagicFile +# directive tells the module where the hint definitions are located. +# +#MIMEMagicFile /etc/apache2/2.2/magic + +# +# Customizable error responses come in three flavors: +# 1) plain text 2) local redirects 3) external redirects +# +# Some examples: +#ErrorDocument 500 "The server made a boo boo." +#ErrorDocument 404 /missing.html +#ErrorDocument 404 "/cgi-bin/missing_handler.pl" +#ErrorDocument 402 http://www.example.com/subscription_info.html +# + +# +# EnableMMAP and EnableSendfile: On systems that support it, +# memory-mapping or the sendfile syscall is used to deliver +# files. This usually improves server performance, but must +# be turned off when serving from networked-mounted +# filesystems or if support for these functions is otherwise +# broken on your system. +# +#EnableMMAP off +#EnableSendfile off + +# Supplemental configuration +# +# The configuration files in the /etc/apache2/2.2/conf.d/ directory can be +# included to add extra features or to modify the default configuration of +# the server, or you may simply copy their contents here and change as +# necessary. + +Include /etc/apache2/2.2/conf.d/php5.2.conf +# +# Visual Panels will supply SSL configuration(s) +# Include /etc/apache2/2.2/conf.d/ssl.conf + +# +# Note: The following must must be present to support +# starting without SSL on platforms with no /dev/random equivalent +# but a statically compiled-in mod_ssl. +# + +SSLRandomSeed startup builtin +SSLRandomSeed connect builtin + + + + ListenBacklog 8192 + ServerLimit 2048 + MaxClients 2048 + + +# +# Virtual Hosts +# +# If you want to maintain multiple domains/hostnames on your +# machine you can setup VirtualHost containers for them. Most configurations +# use only name-based virtual hosts so the server doesn't need to worry about +# IP addresses. This is indicated by the asterisks in the directives below. +# +# Please see the documentation at +# +# for further details before you try to setup virtual hosts. +# +# You may use the command line option '-S' to verify your virtual host +# configuration. + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,27 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. +# + +include $(SRC)/make-rules/Makefile.env +include $(SRC)/make-rules/Makefile.targ diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,28 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. +# + +include $(SRC)/make-rules/Makefile.env +include $(SRC)/make-rules/Makefile.targ + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,34 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. +# + +include $(SRC)/make-rules/Makefile.env + +ASUBDIRS_CMD = $(LS) -1 */build.xml 2>/dev/null | $(SED) 's@/build.xml$$@@' +ASUBDIRS = $(ASUBDIRS_CMD:sh) + +.PARALLEL: $(ASUBDIRS) + +include $(SRC)/make-rules/Makefile.ant +include $(SRC)/make-rules/Makefile.targ diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/build.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/ApacheInfo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/ApacheInfo.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import com.oracle.solaris.vp.panel.common.smf.*; + +public interface ApacheInfo extends SmfPropertyInfo { + // + // HasService methods + // + + @Override + AggregatedRefreshService getService(); + + // + // ApacheInfo methods + // + + ApachePanelDescriptor getPanelDescriptor(); +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/ApachePanelDescriptor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/ApachePanelDescriptor.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,455 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.io.IOException; +import java.util.*; +import javax.management.InstanceNotFoundException; +import javax.swing.*; +import javax.swing.filechooser.FileSystemView; +import com.oracle.solaris.adr.Stability; +import com.oracle.solaris.scf.common.ScfException; +import com.oracle.solaris.vp.panel.common.*; +import com.oracle.solaris.vp.panel.common.api.network.*; +import com.oracle.solaris.vp.panel.common.api.file.RemoteFileSystemView; +import com.oracle.solaris.vp.panel.common.api.smf_old.PropertyGroup; +import com.oracle.solaris.vp.panel.common.control.*; +import com.oracle.solaris.vp.panel.common.model.*; +import com.oracle.solaris.vp.panel.common.smf.*; +import com.oracle.solaris.vp.panel.swing.control.PanelFrameControl; +import com.oracle.solaris.vp.panel.swing.model.SwingPanelDescriptor; +import com.oracle.solaris.vp.util.misc.*; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.misc.property.*; +import com.oracle.solaris.vp.util.swing.HasIcons; + +@SuppressWarnings({"serial"}) +public class ApachePanelDescriptor + extends ServicePanelDescriptor + implements SwingPanelDescriptor, ApacheInfo, HasIcons { + + // + // Static data + // + + // XXX More sizes should be provided + protected static final List icons = Finder.getIcons( + "images/apache-32.png"); + + public static final String SMF_GROUP = "httpd"; + + public static final String PROPERTY_CUSTOM_ENABLED = "custom_conf"; + public static final String PROPERTY_CUSTOM_FILE = "custom_file"; + public static final String PROPERTY_ADDED = "added vhosts"; + public static final String PROPERTY_REMOVED = "removed vhosts"; + + private static final String SERVICE = "network/vpanels-http"; + private static final String INSTANCE = "apache2"; + + // Sort based on domain, then ID + private static final Comparator COMPARATOR = + new Comparator() { + @Override + public int compare(VirtualHost o1, VirtualHost o2) { + int result = ObjectUtil.compare( + o1.getDomainProperty().getFirstValue(), + o2.getDomainProperty().getFirstValue()); + + if (result != 0) { + return result; + } + + return ObjectUtil.compare(o1.getId(), o2.getId()); + } + }; + + // + // Instance data + // + + private DefaultControl control; + private RemoteFileSystemView fsView; + private MXBeanTracker networkBeanTracker; + + private BasicSmfMutableProperty customEnabledProperty = + new BooleanSmfProperty(PROPERTY_CUSTOM_ENABLED, this); + + private BasicSmfMutableProperty customFileProperty = + new StringSmfProperty(PROPERTY_CUSTOM_FILE, this); + + private BasicMutableProperty addedProperty = + new IntegerProperty(PROPERTY_ADDED); + + private BasicMutableProperty removedProperty = + new IntegerProperty(PROPERTY_REMOVED); + + private MimeTypes mimeTypes; + private Modules modules; + private PropertyGroupNamePool vHostNamePool; + private List removed = new ArrayList(); + + // + // Constructors + // + + public ApachePanelDescriptor(String id, ClientContext context) + throws IOException, ScfException, InvalidScfDataException, + MissingScfDataException, InstanceNotFoundException, + TrackerException { + + super(id, context, SERVICE, INSTANCE); + + fsView = new RemoteFileSystemView(context); + + networkBeanTracker = new MXBeanTracker( + NetworkUtil.OBJECT_NAME, NetworkMXBean.class, Stability.PRIVATE, + context); + + vHostNamePool = new PropertyGroupNamePool(getService(), + VirtualHost.SMF_GROUP_PREFIX); + + customEnabledProperty.setFirstValue(false); + addProperties(customEnabledProperty); + + customFileProperty.setFirstValue(""); + addProperties(customFileProperty); + + addProperties(getEnabledProperty()); + + addedProperty.update(0, true); + addProperties(addedProperty); + + removedProperty.update(0, true); + addProperties(removedProperty); + + setComparator(COMPARATOR); + + ChangeableAggregator aggregator = getChangeableAggregator(); + + mimeTypes = new MimeTypes(this); + aggregator.addChangeables(mimeTypes.getChangeableAggregator()); + + modules = new Modules(this); + aggregator.addChangeables(modules.getChangeableAggregator()); + + refresh(true); + control = new PanelFrameControl(this); + control.addChildren(new MainControl(this)); + } + + // + // HasIcons methods + // + + @Override + public List getIcons() { + return icons; + } + + // + // SmfPropertyGroupInfo methods + // + + @Override + public String getPropertyGroupName() { + return SMF_GROUP; + } + + // + // SmfPropertyInfo methods + // + + @Override + public String getPropertyName() { + // Use the default property names + return null; + } + + // + // ApacheInfo methods + // + + @Override + public ApachePanelDescriptor getPanelDescriptor() { + return this; + } + + // + // ManagedObject methods + // + + @Override + public void dispose() { + super.dispose(); + networkBeanTracker.dispose(); + fsView.dispose(); + } + + // + // PanelDescriptor methods + // + + @Override + public Control getControl() { + return control; + } + + // + // AbstractManagedObject methods + // + + @Override + public void addChildren(VirtualHost... toAdd) { + super.addChildren(toAdd); + + ChangeableAggregator aggregator = getChangeableAggregator(); + for (VirtualHost vHost : toAdd) { + if (!vHost.isInRepo()) { + addedProperty.setValue(addedProperty.getValue() + 1); + } + aggregator.addChangeables(vHost.getChangeableAggregator()); + } + } + + @Override + public void removeChildren(VirtualHost... toRemove) { + super.removeChildren(toRemove); + + ChangeableAggregator aggregator = getChangeableAggregator(); + for (VirtualHost vHost : toRemove) { + if (!vHost.isInRepo()) { + addedProperty.setValue(addedProperty.getValue() - 1); + } + aggregator.removeChangeable(vHost.getChangeableAggregator()); + } + } + + // + // ServicePanelDescriptor methods + // + + @Override + public void refresh(boolean force) throws ScfException, + InvalidScfDataException, MissingScfDataException { + + super.refresh(force); + + for (MutableProperty property : getProperties()) { + if (property instanceof SmfMutableProperty) { + ((SmfMutableProperty)property).updateFromRepo(force); + } + } + + // Build list of names of virtual host property groups + List groups = new ArrayList(); + for (PropertyGroup pg : getService().getPropertyGroups()) { + String group = pg.getName(); + if (group.startsWith(VirtualHost.SMF_GROUP_PREFIX)) { + groups.add(group); + } + } + Collections.sort(groups); + + // Remove names of groups that are pending removal on client + for (Iterator i = removed.iterator(); i.hasNext(); ) { + VirtualHost vHost = i.next(); + String group = vHost.getPropertyGroupName(); + if (groups.remove(group)) { + // Pending removal on client, still exists on server + } else { + // Pending removal on client, but already removed on server + i.remove(); + int n = removed.size(); + assert n == removedProperty.getValue() - 1; + removedProperty.setValue(n); + } + } + + // Remove names of groups already created on the client + List children = new ArrayList(getChildren()); + for (VirtualHost vHost : children) { + if (vHost.isInRepo()) { + String group = vHost.getPropertyGroupName(); + if (groups.remove(group)) { + // Exists on server, already exists on client + vHost.refresh(force); + } else { + // Deleted on server, now must be deleted on client + removeChildren(vHost); + } + } + } + + // The list now contains only groups that have been created on the + // server but don't yet exist on the client + for (String group : groups) { + VirtualHost vHost = new VirtualHost(this, group); + addChildren(vHost); + } + + mimeTypes.refresh(force); + modules.refresh(force); + } + + // + // ApachePanelDescriptor methods + // + + public BasicSmfMutableProperty getCustomEnabledProperty() { + return customEnabledProperty; + } + + public BasicSmfMutableProperty getCustomFileProperty() { + return customFileProperty; + } + + public FileSystemView getFileSystemView() { + return fsView; + } + + public MimeTypes getMimeTypes() { + return mimeTypes; + } + + public Modules getModules() { + return modules; + } + + public VirtualHost getVirtualHost(String id) { + synchronized (children) { + for (VirtualHost vHost : children) { + if (vHost.getId().equals(id)) { + return vHost; + } + } + return null; + } + } + + /** + * Gets the first virtual host with the given domain. + */ + public VirtualHost getVirtualHostByDomain(String domain) { + synchronized (children) { + for (VirtualHost vHost : children) { + if (vHost.getDomainProperty().getFirstValue().equals(domain)) { + return vHost; + } + } + return null; + } + } + + protected PropertyGroupNamePool getVirtualHostNamePool() { + return vHostNamePool; + } + + public void scheduleRemove(VirtualHost... vHosts) { + for (VirtualHost vHost : vHosts) { + if (getChildren().contains(vHost)) { + removeChildren(vHost); + + if (vHost.isInRepo()) { + removed.add(vHost); + int n = removed.size(); + assert n == removedProperty.getValue() + 1; + removedProperty.setValue(n); + } + } + } + } + + public void saveToRepo() throws ScfException { + ApacheUtil.saveToRepo(getService(), + new ScfRunnable() { + @Override + public void run() throws ScfException { + for (VirtualHost vHost : getChildren()) { + vHost.saveToRepo(); + } + addedProperty.setValue(0); + + for (Iterator i = removed.iterator(); + i.hasNext(); ) { + + VirtualHost vHost = i.next(); + vHost.removeFromRepo(); + i.remove(); + int n = removed.size(); + assert n == removedProperty.getValue() - 1; + removedProperty.setValue(n); + } + + for (MutableProperty property : getProperties()) { + if (property.isChanged()) { + if (property instanceof SmfMutableProperty) { + ((SmfMutableProperty)property).saveToRepo(); + } else { + property.save(); + } + } + } + + mimeTypes.saveToRepo(); + modules.saveToRepo(); + } + }); + } + + protected void validate() throws GlobalValidationException, + VirtualHostGeneralValidationException, + VirtualHostSSLValidationException { + + validateCustomFile(); + for (VirtualHost vHost : getChildren()) { + vHost.validate(); + } + } + + // + // Private methods + // + + private void validateCustomFile() + throws GlobalValidationException { + + if (customEnabledProperty.getFirstValue() && + (customEnabledProperty.isChanged() || + customFileProperty.isChanged()) && + customFileProperty.getFirstValue().isEmpty()) { + throw new GlobalValidationException( + Finder.getString("global.error.customfile.empty")); + } + } + + // + // ApachePanelDescriptor classes + // + + public NetworkMXBean getNetworkMXBean() { + return networkBeanTracker.getBean(); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/ApacheUtil.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/ApacheUtil.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,114 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.util.*; +import com.oracle.solaris.scf.common.ScfException; +import com.oracle.solaris.vp.panel.common.smf.*; +import com.oracle.solaris.vp.util.misc.property.MutableProperty; + +@SuppressWarnings({"serial"}) +public class ApacheUtil { + // + // Static methods + // + + public static String getNextAvailablePropertyName(SmfPropertyGroupInfo info, + String prefix) throws ScfException { + + ServiceMXBean service = info.getService(); + String group = info.getPropertyGroupName(); + + List names = new ArrayList( + service.getPropertyNames(group)); + + Collections.sort(names); + + String name = null; + int i = 1; + + // Property names take the form , where n > 0 + do { + name = prefix + i++; + } while (Collections.binarySearch(names, name) >= 0); + + return name; + } + + public static void saveToRepo(AggregatedRefreshService service, + ScfRunnable runnable) throws ScfException { + + synchronized (service) { + boolean needLock = !service.isPaused(); + if (needLock) { + service.pause(); + } + + boolean success = false; + try { + // Throws ScfException + runnable.run(); + success = true; + } finally { + if (needLock) { + if (success) { + // Throws ScfException + service.unpause(); + } else { + // Unlock, refresh if needed, ignore any exceptions + // since we are already in the midst of throwing one + try { + service.unpause(); + } catch (Throwable ignore) { + } + } + } + } + } + } + + public static void update(MutableProperty src, + MutableProperty dest) { + + boolean changed = dest.isChanged(); + dest.setSavedValue(src.getSavedValue()); + + if (!changed) { + dest.setValue(src.getValue()); + } + } + + public static void update(BasicSmfMutableProperty src, + MutableProperty dest) { + + boolean changed = dest.isChanged(); + dest.setSavedValue(src.getFirstSavedValue()); + + if (!changed) { + dest.setValue(src.getFirstValue()); + } + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/ChangeButton.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/ChangeButton.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,89 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import javax.swing.*; +import javax.swing.event.*; +import com.oracle.solaris.vp.panel.swing.view.ChangeIndicator; +import com.oracle.solaris.vp.util.misc.Changeable; + +@SuppressWarnings({"serial"}) +public class ChangeButton extends JButton implements ChangeListener { + // + // Constructors + // + + public ChangeButton() { + init(); + } + + public ChangeButton(Action a) { + super(a); + init(); + } + + public ChangeButton(Icon icon) { + super(icon); + init(); + } + + public ChangeButton(String text) { + super(text); + init(); + } + + public ChangeButton(String text, Icon icon) { + super(text, icon); + init(); + } + + // + // ChangeListener methods + // + + @Override + public void stateChanged(ChangeEvent e) { + Changeable source = (Changeable)e.getSource(); + setChanged(source.isChanged()); + } + + // + // ChangeButton methods + // + + public void setChanged(boolean changed) { + setIcon(changed ? ChangeIndicator.ICON_CHANGED : null); + setToolTipText(changed ? ChangeIndicator.TEXT : null); + } + + // + // Private methods + // + + private void init() { + setChanged(false); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/CloneVirtualHostAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/CloneVirtualHostAction.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,122 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.awt.Component; +import java.util.List; +import javax.swing.JOptionPane; +import com.oracle.solaris.vp.panel.common.action.*; +import com.oracle.solaris.vp.panel.common.control.*; +import com.oracle.solaris.vp.panel.common.model.ManagedObject; +import com.oracle.solaris.vp.panel.swing.action.CloneManagedObjectAction; +import com.oracle.solaris.vp.panel.swing.control.SwingControl; +import com.oracle.solaris.vp.util.misc.finder.Finder; + +@SuppressWarnings({"serial"}) +public class CloneVirtualHostAction + extends CloneManagedObjectAction { + + // + // Instance data + // + + private SwingControl control; + + // + // Constructors + // + + public CloneVirtualHostAction( + SwingControl control) { + + super(TEXT, ICONS, control); + this.control = control; + setLoops(true); + } + + // + // StructuredAction methods + // + + @Override + public String getRuntimeInput(List selection, String domain) + throws ActionAbortedException { + + Object response = JOptionPane.showInputDialog( + getHasComponent().getComponent(), + Finder.getString("vhosts.action.clone.message"), + Finder.getString("vhosts.action.clone.title"), + JOptionPane.PLAIN_MESSAGE, null, null, domain); + + if (response == null) { + throw new ActionAbortedException(); + } + + return response.toString(); + } + + /** + * Enables this {@code Action} iff a single {@link VirtualHost} is selected. + */ + @Override + public void refresh() { + List selection = getPresetInput(); + boolean enabled = selection.size() == 1 && + selection.get(0) instanceof VirtualHost; + + setEnabled(enabled); + } + + // + // DefaultStructuredAction methods + // + + @Override + public VirtualHost workBusy(List selection, + String domain) throws ActionAbortedException, ActionFailedException, + ActionUnauthorizedException { + + VirtualHost.validateDomainName(domain, null); + + // Assume valid selection + VirtualHost orig = (VirtualHost)selection.get(0); + + VirtualHost clone = orig.clone(); + clone.getEnabledProperty().setFirstValue(false); + clone.getDomainProperty().setFirstValue(domain); + + control.getPanelDescriptor().addChildren(clone); + + // Navigate to the new virtual host + Navigable navigable = new SimpleNavigable( + VirtualHostControl.ID, null, + VirtualHostControl.PARAM_ID, clone.getId()); + + control.getNavigator().goToAsync(false, control, navigable); + + return clone; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/CreateMimeTypeAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/CreateMimeTypeAction.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,220 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.awt.Component; +import java.awt.event.*; +import java.util.List; +import javax.swing.*; +import com.oracle.solaris.vp.panel.common.action.*; +import com.oracle.solaris.vp.panel.common.control.*; +import com.oracle.solaris.vp.panel.swing.action.AddManagedObjectAction; +import com.oracle.solaris.vp.util.misc.ObjectUtil; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.misc.property.*; +import com.oracle.solaris.vp.util.swing.*; +import com.oracle.solaris.vp.util.swing.layout.*; +import com.oracle.solaris.vp.util.swing.property. + TextComponentPropertySynchronizer; + +@SuppressWarnings({"serial"}) +public class CreateMimeTypeAction extends AddManagedObjectAction + { + + // + // Inner classes + // + + protected class Data { + // + // Instance data + // + + public StringProperty typeProperty = new StringProperty(); + public StringProperty subtypeProperty = new StringProperty(); + public StringArrayProperty extProperty = new StringArrayProperty(); + public JOptionPane pane; + public JDialog dialog; + + // + // Constructors + // + + public Data() { + ActionListener listener = + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + pane.setValue(JOptionPane.OK_OPTION); + } + }; + + JLabel typeLabel = new JLabel( + Finder.getString("mimetype.edit.type")); + JTextField typeField = GUIUtil.createTextField(); + typeField.addActionListener(listener); + new TextComponentPropertySynchronizer( + typeProperty, typeField, false); + + JLabel subtypeLabel = new JLabel( + Finder.getString("mimetype.edit.subtype")); + JTextField subtypeField = GUIUtil.createTextField(); + subtypeField.addActionListener(listener); + new TextComponentPropertySynchronizer( + subtypeProperty, subtypeField, false); + + JLabel extLabel = new JLabel( + Finder.getString("mimetype.edit.extensions")); + JTextField extField = GUIUtil.createTextField(); + extField.addActionListener(listener); + new TextComponentPropertySynchronizer( + extProperty, extField, false); + + JPanel formPanel = new JPanel(); + formPanel.setOpaque(false); + Form form = new Form(formPanel, VerticalAnchor.TOP); + + int gap = GUIUtil.getHalfGap(); + + ColumnLayoutConstraint c = new ColumnLayoutConstraint( + HorizontalAnchor.FILL, gap); + + HasAnchors a = new SimpleHasAnchors( + HorizontalAnchor.LEFT, VerticalAnchor.CENTER); + + form.addTable(2, gap, gap, HorizontalAnchor.LEFT, c); + + form.add(typeLabel, a); + form.add(typeField, a); + + form.add(subtypeLabel, a); + form.add(subtypeField, a); + + form.add(extLabel, a); + form.add(extField, a); + + pane = new JOptionPane(formPanel, JOptionPane.PLAIN_MESSAGE, + JOptionPane.OK_CANCEL_OPTION); + + dialog = pane.createDialog(getHasComponent().getComponent(), + Finder.getString("mimetypes.action.create.title")); + } + } + + // + // Static data + // + + private static final String TEXT = Finder.getString( + "mimetypes.action.create.button"); + + // + // Instance data + // + + private MimeTypesControl control; + + // + // Constructors + // + + public CreateMimeTypeAction(MimeTypesControl control) { + super(TEXT, null, control); + this.control = control; + setLoops(true); + } + + // + // StructuredAction methods + // + + @Override + public Data getRuntimeInput(List selection, Data data) + throws ActionAbortedException { + + // Since this action navigates to the new object once created, we must + // first navigate to control so that any outstanding changes in the + // current Control are handled. + try { + control.getNavigator().goToAsyncAndWait(false, control); + } catch (NavigationException e) { + throw new ActionAbortedException(e); + } + + if (data == null) { + data = new Data(); + } + + // Blocks until dismissed + data.dialog.setVisible(true); + + if (!ObjectUtil.equals(data.pane.getValue(), JOptionPane.OK_OPTION)) { + throw new ActionAbortedException(); + } + + return data; + } + + // + // DefaultStructuredAction methods + // + + @Override + public MimeType workBusy(List selection, Data data) + throws ActionAbortedException, ActionFailedException, + ActionUnauthorizedException { + + String type = data.typeProperty.getValue(); + String subtype = data.subtypeProperty.getValue(); + String[] extensions = data.extProperty.getValue(); + + // Throws ActionFailedException + MimeTypeControl.validate(type, subtype); + + MimeTypes mimeTypes = control.getHasMimeTypes().getMimeTypes(); + + if (mimeTypes.getMimeType(type, subtype) != null) { + throw new ActionFailedException(Finder.getString( + "mimetype.error.duplicate", type, subtype)); + } + + MimeType mimeType = new MimeType(mimeTypes); + mimeType.getTypeProperty().setValue(type); + mimeType.getSubtypeProperty().setValue(subtype); + mimeType.getExtensionsProperty().setValue(extensions); + + mimeTypes.addChildren(mimeType); + + // Navigate to the new MIME type + Navigable navigable = new SimpleNavigable( + MimeTypeControl.ID, null, + MimeTypeControl.PARAM_MIMETYPE, mimeType.getId()); + + control.getNavigator().goToAsync(false, control, navigable); + + return mimeType; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/CreateModuleAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/CreateModuleAction.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,214 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.awt.Component; +import java.awt.event.*; +import java.util.List; +import javax.swing.*; +import javax.swing.filechooser.FileSystemView; +import com.oracle.solaris.vp.panel.common.action.*; +import com.oracle.solaris.vp.panel.common.control.*; +import com.oracle.solaris.vp.panel.swing.action.AddManagedObjectAction; +import com.oracle.solaris.vp.util.misc.ObjectUtil; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.misc.property.StringProperty; +import com.oracle.solaris.vp.util.swing.*; +import com.oracle.solaris.vp.util.swing.layout.*; +import com.oracle.solaris.vp.util.swing.property. + TextComponentPropertySynchronizer; + +@SuppressWarnings({"serial"}) +public class CreateModuleAction extends AddManagedObjectAction + { + + // + // Inner classes + // + + protected class Data { + // + // Instance data + // + + public StringProperty nameProperty = new StringProperty(); + public StringProperty fileProperty = new StringProperty(); + public JOptionPane pane; + public JDialog dialog; + + // + // Constructors + // + + public Data() { + ActionListener listener = + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + pane.setValue(JOptionPane.OK_OPTION); + } + }; + + JLabel nameLabel = new JLabel( + Finder.getString("module.edit.name")); + JTextField nameField = GUIUtil.createTextField(); + nameField.addActionListener(listener); + new TextComponentPropertySynchronizer( + nameProperty, nameField); + + JLabel fileLabel = new JLabel( + Finder.getString("module.edit.file")); + + BrowsableFilePanel fileField = new BrowsableFilePanel(); + fileField.setOpaque(false); + + FileSystemView fsView = + control.getPanelDescriptor().getFileSystemView(); + fileField.getFileChooser().setFileSystemView(fsView); + + new TextComponentPropertySynchronizer( + fileProperty, fileField.getField()); + + JPanel formPanel = new JPanel(); + formPanel.setOpaque(false); + Form form = new Form(formPanel, VerticalAnchor.TOP); + + int gap = GUIUtil.getHalfGap(); + + ColumnLayoutConstraint c = new ColumnLayoutConstraint( + HorizontalAnchor.FILL, gap); + + HasAnchors a = new SimpleHasAnchors( + HorizontalAnchor.LEFT, VerticalAnchor.CENTER); + + form.addTable(2, gap, gap, HorizontalAnchor.LEFT, c); + + form.add(nameLabel, a); + form.add(nameField, a); + + form.add(fileLabel, a); + form.add(fileField, a); + + pane = new JOptionPane(formPanel, JOptionPane.PLAIN_MESSAGE, + JOptionPane.OK_CANCEL_OPTION); + + dialog = pane.createDialog(getHasComponent().getComponent(), + Finder.getString("modules.action.create.title")); + } + } + + // + // Static Data + // + + private static final String TEXT = Finder.getString( + "modules.action.create.button"); + + // + // Instance Data + // + + private ModulesControl control; + + // + // Constructors + // + + public CreateModuleAction(ModulesControl control) { + super(TEXT, null, control); + this.control = control; + setLoops(true); + } + + // + // StructuredAction methods + // + + @Override + public Data getRuntimeInput(List selection, Data data) + throws ActionAbortedException { + + // Since this action navigates to the new object once created, we must + // first navigate to control so that any outstanding changes in the + // current Control are handled. + try { + control.getNavigator().goToAsyncAndWait(false, control); + } catch (NavigationException e) { + throw new ActionAbortedException(e); + } + + if (data == null) { + data = new Data(); + } + + // Blocks until dismissed + data.dialog.setVisible(true); + + if (!ObjectUtil.equals(data.pane.getValue(), JOptionPane.OK_OPTION)) { + throw new ActionAbortedException(); + } + + return data; + } + + // + // DefaultStructuredAction methods + // + + @Override + public Module workBusy(List selection, Data data) + throws ActionAbortedException, ActionFailedException, + ActionUnauthorizedException { + + String name = data.nameProperty.getValue(); + String file = data.fileProperty.getValue(); + + // Throws ActionFailedException + ModuleControl.validate(name, file); + + Modules modules = control.getHasModules().getModules(); + + if (modules.getModule(name) != null) { + throw new ActionFailedException(Finder.getString( + "module.error.duplicate", name)); + } + + Module module = new Module(modules); + module.getNameProperty().setValue(name); + module.getFileProperty().setValue(file); + + modules.addChildren(module); + + // Navigate to the new module + Navigable navigable = new SimpleNavigable( + ModuleControl.ID, null, + ModuleControl.PARAM_MODULE, module.getId()); + + control.getNavigator().goToAsync(false, control, navigable); + + return module; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/CreateVirtualHostAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/CreateVirtualHostAction.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,209 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.awt.Component; +import java.awt.event.*; +import java.util.List; +import javax.swing.*; +import javax.swing.text.JTextComponent; +import com.oracle.solaris.vp.panel.common.action.*; +import com.oracle.solaris.vp.panel.common.control.*; +import com.oracle.solaris.vp.panel.common.model.ManagedObject; +import com.oracle.solaris.vp.panel.swing.action.AddManagedObjectAction; +import com.oracle.solaris.vp.util.misc.ObjectUtil; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.misc.property.StringProperty; +import com.oracle.solaris.vp.util.swing.*; +import com.oracle.solaris.vp.util.swing.layout.*; +import com.oracle.solaris.vp.util.swing.property. + TextComponentPropertySynchronizer; + +@SuppressWarnings({"serial"}) +public class CreateVirtualHostAction extends AddManagedObjectAction + { + + // + // Inner classes + // + + protected class Data { + // + // Instance data + // + + public StringProperty domainProperty = new StringProperty(); + public StringProperty docRootProperty = new StringProperty(); + public JOptionPane pane; + public JDialog dialog; + + // + // Constructors + // + + public Data() { + ActionListener listener = + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + pane.setValue(JOptionPane.OK_OPTION); + } + }; + + JLabel domainLabel = new JLabel( + Finder.getString("vhost.general.edit.domain")); + JTextField domainField = GUIUtil.createTextField(); + domainField.addActionListener(listener); + new TextComponentPropertySynchronizer( + domainProperty, domainField, false); + + JLabel docRootLabel = new JLabel( + Finder.getString("vhost.general.edit.docroot")); + + BrowsableFilePanel docRootField = new BrowsableFilePanel(); + docRootField.setOpaque(false); + JFileChooser chooser = docRootField.getFileChooser(); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + chooser.setFileSystemView( + control.getPanelDescriptor().getFileSystemView()); + + new TextComponentPropertySynchronizer( + docRootProperty, docRootField.getField(), false); + + JPanel formPanel = new JPanel(); + formPanel.setOpaque(false); + Form form = new Form(formPanel, VerticalAnchor.TOP); + + int gap = GUIUtil.getHalfGap(); + + ColumnLayoutConstraint c = new ColumnLayoutConstraint( + HorizontalAnchor.FILL, gap); + + HasAnchors a = new SimpleHasAnchors( + HorizontalAnchor.LEFT, VerticalAnchor.CENTER); + + form.addTable(2, gap, gap, HorizontalAnchor.LEFT, c); + + form.add(domainLabel, a); + form.add(domainField, a); + + form.add(docRootLabel, a); + form.add(docRootField, a); + + pane = new JOptionPane(formPanel, JOptionPane.PLAIN_MESSAGE, + JOptionPane.OK_CANCEL_OPTION); + + dialog = pane.createDialog(getHasComponent().getComponent(), + Finder.getString("vhosts.action.create.title")); + } + } + + // + // Static data + // + + private static final String TEXT = Finder.getString( + "vhosts.action.create.button"); + + // + // Instance data + // + + private MainControl control; + + // + // Constructors + // + + public CreateVirtualHostAction(MainControl control) { + super(TEXT, null, control); + this.control = control; + setLoops(true); + } + + // + // StructuredAction methods + // + + @Override + public Data getRuntimeInput(List selection, Data data) + throws ActionAbortedException { + + // Since this action navigates to the new object once created, we must + // first navigate to control so that any outstanding changes in the + // current Control are handled. + try { + control.getNavigator().goToAsyncAndWait(false, control); + } catch (NavigationException e) { + throw new ActionAbortedException(e); + } + + if (data == null) { + data = new Data(); + } + + // Blocks until dismissed + data.dialog.setVisible(true); + + if (!ObjectUtil.equals(data.pane.getValue(), JOptionPane.OK_OPTION)) { + throw new ActionAbortedException(); + } + + return data; + } + + // + // DefaultStructuredAction methods + // + + @Override + public VirtualHost workBusy(List selection, Data data) + throws ActionAbortedException, ActionFailedException, + ActionUnauthorizedException { + + String domain = data.domainProperty.getValue(); + VirtualHost.validateDomainName(domain, null); + + ApachePanelDescriptor descriptor = control.getPanelDescriptor(); + + VirtualHost vHost = new VirtualHost(descriptor); + vHost.getDomainProperty().setFirstValue(domain); + + vHost.getDocRootProperty().setFirstValue( + data.docRootProperty.getValue()); + + descriptor.addChildren(vHost); + + // Navigate to the new virtual host + Navigable navigable = new SimpleNavigable( + VirtualHostControl.ID, null, + VirtualHostControl.PARAM_ID, vHost.getId()); + + control.getNavigator().goToAsync(false, control, navigable); + + return vHost; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/DeleteMimeTypeAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/DeleteMimeTypeAction.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,129 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.awt.Component; +import java.util.List; +import javax.swing.JOptionPane; +import com.oracle.solaris.vp.panel.common.action.*; +import com.oracle.solaris.vp.panel.common.control.Control; +import com.oracle.solaris.vp.panel.swing.action.DeleteManagedObjectAction; +import com.oracle.solaris.vp.panel.swing.control.SwingControl; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.swing.GUIUtil; + +@SuppressWarnings({"serial"}) +public class DeleteMimeTypeAction + extends DeleteManagedObjectAction> { + + // + // Static data + // + + private static final String TEXT = Finder.getString( + "mimetypes.action.delete.button"); + + // + // Instance data + // + + private SwingControl control; + + // + // Constructors + // + + public DeleteMimeTypeAction(SwingControl control) { + super(TEXT, null, control); + this.control = control; + } + + // + // StructuredAction methods + // + + @Override + public Object getRuntimeInput(List selection, Object input) + throws ActionAbortedException { + + int count = selection.size(); + if (count == 0) { + throw new ActionAbortedException(); + } + + String message = Finder.getString( + "mimetypes.action.delete.confirm." + count, + selection.get(0).getName(), count); + + int response = GUIUtil.showConfirmation( + getHasComponent().getComponent(), null, message, + JOptionPane.YES_NO_OPTION); + + if (response != JOptionPane.YES_OPTION) { + throw new ActionAbortedException(); + } + + return null; + } + + /** + * Enables this {@code Action} iff the selection is not empty. + */ + @Override + public void refresh() { + setEnabled(getPresetInput().size() != 0); + } + + // + // DefaultStructuredAction methods + // + + @Override + public List workBusy(List selection, Object input) + throws ActionAbortedException, ActionFailedException, + ActionUnauthorizedException { + + if (!selection.isEmpty()) { + MimeTypes mimeTypes = selection.get(0).getParent(); + + for (MimeType mimeType : selection) { + mimeTypes.scheduleRemove(mimeType); + } + + // If the running Control is a MimeTypeControl for a just-deleted + // MimeType, reset the Control and navigate back to its parent + Control child = control.getRunningChild(); + if (child instanceof MimeTypeControl) { + MimeType mimeType = ((MimeTypeControl)child).getMimeType(); + if (selection.contains(mimeType)) { + child.doCancel(); + } + } + } + + return selection; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/DeleteModuleAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/DeleteModuleAction.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,129 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.awt.Component; +import java.util.List; +import javax.swing.JOptionPane; +import com.oracle.solaris.vp.panel.common.action.*; +import com.oracle.solaris.vp.panel.common.control.Control; +import com.oracle.solaris.vp.panel.swing.action.DeleteManagedObjectAction; +import com.oracle.solaris.vp.panel.swing.control.SwingControl; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.swing.GUIUtil; + +@SuppressWarnings({"serial"}) +public class DeleteModuleAction + extends DeleteManagedObjectAction> { + + // + // Static data + // + + private static final String TEXT = Finder.getString( + "modules.action.delete.button"); + + // + // Instance data + // + + private SwingControl control; + + // + // Constructors + // + + public DeleteModuleAction(SwingControl control) { + super(TEXT, null, control); + this.control = control; + } + + // + // StructuredAction methods + // + + @Override + public Object getRuntimeInput(List selection, Object input) + throws ActionAbortedException { + + int count = selection.size(); + if (count == 0) { + throw new ActionAbortedException(); + } + + String message = Finder.getString( + "modules.action.delete.confirm." + count, + selection.get(0).getName(), count); + + int response = GUIUtil.showConfirmation( + getHasComponent().getComponent(), null, message, + JOptionPane.YES_NO_OPTION); + + if (response != JOptionPane.YES_OPTION) { + throw new ActionAbortedException(); + } + + return null; + } + + /** + * Enables this {@code Action} iff the selection is not empty. + */ + @Override + public void refresh() { + setEnabled(getPresetInput().size() != 0); + } + + // + // DefaultStructuredAction methods + // + + @Override + public List workBusy(List selection, Object input) + throws ActionAbortedException, ActionFailedException, + ActionUnauthorizedException { + + if (!selection.isEmpty()) { + Modules modules = selection.get(0).getParent(); + + for (Module module : selection) { + modules.scheduleRemove(module); + } + + // If the running Control is a ModuleControl for a just-deleted + // Module, reset the Control and navigate back to its parent + Control child = control.getRunningChild(); + if (child instanceof ModuleControl) { + Module module = ((ModuleControl)child).getModule(); + if (selection.contains(module)) { + child.doCancel(); + } + } + } + + return selection; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/DeleteVirtualHostAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/DeleteVirtualHostAction.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,146 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.awt.Component; +import java.util.List; +import javax.swing.JOptionPane; +import com.oracle.solaris.vp.panel.common.action.*; +import com.oracle.solaris.vp.panel.common.control.Control; +import com.oracle.solaris.vp.panel.common.model.ManagedObject; +import com.oracle.solaris.vp.panel.swing.action.DeleteManagedObjectAction; +import com.oracle.solaris.vp.panel.swing.control.SwingControl; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.swing.GUIUtil; + +@SuppressWarnings({"serial"}) +public class DeleteVirtualHostAction + extends DeleteManagedObjectAction { + + // + // Static data + // + + private static final String TEXT = Finder.getString( + "vhosts.action.delete.button"); + + // + // Instance data + // + + private SwingControl control; + + // + // Constructors + // + + public DeleteVirtualHostAction(SwingControl control) { + super(TEXT, null, control); + this.control = control; + } + + // + // StructuredAction methods + // + + @Override + public Object getRuntimeInput(List selection, Object input) + throws ActionAbortedException { + + int count = selection.size(); + if (count == 0) { + throw new ActionAbortedException(); + } + + String message = Finder.getString( + "vhosts.action.delete.confirm." + count, + selection.get(0).getName(), count); + + int response = GUIUtil.showConfirmation( + getHasComponent().getComponent(), null, message, + JOptionPane.YES_NO_OPTION); + + if (response != JOptionPane.YES_OPTION) { + throw new ActionAbortedException(); + } + + return null; + } + + /** + * Enables this {@code Action} iff the selection is not empty and is all + * {@link VirtualHost}s. + */ + @Override + public void refresh() { + boolean enabled = getPresetInput().size() != 0; + + if (enabled) { + List selection = getPresetInput(); + for (ManagedObject o : selection) { + if (!(o instanceof VirtualHost)) { + enabled = false; + break; + } + } + } + + setEnabled(enabled); + } + + // + // DefaultStructuredAction methods + // + + @Override + public VirtualHost[] workBusy(List selection, + Object input) throws ActionAbortedException, ActionFailedException, + ActionUnauthorizedException { + + // Selection has been verified as VirtualHosts + VirtualHost[] vHosts = selection.toArray( + new VirtualHost[selection.size()]); + + if (!selection.isEmpty()) { + ApachePanelDescriptor descriptor = vHosts[0].getPanelDescriptor(); + descriptor.scheduleRemove(vHosts); + + // If the running Control is a VirtualHostControl for a just-deleted + // VirtualHost, reset the Control and navigate back to its parent + Control child = control.getRunningChild(); + if (child instanceof VirtualHostControl) { + VirtualHost vHost = + ((VirtualHostControl)child).getVirtualHost(); + + if (selection.contains(vHost)) { + child.doCancel(); + } + } + } + + return vHosts; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/EnableVirtualHostAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/EnableVirtualHostAction.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,102 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.util.List; +import com.oracle.solaris.vp.panel.common.action.*; +import com.oracle.solaris.vp.panel.common.model.ManagedObject; +import com.oracle.solaris.vp.panel.swing.action.EnableManagedObjectAction; +import com.oracle.solaris.vp.panel.swing.control.SwingControl; + +@SuppressWarnings({"serial"}) +public class EnableVirtualHostAction + extends EnableManagedObjectAction { + + // + // Instance data + // + + private SwingControl control; + + // + // Constructors + // + + public EnableVirtualHostAction(SwingControl control, boolean enable) { + super(enable ? TEXT_ENABLE : TEXT_DISABLE, null, control, enable); + this.control = control; + } + + // + // StructuredAction methods + // + + /** + * Enables this {@code Action} iff the selection contains only {@link + * VirtualHost}s, and the enabled state of at least one would be changed by + * this action. + */ + @Override + public void refresh() { + boolean enabled = false; + List selection = getPresetInput(); + + for (ManagedObject o : selection) { + if (!(o instanceof VirtualHost)) { + enabled = false; + break; + } + + if (!enabled) { + VirtualHost vHost = (VirtualHost)o; + if (vHost.isEnabled() != getEnable()) { + enabled = true; + } + } + } + + setEnabled(enabled); + } + + // + // DefaultStructuredAction methods + // + + @Override + public Object workBusy(List selection, Object input) + throws ActionAbortedException, ActionFailedException, + ActionUnauthorizedException { + + boolean enable = getEnable(); + + for (ManagedObject object : selection) { + VirtualHost vHost = (VirtualHost)object; + vHost.getEnabledProperty().setFirstValue(enable); + } + + return null; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/GlobalControl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/GlobalControl.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,226 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.awt.event.*; +import java.beans.PropertyChangeListener; +import java.util.Map; +import com.oracle.solaris.vp.panel.common.control.*; +import com.oracle.solaris.vp.panel.common.smf.SmfEnabledProperty; +import com.oracle.solaris.vp.panel.swing.control.*; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.misc.property.MutableProperty; + +public class GlobalControl + extends SettingsControl + implements PropertyChangeListener, HasMimeTypes, HasModules { + + // + // Static data + // + + public static final String ID = "global"; + public static final String NAME = Finder.getString("global.name"); + + // + // Constructors + // + + public GlobalControl(ApachePanelDescriptor descriptor) { + super(ID, NAME, descriptor); + } + + // + // HasMimeTypes methods + // + + @Override + public MimeTypes getMimeTypes() { + return getPanelDescriptor().getMimeTypes(); + } + + // + // HasModules methods + // + + @Override + public Modules getModules() { + return getPanelDescriptor().getModules(); + } + + // + // Control methods + // + + @Override + public String getHelpMapID() { + return "apache-global"; + } + + @Override + protected UnsavedChangesAction getUnsavedChangesAction() { + // Automatically save changes to the ApachePanelDescriptor -- + // let MainControl prompt the user to save them to the repo + return UnsavedChangesAction.SAVE; + } + + @Override + protected boolean isChanged() { + // Save unconditionally, since a property that reports itself as + // unchanged in the panel may still be changed from the corresponding + // property in the ApachePanelDescriptor. Alternatively, we could + // compare each panel property to its ApachePanelDescriptor counterpart + // and save only if there are differences, but this is easier and save() + // has low overhead. + return true; + } + + @Override + protected void save() { + setPropertyChangeIgnore(true); + + try { + GlobalPanel panel = getComponent(); + ApachePanelDescriptor descriptor = getPanelDescriptor(); + + MutableProperty customEnabledProperty = + panel.getCustomEnabledProperty(); + + MutableProperty customFileProperty = + panel.getCustomFileProperty(); + + descriptor.getCustomEnabledProperty().setFirstValue( + customEnabledProperty.getValue()); + + descriptor.getCustomFileProperty().setFirstValue( + customFileProperty.getValue()); + + descriptor.getEnabledProperty().setValue( + panel.getEnabledProperty().getValue()); + } finally { + setPropertyChangeIgnore(false); + } + } + + @Override + public void start(Navigator navigator, Map parameters) + throws NavigationAbortedException, InvalidParameterException, + NavigationFailedException { + + setPropertyChangeSource(getPanelDescriptor(), SmfEnabledProperty.NAME, + ApachePanelDescriptor.PROPERTY_CUSTOM_ENABLED, + ApachePanelDescriptor.PROPERTY_CUSTOM_FILE); + + super.start(navigator, parameters); + } + + // + // DefaultControl methods + // + + @Override + protected void ensureChildrenCreated() { + if (children.size() == 0) { + ApachePanelDescriptor descriptor = getPanelDescriptor(); + + DefaultControl control = new DialogControl( + descriptor); + control.addChildren( + new MimeTypesControl(descriptor, this), + new ModulesControl(descriptor, this)); + + addChildren(control); + } + } + + // + // SwingControl methods + // + + @Override + protected GlobalPanel createComponent() { + GlobalPanel panel = new GlobalPanel(); + + panel.getMimeTypesButton().addActionListener( + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Navigable[] navigables = { + new SimpleNavigable(DialogControl.ID, null), + new SimpleNavigable(MimeTypesControl.ID, null), + }; + + getNavigator().goToAsync(false, GlobalControl.this, + navigables); + } + }); + + panel.getModulesButton().addActionListener( + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Navigable[] navigables = { + new SimpleNavigable(DialogControl.ID, null), + new SimpleNavigable(ModulesControl.ID, null), + }; + + getNavigator().goToAsync(false, GlobalControl.this, + navigables); + } + }); + + return panel; + } + + @Override + protected void deinitComponent() { + ApachePanelDescriptor descriptor = getPanelDescriptor(); + GlobalPanel panel = getComponent(); + + descriptor.getMimeTypes().getChangeableAggregator(). + removeChangeListener(panel.getMimeTypesButton()); + + descriptor.getModules().getChangeableAggregator(). + removeChangeListener(panel.getModulesButton()); + + panel.init(null); + } + + @Override + protected void initComponent() { + ApachePanelDescriptor descriptor = getPanelDescriptor(); + GlobalPanel panel = getComponent(); + + descriptor.getMimeTypes().getChangeableAggregator().addChangeListener( + panel.getMimeTypesButton()); + + descriptor.getModules().getChangeableAggregator().addChangeListener( + panel.getModulesButton()); + + panel.getChangeableAggregator().reset(); + panel.init(descriptor); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/GlobalPanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/GlobalPanel.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,199 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.awt.*; +import javax.swing.*; +import javax.swing.filechooser.FileSystemView; +import com.oracle.solaris.vp.panel.swing.view.ChangeIndicator; +import com.oracle.solaris.vp.util.misc.ChangeableAggregator; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.misc.property.*; +import com.oracle.solaris.vp.util.swing.*; +import com.oracle.solaris.vp.util.swing.layout.*; +import com.oracle.solaris.vp.util.swing.property.*; + +@SuppressWarnings({"serial"}) +public class GlobalPanel extends SettingsPanel { + // + // Instance data + // + + private MutableProperty enabledProperty = new BooleanProperty(); + private MutableProperty customEnabledProperty = + new BooleanProperty(); + private MutableProperty customFileProperty = new StringProperty(); + private JFileChooser fileChooser; + + { + ChangeableAggregator aggregator = getChangeableAggregator(); + aggregator.addChangeables(enabledProperty, customEnabledProperty, + customFileProperty); + } + + private ChangeButton mimeTypesButton; + private ChangeButton modulesButton; + + // + // Constructors + // + + public GlobalPanel() { + JPanel form = createForm(); + setContent(form, false, false); + } + + // + // GlobalPanel methods + // + + public MutableProperty getEnabledProperty() { + return enabledProperty; + } + + public MutableProperty getCustomEnabledProperty() { + return customEnabledProperty; + } + + public MutableProperty getCustomFileProperty() { + return customFileProperty; + } + + public ChangeButton getMimeTypesButton() { + return mimeTypesButton; + } + + public ChangeButton getModulesButton() { + return modulesButton; + } + + public void init(ApachePanelDescriptor descriptor) { + // Sanity check -- the UI should be updated only on the event thread + assert EventQueue.isDispatchThread(); + + FileSystemView fsView; + + if (descriptor == null) { + fsView = FileSystemView.getFileSystemView(); + } else { + ApacheUtil.update(descriptor.getEnabledProperty(), enabledProperty); + + ApacheUtil.update(descriptor.getCustomEnabledProperty(), + customEnabledProperty); + + ApacheUtil.update(descriptor.getCustomFileProperty(), + customFileProperty); + + fsView = descriptor.getFileSystemView(); + } + + fileChooser.setFileSystemView(fsView); + } + + // + // Private methods + // + + private JPanel createForm() { + JCheckBox enableCheckBox = new JCheckBox( + Finder.getString("global.edit.enable")); + new CheckBoxPropertySynchronizer(enabledProperty, enableCheckBox); + ChangeIndicator enableChange = new ChangeIndicator(); + enabledProperty.addChangeListener(enableChange); + + JCheckBox customEnabledFileCheckBox = new JCheckBox( + Finder.getString("global.edit.customfile")); + + new CheckBoxPropertySynchronizer(customEnabledProperty, + customEnabledFileCheckBox); + ChangeIndicator customEnabledChange = new ChangeIndicator(); + customEnabledProperty.addChangeListener(customEnabledChange); + + InfoLabel customEnabledHelp = new InfoLabel( + Finder.getString("global.edit.customfile.help")); + + BrowsableFilePanel customFilePanel = new BrowsableFilePanel(); + customFilePanel.setOpaque(false); + fileChooser = customFilePanel.getFileChooser(); + + new TextComponentPropertySynchronizer( + customFileProperty, customFilePanel.getField()); + ChangeIndicator customFileChange = new ChangeIndicator(); + customFileProperty.addChangeListener(customFileChange); + + GUIUtil.setEnableStateOnSelect( + customEnabledFileCheckBox, true, true, customFilePanel); + + mimeTypesButton = new ChangeButton(Finder.getString( + "global.edit.mimetypes")); + modulesButton = new ChangeButton(Finder.getString( + "global.edit.modules")); + + int bGap = GUIUtil.getButtonGap(); + + JPanel buttonPanel = new JPanel(new GridLayout(1, 2, bGap, 0)); + buttonPanel.setOpaque(false); + buttonPanel.add(mimeTypesButton); + buttonPanel.add(modulesButton); + + JPanel formPanel = new JPanel(); + formPanel.setOpaque(false); + Form form = new Form(formPanel, VerticalAnchor.FILL); + + int hGap = GUIUtil.getHalfGap(); + int sGap = 3 * hGap; + int indent = GUIUtil.getTextXOffset(customEnabledFileCheckBox); + + ColumnLayoutConstraint c = new ColumnLayoutConstraint( + HorizontalAnchor.FILL, hGap); + + RowLayoutConstraint r = new RowLayoutConstraint( + VerticalAnchor.CENTER, hGap); + r.setLayoutIfInvisible(true); + + form.addRow(HorizontalAnchor.LEFT, c); + form.add(enableCheckBox, r); + form.add(enableChange, r); + + form.addRow(HorizontalAnchor.LEFT, c.clone().setGap(sGap)); + form.add(customEnabledFileCheckBox, r); + form.add(customEnabledHelp, r); + form.add(customEnabledChange, r); + + form.addRow(HorizontalAnchor.LEFT, c); + form.add(customFilePanel, r.clone().setGap(indent). + setIgnoreFirstGap(false)); + form.add(customFileChange, r); + + form.addRow(HorizontalAnchor.FILL, c.setGap(sGap).setWeight(1). + setVerticalAnchor(VerticalAnchor.BOTTOM)); + + form.add(buttonPanel, r.clone().setWeight(1).setHorizontalAnchor( + HorizontalAnchor.RIGHT)); + + return formPanel; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/GlobalValidationException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/GlobalValidationException.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import com.oracle.solaris.vp.panel.common.action.ActionFailedException; + +@SuppressWarnings({"serial"}) +public class GlobalValidationException extends ActionFailedException { + // + // Constructors + // + + public GlobalValidationException() { + } + + public GlobalValidationException(String message) { + super(message); + } + + public GlobalValidationException(Throwable cause) { + super(cause); + } + + public GlobalValidationException(String message, + Throwable cause) { + super(message, cause); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/HasMimeTypes.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/HasMimeTypes.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,30 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +public interface HasMimeTypes { + MimeTypes getMimeTypes(); +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/HasModules.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/HasModules.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,30 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +public interface HasModules { + Modules getModules(); +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/MainControl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/MainControl.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,264 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.awt.Component; +import java.util.List; +import javax.swing.*; +import com.oracle.solaris.scf.common.ScfException; +import com.oracle.solaris.vp.panel.common.action.*; +import com.oracle.solaris.vp.panel.common.control.*; +import com.oracle.solaris.vp.panel.common.model.ManagedObject; +import com.oracle.solaris.vp.panel.common.smf.SmfUtil; +import com.oracle.solaris.vp.panel.swing.control.*; +import com.oracle.solaris.vp.panel.swing.view.ListSelectorPanel; +import com.oracle.solaris.vp.util.misc.ChangeableAggregator; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.swing.SimpleCellRenderer; + +public class MainControl extends ListSelectorControl { + + // + // Static data + // + + public static final String ID = "main"; + + // + // Instance data + // + + private ListModel model; + + // + // Constructors + // + + public MainControl(ApachePanelDescriptor descriptor) { + super(ID, null, descriptor); + } + + // + // Control methods + // + + @Override + public void descendantStarted(Control[] path) { + super.descendantStarted(path); + + // Allow our ChangeableAggregator, which indirectly controls the enabled + // state of the Apply/Okay/Reset buttons, to track outstanding changes + // in running descendants. + Control control = path[path.length - 1]; + if (control instanceof SwingControl) { + ChangeableAggregator aggregator = + ((SwingControl)control).getChangeableAggregator(); + + if (aggregator != null) { + getComponent().getChangeableAggregator().addChangeables( + aggregator); + } + } + } + + @Override + public void descendantStopped(Control[] path) { + super.descendantStopped(path); + + // Stop monitoring stopped descendant for changes + Control control = path[path.length - 1]; + if (control instanceof SwingControl) { + ChangeableAggregator aggregator = + ((SwingControl)control).getChangeableAggregator(); + + if (aggregator != null) { + getComponent().getChangeableAggregator().removeChangeable( + aggregator); + } + } + } + + @Override + public Navigable[] getForwardingPath(boolean childStopped) { + return new Navigable[] { + new SimpleNavigable(GlobalControl.ID, null) + }; + } + + @Override + public String getHelpMapID() { + return "apache-overview"; + } + + @Override + protected void save() throws ActionAbortedException, ActionFailedException, + ActionUnauthorizedException { + + try { + ApachePanelDescriptor descriptor = getPanelDescriptor(); + descriptor.validate(); + descriptor.saveToRepo(); + + } catch (GlobalValidationException e) { + // Schedule navigation to global settings + getNavigator().goToAsync(false, this, + new SimpleNavigable(GlobalControl.ID, null)); + throw e; + + } catch (VirtualHostGeneralValidationException e) { + // Schedule navigation to erred virtual host + getNavigator().goToAsync(false, this, + new SimpleNavigable(VirtualHostControl.ID, null, + VirtualHostControl.PARAM_ID, e.getId()), + new SimpleNavigable(VirtualHostGeneralControl.ID, null)); + throw e; + + } catch (VirtualHostSSLValidationException e) { + // Schedule navigation to erred virtual host + getNavigator().goToAsync(false, this, + new SimpleNavigable(VirtualHostControl.ID, null, + VirtualHostControl.PARAM_ID, e.getId()), + new SimpleNavigable(VirtualHostSSLControl.ID, null)); + throw e; + + } catch (ScfException e) { + SmfUtil.throwActionException(e); + throw new ActionFailedException(e); + + } catch (SecurityException e) { + throw new ActionUnauthorizedException(e); + } + + super.save(); + } + + // + // DefaultControl methods + // + + @Override + protected void ensureChildrenCreated() { + if (children.size() == 0) { + ApachePanelDescriptor descriptor = getPanelDescriptor(); + SwingControl[] controls = { + new GlobalControl(descriptor), + new VirtualHostControl(descriptor), + }; + + addChildren(controls); + + // Add the Components of these children to the UI now, so that the + // UI will be sized to fit the largest Component + addToLayout(controls); + } + } + + // + // SwingControl methods + // + + @Override + protected void configComponent(ListSelectorPanel panel) { + super.configComponent(panel); + addDefaultApplyAction(); + addDefaultCancelAction(true); + addDefaultOkayAction(true); + addDefaultHelpAction(); + } + + @Override + protected ListSelectorPanel createComponent() { + ListSelectorPanel panel = new ListSelectorPanel(); + panel.setSelectionTitle(Finder.getString("vhosts.list.title")); + + JList list = panel.getSelectionComponent(); + SimpleCellRenderer renderer = new MainListCellRenderer(); + renderer.configureFor(list); + list.setCellRenderer(renderer); + + panel.getChangeableAggregator().addChangeables( + getPanelDescriptor().getChangeableAggregator()); + + addAction(panel, new CreateVirtualHostAction(this), true, true); + addAction(panel, new DeleteVirtualHostAction(this), true, true); + addAction(panel, new EnableVirtualHostAction(this, true), false, true); + addAction(panel, new EnableVirtualHostAction(this, false), false, true); + addAction(panel, new CloneVirtualHostAction(this), false, true); + + return panel; + } + + // + // ListSelectorControl methods + // + + @Override + protected int getListIndexOf(Control child) { + if (child instanceof GlobalControl) { + return 0; + } + + VirtualHost vHost = ((VirtualHostControl)child).getVirtualHost(); + int index = getPanelDescriptor().indexOf(vHost) + 1; + + assert vHost == getComponent().getSelectionComponent().getModel(). + getElementAt(index); + + return index; + } + + @Override + protected ListModel getListModel() { + if (model == null) { + model = new MainListModel(getPanelDescriptor()); + } + + return model; + } + + @Override + protected Navigable[] getPathForSelection(List selection) { + if (selection.size() != 1) { + return null; + } + + ManagedObject selected = selection.get(0); + Navigable navigable; + + if (selected instanceof ApachePanelDescriptor) { + navigable = new SimpleNavigable(GlobalControl.ID, + MainListCellRenderer.TEXT_GLOBAL); + } else { + VirtualHost vHost = (VirtualHost)selected; + + navigable = new SimpleNavigable(VirtualHostControl.ID, + vHost.getName(), VirtualHostControl.PARAM_ID, vHost.getId()); + } + + return new Navigable[] {navigable}; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/MainListCellRenderer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/MainListCellRenderer.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,77 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.awt.Component; +import javax.swing.Icon; +import com.oracle.solaris.vp.panel.common.model.ManagedObject; +import com.oracle.solaris.vp.panel.swing.view.ManagedObjectCellRenderer; +import com.oracle.solaris.vp.util.misc.finder.Finder; + +@SuppressWarnings({"serial"}) +public class MainListCellRenderer + extends ManagedObjectCellRenderer { + + // + // Static data + // + + static final String TEXT_GLOBAL = Finder.getString("global.name"); + + private static final Icon ICON_GLOBAL = + Finder.getIcon("images/global-24.png"); + + // + // SimpleCellRenderer methods + // + + @Override + public Icon getIcon(Component comp, ManagedObject obj, boolean isSelected, + boolean hasFocus) { + + if (obj instanceof ApachePanelDescriptor) { + return ICON_GLOBAL; + } + + return super.getIcon(comp, obj, isSelected, hasFocus); + } + + @Override + public String getStatusText(Component comp, ManagedObject obj, + boolean isSelected, boolean hasFocus) { + + return obj instanceof ApachePanelDescriptor ? null : + super.getStatusText(comp, obj, isSelected, hasFocus); + } + + @Override + public String getText(Component comp, ManagedObject obj, boolean isSelected, + boolean hasFocus) { + + return obj instanceof ApachePanelDescriptor ? TEXT_GLOBAL : + super.getText(comp, obj, isSelected, hasFocus); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/MainListModel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/MainListModel.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,140 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.util.*; +import javax.swing.ListModel; +import javax.swing.event.*; +import com.oracle.solaris.vp.panel.swing.view.ManagedObjectTableModel; + +@SuppressWarnings({"serial"}) +public class MainListModel implements ListModel { + // + // Inner classes + // + + public class ListDataListenerWrapper implements ListDataListener { + // + // Instance data + // + + private ListDataListener listener; + + // + // Constructors + // + + public ListDataListenerWrapper(ListDataListener listener) { + this.listener = listener; + } + + // + // ListDataListener methods + // + + @Override + public void contentsChanged(ListDataEvent e) { + listener.contentsChanged(convert(e)); + } + + @Override + public void intervalAdded(ListDataEvent e) { + listener.intervalAdded(convert(e)); + } + + @Override + public void intervalRemoved(ListDataEvent e) { + listener.intervalRemoved(convert(e)); + } + + // + // ListDataListenerWrapper methods + // + + public ListDataListener getWrappedListener() { + return listener; + } + + // + // Private methods + // + + private ListDataEvent convert(ListDataEvent e) { + return new ListDataEvent(e.getSource(), e.getType(), + e.getIndex0() + 1, e.getIndex1() + 1); + } + } + + // + // Instance data + // + + private ManagedObjectTableModel model; + + private Map listenerMap = + new HashMap(); + + // + // Constructors + // + + public MainListModel(ApachePanelDescriptor descriptor) { + model = new ManagedObjectTableModel(descriptor); + } + + // + // ListModel methods + // + + @Override + public void addListDataListener(ListDataListener l) { + ListDataListenerWrapper wrapper = new ListDataListenerWrapper(l); + listenerMap.put(l, wrapper); + model.addListDataListener(wrapper); + } + + @Override + public Object getElementAt(int index) { + if (index == 0) { + return model.getParentObject(); + } + return model.getElementAt(index - 1); + } + + @Override + public int getSize() { + return model.getSize() + 1; + } + + @Override + public void removeListDataListener(ListDataListener l) { + ListDataListenerWrapper wrapper = listenerMap.get(l); + if (wrapper != null) { + model.removeListDataListener(wrapper); + listenerMap.remove(l); + } + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/MimeType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/MimeType.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,253 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import javax.swing.Icon; +import com.oracle.solaris.scf.common.ScfException; +import com.oracle.solaris.vp.panel.common.model.*; +import com.oracle.solaris.vp.panel.common.smf.*; +import com.oracle.solaris.vp.panel.common.view.PanelIconUtil; +import com.oracle.solaris.vp.util.misc.property.*; +import com.oracle.solaris.vp.util.swing.HasIcon; + +@SuppressWarnings({"serial"}) +public class MimeType extends AbstractManagedObject + implements HasIcon, Cloneable, SmfPropertyInfo { + + // + // Static data + // + + public static final String PROPERTY_TYPE = "type"; + public static final String PROPERTY_SUBTYPE = "subtype"; + public static final String PROPERTY_EXTENSIONS = "extensions"; + + public static final String SMF_PROPERTY_PREFIX = "mime-"; + public static final String SEPARATOR = "/"; + + // See RFC 1341 + private static final String TSPECIALS = "()<>@,;:\\\"/[]?="; + + // + // Instance data + // + + private MimeTypes parent; + private String propertyName; + + private MutableProperty typeProperty = + new BasicMutableProperty(PROPERTY_TYPE); + + private MutableProperty subtypeProperty = + new BasicMutableProperty(PROPERTY_SUBTYPE); + + private MutableProperty extensionsProperty = + new StringArrayProperty(PROPERTY_EXTENSIONS); + + // This is the property that does the actual work of persisting this + // MimeType's data to the SMF repository + private BasicSmfMutableProperty smfProperty = + new StringSmfProperty(null, this); + + // + // Constructors + // + + public MimeType(MimeTypes parent) { + this.parent = parent; + + typeProperty.setValue(""); + addProperties(typeProperty); + + subtypeProperty.setValue(""); + addProperties(subtypeProperty); + + extensionsProperty.setValue(new String[0]); + addProperties(extensionsProperty); + + // Synchronize the properties holding this MimeType's data with the + // property responsible for persisting it to the SMF repository + new MimeTypePropertySynchronizer(smfProperty, this, false); + } + + public MimeType(MimeTypes parent, String propertyName) throws ScfException { + this(parent); + this.propertyName = propertyName; + refresh(true); + } + + // + // HasService methods + // + + @Override + public AggregatedRefreshService getService() { + return parent.getApacheInfo().getService(); + } + + // + // SmfPropertyGroupInfo methods + // + + @Override + public String getPropertyGroupName() throws ScfException { + return parent.getApacheInfo().getPropertyGroupName(); + } + + // + // SmfPropertyInfo methods + // + + @Override + public String getPropertyName() throws ScfException { + if (propertyName == null) { + propertyName = ApacheUtil.getNextAvailablePropertyName( + parent.getApacheInfo(), SMF_PROPERTY_PREFIX); + } + return propertyName; + } + + // + // Object methods + // + + @Override + public MimeType clone() { + MimeType clone = new MimeType(getParent()); + for (MutableProperty property : getProperties()) { + String name = property.getPropertyName(); + + @SuppressWarnings({"unchecked"}) + MutableProperty oldProperty = + (MutableProperty)property; + + @SuppressWarnings({"unchecked"}) + MutableProperty newProperty = + (MutableProperty)clone.getProperty(name); + + newProperty.setValue(oldProperty.getValue()); + } + + return clone; + } + + // + // ManagedObject methods + // + + @Override + public String getId() { + return toId(typeProperty.getValue(), subtypeProperty.getValue()); + } + + @Override + public String getName() { + return getId(); + } + + // + // HasIcon methods + // + + @Override + public Icon getIcon(int height) { + return PanelIconUtil.getClosestMimeIcon(typeProperty.getValue(), + subtypeProperty.getValue(), height); + } + + // + // MimeType methods + // + + public MutableProperty getExtensionsProperty() { + return extensionsProperty; + } + + public MimeTypes getParent() { + return parent; + } + + public MutableProperty getSubtypeProperty() { + return subtypeProperty; + } + + public MutableProperty getTypeProperty() { + return typeProperty; + } + + public boolean isInRepo() { + return propertyName != null; + } + + public void refresh(boolean force) throws ScfException { + smfProperty.updateFromRepo(force); + } + + protected void removeFromRepo() throws ScfException { + if (isInRepo()) { + smfProperty.removeFromRepo(); + } + } + + public void saveToRepo() throws ScfException { + ApacheUtil.saveToRepo(getService(), + new ScfRunnable() { + @Override + public void run() throws ScfException { + if (smfProperty.isChanged()) { + smfProperty.saveToRepo(); + } + } + }); + } + + // + // Static methods + // + + public static boolean isTokenChar(char c) { + return c > 0x20 && c < 0x7F && TSPECIALS.indexOf(c) == -1; + } + + public static boolean isValidToken(String token) { + int length = token.length(); + if (length == 0) { + return false; + } + + for (int i = 0; i < length; i++) { + if (!isTokenChar(token.charAt(i))) { + return false; + } + } + + return true; + } + + public static String toId(String type, String subtype) { + return type + SEPARATOR + subtype; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/MimeTypeControl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/MimeTypeControl.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,205 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.util.Map; +import com.oracle.solaris.vp.panel.common.action.*; +import com.oracle.solaris.vp.panel.common.control.*; +import com.oracle.solaris.vp.panel.swing.control.SettingsControl; +import com.oracle.solaris.vp.util.misc.finder.Finder; + +public class MimeTypeControl + extends SettingsControl { + + // + // Static data + // + + public static final String ID = "mimetype"; + public static final String PARAM_MIMETYPE = "mimetype"; + + // + // Instance data + // + + private MimeTypesControl parent; + private MimeType mimeType; + + // + // Constructors + // + + public MimeTypeControl(ApachePanelDescriptor descriptor, + MimeTypesControl parent) { + + super(ID, null, descriptor); + + this.parent = parent; + } + + // + // Control methods + // + + @Override + protected UnsavedChangesAction getUnsavedChangesAction() { + // Automatically save changes to the MimeType -- let MainControl + // prompt the user to save them to the repo + return UnsavedChangesAction.SAVE; + } + + @Override + public boolean isBrowsable() { + // This Control requires init parameters + return false; + } + + @Override + protected boolean isChanged() { + // Save unconditionally, since a property that reports itself as + // unchanged in the panel may still be changed from the corresponding + // property in the MimeType. Alternatively, we could compare each panel + // property to its MimeType counterpart and save only if there are + // differences, but this is easier and save() has low overhead. + return true; + } + + @Override + protected void save() throws ActionAbortedException, ActionFailedException, + ActionUnauthorizedException { + + setPropertyChangeIgnore(true); + + try { + MimeTypePanel panel = getComponent(); + + String type = panel.getTypeProperty().getValue(); + String subtype = panel.getSubtypeProperty().getValue(); + + validate(type, subtype); + + MimeType child = mimeType.getParent().getMimeType(type, subtype); + if (child != null && child != mimeType) { + throw new ActionFailedException(Finder.getString( + "mimetype.error.duplicate", type, subtype)); + } + + mimeType.getTypeProperty().setValue(type); + mimeType.getSubtypeProperty().setValue(subtype); + mimeType.getExtensionsProperty().setValue( + panel.getExtensionsProperty().getValue()); + } finally { + setPropertyChangeIgnore(false); + } + } + + @Override + public void start(Navigator navigator, Map parameters) + throws NavigationAbortedException, InvalidParameterException, + NavigationFailedException { + + String param = getParameter(parameters, PARAM_MIMETYPE); + + MimeType mimeType = parent.getHasMimeTypes().getMimeTypes(). + getMimeType(param); + if (mimeType == null) { + throw new InvalidParameterException(getId(), PARAM_MIMETYPE, param); + } + + this.mimeType = mimeType; + setName(mimeType.getName()); + + setPropertyChangeSource(mimeType); + super.start(navigator, parameters); + } + + @Override + public void stop(boolean isCancel) throws NavigationAbortedException { + super.stop(isCancel); + + // Remove reference so it can be garbage collected if deleted + mimeType = null; + } + + // + // SwingControl methods + // + + @Override + protected MimeTypePanel createComponent() { + return new MimeTypePanel(); + } + + @Override + protected void initComponent() { + MimeTypePanel panel = getComponent(); + panel.getChangeableAggregator().reset(); + panel.init(mimeType); + } + + // + // MimeTypeControl methods + // + + public MimeType getMimeType() { + return mimeType; + } + + // + // Static methods + // + + /** + * Validates the entered data in the UI. + * + * @exception ActionFailedException + * if the entered data is invalid (the thrown exception will + * contain a localized error message) + */ + public static void validate(String type, String subtype) + throws ActionFailedException { + + if (type.isEmpty()) { + throw new ActionFailedException(Finder.getString( + "mimetype.error.type.empty", type)); + } + + if (!MimeType.isValidToken(type)) { + throw new ActionFailedException(Finder.getString( + "mimetype.error.type.invalid", type)); + } + + if (subtype.isEmpty()) { + throw new ActionFailedException(Finder.getString( + "mimetype.error.subtype.empty", subtype)); + } + + if (!MimeType.isValidToken(subtype)) { + throw new ActionFailedException(Finder.getString( + "mimetype.error.subtype.invalid", subtype)); + } + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/MimeTypePanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/MimeTypePanel.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,153 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.awt.EventQueue; +import javax.swing.*; +import com.oracle.solaris.vp.panel.swing.view.ChangeIndicator; +import com.oracle.solaris.vp.util.misc.ChangeableAggregator; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.misc.property.*; +import com.oracle.solaris.vp.util.swing.*; +import com.oracle.solaris.vp.util.swing.layout.*; +import com.oracle.solaris.vp.util.swing.property. + TextComponentPropertySynchronizer; + +@SuppressWarnings({"serial"}) +public class MimeTypePanel extends SettingsPanel { + // + // Instance data + // + + private MutableProperty typeProperty = new StringProperty(); + private MutableProperty subtypeProperty = new StringProperty(); + private MutableProperty extensionsProperty = + new StringArrayProperty(); + + { + ChangeableAggregator aggregator = getChangeableAggregator(); + aggregator.addChangeables(typeProperty, subtypeProperty, + extensionsProperty); + } + + // + // Constructors + // + + public MimeTypePanel() { + JPanel form = createForm(); + setContent(form, false, false); + } + + // + // MimeTypePanel methods + // + + public MutableProperty getExtensionsProperty() { + return extensionsProperty; + } + + public MutableProperty getSubtypeProperty() { + return subtypeProperty; + } + + public MutableProperty getTypeProperty() { + return typeProperty; + } + + public void init(MimeType mimeType) { + // Sanity check -- the UI should be updated only on the event thread + assert EventQueue.isDispatchThread(); + + if (mimeType != null) { + ApacheUtil.update(mimeType.getTypeProperty(), typeProperty); + ApacheUtil.update(mimeType.getSubtypeProperty(), subtypeProperty); + ApacheUtil.update(mimeType.getExtensionsProperty(), + extensionsProperty); + } + } + + // + // Private methods + // + + private JPanel createForm() { + int gap = GUIUtil.getHalfGap(); + + JLabel typeLabel = new JLabel( + Finder.getString("mimetype.edit.type")); + + JTextField typeField = GUIUtil.createTextField(); + new TextComponentPropertySynchronizer( + typeProperty, typeField); + ChangeIndicator typeChange = new ChangeIndicator(); + typeProperty.addChangeListener(typeChange); + + JLabel subtypeLabel = new JLabel( + Finder.getString("mimetype.edit.subtype")); + + JTextField subtypeField = GUIUtil.createTextField(); + new TextComponentPropertySynchronizer( + subtypeProperty, subtypeField); + ChangeIndicator subtypeChange = new ChangeIndicator(); + subtypeProperty.addChangeListener(subtypeChange); + + JLabel extensionsLabel = new JLabel( + Finder.getString("mimetype.edit.extensions")); + + JTextField extensionsField = GUIUtil.createTextField(); + new TextComponentPropertySynchronizer( + extensionsProperty, extensionsField); + ChangeIndicator extensionsChange = new ChangeIndicator(); + extensionsProperty.addChangeListener(extensionsChange); + + JPanel formPanel = new JPanel(); + formPanel.setOpaque(false); + Form form = new Form(formPanel, VerticalAnchor.TOP); + + ColumnLayoutConstraint c = new ColumnLayoutConstraint( + HorizontalAnchor.FILL, gap); + + HasAnchors a = new SimpleHasAnchors( + HorizontalAnchor.LEFT, VerticalAnchor.CENTER); + + form.addTable(3, gap, gap, HorizontalAnchor.LEFT, c); + + form.add(typeLabel, a); + form.add(typeField, a); + form.add(typeChange, a); + + form.add(subtypeLabel, a); + form.add(subtypeField, a); + form.add(subtypeChange, a); + + form.add(extensionsLabel, a); + form.add(extensionsField, a); + form.add(extensionsChange, a); + + return formPanel; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/MimeTypePropertySynchronizer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/MimeTypePropertySynchronizer.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,235 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.util.*; +import javax.swing.event.*; +import com.oracle.solaris.vp.util.misc.ObjectUtil; +import com.oracle.solaris.vp.util.misc.converter.DualConverter; +import com.oracle.solaris.vp.util.misc.property.*; + +/** + * The {@code MimeTypePropertySynchronizer} class synchronizes a {@link + * MutableProperty}{@code >} with a {@code MimeType}'s {@link + * MutableProperty}s so that changes in one will automatically be reflected in + * the other. + */ +public class MimeTypePropertySynchronizer + extends PropertySynchronizer, MimeType> { + + // + // Static data + // + + public static final String SMF_VALUE_PREFIX = "MIME:"; + + // + // Instance data + // + + private ChangeListener listener = + new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + objectChanged(); + } + }; + + // + // Constructors + // + + public MimeTypePropertySynchronizer(MutableProperty> property, + MimeType mimeType, boolean initFromProp) { + + super(property, mimeType, initFromProp); + + mimeType.getTypeProperty().addChangeListener(listener); + mimeType.getSubtypeProperty().addChangeListener(listener); + mimeType.getExtensionsProperty().addChangeListener(listener); + } + + /** + * Constructs a {@code MimeTypePropertySynchronizer} with initial + * synchronization from {@code property} to {@code mimeType}. + */ + public MimeTypePropertySynchronizer(MutableProperty> property, + MimeType mimeType) { + + this(property, mimeType, true); + } + + // + // PropertySynchronizer methods + // + + @Override + protected boolean differ() { + return super.differ() || !ObjectUtil.equals(getSavedValue(), + getProperty().getSavedValue()); + } + + @Override + public void desynchronize() { + super.desynchronize(); + + MimeType mimeType = getObject(); + mimeType.getTypeProperty().removeChangeListener(listener); + mimeType.getSubtypeProperty().removeChangeListener(listener); + mimeType.getExtensionsProperty().removeChangeListener(listener); + } + + @Override + public List getValue() { + return getValue(false); + } + + @Override + protected void syncObjectChanges() { + super.syncObjectChanges(); + List value = getSavedValue(); + getProperty().setSavedValue(value); + } + + @Override + protected void syncPropertyChanges() { + super.syncPropertyChanges(); + List value = getProperty().getSavedValue(); + setSavedValue(value); + } + + @Override + public void setValue(List value) { + setValue(value, false); + } + + // + // MimeTypePropertySynchronizer methods + // + + public List getSavedValue() { + return getValue(true); + } + + public void setSavedValue(List value) { + setValue(value, true); + } + + // + // Private methods + // + + private List getValue(boolean saved) { + List value = new ArrayList(2); + + MimeType mimeType = getObject(); + + MutableProperty typeProperty = mimeType.getTypeProperty(); + String type = saved ? typeProperty.getSavedValue() : + typeProperty.getValue(); + + MutableProperty subtypeProperty = mimeType.getSubtypeProperty(); + String subtype = saved ? subtypeProperty.getSavedValue() : + subtypeProperty.getValue(); + + MutableProperty extensionsProperty = + mimeType.getExtensionsProperty(); + String[] extensions = saved ? extensionsProperty.getSavedValue() : + extensionsProperty.getValue(); + + String id = SMF_VALUE_PREFIX + type + MimeType.SEPARATOR + subtype; + value.add(id); + + if (extensions != null && extensions.length > 0) { + DualConverter converter = + extensionsProperty.getConverter(); + + String sValue = converter.revert(extensions); + value.add(sValue); + } + + return value; + } + + private void setValue(List value, boolean saved) { + MimeType mimeType = getObject(); + MutableProperty extensionsProperty = + mimeType.getExtensionsProperty(); + + String type = null; + String subtype = null; + String[] extensions = null; + + if (value != null) { + for (String sValue : value) { + if (sValue.startsWith(SMF_VALUE_PREFIX)) { + sValue = sValue.substring(SMF_VALUE_PREFIX.length()); + + int index = sValue.indexOf(MimeType.SEPARATOR); + if (index == -1) { + type = sValue; + subtype = null; + } else { + type = sValue.substring(0, index); + subtype = sValue.substring( + index + MimeType.SEPARATOR.length()); + } + + if (type.isEmpty()) { + type = null; + } + + if (subtype.isEmpty()) { + subtype = null; + } + } else { + extensions = extensionsProperty.getConverter().convert( + sValue); + } + } + } + + MutableProperty typeProperty = mimeType.getTypeProperty(); + if (saved) { + typeProperty.setSavedValue(type); + } else { + typeProperty.setValue(type); + } + + MutableProperty subtypeProperty = mimeType.getSubtypeProperty(); + if (saved) { + subtypeProperty.setSavedValue(subtype); + } else { + subtypeProperty.setValue(subtype); + } + + if (saved) { + extensionsProperty.setSavedValue(extensions); + } else { + extensionsProperty.setValue(extensions); + } + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/MimeTypes.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/MimeTypes.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,258 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.util.*; +import javax.swing.Icon; +import com.oracle.solaris.scf.common.ScfException; +import com.oracle.solaris.vp.panel.common.model.*; +import com.oracle.solaris.vp.panel.common.smf.*; +import com.oracle.solaris.vp.panel.common.view.PanelIconUtil; +import com.oracle.solaris.vp.util.misc.*; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.misc.property.*; +import com.oracle.solaris.vp.util.swing.HasIcon; + +@SuppressWarnings({"serial"}) +public class MimeTypes extends AbstractManagedObject + implements HasIcon { + + // + // Static data + // + + public static final String ID = "mimetypes"; + public static final String NAME = Finder.getString("mimetypes.title"); + public static final String PROPERTY_ADDED = "added MIME types"; + public static final String PROPERTY_REMOVED = "removed MIME types"; + + // + // Instance data + // + + private ApacheInfo info; + private SimpleHasId tmpHasId = new SimpleHasId(); + + private BasicMutableProperty addedProperty = + new IntegerProperty(PROPERTY_ADDED); + + private BasicMutableProperty removedProperty = + new IntegerProperty(PROPERTY_REMOVED); + + private List removed = new ArrayList(); + + // + // Constructors + // + + public MimeTypes(ApacheInfo info) { + super(ID); + this.info = info; + + addedProperty.update(0, true); + addProperties(addedProperty); + + removedProperty.update(0, true); + addProperties(removedProperty); + + setComparator(SimpleHasId.COMPARATOR); + } + + // + // HasIcon methods + // + + @Override + public Icon getIcon(int height) { + return PanelIconUtil.getClosestMimeIcon(null, null, height); + } + + // + // ManagedObject methods + // + + @Override + public String getName() { + return NAME; + } + + // + // AbstractManagedObject methods + // + + @Override + public void addChildren(MimeType... toAdd) { + super.addChildren(toAdd); + + ChangeableAggregator aggregator = getChangeableAggregator(); + for (MimeType mimeType : toAdd) { + if (!mimeType.isInRepo()) { + addedProperty.setValue(addedProperty.getValue() + 1); + } + aggregator.addChangeables(mimeType.getChangeableAggregator()); + } + } + + @Override + public void removeChildren(MimeType... toRemove) { + super.removeChildren(toRemove); + + ChangeableAggregator aggregator = getChangeableAggregator(); + for (MimeType mimeType : toRemove) { + if (!mimeType.isInRepo()) { + addedProperty.setValue(addedProperty.getValue() - 1); + } + aggregator.removeChangeable(mimeType.getChangeableAggregator()); + } + } + + // + // MimeTypes methods + // + + public ApacheInfo getApacheInfo() { + return info; + } + + public MimeType getMimeType(String id) { + synchronized (children) { + tmpHasId.setId(id); + int index = Collections.binarySearch( + getChildren(), tmpHasId, SimpleHasId.COMPARATOR); + + if (index >= 0) { + return children.get(index); + } + + return null; + } + } + + public MimeType getMimeType(String type, String subtype) { + String id = MimeType.toId(type, subtype); + return getMimeType(id); + } + + public void refresh(boolean force) throws ScfException { + ServiceMXBean service = info.getPanelDescriptor().getService(); + String group = info.getPropertyGroupName(); + + // Build list of names of MIME type properties + List properties = new ArrayList(); + for (String property : service.getPropertyNames(group)) { + if (property.startsWith(MimeType.SMF_PROPERTY_PREFIX)) { + properties.add(property); + } + } + Collections.sort(properties); + + // Remove names of properties that are pending removal on client + for (Iterator i = removed.iterator(); i.hasNext();) { + MimeType mimeType = i.next(); + String property = mimeType.getPropertyName(); + if (properties.remove(property)) { + // Pending removal on client, still exists on server + } else { + // Pending removal on client, but already removed on server + i.remove(); + int n = removed.size(); + assert n == removedProperty.getValue() - 1; + removedProperty.setValue(n); + } + } + + // Remove names of properties already created on the client + List children = new ArrayList(getChildren()); + for (MimeType mimeType : children) { + if (mimeType.isInRepo()) { + String property = mimeType.getPropertyName(); + if (properties.remove(property)) { + // Exists on server, already exists on client + mimeType.refresh(force); + } else { + // Deleted on server, now must be deleted on client + removeChildren(mimeType); + } + } + } + + // The list now contains only properties that have been created on the + // server but don't yet exist on the client + for (String property : properties) { + MimeType mimeType = new MimeType(this, property); + addChildren(mimeType); + } + } + + public void scheduleRemove(MimeType... mimeTypes) { + for (MimeType mimeType : mimeTypes) { + if (getChildren().contains(mimeType)) { + removeChildren(mimeType); + + if (mimeType.isInRepo()) { + removed.add(mimeType); + int n = removed.size(); + assert n == removedProperty.getValue() + 1; + removedProperty.setValue(n); + } + } + } + } + + public void saveToRepo() throws ScfException { + ApacheUtil.saveToRepo(info.getService(), + new ScfRunnable() { + @Override + public void run() throws ScfException { + for (MimeType mimeType : getChildren()) { + mimeType.saveToRepo(); + } + addedProperty.setValue(0); + + for (Iterator i = removed.iterator(); + i.hasNext();) { + + MimeType mimeType = i.next(); + mimeType.removeFromRepo(); + i.remove(); + int n = removed.size(); + assert n == removedProperty.getValue() - 1; + removedProperty.setValue(n); + } + + for (MutableProperty property : getProperties()) { + if (property.isChanged()) { + if (property instanceof SmfMutableProperty) { + ((SmfMutableProperty)property).saveToRepo(); + } else { + property.save(); + } + } + } + } + }); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/MimeTypesControl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/MimeTypesControl.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,180 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.util.List; +import javax.swing.*; +import com.oracle.solaris.vp.panel.common.control.*; +import com.oracle.solaris.vp.panel.common.view.PanelIconUtil; +import com.oracle.solaris.vp.panel.swing.control.*; +import com.oracle.solaris.vp.panel.swing.view.*; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.swing.*; + +public class MimeTypesControl extends ListSelectorControl implements HasIcons { + + // + // Static data + // + + public static final String ID = "mimetypes"; + public static final String NAME = Finder.getString("mimetypes.title"); + + // + // Instance data + // + + private HasMimeTypes parent; + + // + // Constructors + // + + public MimeTypesControl(ApachePanelDescriptor descriptor, + HasMimeTypes parent) { + + super(ID, NAME, descriptor); + this.parent = parent; + } + + // + // HasIcons methods + // + + @Override + public List getIcons() { + return PanelIconUtil.getGenericMimeIcons(); + } + + // + // Control methods + // + + @Override + public Navigable[] getForwardingPath(boolean childStopped) { + List mimeTypes = parent.getMimeTypes().getChildren(); + if (!mimeTypes.isEmpty()) { + + MimeType mimeType = mimeTypes.get(0); + + return new Navigable[] { + new SimpleNavigable(MimeTypeControl.ID, null, + MimeTypeControl.PARAM_MIMETYPE, mimeType.getId()) + }; + } + + return null; + } + + @Override + public String getHelpMapID() { + return "apache-mimetypes"; + } + + // + // DefaultControl methods + // + + @Override + protected void ensureChildrenCreated() { + if (children.size() == 0) { + ApachePanelDescriptor descriptor = getPanelDescriptor(); + SwingControl child = new MimeTypeControl(descriptor, this); + addChildren(child); + addToLayout(child); + } + } + + // + // SwingControl methods + // + + @Override + protected void configComponent(ListSelectorPanel panel) { + super.configComponent(panel); + addDefaultCloseAction(false); + addDefaultHelpAction(); + } + + @Override + protected ListSelectorPanel createComponent() { + ListSelectorPanel panel = new ListSelectorPanel(); + panel.setSelectionTitle(Finder.getString("mimetypes.list.title")); + + JList list = panel.getSelectionComponent(); + SimpleCellRenderer renderer = new ManagedObjectCellRenderer(); + renderer.configureFor(list); + list.setCellRenderer(renderer); + + addAction(panel, new CreateMimeTypeAction(this), true, true); + addAction(panel, new DeleteMimeTypeAction(this), true, true); + + setDefaultContentView(new NoMimeTypePanel()); + + return panel; + } + + // + // ListSelectorControl methods + // + + @Override + protected int getListIndexOf(Control child) { + MimeType mimeType = ((MimeTypeControl)child).getMimeType(); + int index = parent.getMimeTypes().indexOf(mimeType); + assert mimeType == getComponent().getSelectionComponent().getModel(). + getElementAt(index); + return index; + } + + @Override + protected ListModel getListModel() { + return new ManagedObjectTableModel(parent.getMimeTypes()); + } + + @Override + protected Navigable[] getPathForSelection(List selection) { + if (selection.size() != 1) { + return null; + } + + MimeType selected = selection.get(0); + + return new Navigable[] { + new SimpleNavigable(MimeTypeControl.ID, selected.getName(), + MimeTypeControl.PARAM_MIMETYPE, selected.getId()) + }; + } + + // + // MimeTypesControl methods + // + + public HasMimeTypes getHasMimeTypes() { + return parent; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/Module.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/Module.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,224 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.util.List; +import javax.swing.*; +import com.oracle.solaris.scf.common.ScfException; +import com.oracle.solaris.vp.panel.common.model.*; +import com.oracle.solaris.vp.panel.common.smf.*; +import com.oracle.solaris.vp.util.misc.IconUtil; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.misc.property.*; +import com.oracle.solaris.vp.util.swing.HasIcon; + +@SuppressWarnings({"serial"}) +public class Module extends AbstractManagedObject + implements HasIcon, Cloneable, SmfPropertyInfo { + + // + // Static data + // + + public static final String PROPERTY_FILE = "file"; + + public static final String SMF_PROPERTY_PREFIX = "module-"; + + protected static final List icons = Finder.getIcons( + "images/modules-32.png", + "images/modules-48.png", + "images/modules-96.png"); + + // + // Instance data + // + + private Modules parent; + private String propertyName; + + private MutableProperty nameProperty = + new BasicMutableProperty(PROPERTY_NAME); + + private MutableProperty fileProperty = + new BasicMutableProperty(PROPERTY_FILE); + + // This is the property that does the actual work of persisting this + // Module's data to the SMF repository + private BasicSmfMutableProperty smfProperty = + new StringSmfProperty(null, this); + + // + // Constructors + // + + public Module(Modules parent) { + this.parent = parent; + + nameProperty.setValue(""); + addProperties(nameProperty); + + fileProperty.setValue(""); + addProperties(fileProperty); + + // Synchronize the properties holding this Module's data with the + // property responsible for persisting it to the SMF repository + new ModulePropertySynchronizer(smfProperty, this, false); + } + + public Module(Modules parent, String propertyName) throws ScfException { + this(parent); + this.propertyName = propertyName; + refresh(true); + } + + // + // HasService methods + // + + @Override + public AggregatedRefreshService getService() { + return parent.getApacheInfo().getService(); + } + + // + // SmfPropertyGroupInfo methods + // + + @Override + public String getPropertyGroupName() throws ScfException { + return parent.getApacheInfo().getPropertyGroupName(); + } + + // + // SmfPropertyInfo methods + // + + @Override + public String getPropertyName() throws ScfException { + if (propertyName == null) { + propertyName = ApacheUtil.getNextAvailablePropertyName( + parent.getApacheInfo(), SMF_PROPERTY_PREFIX); + } + return propertyName; + } + + // + // Object methods + // + + @Override + public Module clone() { + Module clone = new Module(getParent()); + for (MutableProperty property : getProperties()) { + String name = property.getPropertyName(); + + @SuppressWarnings({"unchecked"}) + MutableProperty oldProperty = + (MutableProperty)property; + + @SuppressWarnings({"unchecked"}) + MutableProperty newProperty = + (MutableProperty)clone.getProperty(name); + + newProperty.setValue(oldProperty.getValue()); + } + + return clone; + } + + // + // ManagedObject methods + // + + @Override + public String getId() { + return nameProperty.getValue(); + } + + @Override + public String getName() { + return getId(); + } + + // + // HasIcon methods + // + + @Override + public Icon getIcon(int height) { + return IconUtil.getClosestIcon(icons, height); + } + + // + // Module methods + // + + public MutableProperty getFileProperty() { + return fileProperty; + } + + public MutableProperty getNameProperty() { + return nameProperty; + } + + public Modules getParent() { + return parent; + } + + public boolean isInRepo() { + return propertyName != null; + } + + public void refresh(boolean force) throws ScfException { + smfProperty.updateFromRepo(force); + } + + protected void removeFromRepo() throws ScfException { + if (isInRepo()) { + smfProperty.removeFromRepo(); + } + } + + public void saveToRepo() throws ScfException { + ApacheUtil.saveToRepo(getService(), + new ScfRunnable() { + @Override + public void run() throws ScfException { + if (smfProperty.isChanged()) { + smfProperty.saveToRepo(); + } + } + }); + } + + // + // Static methods + // + + public static boolean isValidName(String name) { + return !name.isEmpty() && !name.matches(".*\\s.*"); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/ModuleControl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/ModuleControl.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,198 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.util.Map; +import com.oracle.solaris.vp.panel.common.action.*; +import com.oracle.solaris.vp.panel.common.control.*; +import com.oracle.solaris.vp.panel.swing.control.SettingsControl; +import com.oracle.solaris.vp.util.misc.finder.Finder; + +public class ModuleControl + extends SettingsControl { + + // + // Static data + // + + public static final String ID = "module"; + public static final String PARAM_MODULE = "module"; + + // + // Instance data + // + + private ModulesControl parent; + private Module module; + + // + // Constructors + // + + public ModuleControl(ApachePanelDescriptor descriptor, + ModulesControl parent) { + + super(ID, null, descriptor); + + this.parent = parent; + } + + // + // Control methods + // + + @Override + protected UnsavedChangesAction getUnsavedChangesAction() { + // Automatically save changes to the Module -- let MainControl + // prompt the user to save them to the repo + return UnsavedChangesAction.SAVE; + } + + @Override + public boolean isBrowsable() { + // This Control requires init parameters + return false; + } + + @Override + protected boolean isChanged() { + // Save unconditionally, since a property that reports itself as + // unchanged in the panel may still be changed from the corresponding + // property in the Module. Alternatively, we could compare each panel + // property to its Module counterpart and save only if there are + // differences, but this is easier and save() has low overhead. + return true; + } + + @Override + protected void save() throws ActionAbortedException, ActionFailedException, + ActionUnauthorizedException { + + setPropertyChangeIgnore(true); + + try { + ModulePanel panel = getComponent(); + + String name = panel.getNameProperty().getValue(); + String file = panel.getFileProperty().getValue(); + + validate(name, file); + + Module child = module.getParent().getModule(name); + if (child != null && child != module) { + throw new ActionFailedException(Finder.getString( + "module.error.duplicate", name)); + } + + module.getNameProperty().setValue(name); + module.getFileProperty().setValue(file); + } finally { + setPropertyChangeIgnore(false); + } + } + + @Override + public void start(Navigator navigator, Map parameters) + throws NavigationAbortedException, InvalidParameterException, + NavigationFailedException { + + String param = getParameter(parameters, PARAM_MODULE); + + Module module = parent.getHasModules().getModules(). + getModule(param); + if (module == null) { + throw new InvalidParameterException(getId(), PARAM_MODULE, param); + } + + this.module = module; + setName(module.getName()); + + setPropertyChangeSource(module); + super.start(navigator, parameters); + } + + @Override + public void stop(boolean isCancel) throws NavigationAbortedException { + super.stop(isCancel); + + // Remove reference so it can be garbage collected if deleted + module = null; + } + + // + // SwingControl methods + // + + @Override + protected ModulePanel createComponent() { + return new ModulePanel(); + } + + @Override + protected void initComponent() { + ModulePanel panel = getComponent(); + panel.getChangeableAggregator().reset(); + panel.init(module); + } + + // + // ModuleControl methods + // + + public Module getModule() { + return module; + } + + // + // Static methods + // + + /** + * Validates the entered data in the UI. + * + * @exception ActionFailedException + * if the entered data is invalid (the thrown exception will + * contain a localized error message) + */ + public static void validate(String name, String file) + throws ActionFailedException { + + if (name.isEmpty()) { + throw new ActionFailedException(Finder.getString( + "module.error.name.empty", name)); + } + + if (!Module.isValidName(name)) { + throw new ActionFailedException(Finder.getString( + "module.error.name.invalid", name)); + } + + if (file.isEmpty()) { + throw new ActionFailedException(Finder.getString( + "module.error.file.empty", file)); + } + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/ModulePanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/ModulePanel.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,152 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.awt.*; +import javax.swing.*; +import javax.swing.filechooser.FileSystemView; +import javax.swing.text.JTextComponent; +import com.oracle.solaris.vp.panel.swing.view.ChangeIndicator; +import com.oracle.solaris.vp.util.misc.ChangeableAggregator; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.misc.property.*; +import com.oracle.solaris.vp.util.swing.*; +import com.oracle.solaris.vp.util.swing.layout.*; +import com.oracle.solaris.vp.util.swing.property. + TextComponentPropertySynchronizer; + +@SuppressWarnings({"serial"}) +public class ModulePanel extends SettingsPanel { + // + // Instance data + // + + private MutableProperty nameProperty = new StringProperty(); + private MutableProperty fileProperty = new StringProperty(); + + { + ChangeableAggregator aggregator = getChangeableAggregator(); + aggregator.addChangeables(nameProperty, fileProperty); + } + + private JFileChooser fileChooser; + + // + // Constructors + // + + public ModulePanel() { + JPanel form = createForm(); + setContent(form, false, false); + } + + // + // ModulePanel methods + // + + public MutableProperty getFileProperty() { + return fileProperty; + } + + public MutableProperty getNameProperty() { + return nameProperty; + } + + public void init(Module module) { + // Sanity check -- the UI should be updated only on the event thread + assert EventQueue.isDispatchThread(); + + FileSystemView fsView; + + if (module == null) { + fsView = FileSystemView.getFileSystemView(); + } else { + ApacheUtil.update(module.getNameProperty(), nameProperty); + ApacheUtil.update(module.getFileProperty(), fileProperty); + + fsView = module.getParent().getApacheInfo().getPanelDescriptor(). + getFileSystemView(); + } + + fileChooser.setFileSystemView(fsView); + } + + // + // Private methods + // + + private JPanel createForm() { + int gap = GUIUtil.getHalfGap(); + + JLabel nameLabel = new JLabel( + Finder.getString("module.edit.name")); + + JTextField nameField = GUIUtil.createTextField(); + new TextComponentPropertySynchronizer( + nameProperty, nameField); + ChangeIndicator nameChange = new ChangeIndicator(); + nameProperty.addChangeListener(nameChange); + + JLabel fileLabel = new JLabel( + Finder.getString("module.edit.file")); + + BrowsableFilePanel fileField = new BrowsableFilePanel(); + fileField.setOpaque(false); + fileChooser = fileField.getFileChooser(); + + new TextComponentPropertySynchronizer( + fileProperty, fileField.getField()); + ChangeIndicator fileChange = new ChangeIndicator(); + fileProperty.addChangeListener(fileChange); + + JPanel filePanel = new JPanel(new BorderLayout(gap, 0)); + filePanel.setOpaque(false); + filePanel.add(fileField, BorderLayout.CENTER); + filePanel.add(fileChange, BorderLayout.EAST); + + JPanel formPanel = new JPanel(); + formPanel.setOpaque(false); + Form form = new Form(formPanel, VerticalAnchor.TOP); + + ColumnLayoutConstraint c = new ColumnLayoutConstraint( + HorizontalAnchor.FILL, gap); + + HasAnchors a = new SimpleHasAnchors( + HorizontalAnchor.LEFT, VerticalAnchor.CENTER); + + form.addTable(3, gap, gap, HorizontalAnchor.LEFT, c); + + form.add(nameLabel, a); + form.add(nameField, a); + form.add(nameChange, a); + + form.add(fileLabel, a); + form.add(filePanel, a); + form.add(fileChange, a); + + return formPanel; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/ModulePropertySynchronizer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/ModulePropertySynchronizer.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,197 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.util.*; +import javax.swing.event.*; +import com.oracle.solaris.vp.util.misc.ObjectUtil; +import com.oracle.solaris.vp.util.misc.property.*; + +/** + * The {@code ModulePropertySynchronizer} class synchronizes a {@link + * MutableProperty}{@code >} with a {@code Module}'s {@link + * MutableProperty}s so that changes in one will automatically be reflected in + * the other. + */ +public class ModulePropertySynchronizer + extends PropertySynchronizer, Module> { + + // + // Static data + // + + public static final String SMF_VALUE_PREFIX = "MODULE:"; + + // + // Instance data + // + + private ChangeListener listener = + new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + objectChanged(); + } + }; + + // + // Constructors + // + + public ModulePropertySynchronizer(MutableProperty> property, + Module module, boolean initFromProp) { + + super(property, module, initFromProp); + + module.getNameProperty().addChangeListener(listener); + module.getFileProperty().addChangeListener(listener); + } + + /** + * Constructs a {@code ModulePropertySynchronizer} with initial + * synchronization from {@code property} to {@code module}. + */ + public ModulePropertySynchronizer(MutableProperty> property, + Module module) { + + this(property, module, true); + } + + // + // PropertySynchronizer methods + // + + @Override + protected boolean differ() { + return super.differ() || !ObjectUtil.equals(getSavedValue(), + getProperty().getSavedValue()); + } + + @Override + public void desynchronize() { + super.desynchronize(); + + Module module = getObject(); + module.getNameProperty().removeChangeListener(listener); + module.getFileProperty().removeChangeListener(listener); + } + + @Override + public List getValue() { + return getValue(false); + } + + @Override + protected void syncObjectChanges() { + super.syncObjectChanges(); + List value = getSavedValue(); + getProperty().setSavedValue(value); + } + + @Override + protected void syncPropertyChanges() { + super.syncPropertyChanges(); + List value = getProperty().getSavedValue(); + setSavedValue(value); + } + + @Override + public void setValue(List value) { + setValue(value, false); + } + + // + // ModulePropertySynchronizer methods + // + + public List getSavedValue() { + return getValue(true); + } + + public void setSavedValue(List value) { + setValue(value, true); + } + + // + // Private methods + // + + private List getValue(boolean saved) { + List value = new ArrayList(2); + + Module module = getObject(); + + MutableProperty nameProperty = module.getNameProperty(); + String name = saved ? nameProperty.getSavedValue() : + nameProperty.getValue(); + + value.add(SMF_VALUE_PREFIX + name); + + MutableProperty fileProperty = module.getFileProperty(); + String file = saved ? fileProperty.getSavedValue() : + fileProperty.getValue(); + + value.add(file); + + return value; + } + + private void setValue(List value, boolean saved) { + Module module = getObject(); + String name = null; + String file = null; + + if (value != null) { + for (String sValue : value) { + if (sValue.startsWith(SMF_VALUE_PREFIX)) { + name = sValue.substring(SMF_VALUE_PREFIX.length()); + if (name.isEmpty()) { + name = null; + } + } else { + file = sValue; + if (file.isEmpty()) { + file = null; + } + } + } + } + + MutableProperty nameProperty = module.getNameProperty(); + if (saved) { + nameProperty.setSavedValue(name); + } else { + nameProperty.setValue(name); + } + + MutableProperty fileProperty = module.getFileProperty(); + if (saved) { + fileProperty.setSavedValue(file); + } else { + fileProperty.setValue(file); + } + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/Modules.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/Modules.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,251 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.util.*; +import javax.swing.Icon; +import com.oracle.solaris.scf.common.ScfException; +import com.oracle.solaris.vp.panel.common.model.*; +import com.oracle.solaris.vp.panel.common.smf.*; +import com.oracle.solaris.vp.util.misc.*; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.misc.property.*; +import com.oracle.solaris.vp.util.swing.HasIcon; + +@SuppressWarnings({"serial"}) +public class Modules extends AbstractManagedObject + implements HasIcon { + + // + // Static data + // + + public static final String ID = "modules"; + public static final String NAME = Finder.getString("modules.title"); + public static final String PROPERTY_ADDED = "added Modules"; + public static final String PROPERTY_REMOVED = "removed Modules"; + + // + // Instance data + // + + private ApacheInfo info; + private SimpleHasId tmpHasId = new SimpleHasId(); + + private BasicMutableProperty addedProperty = + new IntegerProperty(PROPERTY_ADDED); + + private BasicMutableProperty removedProperty = + new IntegerProperty(PROPERTY_REMOVED); + + private List removed = new ArrayList(); + + // + // Constructors + // + + public Modules(ApacheInfo info) { + super(ID); + this.info = info; + + addedProperty.update(0, true); + addProperties(addedProperty); + + removedProperty.update(0, true); + addProperties(removedProperty); + + setComparator(SimpleHasId.COMPARATOR); + } + + // + // HasIcon methods + // + + @Override + public Icon getIcon(int height) { + return IconUtil.getClosestIcon(Module.icons, height); + } + + // + // ManagedObject methods + // + + @Override + public String getName() { + return NAME; + } + + // + // AbstractManagedObject methods + // + + @Override + public void addChildren(Module... toAdd) { + super.addChildren(toAdd); + + ChangeableAggregator aggregator = getChangeableAggregator(); + for (Module module : toAdd) { + if (!module.isInRepo()) { + addedProperty.setValue(addedProperty.getValue() + 1); + } + aggregator.addChangeables(module.getChangeableAggregator()); + } + } + + @Override + public void removeChildren(Module... toRemove) { + super.removeChildren(toRemove); + + ChangeableAggregator aggregator = getChangeableAggregator(); + for (Module module : toRemove) { + if (!module.isInRepo()) { + addedProperty.setValue(addedProperty.getValue() - 1); + } + aggregator.removeChangeable(module.getChangeableAggregator()); + } + } + + // + // Modules methods + // + + public ApacheInfo getApacheInfo() { + return info; + } + + public Module getModule(String id) { + synchronized (children) { + tmpHasId.setId(id); + int index = Collections.binarySearch( + getChildren(), tmpHasId, SimpleHasId.COMPARATOR); + + if (index >= 0) { + return children.get(index); + } + + return null; + } + } + + public void refresh(boolean force) throws ScfException { + ServiceMXBean service = info.getPanelDescriptor().getService(); + String group = info.getPropertyGroupName(); + + // Build list of names of Module properties + List properties = new ArrayList(); + for (String property : service.getPropertyNames(group)) { + if (property.startsWith(Module.SMF_PROPERTY_PREFIX)) { + properties.add(property); + } + } + Collections.sort(properties); + + // Remove names of properties that are pending removal on client + for (Iterator i = removed.iterator(); i.hasNext();) { + Module module = i.next(); + String property = module.getPropertyName(); + if (properties.remove(property)) { + // Pending removal on client, still exists on server + } else { + // Pending removal on client, but already removed on server + i.remove(); + int n = removed.size(); + assert n == removedProperty.getValue() - 1; + removedProperty.setValue(n); + } + } + + // Remove names of properties already created on the client + List children = new ArrayList(getChildren()); + for (Module module : children) { + if (module.isInRepo()) { + String property = module.getPropertyName(); + if (properties.remove(property)) { + // Exists on server, already exists on client + module.refresh(force); + } else { + // Deleted on server, now must be deleted on client + removeChildren(module); + } + } + } + + // The list now contains only properties that have been created on the + // server but don't yet exist on the client + for (String property : properties) { + Module module = new Module(this, property); + addChildren(module); + } + } + + public void scheduleRemove(Module... modules) { + for (Module module : modules) { + if (getChildren().contains(module)) { + removeChildren(module); + + if (module.isInRepo()) { + removed.add(module); + int n = removed.size(); + assert n == removedProperty.getValue() + 1; + removedProperty.setValue(n); + } + } + } + } + + public void saveToRepo() throws ScfException { + ApacheUtil.saveToRepo(info.getService(), + new ScfRunnable() { + @Override + public void run() throws ScfException { + for (Module module : getChildren()) { + module.saveToRepo(); + } + addedProperty.setValue(0); + + for (Iterator i = removed.iterator(); i.hasNext();) + { + Module module = i.next(); + module.removeFromRepo(); + i.remove(); + int n = removed.size(); + assert n == removedProperty.getValue() - 1; + removedProperty.setValue(n); + } + + for (MutableProperty property : getProperties()) { + if (property.isChanged()) { + if (property instanceof SmfMutableProperty) { + ((SmfMutableProperty)property).saveToRepo(); + } else { + property.save(); + } + } + } + } + }); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/ModulesControl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/ModulesControl.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,179 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.util.List; +import javax.swing.*; +import com.oracle.solaris.vp.panel.common.control.*; +import com.oracle.solaris.vp.panel.swing.control.*; +import com.oracle.solaris.vp.panel.swing.view.*; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.swing.*; + +public class ModulesControl extends ListSelectorControl implements HasIcons { + + // + // Static data + // + + public static final String ID = "modules"; + public static final String NAME = Finder.getString("modules.title"); + + // + // Instance data + // + + private HasModules parent; + + // + // Constructors + // + + public ModulesControl(ApachePanelDescriptor descriptor, + HasModules parent) { + + super(ID, NAME, descriptor); + this.parent = parent; + } + + // + // HasIcons methods + // + + @Override + public List getIcons() { + return Module.icons; + } + + // + // Control methods + // + + @Override + public Navigable[] getForwardingPath(boolean childStopped) { + List modules = parent.getModules().getChildren(); + if (!modules.isEmpty()) { + + Module module = modules.get(0); + + return new Navigable[] { + new SimpleNavigable(ModuleControl.ID, null, + ModuleControl.PARAM_MODULE, module.getId()) + }; + } + + return null; + } + + @Override + public String getHelpMapID() { + return "apache-modules"; + } + + // + // DefaultControl methods + // + + @Override + protected void ensureChildrenCreated() { + if (children.size() == 0) { + ApachePanelDescriptor descriptor = getPanelDescriptor(); + SwingControl child = new ModuleControl(descriptor, this); + addChildren(child); + addToLayout(child); + } + } + + // + // SwingControl methods + // + + @Override + protected void configComponent(ListSelectorPanel panel) { + super.configComponent(panel); + addDefaultCloseAction(false); + addDefaultHelpAction(); + } + + @Override + protected ListSelectorPanel createComponent() { + ListSelectorPanel panel = new ListSelectorPanel(); + panel.setSelectionTitle(Finder.getString("modules.list.title")); + + JList list = panel.getSelectionComponent(); + SimpleCellRenderer renderer = new ManagedObjectCellRenderer(); + renderer.configureFor(list); + list.setCellRenderer(renderer); + + addAction(panel, new CreateModuleAction(this), true, true); + addAction(panel, new DeleteModuleAction(this), true, true); + + setDefaultContentView(new NoModulePanel()); + + return panel; + } + + // + // ListSelectorControl methods + // + + @Override + protected int getListIndexOf(Control child) { + Module module = ((ModuleControl)child).getModule(); + int index = parent.getModules().indexOf(module); + assert module == getComponent().getSelectionComponent().getModel(). + getElementAt(index); + return index; + } + + @Override + protected ListModel getListModel() { + return new ManagedObjectTableModel(parent.getModules()); + } + + @Override + protected Navigable[] getPathForSelection(List selection) { + if (selection.size() != 1) { + return null; + } + + Module selected = selection.get(0); + + return new Navigable[] { + new SimpleNavigable(ModuleControl.ID, selected.getName(), + ModuleControl.PARAM_MODULE, selected.getId()) + }; + } + + // + // ModulesControl methods + // + + public HasModules getHasModules() { + return parent; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/NoContentPanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/NoContentPanel.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,67 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.awt.BorderLayout; +import javax.swing.*; +import com.oracle.solaris.vp.util.misc.TextUtil; +import com.oracle.solaris.vp.util.swing.GUIUtil; + +@SuppressWarnings({"serial"}) +public class NoContentPanel extends JPanel { + // + // Static data + // + + public static final int WIDTH = 40; + + // + // Constructors + // + + public NoContentPanel(String messageText) { + setOpaque(false); + messageText = formatAsHTML(messageText, WIDTH); + + Icon icon = GUIUtil.getIcon(JOptionPane.INFORMATION_MESSAGE); + JLabel label = new JLabel(messageText); + label.setIcon(icon); + label.setIconTextGap(icon.getIconWidth() / 3); + label.setHorizontalAlignment(SwingConstants.CENTER); + label.setVerticalAlignment(SwingConstants.CENTER); + + setLayout(new BorderLayout()); + add(label, BorderLayout.CENTER); + } + + public static String formatAsHTML(String text, int width) { + if (text != null && !text.matches("(?i)^"; + } + return text; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/NoMimeTypePanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/NoMimeTypePanel.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import com.oracle.solaris.vp.util.misc.finder.Finder; + +@SuppressWarnings({"serial"}) +public class NoMimeTypePanel extends NoContentPanel { + // + // Static data + // + + private static final String MESSAGE_TEXT; + static { + String buttonText = Finder.getString("mimetypes.action.create.button"); + MESSAGE_TEXT = Finder.getString("mimetypes.default.message", + buttonText); + } + + // + // Constructors + // + + public NoMimeTypePanel() { + super(MESSAGE_TEXT); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/NoModulePanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/NoModulePanel.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import com.oracle.solaris.vp.util.misc.finder.Finder; + +@SuppressWarnings({"serial"}) +public class NoModulePanel extends NoContentPanel { + // + // Static data + // + + private static final String MESSAGE_TEXT; + static { + String buttonText = Finder.getString("modules.action.create.button"); + MESSAGE_TEXT = Finder.getString("modules.default.message", + buttonText); + } + + // + // Constructors + // + + public NoModulePanel() { + super(MESSAGE_TEXT); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/PropertyGroupNamePool.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/PropertyGroupNamePool.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,149 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.util.*; +import com.oracle.solaris.scf.common.ScfException; +import com.oracle.solaris.vp.panel.common.api.smf_old.*; +import com.oracle.solaris.vp.panel.common.smf.ServiceMXBean; + +public class PropertyGroupNamePool { + // + // Static data + // + + private static final int MINIMUM = 1; + + // + // Instance data + // + + private ServiceMXBean service; + private String prefix; + private List existing = new LinkedList(); + private List reserved = new LinkedList(); + private int next; + + // + // Constructors + // + + public PropertyGroupNamePool(ServiceMXBean service, String prefix) + throws ScfException { + + this.service = service; + this.prefix = prefix; + + refresh(); + } + + // + // PropertyGroupNamePool methods + // + + public String get() { + String name = prefix + next; + + int index = Collections.binarySearch(reserved, next); + assert index < 0; + index = -1 - index; + reserved.add(index, next); + + next = getNext(next); + + return name; + } + + @SuppressWarnings({"unchecked"}) + public boolean put(int ord) { + boolean found = false; + List[] lists = { + reserved, existing + }; + + for (List list : lists) { + int index = Collections.binarySearch(list, ord); + found = index >= 0; + if (found) { + list.remove(index); + if (ord < next) { + next = ord; + } + break; + } + } + + return found; + } + + public boolean put(String name) { + try { + return put(toOrd(name)); + } catch (NumberFormatException e) { + return false; + } + } + + public void refresh() throws ScfException { + existing.clear(); + for (PropertyGroup pg : service.getPropertyGroups()) { + String name = pg.getName(); + try { + int ord = toOrd(name); + int index = Collections.binarySearch(existing, ord); + if (index < 0) { + index = -1 - index; + existing.add(index, ord); + } + index = Collections.binarySearch(reserved, ord); + if (index >= 0) { + reserved.remove(index); + } + } catch (NumberFormatException skip) { + } + } + next = getNext(MINIMUM); + } + + // + // Private methods + // + + private int getNext(int from) { + while (Collections.binarySearch(existing, from) >= 0 || + Collections.binarySearch(reserved, from) >= 0) { + from++; + } + return from; + } + + private int toOrd(String name) { + if (name.startsWith(prefix)) { + return Integer.parseInt(name.substring(prefix.length())); + } + throw new NumberFormatException(); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/ScfRunnable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/ScfRunnable.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,32 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import com.oracle.solaris.scf.common.ScfException; + +public interface ScfRunnable { + void run() throws ScfException; +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHost.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHost.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,513 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.util.List; +import javax.swing.*; +import com.oracle.solaris.rad.ObjectException; +import com.oracle.solaris.scf.common.ScfException; +import com.oracle.solaris.vp.panel.common.model.*; +import com.oracle.solaris.vp.panel.common.smf.*; +import com.oracle.solaris.vp.util.misc.*; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.misc.property.MutableProperty; +import com.oracle.solaris.vp.util.swing.HasIcon; + +@SuppressWarnings({"serial"}) +public class VirtualHost extends AbstractManagedObject + implements HasIcon, Cloneable, Enableable, ApacheInfo { + + // + // Static data + // + + protected static final List ICONS_ENABLED = Finder.getIcons( + "images/vhost-enabled-16.png", + "images/vhost-enabled-24.png", + "images/vhost-enabled-32.png"); + + protected static final List ICONS_DISABLED = Finder.getIcons( + "images/vhost-disabled-16.png", + "images/vhost-disabled-24.png", + "images/vhost-disabled-32.png"); + + public static final String SMF_GROUP_PREFIX = "vhost-"; + + public static final String PROPERTY_CUSTOM_ENABLED = "custom_conf"; + public static final String PROPERTY_CUSTOM_FILE = "custom_file"; + public static final String PROPERTY_DOCROOT = "docroot"; + public static final String PROPERTY_DOMAIN = "domain"; + public static final String PROPERTY_ENABLED = "enabled"; + public static final String PROPERTY_PORT = "port"; + public static final String PROPERTY_SERVE_HOME_DIRS = "serve_home_dir"; + public static final String PROPERTY_SSL_CERT = "sslcert"; + public static final String PROPERTY_SSL_ENABLED = "sslengine"; + public static final String PROPERTY_SSL_IP = "sslip"; + public static final String PROPERTY_SSL_KEY = "sslkey"; + public static final String PROPERTY_SSL_PORT = "sslport"; + + // + // Instance data + // + + private ApachePanelDescriptor parent; + private String group; + private MimeTypes mimeTypes; + + private BasicSmfMutableProperty customEnabledProperty = + new BooleanSmfProperty(PROPERTY_CUSTOM_ENABLED, this); + + private BasicSmfMutableProperty customFileProperty = + new StringSmfProperty(PROPERTY_CUSTOM_FILE, this); + + private BasicSmfMutableProperty docRootProperty = + new StringSmfProperty(PROPERTY_DOCROOT, this); + + private BasicSmfMutableProperty domainProperty = + new StringSmfProperty(PROPERTY_DOMAIN, this); + + private BasicSmfMutableProperty enabledProperty = + new BooleanSmfProperty(PROPERTY_ENABLED, this); + + private BasicSmfMutableProperty portProperty = + new CountSmfProperty(PROPERTY_PORT, this); + + private BasicSmfMutableProperty serveHomeDirsProperty = + new BooleanSmfProperty(PROPERTY_SERVE_HOME_DIRS, this); + + private BasicSmfMutableProperty sslCertProperty = + new StringSmfProperty(PROPERTY_SSL_CERT, this); + + private BasicSmfMutableProperty sslEnabledProperty = + new BooleanSmfProperty(PROPERTY_SSL_ENABLED, this); + + private BasicSmfMutableProperty sslIpProperty = + new StringSmfProperty(PROPERTY_SSL_IP, this); + + private BasicSmfMutableProperty sslKeyProperty = + new StringSmfProperty(PROPERTY_SSL_KEY, this); + + private BasicSmfMutableProperty sslPortProperty = + new CountSmfProperty(PROPERTY_SSL_PORT, this); + + // + // Constructors + // + + public VirtualHost(ApachePanelDescriptor parent) { + this.parent = parent; + + customEnabledProperty.setFirstValue(false); + addProperties(customEnabledProperty); + + customFileProperty.setFirstValue(""); + addProperties(customFileProperty); + + docRootProperty.setFirstValue(""); + addProperties(docRootProperty); + + domainProperty.setFirstValue(""); + addProperties(domainProperty); + + enabledProperty.setFirstValue(false); + addProperties(enabledProperty); + + portProperty.setFirstValue(80); + addProperties(portProperty); + + serveHomeDirsProperty.setFirstValue(false); + addProperties(serveHomeDirsProperty); + + sslCertProperty.setFirstValue(""); + addProperties(sslCertProperty); + + sslEnabledProperty.setFirstValue(false); + addProperties(sslEnabledProperty); + + String ip = ""; + try { + ip = getParent().getClientContext().getConnectionInfo(). + getInetAddresses()[0].getHostAddress(); + } catch (Throwable ignore) { + } + + sslIpProperty.setFirstValue(ip); + addProperties(sslIpProperty); + + sslKeyProperty.setFirstValue(""); + addProperties(sslKeyProperty); + + sslPortProperty.setFirstValue(443); + addProperties(sslPortProperty); + + ChangeableAggregator aggregator = getChangeableAggregator(); + + addChildren(mimeTypes = new MimeTypes(this)); + aggregator.addChangeables(mimeTypes.getChangeableAggregator()); + } + + public VirtualHost(ApachePanelDescriptor parent, String group) + throws ScfException { + + this(parent); + this.group = group; + refresh(true); + } + + // + // ManagedObject methods + // + + @Override + public String getId() { + return getPropertyGroupName(); + } + + @Override + public String getName() { + return domainProperty.getFirstValue(); + } + + @Override + public String getStatusText() { + return docRootProperty.getFirstValue(); + } + + // + // HasIcon methods + // + + @Override + public Icon getIcon(int height) { + return IconUtil.getClosestIcon(isEnabled() ? + ICONS_ENABLED : ICONS_DISABLED, height); + } + + // + // HasService methods + // + + @Override + public AggregatedRefreshService getService() { + return parent.getService(); + } + + // + // SmfPropertyGroupInfo methods + // + + @Override + public String getPropertyGroupName() { + if (group == null) { + group = parent.getVirtualHostNamePool().get(); + } + + return group; + } + + // + // SmfPropertyInfo methods + // + + @Override + public String getPropertyName() { + // Use the default property names + return null; + } + + // + // ApacheInfo methods + // + + @Override + public ApachePanelDescriptor getPanelDescriptor() { + return getParent(); + } + + // + // Enableable methods + // + + @Override + public boolean isEnabled() { + return enabledProperty.getFirstValue(); + } + + // + // Object methods + // + + @Override + public VirtualHost clone() { + VirtualHost clone = new VirtualHost(getParent()); + for (MutableProperty property : getProperties()) { + String name = property.getPropertyName(); + + @SuppressWarnings({"unchecked"}) + MutableProperty oldProperty = + (MutableProperty)property; + + @SuppressWarnings({"unchecked"}) + MutableProperty newProperty = + (MutableProperty)clone.getProperty(name); + + newProperty.setValue(oldProperty.getValue()); + } + + return clone; + } + + // + // VirtualHost methods + // + + public BasicSmfMutableProperty getCustomEnabledProperty() { + return customEnabledProperty; + } + + public BasicSmfMutableProperty getCustomFileProperty() { + return customFileProperty; + } + + public BasicSmfMutableProperty getDocRootProperty() { + return docRootProperty; + } + + public BasicSmfMutableProperty getDomainProperty() { + return domainProperty; + } + + public BasicSmfMutableProperty getEnabledProperty() { + return enabledProperty; + } + + public MimeTypes getMimeTypes() { + return mimeTypes; + } + + public ApachePanelDescriptor getParent() { + return parent; + } + + public BasicSmfMutableProperty getPortProperty() { + return portProperty; + } + + public BasicSmfMutableProperty getServeHomeDirsProperty() { + return serveHomeDirsProperty; + } + + public BasicSmfMutableProperty getSslCertProperty() { + return sslCertProperty; + } + + public BasicSmfMutableProperty getSslEnabledProperty() { + return sslEnabledProperty; + } + + public BasicSmfMutableProperty getSslIpProperty() { + return sslIpProperty; + } + + public BasicSmfMutableProperty getSslKeyProperty() { + return sslKeyProperty; + } + + public BasicSmfMutableProperty getSslPortProperty() { + return sslPortProperty; + } + + public boolean isInRepo() { + return group != null; + } + + public void refresh(boolean force) throws ScfException { + for (MutableProperty property : getProperties()) { + if (property instanceof SmfMutableProperty) { + ((SmfMutableProperty)property).updateFromRepo(force); + } + } + + mimeTypes.refresh(force); + } + + protected void removeFromRepo() throws ScfException { + if (group != null) { + ServiceMXBean service = getService(); + service.deletePropertyGroup(group); + service.refresh(); + parent.getVirtualHostNamePool().put(group); + } + } + + public void saveToRepo() throws ScfException { + ApacheUtil.saveToRepo(getService(), + new ScfRunnable() { + @Override + public void run() throws ScfException { + for (MutableProperty property : getProperties()) { + if (property.isChanged()) { + if (property instanceof SmfMutableProperty) { + ((SmfMutableProperty)property).saveToRepo(); + } else { + property.save(); + } + } + } + + mimeTypes.saveToRepo(); + } + }); + } + + protected void validate() throws VirtualHostGeneralValidationException, + VirtualHostSSLValidationException { + + validateDomain(); + validateCustomFile(); + validateDocRoot(); + validateSSLIP(); + validateSSLCert(); + validateSSLKey(); + } + + // + // Private methods + // + + private void validateCustomFile() + throws VirtualHostGeneralValidationException { + + if (customEnabledProperty.getFirstValue() && + (customEnabledProperty.isChanged() || + customFileProperty.isChanged()) && + customFileProperty.getFirstValue().isEmpty()) { + throw new VirtualHostGeneralValidationException(getId(), + Finder.getString("vhost.general.error.customfile.empty")); + } + } + + private void validateDomain() throws VirtualHostGeneralValidationException { + boolean domainChanged = domainProperty.isChanged(); + String domain = domainProperty.getFirstValue(); + + if (domainChanged) { + validateDomainName(domain, getId()); + } + + // Only one virtual host for a given domain may be enabled + if (isEnabled() && (enabledProperty.isChanged() || domainChanged)) { + for (VirtualHost peer : parent.getChildren()) { + if (peer != this && peer.isEnabled() && + ObjectUtil.equals(domain, + peer.getDomainProperty().getFirstValue())) { + + throw new VirtualHostGeneralValidationException(getId(), + Finder.getString( + "vhost.general.error.domain.duplicate", domain)); + } + } + } + } + + private void validateDocRoot() + throws VirtualHostGeneralValidationException { + + if (docRootProperty.isChanged() && + docRootProperty.getFirstValue().isEmpty()) { + throw new VirtualHostGeneralValidationException(getId(), + Finder.getString("vhost.general.error.docroot.empty")); + } + } + + private void validateSSLCert() + throws VirtualHostSSLValidationException { + + if (sslEnabledProperty.getFirstValue() && + (sslEnabledProperty.isChanged() || sslCertProperty.isChanged()) && + sslCertProperty.getFirstValue().isEmpty()) { + throw new VirtualHostSSLValidationException(getId(), + Finder.getString("vhost.ssl.error.cert.empty")); + } + } + + private void validateSSLIP() + throws VirtualHostSSLValidationException { + + if (sslEnabledProperty.getFirstValue() && + (sslEnabledProperty.isChanged() || sslIpProperty.isChanged())) { + + String sslIP = sslIpProperty.getFirstValue(); + if (sslIP.isEmpty()) { + throw new VirtualHostSSLValidationException(getId(), + Finder.getString("vhost.ssl.error.ip.empty")); + } + + try { + boolean isLocalAddress = + parent.getNetworkMXBean().isLocalAddress(sslIP); + + if (!isLocalAddress) { + throw new VirtualHostSSLValidationException(getId(), + Finder.getString("vhost.ssl.error.ip.invalid", sslIP)); + } + } catch (ObjectException e) { + throw new VirtualHostSSLValidationException(getId(), + Finder.getString("vhost.ssl.error.ip.syserror", e)); + } + } + } + + private void validateSSLKey() + throws VirtualHostSSLValidationException { + + if (sslEnabledProperty.getFirstValue() && + (sslEnabledProperty.isChanged() || sslKeyProperty.isChanged()) && + sslKeyProperty.getFirstValue().isEmpty()) { + throw new VirtualHostSSLValidationException(getId(), + Finder.getString("vhost.ssl.error.key.empty")); + } + } + + // + // Static methods + // + + public static void validateDomainName(String domain, String id) + throws VirtualHostGeneralValidationException { + + if (domain.isEmpty()) { + throw new VirtualHostGeneralValidationException(id, + Finder.getString("vhost.general.error.domain.empty")); + } + + if (!domain.matches("[\\w\\.\\-]+")) { + throw new VirtualHostGeneralValidationException(id, + Finder.getString("vhost.general.error.domain.invalid", + domain)); + } + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHostControl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHostControl.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,132 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.util.Map; +import com.oracle.solaris.vp.panel.common.control.*; +import com.oracle.solaris.vp.panel.swing.control.TabbedControl; + +public class VirtualHostControl extends TabbedControl { + // + // Static data + // + + public static final String ID = "vhost"; + public static final String PARAM_ID = "id"; + public static final String PARAM_DOMAIN = "domain"; + + // + // Instance data + // + + private VirtualHost vHost; + + // + // Constructors + // + + public VirtualHostControl(ApachePanelDescriptor descriptor) { + super(ID, null, descriptor); + } + + // + // Control methods + // + + @Override + public boolean isBrowsable() { + // This Control requires init parameters + return false; + } + + @Override + public void start(Navigator navigator, Map parameters) + throws NavigationAbortedException, InvalidParameterException, + NavigationFailedException { + + VirtualHost vHost; + + try { + String param = getParameter(parameters, PARAM_ID); + vHost = getPanelDescriptor().getVirtualHost(param); + if (vHost == null) { + throw new InvalidParameterException(getId(), PARAM_ID, param); + } + } catch (MissingParameterException e) { + try { + String param = getParameter(parameters, PARAM_DOMAIN); + vHost = getPanelDescriptor().getVirtualHostByDomain(param); + if (vHost == null) { + throw new InvalidParameterException(getId(), PARAM_DOMAIN, + param); + } + } catch (MissingParameterException e2) { + throw e; + } + } + + setVirtualHost(vHost); + + super.start(navigator, parameters); + } + + @Override + public void stop(boolean isCancel) throws NavigationAbortedException { + super.stop(isCancel); + + // Remove reference so it can be garbage collected if deleted + setVirtualHost(null); + } + + // + // DefaultControl methods + // + + @Override + protected void ensureChildrenCreated() { + if (children.size() == 0) { + addChildren(new VirtualHostGeneralControl(this)); + addChildren(new VirtualHostSSLControl(this)); + } + } + + // + // VirtualHostControl methods + // + + public VirtualHost getVirtualHost() { + return vHost; + } + + // + // Private methods + // + + private void setVirtualHost(VirtualHost vHost) { + this.vHost = vHost; + setName(vHost == null ? null : vHost.getName()); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHostGeneralControl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHostGeneralControl.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,209 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.awt.event.*; +import java.util.Map; +import com.oracle.solaris.vp.panel.common.control.*; +import com.oracle.solaris.vp.panel.swing.control.*; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.misc.property.MutableProperty; + +public class VirtualHostGeneralControl + extends SettingsControl + implements HasMimeTypes { + + // + // Static data + // + + public static final String ID = "general"; + public static final String NAME = Finder.getString("vhost.general.name"); + + // + // Instance data + // + + private VirtualHostControl parent; + + // + // Constructors + // + + public VirtualHostGeneralControl(VirtualHostControl parent) { + super(ID, NAME, parent.getPanelDescriptor()); + this.parent = parent; + } + + // + // HasMimeTypes methods + // + + @Override + public MimeTypes getMimeTypes() { + return parent.getVirtualHost().getMimeTypes(); + } + + // + // Control methods + // + + @Override + public String getHelpMapID() { + return "apache-vhosts-general"; + } + + @Override + protected UnsavedChangesAction getUnsavedChangesAction() { + // Automatically save changes to the VirtualHost -- let MainControl + // prompt the user to save them to the repo + return UnsavedChangesAction.SAVE; + } + + @Override + protected boolean isChanged() { + // Save unconditionally, since a property that reports itself as + // unchanged in the panel may still be changed from the corresponding + // property in the VirtualHost. Alternatively, we could compare each + // panel property to its VirtualHost counterpart and save only if there + // are differences, but this is easier and save() has low overhead. + return true; + } + + @Override + protected void save() { + setPropertyChangeIgnore(true); + + try { + VirtualHost vHost = parent.getVirtualHost(); + VirtualHostGeneralPanel panel = getComponent(); + + vHost.getDomainProperty().setFirstValue( + panel.getDomainProperty().getValue()); + + vHost.getEnabledProperty().setFirstValue( + panel.getEnabledProperty().getValue()); + + vHost.getPortProperty().setFirstValue( + panel.getPortProperty().getValue()); + + vHost.getDocRootProperty().setFirstValue( + panel.getDocRootProperty().getValue()); + + vHost.getServeHomeDirsProperty().setFirstValue( + panel.getServeHomeDirsProperty().getValue()); + + vHost.getCustomEnabledProperty().setFirstValue( + panel.getCustomEnabledProperty().getValue()); + + vHost.getCustomFileProperty().setFirstValue( + panel.getCustomFileProperty().getValue()); + + } finally { + setPropertyChangeIgnore(false); + } + } + + @Override + public void start(Navigator navigator, Map parameters) + throws NavigationAbortedException, InvalidParameterException, + NavigationFailedException { + + setPropertyChangeSource(parent.getVirtualHost(), + VirtualHost.PROPERTY_ENABLED, VirtualHost.PROPERTY_PORT, + VirtualHost.PROPERTY_DOMAIN, VirtualHost.PROPERTY_DOCROOT, + VirtualHost.PROPERTY_SERVE_HOME_DIRS, + VirtualHost.PROPERTY_CUSTOM_ENABLED, + VirtualHost.PROPERTY_CUSTOM_FILE); + + super.start(navigator, parameters); + } + + // + // DefaultControl methods + // + + @Override + protected void ensureChildrenCreated() { + if (children.size() == 0) { + ApachePanelDescriptor descriptor = getPanelDescriptor(); + + DefaultControl control = new DialogControl( + descriptor); + control.addChildren(new MimeTypesControl(descriptor, this)); + + addChildren(control); + } + } + + // + // SwingControl methods + // + + @Override + protected VirtualHostGeneralPanel createComponent() { + VirtualHostGeneralPanel panel = new VirtualHostGeneralPanel(); + + panel.getMimeTypesButton().addActionListener( + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Navigable[] navigables = { + new SimpleNavigable(DialogControl.ID, null), + new SimpleNavigable(MimeTypesControl.ID, null), + }; + + getNavigator().goToAsync(false, + VirtualHostGeneralControl.this, navigables); + } + }); + + return panel; + } + + @Override + protected void deinitComponent() { + VirtualHost vHost = parent.getVirtualHost(); + VirtualHostGeneralPanel panel = getComponent(); + + vHost.getMimeTypes().getChangeableAggregator().removeChangeListener( + panel.getMimeTypesButton()); + + panel.init(null); + } + + @Override + protected void initComponent() { + VirtualHost vHost = parent.getVirtualHost(); + VirtualHostGeneralPanel panel = getComponent(); + + vHost.getMimeTypes().getChangeableAggregator().addChangeListener( + panel.getMimeTypesButton()); + + panel.getChangeableAggregator().reset(); + panel.init(vHost); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHostGeneralPanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHostGeneralPanel.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,313 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.awt.*; +import java.util.*; +import java.util.List; +import javax.swing.*; +import javax.swing.filechooser.FileSystemView; +import javax.swing.text.JTextComponent; +import com.oracle.solaris.vp.panel.common.smf.BasicSmfMutableProperty; +import com.oracle.solaris.vp.panel.swing.view.ChangeIndicator; +import com.oracle.solaris.vp.util.misc.ChangeableAggregator; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.misc.property.*; +import com.oracle.solaris.vp.util.swing.*; +import com.oracle.solaris.vp.util.swing.layout.*; +import com.oracle.solaris.vp.util.swing.property.*; + +@SuppressWarnings({"serial"}) +public class VirtualHostGeneralPanel extends SettingsPanel { + // + // Instance data + // + + private MutableProperty enabledProperty = new BooleanProperty(); + private MutableProperty portProperty = new IntegerProperty(); + private MutableProperty domainProperty = new StringProperty(); + private MutableProperty docRootProperty = new StringProperty(); + private MutableProperty serveHomeDirsProperty = + new BooleanProperty(); + private MutableProperty customEnabledProperty = + new BooleanProperty(); + private MutableProperty customFileProperty = new StringProperty(); + + { + ChangeableAggregator aggregator = getChangeableAggregator(); + aggregator.addChangeables(enabledProperty, portProperty, domainProperty, + docRootProperty, serveHomeDirsProperty, customEnabledProperty, + customFileProperty); + } + + private List fileChoosers = new ArrayList(); + private ChangeButton mimeTypesButton; + private JSpinner portSpinner; + + // + // Constructors + // + + public VirtualHostGeneralPanel() { + JPanel form = createForm(); + setContent(form, false, false); + } + + // + // VirtualHostGeneralPanel methods + // + + public MutableProperty getEnabledProperty() { + return enabledProperty; + } + + public MutableProperty getPortProperty() { + return portProperty; + } + + public MutableProperty getDomainProperty() { + return domainProperty; + } + + public MutableProperty getDocRootProperty() { + return docRootProperty; + } + + public MutableProperty getServeHomeDirsProperty() { + return serveHomeDirsProperty; + } + + public MutableProperty getCustomEnabledProperty() { + return customEnabledProperty; + } + + public MutableProperty getCustomFileProperty() { + return customFileProperty; + } + + public ChangeButton getMimeTypesButton() { + return mimeTypesButton; + } + + public void init(VirtualHost vHost) { + // Sanity check -- the UI should be updated only on the event thread + assert EventQueue.isDispatchThread(); + + FileSystemView fsView; + + if (vHost == null) { + fsView = FileSystemView.getFileSystemView(); + } else { + ApacheUtil.update(vHost.getEnabledProperty(), enabledProperty); + ApacheUtil.update(vHost.getPortProperty(), portProperty); + ApacheUtil.update(vHost.getDomainProperty(), domainProperty); + ApacheUtil.update(vHost.getDocRootProperty(), docRootProperty); + ApacheUtil.update(vHost.getServeHomeDirsProperty(), + serveHomeDirsProperty); + + ApacheUtil.update(vHost.getCustomEnabledProperty(), + customEnabledProperty); + + ApacheUtil.update(vHost.getCustomFileProperty(), + customFileProperty); + + fsView = vHost.getParent().getFileSystemView(); + + // Enable port field. + BasicSmfMutableProperty sslEnabledProperty = + vHost.getSslEnabledProperty(); + + boolean sslEnabled = sslEnabledProperty.getFirstValue(); + portSpinner.setEnabled(!sslEnabled); + } + + for (JFileChooser c : fileChoosers) { + c.setFileSystemView(fsView); + } + } + + // + // Private methods + // + + private JPanel createForm() { + int hGap = GUIUtil.getHalfGap(); + + JCheckBox enableCheckBox = new JCheckBox( + Finder.getString("vhost.general.edit.enable")); + new CheckBoxPropertySynchronizer(enabledProperty, enableCheckBox); + ChangeIndicator enableChange = new ChangeIndicator(); + enabledProperty.addChangeListener(enableChange); + + JLabel portLabel = new JLabel( + Finder.getString("vhost.general.edit.port")); + + SpinnerNumberModel portModel = new SpinnerNumberModel(0, 0, + Short.MAX_VALUE, 1); + portSpinner = new JSpinner(portModel); + + JComponent editor = portSpinner.getEditor(); + if (editor instanceof JSpinner.DefaultEditor) { + JTextField field = ((JSpinner.DefaultEditor)editor).getTextField(); + field.setColumns(5); + field.setHorizontalAlignment(JTextField.RIGHT); + } + + new SpinnerNumberModelPropertySynchronizer(portProperty, portModel, + false); + portProperty.save(); + + ChangeIndicator portChange = new ChangeIndicator(); + portProperty.addChangeListener(portChange); + + InfoLabel portHelp = new InfoLabel( + Finder.getString("vhost.general.edit.port.help")); + + JLabel domainLabel = new JLabel( + Finder.getString("vhost.general.edit.domain")); + JTextField domainField = GUIUtil.createTextField(); + + new TextComponentPropertySynchronizer( + domainProperty, domainField); + + ChangeIndicator domainChange = new ChangeIndicator(); + domainProperty.addChangeListener(domainChange); + + JPanel domainPanel = new JPanel(new BorderLayout(hGap, 0)); + domainPanel.setOpaque(false); + domainPanel.add(domainField, BorderLayout.CENTER); + domainPanel.add(domainChange, BorderLayout.EAST); + + JLabel docRootLabel = new JLabel( + Finder.getString("vhost.general.edit.docroot")); + + BrowsableFilePanel docRootField = new BrowsableFilePanel(); + docRootField.setOpaque(false); + JFileChooser chooser = docRootField.getFileChooser(); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + fileChoosers.add(chooser); + + new TextComponentPropertySynchronizer( + docRootProperty, docRootField.getField()); + + ChangeIndicator docRootChange = new ChangeIndicator(); + docRootProperty.addChangeListener(docRootChange); + + JPanel docRootPanel = new JPanel(new BorderLayout(hGap, 0)); + docRootPanel.setOpaque(false); + docRootPanel.add(docRootField, BorderLayout.CENTER); + docRootPanel.add(docRootChange, BorderLayout.EAST); + + JCheckBox serveHomeDirsCheckBox = new JCheckBox( + Finder.getString("vhost.general.edit.homedirs")); + + new CheckBoxPropertySynchronizer(serveHomeDirsProperty, + serveHomeDirsCheckBox); + + ChangeIndicator serveHomeDirsChange = new ChangeIndicator(); + serveHomeDirsProperty.addChangeListener(serveHomeDirsChange); + + JCheckBox useCustomFileCheckBox = new JCheckBox( + Finder.getString("vhost.general.edit.customfile")); + + new CheckBoxPropertySynchronizer(customEnabledProperty, + useCustomFileCheckBox); + ChangeIndicator useCustomChange = new ChangeIndicator(); + customEnabledProperty.addChangeListener(useCustomChange); + + InfoLabel useCustomHelp = new InfoLabel( + Finder.getString("vhost.general.edit.customfile.help")); + + BrowsableFilePanel customFilePanel = new BrowsableFilePanel(); + customFilePanel.setOpaque(false); + fileChoosers.add(customFilePanel.getFileChooser()); + + new TextComponentPropertySynchronizer( + customFileProperty, customFilePanel.getField()); + + ChangeIndicator customFileChange = new ChangeIndicator(); + customFileProperty.addChangeListener(customFileChange); + + GUIUtil.setEnableStateOnSelect(useCustomFileCheckBox, true, true, + customFilePanel); + + mimeTypesButton = new ChangeButton(Finder.getString( + "vhost.general.edit.mimetypes")); + + JPanel formPanel = new JPanel(); + formPanel.setOpaque(false); + + Form form = new Form(formPanel, VerticalAnchor.FILL); + + int gap = GUIUtil.getGap(); + int sGap = 3 * hGap; + int indent = GUIUtil.getTextXOffset(useCustomFileCheckBox); + + ColumnLayoutConstraint c = new ColumnLayoutConstraint( + HorizontalAnchor.FILL, hGap); + + RowLayoutConstraint r = new RowLayoutConstraint( + VerticalAnchor.CENTER, hGap); + + HasAnchors a = new SimpleHasAnchors( + HorizontalAnchor.LEFT, VerticalAnchor.CENTER); + + form.addRow(HorizontalAnchor.FILL, c); + form.add(enableCheckBox, r); + form.add(enableChange, r); + form.add(portChange, r.clone().setWeight(1).setHorizontalAnchor( + HorizontalAnchor.RIGHT)); + form.add(portLabel, r); + form.add(portSpinner, r); + form.add(portHelp, r); + + form.addTable(2, hGap, hGap, HorizontalAnchor.LEFT, + c.clone().setGap(sGap)); + form.add(domainLabel, a); + form.add(domainPanel, a); + form.add(docRootLabel, a); + form.add(docRootPanel, a); + + form.addRow(HorizontalAnchor.LEFT, c.clone().setGap(sGap)); + form.add(serveHomeDirsCheckBox, r); + form.add(serveHomeDirsChange, r); + form.addRow(HorizontalAnchor.LEFT, c); + form.add(useCustomFileCheckBox, r); + form.add(useCustomHelp, r); + form.add(useCustomChange, r); + form.addRow(HorizontalAnchor.LEFT, c); + form.add(customFilePanel, r.clone().setGap(indent). + setIgnoreFirstGap(false)); + form.add(customFileChange, r); + + form.addRow(HorizontalAnchor.FILL, c.setGap(sGap).setWeight(1). + setVerticalAnchor(VerticalAnchor.BOTTOM)); + form.add(mimeTypesButton, r.setHorizontalAnchor( + HorizontalAnchor.RIGHT)); + + return formPanel; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHostGeneralValidationException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHostGeneralValidationException.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +@SuppressWarnings({"serial"}) +public class VirtualHostGeneralValidationException + extends VirtualHostValidationException { + + // + // Constructors + // + + public VirtualHostGeneralValidationException(String id) { + super(id); + } + + public VirtualHostGeneralValidationException(String id, String message) { + super(id, message); + } + + public VirtualHostGeneralValidationException(String id, Throwable cause) { + super(id, cause); + } + + public VirtualHostGeneralValidationException(String id, String message, + Throwable cause) { + super(id, message, cause); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHostSSLControl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHostSSLControl.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,150 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.awt.Component; +import java.util.Map; +import com.oracle.solaris.vp.panel.common.control.*; +import com.oracle.solaris.vp.panel.swing.control.SettingsControl; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.misc.property.MutableProperty; + +public class VirtualHostSSLControl + extends SettingsControl { + + // + // Static data + // + + public static final String ID = "ssl"; + public static final String NAME = Finder.getString("vhost.ssl.name"); + + // + // Instance data + // + + private VirtualHostControl parent; + + // + // Constructors + // + + public VirtualHostSSLControl(VirtualHostControl parent) { + super(ID, NAME, parent.getPanelDescriptor()); + this.parent = parent; + } + + // + // Control methods + // + + @Override + public String getHelpMapID() { + return "apache-vhosts-ssl"; + } + + @Override + protected UnsavedChangesAction getUnsavedChangesAction() { + // Automatically save changes to the VirtualHost -- let MainControl + // prompt the user to save them to the repo + return UnsavedChangesAction.SAVE; + } + + @Override + protected boolean isChanged() { + // Save unconditionally, since a property that reports itself as + // unchanged in the panel may still be changed from the corresponding + // property in the VirtualHost. Alternatively, we could compare each + // panel property to its VirtualHost counterpart and save only if there + // are differences, but this is easier and save() has low overhead. + return true; + } + + @Override + protected void save() { + setPropertyChangeIgnore(true); + + try { + VirtualHost vHost = parent.getVirtualHost(); + VirtualHostSSLPanel panel = getComponent(); + + vHost.getSslEnabledProperty().setFirstValue( + panel.getEnabledProperty().getValue()); + + vHost.getSslIpProperty().setFirstValue( + panel.getIpProperty().getValue()); + + vHost.getSslCertProperty().setFirstValue( + panel.getCertProperty().getValue()); + + vHost.getSslKeyProperty().setFirstValue( + panel.getKeyProperty().getValue()); + + vHost.getSslPortProperty().setFirstValue( + panel.getPortProperty().getValue()); + } finally { + setPropertyChangeIgnore(false); + } + } + + @Override + public void start(Navigator navigator, Map parameters) + throws NavigationAbortedException, InvalidParameterException, + NavigationFailedException { + + setPropertyChangeSource(parent.getVirtualHost(), + VirtualHost.PROPERTY_SSL_ENABLED, + VirtualHost.PROPERTY_SSL_IP, + VirtualHost.PROPERTY_SSL_PORT, + VirtualHost.PROPERTY_SSL_CERT, + VirtualHost.PROPERTY_SSL_KEY); + + super.start(navigator, parameters); + } + + // + // SwingControl methods + // + + @Override + protected VirtualHostSSLPanel createComponent() { + VirtualHostSSLPanel panel = new VirtualHostSSLPanel(); + return panel; + } + + @Override + protected void deinitComponent() { + getComponent().init(null); + } + + @Override + protected void initComponent() { + VirtualHost vHost = parent.getVirtualHost(); + VirtualHostSSLPanel panel = getComponent(); + panel.getChangeableAggregator().reset(); + panel.init(vHost); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHostSSLPanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHostSSLPanel.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,231 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import java.awt.*; +import java.util.*; +import java.util.List; +import javax.swing.*; +import javax.swing.filechooser.FileSystemView; +import javax.swing.text.JTextComponent; +import com.oracle.solaris.vp.panel.swing.view.ChangeIndicator; +import com.oracle.solaris.vp.util.misc.ChangeableAggregator; +import com.oracle.solaris.vp.util.misc.finder.Finder; +import com.oracle.solaris.vp.util.misc.property.*; +import com.oracle.solaris.vp.util.swing.*; +import com.oracle.solaris.vp.util.swing.layout.*; +import com.oracle.solaris.vp.util.swing.property.*; + +@SuppressWarnings({"serial"}) +public class VirtualHostSSLPanel extends SettingsPanel { + // + // Instance data + // + + private MutableProperty enabledProperty = new BooleanProperty(); + private MutableProperty ipProperty = new StringProperty(); + private MutableProperty portProperty = new IntegerProperty(); + private MutableProperty certProperty = new StringProperty(); + private MutableProperty keyProperty = new StringProperty(); + + { + ChangeableAggregator aggregator = getChangeableAggregator(); + aggregator.addChangeables(enabledProperty, ipProperty, portProperty, + certProperty, keyProperty); + } + + private List fileChoosers = new ArrayList(); + + // + // Constructors + // + + public VirtualHostSSLPanel() { + JPanel form = createForm(); + setContent(form, false, false); + } + + // + // VirtualHostSSLPanel methods + // + + public MutableProperty getEnabledProperty() { + return enabledProperty; + } + + public MutableProperty getIpProperty() { + return ipProperty; + } + + public MutableProperty getPortProperty() { + return portProperty; + } + + public MutableProperty getCertProperty() { + return certProperty; + } + + public MutableProperty getKeyProperty() { + return keyProperty; + } + + public void init(VirtualHost vHost) { + // Sanity check -- the UI should be updated only on the event thread + assert EventQueue.isDispatchThread(); + + FileSystemView fsView; + + if (vHost == null) { + fsView = FileSystemView.getFileSystemView(); + } else { + ApacheUtil.update(vHost.getSslEnabledProperty(), enabledProperty); + ApacheUtil.update(vHost.getSslIpProperty(), ipProperty); + ApacheUtil.update(vHost.getSslPortProperty(), portProperty); + ApacheUtil.update(vHost.getSslCertProperty(), certProperty); + ApacheUtil.update(vHost.getSslKeyProperty(), keyProperty); + + fsView = vHost.getParent().getFileSystemView(); + } + + for (JFileChooser c : fileChoosers) { + c.setFileSystemView(fsView); + } + } + + // + // Private methods + // + + private JPanel createForm() { + JCheckBox enabledCheckBox = new JCheckBox( + Finder.getString("vhost.ssl.edit.enable")); + + new CheckBoxPropertySynchronizer(enabledProperty, enabledCheckBox); + ChangeIndicator enabledChange = new ChangeIndicator(); + enabledProperty.addChangeListener(enabledChange); + + JLabel iPLabel = new JLabel( + Finder.getString("vhost.ssl.edit.ip")); + JTextField iPField = GUIUtil.createTextField(); + new TextComponentPropertySynchronizer( + ipProperty, iPField); + ChangeIndicator iPChange = new ChangeIndicator(); + ipProperty.addChangeListener(iPChange); + + JLabel portLabel = new JLabel( + Finder.getString("vhost.ssl.edit.port")); + + SpinnerNumberModel portModel = new SpinnerNumberModel(0, 0, + Short.MAX_VALUE, 1); + JSpinner portSpinner = new JSpinner(portModel); + + JComponent editor = portSpinner.getEditor(); + if (editor instanceof JSpinner.DefaultEditor) { + JTextField field = ((JSpinner.DefaultEditor)editor).getTextField(); + field.setColumns(5); + field.setHorizontalAlignment(JTextField.RIGHT); + } + + new SpinnerNumberModelPropertySynchronizer(portProperty, portModel, + false); + portProperty.save(); + + ChangeIndicator portChange = new ChangeIndicator(); + portProperty.addChangeListener(portChange); + + JLabel certLabel = new JLabel( + Finder.getString("vhost.ssl.edit.certificate")); + + BrowsableFilePanel certPanel = new BrowsableFilePanel(); + certPanel.setOpaque(false); + fileChoosers.add(certPanel.getFileChooser()); + + new TextComponentPropertySynchronizer( + certProperty, certPanel.getField()); + ChangeIndicator certChange = new ChangeIndicator(); + certProperty.addChangeListener(certChange); + + JLabel keyLabel = new JLabel( + Finder.getString("vhost.ssl.edit.key")); + + BrowsableFilePanel keyPanel = new BrowsableFilePanel(); + keyPanel.setOpaque(false); + fileChoosers.add(keyPanel.getFileChooser()); + + new TextComponentPropertySynchronizer( + keyProperty, keyPanel.getField()); + ChangeIndicator keyChange = new ChangeIndicator(); + keyProperty.addChangeListener(keyChange); + + JPanel formPanel = new JPanel(); + formPanel.setOpaque(false); + + Form form = new Form(formPanel, VerticalAnchor.TOP); + + int hGap = GUIUtil.getHalfGap(); + int sGap = 3 * hGap; + int indent = GUIUtil.getTextXOffset(enabledCheckBox); + + ColumnLayoutConstraint c = new ColumnLayoutConstraint( + HorizontalAnchor.FILL, hGap); + + RowLayoutConstraint r = new RowLayoutConstraint( + VerticalAnchor.CENTER, hGap); + + HasAnchors a = new SimpleHasAnchors( + HorizontalAnchor.LEFT, VerticalAnchor.CENTER); + + form.addRow(HorizontalAnchor.LEFT, c); + form.add(enabledCheckBox, r); + form.add(enabledChange, r); + + form.addTable(2, hGap, hGap, HorizontalAnchor.LEFT, c.setGap(sGap)); + form.add(iPLabel, a); + form.add(getRow(hGap, iPField, iPChange), a); + form.add(portLabel, a); + form.add(getRow(hGap, portSpinner, portChange), a); + form.add(certLabel, a); + form.add(getRow(hGap, certPanel, certChange), a); + form.add(keyLabel, a); + form.add(getRow(hGap, keyPanel, keyChange), a); + + return formPanel; + } + + // + // Private methods + // + + private JPanel getRow(int gap, Component comp1, Component comp2) { + JPanel panel = new JPanel(new BorderLayout(gap, 0)); + panel.setOpaque(false); + + panel.add(comp1, BorderLayout.CENTER); + panel.add(comp2, BorderLayout.EAST); + + return panel; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHostSSLValidationException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHostSSLValidationException.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +@SuppressWarnings({"serial"}) +public class VirtualHostSSLValidationException + extends VirtualHostValidationException { + + // + // Constructors + // + + public VirtualHostSSLValidationException(String id) { + super(id); + } + + public VirtualHostSSLValidationException(String id, String message) { + super(id, message); + } + + public VirtualHostSSLValidationException(String id, Throwable cause) { + super(id, cause); + } + + public VirtualHostSSLValidationException(String id, String message, + Throwable cause) { + super(id, message, cause); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHostValidationException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHostValidationException.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,71 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.panels.apache.client.swing; + +import com.oracle.solaris.vp.panel.common.action.ActionFailedException; + +@SuppressWarnings({"serial"}) +public class VirtualHostValidationException + extends ActionFailedException { + + // + // Instance data + // + + private String id; + + // + // Constructors + // + + public VirtualHostValidationException(String id) { + this.id = id; + } + + public VirtualHostValidationException(String id, String message) { + super(message); + this.id = id; + } + + public VirtualHostValidationException(String id, Throwable cause) { + super(cause); + this.id = id; + } + + public VirtualHostValidationException(String id, String message, + Throwable cause) { + super(message, cause); + this.id = id; + } + + // + // VirtualHostValidationException methods + // + + public String getId() { + return id; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/JavaHelpSearch/DOCS Binary file components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/JavaHelpSearch/DOCS has changed diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/JavaHelpSearch/DOCS.TAB --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/JavaHelpSearch/DOCS.TAB Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,5 @@ +eÿÿÿÿÿÿÿÿÝÿÿÿ÷_ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿý×ÿý×ÿÿÿÿÿÿÿÿÿÿÿÿ÷_ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ÷_ÿÿÿÿÿÿÿÿuuÿÿÿÿÿÿÿuÿÿÿÿý×ÿÿÿÿÿ÷]õÿÿÿÝÿÿÿÐ7ý”º0¬ÛŠºèꪩK0ºÿÌÊꌲª£ +Œ.ª¿¼Ø³ ÿêÌ.0ª+Ì.Œ+ê¼Âºª2.0³ +¿ÿî(»꫾ꪫ£ +¸Âªªªªªªªªªªªªªªª®ºªªª®Œ*ªªªªªªêªªªªªªºëŒ.ªï꺪Œ.몪0ª«ªŒ(È¿ÌŠºªªª£ +ªª«ªª¬Âꪪªªªªªª` \ No newline at end of file diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/JavaHelpSearch/OFFSETS --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/JavaHelpSearch/OFFSETS Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,1 @@ +ƒ–«5ÜÆh˜+Û‹Š€U.¬mŒVM(û V¬¶#V€ËèÃÓe [á€ÁÝ¥^Ö¿ì \ No newline at end of file diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/JavaHelpSearch/POSITIONS Binary file components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/JavaHelpSearch/POSITIONS has changed diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/JavaHelpSearch/SCHEMA --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/JavaHelpSearch/SCHEMA Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,2 @@ +JavaSearch 1.0 +TMAP bs=2048 rt=1 fl=-1 id1=512 id2=1 diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/JavaHelpSearch/TMAP Binary file components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/JavaHelpSearch/TMAP has changed diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-authentication.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-authentication.html Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + +

Changing User Credentials

+

Most panels let you make changes as a different user or role, as +well as making changes on a remote host. To change who you +are authenticated as or which system you want to administer, click the credentials +icon in the top right hand corner of the window, next to the +username. A dialog will open, prompting for a host and username. After +clicking the "Log In" button, you may be prompted to enter a password +or other system-defined credentials. If the user is already authenticated in another session, +you may not be prompted for a password.

+ +

After successfully authenticating as the specified user, you may be prompted to select +a role if any roles are assigned to the selected user. From this +dialog you may choose one of the roles or leave the entry as +none. After selecting a role, you may again be prompted for any necessary +passwords or credentials.

+ + +
+ + +Copyright © 2010, 2012, Oracle and/or its affiliates. All rights reserved. Legal Notices + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-global.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-global.html Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + +

Global Settings for the Apache Web Service

+

The Global Settings pane can be used to:

+ + + +

For more information see The Apache Web Server Panel.

+ + +
+ + +Copyright © 2010, 2012, Oracle and/or its affiliates. All rights reserved. Legal Notices + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-mimetypes.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-mimetypes.html Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + +

What are MIME Types in the Apache Service?

+

The Multipurpose Internet Mail Extensions (MIME) types configuration file defines the mappings from +file name extensions (like .html) to content types (like text/plain or text/html). The +behavior defines any handlers or filters that need to be used. The GUI +allows you to add new MIME types, which is equivalent to using the +AddType directive in Apache configuration file.

+ +

Most virtual hosts will not need any custom MIME types defined. These hosts +can rely on the default MIME settings to handle their requests. Occasionally, a +virtual host needs to serve a file for which a MIME type is +not defined, or for which an existing MIME type needs to be overridden. +For example, a virtual host may want to serve sound files with a +.snd extension, with the MIME type audio/x-audiphile-sound.

+ +

The following operations are supported from the Custom MIME types popup:

+ + +
  • A MIME type can be added or deleted

    + +
  • +
  • Properties of a MIME type can be edited

    + +
+

Each MIME type has the following properties:

+ + +
  • The MIME type (major type in Apache documentation) – such as text or image

    + +
  • +
  • The MIME subtype (minor type in Apache documentation) – such as plain, html or jpeg

    + +
  • +
  • The appropriate extensions – such as .text, .html or .jpeg

    + +
+

Multiple extensions can be added at one time. The extensions must start with +a dot “.”. The multiple entries can be separated by commas or a +space (such as jpeg, .jpg).

+ + +
+ + +Copyright © 2010, 2012, Oracle and/or its affiliates. All rights reserved. Legal Notices + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-modules.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-modules.html Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + +

What are Apache Modules?

+

An Apache module can enable operating system specific optimizations, manage how requests are +handled by the server, and define other important parameters. Most virtual hosts will +not need any custom modules added. These hosts can rely on the default +modules. Currently, the default modules are in /etc/apache2/2.2/conf.d/modules-[32|64]. Occasionally, a virtual host needs to +use some custom functionality not included in the Apache core module set. For +example, a virtual host may have extensive dynamic content written in PHP. To +get the Apache service to handle this content properly, the mod_php module would need +to be added.

+ +

From the Custom Modules popup, you can add or delete an Apache module. +Each module entry includes a name and the name of a shared library +file associated with it. Each name must be unique.

+ + +
+ + +Copyright © 2010, 2012, Oracle and/or its affiliates. All rights reserved. Legal Notices + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-overview.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-overview.html Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + +

The Apache Web Server Panel

+

The Apache Web service can be configured to make web pages visible on +the World Wide Web. Several web sites can be supported from one web +server by configuring many virtual hosts. The Apache Web Server panel is used +to configure global settings for all virtual hosts on the local system or +to configure individual virtual hosts.

+ +

At the top of the Apache Web Server panel are two pieces +of information. The Status field on the left shows if the web server is +enabled or not. The User field on the right shows the credential that +is being used by the tool. If you click on the lock +button on the far right, you can change the credential. See Changing User Credentials for more +information about changing the user credentials.

+ +

The panel includes the following components:

+ + + + +
+ + +Copyright © 2010, 2012, Oracle and/or its affiliates. All rights reserved. Legal Notices + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-portnum.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-portnum.html Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + +

Why Would I Change the Port Number for a Virtual Host?

+

By default, the Apache service listens for requests on port 80 and on +all IP addresses configured on the local host. By selecting a specific port +you can determine how each virtual host responds to different IP addresses, host +names and ports. This is equivalent to the Listen directive.

+ +

Multiple virtual hosts can listen on the same port. If there is ambiguity +as to which virtual host should serve a particular request, first the domain +names of the virtual hosts is compared with the domain name in the +incoming request. If they match then the matching virtual host is used. If +no match is found or no domain name was used in the request, +then one of the virtual hosts defined for that port is used.

+ + +
+ + +Copyright © 2010, 2012, Oracle and/or its affiliates. All rights reserved. Legal Notices + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-resources.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-resources.html Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + +

Additional Information Resources for the Apache Web Server Panel

+

For a complete description of the parameters associated with the Apache Web server +see: http://httpd.apache.org/docs/2.2

+ + +
+ + +Copyright © 2010, 2012, Oracle and/or its affiliates. All rights reserved. Legal Notices + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-server-configfile.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-server-configfile.html Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + +

Why Would I Use a Custom Configuration File with the Apache Server?

+

The Apache Web Server panel does not provide access to all Apache configuration +options. If your Apache configuration is too complex to be represented in the +Apache Web Server panel, you can use the custom configuration file option to +identify a complete Apache configuration file instead. A custom configuration file overrides all +other settings made in the Apache Web Server panel. This option is also +useful when you have a pre-existing Apache configuration file you wish to reuse.

+ + +
+ + +Copyright © 2010, 2012, Oracle and/or its affiliates. All rights reserved. Legal Notices + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-vhost-configfile.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-vhost-configfile.html Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + +

Why Would I Use a Custom Configuration File for a Virtual Host?

+

There are many configuration options or directives that can be used for a +virtual host that are not configurable using the Apache Web Server panel. A +custom configuration file lets you expand the options or directives that you need +to use while still using the panel to perform basic configuration tasks.

+ + +
+ + +Copyright © 2010, 2012, Oracle and/or its affiliates. All rights reserved. Legal Notices + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-vhosts-general.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-vhosts-general.html Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + +

General Settings for an Apache Virtual Host

+

The General tab is selected to change or view the following configuration information +for a selected virtual host:

+ + +
  • Whether the virtual host is enabled or disabled.

    + +
  • +
  • The port on which the virtual host is listening. For more information, see Why Would I Change the Port Number for a Virtual Host?.

    + +
  • +
  • The site or domain name. Note that the domain name must be unique among all virtual hosts.

    + +
  • +
  • The document root directory which identifies the directory that contains the files to be served.

    + +
  • +
  • Whether the host serves content from the public_html directory of a users' home directory. This shares ~user1/public_html/myfile.html as http://www.example.com/~user1/myfile.html.

    + +
  • +
  • The location of a custom configuration file that specifies additional Apache configuration parameters for the virtual host. See Why Would I Use a Custom Configuration File for a Virtual Host? for more information.

    + +
  • +
  • Specify which MIME types are defined for files served by the virtual hosts. For more information, see What are MIME Types in the Apache Service?.

    + +
+ +
+ + +Copyright © 2010, 2012, Oracle and/or its affiliates. All rights reserved. Legal Notices + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-vhosts-selector.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-vhosts-selector.html Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + +

Virtual Host Selection

+

The Virtual Host Selector is located on the left side of the Apache +Web Server panel. From the list you can:

+ + +
  • Select to view or edit the global settings for the Apache server.

    + +
  • +
  • Select to view or edit the configuration for a specific virtual host. A default virtual host called localhost comes predefined.

    + +
  • +
  • Add a new virtual host by clicking the New button and entering the domain name and the path to the document root in the popup.

    + +
  • +
  • Delete a virtual host by selecting the appropriate virtual host from the list and clicking the Delete button. A popup asks you to verify your selection before the virtual host is deleted.

    + +
+

You can right-click on the Virtual Host Selector pane to show a context +menu offering the actions listed above, as well as the option to enable, +disable or clone the selected virtual host.

+ +

For more information about the panel, see The Apache Web Server Panel.

+ + +
+ + +Copyright © 2010, 2012, Oracle and/or its affiliates. All rights reserved. Legal Notices + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-vhosts-ssl.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-vhosts-ssl.html Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + +

SSL Settings for an Apache Virtual Host

+

The SSL tab associated with each virtual host is used to enable encryption +with secure HTTP over the Secure Sockets Layer (SSL). SSL provides for secure +communication between client and server. The URLs needed to access this virtual host +would start with https: instead of http:. After selecting the SSL tab you +can make the following configuration changes:

+ + +
  • Enable or disable SSL

    + +
  • +
  • IP address

    + +
  • +
  • Port

    + +
  • +
  • Location of the certificate file which includes all of the certificate file for the server and also to the corresponding RSA or DSA private key file, if needed

    + +
  • +
  • Location of the key file which includes the private key for the server

    + +
+ +
+ + +Copyright © 2010, 2012, Oracle and/or its affiliates. All rights reserved. Legal Notices + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/apache.html Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + +

The Apache Web Server

+

The following topics are included:

+ + + + +
+ + +Copyright © 2010, 2012, Oracle and/or its affiliates. All rights reserved. Legal Notices + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/app.hs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/app.hs Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,50 @@ + + + + + +Visual Panels Help Text + + + + + + TOC + + javax.help.TOCView + toc.xml + + + Index + + javax.help.IndexView + index.xml + + + Search + + javax.help.SearchView + JavaHelpSearch + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/docinfo.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/docinfo.html Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + +

Copyright 2010, 2012

This +software and related documentation are provided under a license agreement containing restrictions on +use and disclosure and are protected by intellectual property laws. Except as expressly +permitted in your license agreement or allowed by law, you may not use, +copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display +any part, in any form, or by any means. Reverse engineering, disassembly, or +decompilation of this software, unless required by law for interoperability, is prohibited.

+ +

The information +contained herein is subject to change without notice and is not warranted to +be error-free. If you find any errors, please report them to us in +writing.

+ +

If this is software or related documentation that is delivered to the U.S. +Government or anyone licensing it on behalf of the U.S. Government, the following +notice is applicable:

+ +

U.S. GOVERNMENT END USERS. Oracle programs, including any operating system, integrated software, +any programs installed on the hardware, and/or documentation, delivered to U.S. Government end +users are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and +agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the programs, +including any operating system, integrated software, any programs installed on the hardware, and/or +documentation, shall be subject to license terms and license restrictions applicable to the +programs. No other rights are granted to the U.S. Government.

+ +

This software or hardware is +developed for general use in a variety of information management applications. It is +not developed or intended for use in any inherently dangerous applications, including applications +that may create a risk of personal injury. If you use this software +or hardware in dangerous applications, then you shall be responsible to take +all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. +Oracle Corporation and its affiliates disclaim any liability for any damages caused by +use of this software or hardware in dangerous applications.

+ +

Oracle and Java are registered +trademarks of Oracle and/or its affiliates. Other names may be trademarks of their +respective owners.

+ +

Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. +All SPARC trademarks are used under license and are trademarks or registered trademarks +of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron +logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a +registered trademark of The Open Group.

+ +

This software or hardware and documentation may +provide access to or information on content, products, and services from third parties. +Oracle Corporation and its affiliates are not responsible for and expressly disclaim all +warranties of any kind with respect to third-party content, products, and services. Oracle Corporation +and its affiliates will not be responsible for any loss, costs, or damages +incurred due to your access to or use of third-party content, products, or +services.

+ + +
+ + +Copyright © 2010, 2012, Oracle and/or its affiliates. All rights reserved. Legal Notices + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/index.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/index.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,26 @@ + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/map.jhm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/map.jhm Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/target.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/target.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,86 @@ + + + + + + +
+ Visual Panels Help Text + “Visual Panels Help Text” +
+
+
+ The Apache Web Server + “The Apache Web Server” +
+
+ The Apache Web Server Panel + “The Apache Web Server Panel” +
+
+ Virtual Host Selection + “Virtual Host Selection” +
+
+ Global Settings for the Apache Web Service + “Global Settings for the Apache Web Service” +
+
+ General Settings for an Apache Virtual Host + “General Settings for an Apache Virtual Host” +
+
+ SSL Settings for an Apache Virtual Host + “SSL Settings for an Apache Virtual Host” +
+
+ Why Would I Change the Port Number for a Virtual Host? + “Why Would I Change the Port Number for a Virtual Host?” +
+
+ Why Would I Use a Custom Configuration File with the Apache Server? + “Why Would I Use a Custom Configuration File with the Apache Server?” +
+
+ Why Would I Use a Custom Configuration File for a Virtual Host? + “Why Would I Use a Custom Configuration File for a Virtual Host?” +
+
+ What are MIME Types in the Apache Service? + “What are MIME Types in the Apache Service?” +
+
+ What are Apache Modules? + “What are Apache Modules?” +
+
+ Additional Information Resources for the Apache Web Server Panel + “Additional Information Resources for the Apache Web Server Panel” +
+
+ Changing User Credentials + “Changing User Credentials” +
+
diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/toc.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/toc.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/vispanelht.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/help/vispanelht.html Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + +

Visual Panels Help Text

+ +
+ + +Copyright © 2010, 2012, Oracle and/or its affiliates. All rights reserved. Legal Notices + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/apache-129.png Binary file components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/apache-129.png has changed diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/apache-32.png Binary file components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/apache-32.png has changed diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/global-16.png Binary file components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/global-16.png has changed diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/global-24.png Binary file components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/global-24.png has changed diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/global-32.png Binary file components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/global-32.png has changed diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/global-48.png Binary file components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/global-48.png has changed diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/modules-32.png Binary file components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/modules-32.png has changed diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/modules-48.png Binary file components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/modules-48.png has changed diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/modules-96.png Binary file components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/modules-96.png has changed diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/vhost-disabled-16.png Binary file components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/vhost-disabled-16.png has changed diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/vhost-disabled-24.png Binary file components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/vhost-disabled-24.png has changed diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/vhost-disabled-32.png Binary file components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/vhost-disabled-32.png has changed diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/vhost-enabled-16.png Binary file components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/vhost-enabled-16.png has changed diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/vhost-enabled-24.png Binary file components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/vhost-enabled-24.png has changed diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/vhost-enabled-32.png Binary file components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/images/vhost-enabled-32.png has changed diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/resources/Resources.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/resources/Resources.properties Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,137 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. +# + +# +# Global +# + +global.name = Global Settings +global.edit.modules = Modules... +global.edit.mimetypes = MIME Types... +global.edit.enable = Enable the Apache web server +global.edit.customfile = Use custom configuration: +global.edit.customfile.help = Specify an Apache httpd.conf-style file here to use in place of any other configuration defined within this application. +global.error.customfile.empty = Specify a custom configuration file to load. + +# +# Virtual Hosts +# + +vhosts.list.title = Virtual Hosts: +vhosts.action.clone.message = Specify a new domain name. +vhosts.action.clone.title = Clone Virtual Host +vhosts.action.create.button = New... +vhosts.action.create.title = Create a Virtual Host +vhosts.action.delete.button = Delete +vhosts.action.delete.confirm = Delete the {1} selected virtual hosts? +vhosts.action.delete.confirm.1 = Delete virtual host "{0}"? + +# +# Virtual Host - General +# + +vhost.general.name = General +vhost.general.edit.enable = Enable this virtual host +vhost.general.edit.port = Port: +vhost.general.edit.port.help = This field specifies the port on which this virtual host listens for HTTP requests. When SSL is enabled, this virtual host does not handle HTTP requests and this field is disabled. +vhost.general.edit.domain = Domain Name: +vhost.general.edit.docroot = Document Root: +vhost.general.edit.homedirs = Share user public_html directories +vhost.general.edit.customfile = Include custom configuration: +vhost.general.edit.customfile.help = Specify an Apache httpd.conf-style file here to amend this virtual host''s configuration in a custom manner. +vhost.general.edit.mimetypes = MIME Types... +vhost.general.edit.modules = Modules... +vhost.general.error.domain.empty = Specify a domain name for this virtual host. +vhost.general.error.domain.invalid = "{0}" is not a valid domain name. Spaces and special characters are not allowed. +vhost.general.error.domain.duplicate = Multiple virtual hosts with same domain ("{0}") may not be enabled simultaneously. +vhost.general.error.docroot.empty = Specify a document root directory for this virtual host. +vhost.general.error.customfile.empty = Specify a custom configuration file to load. + +# +# Virtual Host - Ssl +# + +vhost.ssl.name = SSL +vhost.ssl.edit.enable = Enable SSL (HTTPS) +vhost.ssl.edit.ip = IP Address: +vhost.ssl.edit.port = Port: +vhost.ssl.edit.certificate = Certificate: +vhost.ssl.edit.key = Key File: +vhost.ssl.error.ip.invalid = "{0}" is not a valid local IP address. +vhost.ssl.error.ip.empty = SSL configuration requires a local IP address. +vhost.ssl.error.ip.syserror = A system error occurred when validating input. +vhost.ssl.error.cert.empty = SSL configuration requires an SSL Certificate. +vhost.ssl.error.key.empty = SSL configuration requires an SSL Key. + +# +# MIME types +# + +mimetypes.title = Custom MIME types +mimetypes.list.title = MIME Types: +mimetypes.default.message = No MIME types are defined. Click the "{0}" button to create one. +mimetypes.action.create.button = New... +mimetypes.action.create.title = Create a MIME Type +mimetypes.action.delete.button = Delete +mimetypes.action.delete.confirm = Delete the {1} selected MIME types? +mimetypes.action.delete.confirm.1 = Delete MIME type "{0}"? + +# +# MIME type +# + +mimetype.edit.extensions = Extensions: +mimetype.edit.subtype = Subtype: +mimetype.edit.type = Type: +mimetype.error.duplicate = A MIME type already exists for "{0}/{1}". +mimetype.error.subtype.empty = Specify the MIME subtype. +mimetype.error.subtype.invalid = Invalid MIME subtype: "{0}" +mimetype.error.type.empty = Specify the MIME type. +mimetype.error.type.invalid = Invalid MIME type: "{0}" + +# +# Modules +# + +modules.title = Custom Modules +modules.list.title = Modules: +modules.default.message = No modules are defined. Click the "{0}" button to create one. +modules.action.create.button = New... +modules.action.create.title = Create a Module +modules.action.create.message = Specify a domain name for the new virtual host. +modules.action.delete.button = Delete +modules.action.delete.confirm = Delete the {1} selected modules? +modules.action.delete.confirm.1 = Delete module "{0}"? + +# +# Module +# + +module.edit.name = Name: +module.edit.file = File: +module.error.duplicate = A module named "{0}" already exists. +module.error.name.empty = Specify the name of the module. +module.error.name.invalid = Invalid module name: "{0}"\n\nModule names may not contain spaces. +module.error.file.empty = Specify the module file. diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/system-management-visual-panels-panel-apache-message-files.p5m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/system-management-visual-panels-panel-apache-message-files.p5m Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,58 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +set name=pkg.fmri value=pkg://$(PUBLISHER_LOCALIZABLE)/system/management/visual-panels/panel-apache-message-files@$(IPS_COMPONENT_VERSION),$(BUILD_VERSION) +set name=pkg.summary value="Translatable content for Apache Web Server Administration GUI" +set name=info.classification value="org.opensolaris.category.2008:Applications/Configuration and Preferences" +set name=org.opensolaris.consolidation value=$(CONSOLIDATION) +set name=org.opensolaris.arc-caseid value=LSARC/2007/392 + +license ../vpanels.copyright license=Oracle + +dir path=usr +dir path=usr/share +dir path=usr/share/vpanels +dir path=usr/share/vpanels/__LOCALE__ +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/resources/Resources.properties +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-vhosts-general.html +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/target.xml +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-overview.html +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-modules.html +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-mimetypes.html +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-resources.html +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-vhost-configfile.html +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-vhosts-ssl.html +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/apache.html +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/toc.xml +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/map.jhm +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-server-configfile.html +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-global.html +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-portnum.html +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-vhosts-selector.html +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/app.hs +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/apache-authentication.html +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/index.xml +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/vispanelht.html +file path=usr/share/vpanels/__LOCALE__/com/oracle/solaris/vp/panels/apache/client/swing/help/docinfo.html diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/apache/system-management-visual-panels-panel-apache.p5m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/apache/system-management-visual-panels-panel-apache.p5m Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,59 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +set name=pkg.fmri value=pkg:/system/management/visual-panels/panel-apache@$(IPS_COMPONENT_VERSION),$(BUILD_VERSION) +set name=pkg.summary value="Apache Web Server Administration GUI" +set name=info.classification value="org.opensolaris.category.2008:Applications/Configuration and Preferences" +set name=org.opensolaris.consolidation value=$(CONSOLIDATION) +set name=org.opensolaris.arc-caseid value=LSARC/2007/392 + +license ../vpanels.copyright license=Oracle + +depend fmri=pkg:/system/management/visual-panels-core@$(IPS_COMPONENT_VERSION),$(BUILD_VERSION) type=require +depend fmri=pkg:/system/management/visual-panels/panel-apache/locale type=require +depend fmri=pkg:/web/server/apache-22 type=require +depend fmri=pkg:/web/server/apache-22/module/apache-php5 type=require + +dir path=etc +dir path=etc/vpanels group=sys +dir path=lib +dir path=lib/svc +dir path=lib/svc/manifest +dir path=lib/svc/manifest/network +dir path=lib/svc/method +dir path=usr +dir path=usr/share +dir path=usr/share/applications +dir path=usr/share/vpanels +dir path=usr/share/vpanels/app +dir path=usr/share/vpanels/conf +dir path=usr/share/vpanels/pixmaps +file path=etc/vpanels/httpd_conf.templ group=sys +file path=lib/svc/manifest/network/http-vpanels.xml +file path=lib/svc/method/http-vpanels mode=0555 +file path=usr/share/applications/vp-apache.desktop +file path=usr/share/vpanels/app/vpanels-panels-apache.jar +file path=usr/share/vpanels/conf/apache.xml +file path=usr/share/vpanels/pixmaps/apache.png diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,63 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +include ../../../make-rules/shared-macros.mk + +GMAKE = /usr/bin/make + +COMPONENT_NAME = visual-panels-core +COMPONENT_VERSION = 0.5.11 +COMPONENT_SRC = src + +include $(WS_MAKE_RULES)/justmake.mk +include $(WS_MAKE_RULES)/ips.mk + +COMPONENT_BUILD_TARGETS = build +COMPONENT_BUILD_ENV += ROOT=$(PROTO_DIR) +COMPONENT_BUILD_ENV += SRC=$(WS_COMPONENTS)/visual-panels +COMPONENT_BUILD_ENV += WS_JAVA=$(BUILD_DIR_32)/java +COMPONENT_BUILD_ENV += JAVA_HOME=/usr/java +COMPONENT_BUILD_ENV += PATH=$(dir $(CC)):/usr/bin +COMPONENT_BUILD_ENV += MACH32=$(MACH32) + +COMPONENT_INSTALL_TARGETS = install +COMPONENT_INSTALL_ENV = $(COMPONENT_BUILD_ENV) + +COMPONENT_TEST_TARGETS = test +COMPONENT_TEST_ENV = $(COMPONENT_BUILD_ENV) + +# common targets +$(SOURCE_DIR)/.prep: + $(TOUCH) $@ + +prep: $(SOURCE_DIR)/.prep + +build: $(BUILD_32) + +install: $(INSTALL_32) + +CLEAN_PATH += $(SOURCE_DIR)/.prep + +BUILD_PKG_DEPENDENCIES = $(BUILD_TOOLS) + +include $(WS_MAKE_RULES)/depend.mk diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/developer-opensolaris-vpanels.p5m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/developer-opensolaris-vpanels.p5m Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,35 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +set name=pkg.fmri value=pkg:/developer/opensolaris/vpanels@$(IPS_COMPONENT_VERSION),$(BUILD_VERSION) +set name=pkg.summary value="Dependencies required to build the Visual Panels Consolidation" +set name=info.classification value="org.opensolaris.category.2008:Development/Distribution Tools" +set name=org.opensolaris.consolidation value=$(CONSOLIDATION) +set name=org.opensolaris.arc-caseid value=LSARC/2007/392 + +license ../vpanels.copyright license=Oracle + +depend fmri=pkg:/runtime/java/jre-6 type=require +depend fmri=pkg:/developer/java/jdk-6 type=require diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,34 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +include $(SRC)/make-rules/Makefile.env + +cmd: java +doc: java cmd + +qinstall: + $(MAKE) install ANT='ant -Dquick=true' + +include $(SRC)/make-rules/Makefile.targ diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/apis/file.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/apis/file.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/apis/network.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/apis/network.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/apis/panels.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/apis/panels.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/apis/smf.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/apis/smf.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,1929 @@ + + + + + + + + This API exposes common SMF configuration, actions, and state to + rad(1m) clients. + + + + Three core interfaces are provided: + + + + + Master - a top-level object providing access + to all services and instances on the system + + + Service - an object that represents an SMF + service + + + Instance - an object that represents an SMF + instance + + + + + The latter two interfaces, Service and Instance, are derived from a common Entity interface. + + + + Python SMF wrapper + + + + Provided alongside this API is a convenience wrapper around the + Python bindings to this API. Accessible by importing + smf.rad from within a Python application, this wrapper + simplifies access to the Master, Service, and Instance + objects. + + + + Run /usr/bin/pydoc smf.rad for more information. + + + + + + + + indicates how dependencies are evaluated + + + + all dependencies must be satisfied + + + + + only one dependency must be satisfied + + + + + no dependency may be satisfied + + + + + all satisfiable dependencies must be satisfied + + + + + + + describes when the dependent should be restarted + + + + restart when a dependency encounters an error + + + + + restart any time a dependency restarts + + + + + restart when a dependency is refreshed + + + + + only process dependencies when starting instance + + + + + + + describes a dependency group + + + Fully describes a dependency group, including + the FMRIs for the dependencies, the type of + dependency, and when the dependency should be + evaluated. + + + + the name of the dependency group + + + + + the list of dependencies' FMRIs + + + + + + how the dependencies are evaluated + + + + + when the dependent should be restarted + + + + + + an SMF property type + + + + + + + + + + + + + + + + + + + an SMF property and its values + + Describes a property, its type, and all its values. + + + the name of the property + + + the type of the property + + + all the property's values + + A list of all the values held by the + property. A single-valued property + will have a list of length 1. A + property with no values will have a + list of length 0. + + + + + + + a description of a man page + + Provides all the information needed to find a + man page. The referenced man page can be + displayed by running MANPATH=$path man + -s $section $title. + + + the man page name + + + the section the man page is found in + + + the path the man page is found in + + The colon-separated MANPATH the + man page is found in. If this field + has no value, the default + MANPATH should to be used. + + + + + + an on-line documentation link + + an informative name for the document + + + the URI of the document + + + + + an SMF property group + + the name of the property group + + + the type of the property group + + + the property group flags + + + + + template data for a property group + + the property group name + + + the property group type + + + is the property group required? + + + a localized name + + + a localized description + + + + + the recommended visibility of a property + + the property shouldn't be displayed + + + + the property isn't intended to be modified + + + + the property is modifiable + + + + + template data for a property + + the name of the property + + + the type of the property + + + is the property required? + + + a localized name + + + a localized description + + + a localized units label + + + how the property should be presented + + + the minimum number of values + + + the maximum number of values + + + value separator characters + + Separator characters used to embed + multiple values in a single property + value. + + + + + + + + a change to make to a property + + the property to change + + + the type of the property to write + + + a list of values + + + + + + the general cause for failure + + Indicates the general cause for failure. + Specific meanings are defined by the individual + APIs. + + + an internal error occurred + + + access denied + + + configuration database is read only + + + named object wasn't found + + + name is already in use + + + an illegal value was supplied + + + system was in an invalid state + + + API was called incorrectly + + + + + + + + + + + + + + + + + + + + + functionality common to services and instances + + + + + the service/instance's FMRI + + + + + + the service/instance's scope + + + + + + the service name of the service/instance + + + + + + the service/instance's dependencies + + + A list of dependency objects describing + the full nature of each dependency. An + empty list is returned if there are no + dependencies. + + + + + An internal SMF error occurred. + + + + + + + the service/instance's manual pages + + + A list of manual page objects + describing the name, section, and path + of each relevant manual page. An empty + list is returned if no manual pages are + defined. + + + + + An internal SMF error occurred. + + + + + + + documentation links + + + A list of links to on-line + documentation for the + service/instance. An empty list is + returned if no on-line documents are + defined. + + + + + An internal SMF error occurred. + + + + + + + directly-attached property groups + + + A list of all directly-attached + property groups, including name, + type and flags for each. + + + + + An internal SMF error occurred. + + + + + + + delete the service/instance + + + Delete the service or instance. + + + + + Failed to delete the service or + instance. Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + READONLY - + the repository is read-only + + EXISTS - + delete was called on a service + and the service still had + instances + + + + + + + + + delete administrative customizations + + + Delete all administrative customizations + applied to a service/instance and its + children, if any exist. + + + + + Failed to delete the administrative + customizations applied to a service or + instance. Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + READONLY - + the repository is read-only + + + + + + + + + create a property group + + + Create a property group on the + service/instance. + + + + + Failed to create the property + group. Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + READONLY - + the repository is read-only + + EXISTS - + the propery group already exists + + BADVALUE - + an invalid property group name + or type was specified + + + + + + + the name of the new property group + + + + + the type of the new property group + + + + + the property group flags + + + + + + + delete a property group + + + Delete a directly-attached property + group and all its properties from the + service/instance. + + + + + Failed to delete the property + group. Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + READONLY - + the repository is read-only + + NOTFOUND - + the property group doesn't exist + + + + + + + the name of the property group + + + + + + + delete administrative customizations + + + Delete all administrative customizations + applied to a property group and its children, + if any exist. + + + + + Failed to delete the administrative customizations + applied to a property group. Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + READONLY - + the repository is read-only + + NOTFOUND - + the property group doesn't + exist + + + + + + + the name of the property group + + + + + + + reads all properties in a directly-attached + property group + + + Read all properties in the specified + directly-attached property group. The + name, type, and values of each property + are included. + + + + a list of properties in the + specified directly-attached + property group + + + + + + + Failed to read properties from + the property group. Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + NOTFOUND - + the property group doesn't exist + + + + + + + the name of the property group + + + + + + + commit a list of property changes to a + property group + + + + Commit a set of property changes to + the specified property group. Each + property change specifies a property, + type, and optional set of values. If + the property specified by a property + change doesn't exist prior to the call, + it will be created by the call. If the + property specified by a property change + exists prior to the call but has a + different type, its type will be set to + the type specified by the call. + + + If the call succeeds, all the requested + property changes were made. If the + call fails, none of the requested + changes were made. + + + + + + Failed to make all the + requested property changes. + Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + READONLY - + the repository is read-only + + NOTFOUND - + the property group doesn't + exist (see target) + + BADVALUE - + a property had an invalid name, + or a value couldn't be + converted to the requested type + (see target, aux) + + INVALID - + the same property was + referenced by two + PropertyChanges. + + + + When an invidual property is + the cause of the error, its + name will be returned in + aux. + + + + + + the name of the property group + + + + + the set of changes to apply + + + + + + + + read a single directly-attached property's + values + + + Read a single property from the + specified directly-attached property + group. The result includes the name, + type, and values of the property. + + + + the specified property + + + + + + Failed to read the specified + property. Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + NOTFOUND - + the property or property group + doesn't exist (see target) + + + + + + + the name of the property group + + + + + the name of the property + + + + + + + writes a list of values to a property + + + + Change the specified property. If the + property doesn't exist prior to the + call, it will be created by the call. + If the property exists prior to the + call but has a different type, its + type will be set to the type + specified by the call. + + + + + + Failed to make the requested + property change. Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + READONLY - + the repository is read-only + + NOTFOUND - + the property group doesn't + exist (see target) + + BADVALUE - + the property had an invalid + name, or a value couldn't be + converted to the requested type + (see target) + + + + + + + the name of the property group + + + + + the name of the property + + + + + the type of the property + + + + + the new values for the property + + + + + + + + delete a property + + + + Delete a property from the service/instance. + + + + + + Failed to delete the property. + Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + READONLY - + the repository is read-only + + NOTFOUND - + the property group doesn't + exist, or the property to + be deleted doesn't exist (see + target) + + BADVALUE - + the property had an invalid + name or type (see target) + + INVALID - + the property cannot be deleted + while in use (see target) + + + + + + + the name of the property group + + + + + the name of the property + + + + + + + delete administrative customizations + + + Delete all administrative customizations + applied to this property. + + + + + Failed to delete the administrative customizations + applied to this property. Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + READONLY - + the repository is read-only + + NOTFOUND - + the property group, or property + doesn't exist (see target) + + + + + + + the name of the property group + + + + + the name of the property + + + + + + + obtain the service/instance's localized + common name + + + Obtain the localized common name for the + service/instance, if one exists. If a + common name doesn't exist for the + specified locale, attempts to return + the common name for the "C" locale + instead. + + + + the common name if available, or null + + + + + An internal error occurred. + + + + + the desired locale + + + + + + + obtain the service/instance's localized + description + + + Obtain the localized description for + the service/instance, if one exists. + If a description doesn't exist for the + specified locale, attempts to return + the description for the "C" locale + instead. + + + + the description if available, or null + + + + + An internal error occurred. + + + + + the desired locale + + + + + + + obtain all property group templates + + + Obtain all property group templates + for this service/instance. If + templates aren't provided for the + specified locale, attempts to return + the templates for the "C" locale + instead. + + + + all available property group templates + + + + + + An internal error occurred. + + + + + the desired locale + + + + + + + obtain all property templates for a + property group + + + Obtain all property templates for the + specified property group of this + service/instance. If property + templates aren't provided for the + specified locale, attempts to return + the templates for the "C" locale + instead. If no templates exist for + properties of the specified property + group, an empty list is returned. + + + + all available property templates + + + + + + An internal error occurred. + + + + + the name of the property group + + + + + the type of the property group + + + + + the desired locale + + + + + + + + + + an SMF service object + + + + The Service interface is an Entity that + represents an SMF service. Handles to this type of object can be + retrieved from the RAD server using an object name built with: + + + + + the "com.oracle.solaris.rad.smf" domain name + + + a key named "type" paired with a value of + "Service" + + + a key named "service" paired with the service portion of + an SMF FMRI + + + + + Object names for services can be pulled from the Services exposed by the Master.services property. Or, they can be + built directly: + + + +import rad.client +import rad.util + +# Create a connection +radconn = rad.util.connect_unix() + +# Retrieve a particular service +service_name = rad.client.Name("com.oracle.solaris.rad.smf", + [("type", "Service"), ("service", "network/physical")]) +# Get a native-looking python object that throws RAD exceptions +service = radconn.get_object(service_name) + +# Do something with our service +print "service %s has %d instances" % (service.fmri, len(service.instances)) + + + If using the Python SMF convenience wrapper delivered with this + API, this can be simplified to: + + + +import smf.rad + +repo = smf.rad.Repository() + +# Retrieve a particular service +service = repo.lookup_byfmri("svc:/network/physical") + +# Do something with our service +print "service %s has %d instances" % (service.fmri, len(service.instances)) + + + + + + + + the list of instances of this service + + + The list of instances of this service. + An empty list if the service has no + instances. + + + + + An internal SMF error occurred. + + + + + + + + + + + the state of an SMF instance + + + + + + + + + + + + + + + extended instance state information + + + the current state of the instance + + + the next state of the instance + + + the auxiliary state of the instance + + + the time of last state change + + + the contract ID, or -1 if none + + + is the instance enabled? + + + is the instance enabled temporarily? + + Indicates if the instance is enabled + temporarily. If the instance isn't + enabled or disable temporarily, this + mirrors the value of enabled. + + + + + + instance log data + + the log file's name + + + the log file's size + + + the log file's modification time + + + log file contents + + + + + an SMF instance object + + + + The Instance interface is an Entity + that represents an SMF instance. Handles to this type of object can be + retrieved from the RAD server using an object name built with: + + + + + the "com.oracle.solaris.rad.smf" domain name + + + a key named "type" paired with a value of + "Instance" + + + a key named "service" paired with the service portion of + an SMF FMRI + + + a key named "instance" paired with the instance portion of + an SMF FMRI + + + + + Object names for instances can be pulled from the Instances exposed by the Master.instances property. Or, they can be + built directly: + + + +import rad.client +import rad.util + +# Create a connection +radconn = rad.util.connect_unix() + +# Retrieve a particular instance +instance_name = rad.client.Name("com.oracle.solaris.rad.smf", + [("type", "Instance"), ("service", "network/physical"), + ("instance", "default")]) +# Get a native-looking python object that throws RAD exceptions +instance = radconn.get_object(instance_name) + +# Do something with our instance +print "instance %s state: %s" % (instance.fmri, instance.state) + + + If using the Python SMF convenience wrapper delivered with this + API, this can be simplified to: + + + +import smf.rad + +repo = smf.rad.Repository() + +# Retrieve a particular instance +instance = repo.lookup_byfmri("svc:/network/physical:default") + +# Do something with our instance +print "instance %s state: %s" % (instance.fmri, instance.state) + + + + + + + the name of the instance + + + the fmri of the instance's restarter + + + An internal SMF error occurred. + + + + + is the instance effectively enabled? + + + An internal SMF error occurred. + + + + + the current state of the instance + + + An internal SMF error occurred. + + + + + the extended state of the instance + + + An internal SMF error occurred. + + + + + a list of the instance's snapshots + + + + An internal SMF error occurred. + + + + + + + read all property groups in the + composed view of the specified snapshot + + + + + + + + Failed to read the list of + property groups. Cause: + + + INTERNAL - + an internal error occurred + + NOTFOUND - + the snapshot doesn't exist + + + + + + + the name of the snapshot, or null for the running snapshot + + + + + + + reads all properties in the composed view + of the specified snapshot of a property group + + + + + + + + Failed to read properties from + the snapshot's composed view of + the specified property group. + Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + NOTFOUND - + the property group or snapshot + doesn't exist (see target) + + + + + + + the name of the snapshot, or null for the running snapshot + + + + + the name of the property group + + + + + + + reads a property in the composed view + of the specified snapshot + + + Reads a single property from the + composed view of the specified property + group. The result includes the name, + type, and values of the property. + + + + + + Failed to read the property. + Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + NOTFOUND - + the snapshot, property group, + or property doesn't exist (see + target) + + + + + + + the name of the snapshot, or null for the running snapshot + + + + + the name of the property group + + + + + the name of the property + + + + + + + clear the instance if degraded or in maintenance + + + Attempt to clear the maintenance or + degraded state from the instance. This + operation occurs asynchronously, and + will return success even though the + attempt could fail. + + + + + Was unable to attempt clearing + the instance. Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + READONLY - + the repository is read-only + + BADSTATE - + the instance wasn't in the + maintenance or degraded state + + + + + + + + + + restarts the instance + + + Attempt to restart the instance. This + operation occurs asynchronously, and + will return success even though the + attempt could fail. + + + + + Was unable to attempt + restarting the instance. + Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + READONLY - + the repository is read-only + + + + + + + + + + refresh the instance + + + Attempt to refresh the instance. This + operation occurs asynchronously, and + will return success even though the + attempt could fail. + + + + + Was unable to attempt + restarting the instance. + Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + READONLY - + the repository is read-only + + + + + + + + + + place the instance in maintenance + + + Attempt to place the instance in + maintenance. This operation occurs + asynchronously, and will return success + even though the attempt could fail. + + + + + Was unable to attempt to place + the instance in maintenance. + Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + READONLY - + the repository is read-only + + + + + + + skip attempting a clean shutdown + + + + + maintenance doesn't persist after reboot + + + + + + + + enable the instance + + + Enable the instance. This operation is + idempotent; enabling an enabled + instance has no effect. + + + + + Was unable to enable the + instance. Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + READONLY - + the repository is read-only + + + + + + + enable doesn't persist after reboot + + + + + + + + disable the instance + + + Disable the instance. This operation + is idempotent; disabling a disabled + instance has no effect. + + + + + Was unable to disable the + instance. Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + READONLY - + the repository is read-only + + + + + + + disable doesn't persist after reboot + + + + + + + + obtain instance log file data + + + Obtain information from and about the + instance's log file. Includes the + name, size, modification time, and + contents. + + + + the requested log file data + + + + + + Was unable to obtain log data. + Cause: + + + INTERNAL - + an internal error occurred + + DENIED - + insufficient authorization + + NOTFOUND - + no log file found + + + + + + + bytes of log file content to return + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + a top-level object providing access to all services and instances on + the system + + + + + The Master interface provides an iterative entrypoint into the + SMF subsystem. Handles to this type of object can be retrieved from the + RAD server using an object name built with: + + + + + the "com.oracle.solaris.rad.smf" domain name + + + a key named "type" paired with a value of + "Master" + + + + + For example, to report the number of services in the ONLINE state: + + + +import rad.client +import rad.util + +# Create a connection +radconn = rad.util.connect_unix() + +# Retrieve the Master object +master_name = rad.client.Name("com.oracle.solaris.rad.smf", + [("type", "Master")]) +# Get a native-looking python object that throws RAD exceptions +master = radconn.get_object(master_name) + +# Retrieve a handle to the SMFState enum +SMFState = rad.client.get_types(master).SMFState + +# Do something with the Master object +print "%d service instances are online" % \ + len([x for x in master.instances if x.state is SMFState.ONLINE]) + + + If using the Python SMF convenience wrapper delivered with this + API, this can be simplified to: + + + +import smf.rad + +# Get quick access to the Master interface +repo = smf.rad.Repository() +master = repo.get_master() + +# Retrieve a handle to the SMFState enum +SMFState = rad.client.get_types(master).SMFState + +# Do something with the master object +print "%d service instances are online" % \ + len([x for x in master.instances if x.state is SMFState.ONLINE]) + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/apis/smf_old.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/apis/smf_old.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,382 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/apis/time.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/apis/time.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/cmd/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/cmd/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,30 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +include $(SRC)/make-rules/Makefile.env + +.PARALLEL: $(SUBDIRS) + +include $(SRC)/make-rules/Makefile.targ diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/cmd/rad/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/cmd/rad/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,32 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +include $(SRC)/make-rules/Makefile.env + +build: + +.PARALLEL: $(SUBDIRS) + +include $(SRC)/make-rules/Makefile.targ diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/cmd/rad/mod/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/cmd/rad/mod/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,41 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +include $(SRC)/make-rules/Makefile.env + +MODULE_SUBDIRS = \ + files \ + network \ + panels \ + smf_old + +MODULE_SUBDIRS_sparc = $(MODULE_SUBDIRS) +MODULE_SUBDIRS_i386 = $(MODULE_SUBDIRS) + +SUBDIRS = $(MODULE_SUBDIRS_$(ISA)) + +.PARALLEL: $(SUBDIRS) + +include $(SRC)/make-rules/Makefile.targ diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/cmd/rad/mod/files/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/cmd/rad/mod/files/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,35 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +include $(SRC)/make-rules/Makefile.env + +MOD_APIS=file +MOD_OBJS=mod_files.o +MOD_LIBNAME=mod_files.so +MOD_INSTALLDIR=$(RADDIR_MODULE) +APISDIR=../../../../apis + +include $(SRC)/make-rules/Makefile.com + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/cmd/rad/mod/files/mod_files.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/cmd/rad/mod/files/mod_files.c Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,192 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * Unfortunately, the behavior this module has inherited is not one + * of "get me information about file X or directory Y", but "tell me + * what calling 'new File(X)' would do in Java". This includes + * nonsense like manufacturing correct fake data for nonexistent + * files. + * + * This sorely needs to be ripped out and replaced with a sane + * api. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "api_file.h" + +static data_t * +empty_file(data_t *data, const char *apath, const char *cpath) +{ + struct_set(data, "absolutePath", data_new_string(apath, lt_copy)); + struct_set(data, "canonicalPath", data_new_string(cpath, lt_copy)); + struct_set(data, "canonical", data_new_boolean(B_TRUE)); + struct_set(data, "baseName", data_new_string("", lt_copy)); + struct_set(data, "exists", data_new_boolean(B_FALSE)); + struct_set(data, "readable", data_new_boolean(B_FALSE)); + struct_set(data, "writable", data_new_boolean(B_FALSE)); + struct_set(data, "hidden", data_new_boolean(B_FALSE)); + struct_set(data, "directory", data_new_boolean(B_FALSE)); + struct_set(data, "file", data_new_boolean(B_FALSE)); + struct_set(data, "lastModified", data_new_time(0, 0)); + struct_set(data, "length", data_new_long(0)); + struct_set(data, "freeSpace", data_new_long(0)); + struct_set(data, "totalSpace", data_new_long(0)); + struct_set(data, "usableSpace", data_new_long(0)); + return (data_purify(data)); +} + +static data_t * +read_file(const char *path, const char *file) +{ + struct stat64 st; + char apath[PATH_MAX] = ""; + char cpath[PATH_MAX] = ""; + const char *name = file != NULL ? file : path; + + data_t *data = data_new_struct(&t__FileSnapshot); + struct_set(data, "path", data_new_string(name, lt_copy)); + struct_set(data, "absolute", data_new_boolean(name[0] == '/')); + + if (path[0] != '/') { + if (getcwd(apath, PATH_MAX) == NULL) { + data_free(data); + return (NULL); + } + if (apath[1] != '\0') + (void) strlcat(apath, "/", PATH_MAX); + (void) strlcat(apath, path, PATH_MAX); + } else { + (void) strlcpy(apath, path, PATH_MAX); + } + + if (resolvepath(apath, cpath, PATH_MAX) == -1 || + stat64(path, &st) == -1) + return (empty_file(data, apath, apath)); + + struct_set(data, "absolutePath", data_new_string(apath, lt_copy)); + struct_set(data, "canonicalPath", data_new_string(cpath, lt_copy)); + struct_set(data, "canonical", + data_new_boolean(strcmp(apath, cpath) == 0)); + struct_set(data, "baseName", data_new_string(basename(apath), lt_copy)); + struct_set(data, "exists", data_new_boolean(B_TRUE)); + struct_set(data, "readable", data_new_boolean(access(path, R_OK) == 0)); + struct_set(data, "writable", data_new_boolean(access(path, W_OK) == 0)); + struct_set(data, "hidden", data_new_boolean(B_FALSE)); + struct_set(data, "directory", data_new_boolean(S_ISDIR(st.st_mode))); + struct_set(data, "file", data_new_boolean(S_ISREG(st.st_mode))); + struct_set(data, "lastModified", data_new_time_ts(&st.st_mtim)); + /* XXX: 64-bitify */ + struct_set(data, "length", data_new_long(st.st_size)); + struct_set(data, "freeSpace", data_new_long(0)); + struct_set(data, "totalSpace", data_new_long(0)); + struct_set(data, "usableSpace", data_new_long(0)); + return (data_purify(data)); +} + +/* ARGSUSED */ +conerr_t +interface_FileBrowser_read_roots(rad_instance_t *inst, adr_attribute_t *attr, + data_t **data, data_t **error) +{ + data_t *result = data_new_array(&t_array__FileSnapshot, 1); + (void) array_add(result, read_file("/", NULL)); + *data = data_purify(result); + return (ce_ok); +} + +/* ARGSUSED */ +conerr_t +interface_FileBrowser_invoke_getFile(rad_instance_t *inst, adr_method_t *meth, + data_t **ret, data_t **args, int count, data_t **error) +{ + *ret = read_file(data_to_string(args[0]), NULL); + return (ce_ok); +} + +/* ARGSUSED */ +conerr_t +interface_FileBrowser_invoke_getFiles(rad_instance_t *inst, adr_method_t *meth, + data_t **ret, data_t **args, int count, data_t **error) +{ + const char *path = data_to_string(args[0]); + DIR *d = opendir(path); + struct dirent *ent; + data_t *result; + + if (d == NULL) + return (ce_object); + + result = data_new_array(&t_array__FileSnapshot, 1); + while ((ent = readdir(d)) != NULL) { + char buf[PATH_MAX]; + if (strcmp(ent->d_name, ".") == 0 || + strcmp(ent->d_name, "..") == 0) + continue; + int len = strlen(path); + while (len > 0 && path[len - 1] == '/') + len--; + (void) snprintf(buf, PATH_MAX, "%.*s/%s", len, path, + ent->d_name); + data_t *file = read_file(buf, NULL); + if (file != NULL) + (void) array_add(result, file); + } + (void) closedir(d); + *ret = data_purify(result); + + return (ce_ok); +} + +static rad_modinfo_t modinfo = { "files", "File Browser module" }; + +int +_rad_init(void *handle) +{ + if (rad_module_register(handle, RAD_MODVERSION, &modinfo) == -1) + return (-1); + + if (rad_isproxy) + return (0); + + (void) cont_insert_singleton(rad_container, adr_name_fromstr( + "com.oracle.solaris.vp.panel.common.api.file:type=FileBrowser"), + &interface_FileBrowser_svr); + + return (0); +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/cmd/rad/mod/network/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/cmd/rad/mod/network/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,37 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +include $(SRC)/make-rules/Makefile.env + +LDLIBS += -lsocket -lnsl + +MOD_APIS=network +MOD_OBJS=mod_network.o +MOD_LIBNAME=mod_network.so +MOD_INSTALLDIR=$(RADDIR_MODULE) +APISDIR=../../../../apis + +include $(SRC)/make-rules/Makefile.com + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/cmd/rad/mod/network/mod_network.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/cmd/rad/mod/network/mod_network.c Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,264 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "api_network.h" + +#include +#include +#include +#include +#include + +static int +if_count(int fd, int *count) +{ + struct lifnum ifnum; + + ifnum.lifn_family = AF_INET; + ifnum.lifn_flags = 0; + if (ioctl(fd, SIOCGLIFNUM, &ifnum) == -1) { + (void) close(fd); + return (-1); + } + + *count = ifnum.lifn_count; + return (0); +} + +/* ARGSUSED */ +conerr_t +interface_Network_read_networkInterfaces(rad_instance_t *inst, + adr_attribute_t *attr, data_t **data, data_t **error) +{ + int fd; + int count, rcount; + int reqsize; + struct lifreq *reqs = NULL; + struct lifconf ifconf; + data_t *result; + + if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) + return (ce_object); + + do { + if (reqs != NULL) + free(reqs); + + if (if_count(fd, &count) == -1) + return (ce_object); + + if (count == 0) { + (void) close(fd); + *data = data_new_array(&t_array_string, 0); + return (ce_ok); + } + + count += 5; + reqsize = count * sizeof (struct lifreq); + if ((reqs = malloc(reqsize)) == NULL) { + (void) close(fd); + return (ce_object); + } + + ifconf.lifc_family = AF_INET; + ifconf.lifc_len = reqsize; + ifconf.lifc_buf = (char *)reqs; + ifconf.lifc_flags = 0; + if (ioctl(fd, SIOCGLIFCONF, &ifconf) == -1) { + (void) close(fd); + free(reqs); + return (ce_object); + } + rcount = ifconf.lifc_len / sizeof (struct lifreq); + } while (rcount >= count); + + result = data_new_array(&t_array_string, rcount); + for (int i = 0; i < rcount; i++) { + struct lifreq *r = &ifconf.lifc_req[i]; + if (strchr(r->lifr_name, ':') != NULL) + continue; + if (ioctl(fd, SIOCGLIFFLAGS, r) == -1) + continue; + if ((r->lifr_flags & (IFF_LOOPBACK | IFF_VIRTUAL)) != 0) + continue; + (void) array_add(result, data_new_string(r->lifr_name, + lt_copy)); + } + (void) close(fd); + free(reqs); + + *data = data_purify_deep(result); + return (ce_ok); +} + +/* ARGSUSED */ +conerr_t +interface_Network_invoke_getHostNameForIP(rad_instance_t *inst, + adr_method_t *meth, data_t **ret, data_t **args, int count, data_t **error) +{ + int errnum; + struct hostent *he; + ipaddr_t addr; + + if (inet_pton(AF_INET, data_to_string(args[0]), &addr) != 1) + return (ce_object); + + if ((he = getipnodebyaddr(&addr, sizeof (addr), AF_INET, &errnum)) + == NULL) { + /* Not found? Bounce it back. */ + (void) data_ref(args[0]); + *ret = args[0]; + return (ce_ok); + } + + data_t *result = data_new_string(he->h_name, lt_copy); + freehostent(he); + *ret = result; + + return (ce_ok); +} + +/* ARGSUSED */ +conerr_t +interface_Network_invoke_hostGetIPs(rad_instance_t *inst, adr_method_t *meth, + data_t **ret, data_t **args, int count, data_t **error) +{ + int errnum; + struct hostent *he; + + if ((he = getipnodebyname(data_to_string(args[0]), AF_INET, AI_DEFAULT, + &errnum)) == NULL) { + *ret = NULL; + return (ce_object); + } + + int n = 0; + for (char **aptr = he->h_addr_list; *aptr != NULL; aptr++) + n++; + data_t *result = data_new_array(&t_array_string, n); + for (int i = 0; i < n; i++) { + char abuf[INET_ADDRSTRLEN]; + if (inet_ntop(AF_INET, he->h_addr_list[i], abuf, + sizeof (abuf)) != NULL) + (void) array_add(result, data_new_string(abuf, + lt_copy)); + } + + *ret = data_purify_deep(result); + freehostent(he); + + return (ce_ok); +} + +/* ARGSUSED */ +conerr_t +interface_Network_invoke_isLocalAddress(rad_instance_t *inst, + adr_method_t *meth, data_t **ret, data_t **args, int count, data_t **error) +{ + struct ifaddrs *ifaddr; + struct ifaddrs *ifa; + struct sockaddr_in *sin; + struct sockaddr_in6 *sin6; + + char buf[1024]; + (void) memset(buf, 0, sizeof (buf)); + + /* Set default return value */ + *ret = data_new_boolean(B_FALSE); + + // Get IP addresses of each network interface. + // + // ifa_name ifa_addr->sin_addr.s_addr + // + // lo0 0.0.0.0 + // lo0 ::1 (AF_INET6) + // lo0 127.0.0.1 (AF_INET) + // e1000g0 129.XXX.XXX.XXX (AF_INET) + // + // See: man -s3 socket getifaddrs + if (getifaddrs(&ifaddr) == -1) { + return (ce_object); + } + + /* Iterate over linked list of IP addresses */ + for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { + if (ifa->ifa_flags & IFF_IPV4) { + /* LINTED */ + sin = (struct sockaddr_in *)ifa->ifa_addr; + + /* Match given IP address */ + if (strcmp(data_to_string(args[0]), inet_ntop(AF_INET, + &sin->sin_addr.s_addr, buf, 1024)) == 0) { + *ret = data_new_boolean(B_TRUE); + break; + } + } else { + /* LINTED */ + sin6 = (struct sockaddr_in6 *)ifa->ifa_addr; + + /* Match given IP address */ + if (strcmp(data_to_string(args[0]), inet_ntop(AF_INET6, + &sin6->sin6_addr.s6_addr, buf, 1024)) == 0) { + *ret = data_new_boolean(B_TRUE); + break; + } + } + } + freeifaddrs(ifaddr); + return (ce_ok); +} + +static rad_modinfo_t modinfo = { "network", "Network panel support" }; + +int +_rad_init(void *handle) +{ + if (rad_module_register(handle, RAD_MODVERSION, &modinfo) == -1) + return (-1); + + if (rad_isproxy) + return (0); + + (void) cont_insert_singleton(rad_container, adr_name_fromstr( + "com.oracle.solaris.vp.panel.common.api.network:type=Network"), + &interface_Network_svr); + + return (0); +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/cmd/rad/mod/panels/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/cmd/rad/mod/panels/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,49 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +include $(SRC)/make-rules/Makefile.env + +CPPFLAGS += -I/usr/include/libxml2 +LDLIBS += -lxml2 -lcrypto + +# Compensate for libxml's lint library +LINTFLAGS += -erroff=E_INCONS_ARG_DECL2 + +MOD_APIS=panels +MOD_OBJS=mod_panels.o +MOD_LIBNAME=mod_panels.so +MOD_INSTALLDIR=$(RADDIR_MODULE) + +DTDDIR=$(ROOT)/usr/share/lib/xml/dtd +APISDIR=../../../../apis + +include $(SRC)/make-rules/Makefile.com + +install: $(DTDDIR)/vpanel.dtd.1 + +FILEMODE=444 +$(DTDDIR)/%: % + $(INS.file); + $(RMCDDL) diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/cmd/rad/mod/panels/mod_panels.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/cmd/rad/mod/panels/mod_panels.c Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,518 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "api_panels.h" + +#define PANELDESCDIR "/usr/share/vpanels/conf" + +#define HASH_BSIZE 65536 + +/* + * Function prototypes + */ + +static int md5_file(const char *fname, unsigned char *hash); +static data_t *get_text(xmlDoc *doc, xmlNode *node); +static char *get_text_str(xmlDoc *doc, xmlNode *node); +static data_t *get_prop(xmlNode *node, const char *name); +static data_t *file_to_token(rad_locale_t *rlocale, const char *pname, + char *file); +static conerr_t token_to_file(data_t *t, char **f); +static data_t *create_resource(rad_locale_t *rlocale, const char *pname, + char *file); +static void add_localized(rad_locale_t *rlocale, const char *pname, + data_t *farray, char *file); +static data_t *read_panel_path(rad_locale_t *rlocale, const char *path); +static data_t *read_panel(const char *locale, const char *pname); + +/* + * Static data + */ + +static xmlDtd *dtd; +static rad_modinfo_t modinfo = { "panels", "Visual Panels module" }; + +/* + * Static functions + */ + +static int +md5_file(const char *fname, unsigned char *hash) +{ + int fd, len = -1; + MD5_CTX ctx; + + char *buffer = malloc(HASH_BSIZE); + if (buffer == NULL) + return (-1); + + if ((fd = open(fname, O_RDONLY)) == -1) { + free(buffer); + return (-1); + } + + if (MD5_Init(&ctx) == 0) + goto out; + + while ((len = read(fd, buffer, HASH_BSIZE)) > 0) + if (MD5_Update(&ctx, buffer, len) == 0) { + len = -1; + break; + } + if (MD5_Final(hash, &ctx) == 0) + len = -1; + +out: + (void) close(fd); + free(buffer); + return (len); /* Should be 0 or -1 */ +} + +/* + * Seems like overkill, but it's better than mixing xml-allocated + * and other strings. + */ +static data_t * +get_text(xmlDoc *doc, xmlNode *node) +{ + data_t *result; + xmlChar *d = xmlNodeListGetString(doc, node, 1); + if (d == NULL) + return (NULL); + + result = data_new_string((char *)d, lt_copy); + xmlFree(d); + return (result); +} + +static char * +get_text_str(xmlDoc *doc, xmlNode *node) +{ + char *result; + xmlChar *d = xmlNodeListGetString(doc, node, 1); + if (d == NULL) + return (NULL); + + result = strdup((char *)d); + xmlFree(d); + return (result); +} + +static data_t * +get_prop(xmlNode *node, const char *name) +{ + data_t *result; + xmlChar *d = xmlGetProp(node, (xmlChar *)name); + if (d == NULL) + return (NULL); + + result = data_new_string((char *)d, lt_copy); + xmlFree(d); + return (result); +} + +static data_t * +file_to_token(rad_locale_t *rlocale, const char *pname, char *file) +{ + int llen = strlen(rlocale->locale); + int plen = strlen(pname); + int flen = strlen(file); + int tokenlen = llen + 1 + plen + 1 + flen + 1; + + char *token = rad_zalloc(tokenlen); + if (token == NULL) { + return (NULL); + } + + char *p = token; + (void) strcpy(p, rlocale->locale); + p += llen + 1; + (void) strcpy(p, pname); + p += plen + 1; + (void) strcpy(p, file); + + return (data_new_opaque(token, tokenlen, lt_free)); +} + +static conerr_t +token_to_file(data_t *t, char **f) +{ + char *token = data_to_opaque(t); + char tokenlen = opaque_size(t); + + /* Cursory validation */ + int nullcnt = 0; + for (int i = 0; i < tokenlen; i++) { + if (token[i] == '\0') { + nullcnt++; + } + } + if (nullcnt != 3 || token[tokenlen - 1] != '\0') { + /* Bad token */ + return (ce_object); + } + + char *locale = token; + char *pname = locale + strlen(locale) + 1; + char *file = pname + strlen(pname) + 1; + + data_t *panel = read_panel(locale, pname); + if (panel == NULL) { + /* Bad panel */ + return (ce_object); + } + + data_t *resources = struct_get(panel, "resourceDescriptors"); + static const char * const path[] = { "file", NULL }; + int index = array_search(resources, file, path); + data_free(panel); + if (index == -1) { + /* Bad file */ + return (ce_object); + } + + *f = strdup(file); + if (*f == NULL) { + return (ce_nomem); + } + + return (ce_ok); +} + +static data_t * +create_resource(rad_locale_t *rlocale, const char *pname, char *file) +{ + unsigned char hbuf[MD5_DIGEST_LENGTH]; + if (md5_file(file, hbuf) != 0) { + return (NULL); + } + + data_t *result = data_new_struct(&t__ResourceDescriptor); + struct_set(result, "token", file_to_token(rlocale, pname, file)); + struct_set(result, "file", data_new_string(file, lt_copy)); + struct_set(result, "hashAlgorithm", data_new_string("MD5", lt_const)); + struct_set(result, "hash", data_new_opaque(hbuf, MD5_DIGEST_LENGTH, + lt_copy)); + + return (result); +} + +static void +add_localized(rad_locale_t *rlocale, const char *pname, data_t *farray, + char *file) +{ + if (rlocale != NULL && rlocale->language != NULL && + strlen(rlocale->language)) { + char path[PATH_MAX + 1]; + (void) strlcpy(path, file, PATH_MAX); + + char *ext = strrchr(path, '.'); + if (ext != NULL && strcmp(ext, ".jar") == 0) { + *ext = '\0'; + char *base = strrchr(path, '/'); + if (base == NULL) { + return; + } + *base++ = '\0'; + + char *fmt[] = {NULL, NULL, NULL}; + + /* + * Use a ResourceBundle.getBundle-like algorithm - + * [_[@]] - and order + * from most- to least-specific. + */ + fmt[2] = "%s/locale/%s/%5$s_l10n.jar"; + if (rlocale->territory != NULL) { + fmt[1] = "%s/locale/%s_%s/%5$s_l10n.jar"; + if (rlocale->modifier != NULL) { + fmt[0] = "%s/locale/%s_%s@%s/" + "%5$s_l10n.jar"; + } + } + + char l10njar[PATH_MAX]; + for (int i = 0; i < RAD_COUNT(fmt); i++) { + if (fmt[i] == NULL) { + continue; + } + /* LINTED: E_SEC_PRINTF_VAR_FMT */ + (void) snprintf(l10njar, RAD_COUNT(l10njar), + fmt[i], path, rlocale->language, + rlocale->territory, rlocale->modifier, + base); + if (access(l10njar, F_OK) == 0) { + (void) array_add(farray, + create_resource(rlocale, pname, + l10njar)); + } + } + } + } + (void) array_add(farray, create_resource(rlocale, pname, file)); +} + +static data_t * +read_panel_path(rad_locale_t *rlocale, const char *path) +{ + xmlParserCtxt *ctx; + xmlValidCtxt *vctx; + xmlDoc *doc; + data_t *panel = NULL; + + ctx = xmlNewParserCtxt(); + vctx = xmlNewValidCtxt(); + if (vctx == NULL || ctx == NULL) + return (NULL); + + doc = xmlCtxtReadFile(ctx, path, NULL, 0); + if (doc == NULL) { + xmlFreeValidCtxt(vctx); + xmlFreeParserCtxt(ctx); + rad_log(RL_WARN, "Empty/no such document: %s\n", path); + return (NULL); + } + + /* + * Validate against *our* DTD. + */ + if (xmlValidateDtd(vctx, doc, dtd) == 0) { + rad_log(RL_WARN, "Invalid document: %s\n", path); + goto out; + } + + xmlNodePtr root = xmlDocGetRootElement(doc); + if (root == NULL || strcmp((const char *)root->name, "panel") != 0) { + rad_log(RL_WARN, "Not a panel definition: %s\n", path); + goto out; + } + + panel = data_new_struct(&t__CustomPanel); + struct_set(panel, "locale", data_new_string(rlocale->locale, lt_copy)); + + data_t *pname = get_prop(root, "name"); + struct_set(panel, "name", pname); + + data_t *farray = data_new_array(&t_array__ResourceDescriptor, 1); + struct_set(panel, "resourceDescriptors", farray); + + char *aroot = NULL; + for (xmlNode *np = root->children; np != NULL; np = np->next) { + if (np->type != XML_ELEMENT_NODE) + continue; + if (strcmp((const char *)np->name, "mainclass") == 0) { + data_t *mc = get_text(doc, np->children); + struct_set(panel, "panelDescriptorClassName", mc); + } else if (strcmp((const char *)np->name, "approot") == 0) { + if (aroot != NULL) + continue; /* schema violation */ + aroot = get_text_str(doc, np->children); + } else if (strcmp((const char *)np->name, "file") == 0) { + char *file = get_text_str(doc, np->children); + if (file == NULL) { + rad_log(RL_WARN, + "Empty declaration within %s\n", + path); + continue; + } + + if (aroot == NULL) { + rad_log(RL_WARN, "App root not specified\n"); + continue; + } + + char full[PATH_MAX]; + (void) snprintf(full, RAD_COUNT(full), "%s/%s", aroot, + file); + free(file); + + add_localized(rlocale, data_to_string(pname), farray, + full); + } + } + if (aroot != NULL) + free(aroot); +out: + xmlFreeValidCtxt(vctx); + xmlFreeDoc(doc); + xmlFreeParserCtxt(ctx); + + return (data_purify_deep(panel)); +} + +static data_t * +read_panel(const char *locale, const char *pname) +{ + rad_locale_t *rlocale; + if (rad_locale_parse(locale, &rlocale) != 0) { + return (NULL); + } + + char path[PATH_MAX]; + (void) snprintf(path, RAD_COUNT(path), "%s/%s.xml", PANELDESCDIR, + pname); + data_t *panel = read_panel_path(rlocale, path); + + if (panel != NULL) { + /* Sanity check - ensure panel @name matches file name */ + data_t *nameattr = struct_get(panel, "name"); + if (strcmp(data_to_string(nameattr), pname) != 0) { + data_free(panel); + panel = NULL; + } + } + + rad_locale_free(rlocale); + + return (panel); +} + +/* + * Extern functions + */ + +int +_rad_init(void *handle) +{ + if (rad_module_register(handle, RAD_MODVERSION, &modinfo) == -1) + return (-1); + + dtd = xmlParseDTD(NULL, + (xmlChar *)"/usr/share/lib/xml/dtd/vpanel.dtd.1"); + + adr_name_t *name = adr_name_fromstr( + "com.oracle.solaris.vp.panel.common.api.panel:type=Panel"); + (void) cont_insert_singleton(rad_container, name, &interface_Panel_svr); + + return (0); +} + +/* ARGSUSED */ +conerr_t +interface_Panel_invoke_getPanel(rad_instance_t *inst, adr_method_t *meth, + data_t **ret, data_t **args, int count, data_t **error) +{ + const char *pname = data_to_string(args[0]); + const char *locale = args[1] == NULL ? NULL : data_to_string(args[1]); + + data_t *panel = read_panel(locale, pname); + if (panel == NULL) { + /* + * Could be a memory or system error, but more likely an invalid + * name was specified. + */ + return (ce_object); + } + *ret = panel; + + return (ce_ok); +} + +/* ARGSUSED */ +conerr_t +interface_Panel_read_panelNames(rad_instance_t *inst, adr_attribute_t *attr, + data_t **data, data_t **error) +{ + data_t *array = data_new_array(&t_array_string, 0); + if (array == NULL) { + return (ce_nomem); + } + + DIR *d; + if ((d = opendir(PANELDESCDIR)) == NULL) { + if (errno == ENOENT) { + return (ce_ok); + } + return (ce_system); + } + + struct dirent *ent; + while ((ent = readdir(d)) != NULL) { + char *ext = ".xml"; + size_t len = strlen(ent->d_name) - strlen(ext); + if (len < 1 || strcmp(ent->d_name + len, ext) != 0) { + continue; + } + (void) array_add(array, data_new_nstring(ent->d_name, len)); + } + + (void) closedir(d); + *data = data_purify(array); + + return (*data == NULL ? ce_nomem : ce_ok); +} + +/* ARGSUSED */ +conerr_t +interface_Panel_invoke_getResource(rad_instance_t *inst, adr_method_t *meth, + data_t **ret, data_t **args, int count, data_t **error) +{ + char *file; + conerr_t result = token_to_file(args[0], &file); + if (result != ce_ok) { + return (result); + } + + struct stat st; + if (stat(file, &st) != 0) { + free(file); + return (ce_object); + } + + char *buffer = malloc(st.st_size); + if (buffer == NULL) { + free(file); + return (ce_nomem); + } + + int fd = open(file, O_RDONLY); + free(file); + if (fd == -1) { + free(buffer); + return (ce_priv); + } + + if (read(fd, buffer, st.st_size) != st.st_size) { + (void) close(fd); + free(buffer); + return (ce_system); + } + + (void) close(fd); + + *ret = data_new_opaque(buffer, st.st_size, lt_free); + return (*ret == NULL ? ce_nomem : ce_ok); +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/cmd/rad/mod/panels/vpanel.dtd.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/cmd/rad/mod/panels/vpanel.dtd.1 Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/cmd/rad/mod/smf_old/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/cmd/rad/mod/smf_old/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,36 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +include $(SRC)/make-rules/Makefile.env + +LDLIBS += -lscf +MOD_APIS=smf_old +MOD_OBJS=mod_smf.o propvec.o +MOD_LIBNAME=mod_smf_old.so +MOD_INSTALLDIR=$(RADDIR_MODULE) +APISDIR=../../../../apis + +include $(SRC)/make-rules/Makefile.com + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/cmd/rad/mod/smf_old/mod_smf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/cmd/rad/mod/smf_old/mod_smf.c Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,1916 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "api_smf_old.h" +#include "propvec.h" + +static pthread_mutex_t service_lock = PTHREAD_MUTEX_INITIALIZER; +static list_t service_list; +static list_t instance_list; +static rad_instance_t *agg_inst; +static int service_count = 0; +static int instance_count = 0; + +static const char *aggregator_pattern = + "com.oracle.solaris.vp.panel.common.api.smf_old:type=Aggregator"; + +typedef struct servinst { + char *sname; /* Service name */ + char *iname; /* Instance name */ + char *fmri; /* FMRI */ + rad_instance_t *inst; /* rad object instance */ + boolean_t instance; + + int ninstances; + list_t instances; /* A service's instances */ + list_node_t node; /* Membership in the global list */ + list_node_t snode; /* An instance's membership in its service */ +} servinst_t; + +static const char *framework_pgtypes[] = { + SCF_GROUP_FRAMEWORK, + SCF_GROUP_DEPENDENCY, + SCF_GROUP_METHOD, + SCF_GROUP_TEMPLATE, + SCF_GROUP_TEMPLATE_PG_PATTERN, + SCF_GROUP_TEMPLATE_PROP_PATTERN, + NULL +}; + +static conerr_t +error_scf(data_t **error, int code) +{ + if (error != NULL) { + data_t *e = data_new_struct(&t__SmfError); + struct_set(e, "error", data_new_enum(&t__SmfErrorCode, code)); + struct_set(e, "message", + data_new_string(scf_strerror(code), lt_const)); + *error = data_purify(e); + } + return (ce_object); +} + +static conerr_t +simple_scf(data_t **error, int result) +{ + if (result == 0) + return (ce_ok); + return (error_scf(error, scf_error())); +} + +static boolean_t +strinset(const char **set, const char *str) +{ + for (; *set != NULL; set++) + if (strcmp(*set, str) == 0) + return (B_TRUE); + return (B_FALSE); +} + +static boolean_t +strnotinset(const char **set, const char *str) +{ + return (!strinset(set, str)); +} + +scf_handle_t * +handle_create(void) +{ + scf_handle_t *h = scf_handle_create(SCF_VERSION); + if (h == NULL) + return (NULL); + + if (scf_handle_bind(h) == -1) { + scf_handle_destroy(h); + return (NULL); + } + return (h); +} + +static int getpgs(servinst_t *si, data_t **data, boolean_t namesonly, + boolean_t(*fp)(const char **, const char *), const char **set, + data_t **error) +{ + conerr_t err = ce_ok; + scf_handle_t *scfhandle = handle_create(); + scf_service_t *service = scf_service_create(scfhandle); + scf_instance_t *instance = scf_instance_create(scfhandle); + scf_snapshot_t *snap = scf_snapshot_create(scfhandle); + scf_iter_t *iter = scf_iter_create(scfhandle); + scf_propertygroup_t *pg = scf_pg_create(scfhandle); + + if (scf_handle_decode_fmri(scfhandle, si->fmri, NULL, service, + instance, NULL, NULL, 0) != SCF_SUCCESS) { + rad_log(RL_WARN, "Couldn't decode '%s': %s\n", si->fmri, + scf_strerror(scf_error())); + err = error_scf(error, scf_error()); + goto out; + } + + if (si->instance) { + if (scf_instance_get_snapshot(instance, "running", snap) != 0 || + scf_iter_instance_pgs_composed(iter, instance, snap) + != SCF_SUCCESS) { + err = error_scf(error, scf_error()); + goto out; + } + } else { + if (scf_iter_service_pgs(iter, service) != SCF_SUCCESS) { + rad_log(RL_WARN, "failed to initialize iterator: %s\n", + scf_strerror(scf_error())); + err = error_scf(error, scf_error()); + goto out; + } + } + + data_t *result = namesonly ? data_new_array(&t_array_string, 5) : + data_new_array(&t_array__PropertyGroup, 5); + while (scf_iter_next_pg(iter, pg) > 0) { + char nbuf[1000]; + char tbuf[1000]; + (void) scf_pg_get_name(pg, nbuf, 1000); + (void) scf_pg_get_type(pg, tbuf, 1000); + + if (fp(set, tbuf)) { + if (namesonly) { + (void) array_add(result, + data_new_string(nbuf, lt_copy)); + } else { + data_t *pgdata = + data_new_struct(&t__PropertyGroup); + struct_set(pgdata, "name", + data_new_string(nbuf, lt_copy)); + struct_set(pgdata, "type", + data_new_string(tbuf, lt_copy)); + (void) array_add(result, pgdata); + } + } + } + + *data = result; + +out: + scf_pg_destroy(pg); + scf_snapshot_destroy(snap); + scf_iter_destroy(iter); + scf_instance_destroy(instance); + scf_service_destroy(service); + scf_handle_destroy(scfhandle); + + return (err); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_read_fmri(rad_instance_t *inst, adr_attribute_t *attr, + data_t **data, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + *data = data_new_string(si->fmri, lt_copy); + return (ce_ok); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_read_methodNames(rad_instance_t *inst, + adr_attribute_t *attr, data_t **data, data_t **error) +{ + const char *pgtypes[] = { SCF_GROUP_METHOD, NULL }; + return (getpgs(instance_getdata(inst), data, B_TRUE, strinset, pgtypes, + error)); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_read_dependencyNames(rad_instance_t *inst, + adr_attribute_t *attr, data_t **data, data_t **error) +{ + const char *pgtypes[] = { SCF_GROUP_DEPENDENCY, NULL }; + return (getpgs(instance_getdata(inst), data, B_TRUE, strinset, pgtypes, + error)); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_read_propertyGroups(rad_instance_t *inst, + adr_attribute_t *attr, data_t **data, data_t **error) +{ + return (getpgs(instance_getdata(inst), data, B_FALSE, strnotinset, + framework_pgtypes, error)); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_read_manpages(rad_instance_t *inst, adr_attribute_t *attr, + data_t **data, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + char *title, *section, *path; + rad_propvec_t *badprop; + rad_propvec_t evec[] = { + { SCF_PROPERTY_TM_MANPATH, NULL, SCF_TYPE_USTRING, &path, 0 }, + { SCF_PROPERTY_TM_TITLE, NULL, SCF_TYPE_USTRING, &title, 0 }, + { SCF_PROPERTY_TM_SECTION, NULL, SCF_TYPE_USTRING, §ion, + 0 }, + { NULL } + }; + + const char *pgtypes[] = { + SCF_GROUP_TEMPLATE, + NULL + }; + + data_t *pgs; + conerr_t err = getpgs(si, &pgs, B_TRUE, strinset, pgtypes, error); + if (err != ce_ok) + return (err); + data_t *result = data_new_array(&t_array__Manpage, 5); + for (int i = 0; i < array_size(pgs); i++) { + const char *str = data_to_string(array_get(pgs, i)); + if (strncmp(str, SCF_PG_TM_MAN_PREFIX, + strlen(SCF_PG_TM_MAN_PREFIX)) != 0) { + continue; + } + + if (rad_read_propvec(si->fmri, str, B_FALSE, evec, + &badprop) != 0) + continue; + + data_t *mp = data_new_struct(&t__Manpage); + struct_set(mp, "title", data_new_string(title, lt_copy)); + struct_set(mp, "section", data_new_string(section, lt_copy)); + struct_set(mp, "path", data_new_string(path, lt_copy)); + (void) array_add(result, mp); + rad_clean_propvec(evec); + } + data_free(pgs); + *data = result; + + return (ce_ok); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_read_doclinks(rad_instance_t *inst, adr_attribute_t *attr, + data_t **data, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + char *uri; + rad_propvec_t *badprop; + rad_propvec_t evec[] = { + { SCF_PROPERTY_TM_URI, NULL, SCF_TYPE_USTRING, &uri, 0 }, + { NULL } + }; + + const char *pgtypes[] = { + SCF_GROUP_TEMPLATE, + NULL + }; + + data_t *pgs; + conerr_t err = getpgs(si, &pgs, B_TRUE, strinset, pgtypes, error); + if (err != ce_ok) + return (err); + data_t *result = data_new_array(&t_array_string, 5); + for (int i = 0; i < array_size(pgs); i++) { + const char *str = data_to_string(array_get(pgs, i)); + if (strncmp(str, SCF_PG_TM_DOC_PREFIX, + strlen(SCF_PG_TM_DOC_PREFIX)) != 0) { + continue; + } + + if (rad_read_propvec(si->fmri, str, B_FALSE, evec, + &badprop) == 0) { + (void) array_add(result, data_new_string(uri, lt_copy)); + rad_clean_propvec(evec); + } + } + data_free(pgs); + *data = result; + + return (ce_ok); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_read_persistentlyEnabled(rad_instance_t *inst, + adr_attribute_t *attr, data_t **data, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + if (!si->instance) + return (error_scf(error, SCF_ERROR_INVALID_ARGUMENT)); + + boolean_t enabled; + rad_propvec_t evec[] = { + { SCF_PROPERTY_ENABLED, NULL, SCF_TYPE_BOOLEAN, &enabled, 0 }, + { NULL } + }; + + rad_propvec_t *badprop; + int scferr = rad_read_propvec(si->fmri, SCF_PG_GENERAL, B_FALSE, + evec, &badprop); + if (scferr != 0) + return (error_scf(error, scferr)); + rad_clean_propvec(evec); + + *data = data_new_boolean(enabled); + return (ce_ok); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_read_temporarilyEnabled(rad_instance_t *inst, + adr_attribute_t *attr, data_t **data, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + if (!si->instance) + return (error_scf(error, SCF_ERROR_INVALID_ARGUMENT)); + + boolean_t enabled; + rad_propvec_t evec[] = { + { SCF_PROPERTY_ENABLED, NULL, SCF_TYPE_BOOLEAN, &enabled, 0 }, + { NULL } + }; + + rad_propvec_t *badprop; + if (rad_read_propvec(si->fmri, SCF_PG_GENERAL_OVR, B_FALSE, evec, + &badprop) != 0) + return (interface_ServiceInfo_read_persistentlyEnabled( + inst, attr, data, error)); + rad_clean_propvec(evec); + + *data = data_new_boolean(enabled); + return (ce_ok); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_read_enabled(rad_instance_t *inst, adr_attribute_t *attr, + data_t **data, data_t **error) +{ + /* + * XXX: The java version always had the same implementation for both. + */ + return (interface_ServiceInfo_read_persistentlyEnabled(inst, attr, data, + error)); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_read_instance(rad_instance_t *inst, adr_attribute_t *attr, + data_t **data, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + *data = data_new_boolean(si->instance); + return (ce_ok); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_read_restarter(rad_instance_t *inst, + adr_attribute_t *attr, data_t **data, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + if (!si->instance) + return (error_scf(error, SCF_ERROR_INVALID_ARGUMENT)); + + char *fmri = NULL; + rad_propvec_t evec[] = { + { SCF_PROPERTY_RESTARTER, NULL, SCF_TYPE_USTRING, &fmri, 0 }, + { NULL } + }; + + rad_propvec_t *badprop; + if (rad_read_propvec(si->fmri, SCF_PG_GENERAL, B_FALSE, evec, + &badprop) == 0) { + *data = data_new_string(fmri, lt_copy); + rad_clean_propvec(evec); + } else { + *data = data_new_fstring("svc:/%s:%s", + "system/svc/restarter", "default"); + } + + return (*data != NULL ? ce_ok : ce_system); +} + +static data_t * +state2enum(const char *state) +{ + if (strcmp(state, SCF_STATE_STRING_UNINIT) == 0) { + return (&e__SmfState_UNINIT); + } else if (strcmp(state, SCF_STATE_STRING_MAINT) == 0) { + return (&e__SmfState_MAINT); + } else if (strcmp(state, SCF_STATE_STRING_LEGACY) == 0) { + return (&e__SmfState_LEGACY); + } else { + return (data_new_enum_byname(&t__SmfState, state)); + } +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_read_state(rad_instance_t *inst, adr_attribute_t *attr, + data_t **data, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + if (!si->instance) + return (error_scf(error, SCF_ERROR_INVALID_ARGUMENT)); + + char *state = smf_get_state(si->fmri); + if (state == NULL) + return (error_scf(error, scf_error())); + + *data = state2enum(state); + free(state); + return (*data != NULL ? ce_ok : ce_system); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_read_nextState(rad_instance_t *inst, + adr_attribute_t *attr, data_t **data, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + if (!si->instance) + return (error_scf(error, SCF_ERROR_INVALID_ARGUMENT)); + + char *state = NULL; + rad_propvec_t evec[] = { + { SCF_PROPERTY_NEXT_STATE, NULL, SCF_TYPE_ASTRING, &state, 0 }, + { NULL } + }; + + rad_propvec_t *badprop; + int scferr = rad_read_propvec(si->fmri, SCF_PG_RESTARTER, B_FALSE, evec, + &badprop); + if (scferr != 0) + return (error_scf(error, scferr)); + + *data = state2enum(state); + rad_clean_propvec(evec); + return (*data != NULL ? ce_ok : ce_system); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_read_auxiliaryState(rad_instance_t *inst, + adr_attribute_t *attr, data_t **data, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + if (!si->instance) + return (error_scf(error, SCF_ERROR_INVALID_ARGUMENT)); + + char *aux; + rad_propvec_t evec[] = { + { SCF_PROPERTY_AUX_STATE, NULL, SCF_TYPE_ASTRING, &aux, 0 }, + { NULL } + }; + + rad_propvec_t *badprop; + int scferr = rad_read_propvec(si->fmri, SCF_PG_RESTARTER, B_FALSE, evec, + &badprop); + if (scferr != 0) { + if (scferr == SCF_ERROR_NOT_FOUND) { + *data = NULL; + return (ce_ok); + } + return (error_scf(error, scferr)); + } + + *data = data_new_string(aux, lt_copy); + rad_clean_propvec(evec); + + return (*data != NULL ? ce_ok : ce_system); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_read_stime(rad_instance_t *inst, adr_attribute_t *attr, + data_t **data, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + if (!si->instance) + return (error_scf(error, SCF_ERROR_INVALID_ARGUMENT)); + + scf_time_t time; + rad_propvec_t evec[] = { + { SCF_PROPERTY_STATE_TIMESTAMP, NULL, SCF_TYPE_TIME, &time, 0 }, + { NULL } + }; + + rad_propvec_t *badprop; + int scferr = rad_read_propvec(si->fmri, SCF_PG_RESTARTER, B_FALSE, evec, + &badprop); + if (scferr != 0) + return (error_scf(error, scferr)); + + rad_clean_propvec(evec); + + *data = data_new_time(time.t_seconds, time.t_ns); + + return (*data != NULL ? ce_ok : ce_system); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_read_contractID(rad_instance_t *inst, + adr_attribute_t *attr, data_t **data, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + if (!si->instance) + return (error_scf(error, SCF_ERROR_INVALID_ARGUMENT)); + + uint64_t count; + rad_propvec_t evec[] = { + { SCF_PROPERTY_CONTRACT, NULL, SCF_TYPE_COUNT, &count, 0 }, + { NULL } + }; + + rad_propvec_t *badprop; + int scferr = rad_read_propvec(si->fmri, SCF_PG_RESTARTER, B_FALSE, evec, + &badprop); + if (scferr != 0) + return (error_scf(error, scferr)); + rad_clean_propvec(evec); + + *data = data_new_long(count); + + return (*data != NULL ? ce_ok : ce_system); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_read_reason(rad_instance_t *inst, adr_attribute_t *attr, + data_t **data, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + if (!si->instance) + return (error_scf(error, SCF_ERROR_INVALID_ARGUMENT)); + *data = NULL; + return (ce_ok); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_write_persistentlyEnabled(rad_instance_t *inst, + adr_attribute_t *attr, data_t *data, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + boolean_t enable = data_to_boolean(data); + if (!si->instance) + return (error_scf(error, SCF_ERROR_INVALID_ARGUMENT)); + + return (simple_scf(error, enable ? smf_enable_instance(si->fmri, 0) : + smf_disable_instance(si->fmri, 0))); +} + +static conerr_t +get_pg(scf_handle_t *scfhandle, scf_propertygroup_t *pg, servinst_t *si, + const char *snapname, const char *pgname, data_t **error) +{ + conerr_t err = ce_ok; + scf_service_t *service = scf_service_create(scfhandle); + scf_instance_t *instance = scf_instance_create(scfhandle); + scf_snapshot_t *snap = scf_snapshot_create(scfhandle); + + if (service == NULL || instance == NULL || snap == NULL) { + err = error_scf(error, SCF_ERROR_NO_MEMORY); + goto out; + } + + if (scf_handle_decode_fmri(scfhandle, si->fmri, NULL, service, + instance, NULL, NULL, 0) != SCF_SUCCESS) { + rad_log(RL_WARN, "Couldn't decode '%s': %s\n", + si->fmri, scf_strerror(scf_error())); + err = error_scf(error, scf_error()); + goto out; + } + + if (si->instance) { + scf_snapshot_t *usesnap = NULL; + if (snapname != NULL) { + usesnap = snap; + if (scf_instance_get_snapshot(instance, snapname, snap) + != 0) { + err = error_scf(error, scf_error()); + goto out; + } + } + if (scf_instance_get_pg_composed(instance, usesnap, pgname, pg) + != 0) { + err = error_scf(error, scf_error()); + goto out; + } + } else { + if (scf_service_get_pg(service, pgname, pg) != SCF_SUCCESS) { + err = error_scf(error, scf_error()); + goto out; + } + } +out: + scf_snapshot_destroy(snap); + scf_instance_destroy(instance); + scf_service_destroy(service); + return (err); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_getDependency(rad_instance_t *inst, + adr_method_t *meth, data_t **ret, data_t **args, int count, data_t **error) +{ + conerr_t err = ce_ok; + const char *pgname = data_to_string(args[0]); + servinst_t *si = instance_getdata(inst); + char type[1000]; + char grouping[1000]; + char restarton[1000]; + + scf_handle_t *scfhandle = handle_create(); + scf_iter_t *iter = scf_iter_create(scfhandle); + scf_propertygroup_t *pg = scf_pg_create(scfhandle); + scf_property_t *prop = scf_property_create(scfhandle); + scf_value_t *val = scf_value_create(scfhandle); + + if (scfhandle == NULL || iter == NULL || pg == NULL || prop == NULL || + val == NULL) { + err = error_scf(error, SCF_ERROR_NO_MEMORY); + goto out; + } + if ((err = get_pg(scfhandle, pg, si, "running", pgname, error)) + != ce_ok) + goto out; + + if (scf_pg_get_type(pg, type, sizeof (type)) == 0) { + err = error_scf(error, scf_error()); + goto out; + } + if (strcmp(type, SCF_GROUP_DEPENDENCY) != 0) { + err = error_scf(error, SCF_ERROR_INVALID_ARGUMENT); + goto out; + } + + if (scf_pg_get_property(pg, SCF_PROPERTY_GROUPING, prop) != 0 || + scf_property_get_value(prop, val) != 0 || + scf_value_get_as_string(val, grouping, sizeof (grouping)) == -1 || + scf_pg_get_property(pg, SCF_PROPERTY_RESTART_ON, prop) != 0 || + scf_property_get_value(prop, val) != 0 || + scf_value_get_as_string(val, restarton, sizeof (restarton)) == -1 || + scf_pg_get_property(pg, SCF_PROPERTY_ENTITIES, prop) != 0 || + scf_iter_property_values(iter, prop) != 0) { + err = error_scf(error, scf_error()); + goto out; + } + + data_t *result = data_new_struct(&t__Dependency); + data_t *array = data_new_array(&t_array_string, 5); + struct_set(result, "name", data_ref(args[0])); + struct_set(result, "grouping", data_new_string(grouping, lt_copy)); + struct_set(result, "restartOn", data_new_string(restarton, lt_copy)); + struct_set(result, "target", array); + while (scf_iter_next_value(iter, val) > 0) { + if (scf_value_get_as_string(val, type, sizeof (type)) == -1) { + err = error_scf(error, scf_error()); + data_free(result); + goto out; + } + (void) array_add(array, data_new_string(type, lt_copy)); + } + if (!data_verify(result, NULL, B_TRUE)) { + data_free(result); + err = error_scf(error, SCF_ERROR_NO_MEMORY); + goto out; + } + + *ret = result; +out: + scf_value_destroy(val); + scf_property_destroy(prop); + scf_pg_destroy(pg); + scf_iter_destroy(iter); + scf_handle_destroy(scfhandle); + return (err); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_getPropertyNames(rad_instance_t *inst, + adr_method_t *meth, data_t **ret, data_t **args, int count, data_t **error) +{ + conerr_t err = ce_ok; + const char *pgname = data_to_string(args[0]); + servinst_t *si = instance_getdata(inst); + + scf_handle_t *scfhandle = handle_create(); + scf_iter_t *iter = scf_iter_create(scfhandle); + scf_propertygroup_t *pg = scf_pg_create(scfhandle); + scf_property_t *prop = scf_property_create(scfhandle); + + if (scfhandle == NULL || iter == NULL || pg == NULL || prop == NULL) { + err = error_scf(error, SCF_ERROR_NO_MEMORY); + goto out; + } + + if ((err = get_pg(scfhandle, pg, si, "running", pgname, error)) + != ce_ok) + goto out; + + data_t *result = data_new_array(&t_array_string, 5); + (void) scf_iter_pg_properties(iter, pg); + while (scf_iter_next_property(iter, prop) > 0) { + char pbuf[1000]; + (void) scf_property_get_name(prop, pbuf, 1000); + (void) array_add(result, data_new_string(pbuf, lt_copy)); + } + *ret = result; + +out: + scf_property_destroy(prop); + scf_pg_destroy(pg); + scf_iter_destroy(iter); + scf_handle_destroy(scfhandle); + + return (err); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_getPropertyType(rad_instance_t *inst, + adr_method_t *meth, data_t **ret, data_t **args, int count, data_t **error) +{ + const char *pgname = data_to_string(args[0]); + const char *propname = data_to_string(args[1]); + conerr_t err = ce_ok; + servinst_t *si = instance_getdata(inst); + + scf_handle_t *scfhandle = handle_create(); + scf_propertygroup_t *pg = scf_pg_create(scfhandle); + scf_property_t *prop = scf_property_create(scfhandle); + scf_type_t type; + + if (scfhandle == NULL || pg == NULL || prop == NULL) { + err = error_scf(error, SCF_ERROR_NO_MEMORY); + goto out; + } + if ((err = get_pg(scfhandle, pg, si, "running", pgname, error)) + != ce_ok) + goto out; + + if (scf_pg_get_property(pg, propname, prop) != 0 || + scf_property_type(prop, &type) != 0) { + err = error_scf(error, scf_error()); + goto out; + } + + data_t *result = data_new_enum(&t__PropertyType, type); + if (result != NULL) + *ret = result; + else + err = error_scf(error, SCF_ERROR_NO_MEMORY); + +out: + scf_property_destroy(prop); + scf_pg_destroy(pg); + scf_handle_destroy(scfhandle); + return (err); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_getPropertyValues(rad_instance_t *inst, + adr_method_t *meth, data_t **ret, data_t **args, int count, data_t **error) +{ + conerr_t err = ce_ok; + const char *pgname = data_to_string(args[0]); + const char *propname = data_to_string(args[1]); + + servinst_t *si = instance_getdata(inst); + + scf_handle_t *scfhandle = handle_create(); + scf_service_t *service = scf_service_create(scfhandle); + scf_instance_t *instance = scf_instance_create(scfhandle); + scf_snapshot_t *snap = scf_snapshot_create(scfhandle); + scf_iter_t *iter = scf_iter_create(scfhandle); + scf_propertygroup_t *pg = scf_pg_create(scfhandle); + scf_property_t *prop = scf_property_create(scfhandle); + scf_value_t *val = scf_value_create(scfhandle); + + if (scfhandle == NULL || service == NULL || instance == NULL || + snap == NULL || iter == NULL || pg == NULL || prop == NULL || + prop == NULL || val == NULL) { + err = error_scf(error, SCF_ERROR_NO_MEMORY); + goto out; + } + + if (scf_handle_decode_fmri(scfhandle, si->fmri, NULL, service, + instance, NULL, NULL, 0) != SCF_SUCCESS) { + rad_log(RL_WARN, "Couldn't decode '%s': %s\n", + si->fmri, scf_strerror(scf_error())); + err = error_scf(error, scf_error()); + goto out; + } + if ((si->instance ? scf_instance_get_pg(instance, pgname, pg) : + scf_service_get_pg(service, pgname, pg)) != 0 || + scf_pg_get_property(pg, propname, prop) != 0 || + scf_iter_property_values(iter, prop) != 0) { + err = error_scf(error, scf_error()); + goto out; + } + + data_t *result = data_new_array(&t_array_string, 5); + while (scf_iter_next_value(iter, val) > 0) { + char pbuf[1000]; + (void) scf_value_get_as_string(val, pbuf, 1000); + (void) array_add(result, data_new_string(pbuf, lt_copy)); + } + *ret = result; +out: + scf_value_destroy(val); + scf_property_destroy(prop); + scf_pg_destroy(pg); + scf_iter_destroy(iter); + scf_snapshot_destroy(snap); + scf_instance_destroy(instance); + scf_service_destroy(service); + scf_handle_destroy(scfhandle); + + return (err); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_getSnapshotPropertyValues(rad_instance_t *inst, + adr_method_t *meth, data_t **ret, data_t **args, int count, data_t **error) +{ + conerr_t err = ce_ok; + const char *snapname = data_to_string(args[0]); + const char *pgname = data_to_string(args[1]); + const char *propname = data_to_string(args[2]); + + servinst_t *si = instance_getdata(inst); + if (!si->instance) + return (error_scf(error, SCF_ERROR_INVALID_ARGUMENT)); + + rad_log(RL_DEBUG, "Reading from snapshot: %s\n", snapname); + + scf_handle_t *scfhandle = handle_create(); + scf_iter_t *iter = scf_iter_create(scfhandle); + scf_propertygroup_t *pg = scf_pg_create(scfhandle); + scf_property_t *prop = scf_property_create(scfhandle); + scf_value_t *val = scf_value_create(scfhandle); + + if (scfhandle == NULL || iter == NULL || pg == NULL || prop == NULL || + val == NULL) { + err = error_scf(error, SCF_ERROR_NO_MEMORY); + goto out; + } + + if ((err = get_pg(scfhandle, pg, si, "running", pgname, error)) + != ce_ok) + goto out; + if (scf_pg_get_property(pg, propname, prop) != 0) { + err = error_scf(error, scf_error()); + goto out; + } + + data_t *result = data_new_array(&t_array_string, 5); + (void) scf_iter_property_values(iter, prop); + while (scf_iter_next_value(iter, val) > 0) { + char pbuf[1000]; + (void) scf_value_get_as_string(val, pbuf, 1000); + (void) array_add(result, data_new_string(pbuf, lt_copy)); + } + *ret = result; +out: + scf_value_destroy(val); + scf_property_destroy(prop); + scf_pg_destroy(pg); + scf_iter_destroy(iter); + scf_handle_destroy(scfhandle); + + return (err); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_setPropertyValues(rad_instance_t *inst, + adr_method_t *meth, data_t **ret, data_t **args, int count, data_t **error) +{ + conerr_t err = ce_ok; + const char *pgname = data_to_string(args[0]); + const char *propname = data_to_string(args[1]); + data_t *values = args[2]; + + servinst_t *si = instance_getdata(inst); + + scf_handle_t *scfhandle = handle_create(); + scf_service_t *service = scf_service_create(scfhandle); + scf_instance_t *instance = scf_instance_create(scfhandle); + scf_propertygroup_t *pg = scf_pg_create(scfhandle); + scf_property_t *prop = scf_property_create(scfhandle); + scf_transaction_t *tx = scf_transaction_create(scfhandle); + scf_transaction_entry_t *ent = scf_entry_create(scfhandle); + scf_value_t **val = + rad_zalloc(array_size(values) * sizeof (scf_value_t *)); + scf_type_t type; + + if (scfhandle == NULL || service == NULL || instance == NULL || + pg == NULL || prop == NULL || tx == NULL || ent == NULL || + val == NULL) { + err = error_scf(error, SCF_ERROR_NO_MEMORY); + goto out; + } + + for (int i = 0; i < array_size(values); i++) { + if ((val[i] = scf_value_create(scfhandle)) == NULL) { + err = error_scf(error, SCF_ERROR_NO_MEMORY); + goto out; + } + } + + if (scf_handle_decode_fmri(scfhandle, si->fmri, NULL, service, + instance, NULL, NULL, 0) != SCF_SUCCESS) { + rad_log(RL_WARN, "Couldn't decode '%s': %s\n", + si->fmri, scf_strerror(scf_error())); + err = error_scf(error, scf_error()); + goto out; + } + + if (si->instance) { + /* XXX: silly logic from original java */ + if (scf_instance_get_pg(instance, pgname, pg) != 0 && + scf_service_get_pg(service, pgname, pg) != 0) { + err = error_scf(error, scf_error()); + goto out; + } + } else { + if (scf_service_get_pg(service, pgname, pg) != 0) { + err = error_scf(error, scf_error()); + goto out; + } + } + + if (scf_pg_get_property(pg, propname, prop) != 0 || + scf_property_type(prop, &type) != 0) { + err = error_scf(error, scf_error()); + goto out; + } + +top: + if (scf_transaction_start(tx, pg) == -1) { + err = error_scf(error, scf_error()); + goto out; + } + if (scf_transaction_property_change(tx, ent, propname, type) != 0) { + err = error_scf(error, scf_error()); + goto out; + } + + for (int i = 0; i < array_size(values); i++) { + if (scf_value_set_from_string(val[i], type, + data_to_string(array_get(values, i))) != 0 || + scf_entry_add_value(ent, val[i]) != 0) { + err = error_scf(error, scf_error()); + goto out; + } + } + + int txret = scf_transaction_commit(tx); + if (txret == 1) + goto out; + if (txret == 0 && scf_pg_update(pg) != -1) { + scf_transaction_reset(tx); + goto top; + } + err = error_scf(error, scf_error()); + +out: + if (val != NULL) { + for (int i = 0; i < array_size(values); i++) { + if (val[i] == NULL) + break; + scf_value_destroy(val[i]); + } + free(val); + } + + scf_entry_destroy(ent); + scf_transaction_destroy(tx); + scf_property_destroy(prop); + scf_pg_destroy(pg); + scf_instance_destroy(instance); + scf_service_destroy(service); + scf_handle_destroy(scfhandle); + + return (err); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_createPropertyGroup(rad_instance_t *inst, + adr_method_t *meth, data_t **ret, data_t **args, int count, data_t **error) +{ + conerr_t err = ce_ok; + const char *pgname = data_to_string(args[0]); + const char *pgtype = data_to_string(args[1]); + + servinst_t *si = instance_getdata(inst); + + scf_handle_t *scfhandle = handle_create(); + scf_service_t *service = scf_service_create(scfhandle); + scf_instance_t *instance = scf_instance_create(scfhandle); + scf_propertygroup_t *pg = scf_pg_create(scfhandle); + + if (scfhandle == NULL || service == NULL || instance == NULL || + pg == NULL) { + err = error_scf(error, SCF_ERROR_NO_MEMORY); + goto out; + } + + if (scf_handle_decode_fmri(scfhandle, si->fmri, NULL, service, + instance, NULL, NULL, 0) != SCF_SUCCESS) { + rad_log(RL_WARN, "Couldn't decode '%s': %s\n", + si->fmri, scf_strerror(scf_error())); + err = error_scf(error, scf_error()); + goto out; + } + + if (si->instance) { + if (scf_instance_add_pg(instance, pgname, pgtype, 0, pg) != 0) { + err = error_scf(error, scf_error()); + goto out; + } + } else { + if (scf_service_add_pg(service, pgname, pgtype, 0, pg) != 0) { + err = error_scf(error, scf_error()); + goto out; + } + } + +out: + scf_pg_destroy(pg); + scf_instance_destroy(instance); + scf_service_destroy(service); + scf_handle_destroy(scfhandle); + + return (err); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_deletePropertyGroup(rad_instance_t *inst, + adr_method_t *meth, data_t **ret, data_t **args, int count, data_t **error) +{ + conerr_t err = ce_ok; + const char *pgname = data_to_string(args[0]); + + servinst_t *si = instance_getdata(inst); + + scf_handle_t *scfhandle = handle_create(); + scf_service_t *service = scf_service_create(scfhandle); + scf_instance_t *instance = scf_instance_create(scfhandle); + scf_propertygroup_t *pg = scf_pg_create(scfhandle); + + if (scfhandle == NULL || service == NULL || instance == NULL || + pg == NULL) { + err = error_scf(error, SCF_ERROR_NO_MEMORY); + goto out; + } + + if (scf_handle_decode_fmri(scfhandle, si->fmri, NULL, service, + instance, NULL, NULL, 0) != SCF_SUCCESS) { + rad_log(RL_WARN, "Couldn't decode '%s': %s\n", + si->fmri, scf_strerror(scf_error())); + err = error_scf(error, scf_error()); + goto out; + } + + if (si->instance) { + /* XXX: silly logic from original java */ + if (scf_instance_get_pg(instance, pgname, pg) != 0 && + scf_service_get_pg(service, pgname, pg) != 0) { + err = error_scf(error, scf_error()); + goto out; + } + } else { + if (scf_service_get_pg(service, pgname, pg) != 0) { + err = error_scf(error, scf_error()); + goto out; + } + } + + if (scf_pg_delete(pg) != 0) { + err = error_scf(error, scf_error()); + goto out; + } +out: + scf_pg_destroy(pg); + scf_instance_destroy(instance); + scf_service_destroy(service); + scf_handle_destroy(scfhandle); + + return (err); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_createProperty(rad_instance_t *inst, + adr_method_t *meth, data_t **ret, data_t **args, int count, data_t **error) +{ + conerr_t err = ce_ok; + const char *pgname = data_to_string(args[0]); + const char *propname = data_to_string(args[1]); + scf_type_t type = enum_tovalue(args[2]); + int sret; + + servinst_t *si = instance_getdata(inst); + + scf_handle_t *scfhandle = handle_create(); + scf_service_t *service = scf_service_create(scfhandle); + scf_instance_t *instance = scf_instance_create(scfhandle); + scf_propertygroup_t *pg = scf_pg_create(scfhandle); + scf_transaction_t *tx = scf_transaction_create(scfhandle); + scf_transaction_entry_t *ent = scf_entry_create(scfhandle); + + if (scfhandle == NULL || service == NULL || instance == NULL || + pg == NULL || tx == NULL || ent == NULL) { + err = error_scf(error, SCF_ERROR_NO_MEMORY); + goto out; + } + + if (scf_handle_decode_fmri(scfhandle, si->fmri, NULL, service, + instance, NULL, NULL, 0) != SCF_SUCCESS) { + rad_log(RL_WARN, "Couldn't decode '%s': %s\n", + si->fmri, scf_strerror(scf_error())); + err = error_scf(error, scf_error()); + goto out; + } + + if (si->instance) { + /* XXX: silly logic from original java */ + if (scf_instance_get_pg(instance, pgname, pg) != 0 && + scf_service_get_pg(service, pgname, pg) != 0) { + err = error_scf(error, scf_error()); + goto out; + } + } else { + if (scf_service_get_pg(service, pgname, pg) != 0) { + err = error_scf(error, scf_error()); + goto out; + } + } + +top: + if (scf_transaction_start(tx, pg) == -1) { + err = error_scf(error, scf_error()); + goto out; + } + sret = scf_transaction_property_change(tx, ent, propname, type); + if (sret == -1 && scf_error() == SCF_ERROR_NOT_FOUND) + sret = scf_transaction_property_new(tx, ent, propname, type); + if (sret == -1) { + err = error_scf(error, scf_error()); + goto out; + } + + sret = scf_transaction_commit(tx); + if (sret == 1) + goto out; + if (sret == 0 && scf_pg_update(pg) != -1) { + scf_transaction_reset(tx); + goto top; + } + err = error_scf(error, scf_error()); + +out: + scf_entry_destroy(ent); + scf_transaction_destroy(tx); + scf_pg_destroy(pg); + scf_instance_destroy(instance); + scf_service_destroy(service); + scf_handle_destroy(scfhandle); + + return (err); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_deleteProperty(rad_instance_t *inst, + adr_method_t *meth, data_t **ret, data_t **args, int count, data_t **error) +{ + conerr_t err = ce_ok; + const char *pgname = data_to_string(args[0]); + const char *propname = data_to_string(args[1]); + int sret; + + servinst_t *si = instance_getdata(inst); + + scf_handle_t *scfhandle = handle_create(); + scf_service_t *service = scf_service_create(scfhandle); + scf_instance_t *instance = scf_instance_create(scfhandle); + scf_propertygroup_t *pg = scf_pg_create(scfhandle); + scf_transaction_t *tx = scf_transaction_create(scfhandle); + scf_transaction_entry_t *ent = scf_entry_create(scfhandle); + + if (scfhandle == NULL || service == NULL || instance == NULL || + pg == NULL || tx == NULL || ent == NULL) { + err = error_scf(error, SCF_ERROR_NO_MEMORY); + goto out; + } + + if (scf_handle_decode_fmri(scfhandle, si->fmri, NULL, service, + instance, NULL, NULL, 0) != SCF_SUCCESS) { + rad_log(RL_WARN, "Couldn't decode '%s': %s\n", + si->fmri, scf_strerror(scf_error())); + err = error_scf(error, scf_error()); + goto out; + } + + if (si->instance) { + /* XXX: really, really silly logic from original java */ + if (scf_instance_get_pg(instance, pgname, pg) != 0 && + scf_service_get_pg(service, pgname, pg) != 0) { + err = error_scf(error, scf_error()); + goto out; + } + } else { + if (scf_service_get_pg(service, pgname, pg) != 0) { + err = error_scf(error, scf_error()); + goto out; + } + } + +top: + if (scf_transaction_start(tx, pg) == -1) { + err = error_scf(error, scf_error()); + goto out; + } + if (scf_transaction_property_delete(tx, ent, propname) != 0) { + err = error_scf(error, scf_error()); + goto out; + } + + sret = scf_transaction_commit(tx); + if (sret == 1) + goto out; + if (sret == 0 && scf_pg_update(pg) != -1) { + scf_transaction_reset(tx); + goto top; + } + err = error_scf(error, scf_error()); + +out: + scf_entry_destroy(ent); + scf_transaction_destroy(tx); + scf_pg_destroy(pg); + scf_instance_destroy(instance); + scf_service_destroy(service); + scf_handle_destroy(scfhandle); + + return (err); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_getPropertyTemplate(rad_instance_t *inst, + adr_method_t *meth, data_t **ret, data_t **args, int count, data_t **error) +{ + conerr_t err = ce_ok; + const char *pgname = data_to_string(args[0]); + const char *propname = data_to_string(args[1]); + const char *locale = data_to_string(args[2]); + + servinst_t *si = instance_getdata(inst); + scf_handle_t *scfhandle = handle_create(); + scf_pg_tmpl_t *pgtmpl = scf_tmpl_pg_create(scfhandle); + scf_prop_tmpl_t *proptmpl = scf_tmpl_prop_create(scfhandle); + + if (scfhandle == NULL || pgtmpl == NULL || proptmpl == NULL) { + err = error_scf(error, SCF_ERROR_NO_MEMORY); + goto out; + } + + if (scf_tmpl_get_by_pg_name(si->fmri, NULL, pgname, NULL, pgtmpl, + 0) == -1 || + scf_tmpl_get_by_prop(pgtmpl, propname, proptmpl, 0) == -1) { + err = error_scf(error, scf_error()); + goto out; + } + + data_t *result = data_new_struct(&t__Template); + + char *name; + if (scf_tmpl_prop_common_name(proptmpl, locale, &name) >= 0) + struct_set(result, "name", data_new_string(name, lt_free)); + + if (scf_tmpl_prop_description(proptmpl, locale, &name) >= 0) + struct_set(result, "description", + data_new_string(name, lt_free)); + + if (scf_tmpl_prop_units(proptmpl, locale, &name) >= 0) + struct_set(result, "units", data_new_string(name, lt_free)); + + uint8_t vis; + if (scf_tmpl_prop_visibility(proptmpl, &vis) == -1) { + data_free(result); + goto out; + } + data_t *visvalue = NULL; + switch (vis) { + case SCF_TMPL_VISIBILITY_HIDDEN: + visvalue = &e__PropertyVisibility_HIDDEN; + break; + case SCF_TMPL_VISIBILITY_READONLY: + visvalue = &e__PropertyVisibility_READONLY; + break; + case SCF_TMPL_VISIBILITY_READWRITE: + visvalue = &e__PropertyVisibility_READWRITE; + break; + } + struct_set(result, "visibility", visvalue); + + scf_values_t values; + if (scf_tmpl_prop_internal_seps(proptmpl, &values) == 0) { + data_t *array = + data_new_array(&t_array_string, values.value_count); + for (int i = 0; i < values.value_count; i++) + (void) array_add(array, data_new_string( + values.values_as_strings[i], lt_copy)); + struct_set(result, "separators", array); + scf_values_destroy(&values); + } + + if (scf_tmpl_value_name_choices(proptmpl, &values) == 0) { + data_t *array = + data_new_array(&t_array_string, values.value_count); + for (int i = 0; i < values.value_count; i++) + (void) array_add(array, data_new_string( + values.values_as_strings[i], lt_copy)); + struct_set(result, "allowed", array); + scf_values_destroy(&values); + } + + if ((*ret = data_purify_deep(result)) == NULL) + err = error_scf(error, SCF_ERROR_NO_MEMORY); +out: + scf_tmpl_prop_destroy(proptmpl); + scf_tmpl_pg_destroy(pgtmpl); + scf_handle_destroy(scfhandle); + + return (err); +} + +static int +get_localedprop(servinst_t *si, const char *locale, const char *name, + data_t **ret, data_t **error) +{ + char *str; + rad_propvec_t *badprop; + rad_propvec_t evec[] = { + { locale, NULL, SCF_TYPE_ASTRING, &str, 0 }, + { NULL } + }; + + int scferr = rad_read_propvec(si->fmri, name, si->instance, evec, + &badprop); + if (scferr != 0) { + if (error != NULL && scferr == SCF_ERROR_NOT_FOUND) { + *ret = NULL; + return (ce_ok); + } + return (error_scf(error, scferr)); + } + + *ret = data_new_string(str, lt_copy); + rad_clean_propvec(evec); + return (ce_ok); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_getCommonName(rad_instance_t *inst, + adr_method_t *meth, data_t **ret, data_t **args, int count, data_t **error) +{ + const char *locale = data_to_string(args[0]); + servinst_t *si = instance_getdata(inst); + + if (get_localedprop(si, locale, SCF_PG_TM_COMMON_NAME, ret, NULL) + == ce_ok) + return (ce_ok); + return (get_localedprop(si, "C", SCF_PG_TM_COMMON_NAME, ret, error)); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_getDescription(rad_instance_t *inst, + adr_method_t *meth, data_t **ret, data_t **args, int count, data_t **error) +{ + const char *locale = data_to_string(args[0]); + servinst_t *si = instance_getdata(inst); + + if (get_localedprop(si, locale, SCF_PG_TM_DESCRIPTION, ret, NULL) + == ce_ok) + return (ce_ok); + return (get_localedprop(si, "C", SCF_PG_TM_DESCRIPTION, ret, error)); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_getLogInfo(rad_instance_t *inst, + adr_method_t *meth, data_t **ret, data_t **args, int count, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + if (!si->instance) + return (ce_object); + + char *logname = NULL; + rad_propvec_t evec[] = { + { SCF_PROPERTY_LOGFILE, NULL, SCF_TYPE_USTRING, &logname, 0 }, + { NULL } + }; + + rad_propvec_t *badprop; + int errval = rad_read_propvec(si->fmri, SCF_PG_RESTARTER, B_FALSE, + evec, &badprop); + if (errval != 0) + return (ce_object); + + struct stat st; + if (stat(logname, &st) != 0) { + free(logname); + return (ce_object); + } + + int max_size = data_to_integer(args[0]); + + int bsize = max_size >= 0 && max_size < st.st_size ? + max_size : st.st_size; + char *buffer = malloc(bsize); + if (buffer == NULL) { + free(logname); + return (ce_nomem); + } + + int fd; + if ((fd = open(logname, O_RDONLY)) == -1) { + free(buffer); + free(logname); + return (ce_priv); + } + + if (pread(fd, buffer, bsize, st.st_size - bsize) != bsize) { + (void) close(fd); + free(buffer); + free(logname); + return (ce_system); + } + + (void) close(fd); + + data_t *result = data_new_struct(&t__LogInfo); + struct_set(result, "name", data_new_string(logname, lt_free)); + struct_set(result, "size", data_new_integer(st.st_size)); + struct_set(result, "MTime", data_new_time_ts(&st.st_mtim)); + struct_set(result, "contents", data_new_opaque(buffer, bsize, lt_free)); + + if ((*ret = data_purify(result)) == NULL) + return (ce_object); + + return (ce_ok); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_delete(rad_instance_t *inst, adr_method_t *meth, + data_t **ret, data_t **args, int count, data_t **error) +{ + conerr_t err = ce_ok; + servinst_t *si = instance_getdata(inst); + + scf_handle_t *scfhandle = handle_create(); + scf_service_t *service = scf_service_create(scfhandle); + scf_instance_t *instance = scf_instance_create(scfhandle); + + if (scfhandle == NULL || service == NULL || instance == NULL) { + err = error_scf(error, SCF_ERROR_NO_MEMORY); + goto out; + } + + if (scf_handle_decode_fmri(scfhandle, si->fmri, NULL, service, + instance, NULL, NULL, si->instance ? + SCF_DECODE_FMRI_REQUIRE_INSTANCE : + SCF_DECODE_FMRI_REQUIRE_NO_INSTANCE) != SCF_SUCCESS) { + rad_log(RL_WARN, "Couldn't decode '%s': %s\n", + si->fmri, scf_strerror(scf_error())); + err = error_scf(error, scf_error()); + goto out; + } + + err = simple_scf(error, si->instance ? + scf_instance_delete(instance) : scf_service_delete(service)); +out: + scf_service_destroy(service); + scf_instance_destroy(instance); + scf_handle_destroy(scfhandle); + return (err); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_clear(rad_instance_t *inst, adr_method_t *meth, + data_t **ret, data_t **args, int count, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + if (!si->instance) + return (error_scf(error, SCF_ERROR_INVALID_ARGUMENT)); + + return (simple_scf(error, smf_restore_instance(si->fmri))); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_degrade(rad_instance_t *inst, adr_method_t *meth, + data_t **ret, data_t **args, int count, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + if (!si->instance) + return (error_scf(error, SCF_ERROR_INVALID_ARGUMENT)); + + return (simple_scf(error, smf_degrade_instance(si->fmri, + data_to_boolean(args[0]) ? SMF_IMMEDIATE : 0))); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_maintain(rad_instance_t *inst, adr_method_t *meth, + data_t **ret, data_t **args, int count, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + if (!si->instance) + return (error_scf(error, SCF_ERROR_INVALID_ARGUMENT)); + + return (simple_scf(error, smf_maintain_instance(si->fmri, + data_to_boolean(args[0]) ? SMF_IMMEDIATE : 0))); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_restart(rad_instance_t *inst, adr_method_t *meth, + data_t **ret, data_t **args, int count, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + if (!si->instance) + return (error_scf(error, SCF_ERROR_INVALID_ARGUMENT)); + + return (simple_scf(error, smf_restart_instance(si->fmri))); +} + +/* ARGSUSED */ +conerr_t +interface_ServiceInfo_invoke_refresh(rad_instance_t *inst, adr_method_t *meth, + data_t **ret, data_t **args, int count, data_t **error) +{ + servinst_t *si = instance_getdata(inst); + if (!si->instance) + return (error_scf(error, SCF_ERROR_INVALID_ARGUMENT)); + + return (simple_scf(error, smf_refresh_instance(si->fmri))); +} + +/* ARGSUSED */ +conerr_t +interface_Aggregator_read_services(rad_instance_t *inst, adr_attribute_t *attr, + data_t **data, data_t **error) +{ + rad_mutex_enter(&service_lock); + data_t *result = data_new_array(&t_array__Service, service_count); + + for (servinst_t *si = list_head(&service_list); si != NULL; + si = list_next(&service_list, si)) { + data_t *insts = data_new_array(&t_array_string, si->ninstances); + for (servinst_t *i = list_head(&si->instances); i != NULL; + i = list_next(&si->instances, i)) + (void) array_add(insts, data_new_string(i->iname, + lt_copy)); + + data_t *service = data_new_struct(&t__Service); + struct_set(service, "fmri", data_new_string(si->fmri, lt_copy)); + struct_set(service, "objectName", instance_getname(si->inst)); + struct_set(service, "instances", insts); + (void) array_add(result, service); + } + + if (data_verify(result, NULL, B_TRUE)) + *data = result; + else + data_free(result); + + rad_mutex_exit(&service_lock); + return (*data != NULL ? ce_ok : ce_object); +} + +/* ARGSUSED */ +conerr_t +interface_Aggregator_read_instances(rad_instance_t *inst, adr_attribute_t *attr, + data_t **data, data_t **error) +{ + conerr_t err = ce_ok; + + scf_handle_t *scfhandle = handle_create(); + scf_service_t *service = scf_service_create(scfhandle); + scf_instance_t *instance = scf_instance_create(scfhandle); + scf_propertygroup_t *pg = scf_pg_create(scfhandle); + scf_property_t *prop = scf_property_create(scfhandle); + scf_value_t *val = scf_value_create(scfhandle); + + if (scfhandle == NULL || service == NULL || instance == NULL || + pg == NULL || prop == NULL || prop == NULL || + val == NULL) { + err = error_scf(error, SCF_ERROR_NO_MEMORY); + goto out; + } + + rad_mutex_enter(&service_lock); + data_t *result = data_new_array(&t_array__Instance, instance_count); + + /* + * It would be easy to iterate over all instances -- not just the + * ones we know about -- but until we dynamically add and remove + * their MBeans we'll stick to our list to avoid confusion. + */ + for (servinst_t *si = list_head(&instance_list); si != NULL; + si = list_next(&instance_list, si)) { + + char statestr[MAX_SCF_STATE_STRING_SZ]; + ssize_t len; + int64_t seconds; + int32_t ns; + + if (scf_handle_decode_fmri(scfhandle, si->fmri, NULL, service, + instance, NULL, NULL, 0) != SCF_SUCCESS) + continue; + if (scf_instance_get_pg(instance, SCF_PG_RESTARTER, pg) != 0) + continue; + + if (scf_pg_get_property(pg, SCF_PROPERTY_STATE, prop) != 0 || + scf_property_get_value(prop, val) != 0 || + (len = scf_value_get_as_string(val, statestr, + MAX_SCF_STATE_STRING_SZ)) == -1 || + len > MAX_SCF_STATE_STRING_SZ - 1) + continue; + + if (scf_pg_get_property(pg, SCF_PROPERTY_STATE_TIMESTAMP, + prop) != 0 || scf_property_get_value(prop, val) != 0 || + scf_value_get_time(val, &seconds, &ns) != 0) + continue; + + data_t *inst = data_new_struct(&t__Instance); + struct_set(inst, "fmri", data_new_string(si->fmri, lt_copy)); + struct_set(inst, "objectName", instance_getname(si->inst)); + struct_set(inst, "STime", data_new_time(seconds, ns)); + struct_set(inst, "state", state2enum(statestr)); + if (!data_verify(inst, NULL, B_TRUE)) + data_free(inst); + else + (void) array_add(result, inst); + } + + if ((*data = data_purify(result)) == NULL) + err = ce_object; + rad_mutex_exit(&service_lock); +out: + scf_value_destroy(val); + scf_property_destroy(prop); + scf_pg_destroy(pg); + scf_instance_destroy(instance); + scf_service_destroy(service); + scf_handle_destroy(scfhandle); + + return (err); +} + +static rad_moderr_t +notify_thread(rad_thread_t *arg) +{ + scf_handle_t *scfhandle = handle_create(); + scf_service_t *service = scf_service_create(scfhandle); + scf_instance_t *instance = scf_instance_create(scfhandle); + scf_propertygroup_t *pg = scf_pg_create(scfhandle); + char fmri[5]; + char sname[1000], iname[1000]; + servinst_t *si; + int ret; + + if (scfhandle == NULL || service == NULL || instance == NULL || + pg == NULL || + _scf_notify_add_pgtype(scfhandle, SCF_GROUP_FRAMEWORK) != 0) + goto out; + + rad_thread_ack(arg, rm_ok); + while ((ret = _scf_notify_wait(pg, fmri, 5)) >= 0) { + rad_log(RL_DEBUG, "received SMF event"); + + if (ret > 0) + continue; /* We should care */ + + if (scf_pg_get_parent_instance(pg, instance) != 0 || + scf_instance_get_parent(instance, service) != 0 || + scf_instance_get_name(instance, iname, 1000) == -1 || + scf_service_get_name(service, sname, 1000) == -1) + continue; + + rad_mutex_enter(&service_lock); + + for (si = list_head(&instance_list); si != NULL; + si = list_next(&instance_list, si)) + if (strcmp(si->iname, iname) == 0 && + strcmp(si->sname, sname) == 0) + break; + + if (si == NULL) { + rad_mutex_exit(&service_lock); + continue; + } + + rad_log(RL_DEBUG, "identified SMF event: %s/%s", sname, iname); + + data_t *stime = NULL, *state = NULL, *nstate = NULL; + data_t *astate = NULL, *reason = NULL; + + /* Inefficient, but expedient */ + (void) interface_ServiceInfo_read_stime(si->inst, NULL, &stime, + NULL); + (void) interface_ServiceInfo_read_state(si->inst, NULL, &state, + NULL); + (void) interface_ServiceInfo_read_nextState(si->inst, NULL, + &nstate, NULL); + (void) interface_ServiceInfo_read_auxiliaryState(si->inst, NULL, + &astate, NULL); + (void) interface_ServiceInfo_read_reason(si->inst, NULL, + &reason, NULL); + + data_t *event = data_new_struct(&t__StateChange); + struct_set(event, "source", instance_getname(si->inst)); + struct_set(event, "state", state); + struct_set(event, "nextState", nstate); + struct_set(event, "stateTime", stime); + struct_set(event, "auxState", astate); + struct_set(event, "reason", reason); + struct_set(event, "anomaly", data_new_boolean(B_FALSE)); + if (data_verify(event, NULL, B_FALSE)) { + rad_log(RL_DEBUG, "sending SMF event"); + if (agg_inst != NULL) + instance_notify(agg_inst, "statechange", + 0, data_ref(event)); + instance_notify(si->inst, "statechange", 0, event); + } else { + rad_log(RL_DEBUG, "failed to send SMF event"); + data_free(event); + } + + rad_mutex_exit(&service_lock); + } + rad_log(RL_ERROR, "_scf_notify_wait failed: %s", + scf_strerror(scf_error())); + + /* XXX: reestablish on configd death */ +out: + scf_pg_destroy(pg); + scf_instance_destroy(instance); + scf_service_destroy(service); + scf_handle_destroy(scfhandle); + + rad_log(RL_ERROR, "exiting SMF event loop"); + + return (rm_system); +} + +static servinst_t * +make_service(char *sname, char *iname) +{ + adr_name_t *objname; + boolean_t inst = iname != NULL; + servinst_t *si = rad_zalloc(sizeof (servinst_t)); + si->sname = strdup(sname); + si->iname = inst ? strdup(iname) : NULL; + /* LINTED */ + if (si->instance = inst) { + (void) asprintf(&si->fmri, "svc:/%s:%s", sname, iname); + objname = adr_name_vcreate( + "com.oracle.solaris.vp.panel.common.api.smf_old", 3, + "type", "service", "service", sname, "instance", iname); + } else { + list_create(&si->instances, sizeof (servinst_t), + offsetof(servinst_t, snode)); + (void) asprintf(&si->fmri, "svc:/%s", sname); + objname = adr_name_vcreate( + "com.oracle.solaris.vp.panel.common.api.smf_old", 2, + "type", "service", "service", sname); + } + si->inst = instance_create(objname, &interface_ServiceInfo_svr, + si, NULL); + (void) cont_insert(rad_container, si->inst, INST_ID_PICK); + + if (inst) { + list_insert_tail(&instance_list, si); + instance_count++; + } else { + list_insert_tail(&service_list, si); + service_count++; + } + + + return (si); +} + +static rad_modinfo_t modinfo = { "smf_old", "Legacy SMF module" }; + +int +_rad_init(void *handle) +{ + if (rad_module_register(handle, RAD_MODVERSION, &modinfo) == -1) + return (-1); + + if (rad_isproxy) + return (0); + + list_create(&service_list, sizeof (servinst_t), + offsetof(servinst_t, node)); + list_create(&instance_list, sizeof (servinst_t), + offsetof(servinst_t, node)); + + scf_handle_t *scfhandle = handle_create(); + scf_scope_t *scope = scf_scope_create(scfhandle); + scf_iter_t *siter = scf_iter_create(scfhandle); + scf_iter_t *iiter = scf_iter_create(scfhandle); + scf_service_t *service = scf_service_create(scfhandle); + scf_instance_t *instance = scf_instance_create(scfhandle); + + (void) scf_handle_get_scope(scfhandle, SCF_SCOPE_LOCAL, scope); + (void) scf_iter_scope_services(siter, scope); + while (scf_iter_next_service(siter, service) > 0) { + char svcname[1000]; + (void) scf_service_get_name(service, svcname, 1000); + servinst_t *svc = make_service(svcname, NULL); + (void) scf_iter_service_instances(iiter, service); + while (scf_iter_next_instance(iiter, instance) > 0) { + char instname[1000]; + (void) scf_instance_get_name(instance, instname, 1000); + list_insert_tail(&svc->instances, + make_service(svcname, instname)); + svc->ninstances++; + } + } + + scf_instance_destroy(instance); + scf_service_destroy(service); + scf_iter_destroy(iiter); + scf_iter_destroy(siter); + scf_scope_destroy(scope); + scf_handle_destroy(scfhandle); + + agg_inst = instance_create(adr_name_fromstr(aggregator_pattern), + &interface_Aggregator_svr, NULL, NULL); + if (agg_inst != NULL) + (void) cont_insert(rad_container, agg_inst, INST_ID_PICK); + + if (rad_thread_create(notify_thread, NULL) != rm_ok) + rad_log(RL_ERROR, "failed to start SMF listener"); + return (0); +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/cmd/rad/mod/smf_old/propvec.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/cmd/rad/mod/smf_old/propvec.c Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,254 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "propvec.h" + +extern scf_handle_t *handle_create(void); + +static scf_type_t +scf_true_base_type(scf_type_t type) +{ + scf_type_t base = type; + + do { + type = base; + (void) scf_type_base_type(type, &base); + } while (base != type); + + return (base); +} + +/* + * Convenience routine which frees all strings and opaque data + * allocated by scf_read_propvec. + * + * Like free(3C), this function preserves the value of errno. + */ +void +rad_clean_propvec(rad_propvec_t *propvec) +{ + int saved_errno = errno; + rad_propvec_t *prop; + + for (prop = propvec; prop->pv_prop != NULL; prop++) { + assert(prop->pv_type != SCF_TYPE_INVALID); + if (prop->pv_type == SCF_TYPE_OPAQUE) { + rad_opaque_t *o = prop->pv_ptr; + + if (o->so_addr != NULL) + free(o->so_addr); + } else if (scf_true_base_type(prop->pv_type) == + SCF_TYPE_ASTRING) { + if (*(char **)prop->pv_ptr != NULL) + free(*(char **)prop->pv_ptr); + } + } + + errno = saved_errno; +} + +/* + * Reads a vector of properties from the specified fmri/property group. + * If 'running' is true, reads from the running snapshot instead of the + * editing snapshot. + * + * For string types, a buffer is allocated using malloc(3C) to hold the + * zero-terminated string, a pointer to which is stored in the + * caller-provided char **. It is the caller's responsbility to free + * this string. To simplify error handling, unread strings are + * initialized to NULL. + * + * For opaque types, a buffer is allocated using malloc(3C) to hold the + * opaque data. A pointer to this buffer and its size are stored in + * the caller-provided rad_opaque_t. It is the caller's responsibility + * to free this buffer. To simplify error handling, the address fields + * for unread opaque data are initialized to NULL. + * + * All other data is stored directly in caller-provided variables or + * structures. + * + * If this function fails to read a specific property, *badprop is set + * to point at that property's entry in the properties array. + * + * On all failures, all memory allocated by this function is freed. + */ +int +rad_read_propvec(const char *fmri, const char *pgname, boolean_t running, + rad_propvec_t *properties, rad_propvec_t **badprop) +{ + scf_handle_t *h = handle_create(); + scf_service_t *s = scf_service_create(h); + scf_instance_t *i = scf_instance_create(h); + scf_snapshot_t *snap = running ? scf_snapshot_create(h) : NULL; + scf_propertygroup_t *pg = scf_pg_create(h); + scf_property_t *p = scf_property_create(h); + scf_value_t *v = scf_value_create(h); + boolean_t instance = B_TRUE; + rad_propvec_t *prop; + int error = 0; + + for (prop = properties; prop->pv_prop != NULL; prop++) { + if (prop->pv_type == SCF_TYPE_OPAQUE) + ((rad_opaque_t *)prop->pv_ptr)->so_addr = NULL; + else if (scf_true_base_type(prop->pv_type) == SCF_TYPE_ASTRING) + *((char **)prop->pv_ptr) = NULL; + } + + if (h == NULL || s == NULL || i == NULL || (running && snap == NULL) || + pg == NULL || p == NULL || v == NULL) + goto scferror; + + if (scf_handle_decode_fmri(h, fmri, NULL, s, i, NULL, NULL, 0) == -1) + goto scferror; + + if (scf_instance_to_fmri(i, NULL, 0) == -1) { + if (scf_error() != SCF_ERROR_NOT_SET) + goto scferror; + instance = B_FALSE; + } + + if (running) { + if (!instance) { + error = SCF_ERROR_TYPE_MISMATCH; + goto out; + } + + if (scf_instance_get_snapshot(i, "running", snap) != + SCF_SUCCESS) + goto scferror; + } + + if ((instance ? scf_instance_get_pg_composed(i, snap, pgname, pg) : + scf_service_get_pg(s, pgname, pg)) == -1) + goto scferror; + + for (prop = properties; prop->pv_prop != NULL; prop++) { + int ret = 0; + + if (scf_pg_get_property(pg, prop->pv_prop, p) == -1 || + scf_property_get_value(p, v) == -1) { + *badprop = prop; + goto scferror; + } + switch (prop->pv_type) { + case SCF_TYPE_BOOLEAN: { + uint8_t b; + + ret = scf_value_get_boolean(v, &b); + if (ret == -1) + break; + if (prop->pv_aux != 0) { + uint64_t *bits = prop->pv_ptr; + *bits = b ? (*bits | prop->pv_aux) : + (*bits & ~prop->pv_aux); + } else { + boolean_t *bool = prop->pv_ptr; + *bool = b ? B_TRUE : B_FALSE; + } + break; + } + case SCF_TYPE_COUNT: + ret = scf_value_get_count(v, prop->pv_ptr); + break; + case SCF_TYPE_INTEGER: + ret = scf_value_get_integer(v, prop->pv_ptr); + break; + case SCF_TYPE_TIME: { + scf_time_t *time = prop->pv_ptr; + + ret = scf_value_get_time(v, &time->t_seconds, + &time->t_ns); + break; + } + case SCF_TYPE_OPAQUE: { + rad_opaque_t *opaque = prop->pv_ptr; + ssize_t size = scf_value_get_opaque(v, NULL, 0); + + if (size == -1) { + *badprop = prop; + goto scferror; + } + if ((opaque->so_addr = malloc(size)) == NULL) { + error = SCF_ERROR_NO_MEMORY; + rad_clean_propvec(properties); + goto out; + } + opaque->so_size = size; + ret = scf_value_get_opaque(v, opaque->so_addr, size); + break; + } + default: { + char *s; + ssize_t size; + + assert(scf_true_base_type(prop->pv_type) == + SCF_TYPE_ASTRING); + + size = scf_value_get_astring(v, NULL, 0); + if (size == -1) { + *badprop = prop; + goto scferror; + } + if ((s = malloc(++size)) == NULL) { + error = SCF_ERROR_NO_MEMORY; + rad_clean_propvec(properties); + goto out; + } + ret = scf_value_get_astring(v, s, size); + *(char **)prop->pv_ptr = s; + } + + if (ret == -1) { + *badprop = prop; + goto scferror; + } + + } + } + + goto out; + +scferror: + error = scf_error(); + rad_clean_propvec(properties); +out: + scf_value_destroy(v); + scf_property_destroy(p); + scf_pg_destroy(pg); + scf_snapshot_destroy(snap); + scf_instance_destroy(i); + scf_service_destroy(s); + scf_handle_destroy(h); + + return (error); +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/cmd/rad/mod/smf_old/propvec.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/cmd/rad/mod/smf_old/propvec.h Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _PROPVEC_H +#define _PROPVEC_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + void *so_addr; + size_t so_size; +} rad_opaque_t; + +typedef struct { + const char *pv_prop; + const char *pv_desc; + scf_type_t pv_type; + void *pv_ptr; + uint64_t pv_aux; +} rad_propvec_t; + +void rad_clean_propvec(rad_propvec_t *); +int rad_read_propvec(const char *, const char *, boolean_t, + rad_propvec_t *, rad_propvec_t **); + +#ifdef __cplusplus +} +#endif + +#endif /* _PROPVEC_H */ diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/doc/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/doc/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,28 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +include $(SRC)/make-rules/Makefile.env + +include $(SRC)/make-rules/Makefile.targ diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/doc/Makefile.doc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/doc/Makefile.doc Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,64 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. +# + +include $(SRC)/make-rules/Makefile.env + +# The location of the DocBook XSL stylesheets to use. Most systems +# should provide a catalog which automatically maps from the +# DOCBOOK_XSL URL to a local path. + +DOCBOOK_XSL= http://docbook.sourceforge.net/release/xsl/current + +STYLESHEET= profile-docbook.xsl +FO_XSL= $(DOCBOOK_XSL)/fo/$(STYLESHEET) +HTML_XSL= $(DOCBOOK_XSL)/html/$(STYLESHEET) +MAN_XSL= $(DOCBOOK_XSL)/manpages/$(STYLESHEET) + +# The sections of the documentation that make comments intended for an +# internal audience are given a status of "private". Setting STATUS to +# something other than "private" will cause those sections to be +# eliminated from the generated output. + +STATUS= private +DBOPTS= \ + --stringparam funcsynopsis.style "ansi" \ + --stringparam man.authors.section.enabled 0 \ + --stringparam section.autolabel 1 \ + --stringparam section.label.includes.component.label 1 \ + --stringparam segmentedlist.as.table 1 \ + --stringparam profile.status "$(STATUS)" + +# We assume xsltproc, xmllint, and Apache fop are all in the user's +# path. + +XSLTPROC= xsltproc --xinclude --nonet +XMLLINT= xmllint --xinclude --postvalid --noout + +DBXSLTPROC= $(XSLTPROC) $(DBOPTS) +FOP= fop + +# Commands + +XSLT.man = $(DBXSLTPROC) $(MAN_XSL) $< diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/doc/manpage/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/doc/manpage/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,78 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +include ../Makefile.doc + +APISDIR = ../../apis +APIS_CMD = (cd $(APISDIR); $(LS) -1 *.xml 2>/dev/null; $(TRUE)) +#APIS = $(APIS_CMD:sh) +#APIS = kstat.xml smf.xml zonesbridge.xml +#APIS = smf.xml + +#MANPAGES_1 = radadrgen.1 vp.1 +MANPAGES_1 = vp.1 +#MANPAGES_1m = rad.1m +#MANPAGES_3rad = $(APIS:%.xml=%.3rad) +#MANPAGES = $(MANPAGES_1) $(MANPAGES_1m) $(MANPAGES_3rad) +MANPAGES = $(MANPAGES_1) +CLOBBER_FILES += $(MANPAGES) +SRCS = \ + $(MANPAGES_1:%=%.xml) +INSTALLED_FILES = \ + $(MANPAGES_1:%=$(PROTO_MAN)/man1/%) + +build: $(MANPAGES) + +lint: + $(XMLLINT) $(SRCS) + +install: $(INSTALLED_FILES) + +# Man page rules. Must be updated if new sections are added. + +DBOPTS += --param refentry.meta.get.quietly 1 + +# DocBook's man page stylesheets assume we are using groff with its left- +# and right-quote character constants. A more portable approach would be +# to reference the left- and right-quote string constants. FIX_MAN maps +# from one to the other. + +FIX_MAN = -echo '1,$$s/(lq/*(lq/g\n1,$$s/(rq/*(rq\nw' | ed -s $@ + +$(PROTO_MAN)/man1/% $(PROTO_MAN)/man1m/% $(PROTO_MAN)/man3rad/%: % + $(INS.file) + +%.1: %.1.xml + $(XSLT.man) + $(FIX_MAN) + +%.1m: %.1m.xml + $(XSLT.man) + $(FIX_MAN) + +%.3rad: $(APISDIR)/%.xml + $(RADADRGEN) -N -o man $< > $@ + +include $(SRC)/make-rules/Makefile.targ diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/doc/manpage/vp.1.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/doc/manpage/vp.1.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,154 @@ + + + + + + + SunOS + 5.11 + + + + vp + 1 + User Commands + + + + vp + starts a Visual Panels UI + + + + + /usr/bin/vp + + host + + + port + + + user + + + role + + + + address + + + + + /usr/bin/vp + + + + + /usr/bin/vp + + + + + Description + + vp starts the Visual Panels UI specified by + address. + + + + Options + + The following options are supported: + + + host + + Connect to host host. + + + + + port + + Connect to port port. + + + + + user + + Log in as user user. + + + + + role + + Log in as role role. + + + + + + + Launch the specified panel using a new JVM. Normally an + existing JVM is used, if available. + + + + + + + Print the version number and exit. + + + + + + + Print the help message and exit. + + + + + + + Operands + + The following operand is supported: + + + address + + The address of the management panel to open. + + + + + + + See Also + + + rad + 1M + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,40 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +MSUBDIRS = vpanels +ASUBDIRS = util sleeklock smf smf-old +GSUBDIRS = lib + +lint: + +vpanels: util smf-old + +sleeklock: util + +util: lib + +lib: + +include $(SRC)/make-rules/Makefile.ant diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/lib/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/lib/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,52 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. +# + +include ../../../../../../../make-rules/shared-macros.mk + +COMPONENT_VERSION=0.5.11 + +SUBDIRS = TimingFramework swingx + +.PHONY: $(SUBDIRS) + +download: TARGET = download +prep: TARGET = prep +build: TARGET = build +install: TARGET = install +clean: TARGET = clean +clobber: TARGET = clobber +test: TARGET = test + +.DEFAULT: publish + +download prep build install test: $(SUBDIRS) + +clean: $(SUBDIRS) + $(RM) -r prototype build + +clobber: $(SUBDIRS) clean + +$(SUBDIRS): FORCE + @cd $@ && echo "$(TARGET) $@" && $(MAKE) $(TARGET) + +FORCE: diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/lib/TimingFramework/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/lib/TimingFramework/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,56 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +include ../../../../../../../../make-rules/shared-macros.mk +include ../visual-panels.mk + +COMPONENT_NAME= TimingFramework +COMPONENT_VERSION= 1.0 +COMPONENT_SRC= $(COMPONENT_NAME)-$(COMPONENT_VERSION)-src +COMPONENT_ARCHIVE= $(COMPONENT_SRC).zip +COMPONENT_ARCHIVE_HASH= sha256:0829f0afbb3569ba506d20f7f508338f9902a1d82ef786cbf93a6839579f0bcf +COMPONENT_ARCHIVE_URL= http://firebolt.googlecode.com/svn-history/r20/trunk/firebolt/lib/timing-framework/$(COMPONENT_ARCHIVE) + +UNPACK_ARGS= -r $(COMPONENT_SRC) + +include $(WS_MAKE_RULES)/prep.mk +include $(WS_MAKE_RULES)/ant.mk + +COMPONENT_PREP_ACTION = (cp build.xml $(@D)/) + +COMPONENT_BUILD_ARGS += -Ddist=${PROTO_DIR} -Dver=$(COMPONENT_VERSION) +COMPONENT_BUILD_TARGETS += jar + +COMPONENT_INSTALL_ARGS += -Ddist=${PROTO_DIR} -Dver=$(COMPONENT_VERSION) +COMPONENT_INSTALL_TARGETS += install + +# common targets +build: $(BUILD_32) + +install: $(INSTALL_32) + +test: $(NO_TESTS) + +BUILD_PKG_DEPENDENCIES = $(BUILD_TOOLS) + +include $(WS_MAKE_RULES)/depend.mk diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/lib/TimingFramework/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/lib/TimingFramework/build.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/lib/swingx/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/lib/swingx/Makefile Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,52 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# + +include ../../../../../../../../make-rules/shared-macros.mk + +COMPONENT_NAME= swingx +COMPONENT_VERSION= 0.9.3 +COMPONENT_SRC= $(COMPONENT_NAME)-$(COMPONENT_VERSION)-src +COMPONENT_ARCHIVE= $(COMPONENT_SRC).zip +COMPONENT_ARCHIVE_HASH= sha256:d7f2d0f9d26b60b5a12b4dba29d11343a575f900348b32523153fdfedae22853 +COMPONENT_ARCHIVE_URL= http://java.net/downloads/$(COMPONENT_NAME)/releases/$(COMPONENT_VERSION)/$(COMPONENT_ARCHIVE) + +include $(WS_MAKE_RULES)/prep.mk +include $(WS_MAKE_RULES)/ant.mk +include ../visual-panels.mk + +COMPONENT_BUILD_ARGS += -Ddist=${PROTO_DIR} +COMPONENT_BUILD_TARGETS += jar + +# common targets +build: $(BUILD_32) + +install: build + $(MKDIR) $(VP_DIR) + $(CP) $(BUILD_DIR_32)/dist/$(COMPONENT_NAME).jar \ + $(VP_DIR)/$(COMPONENT_NAME)-$(COMPONENT_VERSION).jar + +test: $(NO_TESTS) + +BUILD_PKG_DEPENDENCIES = $(BUILD_TOOLS) + +include $(WS_MAKE_RULES)/depend.mk diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/lib/visual-panels.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/lib/visual-panels.mk Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,24 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. +# +PROTO_DIR = $(WS_COMPONENTS)/visual-panels/core/build/prototype/$(MACH) +VP_DIR = $(PROTO_DIR)/usr/share/vpanels diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/sleeklock/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/sleeklock/build.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/sleeklock/com/oracle/solaris/sleeklock/SleeKlock.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/sleeklock/com/oracle/solaris/sleeklock/SleeKlock.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.sleeklock; + +import java.awt.BorderLayout; +import java.awt.Container; +import javax.swing.JFrame; +import javax.swing.WindowConstants; +import com.oracle.solaris.vp.util.swing.time.AnalogClock; +import com.oracle.solaris.vp.util.swing.time.TimeModelUpdater; + +public class SleeKlock +{ + public static void main(String args[]) { + AnalogClock clock = new AnalogClock(); + clock.setInteractive(false); + clock.setPreferredDiameter(100); + + TimeModelUpdater updater = new TimeModelUpdater(clock.getTimeModel()); + updater.start(); + + JFrame frame = new JFrame("SleeKlock"); + Container c = frame.getContentPane(); + c.setLayout(new BorderLayout()); + c.add(clock, BorderLayout.CENTER); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + frame.pack(); + frame.setVisible(true); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/smf-old/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/smf-old/build.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/smf-old/com/oracle/solaris/scf/common/FMRI.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/smf-old/com/oracle/solaris/scf/common/FMRI.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,432 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.scf.common; + +import java.net.URI; +import java.net.URISyntaxException; +import java.beans.ConstructorProperties; +import java.util.Map; +import java.util.EnumMap; +import javax.management.openmbean.*; + +/** + * A basic FMRI class. Probably should be named "SmfFMRI", as + * legacy-run services aren't an SCF concept. + */ +public class FMRI implements Comparable, CompositeDataView +{ + /* + * Static data + */ + public static final String SCF_SCOPE_LOCAL = "localhost"; + private static final String FORMAT = + "([A-Za-z][_A-Za-z0-9.-]*,)?[_A-Za-z0-9-]*"; + private static final Map scheme_strings = + new EnumMap(FMRIScheme.class); + + static { + scheme_strings.put(FMRIScheme.FILE, "file"); + scheme_strings.put(FMRIScheme.LEGACY, "lrc"); + scheme_strings.put(FMRIScheme.SERVICE, "svc"); + } + + /* + * FMRI components + */ + private FMRIScheme scheme_; + private String scope_ = null; + private String service_ = null; + private String instance_ = null; + private String pg_ = null; + private String property_ = null; + private String name_ = null; + + /* + * Derivative information + */ + private FMRIType svctype_; + private String canonicalStr_; + + /** + * Creates an FMRI from a URI. + */ + public FMRI(URI uri) throws URISyntaxException + { + if (!uri.isAbsolute() || uri.isOpaque()) + throw (new URISyntaxException(uri.toString(), + "Bad FMRI")); + + String scheme = uri.getScheme(); + scope_ = uri.getAuthority(); + if (scope_ == null || scope_.isEmpty() || + scope_.equals(SCF_SCOPE_LOCAL)) + scope_ = null; + canonicalStr_ = new URI(uri.getScheme(), scope_, uri.getPath(), + null, null).toString(); + + if (scheme.equals("svc")) { + scheme_ = FMRIScheme.SERVICE; + svctype_ = FMRIType.SCOPE; + + String[] top = uri.getPath().split("/:properties/", 2); + + String[] next = top[0].split(":", 2); + /* + * We can assume the path starts with a slash + * because we reject relative URIs above. + */ + service_ = next[0].substring(1); + svctype_ = FMRIType.SERVICE; + if (next.length == 2) { + instance_ = next[1]; + if (!instance_.matches(FORMAT)) + throw (new URISyntaxException( + uri.toString(), + "Invalid instance: " + instance_)); + svctype_ = FMRIType.INSTANCE; + } + + if (top.length == 2) { + next = top[1].split("/", 2); + pg_ = next[0]; + if (!pg_.matches(FORMAT)) + throw (new URISyntaxException( + uri.toString(), + "Invalid property group: " + pg_)); + svctype_ = FMRIType.PGROUP; + if (next.length == 2) { + property_ = next[1]; + if (!property_.matches(FORMAT)) + throw (new URISyntaxException( + uri.toString(), + "Invalid property: " + + property_)); + svctype_ = FMRIType.PROPERTY; + } + } + } else if (scheme.equals("file")) { + scheme_ = FMRIScheme.FILE; + name_ = uri.getPath(); + } else if (scheme.equals("lrc")) { + scheme_ = FMRIScheme.LEGACY; + name_ = uri.getPath(); + } else { + throw (new URISyntaxException(uri.toString(), + "Invalid FMRI scheme: " + scheme)); + } + } + + /** + * Creates an FMRI from a string. + */ + public FMRI(String fmri) throws URISyntaxException + { + /* Work around bug 6504439 in scf_scope_to_fmri */ + this(new URI(fmri.equals("svc:") ? "svc:///" : fmri)); + } + + /** + * Constucts an FMRI from its attributes. Needed for the class to be + * reconstructable. + */ + @SuppressWarnings({"fallthrough"}) + @ConstructorProperties({"scheme", "svcType", "scope", "name", "service", + "instance", "propertyGroup", "property"}) + public FMRI(FMRIScheme scheme, FMRIType type, String scope, String name, + String service, String instance, String pg, String property) + { + scheme_ = scheme; + + scope_ = scope; + if (scope_ == null || scope_.isEmpty() || + scope_.equals(SCF_SCOPE_LOCAL)) + scope_ = null; + + String path; + if (scheme != FMRIScheme.SERVICE) { + svctype_ = FMRIType.NONE; + path = name_ = name; + } else { + svctype_ = type; + name_ = null; + + path = ""; + switch (svctype_) { + case PROPERTY: + property_ = property; + path = "/" + property + path; + case PGROUP: + pg_ = pg; + path = "/:properties/" + pg + path; + case INSTANCE: + instance_ = instance; + path = ":" + instance + path; + case SERVICE: + service_ = service; + path = "/" + service + path; + } + } + + try { + URI uri = new URI(scheme_strings.get(scheme), scope_, + path, null, null); + canonicalStr_ = uri.toString(); + } catch (URISyntaxException ex) { + canonicalStr_ = null; + } + } + + /** + * Returns the FMRI's type (scheme). + */ + public FMRIScheme getScheme() + { + return (scheme_); + } + + /** + * Returns a svc: FMRI's type. + */ + public FMRIType getSvcType() + { + if (scheme_ != FMRIScheme.SERVICE) + throw (new FMRIException(this, "not a service FMRI")); + return (svctype_); + } + + /** + * Returns the FMRI's scope. + */ + public String getScope() + { + return (scope_ == null ? SCF_SCOPE_LOCAL : scope_); + } + + /** + * Returns the name of a legacy-run or file FMRI. + */ + public String getName() + { + if (scheme_ == FMRIScheme.SERVICE) + throw (new FMRIException(this, + "not a file or legacy FMRI")); + return (name_); + } + + /** + * Throws an FMRIException from a function which may only be + * called on a svc: FMRI. Takes the FMRIType required by the + * caller. + */ + private void checktype(FMRIType svctype) + { + String prefix = "unable to read " + svctype; + if (scheme_ != FMRIScheme.SERVICE) + throw (new FMRIException(this, prefix + + " from non-service FMRI")); + if (svctype_.compareTo(svctype) < 0) + throw (new FMRIException(this, prefix + + " from " + svctype_ + "FMRI")); + } + + /** + * Returns the service component of a service FMRI. + */ + public String getService() + { + checktype(FMRIType.SERVICE); + return (service_); + } + + /** + * Returns the instance component of a service FMRI, or {@code + * null} if there is none. + */ + public String getInstance() + { + checktype(FMRIType.INSTANCE); + return (instance_); + } + + /** + * Returns the property group component of a service FMRI. + */ + public String getPropertyGroup() + { + checktype(FMRIType.PGROUP); + return (pg_); + } + + /** + * Returns the property component of a service FMRI. + */ + public String getProperty() + { + checktype(FMRIType.PROPERTY); + return (property_); + } + + public FMRI toServiceFMRI() + { + checktype(FMRIType.SERVICE); + if (svctype_ == FMRIType.SERVICE) + return this; + return (new FMRI(scheme_, FMRIType.SERVICE, scope_, null, + service_, null, null, null)); + } + + public FMRI toInstanceFMRI() + { + checktype(FMRIType.INSTANCE); + if (svctype_ == FMRIType.INSTANCE) + return this; + return (new FMRI(scheme_, FMRIType.INSTANCE, scope_, null, + service_, instance_, null, null)); + } + + public FMRI toInstanceFMRI(String instanceName) + { + checktype(FMRIType.SERVICE); + return (new FMRI(scheme_, FMRIType.INSTANCE, scope_, null, + service_, instanceName, null, null)); + } + + + /* + * CompositeDataView methods + */ + + private static final String[] itemNames = new String[] { "scheme", + "svcType", "scope", "name", "service", "instance", "propertyGroup", + "property" }; + + /* + * Manually convert the FMRI to its automatically-determined + * CompositeType. This conversion is normally performed by the + * MXBean implementation, but the automatic conversion uses our + * accessors to inspect the object. Performing the conversion + * manually permits us to circumvent the run-time checking + * performed by our accessors (or to put it differently, permits + * us to leave the run-time checking in place). + */ + public CompositeData toCompositeData(CompositeType ct) + { + Object[] itemValues = new Object[] { scheme_.name(), + svctype_.name(), scope_, name_, service_, instance_, pg_, + property_ }; + try { + return (new CompositeDataSupport(ct, itemNames, + itemValues)); + } catch (OpenDataException ex) { + throw (new RuntimeException(ex)); + } + } + + // Comparable methods + + private static int strcmp(String a, String b) + { + if (a == null) + return (b == null ? 0 : 1); + if (b == null) + return (-1); + return (a.compareTo(b)); + } + + public int compareTo(FMRI f) + { + int result = scheme_.compareTo(f.scheme_); + + if (result == 0) + result = strcmp(scope_, f.scope_); + if (scheme_ != FMRIScheme.SERVICE) + result = strcmp(name_, f.name_); + else { + if (result == 0) + result = strcmp(service_, f.service_); + if (result == 0) + result = strcmp(instance_, f.instance_); + if (result == 0) + result = strcmp(pg_, f.pg_); + if (result == 0) + result = strcmp(property_, f.property_); + } + + return (result); + } + + /* + * Object methods + */ + + /** + * Returns the FMRI as a string. + */ + @Override + public String toString() + { + return (canonicalStr_); + } + + @Override + public boolean equals(Object o) + { + if (o == null) + return (false); + + FMRI f; + try { + f = (FMRI)o; + } catch (ClassCastException e) { + return (false); + } + + return (compareTo(f) == 0); + } + + @Override + public int hashCode() + { + int hash = 7; + hash = 79 * hash + + (this.scope_ != null ? this.scope_.hashCode() : 0); + hash = 79 * hash + + (this.service_ != null ? this.service_.hashCode() : 0); + hash = 79 * hash + + (this.instance_ != null ? this.instance_.hashCode() : 0); + hash = 79 * hash + + (this.pg_ != null ? this.pg_.hashCode() : 0); + hash = 79 * hash + + (this.property_ != null ? this.property_.hashCode() : 0); + hash = 79 * hash + + (this.name_ != null ? this.name_.hashCode() : 0); + hash = 79 * hash + + (this.scheme_ != null ? this.scheme_.hashCode() : 0); + hash = 79 * hash + + (this.svctype_ != null ? this.svctype_.hashCode() : 0); + return hash; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/smf-old/com/oracle/solaris/scf/common/FMRIException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/smf-old/com/oracle/solaris/scf/common/FMRIException.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.scf.common; + +import com.oracle.solaris.scf.*; + +/** + * Runtime exception thrown for inproper acccesses to an FMRI. + */ +@SuppressWarnings({"serial"}) +public class FMRIException extends RuntimeException implements HasFMRI +{ + private FMRI fmri_; + + public FMRIException(FMRI fmri, String s) + { + super(s); + fmri_ = fmri; + } + + /** + * Returns the FMRI which was improperly accessed. + */ + public FMRI getFMRI() + { + return (fmri_); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/smf-old/com/oracle/solaris/scf/common/FMRIScheme.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/smf-old/com/oracle/solaris/scf/common/FMRIScheme.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.scf.common; + +/** + * FMRI types, enumerated. + */ +public enum FMRIScheme +{ + /** A service (svc:) */ + SERVICE, + + /** A file (file:) */ + FILE, + + /** A legacy-run service (lrc:) */ + LEGACY; +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/smf-old/com/oracle/solaris/scf/common/FMRIType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/smf-old/com/oracle/solaris/scf/common/FMRIType.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.scf.common; + +/** + * svc: types, enumerated. + */ +public enum FMRIType +{ + /** Not a service FMRI */ + NONE, + + /** A scope */ + SCOPE, + + /** A service */ + SERVICE, + + /** An instance */ + INSTANCE, + + /** A property group */ + PGROUP, + + /** A property */ + PROPERTY +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/smf-old/com/oracle/solaris/scf/common/HasFMRI.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/smf-old/com/oracle/solaris/scf/common/HasFMRI.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,37 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.scf.common; + +/** + * Interface for objects which have FMRIs. + */ +public interface HasFMRI +{ + /** + * Returns the FMRI of the object. + */ + FMRI getFMRI(); +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/smf-old/com/oracle/solaris/scf/common/ScfConstants.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/smf-old/com/oracle/solaris/scf/common/ScfConstants.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,39 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.scf.common; + +/* + * Contains common libscf constants + */ +public interface ScfConstants +{ + // Public static snapshots + String SCF_RUNNING = "running"; + + // Property group types + String SCF_APPLICATION_PG = "application"; + +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/smf-old/com/oracle/solaris/scf/common/ScfException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/smf-old/com/oracle/solaris/scf/common/ScfException.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,67 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.scf.common; + +import com.oracle.solaris.rad.ObjectException; +import com.oracle.solaris.vp.panel.common.api.smf_old.SmfError; +import com.oracle.solaris.vp.panel.common.api.smf_old.SmfErrorCode; + +/** + * The SCF checked exeption class. + * + * XXX: This should be generated by ADRgen + */ +@SuppressWarnings({"serial"}) +public class ScfException extends Exception +{ + private SmfErrorCode error_ = null; + private String msg_ = ""; + + public ScfException(ObjectException e) + { + super(e); + SmfError se = e.getPayload(SmfError.class); + if (se != null) { + error_ = se.getError(); + msg_ = se.getMessage(); + } else { + } + } + + @Override + public String getMessage() + { + return (msg_); + } + + /** + * Returns the error which caused the ScfException. + */ + public SmfErrorCode getError() + { + return (error_); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/smf/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/smf/build.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/util/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/util/build.xml Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/CommandLineParser.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/CommandLineParser.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.util.cli; + +public abstract class CommandLineParser { + // + // Instance data + // + + private String[] args; + + // + // CommandLineParser methods + // + + public String[] getArgs() { + return args; + } + + public abstract boolean isDoneParsing(); + + public abstract void getNextOptArg(ParsedOption option); + + public abstract ParsedOption getNextOption(); + + public abstract OptionFormatter getOptionFormatter(); + + public abstract void reset(); + + public abstract void resetToPreviousOption(); + + public void setArgs(String[] args) { + this.args = args; + reset(); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/CommandLineProcessor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/CommandLineProcessor.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,435 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.util.cli; + +import java.beans.IntrospectionException; +import java.lang.reflect.InvocationTargetException; +import java.util.*; +import com.oracle.solaris.vp.util.cli.exception.*; +import com.oracle.solaris.vp.util.misc.*; + +public class CommandLineProcessor { + // + // Instance data + // + + private OptionGroup group; + private CommandLineParser parser; + private Stack processed; + private Map used; + + // + // Constructors + // + + private CommandLineProcessor(OptionGroup group, CommandLineParser parser) { + this.group = group; + this.parser = parser; + this.processed = new Stack(); + used = new HashMap(); + } + + // + // Private methods + // + + private int getUseCount(Option option) { + try { + return used.get(option); + } + catch (NullPointerException e) { + return 0; + } + } + + private int incUseCount(Option option) { + int count = getUseCount(option) + 1; + used.put(option, count); + return count; + } + + private int decUseCount(Option option) { + int count = getUseCount(option) - 1; + used.put(option, count); + return count; + } + + private boolean isUsed(Option option) { + return getUseCount(option) > 0; + } + + private OptionMap[] getProcessed() { + return processed.toArray(new OptionMap[processed.size()]); + } + + private void process(Option curOpt, OptionMap conflict, String indent) + throws OptionException { + + OptionFormatter formatter = parser.getOptionFormatter(); + +// System.out.println(indent + "Current option: " + +// TextUtil.getClassBaseName(curOpt) + ": " + +// formatter.getFormatted(curOpt, false)); + + if (parser.isDoneParsing()) { + // Last check + verifyRequiredOptions(group); + return; + } + + OptionException exception = null; + + if (curOpt instanceof OptionElement) { + OptionElement element = (OptionElement)curOpt; + + ParsedOption parsed = parser.getNextOption(); +// System.out.println(indent + "Next option: " + +// formatter.getFormatted(parsed.getOpt())); + + // Does this OptionElement expect an opt arg? + if (element.getTakesArgument()) { + // Parse opt arg + parser.getNextOptArg(parsed); + } + + // Create mapping between parsed option and option definition + OptionMap map = new OptionMap(parsed, (OptionElement)curOpt); + +// System.out.println(indent + "Used options:"); +// for (int i = 0, n = processed.size(); i < n; i++) { +// System.out.println(indent + " " + i + ": " + +// processed.get(i).getFormatted(formatter)); +// } + + // Add the mapping to list of saved options + processed.push(map); + + int useCount = incUseCount(element); + + try { + // Validate syntax (throws OptionException) + element.validate(parsed, useCount, formatter, getProcessed()); + +// System.out.println(indent + "Validated option: " + +// map.getFormatted(formatter)); + + // The option is lexically and syntactically valid -- + // check for conflict with previously-specified option + if (conflict != null) { + throw new ConflictingOptionsException( + conflict.getFormatted(formatter), + map.getFormatted(formatter), getProcessed()); + } + + exception = null; + + // Recurse... (throws OptionException) + process(group, conflict, indent + " "); + + // Success! All args have been parsed. + return; + } + + catch (OptionException e) { + +// System.out.println(indent + "Should I save 1:"); +// System.out.println(indent + " " + +// (exception == null ? "null" : exception.getMessage())); +// System.out.println(indent + " " + +// (e == null ? "null" : e.getMessage())); + + // Save only the most significant exception to throw later + exception = getMostSignificantException(exception, e); + +// System.out.println(indent + "saved: " + +// (exception == null ? "null" : exception.getMessage())); + + decUseCount(element); + + // Remove the ParsedOption from saved options + processed.pop(); + + // Un-parse previously-parsed option + parser.resetToPreviousOption(); + } + } else + + if (curOpt instanceof OptionGroup) { + + OptionMap newConflict = conflict; + + // If this option is represents a list of options from which only + // one can be chosen... + if (curOpt instanceof OptionChoiceGroup && + + // ...and no conflict option has thus far been specified... + newConflict == null) { + + // Get the first option in this group, if any, which has already + // been specified and validated. Later, if another otherwise + // valid option is found, it will conflict with this option and + // a ConflictingOptionsException will be thrown. + newConflict = getFirstUsedOpt((OptionGroup)curOpt, processed); + +// System.out.println(indent + "Assigning conflict opt: " + +// (newConflict == null ? "null" : +// newConflict.getFormatted(formatter))); + } + + for (Option subOpt : ((OptionGroup)curOpt).getOptions()) { + try { + incUseCount(curOpt); + + // Recurse... (throws OptionException) + process(subOpt, isUsed(subOpt) ? + conflict : newConflict, indent + " "); + + // Success! All args have been parsed. + return; + } + + catch (OptionException e) { +// System.out.println(indent + "Should I save 2:"); +// System.out.println(indent + " " + +// (exception == null ? "null" : exception.getMessage())); +// System.out.println(indent + " " + +// (e == null ? "null" : e.getMessage())); + + // Save only the most significant exception to throw later + exception = getMostSignificantException(exception, e); + +// System.out.println(indent + "saved: " + +// (exception == null ? "null" : exception.getMessage())); + + decUseCount(curOpt); + } + } + } + + if (exception == null) { + ParsedOption parsed = parser.getNextOption(); + exception = new InvalidOptionException( + formatter.getFormatted(parsed.getOpt()), getProcessed()); + parser.resetToPreviousOption(); + } + + throw exception; + } + + /** + * Retrieves the first ParsedOption from this option group. + */ + private OptionMap getFirstUsedOpt(OptionGroup parent, + List maps) { + + for (Option subOpt : parent.getOptions()) { + + if (isUsed(subOpt)) { + if (subOpt instanceof OptionElement) { + // Search for matching ParsedOption + for (OptionMap map : maps) { + if (((OptionElement)subOpt).matches( + map.getParsed())) { + return map; + } + } + // Shouldn't be here + } else + + if (subOpt instanceof OptionGroup) { + OptionMap map = getFirstUsedOpt((OptionGroup)subOpt, maps); + + if (map != null) { + return map; + } + } + } + } + + return null; + } + + private void verifyRequiredOptions(Option option) + throws MissingOptionException { + + OptionFormatter formatter = parser.getOptionFormatter(); + + if (!isUsed(option)) { + if (option.isRequired()) { + throw new MissingOptionException( + formatter.getFormatted(option, false), + getProcessed()); + } + } else { + if (option instanceof OptionGroup) { + for (Option subOpt : ((OptionGroup)option).getOptions()) { + verifyRequiredOptions(subOpt); + } + } + } + } + + // + // Static methods + // + + public static void setInBean(OptionMap[] maps, Object bean) + throws InvalidOptArgException, IntrospectionException, + IllegalAccessException, NoSuchMethodException { + + // Populate bean + for (OptionMap map : maps) { + + ParsedOption parsed = map.getParsed(); + String opt = parsed.getOpt(); + String optArg = parsed.getOptArg(); + +// // Call boolean mutators for no-arg options +// if (!map.getOption().getTakesArgument()) { +// optArg = Boolean.toString(true); +// } + +// System.out.println("opt: " + opt); +// System.out.println("optArg: " + optArg); +// System.out.println("argName: " + map.getOption().getArgName()); + + OptionElement option = map.getOption(); + String[] names = option.getNames(); + + // Handle no-opt options + if (names.length == 1 && names[0].isEmpty()) { + names = new String[] {option.getArgName()}; + } + + List mutators = new ArrayList(names.length); + for (int i = 0; i < names.length; i++) { + String name = TextUtil.toJavaIdentifier(names[i], ""); + if (name.isEmpty()) { + name = names[i]; + } + +// System.out.println("Looking for property: " + name); + try { + BeanUtil.setPropertyInBean(bean, name, optArg); + break; + } + + // Thrown by data conversion routines + catch (RuntimeException e) { +// System.out.println("Caught RuntimeException: " + +// e.getMessage()); + throw new InvalidOptArgException(opt, optArg, maps, e); + } + + // Thrown by data validation routines + catch (InvocationTargetException e) { +// System.out.println("Caught InvocationTargetException: " + +// e.getMessage()); + throw new InvalidOptArgException(opt, optArg, + maps, e.getTargetException()); + } + + // No appropriate mutator in bean + catch (NoSuchMethodException e) { +// System.out.println("Caught NoSuchMethodException: " + +// e.getMessage()); + + // Strip class from fully-qualified method + mutators.add(e.getMessage().replaceFirst(".*\\.", "")); + + if (i == names.length - 1) { + // No need to internationalize since this is an error + // that should only be seen during development + throw new NoSuchMethodException( + "mutator method(s) not found (perhaps these " + + "methods are private?): " + + TextUtil.join(", ", mutators)); + } + } + } + } + } + + public static OptionMap[] process(String[] args, OptionGroup group, + CommandLineParser parser, Object bean) throws OptionException, + IntrospectionException, IllegalAccessException, NoSuchMethodException { + + parser.setArgs(args); + + CommandLineProcessor processor = + new CommandLineProcessor(group, parser); + + processor.process(group, null, ""); + + OptionMap[] maps = processor.getProcessed(); + + if (bean != null) { + setInBean(maps, bean); + } + + return maps; + } + + private static OptionException getMostSignificantException( + OptionException a, OptionException b) { + + // Sorted in order of significance + Class[] classes = { + InvalidOptArgException.class, + UnexpectedOptArgException.class, + MissingOptArgException.class, + OptionUseExceededException.class, + ConflictingOptionsException.class, + MissingOptionException.class, + InvalidOptionException.class, + + // Catch-all (except null a and b) + OptionException.class + }; + + for (Class clazz : classes) { + boolean aIsInstance = clazz.isInstance(a); + boolean bIsInstance = clazz.isInstance(b); + + if (aIsInstance) { + if (bIsInstance) { + + // Return the exception that occured when the most options + // had been validated + return a.getProcessed().length > + b.getProcessed().length ? a : b; + } + return a; + } + + if (bIsInstance) { + return b; + } + } + + return null; + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/CommandUtil.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/CommandUtil.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,63 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.util.cli; + +import java.util.ArrayList; +import com.oracle.solaris.vp.util.misc.TextUtil; +import com.oracle.solaris.vp.util.misc.finder.Finder; + +public class CommandUtil { + // + // Static methods + // + + public static void exit(Throwable t, UsageFormatter usage) { + ArrayList messages = new ArrayList(); + + if (usage != null) { + messages.add(usage.getCommand()); + } + + while (t != null) { + messages.add(t.getMessage()); + t = t.getCause(); + } + + String delim = Finder.getString("command.error.delim"); + System.err.println(TextUtil.join(delim, messages)); + + if (usage != null) { + System.err.println(); + System.err.println(usage.getUsage()); + } + + System.exit(1); + } + + public static void exit(Throwable t) { + exit(t, null); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/HelpFormatter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/HelpFormatter.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,170 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.util.cli; + +import java.util.*; +import com.oracle.solaris.vp.util.misc.TextUtil; +import com.oracle.solaris.vp.util.misc.finder.Finder; + +public class HelpFormatter { + // + // Instance data + // + + private String description; + private UsageFormatter formatter; + private String optionsLabel = Finder.getString("command.help.options"); + + // + // Constructors + // + + public HelpFormatter(String description, UsageFormatter formatter) { + this.description = description; + this.formatter = formatter; + } + + // + // HelpFormatter methods + // + + public String getDescription() { + return description; + } + + public UsageFormatter getUsageFormatter() { + return formatter; + } + + public void setOptionsLabel(String optionsLabel) { + this.optionsLabel = optionsLabel; + } + + public String getOptionsLabel() { + return optionsLabel; + } + + public String getHelp() { + UsageFormatter usage = getUsageFormatter(); + OptionElement[] options = getOptionElements(); + OptionFormatter formatter = usage.getOptionFormatter(); + + StringBuilder buffer = new StringBuilder(); + int width = usage.getWidth(); + + buffer.append(usage.getUsage()). + append("\n\n"). + append(TextUtil.format(getDescription(), width, "", "", false)); + + if (options.length > 0) { + int indentlen = usage.getIndent(); + String indent2 = String.format("%" + indentlen + "s", ""); + + String optionsLabel = getOptionsLabel(); + if (optionsLabel != null) { + buffer.append("\n\n").append(getOptionsLabel()); + } + + for (OptionElement option : options) { + String synopsis = formatter.getFormatted(option, true); + buffer.append("\n\n"); + + String indent1; + String description = option.getDescription(); + + // Can synopsis and description be on the same line? + if (synopsis.length() + 1 <= indentlen) { + description = String.format("%-" + indentlen + "s%s", + synopsis, description); + indent1 = ""; + } else { + buffer.append(synopsis); + if (!description.isEmpty()) { + buffer.append("\n"); + } + indent1 = indent2; + } + + buffer.append(TextUtil.format(description, width, indent1, + indent2, false)); + } + } + + return buffer.toString(); + } + + // + // Private methods + // + + private OptionElement[] getOptionElements() { + // Recursively retrieve all OptionElements + HashMap map = + new HashMap(); + getOptionElements(getUsageFormatter().getOption(), map); + + ArrayList elements = new ArrayList(); + elements.addAll(map.values()); + + Collections.sort(elements, + new Comparator() { + public int compare(OptionElement a, OptionElement b) { + String aName = a.getName(); + String bName = b.getName(); + + int result = aName.toLowerCase().compareTo( + bName.toLowerCase()); + + if (result == 0) { + // Lowercase before uppercase + result = bName.compareTo(aName); + } + + return result; + } + }); + + return elements.toArray(new OptionElement[elements.size()]); + } + + private void getOptionElements( + Option option, HashMap map) { + + if (option.isDocumented()) { + if (option instanceof OptionElement) { + OptionElement element = (OptionElement)option; + String key = element.getName() + element.getArgName(); + map.put(key, element); + } else + + if (option instanceof OptionGroup) { + for (Option o : ((OptionGroup)option).getOptions()) { + getOptionElements(o, map); + } + } + } + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/NoOptOptionElement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/NoOptOptionElement.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,66 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.util.cli; + +public class NoOptOptionElement extends OptionElement { + // + // Constructors + // + + public NoOptOptionElement(boolean required, + String argName, String description, int useLimit) { + + super(new String[] {""}, required, argName, false, description, + useLimit); + } + + public NoOptOptionElement(boolean required, String argName, + String description) { + + this(required, argName, description, 1); + } + + // + // OptionElement methods + // + + /** + * Returns a boolean indicating whether the given ParsedOption + * matches this NoOptOptionElement. + * + * @param option + * a ParsedOption + * + * @return true if the option flag is + * null or an empty string, + * false otherwise + */ + @Override + protected boolean matches(ParsedOption option) { + String opt = option.getOpt(); + return opt == null || opt.isEmpty(); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/Option.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/Option.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,36 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.util.cli; + +public abstract class Option { + // + // Option methods + // + + public abstract boolean isDocumented(); + + public abstract boolean isRequired(); +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/OptionChoiceGroup.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/OptionChoiceGroup.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,40 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.util.cli; + +public class OptionChoiceGroup extends OptionGroup { + // + // Constructors + // + + public OptionChoiceGroup(boolean required) { + super(required); + } + + public OptionChoiceGroup(boolean required, Option... options) { + super(required, options); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/OptionElement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/OptionElement.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,254 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.util.cli; + +import java.util.*; +import com.oracle.solaris.vp.util.cli.exception.*; + +public class OptionElement extends Option { + // + // Instance data + // + + private boolean required; + private boolean documented; + private List names; + private String argName; + private boolean argOptional; + private String description; + private int useLimit; + + // + // Constructors + // + + public OptionElement(String[] names, boolean required, + String argName, boolean argOptional, String description, int useLimit) { + setNames(names); + setRequired(required); + setArgName(argName); + setArgOptional(argOptional); + setDescription(description); + setUseLimit(useLimit); + setDocumented(true); + } + + public OptionElement(String name, boolean required, String argName, + String description) { + this(new String[] {name}, required, argName, false, description, 1); + } + + public OptionElement(String name, boolean required, String description) { + this(name, required, null, description); + } + + public OptionElement(String name1, String name2, boolean required, + String argName, String description) { + this(new String[] {name1, name2}, + required, argName, false, description, 1); + } + + public OptionElement(String name1, String name2, boolean required, + String description) { + this(name1, name2, required, null, description); + } + + // + // Option methods + // + + @Override + public boolean isDocumented() { + return documented; + } + + @Override + public boolean isRequired() { + return required; + } + + // + // OptionElement methods + // + + public void setDocumented(boolean documented) { + this.documented = documented; + } + + public void setRequired(boolean required) { + this.required = required; + } + + public void setNames(String[] names) { + this.names = Arrays.asList(names); + } + + public String[] getNames() { + return names.toArray(new String[names.size()]); + } + + public String getName() { + try { + return names.get(0); + } + catch (IndexOutOfBoundsException e) { + return null; + } + } + + public void setArgName(String argName) { + this.argName = argName; + } + + public String getArgName() { + return argName; + } + + public boolean getTakesArgument() { + return argName != null; + } + + public void setArgOptional(boolean argOptional) { + this.argOptional = argOptional; + } + + public boolean getArgOptional() { + return argOptional; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return description; + } + + public void setUseLimit(int useLimit) { + this.useLimit = useLimit; + } + + public int getUseLimit() { + return useLimit; + } + + /** + * Returns a boolean indicating whether the given + * ParsedOption matches this + * OptionElement. + */ + protected boolean matches(ParsedOption processed) { + String opt = processed.getOpt(); + if (opt != null) { + for (String name : getNames()) { +// System.out.printf("Testing opt=%s optArg=%s against %s\n", +// opt, processed.getOptArg(), name); + + if (opt.equals(name)) { + return true; + } + } + } + return false; + } + + /** + * Validates the given option and optional argument against the + * option/optArg that this OptionElement expects. If the option is valid, + * does nothing. Otherwise, an exception is thrown. + * + * @param parsed + * the option parsed from the command line + * + * @param useCount + * the number of times this option has been used + * + * @param formatter + * used to format the option string in exception + * messages + * + * @param processed + * the options processed so far, for use in exceptions + * + * @exception InvalidOptionException + * if the given option doesn't match the name of this + * OptionElement + * + * @exception OptionUseExceededException + * if this OptionElement has been used more times + * than it is allowed + * + * @exception MissingOptArgException + * if this OptionElement requires an argument but + * none was specified + * + * @exception UnexpectedOptArgException + * if this OptionElement takes no argument but + * one was specified + * + * @exception InvalidOptArgException + * if this OptionElement's argument is invalid -- + * not thrown in this default implementation + */ + protected void validate(ParsedOption parsed, int useCount, + OptionFormatter formatter, OptionMap[] processed) throws + InvalidOptionException, OptionUseExceededException, + MissingOptArgException, UnexpectedOptArgException, + InvalidOptArgException { + + String opt = parsed.getOpt(); + String optArg = parsed.getOptArg(); + String formatted = OptionMap.getFormatted(parsed, this, formatter); + +// System.out.printf("Validating: opt=%s optArg=%s\n", opt, optArg); + + // Verify given option identifies this OptionElement + if (!matches(parsed)) { + throw new InvalidOptionException(formatted, processed); + } + + // Change message to reflect the option syntax, not the passed-in opt + formatted = formatter.getFormatted(this, false); + + // Verify this option hasn't been specified too many times + int useLimit = getUseLimit(); + if (useLimit >= 0 && useCount > useLimit) { + throw new OptionUseExceededException( + formatted, useLimit, processed); + } + + // Verify optArg if required + if (getTakesArgument() && !getArgOptional() && optArg == null) { + throw new MissingOptArgException(formatted, processed); + } + + // Verify no optArg if not expected + if (!getTakesArgument() && optArg != null) { + throw new UnexpectedOptArgException( + formatted, optArg, processed); + } + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/OptionFormatter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/OptionFormatter.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,123 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.util.cli; + +import java.util.ArrayList; +import com.oracle.solaris.vp.util.misc.TextUtil; + +public abstract class OptionFormatter { + // + // Static data + // + + public static final String OPT_LIST_DELIM = " "; + public static final String OPT_NAME_DELIM = ","; + public static final String OPT_CHOICE_DELIM = " | "; + public static final String OPT_REQUIRED_ENCLOSE_LEFT = "["; + public static final String OPT_REQUIRED_ENCLOSE_RIGHT = "]"; + public static final String OPT_GROUP_ENCLOSE_LEFT = "("; + public static final String OPT_GROUP_ENCLOSE_RIGHT = ")"; + public static final String OPT_ARG_ENCLOSE_LEFT = "<"; + public static final String OPT_ARG_ENCLOSE_RIGHT = ">"; + public static final String OPT_REPEAT = "..."; + + // + // OptionFormatter methods + // + + public String getFormatted(Option opt, boolean allNames) { + return getFormatted(opt, allNames, false, true); + } + + public String getFormatted(String opt) { + return getFormatted(new String[] {opt}); + } + + public String getFormatted(String opt, String optArg) { + return getFormatted(new String[] {opt}, optArg); + } + + public abstract String getFormatted(String[] opts); + + public abstract String getFormatted(String[] opts, String optArg); + + // + // Private methods + // + + private String getFormatted(Option opt, boolean allNames, + boolean showGroup, boolean required) { + + StringBuilder buffer = new StringBuilder(); + + if (!required) { + buffer.append(OPT_REQUIRED_ENCLOSE_LEFT); + showGroup = false; + } + + if (opt instanceof OptionElement) { + OptionElement element = (OptionElement)opt; + + buffer.append(allNames ? + getFormatted(element.getNames(), element.getArgName()) : + getFormatted(element.getName(), element.getArgName())); + + if (element.getUseLimit() < 0) { + buffer.append(OPT_REPEAT); + } + } else + + if (opt instanceof OptionGroup) { + ArrayList list = new ArrayList(); + String delim = opt instanceof OptionChoiceGroup ? + OPT_CHOICE_DELIM : OPT_LIST_DELIM; + + for (Option subOpt : ((OptionGroup)opt).getOptions()) { + if (subOpt.isDocumented()) { + list.add(getFormatted(subOpt, allNames, showGroup, + opt instanceof OptionChoiceGroup ? + true : subOpt.isRequired())); + } + } + + if (showGroup) { + buffer.append(OPT_GROUP_ENCLOSE_LEFT); + } + + buffer.append(TextUtil.join(delim, list)); + + if (showGroup) { + buffer.append(OPT_GROUP_ENCLOSE_RIGHT); + } + } + + if (!required) { + buffer.append(OPT_REQUIRED_ENCLOSE_RIGHT); + } + + return buffer.toString(); + } +} diff -r c6aad84d2493 -r 0944d8c0158b components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/OptionGroup.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/visual-panels/core/src/java/util/com/oracle/solaris/vp/util/cli/OptionGroup.java Thu May 24 04:16:47 2012 -0400 @@ -0,0 +1,113 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + */ + +package com.oracle.solaris.vp.util.cli; + +import java.util.*; + +public abstract class OptionGroup extends Option { + // + // Instance data + // + + private boolean required; + private boolean documented; + private List