Can we extract this to a private method? Something like this:

```java
Map<String, String> data = convertMapOfStringArrayToMapOfString(params);
...
private Map<String, String> convertMapOfStringArrayToMapOfString(Map<String, String[]> params) {
    Map<String, String> data= new HashMap<String, String>();
    for(String key : params.keySet()) {
        String[] val = params.get(key);
        if (Array.getLength(val) > 0) {
            data.put(key, val[0]);
        }
    }
    return data;
}
```