FELIX-1206: config/propappend patch

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@783712 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropAppendCommand.java b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropAppendCommand.java
new file mode 100644
index 0000000..562ce8a
--- /dev/null
+++ b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropAppendCommand.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.felix.karaf.gshell.config;
+
+import java.util.Dictionary;
+
+import org.apache.geronimo.gshell.clp.Argument;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+/**
+ * Appends a value to the current property value.
+ */
+public class PropAppendCommand extends ConfigCommandSupport {
+
+    @Argument(index = 0, required = true, description = "the property to set")
+    String prop;
+
+    @Argument(index = 1, required = true, description = "the value to be appended")
+    String value;
+    
+	@Override
+	protected void doExecute(ConfigurationAdmin admin) throws Exception {
+        Dictionary props = getEditedProps();
+        if (props == null) {
+            System.err.println("No configuration is being edited. Run the edit command first");
+        } else {
+        	final Object currentValue = props.get(prop);
+        	if (currentValue == null) {
+        		props.put(prop, value);
+        	} else if (currentValue instanceof String) {
+        		props.put(prop, currentValue + value);
+        	} else {
+        		System.err.println("Append Failed: current value is not a String.");
+        	}
+        }
+	}
+
+}
diff --git a/karaf/gshell/gshell-config/src/main/resources/META-INF/spring/gshell-config.xml b/karaf/gshell/gshell-config/src/main/resources/META-INF/spring/gshell-config.xml
index 095e7e5..8ad512e 100644
--- a/karaf/gshell/gshell-config/src/main/resources/META-INF/spring/gshell-config.xml
+++ b/karaf/gshell/gshell-config/src/main/resources/META-INF/spring/gshell-config.xml
@@ -78,6 +78,15 @@
                 <null/>
             </gshell:completers>
         </gshell:command>
+        <gshell:command name="config/propappend">
+            <gshell:action class="org.apache.felix.karaf.gshell.config.PropAppendCommand">
+                <property name="bundleContext" ref="bundleContext"/>
+            </gshell:action>
+            <gshell:completers>
+                <ref bean="configPropertyCompleter" />
+                <null/>
+            </gshell:completers>
+        </gshell:command>
         <gshell:command name="config/update">
             <gshell:action class="org.apache.felix.karaf.gshell.config.UpdateCommand">
                 <property name="bundleContext" ref="bundleContext"/>
diff --git a/karaf/gshell/gshell-config/src/main/resources/org/apache/felix/karaf/gshell/config/PropAppendCommand.properties b/karaf/gshell/gshell-config/src/main/resources/org/apache/felix/karaf/gshell/config/PropAppendCommand.properties
new file mode 100644
index 0000000..87bc54c
--- /dev/null
+++ b/karaf/gshell/gshell-config/src/main/resources/org/apache/felix/karaf/gshell/config/PropAppendCommand.properties
@@ -0,0 +1,23 @@
+##
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##  http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied.  See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+
+command.description=Appends a value to the end of an existing property value
+
+command.manual=\
+  TODO: date manual