@@ -119,12 +119,19 @@ protected static String encodeAccessControl(Object accessControl) {
119119 }
120120
121121 protected static String encodeContext (Object context ) {
122- if (context != null && context instanceof Map ) {
123- Map <String , String > mapArg = (Map <String , String >) context ;
122+ if (context instanceof Map ) {
123+ Map <String , Object > mapArg = (Map <String , Object >) context ;
124124 HashSet out = new HashSet ();
125- for (Map .Entry <String , String > entry : mapArg .entrySet ()) {
126- final String value = entry .getValue ().replaceAll ("([=\\ |])" ,"\\ \\ $1" );
127- out .add (entry .getKey () + "=" + value );
125+ for (Map .Entry <String , Object > entry : mapArg .entrySet ()) {
126+ final String value ;
127+ if (entry .getValue () instanceof List ) {
128+ value = encodeList (((List ) entry .getValue ()).toArray ());
129+ } else if (entry .getValue () instanceof String []) {
130+ value = encodeList ((String []) entry .getValue ());
131+ } else {
132+ value = entry .getValue ().toString ();
133+ }
134+ out .add (entry .getKey () + "=" + encodeSingleContextString (value ));
128135 }
129136 return StringUtils .join (out .toArray (), "|" );
130137 } else if (context == null ) {
@@ -134,6 +141,26 @@ protected static String encodeContext(Object context) {
134141 }
135142 }
136143
144+ private static String encodeList (Object [] list ) {
145+ StringBuilder builder = new StringBuilder ("[" );
146+
147+ boolean first = true ;
148+ for (Object s : list ) {
149+ if (!first ) {
150+ builder .append ("," );
151+ }
152+
153+ builder .append ("\" " ).append (encodeSingleContextString (s .toString ())).append ("\" " );
154+ first = false ;
155+ }
156+
157+ return builder .append ("]" ).toString ();
158+ }
159+
160+ private static String encodeSingleContextString (String value ) {
161+ return value .replaceAll ("([=\\ |])" , "\\ \\ $1" );
162+ }
163+
137164 @ SuppressWarnings ("unchecked" )
138165 protected static final String buildCustomHeaders (Object headers ) {
139166 if (headers == null ) {
@@ -165,7 +192,7 @@ public static void clearEmpty(Map params) {
165192 @ SuppressWarnings ({"rawtypes" , "unchecked" })
166193 public static final Map <String , Object > buildArchiveParams (Map options , String targetFormat ) {
167194 Map <String , Object > params = new HashMap <String , Object >();
168- if (options != null && options .size () > 0 ){
195+ if (options != null && options .size () > 0 ) {
169196 params .put ("type" , options .get ("type" ));
170197 params .put ("mode" , options .get ("mode" ));
171198 params .put ("target_format" , targetFormat );
@@ -198,7 +225,7 @@ private static void putEager(String name, Map from, Map<String, Object> to) {
198225
199226 private static void putBoolean (String name , Map from , Map <String , Object > to ) {
200227 final Object value = from .get (name );
201- if (value != null ){
228+ if (value != null ) {
202229 to .put (name , ObjectUtils .asBoolean (value ));
203230 }
204231 }
@@ -209,16 +236,16 @@ private static void putObject(String name, Map from, Map<String, Object> to) {
209236
210237 private static void putObject (String name , Map from , Map <String , Object > to , Object defaultValue ) {
211238 final Object value = from .get (name );
212- if (value != null ){
239+ if (value != null ) {
213240 to .put (name , value );
214- } else if (defaultValue != null ){
241+ } else if (defaultValue != null ) {
215242 to .put (name , defaultValue );
216243 }
217244 }
218245
219246 private static void putArray (String name , Map from , Map <String , Object > to ) {
220247 final Object value = from .get (name );
221- if (value != null ){
248+ if (value != null ) {
222249 to .put (name , ObjectUtils .asArray (value ));
223250 }
224251 }
0 commit comments