class WebPositionsResource extends AbstractWebPositionResource {

  @POST
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  @Produces(MediaType.APPLICATION_JSON)
  public Response postJSON(
      @FormParam("quantity") String quantityStr,
      @FormParam("idscheme") String idScheme,
      @FormParam("idvalue") String idValue,
      @FormParam("tradesJson") String tradesJson,
      @FormParam("type") String type,
      @FormParam(POSITION_XML) String positionXml,
      @FormParam("uniqueIdScheme") String uniqueIdScheme) {
    
    uniqueIdScheme = StringUtils.trimToNull(uniqueIdScheme);
    type = StringUtils.trimToEmpty(type);
    URI uri = null;
    switch (type) {
      case "xml":
        uri = addPosition(positionXml, uniqueIdScheme);
        break;
      case StringUtils.EMPTY:
        quantityStr = StringUtils.replace(StringUtils.trimToNull(quantityStr), ",", "");
        BigDecimal quantity = quantityStr != null && NumberUtils.isNumber(quantityStr) ? new BigDecimal(quantityStr) : null;
        idScheme = StringUtils.trimToNull(idScheme);
        idValue = StringUtils.trimToNull(idValue);
        tradesJson = StringUtils.trimToNull(tradesJson);
        
        if (quantity == null || idScheme == null || idValue == null) {
          return Response.status(Status.BAD_REQUEST).build();
        }
        
        ExternalIdBundle id = ExternalIdBundle.of(ExternalId.of(idScheme, idValue));
        UniqueId secUid = getSecurityUniqueId(id);
        if (secUid == null) {
          throw new DataNotFoundException("invalid " + idScheme + "~" + idValue);
        }
        Collection<ManageableTrade> trades = null;
        if (tradesJson != null) {
          trades = parseTrades(tradesJson);
        } else {
          trades = Collections.<ManageableTrade>emptyList();
        }
        uri = addPosition(quantity, secUid, trades, uniqueIdScheme);
        break;
      default:
        throw new IllegalArgumentException("Can only add position by XML or completing provided web form");
    }
    return Response.created(uri).build();
  }

  public  WebPositionsResource(final PositionMaster positionMaster, final SecurityLoader securityLoader, final SecuritySource securitySource,
      final HistoricalTimeSeriesSource htsSource, final Map<ExternalScheme, String> externalSchemes);

}