/*
 * Copyright 2014 Open mHealth
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.openmhealth.shim;

import java.util.Calendar;

/**
 * Wrapper for responses received from shims.
 * <p/>
 * todo: expand to include original parameters
 * TODO there's no pagination information, how does a caller know how to proceed?
 * @author Danilo Bonilla
 */
public class ShimDataResponse {

    private String shim;

    private Long timeStamp;

    private Object body;

    public String getShim() {
        return shim;
    }

    public void setShim(String shim) {
        this.shim = shim;
    }

    // TODO in seconds since the epoch? needs to be documented
    public Long getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Long timeStamp) {
        this.timeStamp = timeStamp;
    }

    public Object getBody() {
        return body;
    }

    public void setBody(Object body) {
        this.body = body;
    }

    public static ShimDataResponse empty(String shimKey) {
        ShimDataResponse response = new ShimDataResponse();
        response.setShim(shimKey);
        response.setBody(null);

        response.setTimeStamp(
            Calendar.getInstance().getTimeInMillis() / 1000);
        return response;
    }

    public static ShimDataResponse result(String shimKey, Object object) {
        ShimDataResponse response = new ShimDataResponse();
        response.setShim(shimKey);
        response.setBody(object);
        response.setTimeStamp(
            Calendar.getInstance().getTimeInMillis() / 1000);
        return response;
    }
}

@@ -632,27 +632,45 @@
 ort 
+static 
 java.
-u
 ti
-l.Calendar;
+me.OffsetDateTime.now;%0A
 %0A%0A/*
@@ -771,19 +771,16 @@
 rameters
-%0A *
  TODO th
@@ -841,16 +841,19 @@
 w how to
+%0A *
  proceed
@@ -854,16 +854,19 @@
 roceed?%0A
+ *%0A
  * @auth
@@ -1535,24 +1535,25 @@
  shimKey) %7B%0A
+%0A
         Shim
@@ -1592,32 +1592,33 @@
 DataResponse();%0A
+%0A
         response
@@ -1668,17 +1668,16 @@
 (null);%0A
-%0A
         
@@ -1702,71 +1702,33 @@
 amp(
-%0A            Calendar.getInstance().getTimeInMillis() / 1000
+now().toEpochSecond()
 );%0A
+%0A
     
@@ -1826,24 +1826,25 @@
 t object) %7B%0A
+%0A
         Shim
@@ -1891,16 +1891,17 @@
 onse();%0A
+%0A
         
@@ -1995,71 +1995,33 @@
 amp(
-%0A            Calendar.getInstance().getTimeInMillis() / 1000
+now().toEpochSecond()
 );%0A
+%0A
     

Replace usages of java.util.Calendar