com.ksc.kvs.model.transform.PresetRequestMarshaller Maven / Gradle / Ivy
package com.ksc.kvs.model.transform;
import java.io.ByteArrayInputStream;
import com.ksc.DefaultRequest;
import com.ksc.KscClientException;
import com.ksc.Request;
import com.ksc.http.HttpMethodName;
import com.ksc.kvs.model.PresetRequest;
import com.ksc.transform.Marshaller;
import com.ksc.util.StringUtils;
public class PresetRequestMarshaller implements Marshaller, PresetRequest>{
public Request marshall(PresetRequest presetRequest) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
if (presetRequest == null) {
throw new KscClientException(
"Invalid argument passed to marshall(...)");
}
Request request = new DefaultRequest(
presetRequest, "kvs");
request.addParameter("Action","Preset");
String version=presetRequest.getVersion();
if(org.apache.commons.lang.StringUtils.isBlank(version)){
version="2017-01-01";
}
byte[] content=presetRequest.getData().getBytes();
request.addHeader("Content-Type", "application/json");
request.addParameter("Version", version);
request.setContent(new ByteArrayInputStream(content));
request.addHeader("Content-Length",
Integer.toString(content.length));
request.setHttpMethod(HttpMethodName.POST);
return request;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy