restlet

Limit request on a Restlet resource with APISpark restlet extension

狂风中的少年 提交于 2019-12-02 11:15:32
Here's my code to limit the number of request for minute: MethodAuthorizer ma = createMethodAuthorizer(); ma.setNext(router); FirewallRule rule = new PeriodicFirewallCounterRule(60, TimeUnit.SECONDS, new IpAddressCountingPolicy()); ((PeriodicFirewallCounterRule)rule).addHandler(new RateLimitationHandler(new UniqueLimitPolicy(10))); FirewallFilter firewallFiler = new FirewallFilter(getContext(), list(rule)); firewallFiler.setNext(ma); return ma; The problem is that there is no error, but even if more than 10 request is requested from the resource still it does not throw "Too Many Request" I

XML & JSON web api : automatic mapping from POJOs?

百般思念 提交于 2019-12-02 09:34:28
I'm about to start on a small project which goal is to end up with a web xml/json api. I'll be writing it in Java, and I'll be using the restlet library. How do I approach the xml/json duality? I know I can use JAXB to "convert" pojos to xml (and back), but how do I automate this for json? Is there any functionality in the restlet library I can leverage? Restlet allows you to directly work with POJOs within your server resources at the level of REST annotated methods, as described below: public class MyServerResource extends ServerResource { @Get public List<MyPojo> getList() { List<MyPojo>

Restlet 2.0.8 with the Jetty connecter doesn't resume SSL sessions, while the Simple connecter does

假如想象 提交于 2019-12-02 08:32:17
Does anyone know why this is, or how to fix it? I'm using an android to connect via httpclient - the Simple connector resumes the connection just fine, but Jetty performs a new handshake each time ! The code is the same, it's just what connecter I've got on the build path. Continually redoing the handshake uses up a ridiculous amount of data and battery - the problem is that I require client authentication, which as I've discovered doesn't work properly with the Simple connecter. Is there something I'm missing here? I'm using the standard connection set up as below. component = new Component()

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

ArrayList<Object> JSON

喜欢而已 提交于 2019-12-02 04:43:10
问题 I am trying to return JSON data with my restlet. I can return a single item's JSON with.. import org.json.JSONObject; Site aSite = new Site().getSite(); JSONObject aSiteJson = new JSONObject(aSite); return aSiteJson.toString(); Returns: {"name":"qwerty","url":"www.qwerty.com"} How do i return JSON for ArrayList Object ArrayList<Site> allSites = new SitesCollection().getAllSites(); JSONObject allSitesJson = new JSONObject(allSites); return allSitesJson.toString(); Returns: {"empty":false}

Empty uri in rest response

核能气质少年 提交于 2019-12-02 04:17:48
问题 I am developing a plugin for nexus oss .My app creates a rest call response(to a request from server) . But when the server receives it , it throws error as follows javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"com.collabnet.teamforge.ia.types.GetConfigurationParametersResponse"). Expected elements are \lt{http://www.collab.net/teamforge/integratedapp}CreateProjectConfigurationRequest\gt, \lt{http://www.collab.net/teamforge/integratedapp

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

Empty uri in rest response

↘锁芯ラ 提交于 2019-12-02 00:59:50
I am developing a plugin for nexus oss .My app creates a rest call response(to a request from server) . But when the server receives it , it throws error as follows javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"com.collabnet.teamforge.ia.types.GetConfigurationParametersResponse"). Expected elements are \lt{http://www.collab.net/teamforge/integratedapp}CreateProjectConfigurationRequest\gt, \lt{http://www.collab.net/teamforge/integratedapp}GetConfigurationParametersRequest\gt, \lt{http://www.collab.net/teamforge/integratedapp}GetConfigurationParametersResponse\gt, \lt

ArrayList<Object> JSON

橙三吉。 提交于 2019-12-01 23:02:40
I am trying to return JSON data with my restlet. I can return a single item's JSON with.. import org.json.JSONObject; Site aSite = new Site().getSite(); JSONObject aSiteJson = new JSONObject(aSite); return aSiteJson.toString(); Returns: {"name":"qwerty","url":"www.qwerty.com"} How do i return JSON for ArrayList Object ArrayList<Site> allSites = new SitesCollection().getAllSites(); JSONObject allSitesJson = new JSONObject(allSites); return allSitesJson.toString(); Returns: {"empty":false} ArrayList<Site> allSites = new SitesCollection().getAllSites(); JSONArray allSitesJson = new JSONArray

Streaming data from client with HTTP Post

北慕城南 提交于 2019-12-01 16:28:49
I would like to stream data from the client to the server. My application streams audio data to the server. I do not know how long the audio will be when I begin streaming it. I want to reduce latency by transmitting the data as it is being recorded. Once all the data has been uploaded, then I will process it. So, what I would like is a HTTP POST where the body is streamed. At the client, the POST would be sent as the data is available. At the server end, I would like it to arrive like a normal POST with a complete body of collected data. I am currently using Restlet, and implementing my