FAQ Database Discussion Community


How to I detrmine Which Version of Restlet API I am using?

java,java-ee,restlet
I am using a java restlet client server based architecture. How to I detrmine Which Version of Restlet API I am using ?...

@XStreamOmitField for Restlet GAE not working

java,google-app-engine,restlet
I have a POJO field annotated with @XStreamOmitField however when I look that the response of the ServerResource, the field is there. Here is the code I have (simplified): @Override public ItemDTO getStuff() { return stuff.getItem(); } Here's the POM config I have: <dependency> <groupId>org.restlet.gae</groupId> <artifactId>org.restlet</artifactId> <version>${version.restlet}</version> </dependency> <dependency> <groupId>org.restlet.gae</groupId>...

Java Restlet - How do I dynamically attach resources to the router?

java,resources,restlet,mashup
Here's the basics of what I'm trying to do. I'm working on a project where I'm creating a mashup page from various web APIs. The mashup page contains country information. I have a BLL layer where I create the mashup page (html page with country input using Chunk Library). This...

How to access RESTlet SuiteScript parameters using GET method

javascript,rest,restlet,netsuite
I was stuck on a problem which probably plenty of new SuiteScript hackers will. As writted on the official doc of SuiteScript p. 243, there's this JS for retrieve a record with GET method. // Get a standard NetSuite record function getRecord(datain) { return nlapiLoadRecord(datain.recordtype, datain.id); // e.g recordtype="customer", id="769"...

Restlet how to decode secret in HTTP basic authentication

java,rest,base64,jax-rs,restlet
I have the following class handling one of my routes: public class HotelsSrv extends ServerResource implements HotelsListResource { private String hotelId; @Override protected void doInit() throws ResourceException { super.doInit(); String str; String secret = getRequest().getChallengeResponse().getSecret().toString(); byte[] bytes = new BASE64Decoder().decodeBuffer(secret) str = new String(bytes); System.out.println("user: "+getRequest().getChallengeResponse().getIdentifier()); System.out.println("password: "+str); } I...

Restlet stop server after exactly one request is handled

java,restlet
I want to use Restlet to create a local server. This server should receive exaclty one request (besides favicon), and after that request is handled it should shut down. I don't want to use System.exit, I want it to shut down properly. As you can see in my code I...

How to attach a restlet to a partiular URL path scheme (HTTP or HTTPS)?

java,restlet
I'm using Restlet 2.3.2 I'd like to run a Restlet server with both HTTP and HTTPS protocols, but I'd like to attach a different restlet to each one. For exemple, restletUnsecure to HTTP but restletSecure to HTTPS. Actualy, attaching only one restlet to the path /test works properly. I tried...

Use restlet with Eclipse Virgo

java,spring,java-ee,restlet,eclipse-virgo
I am trying to integrate restlet in an application using Eclipse Virgo as the application server. As Virgo is based on OSGi, I had to use the org.restlet.osgi libraries and the newest version (restlet 2.2.3) that doesn't rely on Java 1.7 because the latest Virgo release complains about bundles depending...

Extending Restlet 2.3 ClientInfo

restlet,restlet-2.0
Is it possible to extend org.restlet.data.ClientInfo? I need a convenient way of adding a List<String> permissions to complement the existing List<Role> roles. In a perfect world I would be able to add List<Permission> permissions but the former is perfectly acceptable. I need to be able to get this from the...

Starting Jetty from Restlet in OSGi

java,jetty,osgi,restlet,equinox
I'm using Restlet in OSGi (equinox). I keep encountering a java.io.IOException: The thread blocked at the cyclic barrier has timed out. exception with the default HTTP server and so am trying to use Jetty instead. From reading various forums and articles, it seems that the correct way to use Jetty...

Have Restlet working alongside HTTP Servlets

java,servlets,jetty,restlet,java-server
In an existing Java SE project, my colleagues had implemented a bunch of web services in Restlet, relying on an internal server implementation. This turned out to be inadequate in the long run, so we migrated to a server engine based on jetty 9, with the great drawback that Restlet...

Unit testing a Restlet extractor

java,unit-testing,junit,restlet
I'm looking for some guidance on real unit testing for Restlet components, and specifically extractors. There is plenty of advice on running JUnit to rest entire endpoints, but being picky this is not unit testing, but integration testing. I really don't want to have set up an entire routing system...

Using Google authentication with Restlet

java,google-app-engine,restlet
I have this very basic authentication for my app: MapVerifier mapVerifier = new MapVerifier(); mapVerifier.getLocalSecrets().put("user", "pass".toCharArray()); ChallengeAuthenticator guard= new ChallengeAuthenticator(null, ChallengeScheme.HTTP_BASIC, "Secured Resources"); guard.setContext(getContext()); guard.setVerifier(mapVerifier); How do I adapt this to use Google authentication scheme? That, instead of showing the Username/Password browser popup, it will go to the Google authentication...

Spring & Reslet : is it possible to map a URL path component to a method argument?

restlet
I'm new to Restlet, but I've followed the tutorial on Restlet's own website and got a basic application up and running. What I'm doing right now is that I'm setting up a basic ServerResource and expose a @Get method. What I'd like is to be able to invoke /user/{userId} and...

Restlet converts JSON to LinkedHashMap instead of List?

java,json,restlet,restlet-2.0
This is what my Rest endpoint looks like @Post("json") public List<LogProcessorExpression> addLogProcessorExpression( final List<LogProcessorExpression> expressions) throws LPRestletException { if (expressions == null || expressions.isEmpty()) { return Collections.emptyList(); } final Integer currentTenantId = Utils.getCurrentTenantId(getRequest()); return customAttributesManager.addLogProcessorExpression(currentTenantId, expressions); } the method it calls looks like List<LogProcessorExpression>...

NoSuchMethodError: com.google.common.base.Stopwatch.createStarted()Lcom/google/common/base/Stopwatch

java,guava,restlet,apispark
My app is throwing NoSuchMethodError: com.google.common.base.Stopwatch.createStarted()Lcom/google/common/base/Stopwatch error. Not sure why, because 16.0.1 do contain that class, I've checked. From what I have researched, it looks like this is a bug? I also have this code for refernence, though I think this is not the issue: FirewallRule rule = new PeriodicFirewallCounterRule(60,...

Restlet using custom media type

java,json,restlet,restlet-2.0,media-type
In Restlet 2.3 (SE) I am trying to use media types to control versions. My current attempt involves registering new extensions in my inbound route: @Override public Restlet createInboundRoot() { ... getTunnelService().setExtensionsTunnel(true); getMetadataService().addExtension("vnd.myapp.v1", MediaType.valueOf("application/vnd.myapp.v1+json")); getMetadataService().addExtension("vnd.myapp.v2", MediaType.valueOf("application/vnd.myapp.v2+json")); ... } My resource interface is then setup as follows: public interface UsersResource {...

Restlet: can't locate static files through Directory

spring,file,static,restlet
Serving static files through Restlet is proving harder than it feels like it ought to be. I suspect some deep issue to do with context initialization, but I could be wrong. Basically, I have yet to be able to get any actual content served through a Directory although all the...

Restlet send “get” request to server and process response

java,https,restlet,apache-commons-httpclient
I would like to send a get request to a remote server using Restlet and receive the response (as Json). Here is my starting point, please feel free to complete: ClientResource cr = new ClientResource("https://"+url); JsonRepresentation r = (JsonRepresentation) cr.get(); r.getJsonObject().get("MY_VALUE"); Restlet version 2.1.7 Json: {"title":"General Terms & Conditions","version":"20022014_001"}...

Issue in deploying restlet based application on tomcat

tomcat,deployment,restlet
I am having issue in deploying restlet application on tomcat webserver. I am able to run the application directly from eclipse but when I deploy on tomcat I get issues like the following. May 10, 2015 10:04:32 AM org.apache.catalina.loader.WebappClassLoader loadClass INFO: Illegal access: this web application instance has been stopped...

restlet post getFirstValue always returns null

java,rest,jax-rs,restlet
I am using postman client to send RES request to this restless router: public Representation createAgent(Representation entity) { Form form = new Form(entity); String user = form.getFirstValue("user"); String password = form.getFirstValue("password"); System.out.println("user: "+ user); System.out.println("password: "+ password); System.out.println("form: "+ form.toString()); return (agent.save(getUser(),getPassword())) ? new StringRepresentation("user "+ user +" created", MediaType.TEXT_PLAIN)...

The right way to do Filtering with Restlet

java,restlet
Here is my Filter code that I need to fix. The idea behind the filter is that if some query string is found. Process it, no need to return or process the chain or something like that. However when no query string is found, the original request should be serviced,...

Restlet reuse InputStream

java,restlet
Consider the next code. Filter: public class InputFilter extends Filter { @Override protected int beforeHandle(Request request, Response response) { int result = CONTINUE; InputStream inputStream = request.getEntity().getStream(); StringWriter writer = new StringWriter(); IOUtils.copy(inputStream, writer, "UTF-8"); String theString = writer.toString(); JsonRepresentation jRep = new JsonRepresentation(theString); String token = jRep.getJsonObject().getString("token"); . ....

Restlet Filter Post request

java,restlet
I would like to filter a Post request in Filter (prior it getting to the Resource). To filter the request I want to retrieve a token from the bode request and do some testing on it. Current Resource: @Post public JsonRepresentation init(JsonRepresentation jRep) { String token = jRep.getJsonObject().getString("token"); . ....

How to get AJAX values in Java

java,ajax,restlet
I'm doing an ajax call to my server, and need to get the values from it. How is this done? This is the ajax: $.ajax({ type: "POST", url: "http://localhost:8080/myapp/etc", contentType: "application/json; charset=utf-8", data: {"id": "1", "somekey": "somevalue"}, dataType: "json", async: "true", success: function(msg) { alert("success " + msg); }, error:...

Restlet - safely (thread wise) passing information from Filter to Resource

java,restlet
I would like to pass (additional) information from a Filter to a Resource. The way I try to do it currently is, in the Filter: getContext().getAttributes().put("additionalInformation", "info.."); and retrieve it in the Resource: getContext().getAttributes().get("additionalInformation"); Questions: Is this the best way to pass data from filter to resource? Is this way...

Restlet Content Type Negotiation

java,mime-types,content-type,restlet,media-type
It's common for APIs to support various forms of content negotiation: Accept HTTP header on the Request, Content-Type HTTP header on the Request (although I don't think conforms to standards), and deriving the expected type from the file extension. I'd like my Restlet REST API to support all of these,...

Limit request on a Restlet resource with APISpark restlet extension

java,restlet,apispark
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...

Remove '@class' in XStream for Java primitive types

java,serialization,restlet,xstream
I have this field in a POJO that is serialized into JSON: @XStreamAlias("tags") List<String> tags; My problem is that the output looks like this: "tags": [ { "@class": "linked-list", "string": [ "test", "test2" ] } ], In what way that the output would look like this: "tags": [ "test", "test2"...

Failed NetSuite RESTlet authentication

javascript,authentication,restlet,netsuite
I'm trying to develop in NetSuite a simple form portlet submitting to a RESTlet in the back end. Here's my form portlet: function workManagerPortlet(portlet, column) { portlet.setTitle('Portlet'); portlet.addField(....) // INSERT HERE ALL THE FORM FIELDS portlet.setSubmitButton(nlapiResolveURL('RESTLET', 'customscript_gw_ss_form_backend', 'customdeploy_wm_form_backend', true), 'Submit', '_hidden'); } When I click on submit I can see...

Restlet conditional routing to different resources

java,restlet
I have a POST request that I would like to assign to different Resources depending on the body content. If the body contains a non empty token: "token":"1q2w3e4r5t" then I would like to rout the request to TokenedResource, otherwise rout to NonTokenResource. I thought using Filter (@beforeHandle) for it, but...

RESTlet ClientResource with progress bar

android,file-upload,restlet,android-progressbar,clientresource
I'm creating an android app which is uploading files to RESTlet server. I'm using below code. Representation file = new FileRepresentation(filePath, MediaType.IMAGE_ALL); FormDataSet form = new FormDataSet(); form.setMultipart(true); form.getEntries().add(new FormData("file", file)); ClientResource cr = new ClientResource(url); cr.post(form); The question is: How can I monitor uploading process?...

Use router in Rest API - java

java,rest,restlet
package firstREST; import org.restlet.Application; import org.restlet.Component; import org.restlet.Restlet; import org.restlet.data.Protocol; import org.restlet.routing.Router; public class Faculty extends Application { public static void main(String[] args) { Component comp = new Component(); comp.getServers().add(Protocol.HTTP, 8080); Application app = new Faculty(); comp.getDefaultHost().attach(app); try { comp.start(); } catch (Exception e) { // TODO Auto-generated catch block...

File Upload with Description in Restlet

java,file-upload,restlet
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"...

Spring & Restlet : 100% XML configuration?

spring,restlet,xml-configuration
I'm working on a project where all configurations are kept in XML files. I'm about to begin on a smaller part of this project, and I'll be using Restlet for that. Basically, what I'd like to do is to create a few subclasses of ServerResource. I could use annotations to...

Issue trying to expose a Restlet service from Android activity

android,restlet
I'm trying to create a Restlet service as follows (as per the instructions in the Restlet in Action book): @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Component component = new Component(); component.getServers().add(Protocol.HTTP, 8182); component.getDefaultHost().attachDefault(HttpListener.class); try { component.start(); } catch (Exception e) { throw new RuntimeException(e); } } The permissions...

Chrome under Windows 7 and 8 cannot connect to embedded Jetty 9.2.x over HTTPS

google-chrome,https,operating-system,restlet,embedded-jetty
We're using Jetty 9.2.x in the embedded mode in conjunction with Restlet 2.3.1 to develop our application sever. Recently we've enabled support for HTTPS, which utilises a certificated signed by a self-established CA. Everything seemed to be working correctly when connecting to this server from various web browsers under Linux...

Odata Restlet code generation failed

java,eclipse,odata,restlet
public static void main(String[] args) { // TODO Auto-generated method stub String[] arguments = { "http://services.odata.org/V4/Northwind/Northwind.svc/", "src/com" }; Generator.main(arguments); } Output: --------------------------- OData client code generator --------------------------- step 1 - check parameters step 2 - check the ouput directory step 3 - get the metadata descriptor Starting the internal HTTP...

How to get the response data from cloud to string

java,json,gson,google-cloud-storage,restlet
I want to get the response to a string variable from the data from the cloud. ClientResource cr = new ClientResource("http://localhost:8888/users"); cr.setRequestEntityBuffering(true); try { try { cr.get(MediaType.APPLICATION_JSON).write(System.out); } catch (IOException e) { e.printStackTrace(); } } catch (ResourceException e) { // TODO Auto-generated catch block e.printStackTrace(); } I have response as...

How to determine field type in Netsuite Suite Script?

restlet,netsuite
I am creating a RESTlet that is used to update fields in a Netsuite entity. This works no problem for standard Text fields in Netsuite yet for updating Date fields it requires a seperate method, and updating List fields requires knowing the enum value. My question is, in my RESTlet,...

Restlet Authorization by Method AND User

java,authentication,authorization,restlet
I'm new to Restlet and REST in general and want to implement a RESTful API for a running server / database. Routing and addressing seems to work fine so far but I'll need a few hints at how to handle authentication and authorization. The situation: There are some resources with...

Restlet CorsFilter with ChallengeAuthenticator

angularjs,authentication,cors,restlet
I'm building a RESTful API with the Restlet framework and need it to work with cross domain calls (CORS) as well as basic authentication. At the moment I'm using the CorsFilter which does the job of making my webservice support CORS requests. But, when I try to use this with...

Sending json as data with GET call

java,curl,httpurlconnection,restlet
I can see that the following curl command works remotely: curl -X GET -d '{"begin":22, "end":33}' http://myRemoteApp.com:8080/publicApi/user/test/data However as per the docs at http://curl.haxx.se/docs/manpage.html, -d, --data (HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user...

Restlet in OSGI can not find com/sun/net/httpserver/HttpHandler

java,osgi,restlet,restlet-2.0
I am trying to use Restlet in embedded OSGi environment. I have added the org.restlet.jar version 2.3.0 in the class path of my restlet test bundled. But it kept giving me the following error. java.lang.NoClassDefFoundError: com/sun/net/httpserver/HttpHandler The documentation says that this jar should be enough but it is currently not...