V2_0.java [src/java/m/example/simpleservice] Revision: 0eb7802d87405cd03bb930945bc6bcd624982cdb  Date: Mon Jun 06 10:54:08 MDT 2016
/*
 * 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 m.example.simpleservice;

import csip.ServiceException;
import javax.ws.rs.Path;
import oms3.annotations.*;
import org.json.JSONException;

@Name("conv #2")
@Description("Example of an simple service")
@Path("m/simpleservice/2.0")
public class V2_0 extends csip.ModelDataService {

    @Override
    protected void preProcess() throws Exception {
        /// sksks
//        throw new ServiceException(" not good abcde");
    }


    @Override
    protected void postProcess() throws Exception {
//        throw new ServiceException(" post not good abcde");
    }


    @Override
    protected void doProcess() throws Exception {
        double temp = getDoubleParam("temp_c");
        String un = getParamUnit("temp_c");
        if (un.equals("C")) {
            putResult("temp", temp * 9 / 5 + 32, "F");
            return;
        }
        throw new ServiceException("missing unit.");
    }

//    @Override
//    protected String process() throws Exception {
//        double temp = getDoubleParam("temp_c");
//        if ("C".equals(getParamUnit("temp_c"))) {
//            putResult("temp", temp * (9 / 5) + 32, "F");
//            return null;
//        }
//        return "missing unit.";
//    }
}