WEPPHillslopeServiceCall.java [src/java/util] Revision: default  Date:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import static csip.ModelDataService.KEY_METAINFO;
import static csip.ModelDataService.KEY_PARAMETER;
import csip.api.server.ServiceException;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;

/**
 *
 * @author <a href="mailto:shaun.case@colostate.edu">Shaun Case</a>
 */
public class WEPPHillslopeServiceCall extends ServiceCall {

  protected JSONArray _allparms;
  protected JSONObject _callingMetaInfo;


  public WEPPHillslopeServiceCall(String URI, JSONObject callingMetaInfo, JSONArray allparms) {
    super(URI);
    _allparms = allparms;
    _callingMetaInfo = callingMetaInfo;
  }


  @Override
  protected void createRequest() throws ServiceException {

    requestMetainfoObject = new JSONObject();
    request = new JSONObject();

    try {
      requestMetainfoObject.put("MultipartRequest", "Bundled Service Request from WEPP");
      requestMetainfoObject.put("WEPP_Metainfo", _callingMetaInfo);
      request.put(KEY_METAINFO, requestMetainfoObject);

      request.put(KEY_PARAMETER, _allparms);
    } catch (JSONException ex) {
      throwServiceCallException("Cannot create the JSON request for WEPPHillslope call.", ex);
    }
  }

}