restlet-2.0

JsonMappingException: How to transfert a Objectify Entity (with Key) through Restlet

橙三吉。 提交于 2019-12-11 11:37:31
问题 I am developping an Android Application, comunicating with a GAE server + Objectify DB. I choose Restlet for rest framework. I have a problem when I try to retrieve an Entity with a Key attribute. The server throws an error: org.codehaus.jackson.map.JsonMappingException: Direct self-reference leading to cycle (through reference chain: java.util.ArrayList[0]->com.my.model.MyMessage["senderKey"]->com.googlecode.objectify.Key["root"]) Here is my model (very simple): public class MyMessage

Restlet: How can I retrieve DTO with setting custom MediaType?

故事扮演 提交于 2019-12-11 03:16:52
问题 How can I send GET request for entity with custom MediaType ? For example I want to retrieve MyUserDTO and set MediaType to application/user+yml . For now I have two separated actions. I can retrieve entity: resource.get(MyUserDTO.class); and can retrieve string: resource.get(new MediaType("application", "user+yml"); But how to combine them? Or maybe there is some trick to configure Restlet to teach him how to work with custom MediaTypes. 回答1: In fact, you have the right approach but you don

RESTlet 2.1 can't get client certificate

无人久伴 提交于 2019-12-11 02:26:10
问题 I recently updated restlet to version 2.1 and I'm no longer able to get the client certificate. I'm using the new way to get client certificate List<Certificate> r = getRequest().getClientInfo().getCertificates(); I'm using CURL to send my authentication info curl -k -E admin.pem https://localhost:8111/profile -v Any idea why this doesn't work in restlet 2.1 ? 回答1: You should upgrade to version 2.2 which changed the internal HTTP connector and should restore this property. 来源: https:/

Sending restlet response in zip format

匆匆过客 提交于 2019-12-11 01:26:22
问题 I am trying to send my restlet response in zip format if it i slarger then a specific size. This is the link i got that help enabling the encoding service. But i still dont get the response in zip format. How can I enable GZIP compression of the JSON response entity on Reslet? Do i need to send something in the request header or make some other changes to get the response in zip format. Currently my restlet returns an object of a local class that is received at client side in json format. 回答1

Reading config files within Web-INF in RESTLET

故事扮演 提交于 2019-12-11 01:09:25
问题 I'm trying to read a config file placed inside the root path of WEB-INF. The application is using RESTLET framework. I read in the official RESTLET doc that its possible to read files via a WAR connector ("war:///WEB-INF/web.xml") using Context.getClientDispatcher(). However i was not able to figure out as to how this can be achieved. Kindly let me know about this or any other ways a file can be read using RESTLET 回答1: Found the solution for this. I had to access the ServletContext to get to

Running a RESTlet Tutorial, I'm receiving java.lang.NoClassDefFoundError

心不动则不痛 提交于 2019-12-08 17:40:25
问题 I'm trying to run the first server tutorial on RESTlet docs but i'm getting errors even though i added the jars to my classpath. I added org.restlet.jar and org.restlet.ext.* The code for the server is : package test; import org.restlet.Server; import org.restlet.data.Protocol; import org.restlet.resource.Get; import org.restlet.resource.ServerResource; public class Test extends ServerResource { public static void main(String[] args) throws Exception { // Create the HTTP server and listen on

How to register Jackson Jdk8 module in Restlet

假装没事ソ 提交于 2019-12-06 07:04:29
Is it possible to register the jackson-datatype-jdk8 module in the Restlet org.restlet.ext.jackson extension package? I need to take advantage of the new Optional feature. My guess is that it should be accessible through the converter services ( getConverterService() ) but I can't find anything in the documentation that suggests exactly how setting a module is possible. I eventually pieced together from a variety of sources an answer that works with Restlet 2.3. My guess is that this will be refactored for Restlet 3 and it won't work for versions < 2.3 so be aware that this solution will most

Android - First run of Restlet 2.2 server - No available server connector

泪湿孤枕 提交于 2019-12-06 06:48:15
问题 I´m trying to run my first Restlet server with this code: import org.restlet.Server; import org.restlet.data.Protocol; import org.restlet.resource.Get; import org.restlet.resource.ServerResource; public class WebServer extends ServerResource { /** * @param args * @throws Exception */ public WebServer() throws Exception { // Create the HTTP server and listen on port 8182 Server server = new Server(Protocol.HTTP, 8182, WebServer.class); server.start(); } @Get public String present() { return

Restlet streaming data

穿精又带淫゛_ 提交于 2019-12-03 07:32:25
问题 I have this task that I'm undertaking where I would be reading data from a device and make it available over a web service. The data is read 4 times a second. I want the web clients to be have an open HTTP connection and get the device readings as a stream using chunked transfer as long as the client keeps the connection open. As a proof of concept, I want to start with a service that constantly generates a random number, 4 times a second, wraps it in json and stream that to clients. I'm

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

限于喜欢 提交于 2019-12-03 06:38:25
问题 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