Richard Berger | 9 Feb 20:32
Gravatar

Post problems when using Restlet Javascript Edition...

Working on a small project to learn REST/Restlet and ran into a problem where
I can successfully post from a Java client to my server or from an HTML form
to my server, but when I try to post from Javascript it fails.  I am
following the sample code that is now on
github
(https://github.com/restlet/restlet-framework-js/tree/master/tests/org.restlet.js.tests/src/browser/static/html).

On the client side...
For Java (working), I have:
    System.out.println("Adding a commitment");
		ClientResource client3 = new
ClientResource("http://localhost:8888/commitments/");
		client3.setRequestEntityBuffering(true);  // Per
http://stackoverflow.com/questions/6462142/length-required-411-length-required-in-a-restlet-client
		Commitment commitment3 = new Commitment();
		commitment3.setTitle("Added through post - Java client");
		commitment3.setDescription("This is a description of post Java client");
		Representation representation3 = client3.post(commitment3);

For Javascript (not working), I have: 		 
asyncTest("Post with resource Commitment (json)", function() {
  var clientResource = new ClientResource("/commitments/");
  var commitment = {
	title: "From automated test",
	description: "This is from our automated test"
  }
  var jsonRepresentation = new JsonRepresentation(commitment);
  alert(jsonRepresentation.getText());
  // Result is: {"title":"From automated test","description":"This is from
our automated test"}
(Continue reading)

Michael Kaye | 9 Feb 20:54
Picon

How to set response header

Previous to the 2.0.11, I was able to set the responseHeaders as follows.

Form responseHeaders = (Form) getResponse().getAttributes().get("org.restlet.http.headers");  

if ( responseHeaders == null ) {
        	responseHeaders = new Form();
        	getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);  
    	}
responseHeaders.add("Access-Control-Allow-Origin", "*");

Now, I get the following runtime error,

java.lang.ClassCastException: org.restlet.data.Parameter cannot be cast to org.restlet.engine.header.Header

How should I set response headers now?

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2920188

Thomas Mortagne | 9 Feb 14:38
Picon
Gravatar

Put request without any mime type

Hi,

I have a @PUT service accepting any mime type as input. It just
manipulate it as byte[].

public Response putAttachment(@PathParam("wikiName") String wikiName,
@PathParam("spaceName") String spaceName,
        @PathParam("pageName") String pageName,
@PathParam("attachmentName") String attachmentName, byte[] content)

I recently upgraded from Restlet 1.1.10 to Restlet 2.0.11 and now the
following does not work anymore:

curl -u Admin:admin -T /home/test.pdf
http://127.0.0.1/xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome/attachments/foo.pdf

but it's working well with

curl -u Admin:admin -T /home/test.pdf
http://127.0.0.1/xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome/attachments/foo.pdf
-H "Content-Type:any/thing"

I debugged a bit and as far as I can see when no mime type is provided
the MediaType extracted from the entity is null in
org.restlet.ext.jaxrs.internal.wrappers.params.EntityGetter#getValue()
and whatever the supported mime type is
org.restlet.data.MediaType#isCompatible always return false if the
parameter is null even for the default @Consume which is  supposed to
mean anything ("*/*").

(Continue reading)

Picon
Gravatar

Switch Guards

Hi!

Our App has some Resources guarded by an Authenticator which uses our own
Challenge Scheme (OAuth-Mac-Tokens).
Now we also want to have clients, who can access the same resources but not
using the Mac-Tokens, but plain Bearer-Tokens.
The way i would do this, is to create a new Challenge Scheme and a second
guard, and dynamically switch the guards before the route depending on what
Challenge Scheme a request uses.
Unfortunately I don't know if this is possible or how I can do this.
Can somebody point me in the right direction?

Regards,
Sebastian

--
View this message in context: http://restlet-discuss.1400322.n2.nabble.com/Switch-Guards-tp7266201p7266201.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2919474

John Wismar | 6 Feb 23:20

Getting configuration information from context.xml, environment, or somewhere else?

Hey, all-

 

(I’m using Restlet JEE 2.x, Tomcat7, JavaSE7.) I have my app running as a servlet in Tomcat. Ideally, I would like to be able to copy the .war file from one environment to another without recompiling or repackaging. I’m trying to figure out how to retrieve information from outside the WAR, whether it be from that Tomcat instance’s context.xml, or the server’s environment, or some other location.

 

I thought I might be able to use the app’s ServletContext, but I can’t find my various settings inside that – if I’m even looking the right way. (I can get environment-agnostic settings from web.xml already.)

 

Is there a preferred method of getting this type of information?

 

Thanks!

 

--------------------------

John Wismar

Alldata Technology

916-478-3296

 

Gabriel Pulido | 6 Feb 15:19
Picon

ObjectRepresentation with int negative returns null

Hello,

I've attached a file with a very simple example based in the restlet example from the restlet web.

In this example a very simple server is run that exposes the Contact resource as a Java Object representation.
If the Contact resource that is retrieved by the client has any int field with a negative value (in the
example attached I've changed the age field on the ContactServerResorce to be a "-1" ) then when the client
tries to retrieve the Contact, it is always null.
If the age field is positive the contact is retrieved without problem.
I've test this in windows and linux, JDK 1.6 and JDK1.7, with restletjse2.1RC2 and the nightshot. Also with
the 2.0.10, and it always is null if any integer is negative in the POJO.

Also if I change the int for a double, it works. 
This is making me crazy.
Can anybody help me please?
Thank you in advance
Gabriel
PD: the attached file is a netbeans project, however it is not need to compile the source.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2918603
Attachment (RestTestServer.rar): application/octet-stream, 669 KiB
Bjorn Roche | 5 Feb 19:32
Favicon
Gravatar

Redirecting from http to https

I have a restlet-based app running on heroku that I want to use SSL. Heroku has a "piggyback" option which
processes SSL connections for you. As far as I can tell, it works like this: Heroku processes the SSL
connection, and redirects the call to a normal, unencrypted connection on port 80 and sets
HTTP_X_FORWARDED_PROTO header to https. (I assume that incoming calls with HTTP_X_FORWARDED_PROTO
are stripped.)

This works fine for allowing https, but I want to require it. I see the Redirector class, but it's not clear to
me if I can use this class to solve this problem. Any suggestions? Thanks!

bjorn

PS I was previously running my app using GAE, which used a servlet container, so I could specify
"CONFIDENTIAL" in web.xml. I am not using a servlet container anymore.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2918332

Domnic | 2 Feb 17:04
Picon
Favicon
Gravatar

AWS and Freemaker + Restlet

Hi there,
I am trying to use a Freemaker template with a restlet Resource. this runs fine on local host i.e. on a
standalone java. But when I try to export a WAR out of it.I get the following error while deployment.

WARNING: Exception or error caught in server resource
java.lang.AbstractMethodError: org.restlet.engine.converter.ConverterHelper.score(Ljava/lang/Object;Lorg/restlet/representation/Variant;Lorg/restlet/resource/Resource;)F
	at org.restlet.engine.converter.ConverterUtils.getBestHelper(ConverterUtils.java:137)
	at org.restlet.service.ConverterService.toRepresentation(ConverterService.java:229)
	at org.restlet.resource.Resource.toRepresentation(Resource.java:738)
	at org.restlet.resource.ServerResource.doHandle(ServerResource.java:509)
	at org.restlet.resource.ServerResource.get(ServerResource.java:695)
	at org.restlet.resource.ServerResource.head(ServerResource.java:977)
	at org.restlet.resource.ServerResource.doHandle(ServerResource.java:587)
	at org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:637)
	at org.restlet.resource.ServerResource.doConditionalHandle(ServerResource.java:336)
	at org.restlet.resource.ServerResource.handle(ServerResource.java:899)
	at org.restlet.resource.Finder.handle(Finder.java:243)
	at org.restlet.routing.Filter.doHandle(Filter.java:156)
	at org.restlet.routing.Filter.handle(Filter.java:203)
	at org.restlet.routing.Router.doHandle(Router.java:428)
	at org.restlet.routing.Router.handle(Router.java:645)
	at org.restlet.routing.Filter.doHandle(Filter.java:156)
	at org.restlet.routing.Filter.handle(Filter.java:203)
	at org.restlet.routing.Filter.doHandle(Filter.java:156)
	at org.restlet.routing.Filter.handle(Filter.java:203)
	at org.restlet.routing.Filter.doHandle(Filter.java:156)
	at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:151)
	at org.restlet.routing.Filter.handle(Filter.java:203)
	at org.restlet.routing.Filter.doHandle(Filter.java:156)
	at org.restlet.routing.Filter.handle(Filter.java:203)
	at org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:208)
	at org.restlet.engine.application.ApplicationHelper.handle(ApplicationHelper.java:81)
	at org.restlet.Application.handle(Application.java:378)
	at org.restlet.routing.Filter.doHandle(Filter.java:156)
	at org.restlet.routing.Filter.handle(Filter.java:203)
	at org.restlet.routing.Router.doHandle(Router.java:428)
	at org.restlet.routing.Router.handle(Router.java:645)
	at org.restlet.routing.Filter.doHandle(Filter.java:156)
	at org.restlet.routing.Filter.handle(Filter.java:203)
	at org.restlet.routing.Router.doHandle(Router.java:428)
	at org.restlet.routing.Router.handle(Router.java:645)
	at org.restlet.routing.Filter.doHandle(Filter.java:156)
	at org.restlet.routing.Filter.handle(Filter.java:203)
	at org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:208)
	at org.restlet.Component.handle(Component.java:389)
	at org.restlet.Server.handle(Server.java:513)
	at org.restlet.engine.ServerHelper.handle(ServerHelper.java:69)
	at org.restlet.engine.adapter.HttpServerHelper.handle(HttpServerHelper.java:149)
	at org.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:1086)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:647)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
	at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:864)
	at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
	at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1665)
	at java.lang.Thread.run(Thread.java:636)

My web.xml looks like

 
	<context-param>
		<param-name>org.restlet.application</param-name>
		<param-value>com.aws.resource.AlertApplication</param-value>
	</context-param>

	<servlet>
		<servlet-name>ServerServlet</servlet-name>
		<servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>	
		<init-param>
             <param-name>org.restlet.clients</param-name>
             <param-value>HTTP CLAP</param-value>
         </init-param>	
	</servlet> 
	<servlet-mapping>
		<servlet-name>ServerServlet</servlet-name>
		<url-pattern>/*</url-pattern>
	</servlet-mapping> 
</web-app>

could some one guide me thru this.. esp. in relation to servlet deployment on tomcat ?
thanks
Domnic

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2917527

gaoyong | 2 Feb 04:21
Favicon
Gravatar

about org.restlet.data.request

org.restlet.data.request
in which realease version ???
Jeremy M | 1 Feb 18:48
Picon
Gravatar

OData Extension Socket Timeout Setting

I'm looking for a way to set the socketTimeout parameter when using the OData extension.  I tried setting the
parameter through the Client object obtained through the ClientResource:

        Client client = (Client) cr.getNext();
        client.setContext(new Context());
        client.getContext().getParameters().add("socketTimeout", "1");

by overriding org.restlet.ext.odata.Service.createResource(), but it seems the Service constructor
has already created the Client instance in the constructor so this parameter has no effect.

I've also tried setting and modifying the current Context before even creating the Service instance:

        Context.setCurrent(new Context());
        Context.getCurrent().getParameters().add("socketTimeout", "1");

but that's not working either

Is there a way to do this without having to modify the org.restlet.ext.odata.Service constructor where I
guess I would pass an appropriate Context object at the time of instantiation?

Thanks,

Jeremy

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2916968

Tomasz Kaczynski | 1 Feb 00:26
Gravatar

gwt compiler can't see org.restlet.ext.html.FormDataSet

Hello, 

I used FormDataSet class to schedule post operation but the gwt compiler is complaining:

Compiling module com.tk.gwt.ubscart.Ubscart
   Validating newly compiled units
      Ignored 1 unit with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
   Finding entry point classes
      [ERROR] Errors in
'file:/D:/gwt-cart/ubscart/src/com/tk/gwt/ubscart/client/PaypalCheckout.java'
         [ERROR] Line 59: No source code is available for type org.restlet.ext.html.FormDataSet; did you forget
to inherit a required module?
         [ERROR] Line 61: No source code is available for type org.restlet.ext.html.FormData; did you forget to
inherit a required module?
      [ERROR] Unable to find type 'com.tk.gwt.ubscart.client.Ubscart'
         [ERROR] Hint: Previous compiler errors may have made this type unavailable
         [ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a
module may not be adding its source path entries properly

I use  com.google.gwt.eclipse.sdkbundle_2.4.0.v201201120043-rel-r37 and restlet 2.1-RC2-JEE. In my 
Ubscart.gwt.xml  file I already inherit following modules:

	<inherits name="org.restlet.Restlet"/>
	<inherits name="org.restlet.JSON"/>
	<inherits name="org.restlet.XML"/>

I couldn’t find how to inherit the .html module gwt compiler is complaining about. 
I run my application in GWT development mode. I checked Eclipse Run configuration that
org.restlet.ext.html is included in the classpath and also that Eclipse can access source code for the org.restlet.ext.html.FormDataSet.

Any suggestion what to do next?

--tomekka

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2913721


Gmane