net.sf.aguacate.http.impl.ResponseStatusImpl Maven / Gradle / Ivy
package net.sf.aguacate.http.impl;
import javax.servlet.http.HttpServletResponse;
import net.sf.aguacate.http.HttpMethods;
import net.sf.aguacate.http.ResponseStatus;
public class ResponseStatusImpl implements ResponseStatus {
@Override
public int status(String method, boolean success, boolean hasBody) {
switch (method) {
case HttpMethods.M_DELETE:
if (success) {
return HttpServletResponse.SC_OK;
}
break;
case HttpMethods.M_GET0:
if (success) {
return HttpServletResponse.SC_OK;
}
break;
case HttpMethods.M_GET:
if (success) {
if (hasBody) {
return HttpServletResponse.SC_OK;
} else {
return HttpServletResponse.SC_NOT_FOUND;
}
}
break;
case HttpMethods.M_PATCH:
if (success) {
return HttpServletResponse.SC_OK;
}
break;
case HttpMethods.M_POST:
if (success) {
return HttpServletResponse.SC_OK;
}
break;
case HttpMethods.M_PUT:
if (success) {
return HttpServletResponse.SC_CREATED;
}
break;
}
return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
}
}