example.dynamic_controller.DynamicHelloController Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of EpikosRestService Show documentation
Show all versions of EpikosRestService Show documentation
Epikos is a Rest Serivce framework which can be extend to develop any other Rest API/Services. For more
detail please checkout github (https://github.com/epikosrest/epikos.git)
package example.dynamic_controller;
import core.dynamic.resources.*;
import core.exception.EpikosException;
import example.request.HelloRequest;
import example.response.HelloResponse;
import org.apache.commons.lang3.StringUtils;
import javax.ws.rs.core.MultivaluedMap;
/**
* Created by nitina on 5/11/16.
*/
public class DynamicHelloController implements IDynamicResourceController {
public Object process(IDynamicRequestPOST dynamicRequest) throws EpikosException {
//try {
HelloRequest helloRequest = dynamicRequest.getRequest(HelloRequest.class);
MultivaluedMap pathParam = dynamicRequest.getPathParams();
HelloResponse resp = new HelloResponse();
resp.setResponseString("Hello " + helloRequest.getName());
return resp;
//}catch (Exception ioExp){
// System.out.println(ioExp.getMessage());
//ToDo: log and return proper error msg
//}
//return null; //ToDO: need better way to handle and return value
}
public Object process(IDynamicRequestGET dynamicRequestGET) {
HelloResponse getResponse = new HelloResponse();
String testid = StringUtils.EMPTY;
if(!dynamicRequestGET.getPathParams().isEmpty() && dynamicRequestGET.getPathParams().get("doc1") != null){
testid = dynamicRequestGET.getPathParams().get("doc1").get(0);
}
getResponse.setResponseString("This is response entity for GET request from Swagger for Dynamic API example : value " + testid );
return getResponse;
}
@Override
public Object process(IDynamicRequestDELETE dynamicRequest) throws EpikosException {
return null;
}
@Override
public Object process(IDynamicRequestPUT dynamicRequest) throws EpikosException {
return null;
}
@Override
public Object process(IDynamicRequestPATCH dynamicRequest) throws EpikosException {
return null;
}
}