Tag Archives: rest

RESTful on Play! framework

Questions: We are planning a project primarily serving content to mobile apps, but need to have a website. My question is whether is makes sense to use Jersey or Restlet to develop REST APIs for our mobile apps, and then use Play! to serve the website. Or does it make more sense to just use… Read More »

Java RestFull WebService: JAX-RS implementation with Jersey 2.3.1 libraries

Questions: I am trying to run a simple “Hallo World” application Jersey 2.3.1 REST service on JBoss jboss-eap-6.1 AS. In web.xml i have disabled restEasy library. During deployment i am getting the error: JBWEB000289: Servlet com.sun.jersey.samples.helloworld.resources.MyApplication threw load() exception: java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map; In POM i put these dependencies: <dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-server</artifactId> <version>2.3.1</version> </dependency> <dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-servlet-core</artifactId>… Read More »

User authentication on a Jersey REST service

Questions: I am developing a REST application, which is using the Jersey framework. I would like to know how I can control user authentication. I have searched many places, and the closest article I have found is this: http://weblogs.java.net/blog/2008/03/07/authentication-jersey. However this article can only be used with a GlassFish server and an attached database. Is… Read More »

Get list of JSON objects with Spring RestTemplate

Questions: I have two questions: How to map a list of JSON objects using Spring RestTemplate. How to map nested JSON objects. I am trying to consume https://bitpay.com/api/rates, by following the tutorial from http://spring.io/guides/gs/consuming-rest/. Answers: Maybe this way… ResponseEntity<Object[]> responseEntity = restTemplate.getForEntity(urlGETList, Object[].class); Object[] objects = responseEntity.getBody(); MediaType contentType = responseEntity.getHeaders().getContentType(); HttpStatus statusCode = responseEntity.getStatusCode();… Read More »

RESTful Authentication via Spring

Questions: Problem: We have a Spring MVC-based RESTful API which contains sensitive information. The API should be secured, however sending the user’s credentials (user/pass combo) with each request is not desirable. Per REST guidelines (and internal business requirements), the server must remain stateless. The API will be consumed by another server in a mashup-style approach.… Read More »

How do I restrict JFileChooser to a directory?

Questions: I want to limit my users to a directory and its sub directories but the “Parent Directory” button allows them to browse to an arbitrary directory. How should I go about doing that? Answers: You can probably do this by setting your own FileSystemView. Questions: Answers: Incase anyone else needs this in the future:… Read More »

Problems Resteasy 3.09 CorsFilter

Questions: I tried to use the new CorsFilter which is available in Resteasy 3.0.9. I found an example at the bottom of this page: Ajax request with JAX-RS/RESTEasy implementing CORS If I define this filter in the method getSingletons() (of the Application subclass) , then my Resources don’t get scanned anymore. That means that no… Read More »

Getting “NoSuchMethodError: org.hamcrest.Matcher.describeMismatch” when running test in IntelliJ 10.5

Questions: I’m using JUnit-dep 4.10 and Hamcrest 1.3.RC2. I’ve created a custom matcher that looks like the following: public static class MyMatcher extends TypeSafeMatcher<String> { @Override protected boolean matchesSafely(String s) { /* implementation */ } @Override public void describeTo(Description description) { /* implementation */ } @Override protected void describeMismatchSafely(String item, Description mismatchDescription) { /* implementation… Read More »

Gmail REST API : 400 Bad Request + Failed Precondition

Questions: I’m trying to send mails based on Gmail REST API using google java api services. I have configured through Google Develover Console an application client and downloaded p12 and json files. I have used this sample programs, https://developers.google.com/gmail/api/guides/sending#sending_messages… This sample works, but this is based on GoogleAuthorizationCodeFlow. I want just to work from server-to-server,… Read More »

Clearest way to comma-delimit a list?

Questions: What is the clearest way to comma-delimit a list in Java? I know several ways of doing it, but I’m wondering what the best way is (where “best” means clearest and/or shortest, not the most efficient. I have a list and I want to loop over it, printing each value. I want to print… Read More »