You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by Florian Roth <Fl...@in-gmbh.de> on 2009/12/02 15:23:22 UTC
How to return 201 jax-rs on posing new object
Hi,
want to implement jax-rs post object. How do I return 201 I tried this but does not work. Ends in some parsing exceptions. Can you help me?
protected Response getAbderaPostEntry(int skipSegments) {
RequestContext requestContext = getRequestContext(skipSegments);
CollectionAdapter adapter = getAbderaCollectionAdapter(requestContext);
if (adapter == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
ResponseContext con=adapter.postEntry(requestContext);
try {
URI uri=con.getLocation().toURI();
return Response.created(uri).build();
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//return Response.ok(con).build();
return Response.status(Response.Status.BAD_REQUEST).build();
}
Best regards
Florian Roth
in-integrierte informationssysteme GmbH
Am Seerhein 8 • 78467 Konstanz
http://www.in-gmbh.de/ • mailto:info@in-gmbh.de
Telefon: +49 7531 8145-0
Telefax: +49 7531 8145-81
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
Sitz der Gesellschaft: Konstanz • Amtsgericht Freiburg i.B. • Registernummer: HRB 380976 • Geschäftsführer: Siegfried Wagner
AW: How to return 201 jax-rs on posing new object
Posted by Florian Roth <Fl...@in-gmbh.de>.
:D I figgured it out. Do it like this:
protected Response getAbderaPostEntry(int skipSegments) {
RequestContext requestContext = getRequestContext(skipSegments);
CollectionAdapter adapter = getAbderaCollectionAdapter(requestContext);
if (adapter == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
ResponseContext responseContext = adapter.postEntry(requestContext);
URI uri = null;
try {
uri = requestContext.getUri().toURI();
} catch (URISyntaxException e) {
log.error("Error: Could not get uri from requestContext", e);
e.printStackTrace();
}
return Response.created(uri).entity(responseContext).build();
}
Chears
Florian
-----Ursprüngliche Nachricht-----
Von: Florian Roth [mailto:Florian.Roth@in-gmbh.de]
Gesendet: Mittwoch, 2. Dezember 2009 15:23
An: chemistry-dev@incubator.apache.org
Betreff: How to return 201 jax-rs on posing new object
Hi,
want to implement jax-rs post object. How do I return 201 I tried this but does not work. Ends in some parsing exceptions. Can you help me?
protected Response getAbderaPostEntry(int skipSegments) {
RequestContext requestContext = getRequestContext(skipSegments);
CollectionAdapter adapter = getAbderaCollectionAdapter(requestContext);
if (adapter == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
ResponseContext con=adapter.postEntry(requestContext);
try {
URI uri=con.getLocation().toURI();
return Response.created(uri).build();
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//return Response.ok(con).build();
return Response.status(Response.Status.BAD_REQUEST).build();
}
Best regards
Florian Roth
in-integrierte informationssysteme GmbH
Am Seerhein 8 . 78467 Konstanz
http://www.in-gmbh.de/ . mailto:info@in-gmbh.de
Telefon: +49 7531 8145-0
Telefax: +49 7531 8145-81
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
Sitz der Gesellschaft: Konstanz . Amtsgericht Freiburg i.B. . Registernummer: HRB 380976 . Geschäftsführer: Siegfried Wagner