View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport.servlet.transformers;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.transformer.AbstractMessageTransformer;
11  import org.mule.transformer.types.DataTypeFactory;
12  import org.mule.transport.servlet.ServletConnector;
13  
14  import java.util.Map;
15  
16  /**
17   * Returns a simple Map of the parameters sent with the HTTP Request.
18   * If the same parameter is given more than once, only the first value for it will be in the Map.
19   */
20  public class HttpRequestToParameterMap extends AbstractMessageTransformer
21  {
22      public HttpRequestToParameterMap()
23      {
24          registerSourceType(DataTypeFactory.OBJECT);
25          setReturnDataType(DataTypeFactory.create(Map.class));
26      }
27  
28      @Override
29      public Object transformMessage(MuleMessage message, String outputEncoding)
30      {
31          return message.getInboundProperty(ServletConnector.PARAMETER_MAP_PROPERTY_KEY);
32      }
33  }