/*
 * Copyright © 2010 Red Hat, Inc.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package com.redhat.rhevm.api.powershell.util;

import java.util.ArrayList;
import java.util.HashMap;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class PowerShellUtils {
    private static final Log log = LogFactory.getLog(PowerShellUtils.class);

    public static ArrayList<HashMap<String,String>> parseProps(String str) {
        ArrayList<HashMap<String,String>> ret = new ArrayList<HashMap<String,String>>();
        HashMap<String,String> props = null;

        for (String s : str.split("\n")) {
            if (props != null && s.isEmpty()) {
                ret.add(props);
                props = null;
            }

            String[] parts = s.split(":", 2);
            if (parts.length != 2)
                continue;

            if (props == null) {
                props = new HashMap<String,String>();
            }

            props.put(parts[0].trim().toLowerCase(), parts[1].trim());
        }

        if (props != null) {
            ret.add(props);
        }

        return ret;
    }
}

@@ -1595,16 +1595,270 @@
 tinue;%0A%0A
+            String key = parts%5B0%5D.trim().toLowerCase();%0A            if (key.isEmpty()) %7B%0A                continue;%0A            %7D%0A%0A            String value = parts%5B1%5D.trim();%0A            if (value.isEmpty()) %7B%0A                value = null;%0A            %7D%0A%0A
         
@@ -1874,32 +1874,32 @@
 rops == null) %7B%0A
-
                 
@@ -1977,54 +1977,18 @@
 put(
-parts%5B0%5D.trim().toLowerCase(), parts%5B1%5D.trim()
+key, value
 );%0A 

Fix parsing of empty values in powershell output