restlet-2.0

JaxbRepresentation gives error “doesnt contain ObjectFactory.class or jaxb.index”

走远了吗. 提交于 2019-12-02 20:14:39
I am trying to create a sample test application which converts an object to JaxbRepresentation. But when I try to run this, it gives me an error. Main.java file package test_jaxb; import org.restlet.Server; import org.restlet.data.Protocol; public class Main { /** * @param args the command line arguments */ public static void main(String[] args) throws Exception { Server helloServer = new Server(Protocol.HTTP, 8111, TestResource.class); helloServer.start(); } } TestResource.java file package test_jaxb; import org.restlet.ext.jaxb.JaxbRepresentation; import org.restlet.representation

Restlet HTTP Connection Pool

ε祈祈猫儿з 提交于 2019-12-02 18:03:23
问题 I am fairly new to Restlet and wrote small piece of code to make a HTTP call. It is working but I was wondering how can I add HTTP Connection pooling (apache) into it. I am not able to find any tutorial or reference code for it. Client client = new Client(Protocol.HTTP); ChallengeResponse challengeResponse = new ChallengeResponse( ChallengeScheme.HTTP_AZURE_SHAREDKEY, acctName, accKey); String url = RestHelper.createRequestURI("CCC"); Request request = new Request(Method.GET, url); request

Creating a Restlet Authorizer for fine grained authorization

假如想象 提交于 2019-12-02 11:54:27
问题 I'm attempting to implement a RESTful API using Restlet and have found very little on anything more than the basic Role and Method Authorizers. I have stored in a database the routes and methods for those routes that a user can access. The issue I'm running into now is how to get the path in the Authorizer. Is it the resource I'm needing to gather? And how exactly am I supposed to route to the authorizer? I've posted what I have so far an am looking how in my Authorizer to get the path or

How can I disable logging in Restlet 2.0?

杀马特。学长 韩版系。学妹 提交于 2019-12-02 05:46:46
问题 I simply want to disable Restlet's logging to stdout/stderr in my project and forward all Restlet logging through the SLF4J facade provided by org.restlet.ext.slf4j. Is there an easy way to do this? 回答1: You first must configure SLF4J to intercept all of Restlet's calls to the java.util.logging APIs and map them into calls on the SLF4J facade's APIs instead. You simply do this by putting jul-to-slf4j.jar in your classpath, as @Bruno noted. Second, you have to configure the SLF4J facade to

How can I disable logging in Restlet 2.0?

我的未来我决定 提交于 2019-12-02 02:34:18
I simply want to disable Restlet's logging to stdout/stderr in my project and forward all Restlet logging through the SLF4J facade provided by org.restlet.ext.slf4j. Is there an easy way to do this? You first must configure SLF4J to intercept all of Restlet's calls to the java.util.logging APIs and map them into calls on the SLF4J facade's APIs instead. You simply do this by putting jul-to-slf4j.jar in your classpath, as @Bruno noted. Second, you have to configure the SLF4J facade to forward its API calls on to a logging implementation to do the actual log message generation. To use the

Is Restlet returning 415 Unsupported Media Type when it should return 400 Bad Request?

萝らか妹 提交于 2019-11-30 21:38:09
I'm using Restlet 2.1 with jackson to build a json REST api. When I make a request with the expected content type but a malformed body, I get back a 415 "Unsuppored Media Type" status code. I think the correct error code should be 400 "Bad Request". Apparently the mixup happens when Jackson tries and fails to decode the garbage. I'll try to make the case more clear with some code: // java method mapping @Post("json") public Project create(Project project) { The service invocation with curl $ curl -i -XPOST -H 'content-type: application/json' -d '{xgarbage}' http://localhost:8080/projects HTTP

Restlet Complex Object to XML serializaton

老子叫甜甜 提交于 2019-11-28 02:16:31
问题 I have restlet web service which returns response as xml. I'm using Jackson as binder. below is class I'm returning. import java.io.Serializable; import java.util.ArrayList; import java.util.List; public class ApiResponse<T> implements Serializable { /** * */ private static final long serialVersionUID = -2736991050157565598L; private int responseCode; private String reponseMessage; private List<T> body = new ArrayList<T>(); public int getResponseCode() { return responseCode; } public void