All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.aguacate.http.impl.ResponseStatusImpl Maven / Gradle / Ivy

There is a newer version: 0.10.9
Show newest version
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;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy