restlet

Restlet implementing post with json receive and response

那年仲夏 提交于 2019-12-03 03:41:51
First, what i wanted to know is what i am doing is the right way to do it. I have a scenario where i have will receive a json request and i have to update the database with that, once the db is updated i have to respond back with the json acknowledgment. What i have done so far is create the class extending application as follows: @Override public Restlet createRoot() { // Create a router Restlet that routes each call to a // new instance of ScanRequestResource. Router router = new Router(getContext()); // Defines only one route router.attach("/request", RequestResource.class); return router;

Guide to use Restlet Swagger extension for GAE

匿名 (未验证) 提交于 2019-12-03 01:42:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I tried to do a similar approach: public Restlet createInboundRoot() { Router apiRouter = createApiRouter(); attachSwaggerSpecificationRestlet(apiRouter, "/api-docs"); return apiRouter; } When /api-docs is access Restlet throws Error 404, what could be messing. The idea is that the apiRouter we have is fully working at this state, when we acess resource like /stuff etc. What could be missing in this code? Or is there any specific notes to take into consideration when using Restlet Swagger extension for GAE? 回答1: I tested your usecase and I

Restlet POST using JSON

匿名 (未验证) 提交于 2019-12-03 01:12:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How do I implement Restlet function which accepts JSON post? And how do I test this using curl? Thanks 回答1: With Restlet 2, you can either: test the entity media-type compatibility in @Post acceptRepresentation(Representation entity) : @Post public Representation acceptRepresentation(Representation entity) throws ResourceException { if (entity.getMediaType().isCompatible(MediaType.APPLICATION_JSON)) { // ... } // ... } or use @Post with one or two parameters: @Post("json") Representation acceptAndReturnJson(Representation entity) { // ... }

Restlet javax.net.ssl.SSLHandshakeException: null cert chain

柔情痞子 提交于 2019-12-03 00:01:52
I am testing SSL communication between client and server locally. So I generated certificate using OpenSSL commands. Added this certificate in cacert file. Also generated .p12 file. I am using the same .p12 file in server and client. This is the server code Server server = component.getServers().add(Protocol.HTTPS, port); Series<Parameter> params = server.getContext().getParameters(); params.add("keystorePath", ".p12 file path"); params.add("keystoreType", "PKCS12"); params.add("needClientAuthentication","true"); component.getDefaultHost().attach("", "/AA"), new AAClass()); component.start();

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

梦想的初衷 提交于 2019-12-02 23:37:06
问题 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

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

Limit request on a Restlet resource with APISpark restlet extension

余生颓废 提交于 2019-12-02 17:38:27
问题 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

File Upload with Description in Restlet

瘦欲@ 提交于 2019-12-02 15:58:04
问题 I need to upload a file with some additional data using restlet . So i create a sample html page like below. <html> <body> <h1>*****Upload File with RESTFul WebService*****</h1> <form action="http://localhost:8080/test/api/streams/sample.json" method="post" enctype="multipart/form-data"> <fieldset> <legend>Upload File</legend> <input type="file" name="fileToUpload"/><br /> <br /><br /> Party ID<input type="text" name="mybody" /><br /> <input type="submit" name="Upload" id="Upload" value=

XML & JSON web api : automatic mapping from POJOs?

天涯浪子 提交于 2019-12-02 14:23:24
问题 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? 回答1: Restlet allows you to directly work with POJOs within your server resources at the level of REST annotated methods, as described below:

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