package se.metasolutions.recruit.resources; import org.restlet.data.MediaType; import org.restlet.representation.BufferingRepresentation; import org.restlet.representation.Representation; import org.restlet.representation.StringRepresentation; import org.restlet.resource.ResourceException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.restlet.resource.Get; import org.restlet.resource.Post; import java.io.IOException; public class EchoResource extends BaseResource { private final static Logger log = LoggerFactory.getLogger(EchoResource.class); @Post() public Representation echo(Representation entity) throws IOException { return getEchoResponse(entity); } @Post("csv") public Representation tablify(Representation entity) throws IOException { Representation response; if (!getRequest().isEntityAvailable()) { response = new StringRepresentation("No POST data available"); } else { String acceptedMediaTypes = getClientInfo().getAcceptedMediaTypes().toString(); if (acceptedMediaTypes.contains("text/html")) { StringBuilder htmlTable = new StringBuilder("
").append(cell).append(" | \n"); } htmlTable.append("
Error while reading CSV data |